TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
go_commandscript Class Reference

Public Member Functions

 go_commandscript ()
 
std::vector< ChatCommandGetCommands () const override
 
- Public Member Functions inherited from ScriptObject
const std::string & GetName () const
 

Static Public Member Functions

static bool HandleGoCreatureCommand (ChatHandler *handler, char const *args)
 Teleport the GM to the specified creature. More...
 
static bool HandleGoGraveyardCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoGridCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoObjectCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoQuestCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoTaxinodeCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoTriggerCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoZoneXYCommand (ChatHandler *handler, char const *args)
 
static bool HandleGoXYZCommand (ChatHandler *handler, char const *args)
 
template<typename T >
static bool HandleGoTicketCommand (ChatHandler *handler, char const *args)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()
 

Constructor & Destructor Documentation

go_commandscript::go_commandscript ( )
inline
37 : CommandScript("go_commandscript") { }
CommandScript(const char *name)
Definition: ScriptMgr.cpp:1616

Member Function Documentation

std::vector<ChatCommand> go_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

40  {
41  static std::vector<ChatCommand> goCommandTable =
42  {
51  { "xyz", rbac::RBAC_PERM_COMMAND_GO_XYZ, false, &HandleGoXYZCommand, "" },
52  { "bugticket", rbac::RBAC_PERM_COMMAND_GO_BUG_TICKET, false, &HandleGoTicketCommand<BugTicket>, "" },
53  { "complaintticket", rbac::RBAC_PERM_COMMAND_GO_COMPLAINT_TICKET, false, &HandleGoTicketCommand<ComplaintTicket>, "" },
54  { "suggestionticket", rbac::RBAC_PERM_COMMAND_GO_SUGGESTION_TICKET, false, &HandleGoTicketCommand<SuggestionTicket>, "" },
56  };
57 
58  static std::vector<ChatCommand> commandTable =
59  {
60  { "go", rbac::RBAC_PERM_COMMAND_GO, false, NULL, "", goCommandTable },
61  };
62  return commandTable;
63  }
static bool HandleGoTaxinodeCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:374
Definition: RBAC.h:728
static bool HandleGoZoneXYCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:465
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: RBAC.h:292
Definition: RBAC.h:288
static bool HandleGoQuestCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:309
static bool HandleGoTriggerCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:419
static bool HandleGoGridCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:208
static bool HandleGoCreatureCommand(ChatHandler *handler, char const *args)
Teleport the GM to the specified creature.
Definition: cs_go.cpp:76
static bool HandleGoXYZCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:538
Definition: RBAC.h:293
static bool HandleGoGraveyardCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:162
Definition: RBAC.h:287
Definition: RBAC.h:284
static bool HandleGoObjectCommand(ChatHandler *handler, char const *args)
Definition: cs_go.cpp:253

+ Here is the call graph for this function:

static bool go_commandscript::HandleGoCreatureCommand ( ChatHandler handler,
char const args 
)
inlinestatic

Teleport the GM to the specified creature.

.gocreature <GUID> –> TP using creature.guid .gocreature azuregos –> TP player to the mob with this name Warning: If there is more than one mob with this name you will be teleported to the first one that is found. .gocreature id 6109 –> TP player to the mob, that has this creature_template.entry Warning: If there is more than one mob with this "id" you will be teleported to the first one that is found.

