2010-11-09 10:15:35 -05:00
|
|
|
/*
|
2016-01-01 00:34:25 +01:00
|
|
|
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
2010-11-09 10:15:35 -05:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* ScriptData
|
|
|
|
|
Name: achievement_commandscript
|
|
|
|
|
%Complete: 100
|
|
|
|
|
Comment: All achievement related commands
|
|
|
|
|
Category: commandscripts
|
|
|
|
|
EndScriptData */
|
|
|
|
|
|
2012-11-27 13:02:04 +01:00
|
|
|
#include "AchievementMgr.h"
|
2010-11-09 10:15:35 -05:00
|
|
|
#include "Chat.h"
|
2012-11-20 12:30:30 +01:00
|
|
|
#include "Language.h"
|
2012-11-17 05:18:37 +01:00
|
|
|
#include "Player.h"
|
2012-11-20 12:30:30 +01:00
|
|
|
#include "ScriptMgr.h"
|
2010-11-09 10:15:35 -05:00
|
|
|
|
|
|
|
|
class achievement_commandscript : public CommandScript
|
|
|
|
|
{
|
2010-11-19 14:04:21 +01:00
|
|
|
public:
|
|
|
|
|
achievement_commandscript() : CommandScript("achievement_commandscript") { }
|
2010-11-09 10:15:35 -05:00
|
|
|
|
2015-10-22 20:26:56 +02:00
|
|
|
std::vector<ChatCommand> GetCommands() const override
|
2010-11-19 14:04:21 +01:00
|
|
|
{
|
2015-10-22 20:26:56 +02:00
|
|
|
static std::vector<ChatCommand> achievementCommandTable =
|
2010-11-09 10:15:35 -05:00
|
|
|
{
|
2015-10-22 20:26:56 +02:00
|
|
|
{ "add", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT_ADD, false, &HandleAchievementAddCommand, "" },
|
2010-11-19 14:04:21 +01:00
|
|
|
};
|
2015-10-22 20:26:56 +02:00
|
|
|
static std::vector<ChatCommand> commandTable =
|
2010-11-09 10:15:35 -05:00
|
|
|
{
|
2013-09-27 12:46:01 +02:00
|
|
|
{ "achievement", rbac::RBAC_PERM_COMMAND_ACHIEVEMENT, false, NULL, "", achievementCommandTable },
|
2010-11-19 14:04:21 +01:00
|
|
|
};
|
|
|
|
|
return commandTable;
|
|
|
|
|
}
|
2010-11-09 10:15:35 -05:00
|
|
|
|
2011-10-10 10:33:13 -03:00
|
|
|
static bool HandleAchievementAddCommand(ChatHandler* handler, char const* args)
|
2010-11-19 14:04:21 +01:00
|
|
|
{
|
|
|
|
|
if (!*args)
|
|
|
|
|
return false;
|
2010-11-09 10:15:35 -05:00
|
|
|
|
2010-11-19 14:04:21 +01:00
|
|
|
uint32 achievementId = atoi((char*)args);
|
|
|
|
|
if (!achievementId)
|
|
|
|
|
{
|
2011-10-10 10:33:13 -03:00
|
|
|
if (char* id = handler->extractKeyFromLink((char*)args, "Hachievement"))
|
|
|
|
|
achievementId = atoi(id);
|
2010-11-19 14:04:21 +01:00
|
|
|
if (!achievementId)
|
2010-11-09 10:15:35 -05:00
|
|
|
return false;
|
2010-11-19 14:04:21 +01:00
|
|
|
}
|
2010-11-09 10:15:35 -05:00
|
|
|
|
2010-11-19 14:04:21 +01:00
|
|
|
Player* target = handler->getSelectedPlayer();
|
|
|
|
|
if (!target)
|
|
|
|
|
{
|
|
|
|
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
|
|
|
|
handler->SetSentErrorMessage(true);
|
|
|
|
|
return false;
|
2010-11-09 10:15:35 -05:00
|
|
|
}
|
2010-11-19 14:04:21 +01:00
|
|
|
|
2016-05-07 01:16:29 +02:00
|
|
|
if (AchievementEntry const* achievementEntry = sAchievementStore.LookupEntry(achievementId))
|
2011-10-10 10:33:13 -03:00
|
|
|
target->CompletedAchievement(achievementEntry);
|
2010-11-19 14:04:21 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2010-11-09 10:15:35 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void AddSC_achievement_commandscript()
|
|
|
|
|
{
|
|
|
|
|
new achievement_commandscript();
|
|
|
|
|
}
|