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
36: 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
65 {
66 Player* player = handler->GetSession()->GetPlayer();
67
68 if (mapId == MAPID_INVALID)
69 mapId = player->GetMapId();
70
71 if (sObjectMgr->IsTransportMap(mapId))
72 return DoTeleportToTransport(handler, pos, mapId);
73
74 if (!MapMgr::IsValidMapCoord(mapId, pos))
75 {
77 return false;
78 }
79
80 // stop flight if need
81 if (player->IsInFlight())
82 {
84 player->CleanupAfterTaxiFlight();
85 }
86 // save only in non-flight case
87 else
88 player->SaveRecallPosition();
89
90 player->TeleportTo({ mapId, pos });
91 return true;
92 }
@ LANG_INVALID_TARGET_COORD
Definition Language.h:313
#define sObjectMgr
Definition ObjectMgr.h:1686
#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:205
Definition Player.h:1066
void SaveRecallPosition()
Definition Player.cpp:5653
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:10407
MotionMaster * GetMotionMaster()
Definition Unit.h:1738
bool IsInFlight() const
Definition Unit.h:1685
uint32 GetMapId() const
Definition Position.h:281
Player * GetPlayer() const
Definition WorldSession.h:435
static bool DoTeleportToTransport(ChatHandler *handler, Position pos, uint32 transportMapId)
Definition cs_go.cpp:94
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
95 {
96 Player* player = handler->GetSession()->GetPlayer();
97
98 uint32 transportEntry = 0;
99 for (auto const& [entry, goTemplate] : *sObjectMgr->GetGameObjectTemplates())
100 {
101 if (goTemplate.type == GAMEOBJECT_TYPE_MO_TRANSPORT && goTemplate.moTransport.mapID == transportMapId)
102 {
103 transportEntry = entry;
104 break;
105 }
106 }
107
108 if (!transportEntry)
109 {
110 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), transportMapId);
111 return false;
112 }
113
114 MotionTransport* transport = nullptr;
115 sMapMgr->DoForAllMaps([&](Map* map)
116 {
117 if (transport)
118 return;
119
120 for (Transport* t : map->GetAllTransports())
121 {
122 if (MotionTransport* mt = t->ToMotionTransport())
123 {
124 if (mt->GetEntry() == transportEntry)
125 {
126 transport = mt;
127 return;
128 }
129 }
130 }
131 });
132
133 if (!transport)
134 {
135 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, pos.GetPositionX(), pos.GetPositionY(), transportMapId);
136 return false;
137 }
138
139 if (player->IsInFlight())
140 {
141 player->GetMotionMaster()->MovementExpired();
142 player->CleanupAfterTaxiFlight();
143 }
144 else
145 player->SaveRecallPosition();
146
147 if (Transport* oldTransport = player->GetTransport())
148 oldTransport->RemovePassenger(player, true);
149
150 float const localX = pos.GetPositionX();
151 float const localY = pos.GetPositionY();
152 float const localZ = pos.GetPositionZ();
153 float const localO = pos.GetOrientation();
154
155 player->SetTransport(transport);
156 player->m_movementInfo.transport.guid = transport->GetGUID();
157 player->m_movementInfo.transport.pos.Relocate(localX, localY, localZ, localO);
159
160 float worldX = localX;
161 float worldY = localY;
162 float worldZ = localZ;
163 float worldO = localO;
164 transport->CalculatePassengerPosition(worldX, worldY, worldZ, &worldO);
165
166 transport->AddPassenger(player, false);
167
168 player->TeleportTo(transport->GetMapId(), worldX, worldY, worldZ, worldO, TELE_TO_NOT_LEAVE_TRANSPORT);
169 return true;
170 }
std::uint32_t uint32
Definition Define.h:107
#define sMapMgr
Definition MapMgr.h:220
@ TELE_TO_NOT_LEAVE_TRANSPORT
Definition Player.h:809
@ GAMEOBJECT_TYPE_MO_TRANSPORT
Definition SharedDefines.h:1586
@ MOVEMENTFLAG_ONTRANSPORT
Definition UnitDefines.h:378
MotionTransport * ToMotionTransport()
Definition GameObject.h:326
Definition Map.h:163
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:113
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:762
void SetTransport(Transport *t)
Definition Object.h:690
Transport * GetTransport() const
Definition Object.h:682
MovementInfo m_movementInfo
Definition Object.h:692
ObjectGuid guid
Definition Object.h:307
Position pos
Definition Object.h:308
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.

