DMH-Online

Dungeon Masters Helper · Est. 2005

Npcs Scripts

NWN Script: barmaid.htm

Author Sticky: Post Working Scripts Here
FOTL Posted: Monday, 24 June 01:55AM
1. Yet Another Barmaid Script
2. Barmaid Serves Patrons
3. Notes:
This is probably floating around here in many incarnations (some of which don't work) but since I didn't see it in this thread I thought I'd add my version I threw together. This script has been around for a while and is based on the lovely David Gaider's script of similar ilk. I also recall hearing there was one in the game, but I haven' come across it. At minimum you'll need a Barmaid NPC, a couple of friendly NPC patrons, and two waypoints(tags: WP_Bar and WP_Bar2). I also have a barkeeper with the tag "Barkeeper".

This script should be attached to the OnUserDefined event of the Barmaid NPC. Remember to uncomment these two lines in the Barmaid's OnSpawn script (make a copy of it first):
NWScript:
SetSpawnInCondition (NW_FLAG_HEARTBEAT_EVENT);
SetSpawnInCondition (NW_FLAG_ON_DIALOGUE_EVENT);



Here's the OnUserDefined code:

NWScript:
// Barmaid NWScript based on David Gaider of BioWare's script
void main()
{
        int nUser = GetUserDefinedEventNumber();
        int nRandom = Random(4);      //This number should be approx number of NPC patrons
        object oCustomer = GetLocalObject(OBJECT_SELF, "CUSTOMER");
        object oBar = GetWaypointByTag("WP_Bar");     //This waypoint is where she gets drinks from
        object oBar2 = GetWaypointByTag("WP_Bar2");   //This waypoint she returns to rest after delivering drinks
        if (nUser == 1001) // This is a heartbeat event, every 6 sec
        {
                //SendMessageToAllDMs("Barmaid Heartbeat");   <-- I use this for debugging sometimes
                if (!GetIsObjectValid(oCustomer) && (GetLocalInt(OBJECT_SELF, "BARMAID_STATE") < 1))
                    {
                        // Randomly seek out up to the nRandom-nearest non-PC
                        oCustomer = GetNearestCreature (CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC, OBJECT_SELF, nRandom);
                        //Make sure she's not going to ask the Barkeeper if he wants a drink
                        if (oCustomer != GetObjectByTag("Barkeeper") && oCustomer != OBJECT_SELF && GetIsObjectValid(oCustomer) )
                        {
                               // Move to Customer and ask what he/she wants
                                SetLocalInt (OBJECT_SELF, "BARMAID_STATE", 1);
                                SetLocalObject (OBJECT_SELF, "CUSTOMER", oCustomer);
                                ActionMoveToObject(oCustomer);
                                switch(Random(4))
                                {
                                    case 0:
                                        ActionSpeakString ("Can I get you something?");
                                        break;
                                    case 1:
                                        ActionSpeakString ("What'll it be?");
                                        break;
                                    case 2:
                                        ActionSpeakString ("Some refreshment for you and your friends?");
                                        break;
                                    case 3:
                                        ActionSpeakString ("Another round?");
                                        break;
                                 }
                                ActionWait(5.0); //Wait 5 secs.
                                // Move to the Bar to get the Drinks
                                ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 2));
                                ActionMoveToObject(oBar);
                                switch(Random(4))
                                {
                                    case 0:
                                        ActionSpeakString ("I need two Dragon Breath Ales and a Ilipur Bitter.");
                                        break;
                                    case 1:
                                        ActionSpeakString ("A Mindflayer with a twist and two bottles of Prespur Rum.");
                                        break;
                                    case 2:
                                        ActionSpeakString ("They want a basket of Crispy Ogre Ears");
                                        break;
                                    case 3:
                                        ActionSpeakString ("Three ales and a pony keg for theHalf-Orc.");
                                        break;
                                 }
                                ActionWait(8.0);//Wait 8 secs.

                                // Move back to the customer and give him/her the drinks
                                ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 3));
                                ActionMoveToObject (oCustomer);
                                switch(Random(4))
                                {
                                    case 0:
                                        ActionSpeakString ("Enjoy.");
                                        break;
                                    case 1:
                                        ActionSpeakString ("That'll be 5 platinum. I'm just kidding. 15 copper, please.");
                                        break;
                                    case 2:
                                        ActionSpeakString ("You look like you could use this.");
                                        break;
                                    case 3:
                                        ActionSpeakString ("Ice brewed in Icewind Dale, friend. Enjoy.");
                                        break;
                                 }
                                ActionWait(3.0);//Wait 3 secs.
                                ActionDoCommand (SetLocalObject(OBJECT_SELF, "CUSTOMER", OBJECT_INVALID));
                               // Move back to the other side of the bar to take a needed break
                               ActionMoveToObject(oBar2);
                               ActionWait(5.0);//Wait 5 secs.
                               switch(Random(4))
                                {
                                    case 0:
                                        ActionSpeakString ("Slow night tonight, eh Charlie?");
                                        break;
                                    case 1:
                                        ActionSpeakString ("My feet are killing me.");
                                        break;
                                    case 2:
                                        ActionSpeakString ("I can't live on these tips. Two copper?");
                                        break;
                                    case 3:
                                        ActionSpeakString ("He's kind of cute.");
                                        break;
                                 }
                               ActionWait(5.0);//Wait 5 secs.
                               ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 0));
                       }
                }
        }
        if (nUser == 1004) // this is the OnDialogue event
        {
                // This is just in here so you can interrupt her if you want to talk to her
                SetLocalObject (OBJECT_SELF, "CUSTOMER", OBJECT_INVALID);
                SetLocalInt (OBJECT_SELF, "BARMAID_STATE", 0);
        }
}
⌂ All Scripts ← PreviousNext → 👁 Category List

