what it means PlayerData::damage %sourceObject

Scripting questions, discussions, etc
3 posts Page 1 of 1
Johxz
Posts: 390
Joined: Sat Feb 07, 2015 11:37 pm
by Johxz » Thu Jun 23, 2016 5:03 am
Hello!

someone can give a hand here :) a little explanation how this works? I don't found what %sourceObject it means

ShapeBase::damage

PlayerData::damage

Thanks!!
damik
Posts: 16
Joined: Thu Jun 23, 2016 12:02 pm
by damik » Thu Jun 23, 2016 1:12 pm
function WeaponImage::onFire( %this, %obj, %slot )
{
%p = new Projectile()
{
dataBlock = ProjectileData;
sourceObject = %obj;
sourceSlot = %slot;
sourceClass = %obj.getClassName();
};
}

function ProjectileData::onCollision( %data, %proj, %col, %fade, %pos%normal )
{
%col.damage( %proj, %pos, %dmg, %data.damageType );
}

function PlayerData::damage( %this, %obj, %sourceObject, %position, %damage, %damageType )
{
%shooter = %sourceObject.sourceObject;
if( %shooter.team $= %obj.team ) echo( "FRIENDLY FIRE" );
}
rlranft
Posts: 298
Joined: Thu Feb 05, 2015 3:11 pm
 
by rlranft » Fri Jun 24, 2016 3:26 pm
Yeah, as the code that damik posted says, it's the player object that the damage originated from. When the weapon is fired the player id is set on the projectile. When the target takes damage it asks the projectile who it belongs to so the right person gets credit for the kill (if it kills them).
3 posts Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest