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:253
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:195
Definition Player.h:1071
void SaveRecallPosition()
Definition Player.cpp:5655
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1350
void CleanupAfterTaxiFlight()
Definition Player.cpp:10420
MotionMaster * GetMotionMaster()
Definition Unit.h:1713
bool IsInFlight() const
Definition Unit.h:1660
uint32 GetMapId() const
Definition Position.h:281
Player * GetPlayer() const
Definition WorldSession.h:424
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:172
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition cs_go.cpp:204
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition cs_go.cpp:436
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition cs_go.cpp:267
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition cs_go.cpp:235
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:278
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:348
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:411
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:290
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition cs_go.cpp:160
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
524 {
525 CreatureData const* spawnpoint = nullptr;
526 for (auto const& pair : sObjectMgr->GetAllCreatureData())
527 {
528 if (pair.second.id1 != entry)
529 {
530 continue;
531 }
532
533 if (!spawnpoint)
534 {
535 spawnpoint = &pair.second;
536 }
537 else
538 {
540 break;
541 }
542 }
543
544 return spawnpoint;
545 }
@ 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
548 {
549 std::vector<CreatureData const*> spawnpoints;
550 for (auto const& pair : sObjectMgr->GetAllCreatureData())
551 {
552 if (pair.second.id1 != entry)
553 {
554 continue;
555 }
556
557 spawnpoints.emplace_back(&pair.second);
558 }
559
560 return spawnpoints;
561 }

References sObjectMgr.

Referenced by HandleGoCreatureCIdCommand().

◆ GetGameObjectData()

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

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

Referenced by HandleGoQuestCommand().

◆ GetGameObjectDataList()

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

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:547
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 WorldDatabase.EscapeString(str);
141
142 QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str);
143 if (!result)
144 {
146 return false;
147 }
148
149 uint32 entry = result->Fetch()[0].Get<uint32>();
150 CreatureData const* spawnpoint = GetCreatureData(handler, entry);
151 if (!spawnpoint)
152 {
154 return false;
155 }
156
157 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
158 }
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:523

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
173 {
174 uint32 pos = 1;
175 if (_pos)
176 {
177 pos = *_pos;
178 if (pos < 1)
179 {
181 return false;
182 }
183 }
184
185 std::vector<GameObjectData const*> spawnpoints = GetGameObjectDataList(goId);
186
187 if (spawnpoints.empty())
188 {
190 return false;
191 }
192
193 if (spawnpoints.size() < pos)
194 {
195 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
196 return false;
197 }
198
199 GameObjectData const* spawnpoint = spawnpoints[--pos];
200
201 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
202 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition Language.h:317
static std::vector< GameObjectData const * > GetGameObjectDataList(uint32 entry)
Definition cs_go.cpp:587
float posZ
Definition GameObjectData.h:705
uint16 mapid
Definition GameObjectData.h:701
float posX
Definition GameObjectData.h:703
float posY
Definition GameObjectData.h:704

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
161 {
162 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
163 if (!spawnpoint)
164 {
166 return false;
167 }
168
169 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
170 }

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

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

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