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

Public Member Functions

 go_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 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. More...
 
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
42: 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
71 {
72 Player* player = handler->GetSession()->GetPlayer();
73
74 if (mapId == MAPID_INVALID)
75 mapId = player->GetMapId();
76 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
77 {
79 return false;
80 }
81
82 // stop flight if need
83 if (player->IsInFlight())
84 {
86 player->CleanupAfterTaxiFlight();
87 }
88 // save only in non-flight case
89 else
90 player->SaveRecallPosition();
91
92 player->TeleportTo({ mapId, pos });
93 return true;
94 }
#define sObjectMgr
Definition: ObjectMgr.h:1635
@ LANG_INVALID_TARGET_COORD
Definition: Language.h:308
#define MAPID_INVALID
Definition: Position.h:247
WorldSession * GetSession()
Definition: Chat.h:242
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
float GetPositionX() const
Definition: Position.h:116
float GetPositionY() const
Definition: Position.h:117
uint32 GetMapId() const
Definition: Position.h:275
Definition: Player.h:1064
void SaveRecallPosition()
Definition: Player.cpp:5656
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1331
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10437
MotionMaster * GetMotionMaster()
Definition: Unit.h:1620
bool IsInFlight() const
Definition: Unit.h:1572
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:89
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:180
Player * GetPlayer() const
Definition: WorldSession.h:362

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.

