AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
wp_commandscript Class Reference
Inheritance diagram for wp_commandscript:
CommandScript ScriptObject

Public Member Functions

 wp_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleWpAddCommand (ChatHandler *handler, const char *args)
 
static bool HandleWpLoadCommand (ChatHandler *handler, const char *args)
 
static bool HandleWpReloadCommand (ChatHandler *handler, const char *args)
 
static bool HandleWpUnLoadCommand (ChatHandler *handler, const char *)
 
static bool HandleWpEventCommand (ChatHandler *handler, const char *args)
 
static bool HandleWpModifyCommand (ChatHandler *handler, const char *args)
 
static bool HandleWpShowCommand (ChatHandler *handler, const char *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ wp_commandscript()

wp_commandscript::wp_commandscript ( )
inline
39: CommandScript("wp_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable wp_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable wpCommandTable =
44 {
45 { "add", HandleWpAddCommand, SEC_ADMINISTRATOR, Console::No },
46 { "event", HandleWpEventCommand, SEC_ADMINISTRATOR, Console::No },
47 { "load", HandleWpLoadCommand, SEC_ADMINISTRATOR, Console::No },
48 { "modify", HandleWpModifyCommand, SEC_ADMINISTRATOR, Console::No },
49 { "unload", HandleWpUnLoadCommand, SEC_ADMINISTRATOR, Console::No },
50 { "reload", HandleWpReloadCommand, SEC_ADMINISTRATOR, Console::No },
51 { "show", HandleWpShowCommand, SEC_ADMINISTRATOR, Console::No }
52 };
53 static ChatCommandTable commandTable =
54 {
55 { "wp", wpCommandTable }
56 };
57 return commandTable;
58 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleWpEventCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:278
static bool HandleWpLoadCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:143
static bool HandleWpReloadCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:222
static bool HandleWpModifyCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:550
static bool HandleWpUnLoadCommand(ChatHandler *handler, const char *)
Definition: cs_wp.cpp:237
static bool HandleWpShowCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:746
static bool HandleWpAddCommand(ChatHandler *handler, const char *args)
Definition: cs_wp.cpp:80

References HandleWpAddCommand(), HandleWpEventCommand(), HandleWpLoadCommand(), HandleWpModifyCommand(), HandleWpReloadCommand(), HandleWpShowCommand(), HandleWpUnLoadCommand(), and SEC_ADMINISTRATOR.

◆ HandleWpAddCommand()

static bool wp_commandscript::HandleWpAddCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic

Add a waypoint to a creature.

The user can either select an npc or provide its GUID.

The user can even select a visual waypoint - then the new waypoint is placed after the selected one - this makes insertion of new waypoints possible.

eg: .wp add 12345 -> adds a waypoint to the npc with the GUID 12345

.wp add -> adds a waypoint to the currently selected creature

Parameters
argsif the user did not provide a GUID, it is nullptr
Returns
true - command did succeed, false - something went wrong
81 {
82 // optional
83 char* path_number = nullptr;
84 uint32 pathid = 0;
85
86 if (*args)
87 path_number = strtok((char*)args, " ");
88
89 uint32 point = 0;
90 Creature* target = handler->getSelectedCreature();
91
92 if (!path_number)
93 {
94 if (target)
95 pathid = target->GetWaypointPath();
96 else
97 {
99
100 PreparedQueryResult result = WorldDatabase.Query(stmt);
101
102 uint32 maxpathid = result->Fetch()->Get<int32>();
103 pathid = maxpathid + 1;
104 handler->PSendSysMessage("{}{}|r", "|cff00ff00", "New path started.");
105 }
106 }
107 else
108 pathid = atoi(path_number);
109
110 // path_id -> ID of the Path
111 // point -> number of the waypoint (if not 0)
112
113 if (!pathid)
114 {
115 handler->PSendSysMessage("{}{}|r", "|cffff33ff", "Current creature haven't loaded path.");
116 return true;
117 }
118
120 stmt->SetData(0, pathid);
121 PreparedQueryResult result = WorldDatabase.Query(stmt);
122
123 if (result)
124 point = (*result)[0].Get<uint32>();
125
126 Player* player = handler->GetSession()->GetPlayer();
127 //Map* map = player->GetMap();
128
129 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA);
130
131 stmt->SetData(0, pathid);
132 stmt->SetData(1, point + 1);
133 stmt->SetData(2, player->GetPositionX());
134 stmt->SetData(3, player->GetPositionY());
135 stmt->SetData(4, player->GetPositionZ());
136
137 WorldDatabase.Execute(stmt);
138
139 handler->PSendSysMessage("{}{}{}{}{}{}|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point + 1, "|r|cff00ff00 created. ");
140 return true;
141 } // HandleWpAddCommand
std::int32_t int32
Definition: Define.h:103
std::uint32_t uint32
Definition: Define.h:107
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:46
@ WORLD_INS_WAYPOINT_DATA
Definition: WorldDatabase.h:53
@ WORLD_SEL_WAYPOINT_DATA_MAX_ID
Definition: WorldDatabase.h:59
@ WORLD_SEL_WAYPOINT_DATA_MAX_POINT
Definition: WorldDatabase.h:66
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
WorldSession * GetSession()
Definition: Chat.h:244
Creature * getSelectedCreature() const
Definition: Chat.cpp:412
Definition: Creature.h:46
uint32 GetWaypointPath() const
Definition: Creature.h:347
Definition: Player.h:1064
Player * GetPlayer() const
Definition: WorldSession.h:362

References WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetWaypointPath(), ChatHandler::PSendSysMessage(), PreparedStatementBase::SetData(), WORLD_INS_WAYPOINT_DATA, WORLD_SEL_WAYPOINT_DATA_MAX_ID, WORLD_SEL_WAYPOINT_DATA_MAX_POINT, and WorldDatabase.

Referenced by GetCommands().

◆ HandleWpEventCommand()

static bool wp_commandscript::HandleWpEventCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
279 {
280 if (!*args)
281 return false;
282
283 char* show_str = strtok((char*)args, " ");
284 std::string show = show_str;
285
286 // Check
287 if ((show != "add") && (show != "mod") && (show != "del") && (show != "listid"))
288 return false;
289
290 char* arg_id = strtok(nullptr, " ");
291 uint32 id = 0;
292
293 if (show == "add")
294 {
295 if (arg_id)
296 id = atoi(arg_id);
297
298 if (id)
299 {
301 stmt->SetData(0, id);
302 PreparedQueryResult result = WorldDatabase.Query(stmt);
303
304 if (!result)
305 {
307
308 stmt->SetData(0, id);
309
310 WorldDatabase.Execute(stmt);
311
312 handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id);
313 }
314 else
315 handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: {}|r", id);
316 }
317 else
318 {
320
321 PreparedQueryResult result = WorldDatabase.Query(stmt);
322
323 id = result->Fetch()->Get<uint32>();
324
325 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT);
326
327 stmt->SetData(0, id + 1);
328
329 WorldDatabase.Execute(stmt);
330
331 handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: New waypoint event added: |r|cff00ffff", id + 1);
332 }
333
334 return true;
335 }
336
337 if (show == "listid")
338 {
339 if (!arg_id)
340 {
341 handler->PSendSysMessage("{}{}|r", "|cff33ffff", "Wp Event: You must provide waypoint script id.");
342 return true;
343 }
344
345 id = atoi(arg_id);
346
347 uint32 a2, a3, a4, a5, a6;
348 float a8, a9, a10, a11;
349 char const* a7;
350
352 stmt->SetData(0, id);
353 PreparedQueryResult result = WorldDatabase.Query(stmt);
354
355 if (!result)
356 {
357 handler->PSendSysMessage("{}{}{}|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id);
358 return true;
359 }
360
361 Field* fields;
362
363 do
364 {
365 fields = result->Fetch();
366 a2 = fields[0].Get<uint32>();
367 a3 = fields[1].Get<uint32>();
368 a4 = fields[2].Get<uint32>();
369 a5 = fields[3].Get<uint32>();
370 a6 = fields[4].Get<uint32>();
371 a7 = fields[5].Get<std::string>().c_str();
372 a8 = fields[6].Get<float>();
373 a9 = fields[7].Get<float>();
374 a10 = fields[8].Get<float>();
375 a11 = fields[9].Get<float>();
376
377 handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff {}|r|cff00ff00, guid: |r|cff00ffff{}|r|cff00ff00, delay: |r|cff00ffff{}|r|cff00ff00, command: |r|cff00ffff{}|r|cff00ff00, datalong: |r|cff00ffff{}|r|cff00ff00, datalong2: |r|cff00ffff{}|r|cff00ff00, datatext: |r|cff00ffff{}|r|cff00ff00, posx: |r|cff00ffff{}|r|cff00ff00, posy: |r|cff00ffff{}|r|cff00ff00, posz: |r|cff00ffff{}|r|cff00ff00, orientation: |r|cff00ffff{}|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
378 } while (result->NextRow());
379 }
380
381 if (show == "del")
382 {
383 if (!arg_id)
384 {
385 handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
386 return true;
387 }
388
389 id = atoi(arg_id);
390
392
393 stmt->SetData(0, id);
394
395 PreparedQueryResult result = WorldDatabase.Query(stmt);
396
397 if (result)
398 {
400
401 stmt->SetData(0, id);
402
403 WorldDatabase.Execute(stmt);
404
405 handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: Waypoint script removed: ", id);
406 }
407 else
408 handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: {}|r", id);
409
410 return true;
411 }
412
413 if (show == "mod")
414 {
415 if (!arg_id)
416 {
417 handler->SendSysMessage("|cffff33ffERROR: Waypoint script guid not present.|r");
418 return true;
419 }
420
421 id = atoi(arg_id);
422
423 if (!id)
424 {
425 handler->SendSysMessage("|cffff33ffERROR: No vallid waypoint script id not present.|r");
426 return true;
427 }
428
429 char* arg_2 = strtok(nullptr, " ");
430
431 if (!arg_2)
432 {
433 handler->SendSysMessage("|cffff33ffERROR: No argument present.|r");
434 return true;
435 }
436
437 std::string arg_string = arg_2;
438
439 if ((arg_string != "setid") && (arg_string != "delay") && (arg_string != "command")
440 && (arg_string != "datalong") && (arg_string != "datalong2") && (arg_string != "dataint") && (arg_string != "posx")
441 && (arg_string != "posy") && (arg_string != "posz") && (arg_string != "orientation"))
442 {
443 handler->SendSysMessage("|cffff33ffERROR: No valid argument present.|r");
444 return true;
445 }
446
447 char* arg_3;
448 std::string arg_str_2 = arg_2;
449 arg_3 = strtok(nullptr, " ");
450
451 if (!arg_3)
452 {
453 handler->SendSysMessage("|cffff33ffERROR: No additional argument present.|r");
454 return true;
455 }
456
457 if (arg_str_2 == "setid")
458 {
459 uint32 newid = atoi(arg_3);
460 handler->PSendSysMessage("{}{}|r|cff00ffff{}|r|cff00ff00{}|r|cff00ffff{}|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id);
461
463
464 stmt->SetData(0, newid);
465 stmt->SetData(1, id);
466
467 WorldDatabase.Execute(stmt);
468
469 return true;
470 }
471 else
472 {
474 stmt->SetData(0, id);
475 PreparedQueryResult result = WorldDatabase.Query(stmt);
476
477 if (!result)
478 {
479 handler->SendSysMessage("|cffff33ffERROR: You have selected an non existing waypoint script guid.|r");
480 return true;
481 }
482
483 if (arg_str_2 == "posx")
484 {
486
487 stmt->SetData(0, float(atof(arg_3)));
488 stmt->SetData(1, id);
489
490 WorldDatabase.Execute(stmt);
491
492 handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff {}|r|cff00ff00 position_x updated.|r", id);
493 return true;
494 }
495 else if (arg_str_2 == "posy")
496 {
498
499 stmt->SetData(0, float(atof(arg_3)));
500 stmt->SetData(1, id);
501
502 WorldDatabase.Execute(stmt);
503
504 handler->PSendSysMessage("|cff00ff00Waypoint script: {} position_y updated.|r", id);
505 return true;
506 }
507 else if (arg_str_2 == "posz")
508 {
510
511 stmt->SetData(0, float(atof(arg_3)));
512 stmt->SetData(1, id);
513
514 WorldDatabase.Execute(stmt);
515
516 handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 position_z updated.|r", id);
517 return true;
518 }
519 else if (arg_str_2 == "orientation")
520 {
522
523 stmt->SetData(0, float(atof(arg_3)));
524 stmt->SetData(1, id);
525
526 WorldDatabase.Execute(stmt);
527
528 handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 orientation updated.|r", id);
529 return true;
530 }
531 else if (arg_str_2 == "dataint")
532 {
533 WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement
534
535 handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 dataint updated.|r", id);
536 return true;
537 }
538 else
539 {
540 std::string arg_str_3 = arg_3;
541 WorldDatabase.EscapeString(arg_str_3);
542 WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_str_3, id); // Query can't be a prepared statement
543 }
544 }
545 handler->PSendSysMessage("{}{}|r|cff00ffff{}:|r|cff00ff00 {} {}|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated.");
546 }
547 return true;
548 }
@ WORLD_UPD_WAYPOINT_SCRIPT_O
Definition: WorldDatabase.h:81
@ WORLD_UPD_WAYPOINT_SCRIPT_Z
Definition: WorldDatabase.h:80
@ WORLD_UPD_WAYPOINT_SCRIPT_X
Definition: WorldDatabase.h:78
@ WORLD_INS_WAYPOINT_SCRIPT
Definition: WorldDatabase.h:75
@ WORLD_DEL_WAYPOINT_SCRIPT
Definition: WorldDatabase.h:76
@ WORLD_SEL_WAYPOINT_SCRIPTS_MAX_ID
Definition: WorldDatabase.h:70
@ WORLD_SEL_WAYPOINT_SCRIPT_BY_ID
Definition: WorldDatabase.h:86
@ WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID
Definition: WorldDatabase.h:82
@ WORLD_UPD_WAYPOINT_SCRIPT_Y
Definition: WorldDatabase.h:79
@ WORLD_UPD_WAYPOINT_SCRIPT_ID
Definition: WorldDatabase.h:77
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:162

References Field::Get(), ChatHandler::PSendSysMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), WORLD_DEL_WAYPOINT_SCRIPT, WORLD_INS_WAYPOINT_SCRIPT, WORLD_SEL_WAYPOINT_SCRIPT_BY_ID, WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID, WORLD_SEL_WAYPOINT_SCRIPTS_MAX_ID, WORLD_UPD_WAYPOINT_SCRIPT_ID, WORLD_UPD_WAYPOINT_SCRIPT_O, WORLD_UPD_WAYPOINT_SCRIPT_X, WORLD_UPD_WAYPOINT_SCRIPT_Y, WORLD_UPD_WAYPOINT_SCRIPT_Z, and WorldDatabase.

