Author Topic: NPC Text Delay Script  (Read 311 times)

Legacy_Rabstir

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
NPC Text Delay Script
« on: August 29, 2011, 08:39:28 pm »


               I am not sure how to put a DelayCommand (10.0, ...); so each case is not fired every heartbeat in the following script:-

The idea is put a single line entry delay to cater for each case firing, thanks:)':crying:'

void main()
{
  object oPC = GetLastPerceived();
  if (!GetIsPC(oPC)) return;
  if (!GetIsInCombat() && GetLastPerceptionSeen() && !IsInConversation(OBJECT_SELF))
  {

     string sSpeakString;
     switch (d6())
     {

        case 1: sSpeakString = "Oh look what I found in my bag."; break;
        case 2: sSpeakString = "Hey Mr, did you drop this?"; break;
        case 3: sSpeakString = "I am so bored"; break;
        case 4: sSpeakString = "Any Dwagons to hunt here?"; break;
        case 5: sSpeakString = "That ring is nice and shiny!"; break;
        case 6: sSpeakString = "Hey Fizban, how about some fireworks?"; break;

        }
       
        SpeakString(sSpeakString, TALKVOLUME_TALK);
 
}
               
               

               


                     Modifié par Rabstir, 29 août 2011 - 08:41 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
NPC Text Delay Script
« Reply #1 on: August 30, 2011, 12:59:28 pm »


               OK, based upon what limited information you gave me, here is your fix, I hope...

void main()
{
  object oPC = GetLastPerceived();

  if (!GetIsPC(oPC))
  {return;}

  float fDelay = 0.0; // By default there is NO delay.
  // NOTE: Delays are in Seconds! 2.5 = 2 seconds and One Half of a seconds

  string sSpeakString;
 

  if (!GetIsInCombat() && GetLastPerceptionSeen() && !IsInConversation(OBJECT_SELF))
  {

     switch (d6())
     {

        case 1:
        { fDelay = 1.1; // NOTE: You need to set the delay time for EACH Case!
          sSpeakString = "Oh look what I found in my bag.";} break;

        case 2:
        { fDelay = 1.2; sSpeakString = "Hey Mr, did you drop this?";} break;
        case 3:
        { fDelay = 1.3; sSpeakString = "I am so bored"; }break;
        case 4:
        { fDelay = 1.4; sSpeakString = "Any Dwagons to hunt here?"; }break;
        case 5:
        { fDelay = 1.5; sSpeakString = "That ring is nice and shiny!"; }break;
        case 6:
        { fDelay = 1.6; sSpeakString = "Hey Fizban, how about some fireworks?"; }break;

        }
       
        DelayCommand(fDelay, SpeakString(sSpeakString, TALKVOLUME_TALK));
 
}
               
               

               


                     Modifié par _Guile, 30 août 2011 - 12:00 .