Game Development Community

scripts methods questions

by Gabe Zingaretti · in General Discussion · 01/28/2003 (9:01 pm) · 3 replies

hi all,

here is my question:
"function ShapeBase::damage(%this, %sourceObject, %position, %damage, %damageType)
{
// All damage applied by one object to another should go through this
// method. This function is provided to allow objects some chance of
// overriding or processing damage values and types. As opposed to
// having weapons call ShapeBase::applyDamage directly.
// Damage is redirected to the datablock, this is standard proceedure
// for many built in callbacks.
%this.getDataBlock().damage(%this, %sourceObject, %position, %damage, %damageType);
}"


shapebase is a class in C++. damage is a method. How and where does the code know that it needs to be called?

thanks a bunch

#1
01/29/2003 (8:04 am)
In ShapeBase.h and ShapeBase.cc you will find a lot of macros referring to CLASS and such, as well as to the console. These are what ties the scripting engine to the C++ code. Search the source for a script method, and you'll find a line in C++ which defines it.
#2
01/29/2003 (8:09 am)
could you give me an example? I looked for stuff but the entries I found have a different parameters than what the script uses.

thanks,

Gabe
#3
01/29/2003 (8:10 am)
for instance on the projectile:

(code)
virtual void onCollision(const Point3F& p, const Point3F& n, SceneObject*);

(script)
function CrossbowProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)


Gabe