diff options
Diffstat (limited to 'src/server/scripts')
-rw-r--r-- | src/server/scripts/World/duel_reset.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp new file mode 100644 index 00000000000..f08469d5bd5 --- /dev/null +++ b/src/server/scripts/World/duel_reset.cpp @@ -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(); +} + |