77  {
78  if (!*args)
79  return false;
80 
81  Player* player = handler->GetSession()->GetPlayer();
82 
83  // "id" or number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
84  char* param1 = handler->extractKeyFromLink((char*)args, "Hcreature");
85  if (!param1)
86  return false;
87 
88  std::ostringstream whereClause;
89 
90  // User wants to teleport to the NPC's template entry
91  if (strcmp(param1, "id") == 0)
92  {
93  // Get the "creature_template.entry"
94  // number or [name] Shift-click form |color|Hcreature_entry:creature_id|h[name]|h|r
95  char* tail = strtok(NULL, "");
96  if (!tail)
97  return false;
98  char* id = handler->extractKeyFromLink(tail, "Hcreature_entry");
99  if (!id)
100  return false;
101 
102  int32 entry = atoi(id);
103  if (!entry)
104  return false;
105 
106  whereClause << "WHERE id = '" << entry << '\'';
107  }
108  else
109  {
110  int32 guid = atoi(param1);
111 
112  // Number is invalid - maybe the user specified the mob's name
113  if (!guid)
114  {
115  std::string name = param1;
117  whereClause << ", creature_template WHERE creature.id = creature_template.entry AND creature_template.name " _LIKE_" '" << name << '\'';
118  }
119  else
120  whereClause << "WHERE guid = '" << guid << '\'';
121  }
122 
123  QueryResult result = WorldDatabase.PQuery("SELECT position_x, position_y, position_z, orientation, map FROM creature %s", whereClause.str().c_str());
124  if (!result)
125  {
127  handler->SetSentErrorMessage(true);
128  return false;
129  }
130  if (result->GetRowCount() > 1)
132 
133  Field* fields = result->Fetch();
134  float x = fields[0].GetFloat();
135  float y = fields[1].GetFloat();
136  float z = fields[2].GetFloat();
137  float o = fields[3].GetFloat();
138  uint32 mapId = fields[4].GetUInt16();
139 
140  if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId))
141  {
142  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
143  handler->SetSentErrorMessage(true);
144  return false;
145  }
146 
147  // stop flight if need
148  if (player->IsInFlight())
149  {
150  player->GetMotionMaster()->MovementExpired();
151  player->CleanupAfterTaxiFlight();
152  }
153  // save only in non-flight case
154  else
155  player->SaveRecallPosition();
156 
157  player->TeleportTo(mapId, x, y, z, o);
158 
159  return true;
160  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float GetFloat() const
Definition: Field.h:222
QueryResult PQuery(Format &&sql, T *conn, Args &&...args)
Definition: DatabaseWorkerPool.h:165
Class used to access individual fields of database query result.
Definition: Field.h:56
arena_t NULL
Definition: jemalloc_internal.h:624
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:295
G3D::int16 z
Definition: Vector3int16.h:46
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
void EscapeString(std::string &str)
Apply escape string'ing for current collation. (utf8)
Definition: DatabaseWorkerPool.cpp:231
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
G3D::int16 y
Definition: Vector2int16.h:38
#define _LIKE_
Definition: DatabaseEnv.h:32
uint16 GetUInt16() const
Definition: Field.h:108
Definition: Language.h:300
Definition: Language.h:301
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoGraveyardCommand ( ChatHandler handler,
char const args 
)
inlinestatic
163  {
164  Player* player = handler->GetSession()->GetPlayer();
165 
166  if (!*args)
167  return false;
168 
169  char* gyId = strtok((char*)args, " ");
170  if (!gyId)
171  return false;
172 
173  int32 graveyardId = atoi(gyId);
174 
175  if (!graveyardId)
176  return false;
177 
178  WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(graveyardId);
179  if (!gy)
180  {
181  handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
182  handler->SetSentErrorMessage(true);
183  return false;
184  }
185 
186  if (!MapManager::IsValidMapCoord(gy->MapID, gy->Loc.X, gy->Loc.Y, gy->Loc.Z))
187  {
188  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, gy->Loc.X, gy->Loc.Y, gy->MapID);
189  handler->SetSentErrorMessage(true);
190  return false;
191  }
192 
193  // stop flight if need
194  if (player->IsInFlight())
195  {
196  player->GetMotionMaster()->MovementExpired();
197  player->CleanupAfterTaxiFlight();
198  }
199  // save only in non-flight case
200  else
201  player->SaveRecallPosition();
202 
203  player->TeleportTo(gy->MapID, gy->Loc.X, gy->Loc.Y, gy->Loc.Z, (gy->Facing * M_PI) / 180); // Orientation is initially in degrees
204  return true;
205  }
float Z
Definition: DBCEnums.h:36
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float Y
Definition: DBCEnums.h:35
DBCStorage< WorldSafeLocsEntry > sWorldSafeLocsStore(WorldSafeLocsfmt)
#define M_PI
Definition: Common.h:163
float Facing
Definition: DBCStructure.h:1439
Definition: DBCStructure.h:1434
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:295
uint32 MapID
Definition: DBCStructure.h:1437
Definition: Language.h:451
int32_t int32
Definition: Define.h:146
float X
Definition: DBCEnums.h:34
DBCPosition3D Loc
Definition: DBCStructure.h:1438
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoGridCommand ( ChatHandler handler,
char const args 
)
inlinestatic
209  {
210  if (!*args)
211  return false;
212 
213  Player* player = handler->GetSession()->GetPlayer();
214 
215  char* gridX = strtok((char*)args, " ");
216  char* gridY = strtok(NULL, " ");
217  char* id = strtok(NULL, " ");
218 
219  if (!gridX || !gridY)
220  return false;
221 
222  uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
223 
224  // center of grid
225  float x = ((float)atof(gridX) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
226  float y = ((float)atof(gridY) - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
227 
228  if (!MapManager::IsValidMapCoord(mapId, x, y))
229  {
230  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
231  handler->SetSentErrorMessage(true);
232  return false;
233  }
234 
235  // stop flight if need
236  if (player->IsInFlight())
237  {
238  player->GetMotionMaster()->MovementExpired();
239  player->CleanupAfterTaxiFlight();
240  }
241  // save only in non-flight case
242  else
243  player->SaveRecallPosition();
244 
245  Map const* map = sMapMgr->CreateBaseMap(mapId);
246  float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
247 
248  player->TeleportTo(mapId, x, y, z, player->GetOrientation());
249  return true;
250  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
#define SIZE_OF_GRIDS
Definition: GridDefines.h:39
#define CENTER_GRID_ID
Definition: GridDefines.h:40
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Language.h:295
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2582
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
#define sMapMgr
Definition: MapManager.h:194
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_HEIGHT
Definition: Map.h:247

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoObjectCommand ( ChatHandler handler,
char const args 
)
inlinestatic
254  {
255  if (!*args)
256  return false;
257 
258  Player* player = handler->GetSession()->GetPlayer();
259 
260  // number or [name] Shift-click form |color|Hgameobject:go_guid|h[name]|h|r
261  char* id = handler->extractKeyFromLink((char*)args, "Hgameobject");
262  if (!id)
263  return false;
264 
265  ObjectGuid::LowType guid = strtoull(id, nullptr, 10);
266  if (!guid)
267  return false;
268 
269  float x, y, z, o;
270  uint32 mapId;
271 
272  // by DB guid
273  if (GameObjectData const* goData = sObjectMgr->GetGOData(guid))
274  {
275  x = goData->posX;
276  y = goData->posY;
277  z = goData->posZ;
278  o = goData->orientation;
279  mapId = goData->mapid;
280  }
281  else
282  {
284  handler->SetSentErrorMessage(true);
285  return false;
286  }
287 
288  if (!MapManager::IsValidMapCoord(mapId, x, y, z, o) || sObjectMgr->IsTransportMap(mapId))
289  {
290  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
291  handler->SetSentErrorMessage(true);
292  return false;
293  }
294 
295  // stop flight if need
296  if (player->IsInFlight())
297  {
298  player->GetMotionMaster()->MovementExpired();
299  player->CleanupAfterTaxiFlight();
300  }
301  // save only in non-flight case
302  else
303  player->SaveRecallPosition();
304 
305  player->TeleportTo(mapId, x, y, z, o);
306  return true;
307  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
Player * GetPlayer() const
Definition: WorldSession.h:927
uint64 LowType
Definition: ObjectGuid.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Language.h:295
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:833
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
Definition: Language.h:299
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoQuestCommand ( ChatHandler handler,
char const args 
)
inlinestatic
310  {
311  if (!*args)
312  return false;
313 
314  Player* player = handler->GetSession()->GetPlayer();
315 
316  char* id = handler->extractKeyFromLink((char*)args, "Hquest");
317  if (!id)
318  return false;
319 
320  uint32 questID = atoi(id);
321  if (!questID)
322  return false;
323 
324  if (!sObjectMgr->GetQuestTemplate(questID))
325  {
326  handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, questID);
327  handler->SetSentErrorMessage(true);
328  return false;
329  }
330 
331  float x, y, z;
332  uint32 mapId;
333 
334  if (QuestPOIVector const* poiData = sObjectMgr->GetQuestPOIVector(questID))
335  {
336  auto data = poiData->front();
337 
338  mapId = data.MapID;
339 
340  x = data.points.front().X;
341  y = data.points.front().Y;
342  }
343  else
344  {
345  handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, questID);
346  handler->SetSentErrorMessage(true);
347  return false;
348  }
349 
350  if (!MapManager::IsValidMapCoord(mapId, x, y) || sObjectMgr->IsTransportMap(mapId))
351  {
352  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
353  handler->SetSentErrorMessage(true);
354  return false;
355  }
356 
357  // stop flight if need
358  if (player->IsInFlight())
359  {
360  player->GetMotionMaster()->MovementExpired();
361  player->CleanupAfterTaxiFlight();
362  }
363  // save only in non-flight case
364  else
365  player->SaveRecallPosition();
366 
367  Map const* map = sMapMgr->CreateBaseMap(mapId);
368  z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
369 
370  player->TeleportTo(mapId, x, y, z, 0.0f);
371  return true;
372  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
Player * GetPlayer() const
Definition: WorldSession.h:927
#define sObjectMgr
Definition: ObjectMgr.h:1567
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Language.h:295
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2582
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Definition: Language.h:474
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
std::vector< QuestPOI > QuestPOIVector
Definition: ObjectMgr.h:573
#define sMapMgr
Definition: MapManager.h:194
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_HEIGHT
Definition: Map.h:247
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoTaxinodeCommand ( ChatHandler handler,
char const args 
)
inlinestatic
375  {
376  Player* player = handler->GetSession()->GetPlayer();
377 
378  if (!*args)
379  return false;
380 
381  char* id = handler->extractKeyFromLink((char*)args, "Htaxinode");
382  if (!id)
383  return false;
384 
385  int32 nodeId = atoi(id);
386  if (!nodeId)
387  return false;
388 
389  TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
390  if (!node)
391  {
393  handler->SetSentErrorMessage(true);
394  return false;
395  }
396 
397  if ((node->Pos.X == 0.0f && node->Pos.Y == 0.0f && node->Pos.Z == 0.0f) ||
398  !MapManager::IsValidMapCoord(node->MapID, node->Pos.X, node->Pos.Y, node->Pos.Z))
399  {
400  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, node->Pos.X, node->Pos.Y, node->MapID);
401  handler->SetSentErrorMessage(true);
402  return false;
403  }
404 
405  // stop flight if need
406  if (player->IsInFlight())
407  {
408  player->GetMotionMaster()->MovementExpired();
409  player->CleanupAfterTaxiFlight();
410  }
411  // save only in non-flight case
412  else
413  player->SaveRecallPosition();
414 
415  player->TeleportTo(node->MapID, node->Pos.X, node->Pos.Y, node->Pos.Z, player->GetOrientation());
416  return true;
417  }
float Z
Definition: DBCEnums.h:36
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float Y
Definition: DBCEnums.h:35
Player * GetPlayer() const
Definition: WorldSession.h:927
DBCPosition3D Pos
Definition: DB2Structure.h:1328
Definition: Language.h:295
int32_t int32
Definition: Define.h:146
uint32 MapID
Definition: DB2Structure.h:1327
float X
Definition: DBCEnums.h:34
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
WorldSession * GetSession()
Definition: Chat.h:59
Definition: DB2Structure.h:1324
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
Definition: Language.h:375
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
DB2Storage< TaxiNodesEntry > sTaxiNodesStore("TaxiNodes.db2", TaxiNodesFormat, HOTFIX_SEL_TAXI_NODES)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
static bool go_commandscript::HandleGoTicketCommand ( ChatHandler handler,
char const args 
)
inlinestatic
598  {
599  if (!*args)
600  return false;
601 
602  char* id = strtok((char*)args, " ");
603  if (!id)
604  return false;
605 
606  uint32 ticketId = atoi(id);
607  if (!ticketId)
608  return false;
609 
610  T* ticket = sSupportMgr->GetTicket<T>(ticketId);
611  if (!ticket)
612  {
614  return true;
615  }
616 
617  Player* player = handler->GetSession()->GetPlayer();
618  if (player->IsInFlight())
619  {
620  player->GetMotionMaster()->MovementExpired();
621  player->CleanupAfterTaxiFlight();
622  }
623  else
624  player->SaveRecallPosition();
625 
626  ticket->TeleportTo(player);
627  return true;
628  }
Player * GetPlayer() const
Definition: WorldSession.h:927
uint32_t uint32
Definition: Define.h:150
#define sSupportMgr
Definition: SupportMgr.h:296
WorldSession * GetSession()
Definition: Chat.h:59
Definition: Language.h:1043
virtual void SendSysMessage(char const *str, bool escapeCharacters=false)
Definition: Chat.cpp:152

+ Here is the call graph for this function:

static bool go_commandscript::HandleGoTriggerCommand ( ChatHandler handler,
char const args 
)
inlinestatic
420  {
421  Player* player = handler->GetSession()->GetPlayer();
422 
423  if (!*args)
424  return false;
425 
426  char* id = strtok((char*)args, " ");
427  if (!id)
428  return false;
429 
430  int32 areaTriggerId = atoi(id);
431 
432  if (!areaTriggerId)
433  return false;
434 
435  AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(areaTriggerId);
436  if (!at)
437  {
438  handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, areaTriggerId);
439  handler->SetSentErrorMessage(true);
440  return false;
441  }
442 
443  if (!MapManager::IsValidMapCoord(at->MapID, at->Pos.X, at->Pos.Y, at->Pos.Z))
444  {
445  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, at->Pos.X, at->Pos.Y, at->MapID);
446  handler->SetSentErrorMessage(true);
447  return false;
448  }
449 
450  // stop flight if need
451  if (player->IsInFlight())
452  {
453  player->GetMotionMaster()->MovementExpired();
454  player->CleanupAfterTaxiFlight();
455  }
456  // save only in non-flight case
457  else
458  player->SaveRecallPosition();
459 
460  player->TeleportTo(at->MapID, at->Pos.X, at->Pos.Y, at->Pos.Z, player->GetOrientation());
461  return true;
462  }
float Z
Definition: DBCEnums.h:36
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float Y
Definition: DBCEnums.h:35
DBCStorage< AreaTriggerEntry > sAreaTriggerStore(AreaTriggerfmt)
uint32 MapID
Definition: DBCStructure.h:77
Player * GetPlayer() const
Definition: WorldSession.h:927
Definition: Language.h:295
DBCPosition3D Pos
Definition: DBCStructure.h:78
int32_t int32
Definition: Define.h:146
Definition: Language.h:294
float X
Definition: DBCEnums.h:34
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
WorldSession * GetSession()
Definition: Chat.h:59
Definition: DBCStructure.h:74
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoXYZCommand ( ChatHandler handler,
char const args 
)
inlinestatic
539  {
540  if (!*args)
541  return false;
542 
543  Player* player = handler->GetSession()->GetPlayer();
544 
545  char* goX = strtok((char*)args, " ");
546  char* goY = strtok(NULL, " ");
547  char* goZ = strtok(NULL, " ");
548  char* id = strtok(NULL, " ");
549  char* port = strtok(NULL, " ");
550 
551  if (!goX || !goY)
552  return false;
553 
554  float x = (float)atof(goX);
555  float y = (float)atof(goY);
556  float z;
557  float ort = port ? (float)atof(port) : player->GetOrientation();
558  uint32 mapId = id ? (uint32)atoi(id) : player->GetMapId();
559 
560  if (goZ)
561  {
562  z = (float)atof(goZ);
563  if (!MapManager::IsValidMapCoord(mapId, x, y, z))
564  {
565  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
566  handler->SetSentErrorMessage(true);
567  return false;
568  }
569  }
570  else
571  {
572  if (!MapManager::IsValidMapCoord(mapId, x, y))
573  {
574  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
575  handler->SetSentErrorMessage(true);
576  return false;
577  }
578  Map const* map = sMapMgr->CreateBaseMap(mapId);
579  z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
580  }
581 
582  // stop flight if need
583  if (player->IsInFlight())
584  {
585  player->GetMotionMaster()->MovementExpired();
586  player->CleanupAfterTaxiFlight();
587  }
588  // save only in non-flight case
589  else
590  player->SaveRecallPosition();
591 
592  player->TeleportTo(mapId, x, y, z, ort);
593  return true;
594  }
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
arena_t NULL
Definition: jemalloc_internal.h:624
Player * GetPlayer() const
Definition: WorldSession.h:927
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: Language.h:295
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2582
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
#define sMapMgr
Definition: MapManager.h:194
WorldSession * GetSession()
Definition: Chat.h:59
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_HEIGHT
Definition: Map.h:247

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool go_commandscript::HandleGoZoneXYCommand ( ChatHandler handler,
char const args 
)
inlinestatic
466  {
467  if (!*args)
468  return false;
469 
470  Player* player = handler->GetSession()->GetPlayer();
471 
472  char* zoneX = strtok((char*)args, " ");
473  char* zoneY = strtok(NULL, " ");
474  char* tail = strtok(NULL, "");
475 
476  char* id = handler->extractKeyFromLink(tail, "Harea"); // string or [name] Shift-click form |color|Harea:area_id|h[name]|h|r
477 
478  if (!zoneX || !zoneY)
479  return false;
480 
481  float x = (float)atof(zoneX);
482  float y = (float)atof(zoneY);
483 
484  // prevent accept wrong numeric args
485  if ((x == 0.0f && *zoneX != '0') || (y == 0.0f && *zoneY != '0'))
486  return false;
487 
488  uint32 areaId = id ? (uint32)atoi(id) : player->GetZoneId();
489 
490  AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
491 
492  if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
493  {
494  handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
495  handler->SetSentErrorMessage(true);
496  return false;
497  }
498 
499  // update to parent zone if exist (client map show only zones without parents)
500  AreaTableEntry const* zoneEntry = areaEntry->ParentAreaID ? sAreaTableStore.LookupEntry(areaEntry->ParentAreaID) : areaEntry;
501  ASSERT(zoneEntry);
502 
503  Map const* map = sMapMgr->CreateBaseMap(zoneEntry->MapID);
504 
505  if (map->Instanceable())
506  {
507  handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->AreaName_lang, map->GetId(), map->GetMapName());
508  handler->SetSentErrorMessage(true);
509  return false;
510  }
511 
512  Zone2MapCoordinates(x, y, zoneEntry->ID);
513 
514  if (!MapManager::IsValidMapCoord(zoneEntry->MapID, x, y))
515  {
516  handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, zoneEntry->MapID);
517  handler->SetSentErrorMessage(true);
518  return false;
519  }
520 
521  // stop flight if need
522  if (player->IsInFlight())
523  {
524  player->GetMotionMaster()->MovementExpired();
525  player->CleanupAfterTaxiFlight();
526  }
527  // save only in non-flight case
528  else
529  player->SaveRecallPosition();
530 
531  float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
532 
533  player->TeleportTo(zoneEntry->MapID, x, y, z, player->GetOrientation());
534  return true;
535  }
Definition: DBCStructure.h:37
void SetSentErrorMessage(bool val)
Definition: Chat.h:138
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Language.h:297
uint32 MapID
Definition: DBCStructure.h:40
Definition: Language.h:296
Player * GetPlayer() const
Definition: WorldSession.h:927
T max(const T &x, const T &y)
Definition: g3dmath.h:320
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
uint32 GetId(void) const
Definition: Map.h:325
Definition: Language.h:295
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2582
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
char * AreaName_lang
Definition: DBCStructure.h:51
Definition: Map.h:259
uint32 ParentAreaID
Definition: DBCStructure.h:41
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83
#define sMapMgr
Definition: MapManager.h:194
WorldSession * GetSession()
Definition: Chat.h:59
uint32 ID
Definition: DBCStructure.h:39
#define ASSERT
Definition: Errors.h:55
bool Instanceable() const
Definition: Map.h:394
void PSendSysMessage(const char *fmt, Args &&...args)
Definition: Chat.h:72
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
#define MAX_HEIGHT
Definition: Map.h:247
char * extractKeyFromLink(char *text, char const *linkType, char **something1=NULL)
Definition: Chat.cpp:641
const char * GetMapName() const
Definition: Map.cpp:2644
void Zone2MapCoordinates(float &x, float &y, uint32 worldMapAreaId)
Definition: DBCStores.cpp:668

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following file: