Game Development Community

apply damage to shapebase objects

by Tim Lei · in Torque Game Engine · 06/03/2002 (9:27 am) · 4 replies

function ShapeBase::damage(%this, %sourceObject, %position, %damage, %damageType)
{
%this.getDataBlock().damage(%this, %sourceObject, %position, %damage, %damageType);

}

this is the function that applies damage to the objects in the script (provided by in the example). %this is a shapebase object, which means could be a player. However, the part i'm confused about is where the damage function comes from. I've looked all over the script and the engine code, and wasn't able to find it. I know it's there, but just can't find it. I also found out that the damage function in the script somehow calls the applydamage in the shapebase class. Would you experts please tell me where the damage function comes from? I really appreciate your help!

#1
06/03/2002 (9:51 am)
Player.damage() -> %this.getDatablock.damage() -> PlayerData.damage();

If there is no ::damage function for the object, it tries to call the ::damage function of the datablock.

greetings
Daniel
#2
06/03/2002 (11:26 am)
Thanx for your reply. Actually I've looked into playerdata and even shapedata to find that function. However, I wasn't able to. Would you please tell me where exactly the damage fucntion in the script connects with the engine code. Thanx a lot!
#3
06/03/2002 (5:22 pm)
i think i got what you mean, i totally ignored the fact that the player datablock belongs to the armor namespace....and its actually calling the damage funciton in that namespace. thanks alot for the hint
#4
02/16/2009 (10:17 am)
I don't want to open a new thread so Iam going to ask here:
What is %sourceObject? I am confused with this parameter and I get nothing when I "echo" for the name of it (getName()) in the player function:
function HumanMaleAvatar::Damage(%db, %obj, %sourceObject, %position, %damage, %damageType)
{
..
}
Thnks