Author Topic: Dodging Damage?  (Read 661 times)

I want to make it so that a certain playertype has a chance to completely evade damage.
This is what my guessed code is so far:
Code: [Select]
package IronManArmor
{
function Armor::OnDamage(%this, %player, %player2, %position, %damage, %damageType)
{
if(%player.IronManArmor == false)
return parent::Damage(%this, %player, %player2, %position, %damage, %damageType);

%hit = getRandom(0,2);

if(%hit == 0)
return;

else
parent::Damage(%this, %player, %player2, %position, %damage, %damageType);
}
};
activatePackage(IronManArmor);
« Last Edit: February 04, 2015, 02:26:32 PM by EV0_ »

Well to start out with, maybe I should make it say
Code: [Select]
if(%hit == 0)instead of
Code: [Select]
if(%hit = 0)

You need to work on your logic. If the player isn't wearing iron man armor, they are not going to take damage at all.

You need to work on your logic. If the player isn't wearing iron man armor, they are not going to take damage at all.
This. If you want things to go normally you do "return parent::Damage(%this, %player, %player2, %position, %damage, %damageType);"


You're using the wrong function. armor::onDamage is just a callback, so you can't stop the player from being damaged by using it(plus those are the wrong arguments for that function anyways). You want to use the armor::damage(%data, %obj, %source, %pos, %damage, %type) function. %obj is the player who got damaged(not their client) and I'm pretty sure that %source is usually a projectile.


and I'm pretty sure that %source is usually a projectile.
You could also check if the source is a projectile, if it is try to see of the source object or the client exists.

Nah. He should be immune to fall damage too.

Is there a chance I can use '%client = %obj.getClient();'?

Is there a chance I can use '%client = %obj.getClient();'?
%client = %source.client;

You know, you can figure some of these things out for yourself by using trace and dumping objects.