Referenced by GetCommands().

◆ HandleWpLoadCommand()

static bool wp_commandscript::HandleWpLoadCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
144 {
145 if (!*args)
146 return false;
147
148 // optional
149 char* path_number = nullptr;
150
151 if (*args)
152 path_number = strtok((char*)args, " ");
153
154 uint32 pathid = 0;
155 ObjectGuid::LowType guidLow = 0;
156 Creature* target = handler->getSelectedCreature();
157
158 // Did player provide a path_id?
159 if (!path_number)
160 return false;
161
162 if (!target)
163 {
165 return false;
166 }
167
168 if (target->GetEntry() == 1)
169 {
170 handler->SendErrorMessage("{}{}|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?");
171 return false;
172 }
173
174 pathid = atoi(path_number);
175
176 if (!pathid)
177 {
178 handler->PSendSysMessage("{}{}|r", "|cffff33ff", "No valid path number provided.");
179 return true;
180 }
181
182 guidLow = target->GetSpawnId();
183
185
186 stmt->SetData(0, guidLow);
187
188 PreparedQueryResult result = WorldDatabase.Query(stmt);
189
190 if (result)
191 {
192 stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ADDON_PATH);
193
194 stmt->SetData(0, pathid);
195 stmt->SetData(1, guidLow);
196 }
197 else
198 {
199 stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_ADDON);
200
201 stmt->SetData(0, guidLow);
202 stmt->SetData(1, pathid);
203 }
204
205 WorldDatabase.Execute(stmt);
206
207 stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
208
210 stmt->SetData(1, guidLow);
211
212 WorldDatabase.Execute(stmt);
213
214 target->LoadPath(pathid);
216 target->GetMotionMaster()->Initialize();
217 target->Say("Path loaded.", LANG_UNIVERSAL);
218
219 return true;
220 }
std::uint8_t uint8
Definition: Define.h:109
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:39
@ LANG_SELECT_CREATURE
Definition: Language.h:32
@ WORLD_INS_CREATURE_ADDON
Definition: WorldDatabase.h:72
@ WORLD_SEL_CREATURE_ADDON_BY_GUID
Definition: WorldDatabase.h:74
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
Definition: WorldDatabase.h:46
@ WORLD_UPD_CREATURE_ADDON_PATH
Definition: WorldDatabase.h:71
@ LANG_UNIVERSAL
Definition: SharedDefines.h:735
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:68
void SetDefaultMovementType(MovementGeneratorType mgt)
Definition: Creature.h:89
void LoadPath(uint32 pathid)
Definition: Creature.h:348
uint32 GetEntry() const
Definition: Object.h:112
uint32 LowType
Definition: ObjectGuid.h:122
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21095
MotionMaster * GetMotionMaster()
Definition: Unit.h:1601
void Initialize()
Definition: MotionMaster.cpp:73

References Object::GetEntry(), Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), MotionMaster::Initialize(), LANG_SELECT_CREATURE, LANG_UNIVERSAL, Creature::LoadPath(), ChatHandler::PSendSysMessage(), Unit::Say(), ChatHandler::SendErrorMessage(), PreparedStatementBase::SetData(), Creature::SetDefaultMovementType(), WAYPOINT_MOTION_TYPE, WORLD_INS_CREATURE_ADDON, WORLD_SEL_CREATURE_ADDON_BY_GUID, WORLD_UPD_CREATURE_ADDON_PATH, WORLD_UPD_CREATURE_MOVEMENT_TYPE, and WorldDatabase.

Referenced by GetCommands().

◆ HandleWpModifyCommand()

static bool wp_commandscript::HandleWpModifyCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
551 {
552 if (!*args)
553 return false;
554
555 // first arg: add del text emote spell waittime move
556 char* show_str = strtok((char*)args, " ");
557 if (!show_str)
558 {
559 return false;
560 }
561
562 std::string show = show_str;
563 // Check
564 // Remember: "show" must also be the name of a column!
565 if ((show != "delay") && (show != "action") && (show != "action_chance")
566 && (show != "move_type") && (show != "del") && (show != "move") && (show != "wpadd")
567 )
568 {
569 return false;
570 }
571
572 // Next arg is: <PATHID> <WPNUM> <ARGUMENT>
573 char* arg_str = nullptr;
574
575 // Did user provide a GUID
576 // or did the user select a creature?
577 // -> variable lowguid is filled with the GUID of the NPC
578 uint32 pathid = 0;
579 uint32 point = 0;
580 Creature* target = handler->getSelectedCreature();
581
582 if (!target || target->GetEntry() != VISUAL_WAYPOINT)
583 {
584 handler->SendSysMessage("|cffff33ffERROR: You must select a waypoint.|r");
585 return false;
586 }
587
588 // The visual waypoint
589 ObjectGuid::LowType wpSpawnId = target->GetSpawnId();
590
591 // User did select a visual waypoint?
592
593 // Check the creature
595 stmt->SetData(0, wpSpawnId);
596 PreparedQueryResult result = WorldDatabase.Query(stmt);
597
598 if (!result)
599 {
601 // Select waypoint number from database
602 // Since we compare float values, we have to deal with
603 // some difficulties.
604 // Here we search for all waypoints that only differ in one from 1 thousand
605 // (0.001) - There is no other way to compare C++ floats with mySQL floats
606 // See also: http://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
607 std::string maxDiff = "0.01";
608
610 stmt->SetData(0, target->GetPositionX());
611 stmt->SetData(1, maxDiff);
612 stmt->SetData(2, target->GetPositionY());
613 stmt->SetData(3, maxDiff);
614 stmt->SetData(4, target->GetPositionZ());
615 stmt->SetData(5, maxDiff);
616 PreparedQueryResult result = WorldDatabase.Query(stmt);
617
618 if (!result)
619 {
621 return true;
622 }
623 }
624
625 do
626 {
627 Field* fields = result->Fetch();
628 pathid = fields[0].Get<uint32>();
629 point = fields[1].Get<uint32>();
630 } while (result->NextRow());
631
632 // We have the waypoint number and the GUID of the "master npc"
633 // Text is enclosed in "<>", all other arguments not
634 arg_str = strtok((char*)nullptr, " ");
635
636 // Check for argument
637 if (show != "del" && show != "move" && arg_str == nullptr)
638 {
639 handler->PSendSysMessage(LANG_WAYPOINT_ARGUMENTREQ, show_str);
640 return false;
641 }
642
643 if (show == "del")
644 {
645 handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff{}|r", pathid);
646
647 if (wpSpawnId != 0)
648 if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(target->GetGUID()))
649 {
650 wpCreature->CombatStop();
651 wpCreature->DeleteFromDB();
652 wpCreature->AddObjectToRemoveList();
653 }
654
656 stmt->SetData(0, pathid);
657 stmt->SetData(1, point);
658
659 WorldDatabase.Execute(stmt);
660
661 stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT);
662 stmt->SetData(0, pathid);
663 stmt->SetData(1, point);
664
665 WorldDatabase.Execute(stmt);
666
668 return true;
669 } // del
670
671 if (show == "move")
672 {
673 handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff{}|r", pathid);
674
675 Player* chr = handler->GetSession()->GetPlayer();
676 Map* map = chr->GetMap();
677 {
678 // What to do:
679 // Move the visual spawnpoint
680 // Respawn the owner of the waypoints
681 if (wpSpawnId != 0)
682 {
683 if (Creature* wpCreature = map->GetCreature(target->GetGUID()))
684 {
685 wpCreature->CombatStop();
686 wpCreature->DeleteFromDB();
687 wpCreature->AddObjectToRemoveList();
688 }
689 // re-create
690 Creature* wpCreature2 = new Creature;
691 if (!wpCreature2->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
692 {
694 delete wpCreature2;
695 wpCreature2 = nullptr;
696 return false;
697 }
698
699 wpCreature2->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
700 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
701 //TODO: Should we first use "Create" then use "LoadFromDB"?
702 if (!wpCreature2->LoadCreatureFromDB(wpCreature2->GetSpawnId(), map, true, true))
703 {
705 delete wpCreature2;
706 wpCreature2 = nullptr;
707 return false;
708 }
709 //sMapMgr->GetMap(npcCreature->GetMapId())->Add(wpCreature2);
710 }
711
713
714 stmt->SetData(0, chr->GetPositionX());
715 stmt->SetData(1, chr->GetPositionY());
716 stmt->SetData(2, chr->GetPositionZ());
717 stmt->SetData(3, pathid);
718 stmt->SetData(4, point);
719
720 WorldDatabase.Execute(stmt);
721
723 }
724 return true;
725 } // move
726
727 const char* text = arg_str;
728
729 if (text == 0)
730 {
731 // show_str check for present in list of correct values, no sql injection possible
732 WorldDatabase.Execute("UPDATE waypoint_data SET {}=nullptr WHERE id='{}' AND point='{}'", show_str, pathid, point); // Query can't be a prepared statement
733 }
734 else
735 {
736 // show_str check for present in list of correct values, no sql injection possible
737 std::string text2 = text;
738 WorldDatabase.EscapeString(text2);
739 WorldDatabase.Execute("UPDATE waypoint_data SET {}='{}' WHERE id='{}' AND point='{}'", show_str, text2, pathid, point); // Query can't be a prepared statement
740 }
741
742 handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str);
743 return true;
744 }
#define VISUAL_WAYPOINT
Definition: MotionMaster.h:32
@ LANG_WAYPOINT_REMOVED
Definition: Language.h:282
@ LANG_WAYPOINT_CHANGED
Definition: Language.h:277
@ LANG_WAYPOINT_CHANGED_NO
Definition: Language.h:278
@ LANG_WAYPOINT_ARGUMENTREQ
Definition: Language.h:274
@ LANG_WAYPOINT_VP_NOTCREATED
Definition: Language.h:269
@ LANG_WAYPOINT_NOTFOUNDDBPROBLEM
Definition: Language.h:264
@ LANG_WAYPOINT_NOTFOUNDSEARCH
Definition: Language.h:263
@ WORLD_SEL_WAYPOINT_DATA_BY_WPGUID
Definition: WorldDatabase.h:64
@ WORLD_DEL_WAYPOINT_DATA
Definition: WorldDatabase.h:54
@ WORLD_UPD_WAYPOINT_DATA_POINT
Definition: WorldDatabase.h:55
@ WORLD_UPD_WAYPOINT_DATA_POSITION
Definition: WorldDatabase.h:56
@ WORLD_SEL_WAYPOINT_DATA_BY_POS
Definition: WorldDatabase.h:67
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition: Creature.cpp:1687
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData *data=nullptr)
Definition: Creature.cpp:1123
void SaveToDB()
Definition: Creature.cpp:1388
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
Map * GetMap() const
Definition: Object.h:531
float GetPositionZ() const
Definition: Position.h:119
float GetOrientation() const
Definition: Position.h:120
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetPhaseMaskForSpawn() const
Definition: Player.cpp:13769
Definition: Map.h:313
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2651
uint8 GetSpawnMode() const
Definition: Map.h:420
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:638
Creature * GetCreature(ObjectGuid const guid)
Definition: Map.cpp:3314
uint32 GetId() const
Definition: Map.h:379

