*Some update of aura system. Remove unnecessary variables and parameters from auraeffect. Always refer to parent aura when finding target/source/caster.
--HG-- branch : trunk
This commit is contained in:
@@ -421,7 +421,7 @@ struct TRINITY_DLL_DECL boss_veknilashAI : public boss_twinemperorsAI
|
||||
continue;
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
target->AddAura(new Aura(spell, eff_mask, NULL, target, target));
|
||||
target->AddAura(new Aura(spell, eff_mask, target, target, target));
|
||||
target->SetHealth(target->GetMaxHealth());
|
||||
}
|
||||
|
||||
@@ -506,7 +506,7 @@ struct TRINITY_DLL_DECL boss_veklorAI : public boss_twinemperorsAI
|
||||
continue;
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
target->AddAura(new Aura(spell, eff_mask, NULL, target, target));
|
||||
target->AddAura(new Aura(spell, eff_mask, target, target, target));
|
||||
target->SetHealth(target->GetMaxHealth());
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -94,7 +94,7 @@ struct TRINITY_DLL_DECL mob_voidtravelerAI : public ScriptedAI
|
||||
{
|
||||
SpellEntry *spell = GET_SPELL(HeroicMode?H_SPELL_EMPOWERING_SHADOWS:SPELL_EMPOWERING_SHADOWS);
|
||||
if (spell)
|
||||
Vorpil->AddAura(new Aura(spell, 1, NULL, Vorpil, m_creature));
|
||||
Vorpil->AddAura(new Aura(spell, 1, Vorpil, me, me));
|
||||
Vorpil->SetHealth(Vorpil->GetHealth()+Vorpil->GetMaxHealth()/25);
|
||||
DoCast(m_creature, SPELL_SHADOW_NOVA, true);
|
||||
m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
|
||||
@@ -168,7 +168,7 @@ struct TRINITY_DLL_DECL boss_gurtogg_bloodboilAI : public ScriptedAI
|
||||
if (eff>=TOTAL_SPELL_EFFECTS)
|
||||
continue;
|
||||
|
||||
Aura *Aur = new Aura(spellInfo, i, NULL, target);
|
||||
Aura *Aur = new Aura(spellInfo, i, target, target, target);
|
||||
target->AddAura(Aur);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -666,7 +666,7 @@ struct TRINITY_DLL_DECL mob_enchanted_elementalAI : public ScriptedAI
|
||||
continue;
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
Vashj->AddAura(new Aura(spell, eff_mask, NULL, Vashj, Vashj));
|
||||
Vashj->AddAura(new Aura(spell, eff_mask, Vashj, Vashj, Vashj));
|
||||
}
|
||||
m_creature->DealDamage(m_creature, m_creature->GetMaxHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
|
||||
}
|
||||
|
||||
+1
-1
@@ -515,7 +515,7 @@ struct TRINITY_DLL_DECL boss_leotheras_the_blindAI : public ScriptedAI
|
||||
continue;
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
(*itr)->AddAura(new Aura(spell, eff_mask, NULL, (*itr), (*itr)));
|
||||
(*itr)->AddAura(new Aura(spell, eff_mask, *itr, *itr, *itr));
|
||||
if (InnderDemon_Count > 4) InnderDemon_Count = 0;
|
||||
|
||||
//Safe storing of creatures
|
||||
|
||||
+1
-1
@@ -248,7 +248,7 @@ struct TRINITY_DLL_DECL boss_kelidan_the_breakerAI : public ScriptedAI
|
||||
continue;
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
m_creature->AddAura(new Aura(nova, eff_mask, NULL, m_creature, m_creature));
|
||||
m_creature->AddAura(new Aura(nova, eff_mask, me, me, me));
|
||||
}
|
||||
|
||||
if (HeroicMode)
|
||||
|
||||
@@ -2275,7 +2275,7 @@ bool Creature::LoadCreaturesAddon(bool reload)
|
||||
continue;
|
||||
}
|
||||
|
||||
AddAuraEffect(AdditionalSpellInfo, cAura->effect_idx, this);
|
||||
AddAuraEffect(AdditionalSpellInfo, cAura->effect_idx, this, this);
|
||||
sLog.outDebug("Spell: %u with Aura %u added to creature (GUIDLow: %u Entry: %u )", cAura->spell_id, AdditionalSpellInfo->EffectApplyAuraName[cAura->effect_idx],GetGUIDLow(),GetEntry());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
|
||||
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
|
||||
return;
|
||||
// Apply PersistentAreaAura on target
|
||||
if(Aura *aur = target->AddAuraEffect(spellInfo, eff_index, i_dynobject.GetCaster()))
|
||||
if(Aura *aur = target->AddAuraEffect(spellInfo, eff_index, &i_dynobject, i_dynobject.GetCaster()))
|
||||
aur->SetAuraDuration(i_dynobject.GetDuration());
|
||||
|
||||
i_dynobject.AddAffected(target);
|
||||
|
||||
+2
-2
@@ -4382,7 +4382,7 @@ bool ChatHandler::HandleAuraCommand(const char* args)
|
||||
eff_mask|=1<<i;
|
||||
}
|
||||
}
|
||||
Aura *Aur = new Aura(spellInfo, eff_mask, NULL, target);
|
||||
Aura *Aur = new Aura(spellInfo, eff_mask, target, target, target);
|
||||
target->AddAura(Aur);
|
||||
}
|
||||
|
||||
@@ -7352,7 +7352,7 @@ bool ChatHandler::HandleFreezeCommand(const char *args)
|
||||
|
||||
//m_session->GetPlayer()->CastSpell(player,spellID,false);
|
||||
SpellEntry const *spellInfo = sSpellStore.LookupEntry( 9454 );
|
||||
Aura *Aur = new Aura(spellInfo, 1, NULL, player);
|
||||
Aura *Aur = new Aura(spellInfo, 1, player, player, player);
|
||||
player->AddAura(Aur);
|
||||
|
||||
//save player
|
||||
|
||||
+1
-1
@@ -1189,7 +1189,7 @@ void Pet::_LoadAuras(uint32 timediff)
|
||||
else
|
||||
remaincharges = 0;
|
||||
|
||||
Aura* aura = new Aura(spellproto, effmask, NULL, this, NULL, NULL);
|
||||
Aura* aura = new Aura(spellproto, effmask, this, this, this);
|
||||
aura->SetLoadedState(caster_guid,maxduration,remaintime,remaincharges, stackcount, &damage[0]);
|
||||
if(!aura->CanBeSaved())
|
||||
{
|
||||
|
||||
+1
-1
@@ -15379,7 +15379,7 @@ void Player::_LoadAuras(QueryResult *result, uint32 timediff)
|
||||
else
|
||||
remaincharges = 0;
|
||||
|
||||
Aura* aura = new Aura(spellproto, effmask, NULL, this, NULL, NULL);
|
||||
Aura* aura = new Aura(spellproto, effmask, this, this, this);
|
||||
aura->SetLoadedState(caster_guid,maxduration,remaintime,remaincharges, stackcount, &damage[0]);
|
||||
if(!aura->CanBeSaved())
|
||||
{
|
||||
|
||||
+8
-5
@@ -1362,22 +1362,23 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
}
|
||||
}
|
||||
|
||||
Unit * caster = m_originalCaster ? m_originalCaster : m_caster;
|
||||
Aura * Aur = new Aura(aurSpellInfo, aura_effmask, basePoints, unit, m_caster, caster, m_CastItem);
|
||||
if(m_originalCaster)
|
||||
{
|
||||
Aura *Aur = new Aura(aurSpellInfo, aura_effmask, unit, m_caster, m_originalCaster, basePoints, m_CastItem);
|
||||
|
||||
if (!Aur->IsAreaAura())
|
||||
{
|
||||
// Now Reduce spell duration using data received at spell hit
|
||||
int32 duration = Aur->GetAuraMaxDuration();
|
||||
int32 limitduration = GetDiminishingReturnsLimitDuration(m_diminishGroup,aurSpellInfo);
|
||||
unitTarget->ApplyDiminishingToDuration(m_diminishGroup, duration, caster, m_diminishLevel,limitduration);
|
||||
unitTarget->ApplyDiminishingToDuration(m_diminishGroup, duration, m_originalCaster, m_diminishLevel,limitduration);
|
||||
Aur->setDiminishGroup(m_diminishGroup);
|
||||
|
||||
duration = caster->ModSpellDuration(aurSpellInfo, unit, duration, Aur->IsPositive());
|
||||
duration = m_originalCaster->ModSpellDuration(aurSpellInfo, unit, duration, Aur->IsPositive());
|
||||
|
||||
//mod duration of channeled aura by spell haste
|
||||
if (IsChanneledSpell(m_spellInfo))
|
||||
caster->ModSpellCastTime(aurSpellInfo, duration, this);
|
||||
m_originalCaster->ModSpellCastTime(aurSpellInfo, duration, this);
|
||||
|
||||
if(duration != Aur->GetAuraMaxDuration())
|
||||
{
|
||||
@@ -1395,6 +1396,8 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit *unit, const uint32 effectMask, bool
|
||||
// Set aura only when successfully applied
|
||||
if (unit->AddAura(Aur, false))
|
||||
m_spellAura = Aur;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(uint32 effectNumber = 0; effectNumber < 3; ++effectNumber)
|
||||
|
||||
+65
-88
@@ -351,19 +351,19 @@ pAuraHandler AuraHandler[TOTAL_AURAS]=
|
||||
};
|
||||
#undef Aura
|
||||
|
||||
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source, Unit *caster, Item* castItem) :
|
||||
m_caster_guid(0), m_castItemGuid(castItem?castItem->GetGUID():0), m_target(target),
|
||||
m_timeCla(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
|
||||
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isRemoved(false)
|
||||
Aura::Aura(SpellEntry const* spellproto, uint32 effMask, Unit *target, WorldObject *source, Unit *caster, int32 *currentBasePoints, Item* castItem) :
|
||||
m_spellProto(spellproto),
|
||||
m_target(target), m_source(source), m_caster_guid(caster->GetGUID()), m_castItemGuid(castItem ? castItem->GetGUID() : 0),
|
||||
m_applyTime(time(NULL)),
|
||||
m_timeCla(0), m_removeMode(AURA_REMOVE_BY_DEFAULT), m_AuraDRGroup(DIMINISHING_NONE),
|
||||
m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isRemoved(false)
|
||||
{
|
||||
assert(target);
|
||||
|
||||
assert(source);
|
||||
assert(spellproto && spellproto == sSpellStore.LookupEntry( spellproto->Id ) && "`info` must be pointer to sSpellStore element");
|
||||
|
||||
m_auraFlags = effMask;
|
||||
|
||||
m_spellProto = spellproto;
|
||||
|
||||
if(m_spellProto->manaPerSecond || m_spellProto->manaPerSecondPerLevel)
|
||||
m_timeCla = 1000;
|
||||
|
||||
@@ -371,28 +371,15 @@ m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isR
|
||||
|
||||
m_isSingleTargetAura = IsSingleTargetSpell(m_spellProto);
|
||||
|
||||
m_applyTime = time(NULL);
|
||||
|
||||
if(!caster)
|
||||
{
|
||||
m_caster_guid = target->GetGUID();
|
||||
//damage = m_currentBasePoints+1; // stored value-1
|
||||
m_maxduration = target->CalcSpellDuration(m_spellProto);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_caster_guid = caster->GetGUID();
|
||||
|
||||
//damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
|
||||
m_maxduration = caster->CalcSpellDuration(m_spellProto);
|
||||
}
|
||||
//damage = caster->CalculateSpellDamage(m_spellProto,m_effIndex,m_currentBasePoints,target);
|
||||
m_maxduration = caster->CalcSpellDuration(m_spellProto);
|
||||
|
||||
if(m_maxduration == -1 || m_isPassive && m_spellProto->DurationIndex == 0)
|
||||
m_permanent = true;
|
||||
else
|
||||
m_permanent = false;
|
||||
|
||||
Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
|
||||
Player* modOwner = caster->GetSpellModOwner();
|
||||
|
||||
if(!m_permanent && modOwner)
|
||||
{
|
||||
@@ -410,7 +397,7 @@ m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isR
|
||||
if(modOwner)
|
||||
modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, m_procCharges);
|
||||
|
||||
m_isRemovedOnShapeLost = (m_caster_guid==m_target->GetGUID() &&
|
||||
m_isRemovedOnShapeLost = (caster == target &&
|
||||
m_spellProto->Stances &&
|
||||
!(m_spellProto->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT) &&
|
||||
!(m_spellProto->Attributes & SPELL_ATTR_NOT_SHAPESHIFT));
|
||||
@@ -419,39 +406,33 @@ m_auraSlot(MAX_AURAS), m_auraLevel(1), m_procCharges(0), m_stackAmount(1), m_isR
|
||||
{
|
||||
if (m_auraFlags & (uint8(1) << i))
|
||||
{
|
||||
if (currentBasePoints)
|
||||
m_partAuras[i] = CreateAuraEffect(this, i, currentBasePoints + i, caster, NULL, source);
|
||||
else
|
||||
m_partAuras[i] = CreateAuraEffect(this, i, NULL, caster, NULL, source);
|
||||
// correct flags if aura couldn't be created
|
||||
if (!m_partAuras[i])
|
||||
m_auraFlags &= uint8(~(1<< i));
|
||||
if(!(m_partAuras[i] = CreateAuraEffect(this, i, currentBasePoints ? currentBasePoints + i : NULL)))
|
||||
m_auraFlags &= uint8(~(1<< i)); // correct flags if aura couldn't be created
|
||||
}
|
||||
else
|
||||
{
|
||||
m_partAuras[i]=NULL;
|
||||
m_partAuras[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Aura is positive when it is casted by friend and at least one aura is positive
|
||||
// or when it is casted by enemy and at least one aura is negative
|
||||
bool swap=false;
|
||||
if (!caster || caster==target) // caster == target - 1 negative effect is enough for aura to be negative
|
||||
// or when it is casted by enemy and at least one aura is negative
|
||||
bool swap = false;
|
||||
if (caster == target) // caster == target - 1 negative effect is enough for aura to be negative
|
||||
m_positive = false;
|
||||
else
|
||||
m_positive = !caster->IsHostileTo(m_target);
|
||||
for (uint8 i=0;i<MAX_SPELL_EFFECTS;++i)
|
||||
|
||||
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (!(1<<i & GetEffectMask()))
|
||||
continue;
|
||||
if (m_positive == IsPositiveEffect(GetId(), i))
|
||||
if((1<<i & GetEffectMask()) && m_positive == IsPositiveEffect(GetId(), i))
|
||||
{
|
||||
swap = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!swap)
|
||||
m_positive=!m_positive;
|
||||
m_positive = !m_positive;
|
||||
}
|
||||
|
||||
Aura::~Aura()
|
||||
@@ -462,7 +443,7 @@ Aura::~Aura()
|
||||
delete m_partAuras[i];
|
||||
}
|
||||
|
||||
AuraEffect::AuraEffect(Aura * parentAura, uint8 effIndex, int32 * currentBasePoints , Unit *caster, Item* castItem, WorldObject *source) :
|
||||
AuraEffect::AuraEffect(Aura *parentAura, uint8 effIndex, int32 *currentBasePoints) :
|
||||
m_parentAura(parentAura), m_spellmod(NULL), m_periodicTimer(0), m_isPeriodic(false), m_isAreaAura(false), m_isPersistent(false),
|
||||
m_target(parentAura->GetTarget()), m_tickNumber(0)
|
||||
, m_spellProto(parentAura->GetSpellProto()), m_effIndex(effIndex), m_auraName(AuraType(m_spellProto->EffectApplyAuraName[m_effIndex]))
|
||||
@@ -474,6 +455,7 @@ m_target(parentAura->GetTarget()), m_tickNumber(0)
|
||||
else
|
||||
m_currentBasePoints = m_spellProto->EffectBasePoints[m_effIndex];
|
||||
|
||||
Unit *caster = GetParentAura()->GetCaster();
|
||||
if(caster)
|
||||
m_amount = caster->CalculateSpellDamage(m_spellProto, m_effIndex, m_currentBasePoints, m_target);
|
||||
else
|
||||
@@ -482,7 +464,11 @@ m_target(parentAura->GetTarget()), m_tickNumber(0)
|
||||
if (int32 amount = CalculateCrowdControlAuraAmount(caster))
|
||||
m_amount = amount;
|
||||
|
||||
if (!m_amount && castItem && castItem->GetItemSuffixFactor())
|
||||
if(!m_amount && caster)
|
||||
if(uint64 itemGUID = GetParentAura()->GetCastItemGUID())
|
||||
if(Player *playerCaster = dynamic_cast<Player*>(caster))
|
||||
if(Item *castItem = playerCaster->GetItemByGuid(itemGUID))
|
||||
if (castItem->GetItemSuffixFactor())
|
||||
{
|
||||
ItemRandomSuffixEntry const *item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
|
||||
if(item_rand_suffix)
|
||||
@@ -507,7 +493,6 @@ m_target(parentAura->GetTarget()), m_tickNumber(0)
|
||||
}
|
||||
|
||||
Player* modOwner = caster ? caster->GetSpellModOwner() : NULL;
|
||||
m_sourceGUID = source ? source->GetGUID() : (caster ? caster->GetGUID() : 0);
|
||||
m_amplitude = m_spellProto->EffectAmplitude[m_effIndex];
|
||||
|
||||
//apply casting time mods for channeled spells
|
||||
@@ -525,20 +510,20 @@ m_target(parentAura->GetTarget()), m_tickNumber(0)
|
||||
m_isApplied = false;
|
||||
}
|
||||
|
||||
AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster, Item * castItem, Unit * source)
|
||||
: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source)
|
||||
AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints)
|
||||
: AuraEffect(parentAura, effIndex, currentBasePoints)
|
||||
{
|
||||
m_removeTime = FRIENDLY_AA_REMOVE_TIME;
|
||||
m_isAreaAura = true;
|
||||
|
||||
Unit* caster_ptr = caster ? caster : source ? source : m_target;
|
||||
|
||||
if (m_spellProto->Effect[effIndex] == SPELL_EFFECT_APPLY_AREA_AURA_ENEMY)
|
||||
m_radius = GetSpellRadiusForHostile(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
|
||||
else
|
||||
m_radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(GetSpellProto()->EffectRadiusIndex[m_effIndex]));
|
||||
|
||||
if(Player* modOwner = caster_ptr->GetSpellModOwner())
|
||||
Unit *source = GetSource();
|
||||
assert(source);
|
||||
if(Player* modOwner = source->GetSpellModOwner()) // source or caster? should be the same
|
||||
modOwner->ApplySpellMod(GetId(), SPELLMOD_RADIUS, m_radius);
|
||||
|
||||
switch(m_spellProto->Effect[effIndex])
|
||||
@@ -558,7 +543,7 @@ AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * curre
|
||||
break;
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_ENEMY:
|
||||
m_areaAuraType = AREA_AURA_ENEMY;
|
||||
if(m_target == caster_ptr)
|
||||
if(m_target == source)
|
||||
*const_cast<AuraType*>(&m_auraName) = SPELL_AURA_NONE; // Do not do any effect on self
|
||||
break;
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_PET:
|
||||
@@ -566,7 +551,7 @@ AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * curre
|
||||
break;
|
||||
case SPELL_EFFECT_APPLY_AREA_AURA_OWNER:
|
||||
m_areaAuraType = AREA_AURA_OWNER;
|
||||
if(m_target == caster_ptr)
|
||||
if(m_target == source)
|
||||
*const_cast<AuraType*>(&m_auraName) = SPELL_AURA_NONE;
|
||||
break;
|
||||
default:
|
||||
@@ -576,36 +561,34 @@ AreaAuraEffect::AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * curre
|
||||
}
|
||||
}
|
||||
|
||||
AreaAuraEffect::~AreaAuraEffect()
|
||||
{
|
||||
}
|
||||
Unit *AreaAuraEffect::GetSource() const { return dynamic_cast<Unit*>(GetParentAura()->GetSource()); }
|
||||
|
||||
PersistentAreaAuraEffect::PersistentAreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster,Item * castItem, DynamicObject *source)
|
||||
: AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source)
|
||||
PersistentAreaAuraEffect::PersistentAreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints)
|
||||
: AuraEffect(parentAura, effIndex, currentBasePoints)
|
||||
{
|
||||
m_isPersistent = true;
|
||||
}
|
||||
|
||||
PersistentAreaAuraEffect::~PersistentAreaAuraEffect()
|
||||
{
|
||||
}
|
||||
DynamicObject *PersistentAreaAuraEffect::GetSource() const { return dynamic_cast<DynamicObject*>(GetParentAura()->GetSource()); }
|
||||
|
||||
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, WorldObject* source)
|
||||
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints)
|
||||
{
|
||||
// TODO: source should belong to aura, but not areaeffect. multiple areaaura/persistent aura should use one source
|
||||
assert(parentAura);
|
||||
WorldObject *source = parentAura->GetSource();
|
||||
assert(source);
|
||||
if (IsAreaAuraEffect(parentAura->GetSpellProto()->Effect[effIndex]))
|
||||
{
|
||||
if(!source)
|
||||
source = caster;
|
||||
//TODO: determine source here
|
||||
if(source && source->isType(TYPEMASK_UNIT))
|
||||
return new AreaAuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, (Unit*)source);
|
||||
assert(source->isType(TYPEMASK_UNIT));
|
||||
return new AreaAuraEffect(parentAura, effIndex, currentBasePoints);
|
||||
}
|
||||
else if (parentAura->GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_APPLY_AURA)
|
||||
return new AuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem, source);
|
||||
return new AuraEffect(parentAura, effIndex, currentBasePoints);
|
||||
else if (parentAura->GetSpellProto()->Effect[effIndex] == SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
return new PersistentAreaAuraEffect(parentAura, effIndex, currentBasePoints, caster, castItem);
|
||||
{
|
||||
assert(source->isType(TYPEMASK_DYNAMICOBJECT));
|
||||
return new PersistentAreaAuraEffect(parentAura, effIndex, currentBasePoints);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -620,18 +603,6 @@ Unit* Aura::GetCaster() const
|
||||
return unit && unit->IsInWorld() ? unit : NULL;
|
||||
}
|
||||
|
||||
Unit* AuraEffect::GetSource() const
|
||||
{
|
||||
if(m_sourceGUID == m_target->GetGUID())
|
||||
return m_target;
|
||||
|
||||
//return ObjectAccessor::GetUnit(*m_target,m_caster_guid);
|
||||
//must return caster even if it's in another grid/map
|
||||
Unit *unit = ObjectAccessor::GetObjectInWorld(m_sourceGUID, (Unit*)NULL);
|
||||
//only player can be not in world while in objectaccessor
|
||||
return unit && unit->IsInWorld() ? unit : NULL;
|
||||
}
|
||||
|
||||
void Aura::Update(uint32 diff)
|
||||
{
|
||||
// TODO: store pointer to caster in aura class for update/mod handling code
|
||||
@@ -721,10 +692,16 @@ void AuraEffect::Update(uint32 diff)
|
||||
|
||||
void AreaAuraEffect::Update(uint32 diff)
|
||||
{
|
||||
// update for the caster of the aura
|
||||
if(m_sourceGUID == m_target->GetGUID())
|
||||
Unit *source = GetSource();
|
||||
if(!source) // this should never happen
|
||||
{
|
||||
m_target->RemoveAura(GetParentAura());
|
||||
return;
|
||||
}
|
||||
|
||||
// update for the source of the aura
|
||||
if(source == m_target)
|
||||
{
|
||||
Unit *source = m_target;
|
||||
Unit *caster = GetCaster();
|
||||
if (!caster)
|
||||
{
|
||||
@@ -797,7 +774,7 @@ void AreaAuraEffect::Update(uint32 diff)
|
||||
// Check if basepoints can be safely reduced
|
||||
if (newBp == m_spellProto->EffectBasePoints[m_effIndex])
|
||||
newBp = actualSpellInfo->EffectBasePoints[m_effIndex];
|
||||
(*tIter)->AddAuraEffect(actualSpellInfo, GetEffIndex(), caster, &newBp, source);
|
||||
(*tIter)->AddAuraEffect(actualSpellInfo, GetEffIndex(), source, caster, &newBp);
|
||||
|
||||
if(m_areaAuraType == AREA_AURA_ENEMY)
|
||||
caster->CombatStart(*tIter);
|
||||
@@ -1497,8 +1474,8 @@ bool Aura::IsVisible() const
|
||||
{
|
||||
if(m_partAuras[i]->IsAreaAura())
|
||||
{
|
||||
if(WorldObject *source = m_partAuras[i]->GetSource())
|
||||
if(source->GetTypeId() == TYPEID_UNIT && ((Creature*)source)->isTotem())
|
||||
if(Unit *source = ((AreaAuraEffect*)m_partAuras[i])->GetSource())
|
||||
if(source->isTotem())
|
||||
return true;
|
||||
|
||||
if(m_partAuras[i]->GetAuraName() != SPELL_AURA_NONE)
|
||||
@@ -1842,13 +1819,13 @@ bool Aura::IsAuraType(AuraType type) const
|
||||
|
||||
void Aura::SetLoadedState(uint64 caster_guid,int32 maxduration,int32 duration,int32 charges, uint8 stackamount, int32 * amount)
|
||||
{
|
||||
m_caster_guid = caster_guid;
|
||||
*const_cast<uint64*>(&m_caster_guid) = caster_guid;
|
||||
m_maxduration = maxduration;
|
||||
m_duration = duration;
|
||||
m_procCharges = charges;
|
||||
m_stackAmount = stackamount;
|
||||
for (uint8 i=0; i<MAX_SPELL_EFFECTS;++i)
|
||||
if (m_partAuras[i])
|
||||
for(uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
if(m_partAuras[i])
|
||||
m_partAuras[i]->SetAmount(amount[i]);
|
||||
}
|
||||
|
||||
@@ -6622,7 +6599,7 @@ void AuraEffect::HandleAuraControlVehicle(bool apply, bool Real, bool /*changeAm
|
||||
if(!m_target->IsVehicle())
|
||||
return;
|
||||
|
||||
Unit *caster = GetSource();
|
||||
Unit *caster = dynamic_cast<Unit*>(GetParentAura()->GetSource());
|
||||
if(!caster || caster == m_target)
|
||||
return;
|
||||
|
||||
|
||||
+18
-15
@@ -54,7 +54,7 @@ class TRINITY_DLL_SPEC Aura
|
||||
friend void Player::SendAurasForTarget(Unit *target);
|
||||
public:
|
||||
virtual ~Aura();
|
||||
explicit Aura(SpellEntry const* spellproto, uint32 effMask, int32 *currentBasePoints, Unit *target, WorldObject *source = NULL, Unit *caster = NULL, Item *castItem = NULL);
|
||||
explicit Aura(SpellEntry const* spellproto, uint32 effMask, Unit *target, WorldObject *source, Unit *caster, int32 *currentBasePoints = NULL, Item *castItem = NULL);
|
||||
|
||||
SpellEntry const* GetSpellProto() const { return m_spellProto; }
|
||||
uint32 GetId() const{ return m_spellProto->Id; }
|
||||
@@ -63,6 +63,7 @@ class TRINITY_DLL_SPEC Aura
|
||||
uint64 const& GetCasterGUID() const { return m_caster_guid; }
|
||||
Unit* GetCaster() const;
|
||||
Unit* GetTarget() const { return m_target; }
|
||||
WorldObject *GetSource() const { return m_source; }
|
||||
time_t GetAuraApplyTime() const { return m_applyTime; }
|
||||
|
||||
int32 GetAuraMaxDuration() const { return m_maxduration; }
|
||||
@@ -133,11 +134,12 @@ class TRINITY_DLL_SPEC Aura
|
||||
void SetIsSingleTarget(bool val) { m_isSingleTargetAura = val;}
|
||||
|
||||
private:
|
||||
SpellEntry const *m_spellProto;
|
||||
const SpellEntry * const m_spellProto;
|
||||
Unit * const m_target;
|
||||
uint64 m_caster_guid;
|
||||
uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
|
||||
time_t m_applyTime;
|
||||
WorldObject * const m_source;
|
||||
const uint64 m_caster_guid;
|
||||
const uint64 m_castItemGuid; // it is NOT safe to keep a pointer to the item because it may get deleted
|
||||
const time_t m_applyTime;
|
||||
|
||||
int32 m_maxduration; // Max aura duration
|
||||
int32 m_duration; // Current time
|
||||
@@ -169,7 +171,7 @@ class TRINITY_DLL_SPEC Aura
|
||||
class TRINITY_DLL_SPEC AuraEffect
|
||||
{
|
||||
public:
|
||||
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit * caster, Item * castItem, WorldObject *source);
|
||||
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
|
||||
friend void Aura::SetStackAmount(uint8 stackAmount, bool applied);
|
||||
//aura handlers
|
||||
void HandleNULL(bool, bool, bool)
|
||||
@@ -338,7 +340,6 @@ class TRINITY_DLL_SPEC AuraEffect
|
||||
|
||||
Unit * GetCaster() const { return m_parentAura->GetCaster(); }
|
||||
uint64 GetCasterGUID() const{ return m_parentAura->GetCasterGUID(); }
|
||||
Unit* GetSource() const; // { return m_parentAura->GetSource(); }
|
||||
Aura * GetParentAura() const { return m_parentAura; }
|
||||
|
||||
SpellEntry const* GetSpellProto() const { return m_spellProto; }
|
||||
@@ -378,10 +379,9 @@ class TRINITY_DLL_SPEC AuraEffect
|
||||
void CleanupTriggeredSpells();
|
||||
|
||||
protected:
|
||||
explicit AuraEffect(Aura * parentAura, uint8 effIndex, int32 *currentBasePoints , Unit *caster, Item *castItem, WorldObject *source);
|
||||
explicit AuraEffect(Aura * parentAura, uint8 effIndex, int32 *currentBasePoints = NULL);
|
||||
Aura * const m_parentAura;
|
||||
Unit * const m_target;
|
||||
uint64 m_sourceGUID; // Spell::m_caster/trap? for normal aura, totem/paladin for areaaura, dynobj for persistent aura
|
||||
|
||||
uint32 m_tickNumber;
|
||||
|
||||
@@ -405,10 +405,11 @@ class TRINITY_DLL_SPEC AuraEffect
|
||||
class TRINITY_DLL_SPEC AreaAuraEffect : public AuraEffect
|
||||
{
|
||||
public:
|
||||
AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 * currentBasePoints, Unit * caster=NULL, Item * castItem=NULL, Unit * source = NULL);
|
||||
~AreaAuraEffect();
|
||||
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
|
||||
void Update(uint32 diff);
|
||||
private:
|
||||
Unit *GetSource() const;
|
||||
protected:
|
||||
explicit AreaAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints = NULL);
|
||||
float m_radius;
|
||||
int32 m_removeTime;
|
||||
AreaAuraType m_areaAuraType;
|
||||
@@ -417,11 +418,13 @@ class TRINITY_DLL_SPEC AreaAuraEffect : public AuraEffect
|
||||
class TRINITY_DLL_SPEC PersistentAreaAuraEffect : public AuraEffect
|
||||
{
|
||||
public:
|
||||
PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints, Unit *caster = NULL, Item* castItem = NULL, DynamicObject * source = NULL);
|
||||
~PersistentAreaAuraEffect();
|
||||
friend AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints);
|
||||
void Update(uint32 diff);
|
||||
DynamicObject *GetSource() const;
|
||||
protected:
|
||||
explicit PersistentAreaAuraEffect(Aura * parentAura, uint32 eff, int32 *currentBasePoints = NULL);
|
||||
};
|
||||
|
||||
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints, Unit *caster, Item *castItem = NULL, WorldObject *source = NULL);
|
||||
AuraEffect* CreateAuraEffect(Aura * parentAura, uint32 effIndex, int32 *currentBasePoints = NULL);
|
||||
|
||||
#endif
|
||||
|
||||
+15
-17
@@ -4023,7 +4023,7 @@ void Unit::RemoveAurasDueToSpellBySteal(uint32 spellId, uint64 casterGUID, Unit
|
||||
damage[i]=NULL;
|
||||
}
|
||||
int32 dur = 2*MINUTE*IN_MILISECONDS < aur->GetAuraDuration() ? 2*MINUTE*IN_MILISECONDS : aur->GetAuraDuration();
|
||||
Aura * new_aur = new Aura(aur->GetSpellProto(),aur->GetEffectMask(), NULL, stealer, stealer, NULL);
|
||||
Aura * new_aur = new Aura(aur->GetSpellProto(),aur->GetEffectMask(), stealer, stealer, stealer);
|
||||
new_aur->SetLoadedState(aur->GetCasterGUID(), dur, dur, aur->GetAuraCharges(), aur->GetStackAmount(), &damage[0]);
|
||||
|
||||
// Unregister _before_ adding to stealer
|
||||
@@ -6214,7 +6214,7 @@ bool Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, AuraEffect* trigger
|
||||
// Light's Beacon - Beacon of Light
|
||||
if ( dummySpell->Id == 53651 )
|
||||
{
|
||||
if (Unit * source = triggeredByAura->GetSource())
|
||||
if (Unit *source = dynamic_cast<Unit*>(triggeredByAura->GetParentAura()->GetSource()))
|
||||
{
|
||||
// do not proc when target of beacon of light is healed
|
||||
if (source == this)
|
||||
@@ -8877,18 +8877,16 @@ Unit* Unit::SelectMagnetTarget(Unit *victim, SpellEntry const *spellInfo)
|
||||
|
||||
Unit::AuraEffectList const& magnetAuras = victim->GetAurasByType(SPELL_AURA_SPELL_MAGNET);
|
||||
for(Unit::AuraEffectList::const_iterator itr = magnetAuras.begin(); itr != magnetAuras.end(); ++itr)
|
||||
if(Unit* magnet = (*itr)->IsAreaAura() ? ((AreaAuraEffect*)(*itr))->GetSource():(*itr)->GetCaster() )
|
||||
if(magnet->isAlive())
|
||||
{
|
||||
return magnet;
|
||||
}
|
||||
if(Unit* magnet = dynamic_cast<Unit*>((*itr)->GetParentAura()->GetSource()))
|
||||
if(magnet->isAlive())
|
||||
return magnet;
|
||||
}
|
||||
// Melee && ranged case
|
||||
else
|
||||
{
|
||||
AuraEffectList const& hitTriggerAuras = victim->GetAurasByType(SPELL_AURA_ADD_CASTER_HIT_TRIGGER);
|
||||
for(AuraEffectList::const_iterator i = hitTriggerAuras.begin(); i != hitTriggerAuras.end(); ++i)
|
||||
if(Unit* magnet = (*i)->IsAreaAura() ? ((AreaAuraEffect*)(*i))->GetSource():(*i)->GetCaster() )
|
||||
if(Unit* magnet = dynamic_cast<Unit*>((*i)->GetParentAura()->GetSource()))
|
||||
if(magnet->isAlive() && magnet->IsWithinLOSInMap(this))
|
||||
if(roll_chance_i((*i)->GetAmount()))
|
||||
{
|
||||
@@ -14506,7 +14504,7 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::AddAura(uint32 spellId, Unit* target)
|
||||
void Unit::AddAura(uint32 spellId, Unit *target)
|
||||
{
|
||||
if(!target || !target->isAlive())
|
||||
return;
|
||||
@@ -14533,8 +14531,8 @@ void Unit::AddAura(uint32 spellId, Unit* target)
|
||||
if (!eff_mask)
|
||||
return;
|
||||
|
||||
//TODO: we use target as source for now, but that may not be true
|
||||
Aura *Aur = new Aura(spellInfo, eff_mask, NULL, target, target, this, NULL);
|
||||
// Because source is not give, use caster as source
|
||||
Aura *Aur = new Aura(spellInfo, eff_mask, target, this, this);
|
||||
target->AddAura(Aur);
|
||||
}
|
||||
|
||||
@@ -14550,7 +14548,7 @@ void Unit::SetAuraStack(uint32 spellId, Unit *target, uint32 stack)
|
||||
aur->SetStackAmount(stack);
|
||||
}
|
||||
|
||||
Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, Unit* caster, int32 * basePoints, Unit * source)
|
||||
Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, WorldObject *source, Unit* caster, int32 * basePoints)
|
||||
{
|
||||
// can't do that for passive auras - they stack from same caster so there is no way to get exact aura which should get effect
|
||||
//assert (!IsPassiveSpell(spellInfo));
|
||||
@@ -14561,9 +14559,9 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, Unit* c
|
||||
|
||||
if (aur)
|
||||
{
|
||||
AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints, caster,NULL, source);
|
||||
if (aurEffect && !aur->SetPartAura(aurEffect, effIndex))
|
||||
delete aurEffect;
|
||||
if(AuraEffect *aurEffect = CreateAuraEffect(aur, effIndex, basePoints))
|
||||
if(!aur->SetPartAura(aurEffect, effIndex))
|
||||
delete aurEffect;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -14571,10 +14569,10 @@ Aura * Unit::AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, Unit* c
|
||||
{
|
||||
int32 amount[MAX_SPELL_EFFECTS];
|
||||
amount[effIndex] = *basePoints;
|
||||
aur = new Aura(spellInfo, 1<<effIndex, amount, this, source, caster, NULL);
|
||||
aur = new Aura(spellInfo, 1<<effIndex, this, source, caster, amount, NULL);
|
||||
}
|
||||
else
|
||||
aur = new Aura(spellInfo, 1<<effIndex, NULL, this, source ,caster, NULL);
|
||||
aur = new Aura(spellInfo, 1<<effIndex, this, source, caster, NULL, NULL);
|
||||
|
||||
if(!AddAura(aur))
|
||||
return NULL;
|
||||
|
||||
+1
-1
@@ -1363,7 +1363,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
|
||||
void AddAura(uint32 spellId, Unit *target);
|
||||
void SetAuraStack(uint32 spellId, Unit *target, uint32 stack);
|
||||
void HandleAuraEffect(AuraEffect * aureff, bool apply);
|
||||
Aura *AddAuraEffect(const SpellEntry * spellInfo, uint8 effIndex, Unit* caster, int32 * basePoints=NULL, Unit * source=NULL);
|
||||
Aura *AddAuraEffect(const SpellEntry *spellInfo, uint8 effIndex, WorldObject *source, Unit *caster, int32 *basePoints = NULL);
|
||||
|
||||
bool IsDamageToThreatSpell(SpellEntry const * spellInfo) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user