Author Topic: GetHitDice on Dead Creature?  (Read 335 times)

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
GetHitDice on Dead Creature?
« on: June 20, 2012, 02:51:47 am »


                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); 
               
               

               
            

Legacy_the.gray.fox

  • Full Member
  • ***
  • Posts: 214
  • Karma: +0/-0
GetHitDice on Dead Creature?
« Reply #1 on: June 20, 2012, 03:29:57 am »


               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 .
                     
                  


            

Legacy_Buddywarrior

  • Hero Member
  • *****
  • Posts: 512
  • Karma: +0/-0
GetHitDice on Dead Creature?
« Reply #2 on: June 20, 2012, 04:51:21 am »


               Perfect Fox, and thank you kindly for explaining the stack!