Aller au contenu

Photo

On Death script doesn't execute, but used to


  • Veuillez vous connecter pour répondre
5 réponses à ce sujet

#1
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages

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?



#2
Morbane

Morbane
  • Members
  • 1 883 messages

last hit - pretty sure the NWN2 damage system does not have a negative allowance - zero = dead



#3
Morbane

Morbane
  • Members
  • 1 883 messages

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.



#4
Eguintir Eligard

Eguintir Eligard
  • Members
  • 1 832 messages
No its ok I used get total damage or some similar named function and took it off max hit points. Got me the negative but I'll have to convert it to a percent without destroying the function this time.

#5
Dann-J

Dann-J
  • Members
  • 3 161 messages

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.



#6
Shallina

Shallina
  • Members
  • 1 011 messages

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.


  • Morbane et Kaldor Silverwand aiment ceci