Johxz Posted June 23, 2016 Posted June 23, 2016 Hello!someone can give a hand here :) a little explanation how this works? I don't found what %sourceObject it meansShapeBase::damagePlayerData::damageThanks!! Quote
damik Posted June 23, 2016 Posted June 23, 2016 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" ); } Quote
rlranft Posted June 24, 2016 Posted June 24, 2016 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). Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.