mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-18 14:10:18 -04:00
Core/Auras: Add Aura::TryRefreshStackOrCreate function and remove stack checks from Aura::Create
This commit is contained in:
@@ -1956,7 +1956,7 @@ bool ChatHandler::HandleAuraCommand(const char *args)
|
||||
uint32 spellID = extractSpellIdFromLink((char*)args);
|
||||
|
||||
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellID))
|
||||
Aura::TryCreate(spellInfo, target, target);
|
||||
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, target, target);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -4523,7 +4523,7 @@ bool ChatHandler::HandleFreezeCommand(const char *args)
|
||||
|
||||
//m_session->GetPlayer()->CastSpell(player, spellID, false);
|
||||
if (SpellEntry const *spellInfo = sSpellStore.LookupEntry(9454))
|
||||
Aura::TryCreate(spellInfo, player, player);
|
||||
Aura::TryRefreshStackOrCreate(spellInfo, MAX_EFFECT_MASK, player, player);
|
||||
|
||||
//save player
|
||||
player->SaveToDB();
|
||||
|
||||
@@ -1230,7 +1230,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
||||
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())
|
||||
{
|
||||
|
||||
@@ -3815,7 +3815,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
|
||||
if (aura->IsSingleTarget())
|
||||
aura->UnregisterSingleTarget();
|
||||
|
||||
if (newAura = Aura::TryCreate(aura->GetSpellProto(), effMask, stealer, NULL, &baseDamage[0], NULL, aura->GetCasterGUID()))
|
||||
if (newAura = Aura::TryRefreshStackOrCreate(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
|
||||
if (newAura->IsSingleTarget())
|
||||
@@ -16184,7 +16184,7 @@ Aura * Unit::AddAura(SpellEntry const *spellInfo, uint8 effMask, Unit *target)
|
||||
effMask &= ~(1<<i);
|
||||
}
|
||||
|
||||
if (Aura * aura = Aura::TryCreate(spellInfo, effMask, target, this))
|
||||
if (Aura * aura = Aura::TryRefreshStackOrCreate(spellInfo, effMask, target, this))
|
||||
{
|
||||
aura->ApplyForTargets();
|
||||
return aura;
|
||||
@@ -16765,7 +16765,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
else // This can happen during Player::_LoadAuras
|
||||
{
|
||||
int32 bp0 = seatId;
|
||||
Aura::TryCreate(spellEntry, this, clicker, &bp0, NULL, origCasterGUID);
|
||||
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, &bp0, NULL, origCasterGUID);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -16773,7 +16773,7 @@ bool Unit::HandleSpellClick(Unit* clicker, int8 seatId)
|
||||
if (IsInMap(caster))
|
||||
caster->CastSpell(target, spellEntry, true, NULL, NULL, origCasterGUID);
|
||||
else
|
||||
Aura::TryCreate(spellEntry, this, clicker, NULL, NULL, origCasterGUID);
|
||||
Aura::TryRefreshStackOrCreate(spellEntry, MAX_EFFECT_MASK, this, clicker, NULL, NULL, origCasterGUID);
|
||||
}
|
||||
|
||||
success = true;
|
||||
|
||||
@@ -213,70 +213,73 @@ void AuraApplication::ClientUpdate(bool remove)
|
||||
m_target->SendMessageToSet(&data, true);
|
||||
}
|
||||
|
||||
Aura * Aura::TryCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
|
||||
uint8 Aura::BuildEffectMaskForOwner(SpellEntry const* spellProto, uint8 avalibleEffectMask, WorldObject* owner)
|
||||
{
|
||||
ASSERT(spellProto);
|
||||
ASSERT(owner);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellProto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellProto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return effMask & avalibleEffectMask;
|
||||
}
|
||||
|
||||
Aura* Aura::TryRefreshStackOrCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/, bool* refresh /*= NULL*/)
|
||||
{
|
||||
ASSERT(spellproto);
|
||||
ASSERT(owner);
|
||||
ASSERT(caster || casterGUID);
|
||||
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
if (refresh)
|
||||
*refresh = false;
|
||||
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
|
||||
if (!effMask)
|
||||
return NULL;
|
||||
if (Aura* foundAura = owner->ToUnit()->_TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID))
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellproto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// we've here aura, which script triggered removal after modding stack amount
|
||||
// check the state here, so we won't create new Aura object
|
||||
if (foundAura->IsRemoved())
|
||||
return NULL;
|
||||
|
||||
if (refresh)
|
||||
*refresh = true;
|
||||
return foundAura;
|
||||
}
|
||||
if (uint8 realMask = effMask & tryEffMask)
|
||||
return Create(spellproto, realMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
return NULL;
|
||||
else
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
}
|
||||
|
||||
Aura * Aura::TryCreate(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, int32 *baseAmount, Item * castItem, uint64 casterGUID)
|
||||
Aura* Aura::TryCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
|
||||
{
|
||||
ASSERT(spellproto);
|
||||
ASSERT(owner);
|
||||
ASSERT(caster || casterGUID);
|
||||
uint8 effMask = 0;
|
||||
switch(owner->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (IsUnitOwnedAuraEffect(spellproto->Effect[i]))
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
for (uint8 i = 0; i< MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (spellproto->Effect[i] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
effMask |= 1 << i;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (effMask)
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
return NULL;
|
||||
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
|
||||
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
|
||||
if (!effMask)
|
||||
return NULL;
|
||||
return Create(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
}
|
||||
|
||||
Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= NULL*/, Item* castItem /*= NULL*/, uint64 casterGUID /*= 0*/)
|
||||
Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, uint64 casterGUID)
|
||||
{
|
||||
ASSERT(effMask);
|
||||
ASSERT(spellproto);
|
||||
@@ -306,10 +309,7 @@ Aura* Aura::Create(SpellEntry const* spellproto, uint8 effMask, WorldObject* own
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
case TYPEID_PLAYER:
|
||||
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);
|
||||
aura = new UnitAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
break;
|
||||
case TYPEID_DYNAMICOBJECT:
|
||||
aura = new DynObjAura(spellproto, effMask, owner, caster, baseAmount, castItem, casterGUID);
|
||||
|
||||
@@ -83,9 +83,10 @@ class Aura
|
||||
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 uint8 BuildEffectMaskForOwner(SpellEntry const* spellProto, uint8 avalibleEffectMask, WorldObject* owner);
|
||||
static Aura* TryRefreshStackOrCreate(SpellEntry const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount = NULL, Item* castItem = NULL, uint64 casterGUID = 0, bool* refresh = NULL);
|
||||
static Aura* TryCreate(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, Item* castItem, uint64 casterGUID);
|
||||
explicit Aura(SpellEntry const* spellproto, WorldObject * owner, Unit * caster, Item * castItem, uint64 casterGUID);
|
||||
void _InitEffects(uint8 effMask, Unit * caster, int32 *baseAmount);
|
||||
virtual ~Aura();
|
||||
|
||||
@@ -1427,7 +1427,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
|
||||
if (m_originalCaster)
|
||||
{
|
||||
m_spellAura = Aura::TryCreate(aurSpellInfo, effectMask, unit,
|
||||
m_spellAura = Aura::TryRefreshStackOrCreate(aurSpellInfo, effectMask, unit,
|
||||
m_originalCaster, (aurSpellInfo == m_spellInfo)? &m_spellValue->EffectBasePoints[0] : &basePoints[0], m_CastItem);
|
||||
if (m_spellAura)
|
||||
{
|
||||
|
||||
@@ -2543,7 +2543,7 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
|
||||
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
|
||||
if (Aura* aura = Aura::TryCreate(m_spellInfo, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
|
||||
{
|
||||
m_spellAura = aura;
|
||||
m_spellAura->_RegisterForTargets();
|
||||
|
||||
+1
-1
@@ -249,7 +249,7 @@ class boss_kelidan_the_breaker : public CreatureScript
|
||||
|
||||
if (SpellEntry *nova = GET_SPELL(SPELL_BURNING_NOVA))
|
||||
{
|
||||
if (Aura * aura = Aura::TryCreate(nova, me, me))
|
||||
if (Aura * aura = Aura::TryRefreshStackOrCreate(nova, MAX_EFFECT_MASK, me, me))
|
||||
aura->ApplyForTargets();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user