References Map::AddObjectToRemoveList(), Creature::Create(), Map::GenerateLowGuid(), Field::Get(), Map::GetCreature(), Object::GetEntry(), Object::GetGUID(), Map::GetId(), WorldObject::GetMap(), Position::GetOrientation(), Player::GetPhaseMaskForSpawn(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetSpawnId(), Map::GetSpawnMode(), LANG_WAYPOINT_ARGUMENTREQ, LANG_WAYPOINT_CHANGED, LANG_WAYPOINT_CHANGED_NO, LANG_WAYPOINT_NOTFOUNDDBPROBLEM, LANG_WAYPOINT_NOTFOUNDSEARCH, LANG_WAYPOINT_REMOVED, LANG_WAYPOINT_VP_NOTCREATED, Creature::LoadCreatureFromDB(), ChatHandler::PSendSysMessage(), Creature::SaveToDB(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetData(), VISUAL_WAYPOINT, WORLD_DEL_WAYPOINT_DATA, WORLD_SEL_WAYPOINT_DATA_BY_POS, WORLD_SEL_WAYPOINT_DATA_BY_WPGUID, WORLD_UPD_WAYPOINT_DATA_POINT, WORLD_UPD_WAYPOINT_DATA_POSITION, and WorldDatabase.

Referenced by GetCommands().

◆ HandleWpReloadCommand()

static bool wp_commandscript::HandleWpReloadCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
223 {
224 if (!*args)
225 return false;
226
227 uint32 id = atoi(args);
228
229 if (!id)
230 return false;
231
232 handler->PSendSysMessage("{}{}|r|cff00ffff{}|r", "|cff00ff00", "Loading Path: ", id);
233 sWaypointMgr->ReloadPath(id);
234 return true;
235 }
#define sWaypointMgr
Definition: WaypointMgr.h:78

References ChatHandler::PSendSysMessage(), and sWaypointMgr.

Referenced by GetCommands().

◆ HandleWpShowCommand()

static bool wp_commandscript::HandleWpShowCommand ( ChatHandler handler,
const char *  args 
)
inlinestatic
747 {
748 if (!*args)
749 return false;
750
751 // first arg: on, off, first, last
752 char* show_str = strtok((char*)args, " ");
753 if (!show_str)
754 return false;
755
756 // second arg: GUID (optional, if a creature is selected)
757 char* guid_str = strtok((char*)nullptr, " ");
758
759 uint32 pathid = 0;
760 Creature* target = handler->getSelectedCreature();
761
762 // Did player provide a PathID?
763
764 if (!guid_str)
765 {
766 // No PathID provided
767 // -> Player must have selected a creature
768
769 if (!target)
770 {
772 return false;
773 }
774
775 pathid = target->GetWaypointPath();
776 }
777 else
778 {
779 // PathID provided
780 // Warn if player also selected a creature
781 // -> Creature selection is ignored <-
782 if (target)
784
785 pathid = atoi((char*)guid_str);
786 }
787
788 std::string show = show_str;
789
790 //handler->PSendSysMessage("wpshow - show: {}", show);
791
792 // Show info for the selected waypoint
793 if (show == "info")
794 {
795 // Check if the user did specify a visual waypoint
796 if (!target || target->GetEntry() != VISUAL_WAYPOINT)
797 {
799 return false;
800 }
801
803
804 stmt->SetData(0, target->GetSpawnId());
805
806 PreparedQueryResult result = WorldDatabase.Query(stmt);
807
808 if (!result)
809 {
811 return true;
812 }
813
814 handler->SendSysMessage("|cff00ffffDEBUG: wp show info:|r");
815 do
816 {
817 Field* fields = result->Fetch();
818 pathid = fields[0].Get<uint32>();
819 uint32 point = fields[1].Get<uint32>();
820 uint32 delay = fields[2].Get<uint32>();
821 uint32 flag = fields[3].Get<uint32>();
822 uint32 ev_id = fields[4].Get<uint32>();
823 uint32 ev_chance = fields[5].Get<uint32>();
824
825 handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff{}|r|cff00ff00, Path ID: |r|cff00ffff{}|r", point, pathid);
826 handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff{}|r", delay);
827 handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff{}|r", flag);
828 handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff{}|r", ev_id);
829 handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff{}|r", ev_chance);
830 } while (result->NextRow());
831
832 return true;
833 }
834
835 if (show == "on")
836 {
838
839 stmt->SetData(0, pathid);
840
841 PreparedQueryResult result = WorldDatabase.Query(stmt);
842
843 if (!result)
844 {
845 handler->SendErrorMessage("|cffff33ffPath no found.|r");
846 return false;
847 }
848
849 handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff{}|r", pathid);
850
851 // Delete all visuals for this NPC
852 stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID);
853
854 stmt->SetData(0, pathid);
855
856 PreparedQueryResult result2 = WorldDatabase.Query(stmt);
857
858 if (result2)
859 {
860 bool hasError = false;
861 do
862 {
863 Field* fields = result2->Fetch();
864 uint32 wpguid = fields[0].Get<uint32>();
865 Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid));
866
867 if (!creature)
868 {
870 hasError = true;
871
873 stmt->SetData(0, wpguid);
874
875 WorldDatabase.Execute(stmt);
876 }
877 else
878 {
879 creature->CombatStop();
880 creature->DeleteFromDB();
881 creature->AddObjectToRemoveList();
882 }
883 } while (result2->NextRow());
884
885 if (hasError)
886 {
890 }
891 }
892
893 do
894 {
895 Field* fields = result->Fetch();
896 uint32 point = fields[0].Get<uint32>();
897 float x = fields[1].Get<float>();
898 float y = fields[2].Get<float>();
899 float z = fields[3].Get<float>();
900
902
903 Player* chr = handler->GetSession()->GetPlayer();
904 Map* map = chr->GetMap();
905 float o = chr->GetOrientation();
906
907 Creature* wpCreature = new Creature;
908 if (!wpCreature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
909 {
911 delete wpCreature;
912 return false;
913 }
914
915 // Set "wpguid" column to the visual waypoint
917 stmt->SetData(0, int32(wpCreature->GetSpawnId()));
918 stmt->SetData(1, pathid);
919 stmt->SetData(2, point);
920
921 WorldDatabase.Execute(stmt);
922
923 wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
924 // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
925 if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map, true, true))
926 {
928 delete wpCreature;
929 return false;
930 }
931
932 if (target)
933 {
934 wpCreature->SetDisplayId(target->GetDisplayId());
935 wpCreature->SetObjectScale(0.5f);
936 wpCreature->SetLevel(point > STRONG_MAX_LEVEL ? STRONG_MAX_LEVEL : point);
937 }
938 } while (result->NextRow());
939
940 handler->SendSysMessage("|cff00ff00Showing the current creature's path.|r");
941 return true;
942 }
943
944 if (show == "first")
945 {
946 handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: {}|r", pathid);
947
949 stmt->SetData(0, pathid);
950
951 PreparedQueryResult result = WorldDatabase.Query(stmt);
952 if (!result)
953 {
955 return false;
956 }
957
958 Field* fields = result->Fetch();
959 float x = fields[0].Get<float>();
960 float y = fields[1].Get<float>();
961 float z = fields[2].Get<float>();
963
964 Player* chr = handler->GetSession()->GetPlayer();
965 float o = chr->GetOrientation();
966 Map* map = chr->GetMap();
967
968 Creature* creature = new Creature;
969 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
970 {
972 delete creature;
973 return false;
974 }
975
976 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
977 if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, true))
978 {
980 delete creature;
981 return false;
982 }
983
984 if (target)
985 {
986 creature->SetDisplayId(target->GetDisplayId());
987 creature->SetObjectScale(0.5f);
988 }
989
990 return true;
991 }
992
993 if (show == "last")
994 {
995 handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff{}|r", pathid);
996
998 stmt->SetData(0, pathid);
999
1000 PreparedQueryResult result = WorldDatabase.Query(stmt);
1001 if (!result)
1002 {
1004 return false;
1005 }
1006
1007 Field* fields = result->Fetch();
1008 float x = fields[0].Get<float>();
1009 float y = fields[1].Get<float>();
1010 float z = fields[2].Get<float>();
1011 float o = fields[3].Get<float>();
1013
1014 Player* chr = handler->GetSession()->GetPlayer();
1015 Map* map = chr->GetMap();
1016
1017 Creature* creature = new Creature;
1018 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, chr->GetPhaseMaskForSpawn(), id, 0, x, y, z, o))
1019 {
1021 delete creature;
1022 return false;
1023 }
1024
1025 creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMaskForSpawn());
1026 if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map, true, true))
1027 {
1029 delete creature;
1030 return false;
1031 }
1032
1033 if (target)
1034 {
1035 creature->SetDisplayId(target->GetDisplayId());
1036 creature->SetObjectScale(0.5f);
1037 }
1038
1039 return true;
1040 }
1041
1042 if (show == "off")
1043 {
1045 stmt->SetArguments(1, 1, 1);
1046
1047 PreparedQueryResult result = WorldDatabase.Query(stmt);
1048 if (!result)
1049 {
1051 return false;
1052 }
1053
1054 bool hasError = false;
1055
1056 do
1057 {
1058 Field* fields = result->Fetch();
1059 ObjectGuid::LowType guid = fields[0].Get<uint32>();
1060 Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid));
1061 if (!creature)
1062 {
1064 hasError = true;
1065
1067
1068 stmt->SetData(0, guid);
1069
1070 WorldDatabase.Execute(stmt);
1071 }
1072 else
1073 {
1074 creature->CombatStop();
1075 creature->DeleteFromDB();
1076 creature->AddObjectToRemoveList();
1077 }
1078 } while (result->NextRow());
1079
1080 // set "wpguid" column to "empty" - no visual waypoint spawned
1081 stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID);
1082
1083 WorldDatabase.Execute(stmt);
1084
1085 if (hasError)
1086 {
1090 }
1091
1093 return true;
1094 }
1095
1096 handler->PSendSysMessage("|cffff33ffDEBUG: wpshow - no valid command found|r");
1097 return true;
1098 }
@ LANG_WAYPOINT_TOOFAR2
Definition: Language.h:285
@ LANG_WAYPOINT_VP_NOTFOUND
Definition: Language.h:268
@ LANG_WAYPOINT_NOTFOUNDLAST
Definition: Language.h:262
@ LANG_WAYPOINT_NOTREMOVED
Definition: Language.h:283
@ LANG_WAYPOINT_NOTFOUND
Definition: Language.h:261
@ LANG_WAYPOINT_NOTCREATED
Definition: Language.h:271
@ LANG_WAYPOINT_CREATSELECTED
Definition: Language.h:265
@ LANG_WAYPOINT_VP_ALLREMOVED
Definition: Language.h:270
@ LANG_WAYPOINT_TOOFAR1
Definition: Language.h:284
@ LANG_WAYPOINT_VP_SELECT
Definition: Language.h:267
@ LANG_WAYPOINT_TOOFAR3
Definition: Language.h:286
@ WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID
Definition: WorldDatabase.h:63
@ WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID
Definition: WorldDatabase.h:62
@ WORLD_SEL_WAYPOINT_DATA_POS_BY_ID
Definition: WorldDatabase.h:61
@ WORLD_SEL_CREATURE_BY_ID
Definition: WorldDatabase.h:88
@ WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID
Definition: WorldDatabase.h:68
@ WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID
Definition: WorldDatabase.h:65
@ WORLD_UPD_WAYPOINT_DATA_WPGUID
Definition: WorldDatabase.h:57
@ WORLD_DEL_CREATURE
Definition: WorldDatabase.h:83
@ WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID
Definition: WorldDatabase.h:58
#define STRONG_MAX_LEVEL
Definition: DBCEnums.h:43
void SetArguments(Args &&... args)
Definition: PreparedStatement.h:119
void SetObjectScale(float scale) override
Definition: Creature.cpp:3486
void SetDisplayId(uint32 displayId, float displayScale=1.f) override
Definition: Creature.cpp:3505
void SetLevel(uint8 lvl, bool showLevelChange=true)
Definition: Unit.cpp:15415
uint32 GetDisplayId() const
Definition: Unit.h:1507

