feat(Scripts/Commands): Implement go quest starter/ender command (#10442)
* feat(Scripts/Commands): Implement go quest starter/ender command * Update cs_go.cpp
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1643502379399332300');
|
||||||
|
|
||||||
|
DELETE FROM `command` WHERE `name` = 'go quest';
|
||||||
|
INSERT INTO `command` (`name`, `security`, `help`) VALUES
|
||||||
|
('go quest', 1, 'Syntax: .go quest <starter/ender> <quest>.\nTeleports you to the quest starter/ender creature or object.');
|
||||||
|
|
||||||
|
DELETE FROM `acore_string` WHERE `entry` = 5082;
|
||||||
|
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_deDE`) VALUES
|
||||||
|
(5082, 'Incorrect syntax. Specify either \'starter\' or \'ender\'.', 'Falsche syntax. Entweder \'starter\' oder \'ender\' angeben.');
|
||||||
@@ -1248,7 +1248,9 @@ enum AcoreStrings
|
|||||||
LANG_CMD_SETTINGS_ANNOUNCER_ON = 5080,
|
LANG_CMD_SETTINGS_ANNOUNCER_ON = 5080,
|
||||||
LANG_CMD_SETTINGS_ANNOUNCER_OFF = 5081,
|
LANG_CMD_SETTINGS_ANNOUNCER_OFF = 5081,
|
||||||
|
|
||||||
// Room for more strings 5082-9999
|
LANG_CMD_GOQUEST_INVALID_SYNTAX = 5082,
|
||||||
|
|
||||||
|
// Room for more strings 5083-9999
|
||||||
|
|
||||||
// Level requirement notifications
|
// Level requirement notifications
|
||||||
LANG_SAY_REQ = 6604,
|
LANG_SAY_REQ = 6604,
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public:
|
|||||||
{ "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
|
{ "trigger", HandleGoTriggerCommand, SEC_MODERATOR, Console::No },
|
||||||
{ "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
|
{ "zonexy", HandleGoZoneXYCommand, SEC_MODERATOR, Console::No },
|
||||||
{ "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
|
{ "xyz", HandleGoXYZCommand, SEC_MODERATOR, Console::No },
|
||||||
{ "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No }
|
{ "ticket", HandleGoTicketCommand, SEC_GAMEMASTER, Console::No },
|
||||||
|
{ "quest", HandleGoQuestCommand, SEC_MODERATOR, Console::No },
|
||||||
};
|
};
|
||||||
|
|
||||||
static ChatCommandTable commandTable =
|
static ChatCommandTable commandTable =
|
||||||
@@ -91,20 +92,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant<Hyperlink<creature_entry>, uint32> cId)
|
static bool HandleGoCreatureCIdCommand(ChatHandler* handler, Variant<Hyperlink<creature_entry>, uint32> cId)
|
||||||
{
|
{
|
||||||
CreatureData const* spawnpoint = nullptr;
|
CreatureData const* spawnpoint = GetCreatureData(handler, *cId);
|
||||||
for (auto const& pair : sObjectMgr->GetAllCreatureData())
|
|
||||||
{
|
|
||||||
if (pair.second.id1 != *cId)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!spawnpoint)
|
|
||||||
spawnpoint = &pair.second;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!spawnpoint)
|
if (!spawnpoint)
|
||||||
{
|
{
|
||||||
@@ -144,20 +132,7 @@ public:
|
|||||||
|
|
||||||
static bool HandleGoGameObjectGOIdCommand(ChatHandler* handler, uint32 goId)
|
static bool HandleGoGameObjectGOIdCommand(ChatHandler* handler, uint32 goId)
|
||||||
{
|
{
|
||||||
GameObjectData const* spawnpoint = nullptr;
|
GameObjectData const* spawnpoint = GetGameObjectData(handler, goId);
|
||||||
for (auto const& pair : sObjectMgr->GetAllGOData())
|
|
||||||
{
|
|
||||||
if (pair.second.id != goId)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!spawnpoint)
|
|
||||||
spawnpoint = &pair.second;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!spawnpoint)
|
if (!spawnpoint)
|
||||||
{
|
{
|
||||||
@@ -367,6 +342,146 @@ public:
|
|||||||
ticket->TeleportTo(player);
|
ticket->TeleportTo(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HandleGoQuestCommand(ChatHandler* handler, std::string_view type, Quest const* quest)
|
||||||
|
{
|
||||||
|
uint32 entry = quest->GetQuestId();
|
||||||
|
|
||||||
|
if (type == "starter")
|
||||||
|
{
|
||||||
|
QuestRelations* qr = sObjectMgr->GetCreatureQuestRelationMap();
|
||||||
|
|
||||||
|
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second == entry)
|
||||||
|
{
|
||||||
|
CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've found a creature, teleport to it.
|
||||||
|
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qr = sObjectMgr->GetGOQuestRelationMap();
|
||||||
|
|
||||||
|
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second == entry)
|
||||||
|
{
|
||||||
|
GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (type == "ender")
|
||||||
|
{
|
||||||
|
QuestRelations* qr = sObjectMgr->GetCreatureQuestInvolvedRelationMap();
|
||||||
|
|
||||||
|
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second == entry)
|
||||||
|
{
|
||||||
|
CreatureData const* spawnpoint = GetCreatureData(handler, itr->first);
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We've found a creature, teleport to it.
|
||||||
|
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
qr = sObjectMgr->GetGOQuestInvolvedRelationMap();
|
||||||
|
|
||||||
|
for (auto itr = qr->begin(); itr != qr->end(); ++itr)
|
||||||
|
{
|
||||||
|
if (itr->second == entry)
|
||||||
|
{
|
||||||
|
GameObjectData const* spawnpoint = GetGameObjectData(handler, itr->first);
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOOBJNOTFOUND);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DoTeleport(handler, { spawnpoint->posX, spawnpoint->posY, spawnpoint->posZ }, spawnpoint->mapid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_CMD_GOQUEST_INVALID_SYNTAX);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CreatureData const* GetCreatureData(ChatHandler* handler, uint32 entry)
|
||||||
|
{
|
||||||
|
CreatureData const* spawnpoint = nullptr;
|
||||||
|
for (auto const& pair : sObjectMgr->GetAllCreatureData())
|
||||||
|
{
|
||||||
|
if (pair.second.id1 != entry)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
spawnpoint = &pair.second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spawnpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GameObjectData const* GetGameObjectData(ChatHandler* handler, uint32 entry)
|
||||||
|
{
|
||||||
|
GameObjectData const* spawnpoint = nullptr;
|
||||||
|
for (auto const& pair : sObjectMgr->GetAllGOData())
|
||||||
|
{
|
||||||
|
if (pair.second.id != entry)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!spawnpoint)
|
||||||
|
{
|
||||||
|
spawnpoint = &pair.second;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return spawnpoint;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddSC_go_commandscript()
|
void AddSC_go_commandscript()
|
||||||
|
|||||||
Reference in New Issue
Block a user