39 {
40 static ChatCommandTable goCommandTable =
41 {
42 { "creature", HandleGoCreatureSpawnIdCommand, SEC_MODERATOR, Console::No },
43 { "creature id", HandleGoCreatureCIdCommand, SEC_MODERATOR, Console::No },
44 { "creature name", HandleGoCreatureNameCommand, SEC_MODERATOR, Console::No },
45 { "gameobject", HandleGoGameObjectSpawnIdCommand, SEC_MODERATOR, Console::No },
46 { "gameobject id", HandleGoGameObjectGOIdCommand, SEC_MODERATOR, Console::No },
47 { "graveyard", HandleGoGraveyardCommand, SEC_MODERATOR, Console::No },
48 { "grid", HandleGoGridCommand, SEC_MODERATOR, Console::No },
49 { "taxinode", HandleGoTaxinodeCommand, SEC_MODERATOR, Console::No },
50 { "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
51 { "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
52 { "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
53 { "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
54 { "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
55 };
56
57 static ChatCommandTable commandTable =
58 {
59 { "go", goCommandTable }
60 };
61 return commandTable;
62 }
@ 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:255
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition cs_go.cpp:287
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition cs_go.cpp:519
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition cs_go.cpp:350
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition cs_go.cpp:318
static bool HandleGoCreatureNameCommand(ChatHandler *handler, Tail name)
Definition cs_go.cpp:216
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition cs_go.cpp:361
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:431
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId, Optional< uint32 > _pos)
Definition cs_go.cpp:172
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition cs_go.cpp:494
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition cs_go.cpp:204
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition cs_go.cpp:373
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition cs_go.cpp:243
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
607 {
608 CreatureData const* spawnpoint = nullptr;
609 for (auto const& pair : sObjectMgr->GetAllCreatureData())
610 {
611 if (pair.second.id1 != entry)
612 {
613 continue;
614 }
615
616 if (!spawnpoint)
617 {
618 spawnpoint = &pair.second;
619 }
620 else
621 {
623 break;
624 }
625 }
626
627 return spawnpoint;
628 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition Language.h:319
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:160
Definition CreatureData.h:366

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
631 {
632 std::vector<CreatureData const*> spawnpoints;
633 for (auto const& pair : sObjectMgr->GetAllCreatureData())
634 {
635 if (pair.second.id1 != entry)
636 {
637 continue;
638 }
639
640 spawnpoints.emplace_back(&pair.second);
641 }
642
643 return spawnpoints;
644 }

References sObjectMgr.

Referenced by HandleGoCreatureCIdCommand().

◆ GetGameObjectData()

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

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

Referenced by HandleGoQuestCommand().

◆ GetGameObjectDataList()

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

References sObjectMgr.

Referenced by HandleGoGameObjectGOIdCommand().

◆ HandleGoCreatureCIdCommand()

static bool go_commandscript::HandleGoCreatureCIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 cId,
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<CreatureData const*> spawnpoints = GetCreatureDataList(*cId);
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 CreatureData const* spawnpoint = spawnpoints[--pos];
200
201 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
202 }
@ 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:64
static std::vector< CreatureData const * > GetCreatureDataList(uint32 entry)
Definition cs_go.cpp:630
float posY
Definition CreatureData.h:376
float posX
Definition CreatureData.h:375
uint16 mapid
Definition CreatureData.h:371
float posZ
Definition CreatureData.h:377

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

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

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
256 {
257 uint32 pos = 1;
258 if (_pos)
259 {
260 pos = *_pos;
261 if (pos < 1)
262 {
264 return false;
265 }
266 }
267
268 std::vector<GameObjectData const*> spawnpoints = GetGameObjectDataList(goId);
269
270 if (spawnpoints.empty())
271 {
273 return false;
274 }
275
276 if (spawnpoints.size() < pos)
277 {
278 handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
279 return false;
280 }
281
282 GameObjectData const* spawnpoint = spawnpoints[--pos];
283
284 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
285 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition Language.h:317
static std::vector< GameObjectData const * > GetGameObjectDataList(uint32 entry)
Definition cs_go.cpp:670
float posZ
Definition GameObjectData.h:719
uint16 mapid
Definition GameObjectData.h:715
float posX
Definition GameObjectData.h:717
float posY
Definition GameObjectData.h:718

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
244 {
245 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
246 if (!spawnpoint)
247 {
249 return false;
250 }
251
252 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
253 }

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
288 {
289 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
290 if (!gy)
291 {
293 return false;
294 }
295
296 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
297 {
298 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
299 return false;
300 }
301
302 Player* player = handler->GetSession()->GetPlayer();
303 // stop flight if need
304 if (player->IsInFlight())
305 {
306 player->GetMotionMaster()->MovementExpired();
307 player->CleanupAfterTaxiFlight();
308 }
309 // save only in non-flight case
310 else
311 player->SaveRecallPosition();
312
313 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
314 return true;
315 }
#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

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
319 {
320 Player* player = handler->GetSession()->GetPlayer();
321 uint32 mapId = oMapId.value_or(player->GetMapId());
322
323 // center of grid
324 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
325 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
326
327 if (!MapMgr::IsValidMapCoord(mapId, x, y))
328 {
329 handler->SendErrorMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
330 return false;
331 }
332
333 // stop flight if need
334 if (player->IsInFlight())
335 {
336 player->GetMotionMaster()->MovementExpired();
337 player->CleanupAfterTaxiFlight();
338 }
339 // save only in non-flight case
340 else
341 player->SaveRecallPosition();
342
343 Map const* map = sMapMgr->CreateBaseMap(mapId);
344 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
345
346 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
347 return true;
348 }
#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: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
520 {
521 uint32 entry = quest->GetQuestId();
522
523 if (type == "starter")
524 {
525 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
526
527 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
528 {
529 if (itr->second == entry)
530 {
531 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
532 if (!spawnpoint)
533 {
535 return false;
536 }
537
538 // We've found a creature, teleport to it.
539 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
540 }
541 }
542
543 qr = sObjectMgr->GetGOQuestRelationMap();
544
545 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
546 {
547 if (itr->second == entry)
548 {
549 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
550 if (!spawnpoint)
551 {
553 return false;
554 }
555
556 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
557 }
558 }
559 }
560 else if (type == "ender")
561 {
562 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
563
564 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
565 {
566 if (itr->second == entry)
567 {
568 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
569 if (!spawnpoint)
570 {
572 return false;
573 }
574
575 // We've found a creature, teleport to it.
576 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
577 }
578 }
579
580 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
581
582 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
583 {
584 if (itr->second == entry)
585 {
586 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
587 if (!spawnpoint)
588 {
590 return false;
591 }
592
593 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
594 }
595 }
596 }
597 else
598 {
600 return false;
601 }
602
603 return false;
604 }
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition Language.h:1151
std::multimap< uint32, uint32 > QuestRelations
Definition ObjectMgr.h:525
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition cs_go.cpp:646

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