References Creature::Create(), Map::GenerateLowGuid(), Field::Get(), Map::GetCreature(), Unit::GetDisplayId(), Object::GetEntry(), Map::GetId(), WorldObject::GetMap(), Position::GetOrientation(), Player::GetPhaseMaskForSpawn(), WorldSession::GetPlayer(), ChatHandler::getSelectedCreature(), ChatHandler::GetSession(), Creature::GetSpawnId(), Map::GetSpawnMode(), Creature::GetWaypointPath(), LANG_SELECT_CREATURE, LANG_WAYPOINT_CREATSELECTED, LANG_WAYPOINT_NOTCREATED, LANG_WAYPOINT_NOTFOUND, LANG_WAYPOINT_NOTFOUNDDBPROBLEM, LANG_WAYPOINT_NOTFOUNDLAST, LANG_WAYPOINT_NOTREMOVED, LANG_WAYPOINT_TOOFAR1, LANG_WAYPOINT_TOOFAR2, LANG_WAYPOINT_TOOFAR3, LANG_WAYPOINT_VP_ALLREMOVED, LANG_WAYPOINT_VP_NOTCREATED, LANG_WAYPOINT_VP_NOTFOUND, LANG_WAYPOINT_VP_SELECT, Creature::LoadCreatureFromDB(), ChatHandler::PSendSysMessage(), Creature::SaveToDB(), ChatHandler::SendErrorMessage(), ChatHandler::SendSysMessage(), PreparedStatementBase::SetArguments(), PreparedStatementBase::SetData(), Creature::SetDisplayId(), Unit::SetLevel(), Creature::SetObjectScale(), STRONG_MAX_LEVEL, VISUAL_WAYPOINT, WORLD_DEL_CREATURE, WORLD_SEL_CREATURE_BY_ID, WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID, WORLD_SEL_WAYPOINT_DATA_POS_BY_ID, WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID, WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID, WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID, WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID, WORLD_UPD_WAYPOINT_DATA_WPGUID, and WorldDatabase.

