ArKanuS wrote:
I would like to have like a shield (like health) which when runs out starts affecting your health but if you wait awhile the shield recharges but your health stays the same?
For this, I'd suggest setting up a seperate damage manager.
First thing, keep the player from running out of health as mentioned above(set low to 1). Next, set the high and initial to.. Let's go with 1000. Now, add 2 attributes, real_health and shield, both low=0, high=100, initial=100.
Now, create a dummy pawn, no render, no collision, drop to a low level order. This pawn needs to do these things:
1. Get the player's "health" attribute, and subtract this from 1000. Store it in a variable... We'll call it CUR_DAMAGE. This let's us know how much damage the player took. Also, get the current value of "shield", and store it in CUR_SHIELD.
2. Now, we check if CUR_DAMAGE is greater than CUR_SHIELD. If so, we set "shield" to 0, and modify "real_health" by CUR_DAMAGE - CUR_SHIELD. If not, we just modify "shield" by -CUR_DAMAGE.
3. Next, we check if "real_health" is less than 1, and if so, kill the player(setting "health" to zero should do it, but maybe not... I'm not sure offhand. Anyone know for sure? Might be a problem with the low being 1...)
4. Next, to regenerate the shield. We need a variable for regeneration, and a counter system, like so:
Code: Select all
if(COUNTER > REGEN_RATE)
{
ModifyAttribute("player", "shield", 1);
COUNTER = 0;
}
else
{
COUNTER = COUNTER +1;
}
Please excuse me if I made any parameter errors, I don't have docs handy... (Are the HTML docs on-site? If so, anyone got a link?)
5. Last off, we set "health" back to 1000.
Well, that's the general gist of it... Or, at least, the best approach I can think of.