Core/Auras:
* Fixed loading aura charges when they would exceed count set in SpellEntry while still remaining a valid value due to spell modifiers (that might not yet be active) * Fixed refreshing aura charges when recasting the spell Closes #1803 Closes #1786 Closes #1805
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user