Skip to content

Making placeables say stuff randomly overhead?

I'm trying to make placeables speak overhead text. I can't figure out how to do this even with LS's script generator. Any help would be great.

Comments

  • ProlericProleric Member Posts: 1,316
    SpeakString("hello world");

    If the placeable is not running the script

    AssignCommand(oPlaceable, SpeakString("hello world"));
  • Ugly_DuckUgly_Duck Member Posts: 182
    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?
  • NeverwinterWightsNeverwinterWights Member Posts: 339
    Ugly_Duck wrote: »
    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.
  • Ugly_DuckUgly_Duck Member Posts: 182
    So far, the bottom script is working nicely. Thanks for the help!
Sign In or Register to comment.