Blockland Forums > Modification Help
Changing player datablock's max health with events?
infiniteLoop:
--- Quote from: Headcrab Zombie on July 27, 2011, 07:14:38 PM ---What about a damageReduction player variable, and then package onDamage to deal less damage based on the variable?
I saw this done in such a way that it worked exactly the same as changing a players max health. I forgot who posted it, or where they posted it
--- End quote ---
Lol yes, or overwrite the damage functions and create new ones D: :cookieMonster:
Demian:
--- Quote from: Headcrab Zombie on July 27, 2011, 07:14:38 PM ---What about a damageReduction player variable, and then package onDamage to deal less damage based on the variable?
I saw this done in such a way that it worked exactly the same as changing a players max health. I forgot who posted it, or where they posted it
--- End quote ---
Yes that would work too. In fact. That would be even better. It would work like armor. Can this be done? The reduction should be in percentages.
Space Man:
package damagePack
{
function Player::damage(%damaged, %damager, %pos, %damageInflicted, %damage, %damageType)
{
//blah? alter the %damageInflicted if the player is a player or something?
Parent::damage(%damaged, %damager, %pos, %damageInflicted, %damage, %damageType);
}
};
activatePackage(damagePack);
Something like that hopefully.
Headcrab Zombie:
--- Quote from: Demian on July 28, 2011, 05:09:43 AM ---Yes that would work too. In fact. That would be even better. It would work like armor. Can this be done? The reduction should be in percentages.
--- End quote ---
I saw code here before that did exactly what you want, but I forgot who posted it and exactly where it was posted.
EDIT : Found it
http://forum.blockland.us/index.php?topic=158593.msg3828480#msg3828480
So basically something like
--- Code: ---package fakeMaxHP
{
function Player::damage(this,%obj,%pos,%damage,%damageType)
{
%damage = %damage / (%player.fakeMaxHP / 100);
Parent::damage(%this,%obj,%pos,%damage,%damageType);
}
};
ActivatePackage(fakeMaxHP);
--- End code ---
With an event to set %player.fakeMaxHP, of course.