Hey! I got an issue with a scripted damage divisor. Here's the script:
float LinksDefense = 0;
global script Active{
void run(){
int lastFrameLinkHP = Link->HP;
while(true){
Waitdraw();
if ( Link->HP < lastFrameLinkHP && LinksDefense > 0 ) {
Link->HP += (lastFrameLinkHP - Link->HP) / LinksDefense;
}
lastFrameLinkHP = Link->HP;
Waitframe();
}
}
}
I have items that set LinksDefense to 1.5 or 2 or whatever. The issue now is when Link gets very low. It feels like the lower he gets, the higher his defense becomes somehow. I can't figure out how to fix this. :o
Simple: Link's health is both A: Rounded, and B: will never go below 0 (feel free to correct me on these if I'm wrong). The combination of these mean that Link will either be invincible or have extremely high defense the less health he has. Let's say Link has 2 health left, and a weapon does 8 damage.
Normally, with a theoretical defense of 2 and if Link's health could go below 0, his health would be set to -6 (2 - 8 = -6), and then his health would be raised by 4 (2 - -6 = 8, 8 / 2 = 4), leaving him with -2 health, meaning he is still dead.
However, because Link's health can't go below 0, it would go more like this: his health would be set to 0 (2 - 8 = -6, -6 -> 0), then his health would be raised by 1 (2 - 0 = 2, 2 / 2 = 1), leaving him with 1 health, still alive. With a defense of 2, this would mean he is invincible, as with even 1 health left, and he takes any amount of damage, his health would be raised by 0.5 health (1 - 0 = 1, 1 / 2 = 0.5), which rounds up 1, meaning he cannot die.
Frankly, I'd just use peril rings to simulate having higher defenses.
Edited by Dimentio, 14 January 2017 - 06:20 PM.