mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2025-11-29 17:38:24 +08:00
feature(Scripts/Commands) choose Xth spawn of entry for go creature/gameobject id (#22363)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
--
|
||||
DELETE FROM `acore_string` WHERE `entry` = 288;
|
||||
INSERT INTO `acore_string` (`entry`,`content_default`) VALUES (288,'Cannot go to spawn {} as only {} exist');
|
||||
|
||||
UPDATE `command` SET `help`='Syntax: .go creature id #creature_entry [#spawn] Teleports you to first (if no #spawn provided) spawn the given creature entry. ' WHERE `name` = 'go creature id';
|
||||
|
||||
DELETE FROM `command` WHERE `name` = 'go gameobject id';
|
||||
INSERT INTO `command` VALUES('go gameobject id',1,'Syntax: .go gameobject id #gameobject_entry [#spawn] Teleports you to first (if no #spawn provided) spawn the given gameobject entry.');
|
||||
@@ -331,7 +331,8 @@ enum AcoreStrings
|
||||
LANG_COMMAND_WHISPERON = 285,
|
||||
LANG_COMMAND_WHISPEROFF = 286,
|
||||
LANG_COMMAND_CREATGUIDNOTFOUND = 287,
|
||||
// TICKET STRINGS NEED REWRITE // 288-296 FREE
|
||||
LANG_COMMAND_GONOTENOUGHSPAWNS = 288,
|
||||
// TICKET STRINGS NEED REWRITE // 289-296 FREE
|
||||
|
||||
// END
|
||||
LANG_COMMAND_WANDER_DISTANCE = 297,
|
||||
|
||||
@@ -86,16 +86,35 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant<Hyperlink<creature_entry>, uint32> cId)
|
||||
static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant<Hyperlink<creature_entry>, uint32> cId, Optional<uint32> _pos)
|
||||
{
|
||||
CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
|
||||
uint32 pos = 1;
|
||||
if (_pos)
|
||||
{
|
||||
pos = *_pos;
|
||||
if (pos < 1)
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_FACTION_INVPARAM, pos);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!spawnpoint)
|
||||
std::vector<CreatureData const*> spawnpoints = GetCreatureDataList(*cId);
|
||||
|
||||
if (spawnpoints.empty())
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnpoints.size() < pos)
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
CreatureData const* spawnpoint = spawnpoints[--pos];
|
||||
|
||||
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||
}
|
||||
|
||||
@@ -153,16 +172,35 @@ public:
|
||||
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||
}
|
||||
|
||||
static bool HandleGoGameObjectGOIdCommand(ChatHandler* handler, uint32 goId)
|
||||
static bool HandleGoGameObjectGOIdCommand(ChatHandler* handler, uint32 goId, Optional<uint32> _pos)
|
||||
{
|
||||
GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
|
||||
uint32 pos = 1;
|
||||
if (_pos)
|
||||
{
|
||||
pos = *_pos;
|
||||
if (pos < 1)
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_FACTION_INVPARAM, pos);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!spawnpoint)
|
||||
std::vector<GameObjectData const*> spawnpoints = GetGameObjectDataList(goId);
|
||||
|
||||
if (spawnpoints.empty())
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (spawnpoints.size() < pos)
|
||||
{
|
||||
handler->SendErrorMessage(LANG_COMMAND_GONOTENOUGHSPAWNS, pos, spawnpoints.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
GameObjectData const* spawnpoint = spawnpoints[--pos];
|
||||
|
||||
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||
}
|
||||
|
||||
@@ -509,6 +547,22 @@ public:
|
||||
return spawnpoint;
|
||||
}
|
||||
|
||||
static std::vector<CreatureData const*> GetCreatureDataList(uint32 entry)
|
||||
{
|
||||
std::vector<CreatureData const*> spawnpoints;
|
||||
for (auto const& pair : sObjectMgr->GetAllCreatureData())
|
||||
{
|
||||
if (pair.second.id1 != entry)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
spawnpoints.emplace_back(&pair.second);
|
||||
}
|
||||
|
||||
return spawnpoints;
|
||||
}
|
||||
|
||||
static GameObjectData const* GetGameObjectData(ChatHandler* handler, uint32 entry)
|
||||
{
|
||||
GameObjectData const* spawnpoint = nullptr;
|
||||
@@ -532,6 +586,22 @@ public:
|
||||
|
||||
return spawnpoint;
|
||||
}
|
||||
|
||||
static std::vector<GameObjectData const*> GetGameObjectDataList(uint32 entry)
|
||||
{
|
||||
std::vector<GameObjectData const*> spawnpoints;
|
||||
for (auto const& pair : sObjectMgr->GetAllGOData())
|
||||
{
|
||||
if (pair.second.id != entry)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
spawnpoints.emplace_back(&pair.second);
|
||||
}
|
||||
|
||||
return spawnpoints;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_go_commandscript()
|
||||
|
||||
Reference in New Issue
Block a user