Skip to content

Conversation script help.

ZephiriusZephirius Member Posts: 419
edited May 2021 in Builders - Scripting
I have a Stone Giant Taskmaster barking orders to his goblin minions from his OnHeartbeat script. What I'm trying to do is speak one line, then the next - about four or five orders then repeat the sequence...

I stole this code from The Lexicon but I am doing something wrong. He stops after the second order and starts spouting numbers - 1, 2 , 3 ad infinitum...
//::///////////////////////////////////////////////
//:: Name x2_def_heartbeat
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Default Heartbeat script
*/
//:://////////////////////////////////////////////
//:: Created By: Keith Warner
//:: Created On: June 11/03
//:://////////////////////////////////////////////

int nCount=GetLocalInt(OBJECT_SELF, "SINGER_COUNT");

void main()
{
    ExecuteScript("nw_c2_default1", OBJECT_SELF);

    nCount = nCount + 1;
    if (nCount == 1)
    {
        ActionSpeakString("To work goblins!  Were not getting paid by the hour!.");
    }
    else
    {
        ActionSpeakString("The Master eyes are upon you!" + IntToString(nCount) + "");
    }

    SetLocalInt(OBJECT_SELF, "SINGER_COUNT", nCount);
}

...and this bit of code goes on his OnSpawn
SetLocalInt(OBJECT_SELF, "SINGER_COUNT", 0);

Hope you guys can make sense of any of this. :)

I only used two orders as an example...

Comments

  • ProlericProleric Member Posts: 1,316
    Immediately after the last ActionSpeakString, reset nCount to zero, so that the sequence can repeat.

    Take the IntToString bit out of the last order if you don't want to see numbers.
  • ZephiriusZephirius Member Posts: 419
    Thanks. I'll check'her out.
  • ZephiriusZephirius Member Posts: 419
    edited May 2021
    I'm only getting the first line spoken then it stops. It's little scripts like this that drive someone like me absolutely bonkers. Arghhh, thats kinda funny. This map is full of undead pirates. Arghhh!
    ;)

    My weird code:
    void main()
    {
        nCount = nCount + 1;
        if (nCount == 1)
        {
            ActionSpeakString("This is the first and only time I will say this!...");
        }
        else
        {
            ActionSpeakString("Listen to my words!");
            ActionWait(6.0);
            ActionSpeakString("That's the spirit!");
            ActionWait(6.0);
            ActionSpeakString("The harder you work, the less dead you'll be!");
            ActionWait(6.0);
            ActionSpeakString("It's not so bad.  Put your backs into it you grubs!  Ha!");
    
            nCount = nCount + 0;
            if (nCount == 0)
            {
            SetLocalInt(OBJECT_SELF, "SINGER_COUNT", nCount);
            }
        }
    }
    
    

    I don't think I'm fully grasping the meaning of (or how to utilize) the "counter".
  • ProlericProleric Member Posts: 1,316
    Firstly, you need to initialise the counter, like you did before (only it needs to be inside the main() block, which your original isn't).
    void main()
    {
      int nCount=GetLocalInt(OBJECT_SELF, "SINGER_COUNT");
    

    The reason for using a local int is that variables like nCount don't retain their value from one script execution to the next, whereas local int does.

    At the end of the script, for the same reason, you need to set the local int to nCount unconditionally (not if nCount==0).

    Have a look at the switch statement in the Lexicon. Instead of all those waits, since the script is already running on heartbeat, all you need to do each time is ActionSpeakString the string matching the current value of n.

    Lastly, before storing n, you need to reset it if it has reached the final case (5 in this example):
      if (nCount == 5)
        nCount = 0;
    

    Why 0, not 1? You may ask. The reason is that next time the script runs, you will increase nCount by 1 again before doing anything else, so if it's 0 now, the next case will be 1 as intended.
  • ZephiriusZephirius Member Posts: 419
    edited May 2021
    I finally got it working with this. Thanks for the pointers P. ;)
    //::///////////////////////////////////////////////
    //:: Name "talk dirty to me"//////////////////////////////
    //:: /////////////////////////////////////////////////
    //:://////////////////////////////////////////////
    /*
        Default Heartbeat script
    */
    //:://////////////////////////////////////////////
    //:: Created By: Me
    //:: Created On: May 12/21
    //:://////////////////////////////////////////////
    
    void RandomTalk(string sString)
        {
    
        ActionSpeakString(sString);
        }
    
    
    void main()
    {
        ExecuteScript("nw_c2_default1", OBJECT_SELF);
    
        switch (Random(10))
        {
        case 0: RandomTalk("The masters eyes are upon you, always!"); break;
        case 1: RandomTalk("Put yor spines into it!"); break;
        case 2: RandomTalk("Don't act like you're being worked to death..."); break;
        case 3: RandomTalk("...considering the state of your existence, one might think it hillarious"); break;
        case 4: RandomTalk("One, two, three - I spy a skeleton with my eye."); break;
        case 5: RandomTalk("You lazy grubs.  To work!!"); break;
        case 6: RandomTalk("In all my years, I've never seen such an incompetence..."); break;
        case 7: RandomTalk("Another five minutes until break time!"); break;
        case 8: RandomTalk("Devil barbs and lich dust!  I can't beleive my eyes!"); break;
        case 9: RandomTalk("Thus begins the ending of the beginning..."); break;
        }
    }
    

    Now I'm just having fun. :)
    //object oPC = GetNearestCreature
    //(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF);
    
    void RandomTalk(string sString)
        {
    
        ActionSpeakString(sString);
        }
    void RandomYell(string sYell)
        {
        PlaySound(sYell);
        }
    
    void main()
    {
        ExecuteScript("nw_c2_default1", OBJECT_SELF);
    
        switch (Random(10))
        {
        case 0: RandomTalk("The masters eyes are upon you, always!"); break;
        case 1: RandomTalk("Put yor spines into it!"); break;
        case 2: RandomTalk("Don't act like you're being worked to death..."); break;
        case 3: RandomTalk("...considering the state of your existence, one might think it's an improvement, HA!"); break;
        case 4: RandomTalk("One little, two little, three little skellies..."); break;
        case 5: RandomTalk("You lazy grubs.  To work!  Roy?  Is that you?"); break;
        case 6: RandomTalk("In all my years, I've never seen such an incompetence..."); break;
        case 7: RandomTalk("Another five minutes until break time!"); break;
        case 8: RandomTalk("Devil's balls and lich dust!  I can't beleive my eyes!  Best cover them ears...???"); break;
        case 9: RandomTalk("Thus begins the ending of the beginning..."); break;
        }
        switch (Random(4))
        {
        case 0: RandomYell("c_doomkngt_bat1"); break;
        case 1: RandomYell("c_doomkngt_slct"); break;
        case 2: RandomYell("c_elemerth_bat2"); break;
        case 3: RandomYell("c_minotaur_bat1"); break;
        }
    }
    
    
    

    Not the most intense script but having a lot of fun learning.
    Post edited by Zephirius on
Sign In or Register to comment.