don't save auras casted by items

This commit is contained in:
hondacrx
2017-11-22 12:34:00 -05:00
parent d02d893d15
commit caca2dcb7e
6 changed files with 39 additions and 79 deletions
+1 -1
View File
@@ -534,7 +534,7 @@ namespace Game.Entities
AuraLoadEffectInfo info = effectInfo[key];
ObjectGuid castId = ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, GetMapId(), spellInfo.Id, GetMap().GenerateLowGuid(HighGuid.Cast));
Aura aura = Aura.TryCreate(spellInfo, castId, key.EffectMask, this, null, info.BaseAmounts, null, casterGuid, castItemLevel);
Aura aura = Aura.TryCreate(spellInfo, castId, key.EffectMask, this, null, info.BaseAmounts, null, casterGuid, itemGuid, castItemLevel);
if (aura != null)
{
if (!aura.CanBeSaved())
+6 -7
View File
@@ -4161,7 +4161,7 @@ namespace Game.Entities
}
}
}
public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, int castItemLevel = -1)
public Aura _TryStackingOrRefreshingExistingAura(SpellInfo newAura, uint effMask, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{
Contract.Assert(!casterGUID.IsEmpty() || caster);
@@ -4173,15 +4173,14 @@ namespace Game.Entities
if (!newAura.IsMultiSlotAura())
{
// check if cast item changed
ObjectGuid castItemGUID = ObjectGuid.Empty;
if (castItem != null)
{
castItemGUID = castItem.GetGUID();
castItemGuid = castItem.GetGUID();
castItemLevel = (int)castItem.GetItemLevel(castItem.GetOwner());
}
// find current aura from spell and change it's stackamount, or refresh it's duration
Aura foundAura = GetOwnedAura(newAura.Id, casterGUID, (newAura.HasAttribute(SpellCustomAttributes.EnchantProc) ? castItemGUID : ObjectGuid.Empty), 0);
Aura foundAura = GetOwnedAura(newAura.Id, casterGUID, (newAura.HasAttribute(SpellCustomAttributes.EnchantProc) ? castItemGuid : ObjectGuid.Empty), 0);
if (foundAura != null)
{
// effect masks do not match
@@ -4211,10 +4210,10 @@ namespace Game.Entities
}
// correct cast item guid if needed
if (castItemGUID != foundAura.GetCastItemGUID())
if (castItemGuid != foundAura.GetCastItemGUID())
{
castItemGUID = foundAura.GetCasterGUID();
castItemLevel = foundAura.GetCastItemLevel();
foundAura.SetCastItemGUID(castItemGuid);
foundAura.SetCastItemLevel(castItemLevel);
}
// try to increase stack amount
+30 -16
View File
@@ -282,12 +282,12 @@ namespace Game.Spells
{
const int UPDATE_TARGET_MAP_INTERVAL = 500;
public Aura(SpellInfo spellproto, ObjectGuid castId, WorldObject owner, Unit caster, Item castItem, ObjectGuid casterGUID, int castItemLevel)
public Aura(SpellInfo spellproto, ObjectGuid castId, WorldObject owner, Unit caster, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel)
{
m_spellInfo = spellproto;
m_castGuid = castId;
m_casterGuid = !casterGUID.IsEmpty() ? casterGUID : caster.GetGUID();
m_castItemGuid = castItem != null ? castItem.GetGUID() : ObjectGuid.Empty;
m_castItemGuid = castItem != null ? castItem.GetGUID() : castItemGuid;
m_castItemLevel = castItemLevel;
m_spellXSpellVisualId = caster ? caster.GetCastSpellXSpellVisualId(spellproto) : spellproto.GetSpellXSpellVisualId();
m_applyTime = Time.UnixTime;
@@ -971,6 +971,10 @@ namespace Game.Spells
if (IsUsingCharges() && GetCharges() == 0)
return false;
// don't save permanent auras triggered by items, they'll be recasted on login if necessary
if (!GetCastItemGUID().IsEmpty() && IsPermanent())
return false;
return true;
}
@@ -2279,6 +2283,16 @@ namespace Game.Spells
return m_owner.ToDynamicObject();
}
public void SetCastItemGUID(ObjectGuid guid)
{
m_castItemGuid = guid;
}
public void SetCastItemLevel(int level)
{
m_castItemLevel = level;
}
public void _RegisterForTargets()
{
Unit caster = GetCaster();
@@ -2403,12 +2417,12 @@ namespace Game.Spells
}
return (effMask & availableEffectMask);
}
public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, int castItemLevel = -1)
public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount = null, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{
bool throwway;
return TryRefreshStackOrCreate(spellproto, castId, tryEffMask, owner, caster, out throwway, baseAmount, castItem, casterGUID, resetPeriodicTimer, castItemLevel);
return TryRefreshStackOrCreate(spellproto, castId, tryEffMask, owner, caster, out throwway, baseAmount, castItem, casterGUID, resetPeriodicTimer, castItemGuid, castItemLevel);
}
public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, out bool refresh, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, int castItemLevel = -1)
public static Aura TryRefreshStackOrCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, out bool refresh, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), bool resetPeriodicTimer = true, ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{
Contract.Assert(spellproto != null);
Contract.Assert(owner != null);
@@ -2419,7 +2433,7 @@ namespace Game.Spells
uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (effMask == 0)
return null;
Aura foundAura = owner.ToUnit()._TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, resetPeriodicTimer, castItemLevel);
Aura foundAura = owner.ToUnit()._TryStackingOrRefreshingExistingAura(spellproto, effMask, caster, baseAmount, castItem, casterGUID, resetPeriodicTimer, castItemGuid, castItemLevel);
if (foundAura != null)
{
// we've here aura, which script triggered removal after modding stack amount
@@ -2431,9 +2445,9 @@ namespace Game.Spells
return foundAura;
}
else
return Create(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemLevel);
return Create(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel);
}
public static Aura TryCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), int castItemLevel = -1)
public static Aura TryCreate(SpellInfo spellproto, ObjectGuid castId, uint tryEffMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem = null, ObjectGuid casterGUID = default(ObjectGuid), ObjectGuid castItemGuid = default(ObjectGuid), int castItemLevel = -1)
{
Contract.Assert(spellproto != null);
Contract.Assert(owner != null);
@@ -2442,9 +2456,9 @@ namespace Game.Spells
uint effMask = BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (effMask == 0)
return null;
return Create(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemLevel);
return Create(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel);
}
public static Aura Create(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, int castItemLevel)
public static Aura Create(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel)
{
Contract.Assert(effMask != 0);
Contract.Assert(spellproto != null);
@@ -2474,10 +2488,10 @@ namespace Game.Spells
{
case TypeId.Unit:
case TypeId.Player:
aura = new UnitAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemLevel);
aura = new UnitAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel);
break;
case TypeId.DynamicObject:
aura = new DynObjAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemLevel);
aura = new DynObjAura(spellproto, castId, effMask, owner, caster, baseAmount, castItem, casterGUID, castItemGuid, castItemLevel);
break;
default:
Contract.Assert(false);
@@ -2531,8 +2545,8 @@ namespace Game.Spells
public class UnitAura : Aura
{
public UnitAura(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, int castItemLevel)
: base(spellproto, castId, owner, caster, castItem, casterGUID, castItemLevel)
public UnitAura(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel)
: base(spellproto, castId, owner, caster, castItem, casterGUID, castItemGuid, castItemLevel)
{
m_AuraDRGroup = DiminishingGroup.None;
LoadScripts();
@@ -2642,8 +2656,8 @@ namespace Game.Spells
public class DynObjAura : Aura
{
public DynObjAura(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, int castItemLevel)
: base(spellproto, castId, owner, caster, castItem, casterGUID, castItemLevel)
public DynObjAura(SpellInfo spellproto, ObjectGuid castId, uint effMask, WorldObject owner, Unit caster, int[] baseAmount, Item castItem, ObjectGuid casterGUID, ObjectGuid castItemGuid, int castItemLevel)
: base(spellproto, castId, owner, caster, castItem, casterGUID, castItemGuid, castItemLevel)
{
LoadScripts();
Contract.Assert(GetDynobjOwner() != null);
+1 -1
View File
@@ -2167,7 +2167,7 @@ namespace Game.Spells
bool refresh = false;
bool resetPeriodicTimer = !_triggeredCastFlags.HasAnyFlag(TriggerCastFlags.DontResetPeriodicTimer);
m_spellAura = Aura.TryRefreshStackOrCreate(aurSpellInfo, m_castId, (byte)effectMask, unit,
m_originalCaster, out refresh, (aurSpellInfo == m_spellInfo) ? m_spellValue.EffectBasePoints : basePoints, m_CastItem, ObjectGuid.Empty, resetPeriodicTimer, m_castItemLevel);
m_originalCaster, out refresh, (aurSpellInfo == m_spellInfo) ? m_spellValue.EffectBasePoints : basePoints, m_CastItem, ObjectGuid.Empty, resetPeriodicTimer, ObjectGuid.Empty, m_castItemLevel);
if (m_spellAura != null)
{
// Set aura stack amount to desired value
+1 -1
View File
@@ -1247,7 +1247,7 @@ namespace Game.Spells
if (!dynObj.CreateDynamicObject(caster.GetMap().GenerateLowGuid(HighGuid.DynamicObject), caster, m_spellInfo, destTarget, radius, DynamicObjectType.AreaSpell, m_SpellVisual))
return;
Aura aura = Aura.TryCreate(m_spellInfo, m_castId, SpellConst.MaxEffectMask, dynObj, caster, m_spellValue.EffectBasePoints, null, ObjectGuid.Empty, m_castItemLevel);
Aura aura = Aura.TryCreate(m_spellInfo, m_castId, SpellConst.MaxEffectMask, dynObj, caster, m_spellValue.EffectBasePoints, null, ObjectGuid.Empty, ObjectGuid.Empty, m_castItemLevel);
if (aura != null)
{
m_spellAura = aura;