Core/Custom: Fixed Duel Reset Exploits

Port From (https://github.com/TrinityCore/TrinityCore/commit/04c303a7e5bc8bc27dedfdb99bc893f6d55da1de)
This commit is contained in:
hondacrx
2020-08-22 12:01:01 -04:00
parent 193ad3a48d
commit 36d5ba9884
+11 -26
View File
@@ -92,33 +92,18 @@ namespace Scripts.World
void ResetSpellCooldowns(Player player, bool onStartDuel) 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 SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itr.Key, Difficulty.None);
player.GetSpellHistory().ResetCooldowns(pair => uint remainingCooldown = player.GetSpellHistory().GetRemainingCooldown(spellInfo);
{ return remainingCooldown > 0
DateTime now = GameTime.GetGameTimeSystemPoint(); && !itr.Value.OnHold
uint cooldownDuration = pair.Value.CooldownEnd > now ? (uint)(pair.Value.CooldownEnd - now).TotalMilliseconds : 0; && TimeSpan.FromMilliseconds(spellInfo.RecoveryTime) < TimeSpan.FromMinutes(10)
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(pair.Key, Difficulty.None); && TimeSpan.FromMilliseconds(spellInfo.CategoryRecoveryTime) < TimeSpan.FromMinutes(10)
return spellInfo.RecoveryTime < 10 * Time.Minute * Time.InMilliseconds && TimeSpan.FromMilliseconds(remainingCooldown) < TimeSpan.FromMinutes(10)
&& spellInfo.CategoryRecoveryTime < 10 * Time.Minute * Time.InMilliseconds && (onStartDuel ? !player.HasAura(spellInfo.Id) : true);
&& !pair.Value.OnHold }, true);
&& 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);
}
// pet cooldowns // pet cooldowns
Pet pet = player.GetPet(); Pet pet = player.GetPet();