Merge pull request #15731 from ShinDarth/toscri

Convert the Duel Cooldown Reset feature to scripts
(cherry picked from commit 5c449b50aa)
This commit is contained in:
blub
2015-10-18 18:46:28 +02:00
committed by Carbenium
parent 42cf4e7713
commit bf7175ee83
5 changed files with 60 additions and 19 deletions

View File

@@ -0,0 +1,57 @@
/*
* Copyright (C) 2008-2015 TrinityCore <http://www.trinitycore.org/>
*
* 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/>.
*/
#include "ScriptMgr.h"
#include "Player.h"
class DuelResetScript : public PlayerScript
{
public:
DuelResetScript() : PlayerScript("DuelResetScript") { }
// Called when a duel starts (after 3s countdown)
void OnDuelStart(Player* player1, Player* player2) override
{
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
player1->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player2->GetSpellHistory()->SaveCooldownStateBeforeDuel();
player1->RemoveArenaSpellCooldowns(true);
player2->RemoveArenaSpellCooldowns(true);
}
}
// Called when a duel ends
void OnDuelEnd(Player* winner, Player* loser, DuelCompleteType /*type*/) override
{
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
{
winner->RemoveArenaSpellCooldowns(true);
loser->RemoveArenaSpellCooldowns(true);
winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
}
}
};
void AddSC_duel_reset()
{
new DuelResetScript();
}