Author Topic: Question on walk waypoints  (Read 1749 times)

Legacy_Eagles Talon

  • Full Member
  • ***
  • Posts: 192
  • Karma: +0/-0
Question on walk waypoints
« on: July 26, 2010, 09:39:16 pm »


               Greetings,

Not sure if this needs to be posted here or in scripters, but here goes anyway....

I have some waitresses traveling to different tables at the tavern and back to the bar.  The question: Is there a way to have them pause when they get to a table?  They go to a table, turn around and head to the next table in a fraction of a second.  A second question would be, it there a way to make them pause their route if a conversation is started with them?

Any help would be much appreciated.

ET
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Question on walk waypoints
« Reply #1 on: July 26, 2010, 10:24:18 pm »


               From the Vault and have used it before.
http://nwvault.ign.c....Detail&id=2266




//////////////////////////////////////////////
// XE-Ryder KoJ's NPC Barmaid OnUserDefined //
//////////////////////////////////////////////
/*  This script has evolved over time and been greatly revised.
    Proper credit goes to David Gaider for the idea and original,
    then we have to credit Adam Miller for working it a bit better.
    This is where I got it and customized it quite a bit further. If
    someone else had a hand in this I am unawares, I pass it to you,
    the reader to enjoy.
    Place this in the OnUserDefined event of your barmaid and I
    suggest slowing her movement down a bit so they'll saunter around
    the tavern instead of power-walking! Set the nRandom number to the
    number of NPC's in the bar. Place a waypoint at the bar
    with tag WP_BAR and a Bartender with tag BARTEND close enough to
    give her the drinks. Place a waypoint where she should rest with
    tag WP_REST and a Cook with tag COOK close enough for her to confide
    in. While on her break you can make her face any way you like by entering
    it, look for the comment below. DIRECTION_WEST is the default.
    Make sure your NPC's have voicesets and they will speak once in awhile.
    Enter the direction to face while resting where indicated below so they
    don't look into a wall while on break. Follow tuning notes and comments
    below to get it working very easily. Don't forget to cut the OnSpawn
    script off the bottom and place in the OnSpawn event! Enjoy! XE :-)  */
void main()
{
// If no one is about - Exit to save CPU!
if (GetAILevel() == AI_LEVEL_VERY_LOW) return;
int nUser = GetUserDefinedEventNumber();
object oCustomer = GetLocalObject(OBJECT_SELF, "CUSTOMER");
int nRandom = Random(8);    // Set this to the approx number of NPC's in the room
object oBar = GetWaypointByTag("WP_BAR");   // Place this waypoint where she gets drinks from
object oRest = GetWaypointByTag("WP_REST"); // Place this waypoint where she returns to rest
object oCook = GetObjectByTag("COOK");      // Place an NPC Cook in the kitchen with this tag
object oBartend = GetObjectByTag("BARTEND");// Place an NPC Bartender at bar with this tag
if (nUser == 1001) // OnHeartbeat event
    {
    if (!GetIsObjectValid(oCustomer) && GetLocalInt(OBJECT_SELF, "BARMAID_STATE") < 1)
        { //Valid customer and state
        oCustomer = GetNearestCreature (CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_NOT_PC, OBJECT_SELF, nRandom);
        if (oCustomer != oCook && oCustomer != oBartend && oCustomer != OBJECT_SELF && GetIsObjectValid(oCustomer))
            { //Customer is not cook, bartend or self & is valid
            SetLocalInt (OBJECT_SELF, "BARMAID_STATE", 1);
            SetLocalObject (OBJECT_SELF, "CUSTOMER", oCustomer);
            ActionMoveToObject(oCustomer);
            switch(Random(4))
                {
                case 0: ActionSpeakString ("Can I get you something?");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_YES,oCustomer)); break;
                case 1: ActionSpeakString ("What would you like?"); break;
                case 2: ActionSpeakString ("How are we doing over here?"); break;
                case 3: ActionSpeakString ("Another round?");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_GOODIDEA,oCustomer)); break;
                }
            ActionWait(5.0); //Wait, then order drinks from bar
            ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 2));
            ActionMoveToObject(oBar);
            switch(Random(4))
                {
                case 0: ActionSpeakString ("I need two ales and a bottle of mead.");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_CANDO,oCook)); break;
                case 1: ActionSpeakString ("Two whiskeys with a water back please."); break;
                case 2: ActionSpeakString ("They want a pitcher of ale and a loaf of bread");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_CANTDO,oCook)); break;
                case 3: ActionSpeakString ("A bottle of wine and two glasses then.");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_TASKCOMPLETE,oCook)); break;
                }
            ActionWait(8.0); //Wait, then deliver the drinks
            ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 3));
            ActionMoveToObject(oCustomer);
            switch(Random(4))
                {
                case 0: ActionSpeakString ("Enjoy this friend."); break;
                case 1: ActionSpeakString ("That'll be 5 platinum. I'm just kidding. 15 electrum, please.");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_LAUGH,oCustomer)); break;
                case 2: ActionSpeakString ("You look like you could use this."); break;
                case 3: ActionSpeakString ("Ice brewed in the Frigid North, friend. Enjoy.");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_THANKS,oCustomer)); break;
                }
            ActionWait(3.0); // Wait, then back to bar to take a break
            ActionDoCommand (SetLocalObject(OBJECT_SELF, "CUSTOMER", OBJECT_INVALID));
            ActionMoveToObject(oRest);
            //Enter the direction for her to face while on break or comment line below out!
            DelayCommand(4.0,AssignCommand(OBJECT_SELF,SetFacing(DIRECTION_WEST)));
            ActionWait(5.0);
            switch(Random(4))
                {
                case 0: ActionSpeakString ("Slow night tonight, eh Thallin?");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_YES,oBartend)); break;
                case 1: ActionSpeakString ("My feet are killing me."); break;
                case 2: ActionSpeakString ("Well they sure tip well here."); break;
                case 3: ActionSpeakString ("Look at that tender morsel!");
                        ActionDoCommand(PlayVoiceChat(VOICE_CHAT_LAUGH,oBartend)); break;
                }
            ActionWait(5.0);//Wait then reset our variable for next go around
            ActionDoCommand (SetLocalInt(OBJECT_SELF, "BARMAID_STATE", 0));
            }
        }
    }