45 {
46 static ChatCommandTable goCommandTable =
47 {
48 { "creature", HandleGoCreatureSpawnIdCommand, SEC_MODERATOR, Console::No },
49 { "creature id", HandleGoCreatureCIdCommand, SEC_MODERATOR, Console::No },
50 { "creature name", HandleGoCreatureNameCommand, SEC_MODERATOR, Console::No },
51 { "gameobject", HandleGoGameObjectSpawnIdCommand, SEC_MODERATOR, Console::No },
52 { "gameobject id", HandleGoGameObjectGOIdCommand, SEC_MODERATOR, Console::No },
53 { "graveyard", HandleGoGraveyardCommand, SEC_MODERATOR, Console::No },
54 { "grid", HandleGoGridCommand, SEC_MODERATOR, Console::No },
55 { "taxinode", HandleGoTaxinodeCommand, SEC_MODERATOR, Console::No },
56 { "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
57 { "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
58 { "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
59 { "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
60 { "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
61 };
62
63 static ChatCommandTable commandTable =
64 {
65 { "go", goCommandTable }
66 };
67 return commandTable;
68 }
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_MODERATOR
Definition: Common.h:58
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleGoGameObjectGOIdCommand(ChatHandler *handler, uint32 goId)
Definition: cs_go.cpp:163
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition: cs_go.cpp:176
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition: cs_go.cpp:408
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition: cs_go.cpp:239
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition: cs_go.cpp:207
static bool HandleGoCreatureNameCommand(ChatHandler *handler, Tail name)
Definition: cs_go.cpp:121
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition: cs_go.cpp:250
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:320
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_go.cpp:383
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition: cs_go.cpp:109
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition: cs_go.cpp:262
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition: cs_go.cpp:151
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId)
Definition: cs_go.cpp:96

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
496 {
497 CreatureData const* spawnpoint = nullptr;
498 for (auto const& pair : sObjectMgr->GetAllCreatureData())
499 {
500 if (pair.second.id1 != entry)
501 {
502 continue;
503 }
504
505 if (!spawnpoint)
506 {
507 spawnpoint = &pair.second;
508 }
509 else
510 {
512 break;
513 }
514 }
515
516 return spawnpoint;
517 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition: Language.h:314
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:159
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
520 {
521 GameObjectData const* spawnpoint = nullptr;
522 for (auto const& pair : sObjectMgr->GetAllGOData())
523 {
524 if (pair.second.id != entry)
525 {
526 continue;
527 }
528
529 if (!spawnpoint)
530 {
531 spawnpoint = &pair.second;
532 }
533 else
534 {
536 break;
537 }
538 }
539
540 return spawnpoint;
541 }
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
97 {
98 CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
99
100 if (!spawnpoint)
101 {
103 return false;
104 }
105
106 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
107 }
@ LANG_COMMAND_GOCREATNOTFOUND
Definition: Language.h:313
float posY
Definition: CreatureData.h:380
float posX
Definition: CreatureData.h:379
uint16 mapid
Definition: CreatureData.h:375
float posZ
Definition: CreatureData.h:381
static CreatureData const * GetCreatureData(ChatHandler *handler, uint32 entry)
Definition: cs_go.cpp:495
static bool DoTeleport(ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
Definition: cs_go.cpp:70

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

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
110 {
111 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
112 if (!spawnpoint)
113 {
115 return false;
116 }
117
118 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
119 }

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
164 {
165 GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
166
167 if (!spawnpoint)
168 {
170 return false;
171 }
172
173 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
174 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition: Language.h:312
float posZ
Definition: GameObjectData.h:703
uint16 mapid
Definition: GameObjectData.h:699
float posX
Definition: GameObjectData.h:701
float posY
Definition: GameObjectData.h:702
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition: cs_go.cpp:519

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
152 {
153 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
154 if (!spawnpoint)
155 {
157 return false;
158 }
159
160 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
161 }

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
177 {
178 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
179 if (!gy)
180 {
182 return false;
183 }
184
185 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
186 {
187 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
188 return false;
189 }
190
191 Player* player = handler->GetSession()->GetPlayer();
192 // stop flight if need
193 if (player->IsInFlight())
194 {
195 player->GetMotionMaster()->MovementExpired();
196 player->CleanupAfterTaxiFlight();
197 }
198 // save only in non-flight case
199 else
200 player->SaveRecallPosition();
201
202 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
203 return true;
204 }
#define sGraveyard
Definition: GameGraveyard.h:74
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition: Language.h:481
float GetOrientation() const
Definition: Position.h:119
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

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
208 {
209 Player* player = handler->GetSession()->GetPlayer();
210 uint32 mapId = oMapId.value_or(player->GetMapId());
211
212 // center of grid
213 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
214 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
215
216 if (!MapMgr::IsValidMapCoord(mapId, x, y))
217 {
218 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
219 return false;
220 }
221
222 // stop flight if need
223 if (player->IsInFlight())
224 {
225 player->GetMotionMaster()->MovementExpired();
226 player->CleanupAfterTaxiFlight();
227 }
228 // save only in non-flight case
229 else
230 player->SaveRecallPosition();
231
232 Map const* map = sMapMgr->CreateBaseMap(mapId);
233 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
234
235 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
236 return true;
237 }
#define SIZE_OF_GRIDS
Definition: MapDefines.h:25
#define sMapMgr
Definition: MapMgr.h:219
#define MAX_HEIGHT
Definition: Map.h:162
#define CENTER_GRID_ID
Definition: GridDefines.h:36
Definition: Map.h:311
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2433
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2043

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
409 {
410 uint32 entry = quest->GetQuestId();
411
412 if (type == "starter")
413 {
414 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
415
416 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
417 {
418 if (itr->second == entry)
419 {
420 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
421 if (!spawnpoint)
422 {
424 return false;
425 }
426
427 // We've found a creature, teleport to it.
428 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
429 }
430 }
431
432 qr = sObjectMgr->GetGOQuestRelationMap();
433
434 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
435 {
436 if (itr->second == entry)
437 {
438 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
439 if (!spawnpoint)
440 {
442 return false;
443 }
444
445 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
446 }
447 }
448 }
449 else if (type == "ender")
450 {
451 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
452
453 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
454 {
455 if (itr->second == entry)
456 {
457 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
458 if (!spawnpoint)
459 {
461 return false;
462 }
463
464 // We've found a creature, teleport to it.
465 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
466 }
467 }
468
469 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
470
471 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
472 {
473 if (itr->second == entry)
474 {
475 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
476 if (!spawnpoint)
477 {
479 return false;
480 }
481
482 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
483 }
484 }
485 }
486 else
487 {
489 return false;
490 }
491
492 return false;
493 }
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:524
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition: Language.h:1140

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
240 {
241 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
242 if (!node)
243 {
245 return false;
246 }
247 return DoTeleport(handler, { node->x, node->y, node->z }, node->map_id);
248 }
@ LANG_COMMAND_GOTAXINODENOTFOUND
Definition: Language.h:388
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
Definition: DBCStructure.h:1952
float z
Definition: DBCStructure.h:1957
uint32 map_id
Definition: DBCStructure.h:1954
float x
Definition: DBCStructure.h:1955
float y
Definition: DBCStructure.h:1956

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
384 {
385 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
386 if (!ticket)
387 {
389 return true;
390 }
391
392 Player* player = handler->GetSession()->GetPlayer();
393
394 // stop flight if need
395 if (player->IsInFlight())
396 {
397 player->GetMotionMaster()->MovementExpired();
398 player->CleanupAfterTaxiFlight();
399 }
400 // save only in non-flight case
401 else
402 player->SaveRecallPosition();
403
404 ticket->TeleportTo(player);
405 return true;
406 }
@ LANG_COMMAND_TICKETNOTEXIST
Definition: Language.h:1016
#define sTicketMgr
Definition: TicketMgr.h:260
Definition: TicketMgr.h:88
void TeleportTo(Player *player) const
Definition: TicketMgr.cpp:237

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
251 {
252 AreaTrigger const* at = sObjectMgr->GetAreaTrigger(areaTriggerId);
253 if (!at)
254 {
255 handler->SendErrorMessage(LANG_COMMAND_GOAREATRNOTFOUND, uint32(areaTriggerId));
256 return false;
257 }
258 return DoTeleport(handler, { at->x, at->y, at->z }, at->map);
259 }
@ LANG_COMMAND_GOAREATRNOTFOUND
Definition: Language.h:307
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)
321 {
322 std::wstring wInputCoords;
323 if (!Utf8toWStr(args, wInputCoords))
324 {
325 return false;
326 }
327
328 // extract float and integer values from the input
329 std::vector<float> locationValues;
330 std::wregex floatRegex(L"(-?\\d+(?:\\.\\d+)?)");
331 std::wsregex_iterator floatRegexIterator(wInputCoords.begin(), wInputCoords.end(), floatRegex);
332 std::wsregex_iterator end;
333 while (floatRegexIterator != end)
334 {
335 std::wsmatch match = *floatRegexIterator;
336 std::wstring matchStr = match.str();
337
338 // try to convert the match to a float
339 try
340 {
341 locationValues.push_back(std::stof(matchStr));
342 }
343 // if the match is not a float, do not add it to the vector
344 catch (std::invalid_argument const&){}
345
346 ++floatRegexIterator;
347 }
348
349 // X and Y are required
350 if (locationValues.size() < 2)
351 {
352 return false;
353 }
354
355 Player* player = handler->GetSession()->GetPlayer();
356
357 uint32 mapId = locationValues.size() >= 4 ? uint32(locationValues[3]) : player->GetMapId();
358
359 float x = locationValues[0];
360 float y = locationValues[1];
361
362 if (!sMapStore.LookupEntry(mapId) || !MapMgr::IsValidMapCoord(mapId, x, y))
363 {
364 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
365 return false;
366 }
367
368 Map const* map = sMapMgr->CreateBaseMap(mapId);
369
370 float z = locationValues.size() >= 3 ? locationValues[2] : std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
371 // map ID (locationValues[3]) already handled above
372 float o = locationValues.size() >= 5 ? locationValues[4] : player->GetOrientation();
373
374 if (!MapMgr::IsValidMapCoord(mapId, x, y, z, o))
375 {
376 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
377 return false;
378 }
379
380 return DoTeleport(handler, { x, y, z, o }, mapId);
381 }
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition: Util.cpp:281
DBCStorage< MapEntry > sMapStore(MapEntryfmt)

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

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().