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
 

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)
 
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 MAPID_INVALID
Definition: Position.h:248
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ LANG_INVALID_TARGET_COORD
Definition: Language.h:308
WorldSession * GetSession()
Definition: Chat.h:139
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:152
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetMapId() const
Definition: Position.h:276
Definition: Player.h:1056
void SaveRecallPosition()
Definition: Player.cpp:5577
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1314
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10346
MotionMaster * GetMotionMaster()
Definition: Unit.h:2276
bool IsInFlight() const
Definition: Unit.h:1690
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:91
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Player * GetPlayer() const
Definition: WorldSession.h:364

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:61
@ SEC_MODERATOR
Definition: Common.h:60
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
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:121
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:109
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: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
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:314
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:101
Definition: CreatureData.h:359

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:697

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:369
float posX
Definition: CreatureData.h:368
uint16 mapid
Definition: CreatureData.h:364
float posZ
Definition: CreatureData.h:370
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: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 QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1" , name.data());
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::uint32_t uint32
Definition: Define.h:108
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28

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
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:312
float posZ
Definition: GameObjectData.h:704
uint16 mapid
Definition: GameObjectData.h:700
float posX
Definition: GameObjectData.h:702
float posY
Definition: GameObjectData.h:703
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition: cs_go.cpp:512

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:75
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition: Language.h:464
float GetOrientation() const
Definition: Position.h:120
Definition: GameGraveyard.h:28
float z
Definition: GameGraveyard.h:33
float x
Definition: GameGraveyard.h:31
float y
Definition: GameGraveyard.h:32
uint32 Map
Definition: GameGraveyard.h:30

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 SIZE_OF_GRIDS
Definition: MapDefines.h:25
#define CENTER_GRID_ID
Definition: GridDefines.h:37
#define MAX_HEIGHT
Definition: Map.h:164
#define sMapMgr
Definition: MapMgr.h:221
Definition: Map.h:313
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
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 }
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:518
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition: Language.h:1156

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:388
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:1034
#define sTicketMgr
Definition: TicketMgr.h:258
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
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:307
Definition: ObjectMgr.h:421
float x
Definition: ObjectMgr.h:424
float y
Definition: ObjectMgr.h:425
uint32 map
Definition: ObjectMgr.h:423
float z
Definition: ObjectMgr.h:426

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 (mapId == MAPID_INVALID)
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 }
bool Utf8toWStr(char const *utf8str, size_t csize, wchar_t *wstr, 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, MAPID_INVALID, MAX_HEIGHT, ChatHandler::SendErrorMessage(), sMapMgr, 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 }
#define ASSERT
Definition: Errors.h:68
void Zone2MapCoordinates(float &x, float &y, uint32 zone)
Definition: DBCStores.cpp:731
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ LANG_INVALID_ZONE_MAP
Definition: Language.h:310
@ LANG_INVALID_ZONE_COORD
Definition: Language.h:309
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:789
uint32 GetZoneId() const
Definition: Object.cpp:3100
bool Instanceable() const
Definition: Map.h:447
uint32 GetId() const
Definition: Map.h:379
const char * GetMapName() const
Definition: Map.cpp:2519
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().