From b35a53e2b92c191fff54023a7df05f77640e67f7 Mon Sep 17 00:00:00 2001 From: Olion Date: Fri, 25 Sep 2015 09:27:40 +0300 Subject: [PATCH] [Spell] Extra attack: instant or on the next swing Known issue: wrong combat logging order. Though the timestamp for spelleffect and instant extra attack is the same, the spelleffect appears later in the log. Was tested on the Windfury weapon only. Main idea was taken from the TC. --- src/game/Object/Unit.cpp | 24 ++++++++++-------------- src/game/Object/Unit.h | 5 ++++- src/game/Server/DBCStructure.h | 7 +++++++ src/game/WorldHandlers/Spell.cpp | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/src/game/Object/Unit.cpp b/src/game/Object/Unit.cpp index 8ea8a1cd..c04fd888 100644 --- a/src/game/Object/Unit.cpp +++ b/src/game/Object/Unit.cpp @@ -2102,14 +2102,8 @@ void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool ext // not recent extra attack only at any non extra attack (melee spell case) if (!extra && extraAttacks) - { - while (m_extraAttacks) - { - AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if (m_extraAttacks > 0) - { --m_extraAttacks; } - } - } + HandleProcExtraAttackFor(pVictim); + return; } @@ -2133,13 +2127,15 @@ void Unit::AttackerStateUpdate(Unit* pVictim, WeaponAttackType attType, bool ext // extra attack only at any non extra attack (normal case) if (!extra && extraAttacks) + HandleProcExtraAttackFor(pVictim); +} + +void Unit::HandleProcExtraAttackFor(Unit* victim) +{ + while (m_extraAttacks) { - while (m_extraAttacks) - { - AttackerStateUpdate(pVictim, BASE_ATTACK, true); - if (m_extraAttacks > 0) - { --m_extraAttacks; } - } + --m_extraAttacks; + AttackerStateUpdate(victim, BASE_ATTACK, true); } } diff --git a/src/game/Object/Unit.h b/src/game/Object/Unit.h index b56a9906..0ab6bda7 100644 --- a/src/game/Object/Unit.h +++ b/src/game/Object/Unit.h @@ -1971,7 +1971,10 @@ class Unit : public WorldObject * @param durabilityLoss whether or not durability loss should happen */ void DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss); - + /** + * Handles all extra attacks set up by a spell + */ + void HandleProcExtraAttackFor(Unit* victim); /** * Calculates how much damage a spell should do, it will do some bonus damage according * to which SpellNonMeleeDamage::DmgClass it belongs to, ie: SPELL_DAMAGE_CLASS_RANGED diff --git a/src/game/Server/DBCStructure.h b/src/game/Server/DBCStructure.h index 12ed6b4f..11790f3b 100644 --- a/src/game/Server/DBCStructure.h +++ b/src/game/Server/DBCStructure.h @@ -921,6 +921,13 @@ struct SpellEntry */ inline bool HasAttribute(SpellAttributesEx4 attribute) const { return AttributesEx4 & attribute; } + inline bool HasSpellEffect(uint16 effect) const + { + for (uint8 i = EFFECT_INDEX_0; i <= EFFECT_INDEX_2; ++i) + if (Effect[i] == effect) + return true; + return false; + } private: // prevent creating custom entries (copy data from original in fact) SpellEntry(SpellEntry const&); // DON'T must have implementation diff --git a/src/game/WorldHandlers/Spell.cpp b/src/game/WorldHandlers/Spell.cpp index 1eef27a4..04c2ccb0 100644 --- a/src/game/WorldHandlers/Spell.cpp +++ b/src/game/WorldHandlers/Spell.cpp @@ -2950,6 +2950,22 @@ void Spell::_handle_finish_phase() // spell log if (m_needSpellLog) { SendLogExecute(); } + + if (m_caster->m_extraAttacks && m_spellInfo->HasSpellEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS)) + { + switch (m_spellInfo->Id) + { + case 15494: + case 18797: + case 21919: + case 20178: // paladin reckoning proc + break; + default: + if (Unit* victim = m_caster->getVictim()) + m_caster->HandleProcExtraAttackFor(victim); + break; + } + } } void Spell::SendSpellCooldown()