diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 6b8ecb0e8c..eeae8bf6fc 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3735,6 +3735,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit int32 baseDamage[MAX_SPELL_EFFECTS]; uint8 effMask = 0; uint8 recalculateMask = 0; + Unit * caster = aura->GetCaster(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { if (aura->GetEffect(i)) @@ -3753,35 +3754,53 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit } bool stealCharge = aura->GetSpellProto()->AttributesEx7 & SPELL_ATTR7_DISPEL_CHARGES; + bool stealStack = aura->GetSpellProto()->StackAmount > 1; + int32 dur = (2*MINUTE*IN_MILLISECONDS < aura->GetDuration() || aura->GetDuration() < 0) ? 2*MINUTE*IN_MILLISECONDS : aura->GetDuration(); + + if (Aura * newAura = (stealCharge || stealStack) ? stealer->GetAura(aura->GetId(), aura->GetCasterGUID()) : NULL) + { + if (stealCharge) + { + uint8 newCharges = newAura->GetCharges() + 1; + uint8 maxCharges = newAura->GetSpellProto()->procCharges; + // We must be able to steal as much charges as original caster can have + if (caster) + if (Player* modOwner = caster->GetSpellModOwner()) + modOwner->ApplySpellMod(aura->GetId(), SPELLMOD_CHARGES, maxCharges); + newAura->SetCharges(maxCharges < newCharges ? maxCharges : newCharges); + } + else + { + uint8 newStacks = newAura->GetStackAmount() + 1; + uint8 maxStacks = newAura->GetSpellProto()->StackAmount; + newAura->SetStackAmount(maxStacks < newStacks ? maxStacks : newStacks); + } + newAura->SetDuration(dur); + } + else + { + bool isSingleTarget = aura->IsSingleTarget() && caster; + if (isSingleTarget) + aura->UnregisterSingleTarget(); + newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()); + // strange but intended behaviour: Stolen single target auras won't be treated as single targeted + if (newAura && isSingleTarget) + { + aura->SetIsSingleTarget(true); + caster->GetSingleCastAuras().push_back(aura); + newAura->UnregisterSingleTarget(); + } + if (!newAura) + return; + newAura->SetLoadedState(dur, dur, stealCharge ? 1 : aura->GetCharges(), 1, recalculateMask, &damage[0]); + newAura->ApplyForTargets(); + } if (stealCharge) aura->DropCharge(); else RemoveAuraFromStack(iter, AURA_REMOVE_BY_ENEMY_SPELL); - if (Aura * newAura = stealCharge ? stealer->GetAura(aura->GetId(), aura->GetCasterGUID()) : NULL) - { - uint8 newCharges = newAura->GetCharges() + 1; - uint8 maxCharges = newAura->GetSpellProto()->procCharges; - // We must be able to steal as much charges as original caster can have - if (Unit * caster = newAura->GetCaster()) - if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(aura->GetId(), SPELLMOD_CHARGES, maxCharges); - newAura->SetCharges(maxCharges < newCharges ? maxCharges : newCharges); - } - else - { - int32 dur = (2*MINUTE*IN_MILLISECONDS < aura->GetDuration() || aura->GetDuration() < 0) ? 2*MINUTE*IN_MILLISECONDS : aura->GetDuration(); - - newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()); - if (!newAura) - return; - // strange but intended behaviour: Stolen single target auras won't be treated as single targeted - if (newAura->IsSingleTarget()) - newAura->UnregisterSingleTarget(); - newAura->SetLoadedState(dur, dur, stealCharge ? 1 : aura->GetCharges(), aura->GetStackAmount(), recalculateMask, &damage[0]); - newAura->ApplyForTargets(); - } return; } else