Please help me figure this out
What way can we detect hitpoints below zero on the creature? It seems to always return 0 even when I overkill a creature. Or should I just be checking damage of last hit?
Please help me figure this out
What way can we detect hitpoints below zero on the creature? It seems to always return 0 even when I overkill a creature. Or should I just be checking damage of last hit?
last hit - pretty sure the NWN2 damage system does not have a negative allowance - zero = dead
thinking about the negative damage system you mentioned elsewhere...
one way would be to pad every hit and save the padded amount in an int or float even - when the true total reaches zero you will have created in effect a negative amount = to the stored value - but that is gonna get messy for a whole party and if also creatures.
Calculating percentages using integers involves some IntToFloat() / FloatToInt() nestings if you want the script to be nice and concise. For instance...
int iHP = [blah blah blah];
int iTotalDMG = [blah blah blah];
int iPercentDmg = FloatToInt( ( IntToFloat(iTotalDMG) / IntToFloat(iHP) ) * 100.0 );
... is a lot more concise than...
int iHP = [blah blah blah];
float fHP = IntToFloat(iMaxHP);
int iTotalDmg = [blah blah blah];
float fTotalDMG = IntToFloat(iTotalDMG);
float fPercentDmg = ( fTotalDMG / fHP ) * 100.0;
int iPercentDmg = FloatToInt(fPercentDMG);
... which would also work.
The death script is runned by the object dying.
The problem is that when the object is dead it no longer exist, and when that happend, the scripts that object were running are aborted.
To avoid death script from not running, you have to run them on a persistant object. So on the death sript of your creature you put : ExecuteScript("real_death_script",GetModule());
And the instructions you wanted so bad to run that were most of the time cut need to be in "real_death_script", the module object isn 't going anywhere, so by doing it this way, the script isn 't aborted.