39#if TRINITY_COMPILER == TRINITY_COMPILER_GNU
40#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
50 static std::vector<ChatCommand> wpCommandTable =
60 static std::vector<ChatCommand> commandTable =
90 char* path_number =
nullptr;
94 path_number = strtok((
char*)args,
" ");
109 uint32 maxpathid = result->Fetch()->GetInt32();
110 pathid = maxpathid+1;
115 pathid = atoi(path_number);
122 handler->
PSendSysMessage(
"%s%s|r",
"|cffff33ff",
"Current creature haven't loaded path.");
131 point = (*result)[0].GetUInt32();
147 handler->
PSendSysMessage(
"%s%s%u%s%u%s|r",
"|cff00ff00",
"PathID: |r|cff00ffff", pathid,
"|r|cff00ff00: Waypoint |r|cff00ffff", point+1,
"|r|cff00ff00 created. ");
157 char* path_number =
nullptr;
160 path_number = strtok((
char*)args,
" ");
179 handler->
PSendSysMessage(
"%s%s|r",
"|cffff33ff",
"You want to load path to a waypoint? Aren't you?");
184 pathid = atoi(path_number);
188 handler->
PSendSysMessage(
"%s%s|r",
"|cffff33ff",
"No valid path number provided.");
242 handler->
PSendSysMessage(
"%s%s|r|cff00ffff%u|r",
"|cff00ff00",
"Loading Path: ",
id);
254 handler->
PSendSysMessage(
"%s%s|r",
"|cff33ffff",
"You must select a target.");
261 handler->
PSendSysMessage(
"%s%s|r",
"|cffff33ff",
"Target is not saved to DB.");
266 if (!addon || addon->
path_id == 0)
268 handler->
PSendSysMessage(
"%s%s|r",
"|cffff33ff",
"Target does not have a loaded path.");
296 char* show_str = strtok((
char*)args,
" ");
297 std::string show = show_str;
301 if ((show !=
"add") && (show !=
"mod") && (show !=
"del") && (show !=
"listid"))
304 char* arg_id = strtok(
nullptr,
" ");
310 id = Trinity::StringTo<uint32>(arg_id);
324 handler->
PSendSysMessage(
"%s%s%u|r",
"|cff00ff00",
"Wp Event: New waypoint event added: ", *
id);
327 handler->
PSendSysMessage(
"|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", *
id);
333 id = result->Fetch()->GetUInt32();
338 handler->
PSendSysMessage(
"%s%s%u|r",
"|cff00ff00",
"Wp Event: New waypoint event added: |r|cff00ffff", *
id+1);
344 if (show ==
"listid")
348 handler->
PSendSysMessage(
"%s%s|r",
"|cff33ffff",
"Wp Event: You must provide waypoint script id.");
352 uint32 id = Trinity::StringTo<uint32>(arg_id).value_or(0);
354 uint32 a2, a3, a4, a5, a6, a7;
355 float a8, a9, a10, a11;
363 handler->
PSendSysMessage(
"%s%s%u|r",
"|cff33ffff",
"Wp Event: No waypoint scripts found on id: ",
id);
371 fields = result->Fetch();
383 handler->
PSendSysMessage(
"|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, dataint: |r|cff00ffff%u|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r",
id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
385 while (result->NextRow());
392 handler->
SendSysMessage(
"|cffff33ffERROR: Waypoint script guid not present.|r");
396 uint32 id = Trinity::StringTo<uint32>(arg_id).value_or(0);
408 handler->
PSendSysMessage(
"%s%s%u|r",
"|cff00ff00",
"Wp Event: Waypoint script removed: ",
id);
411 handler->
PSendSysMessage(
"|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r",
id);
420 handler->
SendSysMessage(
"|cffff33ffERROR: Waypoint script guid not present.|r");
424 uint32 id = Trinity::StringTo<uint32>(arg_id).value_or(0);
428 handler->
SendSysMessage(
"|cffff33ffERROR: No vallid waypoint script id not present.|r");
432 char* arg_2 = strtok(
nullptr,
" ");
436 handler->
SendSysMessage(
"|cffff33ffERROR: No argument present.|r");
440 std::string arg_string = arg_2;
442 if ((arg_string !=
"setid") && (arg_string !=
"delay") && (arg_string !=
"command")
443 && (arg_string !=
"datalong") && (arg_string !=
"datalong2") && (arg_string !=
"dataint") && (arg_string !=
"posx")
444 && (arg_string !=
"posy") && (arg_string !=
"posz") && (arg_string !=
"orientation"))
446 handler->
SendSysMessage(
"|cffff33ffERROR: No valid argument present.|r");
451 std::string arg_str_2 = arg_2;
452 arg_3 = strtok(
nullptr,
" ");
456 handler->
SendSysMessage(
"|cffff33ffERROR: No additional argument present.|r");
460 if (arg_str_2 ==
"setid")
462 uint32 newid = Trinity::StringTo<uint32>(arg_3).value_or(0);
463 handler->
PSendSysMessage(
"%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r",
"|cff00ff00",
"Wp Event: Waypoint script guid: ", newid,
" id changed: ",
id);
480 handler->
SendSysMessage(
"|cffff33ffERROR: You have selected an non existing waypoint script guid.|r");
484 if (arg_str_2 ==
"posx")
487 stmt->
setFloat(0,
float(atof(arg_3)));
492 handler->
PSendSysMessage(
"|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r",
id);
495 else if (arg_str_2 ==
"posy")
498 stmt->
setFloat(0,
float(atof(arg_3)));
503 handler->
PSendSysMessage(
"|cff00ff00Waypoint script: %u position_y updated.|r",
id);
506 else if (arg_str_2 ==
"posz")
509 stmt->
setFloat(0,
float(atof(arg_3)));
514 handler->
PSendSysMessage(
"|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r",
id);
517 else if (arg_str_2 ==
"orientation")
520 stmt->
setFloat(0,
float(atof(arg_3)));
525 handler->
PSendSysMessage(
"|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r",
id);
528 else if (arg_str_2 ==
"dataint")
530 WorldDatabase.PExecute(
"UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_3,
id);
532 handler->
PSendSysMessage(
"|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r",
id);
537 std::string arg_str_3 = arg_3;
539 WorldDatabase.PExecute(
"UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_str_3,
id);
542 handler->
PSendSysMessage(
"%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r",
"|cff00ff00",
"Waypoint script:",
id, arg_2,
"updated.");
553 char* show_str = strtok((
char*)args,
" ");
559 std::string show = show_str;
562 if ((show !=
"delay") && (show !=
"action") && (show !=
"action_chance")
563 && (show !=
"move_type") && (show !=
"del") && (show !=
"move")
570 char* arg_str =
nullptr;
583 handler->
SendSysMessage(
"|cffff33ffERROR: You must select a waypoint.|r");
601 std::string maxDiff =
"0.01";
621 Field* fields = result->Fetch();
625 while (result->NextRow());
629 arg_str = strtok((
char*)
nullptr,
" ");
632 if (show !=
"del" && show !=
"move" && arg_str ==
nullptr)
640 handler->
PSendSysMessage(
"|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid);
667 handler->
PSendSysMessage(
"|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid);
712 const char *text = arg_str;
717 WorldDatabase.PExecute(
"UPDATE waypoint_data SET {}=NULL WHERE id='{}' AND point='{}'", show_str, pathid, point);
722 std::string text2 = text;
724 WorldDatabase.PExecute(
"UPDATE waypoint_data SET {}='{}' WHERE id='{}' AND point='{}'", show_str, text2, pathid, point);
737 char* show_str = strtok((
char*)args,
" ");
742 char* guid_str = strtok((
char*)
nullptr,
" ");
772 pathid = Trinity::StringTo<uint32>(guid_str).value_or(0);
775 std::string show = show_str;
803 Field* fields = result->Fetch();
811 handler->
PSendSysMessage(
"|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid);
812 handler->
PSendSysMessage(
"|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay);
813 handler->
PSendSysMessage(
"|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag);
814 handler->
PSendSysMessage(
"|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id);
815 handler->
PSendSysMessage(
"|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance);
817 while (result->NextRow());
835 handler->
PSendSysMessage(
"|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid);
846 bool hasError =
false;
849 Field* fields = result2->Fetch();
858 while (result2->NextRow());
870 Field* fields = result->Fetch();
914 while (result->NextRow());
916 handler->
SendSysMessage(
"|cff00ff00Showing the current creature's path.|r");
922 handler->
PSendSysMessage(
"|cff00ff00DEBUG: wp first, GUID: %u|r", pathid);
935 Field* fields = result->Fetch();
973 handler->
PSendSysMessage(
"|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid);
985 Field* fields = result->Fetch();
1032 bool hasError =
false;
1035 Field* fields = result->Fetch();
1044 while (result->NextRow());
1062 handler->
PSendSysMessage(
"|cffff33ffDEBUG: wpshow - no valid command found|r");
std::shared_ptr< PreparedResultSet > PreparedQueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
@ LANG_WAYPOINT_CHANGED_NO
@ LANG_WAYPOINT_ARGUMENTREQ
@ LANG_WAYPOINT_VP_NOTFOUND
@ LANG_WAYPOINT_NOTFOUNDLAST
@ LANG_WAYPOINT_VP_NOTCREATED
@ LANG_WAYPOINT_NOTREMOVED
@ LANG_WAYPOINT_NOTFOUNDDBPROBLEM
@ LANG_WAYPOINT_NOTFOUNDSEARCH
@ LANG_WAYPOINT_NOTCREATED
@ LANG_WAYPOINT_CREATSELECTED
@ LANG_WAYPOINT_VP_ALLREMOVED
@ LANG_WAYPOINT_VP_SELECT
std::optional< T > Optional
Optional helper class to wrap optional values within.
Role Based Access Control related classes definition.
@ WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID
@ WORLD_SEL_WAYPOINT_DATA_BY_WPGUID
@ WORLD_DEL_WAYPOINT_DATA
@ WORLD_UPD_WAYPOINT_SCRIPT_O
@ WORLD_INS_WAYPOINT_DATA
@ WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID
@ WORLD_INS_CREATURE_ADDON
@ WORLD_SEL_CREATURE_ADDON_BY_GUID
@ WORLD_UPD_WAYPOINT_DATA_POINT
@ WORLD_UPD_WAYPOINT_SCRIPT_Z
@ WORLD_UPD_WAYPOINT_DATA_POSITION
@ WORLD_UPD_CREATURE_MOVEMENT_TYPE
@ WORLD_SEL_WAYPOINT_DATA_BY_POS
@ WORLD_UPD_CREATURE_ADDON_PATH
@ WORLD_DEL_CREATURE_ADDON
@ WORLD_UPD_WAYPOINT_SCRIPT_X
@ WORLD_INS_WAYPOINT_SCRIPT
@ WORLD_SEL_WAYPOINT_DATA_POS_BY_ID
@ WORLD_SEL_CREATURE_BY_ID
@ WORLD_DEL_WAYPOINT_SCRIPT
@ WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID
@ WORLD_SEL_WAYPOINT_SCRIPTS_MAX_ID
@ WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID
@ WORLD_UPD_WAYPOINT_DATA_WPGUID
@ WORLD_SEL_WAYPOINT_SCRIPT_BY_ID
@ WORLD_UPD_WAYPOINT_DATA_ALL_WPGUID
@ WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID
@ WORLD_SEL_WAYPOINT_DATA_MAX_ID
@ WORLD_SEL_WAYPOINT_DATA_MAX_POINT
@ WORLD_UPD_WAYPOINT_SCRIPT_Y
@ WORLD_UPD_WAYPOINT_SCRIPT_ID
WorldSession * GetSession()
Creature * getSelectedCreature()
void SetSentErrorMessage(bool val)
void PSendSysMessage(char const *fmt, Args &&... args)
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
void SetDisplayId(uint32 modelId) override
void SetObjectScale(float scale) override
uint32 GetWaypointPath() const
void UpdateCurrentWaypointInfo(uint32 nodeId, uint32 pathId)
ObjectGuid::LowType GetSpawnId() const
static bool DeleteFromDB(ObjectGuid::LowType spawnId)
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, Position const &pos, CreatureData const *data=nullptr, uint32 vehId=0, bool dynamic=false)
void SetDefaultMovementType(MovementGeneratorType mgt)
void LoadPath(uint32 pathid)
Class used to access individual fields of database query result.
uint8 GetSpawnMode() const
ObjectGuid::LowType GenerateLowGuid()
uint32 GetPhaseMaskForSpawn() const
void setUInt32(uint8 index, uint32 value)
void setFloat(uint8 index, float value)
void setUInt8(uint8 index, uint8 value)
void setString(uint8 index, std::string const &value)
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
MotionMaster * GetMotionMaster()
uint32 GetDisplayId() const
void SetLevel(uint8 lvl, bool sendUpdate=true)
Player * GetPlayer() const
static bool HandleWpShowCommand(ChatHandler *handler, char const *args)
static bool HandleWpAddCommand(ChatHandler *handler, char const *args)
static bool HandleWpUnLoadCommand(ChatHandler *handler, char const *)
static bool HandleWpLoadCommand(ChatHandler *handler, char const *args)
std::vector< ChatCommand > GetCommands() const override
static bool HandleWpEventCommand(ChatHandler *handler, char const *args)
static bool HandleWpModifyCommand(ChatHandler *handler, char const *args)
static bool HandleWpReloadCommand(ChatHandler *handler, char const *args)
void AddSC_wp_commandscript()
@ RBAC_PERM_COMMAND_WP_SHOW
@ RBAC_PERM_COMMAND_WP_MODIFY
@ RBAC_PERM_COMMAND_WP_UNLOAD
@ RBAC_PERM_COMMAND_WP_LOAD
@ RBAC_PERM_COMMAND_WP_ADD
@ RBAC_PERM_COMMAND_WP_EVENT
@ RBAC_PERM_COMMAND_WP_RELOAD
float GetPositionZ() const
float GetOrientation() const
float GetPositionX() const
float GetPositionY() const