I hit an interesting problem while trying to get my trolls to work right. The basic gist is that it seems applying a death effect to a creature causes the OnDeath handler to run right then, but does not modify hitpoints until after that. It appears that, as the Lexicon implies, GetIs Dead relies on the creature's hit points. My on death scripts have a GetIsDead check at the top because I read that creatures fleeing the map have their death scripts run and I did not want that. (I have not validated that that is indeed the case so the check may not be needed). But what happens is the GetIsDead returns FALSE when the OnDeath handler runs but TRUE when tested in the line after the ApplyEffectToObject.
I can finagle a work around when I get back to it. But I was wondering if anyone else had noticed this before.
This is basically what I'm doing (from the OnDamaged handler):
SendMessageToPC(OBJECT_SELF, "TROLL - kill troll called - removing immortal flag...");
SetImmortal(oTroll,FALSE);
ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectDeath(), oTroll);
SendMessageToPC(OBJECT_SELF, "TROLL - killed dead = "+IntToString(GetIsDead(oTroll)));
And this is what it shows:
[CHAT WINDOW TEXT] [Wed Sep 23 22:09:59] TROLL - kill troll called - removing immortal flag...
[CHAT WINDOW TEXT] [Wed Sep 23 22:09:59] OnDeathHandler Fires for large humanoid
[CHAT WINDOW TEXT] [Wed Sep 23 22:09:59] tb_npc_death called, is dead = 0 hp = 1
[CHAT WINDOW TEXT] [Wed Sep 23 22:09:59] Andorian Fireblood killed large humanoid
[CHAT WINDOW TEXT] [Wed Sep 23 22:09:59] TROLL - killed dead = 1
The tb_npc_death script is called from the ondeath handler and stops because GetIsDead return 0.