From 8fcfabe784797fea46e25428492d9070adda1dc9 Mon Sep 17 00:00:00 2001 From: jackpoz Date: Fri, 10 Jan 2014 22:39:08 +0100 Subject: Core/Spells: Fix potions cooldown in combat Fix a cooldown issue related to potions allowing Players in combat to use more than 1 potion in a row, especially with high latency. This also fixes an exploit about using infinite potions in combat just by skipping the client-side check. The original implementation c064c2e2e1eebd43b273365583dd181293bafa22 was missing a check in Spell::CheckCast() about this particular case since Potion cooldown is added only after the Player goes out of combat. Fixes #1259 . --- src/server/game/Entities/Player/Player.h | 1 + src/server/game/Spells/Spell.cpp | 4 ++++ 2 files changed, 5 insertions(+) (limited to 'src') diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 457f5af8361..f04f485fa1e 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1643,6 +1643,7 @@ class Player : public Unit, public GridObject void RemoveAllSpellCooldown(); void _LoadSpellCooldowns(PreparedQueryResult result); void _SaveSpellCooldowns(SQLTransaction& trans); + uint32 GetLastPotionId() { return m_lastPotionId; } void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } void UpdatePotionCooldown(Spell* spell = NULL); diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4aedc1a95eb..49eed70f57d 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4760,6 +4760,10 @@ SpellCastResult Spell::CheckCast(bool strict) else return SPELL_FAILED_NOT_READY; } + + // check if we are using a potion in combat for the 2nd+ time. Cooldown is added only after caster gets out of combat + if (m_caster->ToPlayer()->GetLastPotionId() && m_CastItem && (m_CastItem->IsPotion() || m_spellInfo->IsCooldownStartedOnEvent())) + return SPELL_FAILED_NOT_READY; } if (m_spellInfo->AttributesEx7 & SPELL_ATTR7_IS_CHEAT_SPELL && !m_caster->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_ALLOW_CHEAT_SPELLS)) -- cgit v1.2.3