Aller au contenu

Photo

GetHitDice on Dead Creature?


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

#1
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
 I need to be able to get the CR of a creature. For ease, I would like to get the CR from the creatures OnDeath script.

For debugging, I'm just using this on the OnDeath, and I'm assuming it's not shouting the CR because it's already dead.... How can I shout the CR of the dead creature from the OnDeath script?

object oCreature = OBJECT_SELF;int MyHD = GetHitDice(oCreature);
ActionSpeakString(IntToString(MyHD), TALKVOLUME_SHOUT); 

#2
the.gray.fox

the.gray.fox
  • Members
  • 127 messages
Hello.
This line will not work:

ActionSpeakString(IntToString(MyHD), TALKVOLUME_SHOUT);

because it would be added to the creature's action queue, and execute only after the script has finished running. The catch is that a dead creature has no action queue. Meaning that no queued action will work. Only instant-actions will carry out, because they do as the script is still running.

This should work, instead. I say *should* because 1) I can not check it right now, and 2) I rarely use SpeakString() anyway:

SpeakString (IntToString (MyHD), TALKVOLUME_SHOUT);


Should the above one not work, this other one will succeed for sure:

SendMessageToPC (GetFirstPC (), "DBG: OnDeath -- HD: " + IntToString (MyHD));

which outputs the dead creature's HD in your console. If you want to also see the creature's name (in case you multi-kill), you can use something like this:

SendMessageToPC (GetFirstPC (), "DBG: OnDeath (" + GetName (oCreature) + ") -- HD: " + IntToString (MyHD));


-fox

[edited]: errata corrige -- I should not post when it is this late

Modifié par the.gray.fox, 20 juin 2012 - 02:40 .


#3
Buddywarrior

Buddywarrior
  • Members
  • 256 messages
Perfect Fox, and thank you kindly for explaining the stack!