Conversation script help.
Zephirius
Member Posts: 419
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...
...and this bit of code goes on his OnSpawn
Hope you guys can make sense of any of this.
I only used two orders as an example...
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...
0
Comments
Take the IntToString bit out of the last order if you don't want to see numbers.
My weird code:
I don't think I'm fully grasping the meaning of (or how to utilize) the "counter".
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):
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.
Now I'm just having fun.
Not the most intense script but having a lot of fun learning.