diff options
| author | Keader <keader.android@gmail.com> | 2017-07-01 16:56:30 -0300 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2020-08-14 17:38:52 +0200 |
| commit | 04c303a7e5bc8bc27dedfdb99bc893f6d55da1de (patch) | |
| tree | 20b0b34ab9eff671c2dbc8900cfdba2d8bad24c6 /src | |
| parent | 1c52d5fff738aa01bd27fd117076ac33515acef5 (diff) | |
Core/Custom: Fixed Duel Reset Exploits
Close #17419
*Fixed exploit with SPELLMOD_COOLDOWN
*Fixed exploit with some items (like Sylvanas' Music Box)
*Little cleanup
(cherry picked from commit 0048d4b618e6503a5f1607f3503fcf2d48e6a385)
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/scripts/World/duel_reset.cpp | 37 |
1 files changed, 11 insertions, 26 deletions
diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp index 7ad9fb596e7..c2255893704 100644 --- a/src/server/scripts/World/duel_reset.cpp +++ b/src/server/scripts/World/duel_reset.cpp @@ -90,33 +90,18 @@ class DuelResetScript : public PlayerScript static void ResetSpellCooldowns(Player* player, bool onStartDuel) { - if (onStartDuel) + // remove cooldowns on spells that have < 10 min CD, has no onHold and Aura + player->GetSpellHistory()->ResetCooldowns([player, onStartDuel](SpellHistory::CooldownStorageType::iterator itr) -> bool { - // remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold - player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool - { - SpellHistory::Clock::time_point now = GameTime::GetGameTimeSystemPoint(); - uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0; - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && !itr->second.OnHold - && cooldownDuration > 0 - && ( spellInfo->RecoveryTime - cooldownDuration ) > (MINUTE / 2) * IN_MILLISECONDS - && ( spellInfo->CategoryRecoveryTime - cooldownDuration ) > (MINUTE / 2) * IN_MILLISECONDS; - }, true); - } - else - { - // remove cooldowns on spells that have < 10 min CD and has no onHold - player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool - { - SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); - return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS - && !itr->second.OnHold; - }, true); - } + SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE); + uint32 remainingCooldown = player->GetSpellHistory()->GetRemainingCooldown(spellInfo); + return remainingCooldown > 0 + && !itr->second.OnHold + && Milliseconds(spellInfo->RecoveryTime) < Minutes(10) + && Milliseconds(spellInfo->CategoryRecoveryTime) < Minutes(10) + && Milliseconds(remainingCooldown) < Minutes(10) + && (onStartDuel ? !player->HasAura(spellInfo->Id) : true); + }, true); // pet cooldowns if (Pet* pet = player->GetPet()) |
