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 DoTeleportToTransport (ChatHandler *handler, Position pos, uint32 transportMapId)
 
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
37: 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
66 {
67 Player* player = handler->GetSession()->GetPlayer();
68
69 if (mapId == MAPID_INVALID)
70 mapId = player->GetMapId();
71
72 if (sObjectMgr->IsTransportMap(mapId))
73 return DoTeleportToTransport(handler, pos, mapId);
74
75 if (!MapMgr::IsValidMapCoord(mapId, pos))
76 {
78 return false;
79 }
80
81 // stop flight if need
82 if (player->IsInFlight())
83 {
85 player->CleanupAfterTaxiFlight();
86 }
87 // save only in non-flight case
88 else
89 player->SaveRecallPosition();
90
91 player->TeleportTo({ mapId, pos });
92 return true;
93 }
@ LANG_INVALID_TARGET_COORD
Definition Language.h:316
#define sObjectMgr
Definition ObjectMgr.h:1723
#define MAPID_INVALID
Definition Position.h:253
WorldSession * GetSession()
Definition Chat.h:242
void SendErrorMessage(uint32 entry)
Definition Chat.cpp:224
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition MapMgr.h:90
void MovementExpired(bool reset=true)
Definition MotionMaster.h:206
Definition Player.h:1084
void SaveRecallPosition()
Definition Player.cpp:5660
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1353
void CleanupAfterTaxiFlight()
Definition Player.cpp:10375
MotionMaster * GetMotionMaster()
Definition Unit.h:1759
bool IsInFlight() const
Definition Unit.h:1706
uint32 GetMapId() const
Definition Position.h:281
Player * GetPlayer() const
Definition WorldSession.h:454
static bool DoTeleportToTransport(ChatHandler *handler, Position pos, uint32 transportMapId)
Definition cs_go.cpp:95
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References Player::CleanupAfterTaxiFlight(), DoTeleportToTransport(), 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().

◆ DoTeleportToTransport()

static bool go_commandscript::DoTeleportToTransport ( ChatHandler handler,
Position  pos,
uint32  transportMapId 
)
inlinestatic
96 {
97 Player* player = handler->GetSession()->GetPlayer();
98
99 uint32 transportEntry = 0;
100 for (auto const& [entry, goTemplate] : *sObjectMgr->GetGameObjectTemplates())
101 {
102 if (goTemplate.type == GAMEOBJECT_TYPE_MO_TRANSPORT && goTemplate.moTransport.mapID == transportMapId)
103 {
104 transportEntry = entry;
105 break;
106 }
107 }
108
109 if (!transportEntry)
110 {
111 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), transportMapId);
112 return false;
113 }
114
115 MotionTransport* transport = nullptr;
116 sMapMgr->DoForAllMaps([&](Map* map)
117 {
118 if (transport)
119 return;
120
121 for (Transport* t : map->GetAllTransports())
122 {
123 if (MotionTransport* mt = t->ToMotionTransport())
124 {
125 if (mt->GetEntry() == transportEntry)
126 {
127 transport = mt;
128 return;
129 }
130 }
131 }
132 });
133
134 if (!transport)
135 {
136 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), transportMapId);
137 return false;
138 }
139
140 if (player->IsInFlight())
141 {
142 player->GetMotionMaster()->MovementExpired();
143 player->CleanupAfterTaxiFlight();
144 }
145 else
146 player->SaveRecallPosition();
147
148 if (Transport* oldTransport = player->GetTransport())
149 oldTransport->RemovePassenger(player, true);
150
151 float const localX = pos.GetPositionX();
152 float const localY = pos.GetPositionY();
153 float const localZ = pos.GetPositionZ();
154 float const localO = pos.GetOrientation();
155
156 player->SetTransport(transport);
157 player->m_movementInfo.transport.guid = transport->GetGUID();
158 player->m_movementInfo.transport.pos.Relocate(localX, localY, localZ, localO);
160
161 float worldX = localX;
162 float worldY = localY;
163 float worldZ = localZ;
164 float worldO = localO;
165 transport->CalculatePassengerPosition(worldX, worldY, worldZ, &worldO);
166
167 transport->AddPassenger(player, false);
168
169 player->TeleportTo(transport->GetMapId(), worldX, worldY, worldZ, worldO, TELE_TO_NOT_LEAVE_TRANSPORT);
170 return true;
171 }
std::uint32_t uint32
Definition Define.h:107
#define sMapMgr
Definition MapMgr.h:220
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:815
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1579
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:381
MotionTransport * ToMotionTransport()
Definition GameObject.h:328
Definition Map.h:166
Definition Transport.h:51
void AddPassenger(WorldObject *passenger, bool withAll=false) override
Definition Transport.cpp:264
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114
Definition Transport.h:30
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
Definition Transport.h:33
void AddUnitMovementFlag(uint32 f)
Definition Unit.h:772
void SetTransport(Transport *t)
Definition Object.h:696
Transport * GetTransport() const
Definition Object.h:688
MovementInfo m_movementInfo
Definition Object.h:698
ObjectGuid guid
Definition Object.h:308
Position pos
Definition Object.h:309
struct MovementInfo::TransportInfo transport
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
void Relocate(float x, float y)
Definition Position.h:77

