diff options
author | blub <Vincent_Michael@gmx.de> | 2015-10-18 18:46:28 +0200 |
---|---|---|
committer | blub <Vincent_Michael@gmx.de> | 2015-10-18 18:46:28 +0200 |
commit | 5c449b50aadcb35a4bd7fdc25d3a249f023cf507 (patch) | |
tree | 54853a53a5d61e54ebc63dd8321b7cdc9b5cb67c /src/server/scripts | |
parent | 981e764004cc8b09c8f29205d9675bfd6e02ae7b (diff) | |
parent | c6c3e72b55846ccfb565fd09580509800bd25c2a (diff) |
Merge pull request #15731 from ShinDarth/toscri
Convert the Duel Cooldown Reset feature to scripts
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(); +} + |