AzerothCore 3.3.5a
OpenSource WoW Emulator
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
go_commandscript Class Reference
Inheritance diagram for go_commandscript:
CommandScript ScriptObject

Public Member Functions

 go_commandscript ()
 
ChatCommandTable GetCommands () const override
 
- 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 DoTeleport (ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
 
static bool HandleGoCreatureCIdCommand (ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId)
 
static bool HandleGoCreatureSpawnIdCommand (ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
 
static bool HandleGoCreatureNameCommand (ChatHandler *handler, Tail name)
 
static bool HandleGoGameObjectSpawnIdCommand (ChatHandler *handler, uint32 spawnId)
 
static bool HandleGoGameObjectGOIdCommand (ChatHandler *handler, uint32 goId)
 
static bool HandleGoGraveyardCommand (ChatHandler *handler, uint32 gyId)
 
static bool HandleGoGridCommand (ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
 
static bool HandleGoTaxinodeCommand (ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
 
static bool HandleGoTriggerCommand (ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
 
static bool HandleGoZoneXYCommand (ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
 
static bool HandleGoXYZCommand (ChatHandler *handler, Tail args)
 Teleports the GM to the specified world coordinates, optionally specifying map ID and orientation.
 
static bool HandleGoTicketCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGoQuestCommand (ChatHandler *handler, std::string_view type, Quest const *quest)
 
static CreatureData const * GetCreatureData (ChatHandler *handler, uint32 entry)
 
static GameObjectData const * GetGameObjectData (ChatHandler *handler, uint32 entry)
 

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

◆ go_commandscript()

go_commandscript::go_commandscript ( )
inline
35: CommandScript("go_commandscript") { }
Definition CommandScript.h:25

Member Function Documentation

◆ DoTeleport()

static bool go_commandscript::DoTeleport ( ChatHandler handler,
Position  pos,
uint32  mapId = MAPID_INVALID 
)
inlinestatic
64 {
65 Player* player = handler->GetSession()->GetPlayer();
66
67 if (mapId == MAPID_INVALID)
68 mapId = player->GetMapId();
69 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
70 {
72 return false;
73 }
74
75 // stop flight if need
76 if (player->IsInFlight())
77 {
79 player->CleanupAfterTaxiFlight();
80 }
81 // save only in non-flight case
82 else
83 player->SaveRecallPosition();
84
85 player->TeleportTo({ mapId, pos });
86 return true;
87 }
@ LANG_INVALID_TARGET_COORD
Definition Language.h:309
#define sObjectMgr
Definition ObjectMgr.h:1650
#define MAPID_INVALID
Definition Position.h:252
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:216
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90
void MovementExpired(bool reset=true)
Definition MotionMaster.h:180
Definition Player.h:1082
void SaveRecallPosition()
Definition Player.cpp:5667
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1338
void CleanupAfterTaxiFlight()
Definition Player.cpp:10376
MotionMaster * GetMotionMaster()
Definition Unit.h:1664
bool IsInFlight() const
Definition Unit.h:1616
uint32 GetMapId() const
Definition Position.h:280
Player * GetPlayer() const
Definition WorldSession.h:376
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References Player::CleanupAfterTaxiFlight(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), ChatHandler::GetSession(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, MAPID_INVALID, MotionMaster::MovementExpired(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), sObjectMgr, and Player::TeleportTo().

Referenced by HandleGoCreatureCIdCommand(), HandleGoCreatureNameCommand(), HandleGoCreatureSpawnIdCommand(), HandleGoGameObjectGOIdCommand(), HandleGoGameObjectSpawnIdCommand(), HandleGoQuestCommand(), HandleGoTaxinodeCommand(), HandleGoTriggerCommand(), and HandleGoXYZCommand().

◆ GetCommands()

ChatCommandTable go_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

38 {
39 static ChatCommandTable goCommandTable =
40 {
41 { "creature", HandleGoCreatureSpawnIdCommand, SEC_MODERATOR, Console::No },
42 { "creature id", HandleGoCreatureCIdCommand, SEC_MODERATOR, Console::No },
43 { "creature name", HandleGoCreatureNameCommand, SEC_MODERATOR, Console::No },
44 { "gameobject", HandleGoGameObjectSpawnIdCommand, SEC_MODERATOR, Console::No },
45 { "gameobject id", HandleGoGameObjectGOIdCommand, SEC_MODERATOR, Console::No },
46 { "graveyard", HandleGoGraveyardCommand, SEC_MODERATOR, Console::No },
47 { "grid", HandleGoGridCommand, SEC_MODERATOR, Console::No },
48 { "taxinode", HandleGoTaxinodeCommand, SEC_MODERATOR, Console::No },
49 { "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
50 { "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
51 { "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
52 { "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
53 { "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
54 };
55
56 static ChatCommandTable commandTable =
57 {
58 { "go", goCommandTable }
59 };
60 return commandTable;
61 }
@ SEC_GAMEMASTER
Definition Common.h:59
@ SEC_MODERATOR
Definition Common.h:58
static bool HandleGoGameObjectGOIdCommand(ChatHandler *handler, uint32 goId)
Definition cs_go.cpp:156
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition cs_go.cpp:169
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition cs_go.cpp:401
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition cs_go.cpp:232
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition cs_go.cpp:200
static bool HandleGoCreatureNameCommand(ChatHandler *handler, Tail name)
Definition cs_go.cpp:114
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition cs_go.cpp:243
static bool HandleGoXYZCommand(ChatHandler *handler, Tail args)
Teleports the GM to the specified world coordinates, optionally specifying map ID and orientation.
Definition cs_go.cpp:313
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition cs_go.cpp:376
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_go.cpp:102
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition cs_go.cpp:255
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition cs_go.cpp:144
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId)
Definition cs_go.cpp:89
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46

References HandleGoCreatureCIdCommand(), HandleGoCreatureNameCommand(), HandleGoCreatureSpawnIdCommand(), HandleGoGameObjectGOIdCommand(), HandleGoGameObjectSpawnIdCommand(), HandleGoGraveyardCommand(), HandleGoGridCommand(), HandleGoQuestCommand(), HandleGoTaxinodeCommand(), HandleGoTicketCommand(), HandleGoTriggerCommand(), HandleGoXYZCommand(), HandleGoZoneXYCommand(), SEC_GAMEMASTER, and SEC_MODERATOR.

◆ GetCreatureData()

static CreatureData const * go_commandscript::GetCreatureData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
489 {
490 CreatureData const* spawnpoint = nullptr;
491 for (auto const& pair : sObjectMgr->GetAllCreatureData())
492 {
493 if (pair.second.id1 != entry)
494 {
495 continue;
496 }
497
498 if (!spawnpoint)
499 {
500 spawnpoint = &pair.second;
501 }
502 else
503 {
505 break;
506 }
507 }
508
509 return spawnpoint;
510 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition Language.h:315
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
Definition CreatureData.h:370

References LANG_COMMAND_GOCREATMULTIPLE, ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by HandleGoCreatureCIdCommand(), HandleGoCreatureNameCommand(), and HandleGoQuestCommand().

◆ GetGameObjectData()

static GameObjectData const * go_commandscript::GetGameObjectData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
513 {
514 GameObjectData const* spawnpoint = nullptr;
515 for (auto const& pair : sObjectMgr->GetAllGOData())
516 {
517 if (pair.second.id != entry)
518 {
519 continue;
520 }
521
522 if (!spawnpoint)
523 {
524 spawnpoint = &pair.second;
525 }
526 else
527 {
529 break;
530 }
531 }
532
533 return spawnpoint;
534 }
Definition GameObjectData.h:696

References LANG_COMMAND_GOCREATMULTIPLE, ChatHandler::SendSysMessage(), and sObjectMgr.

Referenced by HandleGoGameObjectGOIdCommand(), and HandleGoQuestCommand().

◆ HandleGoCreatureCIdCommand()

static bool go_commandscript::HandleGoCreatureCIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 cId 
)
inlinestatic
90 {
91 CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
92
93 if (!spawnpoint)
94 {
96 return false;
97 }
98
99 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
100 }
@ LANG_COMMAND_GOCREATNOTFOUND
Definition Language.h:314
static CreatureData const * GetCreatureData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:488
static bool DoTeleport(ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
Definition cs_go.cpp:63
float posY
Definition CreatureData.h:380
float posX
Definition CreatureData.h:379
uint16 mapid
Definition CreatureData.h:375
float posZ
Definition CreatureData.h:381

References DoTeleport(), GetCreatureData(), LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureData::posX, CreatureData::posY, CreatureData::posZ, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleGoCreatureNameCommand()

static bool go_commandscript::HandleGoCreatureNameCommand ( ChatHandler handler,
Tail  name 
)
inlinestatic
115 {
116 if (!name.data())
117 return false;
118
119 // Make sure we don't pass double quotes into the SQL query. Otherwise it causes a MySQL error
120 std::string str = name.data(); // Making subtractions to the last character does not with in string_view
121 if (str.front() == '"')
122 str = str.substr(1);
123 if (str.back() == '"')
124 str = str.substr(0, str.size() - 1);
125
126 QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str);
127 if (!result)
128 {
130 return false;
131 }
132
133 uint32 entry = result->Fetch()[0].Get<uint32>();
134 CreatureData const* spawnpoint = GetCreatureData(handler, entry);
135 if (!spawnpoint)
136 {
138 return false;
139 }
140
141 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
142 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::uint32_t uint32
Definition Define.h:107

References DoTeleport(), GetCreatureData(), LANG_COMMAND_GOCREATNOTFOUND, ChatHandler::SendErrorMessage(), and WorldDatabase.

Referenced by GetCommands().

◆ HandleGoCreatureSpawnIdCommand()

static bool go_commandscript::HandleGoCreatureSpawnIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature >, ObjectGuid::LowType spawnId 
)
inlinestatic
103 {
104 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
105 if (!spawnpoint)
106 {
108 return false;
109 }
110
111 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
112 }

References DoTeleport(), LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureData::posX, CreatureData::posY, CreatureData::posZ, ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoGameObjectGOIdCommand()

static bool go_commandscript::HandleGoGameObjectGOIdCommand ( ChatHandler handler,
uint32  goId 
)
inlinestatic
157 {
158 GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
159
160 if (!spawnpoint)
161 {
163 return false;
164 }
165
166 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
167 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition Language.h:313
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:512
float posZ
Definition GameObjectData.h:703
uint16 mapid
Definition GameObjectData.h:699
float posX
Definition GameObjectData.h:701
float posY
Definition GameObjectData.h:702

References DoTeleport(), GetGameObjectData(), LANG_COMMAND_GOOBJNOTFOUND, GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleGoGameObjectSpawnIdCommand()

static bool go_commandscript::HandleGoGameObjectSpawnIdCommand ( ChatHandler handler,
uint32  spawnId 
)
inlinestatic
145 {
146 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
147 if (!spawnpoint)
148 {
150 return false;
151 }
152
153 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
154 }

References DoTeleport(), LANG_COMMAND_GOOBJNOTFOUND, GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoGraveyardCommand()

static bool go_commandscript::HandleGoGraveyardCommand ( ChatHandler handler,
uint32  gyId 
)
inlinestatic
170 {
171 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
172 if (!gy)
173 {
175 return false;
176 }
177
178 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
179 {
180 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
181 return false;
182 }
183
184 Player* player = handler->GetSession()->GetPlayer();
185 // stop flight if need
186 if (player->IsInFlight())
187 {
188 player->GetMotionMaster()->MovementExpired();
189 player->CleanupAfterTaxiFlight();
190 }
191 // save only in non-flight case
192 else
193 player->SaveRecallPosition();
194
195 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
196 return true;
197 }
#define sGraveyard
Definition GameGraveyard.h:74
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition Language.h:482
Definition GameGraveyard.h:27
float z
Definition GameGraveyard.h:32
float x
Definition GameGraveyard.h:30
float y
Definition GameGraveyard.h:31
uint32 Map
Definition GameGraveyard.h:29
float GetOrientation() const
Definition Position.h:124

References Player::CleanupAfterTaxiFlight(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_COMMAND_GRAVEYARDNOEXIST, LANG_INVALID_TARGET_COORD, GraveyardStruct::Map, MotionMaster::MovementExpired(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), sGraveyard, Player::TeleportTo(), GraveyardStruct::x, GraveyardStruct::y, and GraveyardStruct::z.

Referenced by GetCommands().

◆ HandleGoGridCommand()

static bool go_commandscript::HandleGoGridCommand ( ChatHandler handler,
float  gridX,
float  gridY,
Optional< uint32 oMapId 
)
inlinestatic
201 {
202 Player* player = handler->GetSession()->GetPlayer();
203 uint32 mapId = oMapId.value_or(player->GetMapId());
204
205 // center of grid
206 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
207 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
208
209 if (!MapMgr::IsValidMapCoord(mapId, x, y))
210 {
211 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
212 return false;
213 }
214
215 // stop flight if need
216 if (player->IsInFlight())
217 {
218 player->GetMotionMaster()->MovementExpired();
219 player->CleanupAfterTaxiFlight();
220 }
221 // save only in non-flight case
222 else
223 player->SaveRecallPosition();
224
225 Map const* map = sMapMgr->CreateBaseMap(mapId);
226 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
227
228 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
229 return true;
230 }
#define CENTER_GRID_ID
Definition GridDefines.h:35
#define MAX_HEIGHT
Definition GridTerrainData.h:26
#define SIZE_OF_GRIDS
Definition MapDefines.h:26
#define sMapMgr
Definition MapMgr.h:220
Definition Map.h:156
float GetWaterLevel(float x, float y) const
Definition Map.cpp:1584
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1194

References CENTER_GRID_ID, Player::CleanupAfterTaxiFlight(), Map::GetHeight(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Map::GetWaterLevel(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, MAX_HEIGHT, MotionMaster::MovementExpired(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), SIZE_OF_GRIDS, sMapMgr, and Player::TeleportTo().

Referenced by GetCommands().

◆ HandleGoQuestCommand()

static bool go_commandscript::HandleGoQuestCommand ( ChatHandler handler,
std::string_view  type,
Quest const *  quest 
)
inlinestatic
402 {
403 uint32 entry = quest->GetQuestId();
404
405 if (type == "starter")
406 {
407 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
408
409 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
410 {
411 if (itr->second == entry)
412 {
413 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
414 if (!spawnpoint)
415 {
417 return false;
418 }
419
420 // We've found a creature, teleport to it.
421 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
422 }
423 }
424
425 qr = sObjectMgr->GetGOQuestRelationMap();
426
427 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
428 {
429 if (itr->second == entry)
430 {
431 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
432 if (!spawnpoint)
433 {
435 return false;
436 }
437
438 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
439 }
440 }
441 }
442 else if (type == "ender")
443 {
444 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
445
446 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
447 {
448 if (itr->second == entry)
449 {
450 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
451 if (!spawnpoint)
452 {
454 return false;
455 }
456
457 // We've found a creature, teleport to it.
458 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
459 }
460 }
461
462 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
463
464 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
465 {
466 if (itr->second == entry)
467 {
468 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
469 if (!spawnpoint)
470 {
472 return false;
473 }
474
475 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
476 }
477 }
478 }
479 else
480 {
482 return false;
483 }
484
485 return false;
486 }
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition Language.h:1141
std::multimap< uint32, uint32 > QuestRelations
Definition ObjectMgr.h:524

References DoTeleport(), GetCreatureData(), GetGameObjectData(), Quest::GetQuestId(), LANG_CMD_GOQUEST_INVALID_SYNTAX, LANG_COMMAND_GOCREATNOTFOUND, LANG_COMMAND_GOOBJNOTFOUND, CreatureData::mapid, GameObjectData::mapid, CreatureData::posX, GameObjectData::posX, CreatureData::posY, GameObjectData::posY, CreatureData::posZ, GameObjectData::posZ, ChatHandler::SendErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoTaxinodeCommand()

static bool go_commandscript::HandleGoTaxinodeCommand ( ChatHandler handler,
Variant< Hyperlink< taxinode >, uint32 nodeId 
)
inlinestatic
233 {
234 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
235 if (!node)
236 {
238 return false;
239 }
240 return DoTeleport(handler, { node->x, node->y, node->z }, node->map_id);
241 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_GOTAXINODENOTFOUND
Definition Language.h:389
Definition DBCStructure.h:1954
float z
Definition DBCStructure.h:1959
uint32 map_id
Definition DBCStructure.h:1956
float x
Definition DBCStructure.h:1957
float y
Definition DBCStructure.h:1958

References DoTeleport(), LANG_COMMAND_GOTAXINODENOTFOUND, TaxiNodesEntry::map_id, ChatHandler::SendErrorMessage(), sTaxiNodesStore, TaxiNodesEntry::x, TaxiNodesEntry::y, and TaxiNodesEntry::z.

Referenced by GetCommands().

◆ HandleGoTicketCommand()

static bool go_commandscript::HandleGoTicketCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
377 {
378 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
379 if (!ticket)
380 {
382 return true;
383 }
384
385 Player* player = handler->GetSession()->GetPlayer();
386
387 // stop flight if need
388 if (player->IsInFlight())
389 {
390 player->GetMotionMaster()->MovementExpired();
391 player->CleanupAfterTaxiFlight();
392 }
393 // save only in non-flight case
394 else
395 player->SaveRecallPosition();
396
397 ticket->TeleportTo(player);
398 return true;
399 }
@ LANG_COMMAND_TICKETNOTEXIST
Definition Language.h:1017
#define sTicketMgr
Definition TicketMgr.h:260
Definition TicketMgr.h:88
void TeleportTo(Player *player) const
Definition TicketMgr.cpp:238

References Player::CleanupAfterTaxiFlight(), Unit::GetMotionMaster(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::IsInFlight(), LANG_COMMAND_TICKETNOTEXIST, MotionMaster::MovementExpired(), Player::SaveRecallPosition(), ChatHandler::SendSysMessage(), sTicketMgr, and GmTicket::TeleportTo().

Referenced by GetCommands().

◆ HandleGoTriggerCommand()

static bool go_commandscript::HandleGoTriggerCommand ( ChatHandler handler,
Variant< Hyperlink< areatrigger >, uint32 areaTriggerId 
)
inlinestatic
244 {
245 AreaTrigger const* at = sObjectMgr->GetAreaTrigger(areaTriggerId);
246 if (!at)
247 {
248 handler->SendErrorMessage(LANG_COMMAND_GOAREATRNOTFOUND, uint32(areaTriggerId));
249 return false;
250 }
251 return DoTeleport(handler, { at->x, at->y, at->z }, at->map);
252 }
@ LANG_COMMAND_GOAREATRNOTFOUND
Definition Language.h:308
Definition ObjectMgr.h:420
float x
Definition ObjectMgr.h:423
float y
Definition ObjectMgr.h:424
uint32 map
Definition ObjectMgr.h:422
float z
Definition ObjectMgr.h:425

References DoTeleport(), LANG_COMMAND_GOAREATRNOTFOUND, AreaTrigger::map, ChatHandler::SendErrorMessage(), sObjectMgr, AreaTrigger::x, AreaTrigger::y, and AreaTrigger::z.

Referenced by GetCommands().

◆ HandleGoXYZCommand()

static bool go_commandscript::HandleGoXYZCommand ( ChatHandler handler,
Tail  args 
)
inlinestatic

Teleports the GM to the specified world coordinates, optionally specifying map ID and orientation.

Parameters
handlerThe ChatHandler that is handling the command.
argsThe coordinates to teleport to in format "x y z [mapId [orientation]]".
Returns
true The command was successful.
false The command was unsuccessful (show error or syntax)
314 {
315 std::wstring wInputCoords;
316 if (!Utf8toWStr(args, wInputCoords))
317 {
318 return false;
319 }
320
321 // extract float and integer values from the input
322 std::vector<float> locationValues;
323 std::wregex floatRegex(L"(-?\\d+(?:\\.\\d+)?)");
324 std::wsregex_iterator floatRegexIterator(wInputCoords.begin(), wInputCoords.end(), floatRegex);
325 std::wsregex_iterator end;
326 while (floatRegexIterator != end)
327 {
328 std::wsmatch match = *floatRegexIterator;
329 std::wstring matchStr = match.str();
330
331 // try to convert the match to a float
332 try
333 {
334 locationValues.push_back(std::stof(matchStr));
335 }
336 // if the match is not a float, do not add it to the vector
337 catch (std::invalid_argument const&){}
338
339 ++floatRegexIterator;
340 }
341
342 // X and Y are required
343 if (locationValues.size() < 2)
344 {
345 return false;
346 }
347
348 Player* player = handler->GetSession()->GetPlayer();
349
350 uint32 mapId = locationValues.size() >= 4 ? uint32(locationValues[3]) : player->GetMapId();
351
352 float x = locationValues[0];
353 float y = locationValues[1];
354
355 if (!sMapStore.LookupEntry(mapId) || !MapMgr::IsValidMapCoord(mapId, x, y))
356 {
357 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
358 return false;
359 }
360
361 Map const* map = sMapMgr->CreateBaseMap(mapId);
362
363 float z = locationValues.size() >= 3 ? locationValues[2] : std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
364 // map ID (locationValues[3]) already handled above
365 float o = locationValues.size() >= 5 ? locationValues[4] : player->GetOrientation();
366
367 if (!MapMgr::IsValidMapCoord(mapId, x, y, z, o))
368 {
369 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
370 return false;
371 }
372
373 return DoTeleport(handler, { x, y, z, o }, mapId);
374 }
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition Util.cpp:281

References DoTeleport(), Map::GetHeight(), WorldLocation::GetMapId(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Map::GetWaterLevel(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, MAX_HEIGHT, ChatHandler::SendErrorMessage(), sMapMgr, sMapStore, and Utf8toWStr().

Referenced by GetCommands().

◆ HandleGoZoneXYCommand()

static bool go_commandscript::HandleGoZoneXYCommand ( ChatHandler handler,
float  x,
float  y,
Optional< Variant< Hyperlink< area >, uint32 > >  areaIdArg 
)
inlinestatic
256 {
257 Player* player = handler->GetSession()->GetPlayer();
258
259 uint32 areaId = areaIdArg ? *areaIdArg : player->GetZoneId();
260
261 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
262
263 if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
264 {
265 handler->SendErrorMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
266 return false;
267 }
268
269 // update to parent zone if exist (client map show only zones without parents)
270 AreaTableEntry const* zoneEntry = areaEntry->zone ? sAreaTableStore.LookupEntry(areaEntry->zone) : areaEntry;
271 ASSERT(zoneEntry);
272
273 Map const* map = sMapMgr->CreateBaseMap(zoneEntry->mapid);
274
275 if (map->Instanceable())
276 {
277 handler->SendErrorMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
278 return false;
279 }
280
281 Zone2MapCoordinates(x, y, zoneEntry->ID);
282
283 if (!MapMgr::IsValidMapCoord(zoneEntry->mapid, x, y))
284 {
285 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, zoneEntry->mapid);
286 return false;
287 }
288
289 // stop flight if need
290 if (player->IsInFlight())
291 {
292 player->GetMotionMaster()->MovementExpired();
293 player->CleanupAfterTaxiFlight();
294 }
295 // save only in non-flight case
296 else
297 player->SaveRecallPosition();
298
299 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
300
301 player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
302 return true;
303 }
void Zone2MapCoordinates(float &x, float &y, uint32 zone)
Definition DBCStores.cpp:735
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define ASSERT
Definition Errors.h:68
@ LANG_INVALID_ZONE_MAP
Definition Language.h:311
@ LANG_INVALID_ZONE_COORD
Definition Language.h:310
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:870
bool Instanceable() const
Definition Map.h:294
uint32 GetId() const
Definition Map.h:229
const char * GetMapName() const
Definition Map.cpp:1680
uint32 GetZoneId() const
Definition Object.cpp:3148
Definition DBCStructure.h:519
uint32 mapid
Definition DBCStructure.h:521
uint32 zone
Definition DBCStructure.h:522
char const * area_name[16]
Definition DBCStructure.h:527
uint32 ID
Definition DBCStructure.h:520

References AreaTableEntry::area_name, ASSERT, Player::CleanupAfterTaxiFlight(), Map::GetHeight(), Map::GetId(), Map::GetMapName(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Map::GetWaterLevel(), WorldObject::GetZoneId(), AreaTableEntry::ID, Map::Instanceable(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, LANG_INVALID_ZONE_COORD, LANG_INVALID_ZONE_MAP, AreaTableEntry::mapid, MAX_HEIGHT, MotionMaster::MovementExpired(), sAreaTableStore, Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), sMapMgr, Player::TeleportTo(), AreaTableEntry::zone, and Zone2MapCoordinates().

Referenced by GetCommands().


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