Short guide to making NPCs move around

Post Reply
User avatar
Gnurg
Posts: 2395
Joined: 28 Jan 2013 19:38
Location: Oslo, Norway

Short guide to making NPCs move around

#1 » Post by Gnurg » 17 Feb 2017 11:36

Unlike the other guides, I have actually never played with this before, but it seemed relatively simple to work with.

Want something applied? viewtopic.php?f=66&t=37106

Trinity Core's page on waypoint_data: https://trinitycore.atlassian.net/wiki/ ... point_data

Concept:
You create certain waypoints: A, B & C. The creature moves from A to B, B to C and C to A. You can have as many waypoints as you wish. This is used by patrolling NPCs, which will take the same path endlessly. Do not use this for escort like NPCs.

Attributes in the waypoint_data table: *Bolded are most important*
  • id - Unlike the other guides, we now want the unique identification of the NPC, the GUID. It's also multiplied by 10.
  • point - Incremented for every waypoint you have. It starts at 1.
  • positon_x/y/z - The coordinate in x, y and z directions
  • orientation - If you want the NPC to turn in a certain direction. i.e. North would be 0, while South would be pi (3.14...).
  • delay - If you want to have the NPC wait a bit before moving, you can add a delay in milliseconds (1000 ms = 1 s).
  • move_type - How it should move between the points. Maybe you want the NPC to run between two points? 0 = walk, 1 run, 2 = fly.
  • action - Maybe you want the create to do something special? Maybe an emote, a spell cast or whatever you desire.
  • action_chance - Chance for the action to occur. Uncertain if this refers to the action or the waypoint, but most of the time, it's left at 100 %.
Useful commands

Code: Select all

.npc info - Show information about the creature. You need to retrieve the DB GUID, as you will add that in the SQL for the id field.
[hide]Image[/hide]

Code: Select all

.gps - Show information about the location you're standing at. You need to find the cordinates (x, y, z) that you add to every waypoint. MAKE SURE YOU DON'T TARGET ANYTHING WHEN USING THE COMMAND.
[hide]Image[/hide]

Template
* With this template, you do only have to set NPC_GUID and the X, Y & Z cordinates.

Code: Select all

SET @GUID := NPC_GUID;
SET @PATH := @GUID * 10;
UPDATE `creature` SET `MovementType`=2 WHERE `guid`=@GUID;
DELETE FROM `creature_addon` WHERE `guid`=@GUID;
INSERT INTO `creature_addon` (`guid`,`path_id`,`mount`,`bytes1`,`bytes2`,`emote`,`auras`) VALUES (@GUID,@PATH,0,0,1,0, '');
DELETE FROM `waypoint_data` WHERE `id`=@PATH;
INSERT INTO `waypoint_data` (`id`,`point`,`position_x`,`position_y`,`position_z`,`orientation`,`delay`,`move_type`,`action`,`action_chance`,`wpguid`) VALUES
(@PATH, 1, X, Y, Z, 0, 0, 0 ,0, 100, 0),
(@PATH, 2, X, Y, Z, 0, 0, 0, 0, 100, 0),
(@PATH, 3, X, Y, Z, 0, 0, 0, 0, 100, 0);

Please feel free to ask questions if you have any. Also, if there's something you feel like is missing or is wrong, let me know! :-)
Last edited by Gnurg on 02 Mar 2017 18:32, edited 4 times in total.
HAI
CAN HAZ STDIO?
VISIBLE "HAI WORLD, IZ GNURF!"
KTHXBYE

User avatar
Doctor_J
Developer
Posts: 5750
Joined: 01 Sep 2012 19:30
Location: United Kingdom

Re: Short guide to making NPCs move around

#2 » Post by Doctor_J » 17 Feb 2017 12:14

remember that waypoints should come from sniff data if possible, adnd if you do have access to sniffs you only need the end waypoint from each waypoint packet if you include all waypoints from each packet you will end up with messy waypoints and a npc which ends up walking back on itself during.

And the above should only be used for cratures which continuosly follow a path without pausing it should not be used for escort npcs as waypoints for those should be dealt with cpp or sai nor should it be used for any waypoints which dont start automatically (ie player has to select a gossip otion or take quest or there is some other criteria for waypoints to start.

Also remember if creature has sai script and you wish to pause waypoints or run some event on reaching a certain waypoint then waypoints should be in waypoints table and scripted to start wp via sai as sai and way_point_data dont talk to each other so you cannot pause wp or run a event on reaching a waypoint in sai if waypoints are in waypoint_data.
Play Chars

Demonscream 80 Blood Elf Destruction Warlock
Xora 80 Undead Shadow/Holy Priest
Betelgeuse 80 Undead Arcane Mage
Esteban 80 Blood Elf Retribution Paladin
Artfuldodger 80 Human Assasination Rogue
Makka 80 Orc Beast Master Hunter
Cheetara 80 Tauren Balance/resto Druid
Gloriosa 80 Troll Resto/Elemental Shaman
Blotto 80 Undead Fury Warrior

Angelscream 80 Human Warlock

--------------------------------------------------------------------------------------------------------------------
Gm's

Docmin
Docmina

User avatar
Gnurg
Posts: 2395
Joined: 28 Jan 2013 19:38
Location: Oslo, Norway

Re: Short guide to making NPCs move around

#3 » Post by Gnurg » 17 Feb 2017 12:30

Doctor_J wrote:remember that waypoints should come from sniff data if possible, adnd if you do have access to sniffs you only need the end waypoint from each waypoint packet if you include all waypoints from each packet you will end up with messy waypoints and a npc which ends up walking back on itself during.

And the above should only be used for cratures which continuosly follow a path without pausing it should not be used for escort npcs as waypoints for those should be dealt with cpp or sai nor should it be used for any waypoints which dont start automatically (ie player has to select a gossip otion or take quest or there is some other criteria for waypoints to start.

Also remember if creature has sai script and you wish to pause waypoints or run some event on reaching a certain waypoint then waypoints should be in waypoints table and scripted to start wp via sai as sai and way_point_data dont talk to each other so you cannot pause wp or run a event on reaching a waypoint in sai if waypoints are in waypoint_data.
I don't think the ones who will use this guide will have access to any other sniff than WoWhead and similar sources. It's kind of supposed to be a beginner's guide to get people interested in contributing.

From how I understood you, we should use this ONLY for patrolling NPCs? i.e. http://www.wowhead.com/npc=18258/bachlor stands still at the moment, when he should move around in a circle. Should we use waypoint_data then?

Thanks for the quick response! :-)
HAI
CAN HAZ STDIO?
VISIBLE "HAI WORLD, IZ GNURF!"
KTHXBYE

User avatar
IronSharona
Staff Member
Posts: 1143
Joined: 02 Feb 2017 00:49
Location: Austin, Texas, USA

Re: Short guide to making NPCs move around

#4 » Post by IronSharona » 20 Feb 2017 01:01

Another question, maybe you know Gnurg:
If an NPC has 3 separate possible spawn locations to patrol around, I assume we can set the waypoints the same for any of them in the same way. But how do we set multiple spawn locations for an NPC? And if that works well, how can we script that certain spawns correspond to certain waypoint patrol assignments?

Maybe I should just start with getting an NPC to patrol around it's current spawn point?
Welcome to the new decade! Let's hope the Roaring 20's come with just as much jazz, but a bit less prohibition and Great Depression. 8-)

User avatar
Gnurg
Posts: 2395
Joined: 28 Jan 2013 19:38
Location: Oslo, Norway

Re: Short guide to making NPCs move around

#5 » Post by Gnurg » 20 Feb 2017 01:12

IronSharona wrote:Another question, maybe you know Gnurg:
If an NPC has 3 separate possible spawn locations to patrol around, I assume we can set the waypoints the same for any of them in the same way. But how do we set multiple spawn locations for an NPC? And if that works well, how can we script that certain spawns correspond to certain waypoint patrol assignments?

Maybe I should just start with getting an NPC to patrol around it's current spawn point?
There are very few NPCs who spawn in different locations and from what I've seen there's not really no functionality for it unless the NPC is spawned by a script.

Make it patrol in the area where it's currently spawned.
HAI
CAN HAZ STDIO?
VISIBLE "HAI WORLD, IZ GNURF!"
KTHXBYE

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest