Jump to content

what it means PlayerData::damage %sourceObject


Johxz

Recommended Posts

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"  );
}
Link to comment
Share on other sites

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).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...