Where do I put that script? Also, if I want the placeable to speak like 5 random things every now and then, do I replicate that SpeakString("Text goes Here"); 5 times? Do I need a conversation file too?
Where do I put that script? Also, if I want the placeable to speak like 5 random things every now and then, do I replicate that SpeakString("Text goes Here"); 5 times? Do I need a conversation file too?
Depends on how you want it to happen. The placeable object's OnHeartbeat might work the best, but the heartbeat is every 6 seconds. The following would make the object speak a random string every heartbeat:
void main()
{
string sRandom;
switch (Random(5))
{
case 0: sRandom = "Hello World"; break;
case 1: sRandom = "Hello People"; break;
case 2: sRandom = "Hello Animals"; break;
case 3: sRandom = "Hello Trent"; break;
case 4: sRandom = "Hello NWN"; break;
}
SpeakString(sRandom);
}
If you wanted a longer time in between each spoken string then you would do something like so:
void main()
{
int iBeat = GetLocalInt(OBJECT_SELF, "CURRENT_BEAT");
string sRandom;
if (iBeat == 4)//There should be 5 heartbeats (0-4) before the following happens: Can change to however many heartbeats you need.
{
switch (Random(5))
{
case 0: sRandom = "Hello World"; break;
case 1: sRandom = "Hello People"; break;
case 2: sRandom = "Hello Animals"; break;
case 3: sRandom = "Hello Trent"; break;
case 4: sRandom = "Hello NWN"; break;
}
SpeakString(sRandom);
SetLocalInt(OBJECT_SELF, "CURRENT_BEAT", 0);//reset hearbeats back to 0
}
else//if we haven't made it to 5 hearbeats count up another
{
SetLocalInt(OBJECT_SELF, "CURRENT_BEAT", iBeat+1);
}
}
The second script fires after however many heartbeats. In this case after 5 heartbeats (5 x 6 seconds = 30 seconds). You cold also throw in a random amount of heartbeats so it's not exactly every 30 seconds, etc.
Comments
If the placeable is not running the script
AssignCommand(oPlaceable, SpeakString("hello world"));
Depends on how you want it to happen. The placeable object's OnHeartbeat might work the best, but the heartbeat is every 6 seconds. The following would make the object speak a random string every heartbeat:
If you wanted a longer time in between each spoken string then you would do something like so:
The second script fires after however many heartbeats. In this case after 5 heartbeats (5 x 6 seconds = 30 seconds). You cold also throw in a random amount of heartbeats so it's not exactly every 30 seconds, etc.