diff options
author | megamage <none@none> | 2009-03-02 17:01:41 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-03-02 17:01:41 -0600 |
commit | c064c2e2e1eebd43b273365583dd181293bafa22 (patch) | |
tree | 8db7a9eaa19c5485b392881bc78e52ea3697bdc4 | |
parent | d7d7c3562a9e33f0d655b86572e7a73e0ee384a6 (diff) |
[7365] Implement potion in combat delay proper work. Author: VladimirMangos
Original patch provided by miranda.conrado.
--HG--
branch : trunk
-rw-r--r-- | src/game/Player.cpp | 26 | ||||
-rw-r--r-- | src/game/Player.h | 3 | ||||
-rw-r--r-- | src/game/Spell.cpp | 13 | ||||
-rw-r--r-- | src/game/Unit.cpp | 2 | ||||
-rw-r--r-- | src/shared/revision_nr.h | 2 |
5 files changed, 45 insertions, 1 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 7bb518c130b..83047741625 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -424,6 +424,8 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this) m_InstanceValid = true; m_dungeonDifficulty = DIFFICULTY_NORMAL; + m_lastPotionId = 0; + for (int i = 0; i < BASEMOD_END; i++) { m_auraBaseMod[i][FLAT_MOD] = 0.0f; @@ -18154,6 +18156,30 @@ void Player::SendCooldownEvent(SpellEntry const *spellInfo, uint32 itemId, Spell data << GetGUID(); SendDirectMessage(&data); } + +void Player::UpdatePotionCooldown(Spell* spell) +{ + // no potion used i combat or still in combat + if(!m_lastPotionId || isInCombat()) + return; + + // Call not from spell cast, send cooldown event for item spells if no in combat + if(!spell) + { + // spell/item pair let set proper cooldown (except not existed charged spell cooldown spellmods for potions) + if(ItemPrototype const* proto = ObjectMgr::GetItemPrototype(m_lastPotionId)) + for(int idx = 0; idx < 5; ++idx) + if(proto->Spells[idx].SpellId && proto->Spells[idx].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE) + if(SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[idx].SpellId)) + SendCooldownEvent(spellInfo,m_lastPotionId); + } + // from spell cases (m_lastPotionId set in Spell::SendSpellCooldown) + else + SendCooldownEvent(spell->m_spellInfo,m_lastPotionId,spell); + + m_lastPotionId = 0; +} + //slot to be excluded while counting bool Player::EnchantmentFitsRequirements(uint32 enchantmentcondition, int8 slot) { diff --git a/src/game/Player.h b/src/game/Player.h index 086fae3e391..9f32bf68f9b 100644 --- a/src/game/Player.h +++ b/src/game/Player.h @@ -1500,6 +1500,8 @@ class TRINITY_DLL_SPEC Player : public Unit void RemoveAllSpellCooldown(); void _LoadSpellCooldowns(QueryResult *result); void _SaveSpellCooldowns(); + void SetLastPotionId(uint32 item_id) { m_lastPotionId = item_id; } + void UpdatePotionCooldown(Spell* spell = NULL); void setResurrectRequestData(uint64 guid, uint32 mapId, float X, float Y, float Z, uint32 health, uint32 mana) { @@ -2293,6 +2295,7 @@ class TRINITY_DLL_SPEC Player : public Unit PlayerMails m_mail; PlayerSpellMap m_spells; SpellCooldowns m_spellCooldowns; + uint32 m_lastPotionId; // last used health/mana potion in combat, that block next potion use ActionButtonList m_actionButtons; diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index 1e36ee5e231..0a88010a6c8 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -2433,6 +2433,15 @@ void Spell::SendSpellCooldown() Player* _player = (Player*)m_caster; + // mana/health potions, disabled by client + if (m_spellInfo->Category==SPELLCATEGORY_HEALTH_MANA_POTIONS) + { + // need in some way provided data for Spell::finish SendCooldownEvent + if(m_CastItem) + _player->SetLastPotionId(m_CastItem->GetEntry()); + return; + } + // have infinity cooldown but set at aura apply if(m_spellInfo->Attributes & SPELL_ATTR_DISABLED_WHILE_ACTIVE) return; @@ -2591,6 +2600,10 @@ void Spell::finish(bool ok) m_caster->resetAttackTimer(RANGED_ATTACK); } + // mana/health potions, disabled by client, send event "not in combat" + if (m_caster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->Category == SPELLCATEGORY_HEALTH_MANA_POTIONS) + ((Player*)m_caster)->UpdatePotionCooldown(this); + // call triggered spell only at successful cast (after clear combo points -> for add some if need) // I assume what he means is that some triggered spells may add combo points if(!m_TriggerSpells.empty()) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index c6170a2f18d..1002318f79e 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -9476,6 +9476,8 @@ void Unit::ClearInCombat() // Player's state will be cleared in Player::UpdateContestedPvP if(GetTypeId()!=TYPEID_PLAYER) clearUnitState(UNIT_STAT_ATTACK_PLAYER); + else + ((Player*)this)->UpdatePotionCooldown(); if(GetTypeId() != TYPEID_PLAYER && ((Creature*)this)->isPet()) { diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 7e292898bc9..e09088eb370 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "7364" + #define REVISION_NR "7365" #endif // __REVISION_NR_H__ |