You are here

random one -liner conversation nodes form npcs

5 posts / 0 new
Last post
Foghopper
random one -liner conversation nodes form npcs

I'm doing a scene with a bunch of background npcs and wanted to set it up so that if you speak to any of them they give a random one-liner about the situation.

I currently have a script that randomly picks a blurtstring from a selection that I have put within the script. I put that in the Action slot in a conversation with a single blank node that I give to those npcs's. it works fine, but I would like to find a more effiecient way to do this. As is for each situation where I want thsi kind of thing to happen I will need to do a seperate script and a conversation for it to go in.

I am trying and failing miserably so far to work out how to set it up so that I can put the one liners into conversation nodes and have a script call random nodes instead. My thinking is that I can then have a single script and a set of different conversation files. 

I have seen blurtstring conversations in the OC and other modules for npcs, but I haven't been able to work out how to use them.

 

  • up
    50%
  • down
    50%
rjshae

You can create a conversation with a series of single entries, then use the gc_rand_1of script for their condition. If you have 20 entries, just set iMax to 20 on the first line, 19, on the second line, and so forth.

  • up
    50%
  • down
    50%
Foghopper

That is refreshingly simple. Thank you very much.

  • up
    100%
  • down
    0%
kevL's

here's something a bit more indepth ...

i think what you're looking for is some sort of master barkstring file. If i had to dish out barks for god-knows-who, I'd put them in an #include, sorta like so:

// 'inc_barks'
string GetBark(string barktype = "")
{
    if (barktype == "")
    {
        return "hi";
    }

    if (barktype == "forest")
    {
        switch (Random(3))
        {
            case 0: return "Beware there's a brigand camp in the northeast.";
            case 1: return "Tra-la-la";
            case 2:
                if (GetIsDawn() || GetIsDay())
                    return "It feels nice in the forest today.";

                return "Watch out for the werewolves. The moon is full.";
        }
    }

    if (barktype == "city")
    {
        switch (Random(2))
        {
            case 0: return "Have I seen you before?";
            case 1: return "You don't look familiar...";
        }
    }

    if (barktype == "bandofbrothers")
    {
        switch (Random(5))
        {
            case 0: return "Look out for the Tiger!";
            case 1: return "eh whot?";
            case 2: return "Incoming!!!";
            case 3: return "Adolf my arse.";
            case 4: return "It's a long way to Tipperary.";
        }
    }

    if (barktype == "elfband")
    {
        switch (Random(2))
        {
            case 0: return "Love those ears!!";
            case 1:
            {
                string bark = "Have you seen Galadriel's new gown??";
                switch (GetGender(OBJECT_SELF))
                {
                    case GENDER_FEMALE: return bark += " oh my.";
                    case GENDER_MALE:   return bark += " oh yes.";
                    default:            return bark;
                }
            }
        }
    }

    if (barktype == "dwarfband")
    {
        switch (Random(4))
        {
            case 0: return "Harumph.";
            case 1: return "I didn't get a <i>Harumph</i> outta that guy!";
            case 2: return "Harumph.";
            case 3: return "";
        }
    }
}



Also, notice there's an OnConversation event on NPCs. If you know that certain NPCs are only going to ever bark, then creating dialogs for them should be unnecessary; try more-or-less replacing their OnConversation script w/

#include "inc_barks"
void main()
{
    // .. should do a few checks first, to ensure it's not dead, fighting, responding to a shout, etc.
    // See the regular script 'nw_c2_default4'

    string barktype = GetLocalString(OBJECT_SELF, "barktype");
    SpeakString(GetBark(barktype)); // or, FloatingTextStringOnCreature()
}

 

... once that's all been set up, the simple part is setting a string-var on any NPC whose OnConversation event fires the script. Eg,

barktype="forest"

or whichever group the NPC's barks belong to.

  • up
    50%
  • down
    50%
Foghopper

That is pretty much what I was thinking of KevL. Thanks again.

  • up
    50%
  • down
    50%