All Npcs Scripts

📄 ambient_animations 📄 barmaid 📄 barmaid002 📄 barmaid003 📄 barmaid003a 📄 barmaid004 📄 bitch_slap 📄 blacksmith 📄 blacksmith_001 📄 blacksmith_002 📄 blacksmith_003 📄 bounty_hunter 📄 check 📄 check_pc_item 📄 check_pc_item_002 📄 cheer_pcs 📄 cook 📄 daily_activity 📄 day_merchant 📄 determine_armed 📄 drunk 📄 equip_dequip 📄 equip_dequip_002 📄 escort 📄 flee 📄 flee_001 📄 force_pc_sit 📄 gate_guard 📄 get_nearest 📄 guard_dog_002 📄 guard_patrol 📄 healer 📄 impersonation 📄 item_guardian 📄 item_guardian_002 📄 jail_cell 📄 janitor 📄 janitor_002 📄 living_statues 📄 misc_activity 📄 monolouge 📄 multi_converse 📄 night_watch 📄 npc_brawls 📄 npc_pick_pocket 📄 npc_speak_onperception 📄 npc_start_conv 📄 npc_start_conv_002 📄 npc_start_conv_003 📄 npc_start_conv_004 📄 npc_start_conv_005 📄 open_door 📄 polymorph 📄 prostitute 📄 protect_items 📄 protect_items_002 📄 random_speak 📄 random_speak_002 📄 random_speak_003 📄 random_speak_004 📄 random_speak_005 📄 random_walk2 📄 reinforcements 📄 reinforcements_002 📄 remember_conv 📄 rowdy 📄 sheath_weapons 📄 sit_and_talk 📄 sit_and_talk_002 📄 sit_in_nearest_chair 📄 smart_npc 📄 smart_sitting 📄 streetfight 📄 tag 📄 tag_001a 📄 teleport_away 📄 teleport_away_002 📄 teleport_away_003 📄 town_crier 📄 trivia_bot 📄 walk_after 📄 woodcutter 📄 worker 📄 worker_002 📄 workstation 📄 wrestling_game