Scripts/Commands: Added .quest reward command - this will reward player's quest, similar to finishing it at quest ender, requires quest to be completed, rewards all items and first choice item (if quest has choice rewards)

This commit is contained in:
Shauren committed 2012-08-21 17:45:10 +02:00
1 parent d22c82332b
commit 7ccd254fdc
2 files changed
+36

No files matched your search

@@ -0,0 +1,3 @@
DELETE FROM `command` WHERE name='quest reward';
INSERT INTO `command` (`name`,`security`,`help`) VALUES
('quest reward',3,'Syntax: .quest reward #questId\n\n\Grants quest reward to selected player and removes quest from his log (quest must be in completed state).');
+33
View File
@@ -38,6 +38,7 @@ public:
{ "add", SEC_ADMINISTRATOR, false, &HandleQuestAdd, "", NULL },
{ "complete", SEC_ADMINISTRATOR, false, &HandleQuestComplete, "", NULL },
{ "remove", SEC_ADMINISTRATOR, false, &HandleQuestRemove, "", NULL },
{ "reward", SEC_ADMINISTRATOR, false, &HandleQuestReward, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
@@ -244,6 +245,38 @@ public:
player->CompleteQuest(entry);
return true;
}
static bool HandleQuestReward(ChatHandler* handler, char const* args)
{
Player* player = handler->getSelectedPlayer();
if (!player)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
// .quest reward #entry
// number or [name] Shift-click form |color|Hquest:quest_id:quest_level|h[name]|h|r
char* cId = handler->extractKeyFromLink((char*)args, "Hquest");
if (!cId)
return false;
uint32 entry = atol(cId);
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
// If player doesn't have the quest
if (!quest || player->GetQuestStatus(entry) != QUEST_STATUS_COMPLETE)
{
handler->PSendSysMessage(LANG_COMMAND_QUEST_NOTFOUND, entry);
handler->SetSentErrorMessage(true);
return false;
}
player->RewardQuest(quest, 0, player);
return true;
}
};
void AddSC_quest_commandscript()