fix(Scripts/Commands): Implement quest status command (#23721)

This commit is contained in:
Andrew
2025-11-17 18:48:23 -03:00
committed by GitHub
parent c0b768ace6
commit fa9574a8e2
3 changed files with 61 additions and 1 deletions

View File

@@ -0,0 +1,9 @@
--
DELETE FROM `acore_string` WHERE `entry` IN (5088, 5089);
INSERT INTO `acore_string` (`entry`, `content_default`) VALUES
(5088, 'Quest: {} ({}) \nStatus: {}'),
(5089, 'Quest can\'t be taken!');
DELETE FROM `command` WHERE `name` = 'quest status';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('quest status', 2, 'Syntax: .quest status $id [$name]. Displays the selected player\'s status for the specified quest.');

View File

@@ -1157,7 +1157,10 @@ enum AcoreStrings
LANG_CMD_NO_DOOR_FOUND = 5086,
LANG_CMD_DOOR_OPENED = 5087,
// Room for more strings 5088-9999
LANG_CMD_QUEST_STATUS = 5088,
LANG_CMD_QUEST_UNAVAILABLE = 5089,
// Room for more strings 5090-9999
// Level requirement notifications
LANG_SAY_REQ = 6604,

View File

@@ -37,6 +37,7 @@ public:
{ "complete", HandleQuestComplete, SEC_GAMEMASTER, Console::Yes },
{ "remove", HandleQuestRemove, SEC_GAMEMASTER, Console::Yes },
{ "reward", HandleQuestReward, SEC_GAMEMASTER, Console::Yes },
{ "status", HandleQuestStatus, SEC_GAMEMASTER, Console::Yes },
};
static ChatCommandTable commandTable =
{
@@ -724,6 +725,53 @@ public:
handler->SetSentErrorMessage(false);
return true;
}
static bool HandleQuestStatus(ChatHandler* handler, Quest const* quest, Optional<PlayerIdentifier> playerTarget)
{
if (!playerTarget)
playerTarget = PlayerIdentifier::FromTargetOrSelf(handler);
if (!playerTarget)
{
handler->SendErrorMessage(LANG_PLAYER_NOT_FOUND);
return false;
}
uint32 entry = quest->GetQuestId();
std::string status;
if (Player* player = playerTarget->GetConnectedPlayer())
{
QuestStatus qs = player->GetQuestStatus(entry);
switch (qs)
{
case QUEST_STATUS_NONE:
status = "Not Taken";
break;
case QUEST_STATUS_COMPLETE:
status = "Complete";
break;
case QUEST_STATUS_INCOMPLETE:
status = "Incomplete";
break;
case QUEST_STATUS_FAILED:
status = "Failed";
break;
case QUEST_STATUS_REWARDED:
status = "Rewarded";
break;
default:
status = "Unknown";
break;
}
handler->PSendSysMessage(LANG_CMD_QUEST_STATUS, quest->GetTitle(), entry, status);
if (!player->CanTakeQuest(quest, true))
handler->PSendSysMessage(LANG_CMD_QUEST_UNAVAILABLE, entry, status);
}
return true;
}
};
void AddSC_quest_commandscript()