Author Topic: Reduction in Damage Taken  (Read 483 times)

When hit, reduces the damage sustained by a specific percentage.

Is it possible to just have a small snippet of code to insert that does this?

You'll need to package the damage function

Code: [Select]
package stuff
{
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
//do stuff
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
}
};

Code: [Select]
package stuff
{
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
%damageReducePerc = (100 - %obj.getDamageDamp()) / 100;
%damage *= %damageReducePerc;
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
}
};
activatePackage(stuff);
Code: [Select]
function Player::getDamageDamp(%this)
{
%damageReducePerc = 5; // Reduce damage by 5%
//calculations, if needed
return %damageReducePerc;
}

Code: [Select]
function Player::getDamageDamp(%this)
{
%damageReducePerc = 5; // Reduce damage by 5%
//calculations, if needed
return %damageReducePerc;
}

Lol, thanks.  I haven't even so much as looked at coding before, so, although I got what he meant, I didn't know how to alter it.

Lol, thanks.  I haven't even so much as looked at coding before, so, although I got what he meant, I didn't know how to alter it.
Just in case you didn't understand, you need both parts of my code for it to work.