diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index af0c65c2d5a..6282dc5530f 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -1714,67 +1714,72 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) ((Player*)this)->CastItemCombatSpell(pVictim, damageInfo->attackType); // victim's damage shield - std::set alreadyDone; - AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); - for (AuraList::const_iterator i = vDamageShields.begin(); i != vDamageShields.end();) + TriggerDamageShields(pVictim); + } +} + +void Unit::TriggerDamageShields(Unit* pVictim) +{ + std::set alreadyDone; + AuraList const& vDamageShields = pVictim->GetAurasByType(SPELL_AURA_DAMAGE_SHIELD); + for (AuraList::const_iterator i = vDamageShields.begin(); i != vDamageShields.end();) + { + if (alreadyDone.find(*i) == alreadyDone.end()) { - if (alreadyDone.find(*i) == alreadyDone.end()) - { - alreadyDone.insert(*i); - SpellEntry const* pSpellProto = (*i)->GetSpellProto(); + alreadyDone.insert(*i); + SpellEntry const* pSpellProto = (*i)->GetSpellProto(); - // Damage shield can be resisted... - if (SpellMissInfo missInfo = pVictim->SpellHitResult(this, pSpellProto, (*i)->GetEffIndex())) - { - pVictim->SendSpellMiss(this, pSpellProto->Id, missInfo); - continue; - } + // Damage shield can be resisted... + if (SpellMissInfo missInfo = pVictim->SpellHitResult(this, pSpellProto, (*i)->GetEffIndex())) + { + pVictim->SendSpellMiss(this, pSpellProto->Id, missInfo); + continue; + } - // ...or immuned - if (IsImmuneToDamage(pSpellProto->GetSpellSchoolMask())) - { - pVictim->SendSpellOrDamageImmune(this, pSpellProto->Id); - continue; - } + // ...or immuned + if (IsImmuneToDamage(pSpellProto->GetSpellSchoolMask())) + { + pVictim->SendSpellOrDamageImmune(this, pSpellProto->Id); + continue; + } - float fdamage = (*i)->GetModifier()->m_amount; + float fdamage = (*i)->GetModifier()->m_amount; - // Damage shield effects do benefit from damage done bonuses, including spell power if bonus coefficient is set. - // For example Flame Wrath has a coefficient of 1, making it scale with 100% of spell power. - fdamage = pVictim->SpellDamageBonusDone(this, pSpellProto, (*i)->GetEffIndex(), fdamage, SPELL_DIRECT_DAMAGE, (*i)->GetStackAmount()); + // Damage shield effects do benefit from damage done bonuses, including spell power if bonus coefficient is set. + // For example Flame Wrath has a coefficient of 1, making it scale with 100% of spell power. + fdamage = pVictim->SpellDamageBonusDone(this, pSpellProto, (*i)->GetEffIndex(), fdamage, SPELL_DIRECT_DAMAGE, (*i)->GetStackAmount()); - // apply SpellBaseDamageBonusTaken for mobs only - // for example, Death Talon Seethers with Aura of Flames reflect 1200 damage to tanks with Mark of Flame - if (pVictim->IsCreature()) - { - int32 spellDmgTakenBonus = this->SpellBaseDamageBonusTaken(pSpellProto->GetSpellSchoolMask()); - // don't allow damage shields to be reduced by Blessing of Sanctuary, etc. - if (spellDmgTakenBonus > 0) fdamage += spellDmgTakenBonus; - } + // apply SpellBaseDamageBonusTaken for mobs only + // for example, Death Talon Seethers with Aura of Flames reflect 1200 damage to tanks with Mark of Flame + if (pVictim->IsCreature()) + { + int32 spellDmgTakenBonus = this->SpellBaseDamageBonusTaken(pSpellProto->GetSpellSchoolMask()); + // don't allow damage shields to be reduced by Blessing of Sanctuary, etc. + if (spellDmgTakenBonus > 0) fdamage += spellDmgTakenBonus; + } - //Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist? - //uint32 absorb; - //uint32 resist; - //CalcAbsorbResist(pVictim, SpellSchools(spellProto->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); - //damage-=absorb + resist; + //Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist? + //uint32 absorb; + //uint32 resist; + //CalcAbsorbResist(pVictim, SpellSchools(spellProto->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + //damage-=absorb + resist; - uint32 damage = ditheru(fdamage); - pVictim->DealDamageMods(this, damage, nullptr); + uint32 damage = ditheru(fdamage); + pVictim->DealDamageMods(this, damage, nullptr); - WorldPacket data(SMSG_SPELLDAMAGESHIELD, (8 + 8 + 4 + 4)); - data << pVictim->GetObjectGuid(); - data << GetObjectGuid(); - data << uint32(damage); - data << uint32(pSpellProto->School); - pVictim->SendObjectMessageToSet(&data, true); + WorldPacket data(SMSG_SPELLDAMAGESHIELD, (8 + 8 + 4 + 4)); + data << pVictim->GetObjectGuid(); + data << GetObjectGuid(); + data << uint32(damage); + data << uint32(pSpellProto->School); + pVictim->SendObjectMessageToSet(&data, true); - pVictim->DealDamage(this, damage, nullptr, SPELL_DIRECT_DAMAGE, pSpellProto->GetSpellSchoolMask(), pSpellProto, true); + pVictim->DealDamage(this, damage, nullptr, SPELL_DIRECT_DAMAGE, pSpellProto->GetSpellSchoolMask(), pSpellProto, true); - i = vDamageShields.begin(); - } - else - ++i; + i = vDamageShields.begin(); } + else + ++i; } } diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 09ea7e5c369..36a92dae308 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -841,6 +841,7 @@ class Unit : public SpellCaster void ProcDamageAndSpellFor(bool isVictim, Unit* pTarget, ProcSystemArguments const& data, ProcTriggeredList& triggeredList, ProcessProcsAuraType processAurasType); void ProcSkillsAndReactives(bool isVictim, Unit* pTarget, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellEntry const* procSpell); void HandleTriggers(Unit* pVictim, uint32 procExtra, uint32 amount, SpellEntry const* procSpell, ProcTriggeredList const& procTriggered); + void TriggerDamageShields(Unit* pVictim); SpellProcEventTriggerCheck IsTriggeredAtSpellProcEvent(Unit* pVictim, SpellAuraHolder* holder, SpellEntry const* procSpell, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, bool isVictim, SpellProcEventEntry const*& spellProcEvent, bool isSpellTriggeredByAuraOrItem) const; // only to be used in proc handlers - basepoints is expected to be a MAX_EFFECT_INDEX sized array diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index f5a0277f491..d854d527984 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -1741,9 +1741,15 @@ void Spell::DoAllEffectOnTarget(TargetInfo *target) this)); } - if (triggerWeaponProcs && m_caster->IsPlayer()) - ((Player*)m_caster)->CastItemCombatSpell(unitTarget, m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON ? m_attackType : BASE_ATTACK); + if (triggerWeaponProcs && m_casterUnit) + { + if (m_casterUnit->IsPlayer() && unitTarget->IsAlive()) + ((Player*)m_casterUnit)->CastItemCombatSpell(unitTarget, m_spellInfo->EquippedItemClass == ITEM_CLASS_WEAPON ? m_attackType : BASE_ATTACK); + if (m_damage) + m_casterUnit->TriggerDamageShields(unitTarget); + } + if (missInfo != SPELL_MISS_NONE) return;