if (nUser == 1004) // OnDialogue event so you can talk to them.
    {
    SetLocalObject (OBJECT_SELF, "CUSTOMER", OBJECT_INVALID);
    SetLocalInt (OBJECT_SELF, "BARMAID_STATE", 0);
    }
}
*******************************************************************
////////////////////////////////////////
// XE-Ryder KoJ's NPC Barmaid OnSpawn //
////////////////////////////////////////
/*  This script has evolved over time and been greatly revised.
    Proper credit goes to David Gaider for the idea and original,
    then we have to credit Adam Miller for working it a bit better.
    This is where I got it and customized it quite a bit further. If
    someone else had a hand in this I am unawares, I pass it to you,
    the reader to enjoy.
    You do not have to use this code for the OnSpawn handler so long
    as the script you DO use in this event has the Hearbeat and OnDialogue
    events uncommented. WalkWayPoints() is optional and if you place numbered
    waypoints it may cause the barmaid to behave a bit odd. Enjoy! XE :-) */
#include "NW_I0_GENERIC"
void main()
{
SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);
SetSpawnInCondition(NW_FLAG_ON_DIALOGUE_EVENT);
SetListeningPatterns();
//WalkWayPoints();
}
               
               

               
            

Legacy_Eagles Talon

  • Full Member
  • ***
  • Posts: 192
  • Karma: +0/-0
Question on walk waypoints
« Reply #2 on: July 26, 2010, 11:24:30 pm »


               Interesting to be sure. I'm not much of a scripter, but I can read them enough to use them properly. I do see some conflicts with this script and the way I have the barmaids set up. They have stores attached to their conversation for both food and drink already.  And neither our server nor myself are big fans of heartbeat scripts.  But this does give me some ideas to work with. Thanks!!!
               
               

               


                     Modifié par Eagles Talon, 26 juillet 2010 - 10:25 .
                     
                  


            

Legacy_Fester Pot

  • Hero Member
  • *****
  • Posts: 1698
  • Karma: +0/-0
Question on walk waypoints
« Reply #3 on: July 27, 2010, 01:56:39 am »


               It's not a heartbeat script, it's an event. It'll load once when the NPC is created in the area and run until the NPC is destroyed. I use a similar and modified version of the above script myself for populating NPCs with tasks.



FP!
               
               

               
            

Legacy_dndr

  • Newbie
  • *
  • Posts: 36
  • Karma: +0/-0
Question on walk waypoints
« Reply #4 on: July 31, 2010, 12:52:59 am »


               this might be best in the scripting forum.