/* * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information * * 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 . */ /* ScriptData Name: honor_commandscript %Complete: 100 Comment: All honor related commands Category: commandscripts EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" #include "ChatCommand.h" #include "Language.h" #include "Player.h" #include "RBAC.h" #include "WorldSession.h" using namespace Trinity::ChatCommands; class honor_commandscript : public CommandScript { public: honor_commandscript() : CommandScript("honor_commandscript") { } ChatCommandTable GetCommands() const override { static ChatCommandTable honorAddCommandTable = { { "kill", HandleHonorAddKillCommand, rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL, Console::No }, { "", HandleHonorAddCommand, rbac::RBAC_PERM_COMMAND_HONOR_ADD, Console::No }, }; static ChatCommandTable honorCommandTable = { { "add", honorAddCommandTable }, { "update", HandleHonorUpdateCommand, rbac::RBAC_PERM_COMMAND_HONOR_UPDATE, Console::No }, }; static ChatCommandTable commandTable = { { "honor", honorCommandTable }, }; return commandTable; } static bool HandleHonorAddCommand(ChatHandler* handler, int32 amount) { Player* target = handler->getSelectedPlayer(); if (!target) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); return false; } // check online security if (handler->HasLowerSecurity(target, ObjectGuid::Empty)) return false; target->RewardHonor(nullptr, 1, amount, HonorGainSource::Spell); return true; } static bool HandleHonorAddKillCommand(ChatHandler* handler) { Unit* target = handler->getSelectedUnit(); if (!target) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); return false; } // check online security if (Player* player = target->ToPlayer()) if (handler->HasLowerSecurity(player, ObjectGuid::Empty)) return false; handler->GetSession()->GetPlayer()->RewardHonor(target, 1, -1, HonorGainSource::Kill); return true; } static bool HandleHonorUpdateCommand(ChatHandler* handler) { Player* target = handler->getSelectedPlayer(); if (!target) { handler->SendSysMessage(LANG_PLAYER_NOT_FOUND); handler->SetSentErrorMessage(true); return false; } // check online security if (handler->HasLowerSecurity(target, ObjectGuid::Empty)) return false; target->UpdateHonorFields(); return true; } }; void AddSC_honor_commandscript() { new honor_commandscript(); }