From 36d5ba9884e62f26f70f2ddeaab5ffd475e3c3ec Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 22 Aug 2020 12:01:01 -0400 Subject: [PATCH] Core/Custom: Fixed Duel Reset Exploits Port From (https://github.com/TrinityCore/TrinityCore/commit/04c303a7e5bc8bc27dedfdb99bc893f6d55da1de) --- Source/Scripts/World/DuelReset.cs | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/Source/Scripts/World/DuelReset.cs b/Source/Scripts/World/DuelReset.cs index 411d737f7..86f4fb14c 100644 --- a/Source/Scripts/World/DuelReset.cs +++ b/Source/Scripts/World/DuelReset.cs @@ -92,33 +92,18 @@ namespace Scripts.World 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(itr => { - // remove cooldowns on spells that have < 10 min CD > 30 sec and has no onHold - player.GetSpellHistory().ResetCooldowns(pair => - { - DateTime now = GameTime.GetGameTimeSystemPoint(); - uint cooldownDuration = pair.Value.CooldownEnd > now ? (uint)(pair.Value.CooldownEnd - now).TotalMilliseconds : 0; - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(pair.Key, Difficulty.None); - return spellInfo.RecoveryTime < 10 * Time.Minute * Time.InMilliseconds - && spellInfo.CategoryRecoveryTime < 10 * Time.Minute * Time.InMilliseconds - && !pair.Value.OnHold - && cooldownDuration > 0 - && (spellInfo.RecoveryTime - cooldownDuration) > (Time.Minute / 2) * Time.InMilliseconds - && (spellInfo.CategoryRecoveryTime - cooldownDuration) > (Time.Minute / 2) * Time.InMilliseconds; - }, true); - } - else - { - // remove cooldowns on spells that have < 10 min CD and has no onHold - player.GetSpellHistory().ResetCooldowns(pair => - { - SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(pair.Key, Difficulty.None); - return spellInfo.RecoveryTime < 10 * Time.Minute * Time.InMilliseconds - && spellInfo.CategoryRecoveryTime < 10 * Time.Minute * Time.InMilliseconds - && !pair.Value.OnHold; - }, true); - } + SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itr.Key, Difficulty.None); + uint remainingCooldown = player.GetSpellHistory().GetRemainingCooldown(spellInfo); + return remainingCooldown > 0 + && !itr.Value.OnHold + && TimeSpan.FromMilliseconds(spellInfo.RecoveryTime) < TimeSpan.FromMinutes(10) + && TimeSpan.FromMilliseconds(spellInfo.CategoryRecoveryTime) < TimeSpan.FromMinutes(10) + && TimeSpan.FromMilliseconds(remainingCooldown) < TimeSpan.FromMinutes(10) + && (onStartDuel ? !player.HasAura(spellInfo.Id) : true); + }, true); // pet cooldowns Pet pet = player.GetPet();