References MotionTransport::AddPassenger(), Unit::AddUnitMovementFlag(), Transport::CalculatePassengerPosition(), Player::CleanupAfterTaxiFlight(), GAMEOBJECT_TYPE_MO_TRANSPORT, Map::GetAllTransports(), Object::GetGUID(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), ChatHandler::GetSession(), WorldObject::GetTransport(), MovementInfo::TransportInfo::guid, Unit::IsInFlight(), LANG_INVALID_TARGET_COORD, WorldObject::m_movementInfo, MotionMaster::MovementExpired(), MOVEMENTFLAG_ONTRANSPORT, MovementInfo::TransportInfo::pos, Position::Relocate(), Player::SaveRecallPosition(), ChatHandler::SendErrorMessage(), WorldObject::SetTransport(), sMapMgr, sObjectMgr, TELE_TO_NOT_LEAVE_TRANSPORT, Player::TeleportTo(), GameObject::ToMotionTransport(), and MovementInfo::transport.

Referenced by DoTeleport().

◆ GetCommands()

ChatCommandTable go_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

40 {
41 static ChatCommandTable goCommandTable =
42 {
44 { "creature id", HandleGoCreatureCIdCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
45 { "creature name", HandleGoCreatureNameCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
47 { "gameobject id", HandleGoGameObjectGOIdCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
48 { "graveyard", HandleGoGraveyardCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
49 { "grid", HandleGoGridCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
50 { "taxinode", HandleGoTaxinodeCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
51 { "trigger", HandleGoTriggerCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
52 { "zonexy", HandleGoZoneXYCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
53 { "xyz", HandleGoXYZCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
54 { "ticket", HandleGoTicketCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
55 { "quest", HandleGoQuestCommand, rbac::RBAC_PERM_COMMAND_GO, Console::No },
56 };
57
58 static ChatCommandTable commandTable =
59 {
60 { "go", goCommandTable }
61 };
62 return commandTable;
63 }
static bool HandleGoGameObjectGOIdCommand(ChatHandler *handler, uint32 goId, Optional< uint32 > _pos)
Definition cs_go.cpp:256
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition cs_go.cpp:288
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition cs_go.cpp:520
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition cs_go.cpp:351
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition cs_go.cpp:319
static bool HandleGoCreatureNameCommand(ChatHandler *handler, Tail name)
Definition cs_go.cpp:217
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition cs_go.cpp:362
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:432
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId, Optional< uint32 > _pos)
Definition cs_go.cpp:173
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition cs_go.cpp:495
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_go.cpp:205
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition cs_go.cpp:374
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition cs_go.cpp:244
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:46
@ RBAC_PERM_COMMAND_GO
Definition RBAC.h:225

References HandleGoCreatureCIdCommand(), HandleGoCreatureNameCommand(), HandleGoCreatureSpawnIdCommand(), HandleGoGameObjectGOIdCommand(), HandleGoGameObjectSpawnIdCommand(), HandleGoGraveyardCommand(), HandleGoGridCommand(), HandleGoQuestCommand(), HandleGoTaxinodeCommand(), HandleGoTicketCommand(), HandleGoTriggerCommand(), HandleGoXYZCommand(), HandleGoZoneXYCommand(), and rbac::RBAC_PERM_COMMAND_GO.

◆ GetCreatureData()

static CreatureData const * go_commandscript::GetCreatureData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
608 {
609 CreatureData const* spawnpoint = nullptr;
610 for (auto const& pair : sObjectMgr->GetAllCreatureData())
611 {
612 if (pair.second.id1 != entry)
613 {
614 continue;
615 }
616
617 if (!spawnpoint)
618 {
619 spawnpoint = &pair.second;
620 }
621 else
622 {
624 break;
625 }
626 }
627
628 return spawnpoint;
629 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition Language.h:322
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:168
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
632 {
633 std::vector<CreatureData const*> spawnpoints;
634 for (auto const& pair : sObjectMgr->GetAllCreatureData())
635 {
636 if (pair.second.id1 != entry)
637 {
638 continue;
639 }
640
641 spawnpoints.emplace_back(&pair.second);
642 }
643
644 return spawnpoints;
645 }

References sObjectMgr.

Referenced by HandleGoCreatureCIdCommand().

◆ GetGameObjectData()

static GameObjectData const * go_commandscript::GetGameObjectData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
648 {
649 GameObjectData const* spawnpoint = nullptr;
650 for (auto const& pair : sObjectMgr->GetAllGOData())
651 {
652 if (pair.second.id != entry)
653 {
654 continue;
655 }
656
657 if (!spawnpoint)
658 {
659 spawnpoint = &pair.second;
660 }
661 else
662 {
664 break;
665 }
666 }
667
668 return spawnpoint;
669 }
Definition GameObjectData.h:715

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

Referenced by HandleGoQuestCommand().

◆ GetGameObjectDataList()

static std::vector< GameObjectData const * > go_commandscript::GetGameObjectDataList ( uint32  entry)
inlinestatic
672 {
673 std::vector<GameObjectData const*> spawnpoints;
674 for (auto const& pair : sObjectMgr->GetAllGOData())
675 {
676 if (pair.second.id != entry)
677 {
678 continue;
679 }
680
681 spawnpoints.emplace_back(&pair.second);
682 }
683
684 return spawnpoints;
685 }

References sObjectMgr.

Referenced by HandleGoGameObjectGOIdCommand().

◆ HandleGoCreatureCIdCommand()

static bool go_commandscript::HandleGoCreatureCIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 cId,
Optional< uint32 _pos 
)
inlinestatic
174 {
175 uint32 pos = 1;
176 if (_pos)
177 {
178 pos = *_pos;
179 if (pos < 1)
180 {
182 return false;
183 }
184 }
185
186 std::vector<CreatureData const*> spawnpoints = GetCreatureDataList(*cId);
187
188 if (spawnpoints.empty())
189 {
191 return false;
192 }
193
194 if (spawnpoints.size() < pos)
195 {
196 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
197 return false;
198 }
199
200 CreatureData const* spawnpoint = spawnpoints[--pos];
201
202 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
203 }
@ LANG_COMMAND_GOCREATNOTFOUND
Definition Language.h:321
@ LANG_COMMAND_GONOTENOUGHSPAWNS
Definition Language.h:341
@ LANG_COMMAND_FACTION_INVPARAM
Definition Language.h:359
static bool DoTeleport(ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
Definition cs_go.cpp:65
static std::vector< CreatureData const * > GetCreatureDataList(uint32 entry)
Definition cs_go.cpp:631
float posX
Definition SpawnData.h:71
float posY
Definition SpawnData.h:72
uint16 mapid
Definition SpawnData.h:69
float posZ
Definition SpawnData.h:73

References DoTeleport(), GetCreatureDataList(), LANG_COMMAND_FACTION_INVPARAM, LANG_COMMAND_GOCREATNOTFOUND, LANG_COMMAND_GONOTENOUGHSPAWNS, SpawnData::mapid, SpawnData::posX, SpawnData::posY, SpawnData::posZ, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleGoCreatureNameCommand()

static bool go_commandscript::HandleGoCreatureNameCommand ( ChatHandler handler,
Tail  name 
)
inlinestatic
218 {
219 if (!name.data())
220 return false;
221
222 // Make sure we don't pass double quotes into the SQL query. Otherwise it causes a MySQL error
223 std::string str = name.data(); // Making subtractions to the last character does not with in string_view
224 WorldDatabase.EscapeString(str);
225
226 QueryResult result = WorldDatabase.Query("SELECT entry FROM creature_template WHERE name = \"{}\" LIMIT 1", str);
227 if (!result)
228 {
230 return false;
231 }
232
233 uint32 entry = result->Fetch()[0].Get<uint32>();
234 CreatureData const* spawnpoint = GetCreatureData(handler, entry);
235 if (!spawnpoint)
236 {
238 return false;
239 }
240
241 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
242 }
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:607

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
206 {
207 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
208 if (!spawnpoint)
209 {
211 return false;
212 }
213
214 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
215 }

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

Referenced by GetCommands().

◆ HandleGoGameObjectGOIdCommand()

static bool go_commandscript::HandleGoGameObjectGOIdCommand ( ChatHandler handler,
uint32  goId,
Optional< uint32 _pos 
)
inlinestatic
257 {
258 uint32 pos = 1;
259 if (_pos)
260 {
261 pos = *_pos;
262 if (pos < 1)
263 {
265 return false;
266 }
267 }
268
269 std::vector<GameObjectData const*> spawnpoints = GetGameObjectDataList(goId);
270
271 if (spawnpoints.empty())
272 {
274 return false;
275 }
276
277 if (spawnpoints.size() < pos)
278 {
279 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
280 return false;
281 }
282
283 GameObjectData const* spawnpoint = spawnpoints[--pos];
284
285 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
286 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition Language.h:320
static std::vector< GameObjectData const * > GetGameObjectDataList(uint32 entry)
Definition cs_go.cpp:671

References DoTeleport(), GetGameObjectDataList(), LANG_COMMAND_FACTION_INVPARAM, LANG_COMMAND_GONOTENOUGHSPAWNS, LANG_COMMAND_GOOBJNOTFOUND, SpawnData::mapid, SpawnData::posX, SpawnData::posY, SpawnData::posZ, and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleGoGameObjectSpawnIdCommand()

static bool go_commandscript::HandleGoGameObjectSpawnIdCommand ( ChatHandler handler,
uint32  spawnId 
)
inlinestatic
245 {
246 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
247 if (!spawnpoint)
248 {
250 return false;
251 }
252
253 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
254 }

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

Referenced by GetCommands().

◆ HandleGoGraveyardCommand()

static bool go_commandscript::HandleGoGraveyardCommand ( ChatHandler handler,
uint32  gyId 
)
inlinestatic
289 {
290 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
291 if (!gy)
292 {
294 return false;
295 }
296
297 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
298 {
299 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
300 return false;
301 }
302
303 Player* player = handler->GetSession()->GetPlayer();
304 // stop flight if need
305 if (player->IsInFlight())
306 {
307 player->GetMotionMaster()->MovementExpired();
308 player->CleanupAfterTaxiFlight();
309 }
310 // save only in non-flight case
311 else
312 player->SaveRecallPosition();
313
314 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
315 return true;
316 }
#define sGraveyard
Definition GameGraveyard.h:74
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition Language.h:490
Definition GameGraveyard.h:27
float z
Definition GameGraveyard.h:32
float x
Definition GameGraveyard.h:30
float y
Definition GameGraveyard.h:31
uint32 Map
Definition GameGraveyard.h:29

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

Referenced by GetCommands().

◆ HandleGoGridCommand()

static bool go_commandscript::HandleGoGridCommand ( ChatHandler handler,
float  gridX,
float  gridY,
Optional< uint32 oMapId 
)
inlinestatic
320 {
321 Player* player = handler->GetSession()->GetPlayer();
322 uint32 mapId = oMapId.value_or(player->GetMapId());
323
324 // center of grid
325 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
326 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
327
328 if (!MapMgr::IsValidMapCoord(mapId, x, y))
329 {
330 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
331 return false;
332 }
333
334 // stop flight if need
335 if (player->IsInFlight())
336 {
337 player->GetMotionMaster()->MovementExpired();
338 player->CleanupAfterTaxiFlight();
339 }
340 // save only in non-flight case
341 else
342 player->SaveRecallPosition();
343
344 Map const* map = sMapMgr->CreateBaseMap(mapId);
345 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
346
347 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
348 return true;
349 }
#define CENTER_GRID_ID
Definition GridDefines.h:35
#define MAX_HEIGHT
Definition GridTerrainData.h:26
#define SIZE_OF_GRIDS
Definition MapDefines.h:26
float GetWaterLevel(float x, float y) const
Definition Map.cpp:1529
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1156

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
521 {
522 uint32 entry = quest->GetQuestId();
523
524 if (type == "starter")
525 {
526 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
527
528 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
529 {
530 if (itr->second == entry)
531 {
532 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
533 if (!spawnpoint)
534 {
536 return false;
537 }
538
539 // We've found a creature, teleport to it.
540 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
541 }
542 }
543
544 qr = sObjectMgr->GetGOQuestRelationMap();
545
546 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
547 {
548 if (itr->second == entry)
549 {
550 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
551 if (!spawnpoint)
552 {
554 return false;
555 }
556
557 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
558 }
559 }
560 }
561 else if (type == "ender")
562 {
563 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
564
565 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
566 {
567 if (itr->second == entry)
568 {
569 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
570 if (!spawnpoint)
571 {
573 return false;
574 }
575
576 // We've found a creature, teleport to it.
577 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
578 }
579 }
580
581 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
582
583 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
584 {
585 if (itr->second == entry)
586 {
587 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
588 if (!spawnpoint)
589 {
591 return false;
592 }
593
594 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
595 }
596 }
597 }
598 else
599 {
601 return false;
602 }
603
604 return false;
605 }
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition Language.h:1155
std::multimap< uint32, uint32 > QuestRelations
Definition ObjectMgr.h:528
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:647

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

Referenced by GetCommands().

◆ HandleGoTaxinodeCommand()

static bool go_commandscript::HandleGoTaxinodeCommand ( ChatHandler handler,
Variant< Hyperlink< taxinode >, uint32 nodeId 
)
inlinestatic
352 {
353 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
354 if (!node)
355 {
357 return false;
358 }
359 return DoTeleport(handler, { node->x, node->y, node->z }, node->map_id);
360 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_GOTAXINODENOTFOUND
Definition Language.h:397
Definition DBCStructure.h:1953
float z
Definition DBCStructure.h:1958
uint32 map_id
Definition DBCStructure.h:1955
float x
Definition DBCStructure.h:1956
float y
Definition DBCStructure.h:1957

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
496 {
497 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
498 if (!ticket)
499 {
501 return true;
502 }
503
504 Player* player = handler->GetSession()->GetPlayer();
505
506 // stop flight if need
507 if (player->IsInFlight())
508 {
509 player->GetMotionMaster()->MovementExpired();
510 player->CleanupAfterTaxiFlight();
511 }
512 // save only in non-flight case
513 else
514 player->SaveRecallPosition();
515
516 ticket->TeleportTo(player);
517 return true;
518 }
@ LANG_COMMAND_TICKETNOTEXIST
Definition Language.h:1031
#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
363 {
364 AreaTrigger const* at = sObjectMgr->GetAreaTrigger(areaTriggerId);
365 if (!at)
366 {
367 handler->SendErrorMessage(LANG_COMMAND_GOAREATRNOTFOUND, uint32(areaTriggerId));
368 return false;
369 }
370 return DoTeleport(handler, { at->x, at->y, at->z }, at->map);
371 }
@ LANG_COMMAND_GOAREATRNOTFOUND
Definition Language.h:315
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)
433 {
434 std::wstring wInputCoords;
435 if (!Utf8toWStr(args, wInputCoords))
436 {
437 return false;
438 }
439
440 // extract float and integer values from the input
441 std::vector<float> locationValues;
442 std::wregex floatRegex(L"(-?\\d+(?:\\.\\d+)?)");
443 std::wsregex_iterator floatRegexIterator(wInputCoords.begin(), wInputCoords.end(), floatRegex);
444 std::wsregex_iterator end;
445 while (floatRegexIterator != end)
446 {
447 std::wsmatch match = *floatRegexIterator;
448 std::wstring matchStr = match.str();
449
450 // try to convert the match to a float
451 try
452 {
453 locationValues.push_back(std::stof(matchStr));
454 }
455 // if the match is not a float, do not add it to the vector
456 catch (std::invalid_argument const&){}
457
458 ++floatRegexIterator;
459 }
460
461 // X and Y are required
462 if (locationValues.size() < 2)
463 {
464 return false;
465 }
466
467 Player* player = handler->GetSession()->GetPlayer();
468
469 uint32 mapId = locationValues.size() >= 4 ? uint32(locationValues[3]) : player->GetMapId();
470
471 float x = locationValues[0];
472 float y = locationValues[1];
473
474 if (!sMapStore.LookupEntry(mapId) || !MapMgr::IsValidMapCoord(mapId, x, y))
475 {
476 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
477 return false;
478 }
479
480 Map const* map = sMapMgr->CreateBaseMap(mapId);
481
482 float z = locationValues.size() >= 3 ? locationValues[2] : std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
483 // map ID (locationValues[3]) already handled above
484 float o = locationValues.size() >= 5 ? locationValues[4] : player->GetOrientation();
485
486 if (!MapMgr::IsValidMapCoord(mapId, x, y, z, o))
487 {
488 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
489 return false;
490 }
491
492 return DoTeleport(handler, { x, y, z, o }, mapId);
493 }
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
375 {
376 Player* player = handler->GetSession()->GetPlayer();
377
378 uint32 areaId = areaIdArg ? *areaIdArg : player->GetZoneId();
379
380 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
381
382 if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
383 {
384 handler->SendErrorMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
385 return false;
386 }
387
388 // update to parent zone if exist (client map show only zones without parents)
389 AreaTableEntry const* zoneEntry = areaEntry->zone ? sAreaTableStore.LookupEntry(areaEntry->zone) : areaEntry;
390 ASSERT(zoneEntry);
391
392 Map const* map = sMapMgr->CreateBaseMap(zoneEntry->mapid);
393
394 if (map->Instanceable())
395 {
396 handler->SendErrorMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
397 return false;
398 }
399
400 Zone2MapCoordinates(x, y, zoneEntry->ID);
401
402 if (!MapMgr::IsValidMapCoord(zoneEntry->mapid, x, y))
403 {
404 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, zoneEntry->mapid);
405 return false;
406 }
407
408 // stop flight if need
409 if (player->IsInFlight())
410 {
411 player->GetMotionMaster()->MovementExpired();
412 player->CleanupAfterTaxiFlight();
413 }
414 // save only in non-flight case
415 else
416 player->SaveRecallPosition();
417
418 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
419
420 player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
421 return true;
422 }
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:318
@ LANG_INVALID_ZONE_COORD
Definition Language.h:317
virtual LocaleConstant GetSessionDbcLocale() const
Definition Chat.cpp:878
bool Instanceable() const
Definition Map.h:296
uint32 GetId() const
Definition Map.h:232
const char * GetMapName() const
Definition Map.cpp:1611
uint32 GetZoneId() const
Definition Object.cpp:3111
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: