I'm attempting to implement a script that is akin to Spartan Rage from God of War. I have a counter that is supposed to increment each time you take damage, then once it reaches 100, it ticks down until it reaches 0 again. Whenever I get hit, the counter just ticks all the way up to 99 and then freezes there.
import "std.zh"
global script Active
{
void run()
{
bool rage = false;
int lasthp = Link->HP;
while (true)
{
moblinRage(rage, lasthp);
Waitframe();
}
}
}
void moblinRage(bool rage, int lasthp){
if(Link->HP < lasthp)
{
Game->Counter[CR_SCRIPT1] += (lasthp - Link->HP)/2;
lasthp = Link->HP;
}
if(Game->Counter[CR_SCRIPT1] > 100)
{
Game->Counter[CR_SCRIPT1] = 100;
}
if(Game->Counter[CR_SCRIPT1] < 0)
{
Game->Counter[CR_SCRIPT1] = 0;
}
if(Game->Counter[CR_SCRIPT1] == 0)
{
rage = false;
}
if(Game->Counter[CR_SCRIPT1] == 100)
{
rage = true;
}
if(rage == true)
{
Game->Counter[CR_SCRIPT1]--;
}
}
Edited by Smiles the Death Bringer, 11 August 2019 - 04:02 PM.

