diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 7 | ||||
| -rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 17 | ||||
| -rwxr-xr-x | src/server/game/Entities/Unit/Unit.h | 2 | ||||
| -rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 2 | ||||
| -rwxr-xr-x | src/server/game/Spells/Auras/SpellAuras.cpp | 26 | ||||
| -rwxr-xr-x | src/server/game/Spells/Auras/SpellAuras.h | 4 |
6 files changed, 33 insertions, 25 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index a4a051e39ce..6e43d918760 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -17130,19 +17130,22 @@ void Player::_LoadAuras(PreparedQueryResult result, uint32 timediff) // prevent wrong values of remaincharges if (spellproto->procCharges) { - if (remaincharges <= 0 || remaincharges > spellproto->procCharges) + // we have no control over the order of applying auras and modifiers allow auras + // to have more charges than value in SpellEntry + if (remaincharges <= 0/* || remaincharges > spellproto->procCharges*/) remaincharges = spellproto->procCharges; } else remaincharges = 0; - if (Aura * aura = Aura::TryCreate(spellproto, effmask, this, NULL, &baseDamage[0], NULL, caster_guid)) + if (Aura* aura = Aura::TryCreate(spellproto, effmask, this, NULL, &baseDamage[0], NULL, caster_guid)) { if (!aura->CanBeSaved()) { aura->Remove(); continue; } + aura->SetLoadedState(maxduration, remaintime, remaincharges, stackcount, recalculatemask, &damage[0]); aura->ApplyForTargets(); sLog->outDetail("Added aura spellid %u, effectmask %u", spellproto->Id, effmask); diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 47f8f48788c..8a70efff5bf 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -3111,7 +3111,7 @@ void Unit::DeMorph() SetDisplayId(GetNativeDisplayId()); } -Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/) +Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/) { ASSERT(casterGUID); // passive and Incanter's Absorption and auras with different type can stack with themselves any number of times @@ -3134,15 +3134,16 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint // update basepoints with new values - effect amount will be recalculated in ModStackAmount for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) { - if (!foundAura->m_effects[i]) + if (!foundAura->HasEffect(i)) continue; + int bp; if (baseAmount) bp = *(baseAmount + i); else bp = foundAura->GetSpellProto()->EffectBasePoints[i]; - int32* oldBP = const_cast<int32*>(&(foundAura->m_effects[i]->m_baseAmount)); + int32* oldBP = const_cast<int32*>(&(foundAura->GetEffect(i)->m_baseAmount)); *oldBP = bp; } @@ -3153,6 +3154,14 @@ Aura* Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint *oldGUID = castItemGUID; } + uint8 charges = foundAura->GetSpellProto()->procCharges; + if (caster) + if (Player* modOwner = caster->GetSpellModOwner()) + modOwner->ApplySpellMod(foundAura->GetId(), SPELLMOD_CHARGES, charges); + + // refresh charges + foundAura->SetCharges(charges); + // try to increase stack amount foundAura->ModStackAmount(1); return foundAura; @@ -3805,7 +3814,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit // single target state must be removed before aura creation to preserve existing single target aura if (aura->IsSingleTarget()) aura->UnregisterSingleTarget(); - + if (newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID())) { // created aura must not be single target aura,, so stealer won't loose it on recast diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 82c8eafb589..e4180910bb3 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1616,7 +1616,7 @@ class Unit : public WorldObject bool InitTamedPet(Pet * pet, uint8 level, uint32 spell_id); // aura apply/remove helpers - you should better not use these - Aura* _TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0); + Aura* _TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0); void _AddAura(UnitAura * aura, Unit * caster); AuraApplication * _CreateAuraApplication(Aura * aura, uint8 effMask); void _ApplyAuraEffect(Aura * aura, uint8 effIndex); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 0525c00c4e0..3f6c6b5587c 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -14,7 +14,7 @@ typedef void(AuraEffect::*pAuraEffectHandler)(AuraApplication const * aurApp, ui class AuraEffect { friend void Aura::_InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount); - friend Aura * Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const * newAura, uint8 effMask, int32 *baseAmount, Item * castItem, uint64 casterGUID); + friend Aura * Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const* newAura, uint8 effMask, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID); friend Aura::~Aura(); private: ~AuraEffect(); diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index c89cd867db5..e2cc64e8df7 100755 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -276,7 +276,7 @@ Aura * Aura::TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * return NULL; } -Aura * Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID) +Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/) { ASSERT(effMask); ASSERT(spellproto); @@ -287,33 +287,29 @@ Aura * Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * o if (casterGUID) { if (owner->GetGUID() == casterGUID) - caster = (Unit *)owner; + caster = owner->ToUnit(); else caster = ObjectAccessor::GetUnit(*owner, casterGUID); } else - { casterGUID = caster->GetGUID(); - } + // check if aura can be owned by owner if (owner->isType(TYPEMASK_UNIT)) - { if (!owner->IsInWorld() || ((Unit*)owner)->IsDuringRemoveFromWorld()) - { - // owner not in world so - // don't allow to own not self casted single target auras + // owner not in world so don't allow to own not self casted single target auras if (casterGUID != owner->GetGUID() && IsSingleTargetSpell(spellproto)) return NULL; - } - } - Aura * aura = NULL; - switch(owner->GetTypeId()) + + Aura* aura = NULL; + switch (owner->GetTypeId()) { case TYPEID_UNIT: case TYPEID_PLAYER: - if (aura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, baseAmount, castItem, casterGUID)) - return aura; - aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); + if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID)) + aura = foundAura; + else + aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); break; case TYPEID_DYNAMICOBJECT: aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 8204fbb8be9..9701c81869e 100755 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -79,13 +79,13 @@ class AuraApplication class Aura { - friend Aura * Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const * newAura, uint8 effMask, int32 *baseAmount, Item * castItem, uint64 casterGUID); + friend Aura * Unit::_TryStackingOrRefreshingExistingAura(SpellEntry const * newAura, uint8 effMask, Unit* caster, int32 *baseAmount, Item * castItem, uint64 casterGUID); public: typedef std::map<uint64, AuraApplication *> ApplicationMap; static Aura * TryCreate(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0); static Aura * TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0); - static Aura * Create(SpellEntry const* spellproto, uint8 effMask, WorldObject * owner, Unit * caster, int32 *baseAmount = NULL, Item * castItem = NULL, uint64 casterGUID = 0); + static Aura* Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0); explicit Aura(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, Item * castItem, uint64 casterGUID); void _InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount); virtual ~Aura(); |