Referenced by GetCommands().

◆ HandleWpUnLoadCommand()

static bool wp_commandscript::HandleWpUnLoadCommand ( ChatHandler handler,
const char *   
)
inlinestatic
238 {
239 Creature* target = handler->getSelectedCreature();
240
241 if (!target)
242 {
243 handler->PSendSysMessage("{}{}|r", "|cff33ffff", "You must select target.");
244 return true;
245 }
246
247 uint32 guildLow = target->GetSpawnId();
248
249 if (target->GetCreatureAddon())
250 {
251 if (target->GetCreatureAddon()->path_id != 0)
252 {
254 stmt->SetData(0, guildLow);
255
256 WorldDatabase.Execute(stmt);
257
258 target->UpdateWaypointID(0);
259
260 stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE);
261 stmt->SetData(0, uint8(IDLE_MOTION_TYPE));
262 stmt->SetData(1, guildLow);
263
264 WorldDatabase.Execute(stmt);
265
266 target->LoadPath(0);
269 target->GetMotionMaster()->Initialize();
270 target->Say("Path unloaded.", LANG_UNIVERSAL);
271 return true;
272 }
273 handler->PSendSysMessage("{}{}|r", "|cffff33ff", "Target have no loaded path.");
274 }
275 return true;
276 }
@ IDLE_MOTION_TYPE
Definition: MotionMaster.h:37
@ WORLD_DEL_CREATURE_ADDON
Definition: WorldDatabase.h:73
void UpdateWaypointID(uint32 wpID)
Definition: Creature.h:351
CreatureAddon const * GetCreatureAddon() const
Definition: Creature.cpp:2692
uint32 path_id
Definition: CreatureData.h:444
void MoveTargetedHome(bool walk=false)
The unit will return this initial position (owner for pets and summoned creatures)....
Definition: MotionMaster.cpp:259

References Creature::GetCreatureAddon(), Unit::GetMotionMaster(), ChatHandler::getSelectedCreature(), Creature::GetSpawnId(), IDLE_MOTION_TYPE, MotionMaster::Initialize(), LANG_UNIVERSAL, Creature::LoadPath(), MotionMaster::MoveTargetedHome(), CreatureAddon::path_id, ChatHandler::PSendSysMessage(), Unit::Say(), PreparedStatementBase::SetData(), Creature::SetDefaultMovementType(), Creature::UpdateWaypointID(), WORLD_DEL_CREATURE_ADDON, WORLD_UPD_CREATURE_MOVEMENT_TYPE, and WorldDatabase.

Referenced by GetCommands().