mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-23 02:25:38 +01:00
Merge pull request #16287 from GigaDev90/fix_bug_duel_abuse
Core/Script: fix bug that prevent double spending reset cooldown
This commit is contained in:
@@ -34,9 +34,8 @@ class DuelResetScript : public PlayerScript
|
||||
player1->GetSpellHistory()->SaveCooldownStateBeforeDuel();
|
||||
player2->GetSpellHistory()->SaveCooldownStateBeforeDuel();
|
||||
|
||||
|
||||
ResetSpellCooldowns(player1);
|
||||
ResetSpellCooldowns(player2);
|
||||
ResetSpellCooldowns(player1, true);
|
||||
ResetSpellCooldowns(player2, true);
|
||||
}
|
||||
|
||||
// Health and mana reset
|
||||
@@ -73,9 +72,8 @@ class DuelResetScript : public PlayerScript
|
||||
// Cooldown restore
|
||||
if (sWorld->getBoolConfig(CONFIG_RESET_DUEL_COOLDOWNS))
|
||||
{
|
||||
|
||||
ResetSpellCooldowns(winner);
|
||||
ResetSpellCooldowns(loser);
|
||||
ResetSpellCooldowns(winner, false);
|
||||
ResetSpellCooldowns(loser, false);
|
||||
|
||||
winner->GetSpellHistory()->RestoreCooldownStateAfterDuel();
|
||||
loser->GetSpellHistory()->RestoreCooldownStateAfterDuel();
|
||||
@@ -98,14 +96,35 @@ class DuelResetScript : public PlayerScript
|
||||
}
|
||||
}
|
||||
|
||||
static void ResetSpellCooldowns(Player* player)
|
||||
static void ResetSpellCooldowns(Player* player, bool onStartDuel)
|
||||
{
|
||||
// remove cooldowns on spells that have < 10 min CD and has no onHold
|
||||
player->GetSpellHistory()->ResetCooldowns([](SpellHistory::CooldownStorageType::iterator itr) -> bool
|
||||
if (onStartDuel)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first);
|
||||
return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS && spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS && !itr->second.OnHold;
|
||||
}, true);
|
||||
// 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 = SpellHistory::Clock::now();
|
||||
uint32 cooldownDuration = itr->second.CooldownEnd > now ? std::chrono::duration_cast<std::chrono::milliseconds>(itr->second.CooldownEnd - now).count() : 0;
|
||||
SpellInfo const* spellInfo = sSpellMgr->EnsureSpellInfo(itr->first);
|
||||
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->EnsureSpellInfo(itr->first);
|
||||
return spellInfo->RecoveryTime < 10 * MINUTE * IN_MILLISECONDS
|
||||
&& spellInfo->CategoryRecoveryTime < 10 * MINUTE * IN_MILLISECONDS
|
||||
&& !itr->second.OnHold;
|
||||
}, true);
|
||||
}
|
||||
|
||||
// pet cooldowns
|
||||
if (Pet* pet = player->GetPet())
|
||||
|
||||
Reference in New Issue
Block a user