*Use one dynobj to handle multiple aura effects.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-08-27 16:41:10 -05:00
parent d829014920
commit ee3c766bc9
8 changed files with 48 additions and 51 deletions
+6 -7
View File
@@ -53,7 +53,7 @@ void DynamicObject::RemoveFromWorld()
///- Remove the dynamicObject from the accessor
if(IsInWorld())
{
if(m_effIndex == 4)
if(m_isWorldObject)
{
if(Unit *caster = GetCaster())
{
@@ -70,7 +70,7 @@ void DynamicObject::RemoveFromWorld()
}
}
bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius )
bool DynamicObject::Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active)
{
SetMap(caster->GetMap());
@@ -78,7 +78,7 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
if(!IsPositionValid())
{
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effIndex,GetPositionX(),GetPositionY());
sLog.outError("DynamicObject (spell %u eff %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)",spellId,effMask,GetPositionX(),GetPositionY());
return false;
}
@@ -97,12 +97,11 @@ bool DynamicObject::Create( uint32 guidlow, Unit *caster, uint32 spellId, uint32
m_aliveDuration = duration;
m_radius = radius;
m_effIndex = effIndex;
m_effMask = effMask;
m_spellId = spellId;
m_updateTimer = 0;
if(m_effIndex == 4)
m_isWorldObject = true;
m_isWorldObject = active;
return true;
}
@@ -129,7 +128,7 @@ void DynamicObject::Update(uint32 p_time)
else
deleteThis = true;
if(m_effIndex < 4)
if(m_effMask)
{
if(m_updateTimer < p_time)
{
+5 -3
View File
@@ -35,11 +35,13 @@ class DynamicObject : public WorldObject
void AddToWorld();
void RemoveFromWorld();
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effIndex, float x, float y, float z, int32 duration, float radius);
bool Create(uint32 guidlow, Unit *caster, uint32 spellId, uint32 effMask, float x, float y, float z, int32 duration, float radius, bool active);
void Update(uint32 p_time);
void Delete();
uint32 GetSpellId() const { return m_spellId; }
uint32 GetEffIndex() const { return m_effIndex; }
uint32 GetEffectMask() const { return m_effMask; }
void AddEffect(uint32 effIndex) { m_effMask |= (1<<effIndex); }
bool HasEffect(uint32 effIndex) const { return m_effMask & (1<<effIndex); }
uint32 GetDuration() const { return m_aliveDuration; }
uint64 GetCasterGUID() const { return GetUInt64Value(DYNAMICOBJECT_CASTER); }
Unit* GetCaster() const;
@@ -59,7 +61,7 @@ class DynamicObject : public WorldObject
GridReference<DynamicObject> &GetGridRef() { return m_gridRef; }
protected:
uint32 m_spellId;
uint32 m_effIndex;
uint32 m_effMask;
int32 m_aliveDuration;
uint32 m_updateTimer;
time_t m_nextThinkTime;
+15 -6
View File
@@ -178,8 +178,16 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
if (i_dynobject.IsAffecting(target))
return;
uint32 eff_index = i_dynobject.GetEffIndex();
if(target->HasAuraEffect(i_dynobject.GetSpellId(), eff_index, i_check->GetGUID()))
if(target->HasAura(i_dynobject.GetSpellId(), i_check->GetGUID()))
return;
uint32 eff_index = 0;
for(; eff_index < MAX_SPELL_EFFECTS; ++eff_index)
if(i_dynobject.HasEffect(eff_index))
break;
if(eff_index == MAX_SPELL_EFFECTS)
return;
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i_dynobject.GetSpellId());
@@ -207,11 +215,12 @@ inline void Trinity::DynamicObjectUpdater::VisitHelper(Unit* target)
// Check target immune to spell or aura
if (target->IsImmunedToSpell(spellInfo) || target->IsImmunedToSpellEffect(spellInfo, eff_index))
return;
// Apply PersistentAreaAura on target
if(Aura *aur = target->AddAuraEffect(spellInfo, eff_index, &i_dynobject, i_dynobject.GetCaster()))
aur->SetAuraDuration(i_dynobject.GetDuration());
i_dynobject.AddAffected(target);
// Apply PersistentAreaAura on target
Aura *aur = new Aura(spellInfo, i_dynobject.GetEffectMask(), target, &i_dynobject, i_check);
aur->SetAuraDuration(i_dynobject.GetDuration());
if(target->AddAura(aur, true))
i_dynobject.AddAffected(target);
}
template<>
+4 -7
View File
@@ -450,6 +450,7 @@ Spell::Spell( Unit* Caster, SpellEntry const *info, bool triggered, uint64 origi
m_preCastSpell = 0;
m_triggeredByAuraSpell = NULL;
m_spellAura = NULL;
m_spellDynObj = NULL;
//Auto Shot & Shoot (wand)
m_autoRepeat = IsAutoRepeatRangedSpell(m_spellInfo);
@@ -6048,13 +6049,9 @@ void Spell::DelayedChannel()
}
}
for(int j = 0; j < 3; ++j)
{
// partially interrupt persistent area auras
DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id, j);
if(dynObj)
dynObj->Delay(delaytime);
}
// partially interrupt persistent area auras
if(DynamicObject* dynObj = m_caster->GetDynObject(m_spellInfo->Id))
dynObj->Delay(delaytime);
SendChannelUpdate(m_timer);
}
+2
View File
@@ -27,6 +27,7 @@
class Unit;
class Player;
class GameObject;
class DynamicObject;
class Aura;
enum SpellCastTargetFlags
@@ -555,6 +556,7 @@ class Spell
GameObject* gameObjTarget;
int32 damage;
Aura * m_spellAura; // only used in DoAllEffectOnTarget
DynamicObject *m_spellDynObj; // only used in DoAllEffectOnTarget
// this is set in Spell Hit, but used in Apply Aura handler
DiminishingLevels m_diminishLevel;
+10 -2
View File
@@ -2926,6 +2926,13 @@ void Spell::EffectCreateRandomItem(uint32 i)
void Spell::EffectPersistentAA(uint32 i)
{
if(m_spellDynObj)
{
assert(ObjectAccessor::GetObjectInWorld(m_spellDynObj->GetGUID(), (DynamicObject*)NULL) == m_spellDynObj);
m_spellDynObj->AddEffect(i);
return;
}
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
if(Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius);
@@ -2933,7 +2940,7 @@ void Spell::EffectPersistentAA(uint32 i)
Unit *caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), caster, m_spellInfo->Id, 1<<i, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, false))
{
delete dynObj;
return;
@@ -2941,6 +2948,7 @@ void Spell::EffectPersistentAA(uint32 i)
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
caster->AddDynObject(dynObj);
dynObj->GetMap()->Add(dynObj);
m_spellDynObj = dynObj;
}
void Spell::EffectEnergize(uint32 i)
@@ -3718,7 +3726,7 @@ void Spell::EffectAddFarsight(uint32 i)
float radius = GetSpellRadiusForFriend(sSpellRadiusStore.LookupEntry(m_spellInfo->EffectRadiusIndex[i]));
int32 duration = GetSpellDuration(m_spellInfo);
DynamicObject* dynObj = new DynamicObject;
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 4, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius))
if(!dynObj->Create(objmgr.GenerateLowGuid(HIGHGUID_DYNAMICOBJECT), m_caster, m_spellInfo->Id, 0, m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ, duration, radius, true))
{
delete dynObj;
return;
+6 -25
View File
@@ -4109,6 +4109,10 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode)
++m_removedAurasCount;
if(Aur->IsPersistent())
if(DynamicObject *dynObj = ObjectAccessor::GetObjectInWorld(Aur->GetSourceGUID(), (DynamicObject*)NULL))
dynObj->RemoveAffected(this);
Aur->UnregisterSingleCastAura();
if(Aur->GetSpellProto()->AuraInterruptFlags)
@@ -4428,24 +4432,6 @@ void Unit::RemoveAllDynObjects()
}
}
DynamicObject * Unit::GetDynObject(uint32 spellId, uint32 effIndex)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
{
DynamicObject* dynObj = GetMap()->GetDynamicObject(*i);
if(!dynObj)
{
i = m_dynObjGUIDs.erase(i);
continue;
}
if (dynObj->GetSpellId() == spellId && dynObj->GetEffIndex() == effIndex)
return dynObj;
++i;
}
return NULL;
}
DynamicObject * Unit::GetDynObject(uint32 spellId)
{
for (DynObjectGUIDs::iterator i = m_dynObjGUIDs.begin(); i != m_dynObjGUIDs.end();)
@@ -14489,17 +14475,12 @@ void Unit::HandleAuraEffect(AuraEffect * aureff, bool apply)
{
if (!aureff->IsApplied())
return;
aureff->SetApplied(false);
// remove from list before mods removing (prevent cyclic calls, mods added before including to aura list - use reverse order)
m_modAuras[aureff->GetAuraName()].remove(aureff);
aureff->ApplyModifier(false, true);
Unit * caster = aureff->GetParentAura()->GetCaster();
if(caster && aureff->IsPersistent())
{
DynamicObject *dynObj = caster->GetDynObject(aureff->GetId(), aureff->GetEffIndex());
if (dynObj)
dynObj->RemoveAffected(this);
}
// Remove all triggered by aura spells vs unlimited duration
aureff->CleanupTriggeredSpells();
}
-1
View File
@@ -1688,7 +1688,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
DynamicObject* GetDynObject(uint32 spellId, uint32 effIndex);
DynamicObject* GetDynObject(uint32 spellId);
void AddDynObject(DynamicObject* dynObj);
void RemoveDynObject(uint32 spellid);