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:
Shauren
2011-06-03 21:30:50 +02:00
parent 87ce4988f4
commit 97a5db68c2
6 changed files with 33 additions and 25 deletions
+5 -2
View File
@@ -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);
+13 -4
View File
@@ -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
+1 -1
View File
@@ -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);