mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 17:27:36 +01:00
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:
57
src/server/scripts/World/duel_reset.cpp
Normal file
57
src/server/scripts/World/duel_reset.cpp
Normal 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user