AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
go_commandscript Class Reference
Inheritance diagram for go_commandscript:
CommandScript ScriptObject

Public Member Functions

 go_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 

Static Public Member Functions

static bool DoTeleport (ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
 
static bool HandleGoCreatureCIdCommand (ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId)
 
static bool HandleGoCreatureSpawnIdCommand (ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
 
static bool HandleGoGameObjectSpawnIdCommand (ChatHandler *handler, uint32 spawnId)
 
static bool HandleGoGameObjectGOIdCommand (ChatHandler *handler, uint32 goId)
 
static bool HandleGoGraveyardCommand (ChatHandler *handler, uint32 gyId)
 
static bool HandleGoGridCommand (ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
 
static bool HandleGoTaxinodeCommand (ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
 
static bool HandleGoTriggerCommand (ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
 
static bool HandleGoZoneXYCommand (ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
 
static bool HandleGoXYZCommand (ChatHandler *handler, float x, float y, Optional< float > z, Optional< uint32 > id, Optional< float > o)
 
static bool HandleGoTicketCommand (ChatHandler *handler, uint32 ticketId)
 
static bool HandleGoQuestCommand (ChatHandler *handler, std::string_view type, Quest const *quest)
 
static CreatureData const * GetCreatureData (ChatHandler *handler, uint32 entry)
 
static GameObjectData const * GetGameObjectData (ChatHandler *handler, uint32 entry)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ go_commandscript()

go_commandscript::go_commandscript ( )
inline
39: CommandScript("go_commandscript") { }
Definition: ScriptMgr.h:850

Member Function Documentation

◆ DoTeleport()

static bool go_commandscript::DoTeleport ( ChatHandler handler,
Position  pos,
uint32  mapId = MAPID_INVALID 
)
inlinestatic
67 {
68 Player* player = handler->GetSession()->GetPlayer();
69
70 if (mapId == MAPID_INVALID)
71 mapId = player->GetMapId();
72 if (!MapMgr::IsValidMapCoord(mapId, pos) || sObjectMgr->IsTransportMap(mapId))
73 {
75 handler->SetSentErrorMessage(true);
76 return false;
77 }
78
79 // stop flight if need
80 if (player->IsInFlight())
81 {
83 player->CleanupAfterTaxiFlight();
84 }
85 // save only in non-flight case
86 else
87 player->SaveRecallPosition();
88
89 player->TeleportTo({ mapId, pos });
90 return true;
91 }
#define MAPID_INVALID
Definition: Position.h:248
#define sObjectMgr
Definition: ObjectMgr.h:1640
@ LANG_INVALID_TARGET_COORD
Definition: Language.h:308
WorldSession * GetSession()
Definition: Chat.h:122
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
void PSendSysMessage(char const *fmt, Args &&... args)
Definition: Chat.h:60
float GetPositionX() const
Definition: Position.h:117
float GetPositionY() const
Definition: Position.h:118
uint32 GetMapId() const
Definition: Position.h:276
Definition: Player.h:1046
void SaveRecallPosition()
Definition: Player.cpp:5564
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1311
void CleanupAfterTaxiFlight()
Definition: Player.cpp:10325
MotionMaster * GetMotionMaster()
Definition: Unit.h:2262
bool IsInFlight() const
Definition: Unit.h:1676
static bool IsValidMapCoord(uint32 mapid, Position const &pos)
Definition: MapMgr.h:91
void MovementExpired(bool reset=true)
Definition: MotionMaster.h:178
Player * GetPlayer() const
Definition: WorldSession.h:361

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(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SetSentErrorMessage(), sObjectMgr, and Player::TeleportTo().

Referenced by HandleGoCreatureCIdCommand(), HandleGoCreatureSpawnIdCommand(), HandleGoGameObjectGOIdCommand(), HandleGoGameObjectSpawnIdCommand(), HandleGoQuestCommand(), HandleGoTaxinodeCommand(), HandleGoTriggerCommand(), and HandleGoXYZCommand().

◆ GetCommands()

ChatCommandTable go_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable goCommandTable =
44 {
45 { "creature", HandleGoCreatureSpawnIdCommand, SEC_MODERATOR, Console::No },
46 { "creature id", HandleGoCreatureCIdCommand, SEC_MODERATOR, Console::No },
47 { "gameobject", HandleGoGameObjectSpawnIdCommand, SEC_MODERATOR, Console::No },
48 { "gameobject id", HandleGoGameObjectGOIdCommand, SEC_MODERATOR, Console::No },
49 { "graveyard", HandleGoGraveyardCommand, SEC_MODERATOR, Console::No },
50 { "grid", HandleGoGridCommand, SEC_MODERATOR, Console::No },
51 { "taxinode", HandleGoTaxinodeCommand, SEC_MODERATOR, Console::No },
52 { "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
53 { "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
54 { "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
55 { "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
56 { "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
57 };
58
59 static ChatCommandTable commandTable =
60 {
61 { "go", goCommandTable }
62 };
63 return commandTable;
64 }
@ SEC_GAMEMASTER
Definition: Common.h:68
@ SEC_MODERATOR
Definition: Common.h:67
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleGoGameObjectGOIdCommand(ChatHandler *handler, uint32 goId)
Definition: cs_go.cpp:133
static bool HandleGoGraveyardCommand(ChatHandler *handler, uint32 gyId)
Definition: cs_go.cpp:147
static bool HandleGoQuestCommand(ChatHandler *handler, std::string_view type, Quest const *quest)
Definition: cs_go.cpp:346
static bool HandleGoTaxinodeCommand(ChatHandler *handler, Variant< Hyperlink< taxinode >, uint32 > nodeId)
Definition: cs_go.cpp:213
static bool HandleGoGridCommand(ChatHandler *handler, float gridX, float gridY, Optional< uint32 > oMapId)
Definition: cs_go.cpp:180
static bool HandleGoTriggerCommand(ChatHandler *handler, Variant< Hyperlink< areatrigger >, uint32 > areaTriggerId)
Definition: cs_go.cpp:225
static bool HandleGoTicketCommand(ChatHandler *handler, uint32 ticketId)
Definition: cs_go.cpp:321
static bool HandleGoCreatureSpawnIdCommand(ChatHandler *handler, Variant< Hyperlink< creature >, ObjectGuid::LowType > spawnId)
Definition: cs_go.cpp:107
static bool HandleGoZoneXYCommand(ChatHandler *handler, float x, float y, Optional< Variant< Hyperlink< area >, uint32 > > areaIdArg)
Definition: cs_go.cpp:238
static bool HandleGoGameObjectSpawnIdCommand(ChatHandler *handler, uint32 spawnId)
Definition: cs_go.cpp:120
static bool HandleGoXYZCommand(ChatHandler *handler, float x, float y, Optional< float > z, Optional< uint32 > id, Optional< float > o)
Definition: cs_go.cpp:292
static bool HandleGoCreatureCIdCommand(ChatHandler *handler, Variant< Hyperlink< creature_entry >, uint32 > cId)
Definition: cs_go.cpp:93

References HandleGoCreatureCIdCommand(), 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
439 {
440 CreatureData const* spawnpoint = nullptr;
441 for (auto const& pair : sObjectMgr->GetAllCreatureData())
442 {
443 if (pair.second.id1 != entry)
444 {
445 continue;
446 }
447
448 if (!spawnpoint)
449 {
450 spawnpoint = &pair.second;
451 }
452 else
453 {
455 break;
456 }
457 }
458
459 return spawnpoint;
460 }
@ LANG_COMMAND_GOCREATMULTIPLE
Definition: Language.h:314
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
Definition: CreatureData.h:359

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

Referenced by HandleGoCreatureCIdCommand(), and HandleGoQuestCommand().

◆ GetGameObjectData()

static GameObjectData const * go_commandscript::GetGameObjectData ( ChatHandler handler,
uint32  entry 
)
inlinestatic
463 {
464 GameObjectData const* spawnpoint = nullptr;
465 for (auto const& pair : sObjectMgr->GetAllGOData())
466 {
467 if (pair.second.id != entry)
468 {
469 continue;
470 }
471
472 if (!spawnpoint)
473 {
474 spawnpoint = &pair.second;
475 }
476 else
477 {
479 break;
480 }
481 }
482
483 return spawnpoint;
484 }
Definition: GameObjectData.h:697

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

Referenced by HandleGoGameObjectGOIdCommand(), and HandleGoQuestCommand().

◆ HandleGoCreatureCIdCommand()

static bool go_commandscript::HandleGoCreatureCIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature_entry >, uint32 cId 
)
inlinestatic
94 {
95 CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
96
97 if (!spawnpoint)
98 {
100 handler->SetSentErrorMessage(true);
101 return false;
102 }
103
104 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
105 }
@ LANG_COMMAND_GOCREATNOTFOUND
Definition: Language.h:313
float posY
Definition: CreatureData.h:369
float posX
Definition: CreatureData.h:368
uint16 mapid
Definition: CreatureData.h:364
float posZ
Definition: CreatureData.h:370
static CreatureData const * GetCreatureData(ChatHandler *handler, uint32 entry)
Definition: cs_go.cpp:438
static bool DoTeleport(ChatHandler *handler, Position pos, uint32 mapId=MAPID_INVALID)
Definition: cs_go.cpp:66

References DoTeleport(), GetCreatureData(), LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureData::posX, CreatureData::posY, CreatureData::posZ, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleGoCreatureSpawnIdCommand()

static bool go_commandscript::HandleGoCreatureSpawnIdCommand ( ChatHandler handler,
Variant< Hyperlink< creature >, ObjectGuid::LowType spawnId 
)
inlinestatic
108 {
109 CreatureData const* spawnpoint = sObjectMgr->GetCreatureData(spawnId);
110 if (!spawnpoint)
111 {
113 handler->SetSentErrorMessage(true);
114 return false;
115 }
116
117 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
118 }

References DoTeleport(), LANG_COMMAND_GOCREATNOTFOUND, CreatureData::mapid, CreatureData::posX, CreatureData::posY, CreatureData::posZ, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoGameObjectGOIdCommand()

static bool go_commandscript::HandleGoGameObjectGOIdCommand ( ChatHandler handler,
uint32  goId 
)
inlinestatic
134 {
135 GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
136
137 if (!spawnpoint)
138 {
140 handler->SetSentErrorMessage(true);
141 return false;
142 }
143
144 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
145 }
@ LANG_COMMAND_GOOBJNOTFOUND
Definition: Language.h:312
float posZ
Definition: GameObjectData.h:704
uint16 mapid
Definition: GameObjectData.h:700
float posX
Definition: GameObjectData.h:702
float posY
Definition: GameObjectData.h:703
static GameObjectData const * GetGameObjectData(ChatHandler *handler, uint32 entry)
Definition: cs_go.cpp:462

References DoTeleport(), GetGameObjectData(), LANG_COMMAND_GOOBJNOTFOUND, GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, ChatHandler::SendSysMessage(), and ChatHandler::SetSentErrorMessage().

Referenced by GetCommands().

◆ HandleGoGameObjectSpawnIdCommand()

static bool go_commandscript::HandleGoGameObjectSpawnIdCommand ( ChatHandler handler,
uint32  spawnId 
)
inlinestatic
121 {
122 GameObjectData const* spawnpoint = sObjectMgr->GetGameObjectData(spawnId);
123 if (!spawnpoint)
124 {
126 handler->SetSentErrorMessage(true);
127 return false;
128 }
129
130 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
131 }

References DoTeleport(), LANG_COMMAND_GOOBJNOTFOUND, GameObjectData::mapid, GameObjectData::posX, GameObjectData::posY, GameObjectData::posZ, ChatHandler::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoGraveyardCommand()

static bool go_commandscript::HandleGoGraveyardCommand ( ChatHandler handler,
uint32  gyId 
)
inlinestatic
148 {
149 GraveyardStruct const* gy = sGraveyard->GetGraveyard(gyId);
150 if (!gy)
151 {
153 handler->SetSentErrorMessage(true);
154 return false;
155 }
156
157 if (!MapMgr::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
158 {
159 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
160 handler->SetSentErrorMessage(true);
161 return false;
162 }
163
164 Player* player = handler->GetSession()->GetPlayer();
165 // stop flight if need
166 if (player->IsInFlight())
167 {
168 player->GetMotionMaster()->MovementExpired();
169 player->CleanupAfterTaxiFlight();
170 }
171 // save only in non-flight case
172 else
173 player->SaveRecallPosition();
174
175 player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
176 return true;
177 }
#define sGraveyard
Definition: GameGraveyard.h:75
@ LANG_COMMAND_GRAVEYARDNOEXIST
Definition: Language.h:464
float GetOrientation() const
Definition: Position.h:120
Definition: GameGraveyard.h:28
float z
Definition: GameGraveyard.h:33
float x
Definition: GameGraveyard.h:31
float y
Definition: GameGraveyard.h:32
uint32 Map
Definition: GameGraveyard.h:30

References Player::CleanupAfterTaxiFlight(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_COMMAND_GRAVEYARDNOEXIST, LANG_INVALID_TARGET_COORD, GraveyardStruct::Map, MotionMaster::MovementExpired(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SetSentErrorMessage(), 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
181 {
182 Player* player = handler->GetSession()->GetPlayer();
183 uint32 mapId = oMapId.value_or(player->GetMapId());
184
185 // center of grid
186 float x = (gridX - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
187 float y = (gridY - CENTER_GRID_ID + 0.5f) * SIZE_OF_GRIDS;
188
189 if (!MapMgr::IsValidMapCoord(mapId, x, y))
190 {
191 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
192 handler->SetSentErrorMessage(true);
193 return false;
194 }
195
196 // stop flight if need
197 if (player->IsInFlight())
198 {
199 player->GetMotionMaster()->MovementExpired();
200 player->CleanupAfterTaxiFlight();
201 }
202 // save only in non-flight case
203 else
204 player->SaveRecallPosition();
205
206 Map const* map = sMapMgr->CreateBaseMap(mapId);
207 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
208
209 player->TeleportTo(mapId, x, y, z, player->GetOrientation());
210 return true;
211 }
#define SIZE_OF_GRIDS
Definition: MapDefines.h:13
std::uint32_t uint32
Definition: Define.h:108
#define CENTER_GRID_ID
Definition: GridDefines.h:37
#define MAX_HEIGHT
Definition: Map.h:163
#define sMapMgr
Definition: MapMgr.h:221
Definition: Map.h:312
float GetWaterLevel(float x, float y) const
Definition: Map.cpp:2433
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2043

References CENTER_GRID_ID, Player::CleanupAfterTaxiFlight(), Map::GetHeight(), WorldLocation::GetMapId(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Map::GetWaterLevel(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, MAX_HEIGHT, MotionMaster::MovementExpired(), ChatHandler::PSendSysMessage(), Player::SaveRecallPosition(), ChatHandler::SetSentErrorMessage(), 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
347 {
348 uint32 entry = quest->GetQuestId();
349
350 if (type == "starter")
351 {
352 QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
353
354 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
355 {
356 if (itr->second == entry)
357 {
358 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
359 if (!spawnpoint)
360 {
362 handler->SetSentErrorMessage(true);
363 return false;
364 }
365
366 // We've found a creature, teleport to it.
367 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
368 }
369 }
370
371 qr = sObjectMgr->GetGOQuestRelationMap();
372
373 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
374 {
375 if (itr->second == entry)
376 {
377 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
378 if (!spawnpoint)
379 {
381 handler->SetSentErrorMessage(true);
382 return false;
383 }
384
385 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
386 }
387 }
388 }
389 else if (type == "ender")
390 {
391 QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
392
393 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
394 {
395 if (itr->second == entry)
396 {
397 CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
398 if (!spawnpoint)
399 {
401 handler->SetSentErrorMessage(true);
402 return false;
403 }
404
405 // We've found a creature, teleport to it.
406 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
407 }
408 }
409
410 qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
411
412 for (auto itr = qr->begin(); itr != qr->end(); ++itr)
413 {
414 if (itr->second == entry)
415 {
416 GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
417 if (!spawnpoint)
418 {
420 handler->SetSentErrorMessage(true);
421 return false;
422 }
423
424 return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
425 }
426 }
427 }
428 else
429 {
431 handler->SetSentErrorMessage(true);
432 return false;
433 }
434
435 return false;
436 }
std::multimap< uint32, uint32 > QuestRelations
Definition: ObjectMgr.h:518
@ LANG_CMD_GOQUEST_INVALID_SYNTAX
Definition: Language.h:1147

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::SendSysMessage(), ChatHandler::SetSentErrorMessage(), and sObjectMgr.

Referenced by GetCommands().

◆ HandleGoTaxinodeCommand()

static bool go_commandscript::HandleGoTaxinodeCommand ( ChatHandler handler,
Variant< Hyperlink< taxinode >, uint32 nodeId 
)
inlinestatic
214 {
215 TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(nodeId);
216 if (!node)
217 {
219 handler->SetSentErrorMessage(true);
220 return false;
221 }
222 return DoTeleport(handler, { node->x, node->y, node->z }, node->map_id);
223 }
DBCStorage< TaxiNodesEntry > sTaxiNodesStore(TaxiNodesEntryfmt)
@ LANG_COMMAND_GOTAXINODENOTFOUND
Definition: Language.h:388
Definition: DBCStructure.h:1929
float z
Definition: DBCStructure.h:1934
uint32 map_id
Definition: DBCStructure.h:1931
float x
Definition: DBCStructure.h:1932
float y
Definition: DBCStructure.h:1933

References DoTeleport(), LANG_COMMAND_GOTAXINODENOTFOUND, TaxiNodesEntry::map_id, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), sTaxiNodesStore, TaxiNodesEntry::x, TaxiNodesEntry::y, and TaxiNodesEntry::z.

Referenced by GetCommands().

◆ HandleGoTicketCommand()

static bool go_commandscript::HandleGoTicketCommand ( ChatHandler handler,
uint32  ticketId 
)
inlinestatic
322 {
323 GmTicket* ticket = sTicketMgr->GetTicket(ticketId);
324 if (!ticket)
325 {
327 return true;
328 }
329
330 Player* player = handler->GetSession()->GetPlayer();
331
332 // stop flight if need
333 if (player->IsInFlight())
334 {
335 player->GetMotionMaster()->MovementExpired();
336 player->CleanupAfterTaxiFlight();
337 }
338 // save only in non-flight case
339 else
340 player->SaveRecallPosition();
341
342 ticket->TeleportTo(player);
343 return true;
344 }
@ LANG_COMMAND_TICKETNOTEXIST
Definition: Language.h:1025
#define sTicketMgr
Definition: TicketMgr.h:258
Definition: TicketMgr.h:88
void TeleportTo(Player *player) const
Definition: TicketMgr.cpp:237

References Player::CleanupAfterTaxiFlight(), Unit::GetMotionMaster(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::IsInFlight(), LANG_COMMAND_TICKETNOTEXIST, MotionMaster::MovementExpired(), Player::SaveRecallPosition(), ChatHandler::SendSysMessage(), sTicketMgr, and GmTicket::TeleportTo().

Referenced by GetCommands().

◆ HandleGoTriggerCommand()

static bool go_commandscript::HandleGoTriggerCommand ( ChatHandler handler,
Variant< Hyperlink< areatrigger >, uint32 areaTriggerId 
)
inlinestatic
226 {
227 AreaTrigger const* at = sObjectMgr->GetAreaTrigger(areaTriggerId);
228 if (!at)
229 {
230 handler->PSendSysMessage(LANG_COMMAND_GOAREATRNOTFOUND, uint32(areaTriggerId));
231 handler->SetSentErrorMessage(true);
232 return false;
233 }
234 return DoTeleport(handler, { at->x, at->y, at->z }, at->map);
235 }
@ LANG_COMMAND_GOAREATRNOTFOUND
Definition: Language.h:307
Definition: ObjectMgr.h:421
float x
Definition: ObjectMgr.h:424
float y
Definition: ObjectMgr.h:425
uint32 map
Definition: ObjectMgr.h:423
float z
Definition: ObjectMgr.h:426

References DoTeleport(), LANG_COMMAND_GOAREATRNOTFOUND, AreaTrigger::map, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), sObjectMgr, AreaTrigger::x, AreaTrigger::y, and AreaTrigger::z.

Referenced by GetCommands().

◆ HandleGoXYZCommand()

static bool go_commandscript::HandleGoXYZCommand ( ChatHandler handler,
float  x,
float  y,
Optional< float >  z,
Optional< uint32 id,
Optional< float >  o 
)
inlinestatic
293 {
294 Player* player = handler->GetSession()->GetPlayer();
295 uint32 mapId = id.value_or(player->GetMapId());
296
297 if (z)
298 {
299 if (!MapMgr::IsValidMapCoord(mapId, x, y, *z))
300 {
301 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
302 handler->SetSentErrorMessage(true);
303 return false;
304 }
305 }
306 else
307 {
308 if (!MapMgr::IsValidMapCoord(mapId, x, y))
309 {
310 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, mapId);
311 handler->SetSentErrorMessage(true);
312 return false;
313 }
314 Map const* map = sMapMgr->CreateBaseMap(mapId);
315 z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
316 }
317
318 return DoTeleport(handler, { x, y, *z, o.value_or(0.0f) }, mapId);
319 }

References DoTeleport(), Map::GetHeight(), WorldLocation::GetMapId(), WorldSession::GetPlayer(), ChatHandler::GetSession(), Map::GetWaterLevel(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, MAX_HEIGHT, ChatHandler::PSendSysMessage(), ChatHandler::SetSentErrorMessage(), and sMapMgr.

Referenced by GetCommands().

◆ HandleGoZoneXYCommand()

static bool go_commandscript::HandleGoZoneXYCommand ( ChatHandler handler,
float  x,
float  y,
Optional< Variant< Hyperlink< area >, uint32 > >  areaIdArg 
)
inlinestatic
239 {
240 Player* player = handler->GetSession()->GetPlayer();
241
242 uint32 areaId = areaIdArg ? *areaIdArg : player->GetZoneId();
243
244 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(areaId);
245
246 if (x < 0 || x > 100 || y < 0 || y > 100 || !areaEntry)
247 {
248 handler->PSendSysMessage(LANG_INVALID_ZONE_COORD, x, y, areaId);
249 handler->SetSentErrorMessage(true);
250 return false;
251 }
252
253 // update to parent zone if exist (client map show only zones without parents)
254 AreaTableEntry const* zoneEntry = areaEntry->zone ? sAreaTableStore.LookupEntry(areaEntry->zone) : areaEntry;
255 ASSERT(zoneEntry);
256
257 Map const* map = sMapMgr->CreateBaseMap(zoneEntry->mapid);
258
259 if (map->Instanceable())
260 {
261 handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaEntry->ID, areaEntry->area_name[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
262 handler->SetSentErrorMessage(true);
263 return false;
264 }
265
266 Zone2MapCoordinates(x, y, zoneEntry->ID);
267
268 if (!MapMgr::IsValidMapCoord(zoneEntry->mapid, x, y))
269 {
270 handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, x, y, zoneEntry->mapid);
271 handler->SetSentErrorMessage(true);
272 return false;
273 }
274
275 // stop flight if need
276 if (player->IsInFlight())
277 {
278 player->GetMotionMaster()->MovementExpired();
279 player->CleanupAfterTaxiFlight();
280 }
281 // save only in non-flight case
282 else
283 player->SaveRecallPosition();
284
285 float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
286
287 player->TeleportTo(zoneEntry->mapid, x, y, z, player->GetOrientation());
288 return true;
289 }
#define ASSERT
Definition: Errors.h:68
void Zone2MapCoordinates(float &x, float &y, uint32 zone)
Definition: DBCStores.cpp:728
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ LANG_INVALID_ZONE_MAP
Definition: Language.h:310
@ LANG_INVALID_ZONE_COORD
Definition: Language.h:309
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:782
uint32 GetZoneId() const
Definition: Object.cpp:3075
bool Instanceable() const
Definition: Map.h:446
uint32 GetId() const
Definition: Map.h:378
const char * GetMapName() const
Definition: Map.cpp:2519
Definition: DBCStructure.h:519
uint32 mapid
Definition: DBCStructure.h:521
uint32 zone
Definition: DBCStructure.h:522
char const * area_name[16]
Definition: DBCStructure.h:527
uint32 ID
Definition: DBCStructure.h:520

References AreaTableEntry::area_name, ASSERT, Player::CleanupAfterTaxiFlight(), Map::GetHeight(), Map::GetId(), Map::GetMapName(), Unit::GetMotionMaster(), Position::GetOrientation(), WorldSession::GetPlayer(), ChatHandler::GetSession(), ChatHandler::GetSessionDbcLocale(), Map::GetWaterLevel(), WorldObject::GetZoneId(), AreaTableEntry::ID, Map::Instanceable(), Unit::IsInFlight(), MapMgr::IsValidMapCoord(), LANG_INVALID_TARGET_COORD, LANG_INVALID_ZONE_COORD, LANG_INVALID_ZONE_MAP, AreaTableEntry::mapid, MAX_HEIGHT, MotionMaster::MovementExpired(), ChatHandler::PSendSysMessage(), sAreaTableStore, Player::SaveRecallPosition(), ChatHandler::SetSentErrorMessage(), sMapMgr, Player::TeleportTo(), AreaTableEntry::zone, and Zone2MapCoordinates().

Referenced by GetCommands().