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
 
- 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, Optional< uint32 > _pos)
 
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, Optional< uint32 > _pos)
 
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 std::vector< CreatureData const * > GetCreatureDataList (uint32 entry)
 
static GameObjectData const * GetGameObjectData (ChatHandler *handler, uint32 entry)
 
static std::vector< GameObjectData const * > GetGameObjectDataList (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:313
#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:1083
void SaveRecallPosition()
Definition Player.cpp:5690
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1342
void CleanupAfterTaxiFlight()
Definition Player.cpp:10412
MotionMaster * GetMotionMaster()
Definition Unit.h:1673
bool IsInFlight() const
Definition Unit.h:1619
uint32 GetMapId() const
Definition Position.h:280
Player * GetPlayer() const
Definition WorldSession.h:381
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, Optional< uint32 > _pos)
Definition cs_go.cpp:175
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition cs_go.cpp:207
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition cs_go.cpp:439
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition cs_go.cpp:270
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition cs_go.cpp:238
static bool HandleGoCreatureNameCommand(ChatHandler *handler, Tail name)
Definition cs_go.cpp:133
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition cs_go.cpp:281
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:351
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId, Optional< uint32 > _pos)
Definition cs_go.cpp:89
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition cs_go.cpp:414
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_go.cpp:121
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition cs_go.cpp:293
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition cs_go.cpp:163
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
527 {
528 CreatureData const* spawnpoint = nullptr;
529 for (auto const& pair : sObjectMgr->GetAllCreatureData())
530 {
531 if (pair.second.id1 != entry)
532 {
533 continue;
534 }
535
536 if (!spawnpoint)
537 {
538 spawnpoint = &pair.second;
539 }
540 else
541 {
543 break;
544 }
545 }
546
547 return spawnpoint;
548 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition Language.h:319
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 HandleGoCreatureNameCommand(), and HandleGoQuestCommand().

◆ GetCreatureDataList()

static std::vector< CreatureData const * > go_commandscript::GetCreatureDataList ( uint32  entry)
inlinestatic
551 {
552 std::vector<CreatureData const*> spawnpoints;
553 for (auto const& pair : sObjectMgr->GetAllCreatureData())
554 {
555 if (pair.second.id1 != entry)
556 {
557 continue;
558 }
559
560 spawnpoints.emplace_back(&pair.second);
561 }
562
563 return spawnpoints;
564 }

References sObjectMgr.

Referenced by HandleGoCreatureCIdCommand().

◆ GetGameObjectData()

static GameObjectData const * go_commandscript::GetGameObjectData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
567 {
568 GameObjectData const* spawnpoint = nullptr;
569 for (auto const& pair : sObjectMgr->GetAllGOData())
570 {
571 if (pair.second.id != entry)
572 {
573 continue;
574 }
575
576 if (!spawnpoint)
577 {
578 spawnpoint = &pair.second;
579 }
580 else
581 {
583 break;
584 }
585 }
586
587 return spawnpoint;
588 }
Definition GameObjectData.h:696

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

Referenced by HandleGoQuestCommand().

◆ GetGameObjectDataList()

static std::vector< GameObjectData const * > go_commandscript::GetGameObjectDataList ( uint32  entry)
inlinestatic
591 {
592 std::vector<GameObjectData const*> spawnpoints;
593 for (auto const& pair : sObjectMgr->GetAllGOData())
594 {
595 if (pair.second.id != entry)
596 {
597 continue;
598 }
599
600 spawnpoints.emplace_back(&pair.second);
601 }
602
603 return spawnpoints;
604 }

References sObjectMgr.

Referenced by HandleGoGameObjectGOIdCommand().

◆ HandleGoCreatureCIdCommand()

static bool go_commandscript::HandleGoCreatureCIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 cId,
Optional< uint32 _pos 
)
inlinestatic
90 {
91 uint32 pos = 1;
92 if (_pos)
93 {
94 pos = *_pos;
95 if (pos < 1)
96 {
98 return false;
99 }
100 }
101
102 std::vector<CreatureData const*> spawnpoints = GetCreatureDataList(*cId);
103
104 if (spawnpoints.empty())
105 {
107 return false;
108 }
109
110 if (spawnpoints.size() < pos)
111 {
112 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
113 return false;
114 }
115
116 CreatureData const* spawnpoint = spawnpoints[--pos];
117
118 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
119 }
std::uint32_t uint32
Definition Define.h:107
@ LANG_COMMAND_GOCREATNOTFOUND
Definition Language.h:318
@ LANG_COMMAND_GONOTENOUGHSPAWNS
Definition Language.h:338
@ LANG_COMMAND_FACTION_INVPARAM
Definition Language.h:356
static bool DoTeleport(ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
Definition cs_go.cpp:63
static std::vector< CreatureData const * > GetCreatureDataList(uint32 entry)
Definition cs_go.cpp:550
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(), GetCreatureDataList(), LANG_COMMAND_FACTION_INVPARAM, LANG_COMMAND_GOCREATNOTFOUND, LANG_COMMAND_GONOTENOUGHSPAWNS, 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
134 {
135 if (!name.data())
136 return false;
137
138 // Make sure we don't pass double quotes into the SQL query. Otherwise it causes a MySQL error
139 std::string str = name.data(); // Making subtractions to the last character does not with in string_view
140 if (str.front() == '"')
141 str = str.substr(1);
142 if (str.back() == '"')
143 str = str.substr(0, str.size() - 1);
144
145 QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str);
146 if (!result)
147 {
149 return false;
150 }
151
152 uint32 entry = result->Fetch()[0].Get<uint32>();
153 CreatureData const* spawnpoint = GetCreatureData(handler, entry);
154 if (!spawnpoint)
155 {
157 return false;
158 }
159
160 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
161 }
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
static CreatureData const * GetCreatureData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:526

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
122 {
123 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
124 if (!spawnpoint)
125 {
127 return false;
128 }
129
130 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
131 }

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,
Optional< uint32 _pos 
)
inlinestatic
176 {
177 uint32 pos = 1;
178 if (_pos)
179 {
180 pos = *_pos;
181 if (pos < 1)
182 {
184 return false;
185 }
186 }
187
188 std::vector<GameObjectData const*> spawnpoints = GetGameObjectDataList(goId);
189
190 if (spawnpoints.empty())
191 {
193 return false;
194 }
195
196 if (spawnpoints.size() < pos)
197 {
198 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
199 return false;
200 }
201
202 GameObjectData const* spawnpoint = spawnpoints[--pos];
203
204 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
205 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition Language.h:317
static std::vector< GameObjectData const * > GetGameObjectDataList(uint32 entry)
Definition cs_go.cpp:590
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(), GetGameObjectDataList(), LANG_COMMAND_FACTION_INVPARAM, LANG_COMMAND_GONOTENOUGHSPAWNS, 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
164 {
165 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
166 if (!spawnpoint)
167 {
169 return false;
170 }
171
172 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
173 }

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
208 {
209 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
210 if (!gy)
211 {
213 return false;
214 }
215
216 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
217 {
218 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
219 return false;
220 }
221
222 Player* player = handler->GetSession()->GetPlayer();
223 // stop flight if need
224 if (player->IsInFlight())
225 {
226 player->GetMotionMaster()->MovementExpired();
227 player->CleanupAfterTaxiFlight();
228 }
229 // save only in non-flight case
230 else
231 player->SaveRecallPosition();
232
233 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
234 return true;
235 }
#define sGraveyard
Definition GameGraveyard.h:74
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition Language.h:487
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
239 {
240 Player* player = handler->GetSession()->GetPlayer();
241 uint32 mapId = oMapId.value_or(player->GetMapId());
242
243 // center of grid
244 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
245 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
246
247 if (!MapMgr::IsValidMapCoord(mapId, x, y))
248 {
249 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
250 return false;
251 }
252
253 // stop flight if need
254 if (player->IsInFlight())
255 {
256 player->GetMotionMaster()->MovementExpired();
257 player->CleanupAfterTaxiFlight();
258 }
259 // save only in non-flight case
260 else
261 player->SaveRecallPosition();
262
263 Map const* map = sMapMgr->CreateBaseMap(mapId);
264 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
265
266 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
267 return true;
268 }
#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:158
float GetWaterLevel(float x, float y) const
Definition Map.cpp:1512
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1122

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
440 {
441 uint32 entry = quest->GetQuestId();
442
443 if (type == "starter")
444 {
445 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
446
447 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
448 {
449 if (itr->second == entry)
450 {
451 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
452 if (!spawnpoint)
453 {
455 return false;
456 }
457
458 // We've found a creature, teleport to it.
459 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
460 }
461 }
462
463 qr = sObjectMgr->GetGOQuestRelationMap();
464
465 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
466 {
467 if (itr->second == entry)
468 {
469 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
470 if (!spawnpoint)
471 {
473 return false;
474 }
475
476 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
477 }
478 }
479 }
480 else if (type == "ender")
481 {
482 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
483
484 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
485 {
486 if (itr->second == entry)
487 {
488 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
489 if (!spawnpoint)
490 {
492 return false;
493 }
494
495 // We've found a creature, teleport to it.
496 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
497 }
498 }
499
500 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
501
502 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
503 {
504 if (itr->second == entry)
505 {
506 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
507 if (!spawnpoint)
508 {
510 return false;
511 }
512
513 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
514 }
515 }
516 }
517 else
518 {
520 return false;
521 }
522
523 return false;
524 }
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition Language.h:1148
std::multimap< uint32, uint32 > QuestRelations
Definition ObjectMgr.h:524
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:566

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
271 {
272 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
273 if (!node)
274 {
276 return false;
277 }
278 return DoTeleport(handler, { node->x, node->y, node->z }, node->map_id);
279 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_GOTAXINODENOTFOUND
Definition Language.h:394
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
415 {
416 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
417 if (!ticket)
418 {
420 return true;
421 }
422
423 Player* player = handler->GetSession()->GetPlayer();
424
425 // stop flight if need
426 if (player->IsInFlight())
427 {
428 player->GetMotionMaster()->MovementExpired();
429 player->CleanupAfterTaxiFlight();
430 }
431 // save only in non-flight case
432 else
433 player->SaveRecallPosition();
434
435 ticket->TeleportTo(player);
436 return true;
437 }
@ LANG_COMMAND_TICKETNOTEXIST
Definition Language.h:1024
#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
282 {
283 AreaTrigger const* at = sObjectMgr->GetAreaTrigger(areaTriggerId);
284 if (!at)
285 {
286 handler->SendErrorMessage(LANG_COMMAND_GOAREATRNOTFOUND, uint32(areaTriggerId));
287 return false;
288 }
289 return DoTeleport(handler, { at->x, at->y, at->z }, at->map);
290 }
@ LANG_COMMAND_GOAREATRNOTFOUND
Definition Language.h:312
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)
352 {
353 std::wstring wInputCoords;
354 if (!Utf8toWStr(args, wInputCoords))
355 {
356 return false;
357 }
358
359 // extract float and integer values from the input
360 std::vector<float> locationValues;
361 std::wregex floatRegex(L"(-?\\d+(?:\\.\\d+)?)");
362 std::wsregex_iterator floatRegexIterator(wInputCoords.begin(), wInputCoords.end(), floatRegex);
363 std::wsregex_iterator end;
364 while (floatRegexIterator != end)
365 {
366 std::wsmatch match = *floatRegexIterator;
367 std::wstring matchStr = match.str();
368
369 // try to convert the match to a float
370 try
371 {
372 locationValues.push_back(std::stof(matchStr));
373 }
374 // if the match is not a float, do not add it to the vector
375 catch (std::invalid_argument const&){}
376
377 ++floatRegexIterator;
378 }
379
380 // X and Y are required
381 if (locationValues.size() < 2)
382 {
383 return false;
384 }
385
386 Player* player = handler->GetSession()->GetPlayer();
387
388 uint32 mapId = locationValues.size() >= 4 ? uint32(locationValues[3]) : player->GetMapId();
389
390 float x = locationValues[0];
391 float y = locationValues[1];
392
393 if (!sMapStore.LookupEntry(mapId) || !MapMgr::IsValidMapCoord(mapId, x, y))
394 {
395 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
396 return false;
397 }
398
399 Map const* map = sMapMgr->CreateBaseMap(mapId);
400
401 float z = locationValues.size() >= 3 ? locationValues[2] : std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
402 // map ID (locationValues[3]) already handled above
403 float o = locationValues.size() >= 5 ? locationValues[4] : player->GetOrientation();
404
405 if (!MapMgr::IsValidMapCoord(mapId, x, y, z, o))
406 {
407 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
408 return false;
409 }
410
411 return DoTeleport(handler, { x, y, z, o }, mapId);
412 }
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
294 {
295 Player* player = handler->GetSession()->GetPlayer();
296
297 uint32 areaId = areaIdArg ? *areaIdArg : player->GetZoneId();
298
299 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
300
301 if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
302 {
303 handler->SendErrorMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
304 return false;
305 }
306
307 // update to parent zone if exist (client map show only zones without parents)
308 AreaTableEntry const* zoneEntry = areaEntry->zone ? sAreaTableStore.LookupEntry(areaEntry->zone) : areaEntry;
309 ASSERT(zoneEntry);
310
311 Map const* map = sMapMgr->CreateBaseMap(zoneEntry->mapid);
312
313 if (map->Instanceable())
314 {
315 handler->SendErrorMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
316 return false;
317 }
318
319 Zone2MapCoordinates(x, y, zoneEntry->ID);
320
321 if (!MapMgr::IsValidMapCoord(zoneEntry->mapid, x, y))
322 {
323 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, zoneEntry->mapid);
324 return false;
325 }
326
327 // stop flight if need
328 if (player->IsInFlight())
329 {
330 player->GetMotionMaster()->MovementExpired();
331 player->CleanupAfterTaxiFlight();
332 }
333 // save only in non-flight case
334 else
335 player->SaveRecallPosition();
336
337 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
338
339 player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
340 return true;
341 }
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:315
@ LANG_INVALID_ZONE_COORD
Definition Language.h:314
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:870
bool Instanceable() const
Definition Map.h:289
uint32 GetId() const
Definition Map.h:224
const char * GetMapName() const
Definition Map.cpp:1608
uint32 GetZoneId() const
Definition Object.cpp:3144
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: