diff --git a/data/sql/updates/pending_db_world/rev_1750935609519453293.sql b/data/sql/updates/pending_db_world/rev_1750935609519453293.sql new file mode 100644 index 000000000..b9e47eb5a --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1750935609519453293.sql @@ -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.'); diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 7de625355..b99ed999b 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -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, diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index e195fdfc5..0e6bca422 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -86,16 +86,35 @@ public: return true; } - static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant, uint32> cId) + static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant, uint32> cId, Optional _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 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 _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 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 GetCreatureDataList(uint32 entry) + { + std::vector 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 GetGameObjectDataList(uint32 entry) + { + std::vector spawnpoints; + for (auto const& pair : sObjectMgr->GetAllGOData()) + { + if (pair.second.id != entry) + { + continue; + } + + spawnpoints.emplace_back(&pair.second); + } + + return spawnpoints; + } }; void AddSC_go_commandscript()