Core/Spells: Refactor building SMSG_SPELL_EXECUTE_LOG to not create 192 empty vectors on every spell cast

Port From (https://github.com/TrinityCore/TrinityCore/commit/bc2c76a5b8b4a6e5c1d6e65d367c700e4ef1cbf2)
This commit is contained in:
hondacrx
2021-08-30 15:46:45 -04:00
parent 85f7edc339
commit 6e9451082d
3 changed files with 116 additions and 139 deletions
@@ -18,6 +18,7 @@
using Framework.Constants; using Framework.Constants;
using Framework.Dynamic; using Framework.Dynamic;
using Game.Entities; using Game.Entities;
using Game.Spells;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -190,18 +191,6 @@ namespace Game.Networking.Packets
public ObjectGuid Caster; public ObjectGuid Caster;
public uint SpellID; public uint SpellID;
public List<SpellLogEffect> Effects = new(); public List<SpellLogEffect> Effects = new();
public class SpellLogEffect
{
public int Effect;
public List<SpellLogEffectPowerDrainParams> PowerDrainTargets = new();
public List<SpellLogEffectExtraAttacksParams> ExtraAttacksTargets = new();
public List<SpellLogEffectDurabilityDamageParams> DurabilityDamageTargets = new();
public List<SpellLogEffectGenericVictimParams> GenericVictimTargets = new();
public List<SpellLogEffectTradeSkillItemParams> TradeSkillTargets = new();
public List<SpellLogEffectFeedPetParams> FeedPetTargets = new();
}
} }
class SpellHealLog : CombatLogServerPacket class SpellHealLog : CombatLogServerPacket
@@ -639,9 +628,9 @@ namespace Game.Networking.Packets
public uint OriginalDamage; public uint OriginalDamage;
public bool Unk; public bool Unk;
} }
//Structs //Structs
struct SpellLogEffectPowerDrainParams public struct SpellLogEffectPowerDrainParams
{ {
public ObjectGuid Victim; public ObjectGuid Victim;
public uint Points; public uint Points;
@@ -649,30 +638,30 @@ namespace Game.Networking.Packets
public float Amplitude; public float Amplitude;
} }
struct SpellLogEffectExtraAttacksParams public struct SpellLogEffectExtraAttacksParams
{ {
public ObjectGuid Victim; public ObjectGuid Victim;
public uint NumAttacks; public uint NumAttacks;
} }
struct SpellLogEffectDurabilityDamageParams public struct SpellLogEffectDurabilityDamageParams
{ {
public ObjectGuid Victim; public ObjectGuid Victim;
public int ItemID; public int ItemID;
public int Amount; public int Amount;
} }
struct SpellLogEffectGenericVictimParams public struct SpellLogEffectGenericVictimParams
{ {
public ObjectGuid Victim; public ObjectGuid Victim;
} }
struct SpellLogEffectTradeSkillItemParams public struct SpellLogEffectTradeSkillItemParams
{ {
public int ItemID; public int ItemID;
} }
struct SpellLogEffectFeedPetParams public struct SpellLogEffectFeedPetParams
{ {
public int ItemID; public int ItemID;
} }
@@ -745,4 +734,4 @@ namespace Game.Networking.Packets
public float State11; public float State11;
public uint State12; public uint State12;
} }
} }
+74 -85
View File
@@ -1993,10 +1993,10 @@ namespace Game.Spells
if (Aura.BuildEffectMaskForOwner(m_spellInfo, SpellConst.MaxEffectMask, unit) != 0) if (Aura.BuildEffectMaskForOwner(m_spellInfo, SpellConst.MaxEffectMask, unit) != 0)
{ {
foreach (SpellEffectInfo auraSpellEffect in m_spellInfo.GetEffects()) foreach (SpellEffectInfo auraSpellEffect in m_spellInfo.GetEffects())
if (auraSpellEffect != null) if (auraSpellEffect != null)
hitInfo.AuraBasePoints[auraSpellEffect.EffectIndex] = (m_spellValue.CustomBasePointsMask & (1 << (int)auraSpellEffect.EffectIndex)) != 0 ? hitInfo.AuraBasePoints[auraSpellEffect.EffectIndex] = (m_spellValue.CustomBasePointsMask & (1 << (int)auraSpellEffect.EffectIndex)) != 0 ?
m_spellValue.EffectBasePoints[auraSpellEffect.EffectIndex] : m_spellValue.EffectBasePoints[auraSpellEffect.EffectIndex] :
auraSpellEffect.CalcBaseValue(m_originalCaster, unit, m_castItemEntry, m_castItemLevel); auraSpellEffect.CalcBaseValue(m_originalCaster, unit, m_castItemEntry, m_castItemLevel);
// Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add // Get Data Needed for Diminishing Returns, some effects may have multiple auras, so this must be done on spell hit, not aura add
hitInfo.DRGroup = m_spellInfo.GetDiminishingReturnsGroupForSpell(); hitInfo.DRGroup = m_spellInfo.GetDiminishingReturnsGroupForSpell();
@@ -2664,7 +2664,7 @@ namespace Game.Spells
SetExecutedCurrently(false); SetExecutedCurrently(false);
return; return;
} }
Unit unitCaster = m_caster.ToUnit(); Unit unitCaster = m_caster.ToUnit();
if (unitCaster != null) if (unitCaster != null)
{ {
@@ -3185,7 +3185,7 @@ namespace Game.Spells
&& charm.m_unitData.CreatedBySpell == m_spellInfo.Id) && charm.m_unitData.CreatedBySpell == m_spellInfo.Id)
((Puppet)charm).UnSummon(); ((Puppet)charm).UnSummon();
} }
Creature creatureCaster = unitCaster.ToCreature(); Creature creatureCaster = unitCaster.ToCreature();
if (creatureCaster != null) if (creatureCaster != null)
creatureCaster.ReleaseFocus(this); creatureCaster.ReleaseFocus(this);
@@ -3805,51 +3805,32 @@ namespace Game.Spells
void SendSpellExecuteLog() void SendSpellExecuteLog()
{ {
if (_executeLogEffects.Empty())
return;
SpellExecuteLog spellExecuteLog = new(); SpellExecuteLog spellExecuteLog = new();
spellExecuteLog.Caster = m_caster.GetGUID(); spellExecuteLog.Caster = m_caster.GetGUID();
spellExecuteLog.SpellID = m_spellInfo.Id; spellExecuteLog.SpellID = m_spellInfo.Id;
spellExecuteLog.Effects = _executeLogEffects.Values.ToList();
foreach (SpellEffectInfo effect in m_spellInfo.GetEffects())
{
if (effect == null)
continue;
if (_powerDrainTargets[effect.EffectIndex].Empty() && _extraAttacksTargets[effect.EffectIndex].Empty() &&
_durabilityDamageTargets[effect.EffectIndex].Empty() && _genericVictimTargets[effect.EffectIndex].Empty() &&
_tradeSkillTargets[effect.EffectIndex].Empty() && _feedPetTargets[effect.EffectIndex].Empty())
continue;
SpellExecuteLog.SpellLogEffect spellLogEffect = new();
spellLogEffect.Effect = (int)effect.Effect;
spellLogEffect.PowerDrainTargets = _powerDrainTargets[effect.EffectIndex];
spellLogEffect.ExtraAttacksTargets = _extraAttacksTargets[effect.EffectIndex];
spellLogEffect.DurabilityDamageTargets = _durabilityDamageTargets[effect.EffectIndex];
spellLogEffect.GenericVictimTargets = _genericVictimTargets[effect.EffectIndex];
spellLogEffect.TradeSkillTargets = _tradeSkillTargets[effect.EffectIndex];
spellLogEffect.FeedPetTargets = _feedPetTargets[effect.EffectIndex];
spellExecuteLog.Effects.Add(spellLogEffect);
}
spellExecuteLog.LogData.Initialize(this); spellExecuteLog.LogData.Initialize(this);
if (!spellExecuteLog.Effects.Empty()) m_caster.SendCombatLogMessage(spellExecuteLog);
m_caster.SendCombatLogMessage(spellExecuteLog);
CleanupExecuteLogList();
} }
void CleanupExecuteLogList() SpellLogEffect GetExecuteLogEffect(SpellEffectName effect)
{ {
_powerDrainTargets.Clear(); var spellLogEffect = _executeLogEffects.LookupByKey(effect);
_extraAttacksTargets.Clear(); if (spellLogEffect != null)
_durabilityDamageTargets.Clear(); return spellLogEffect;
_genericVictimTargets.Clear();
_tradeSkillTargets.Clear(); SpellLogEffect executeLogEffect = new();
_feedPetTargets.Clear(); executeLogEffect.Effect = (int)effect;
_executeLogEffects.Add(effect, executeLogEffect);
return executeLogEffect;
} }
void ExecuteLogEffectTakeTargetPower(uint effIndex, Unit target, PowerType powerType, uint points, float amplitude) void ExecuteLogEffectTakeTargetPower(SpellEffectName effect, Unit target, PowerType powerType, uint points, float amplitude)
{ {
SpellLogEffectPowerDrainParams spellLogEffectPowerDrainParams; SpellLogEffectPowerDrainParams spellLogEffectPowerDrainParams;
@@ -3858,19 +3839,19 @@ namespace Game.Spells
spellLogEffectPowerDrainParams.PowerType = (uint)powerType; spellLogEffectPowerDrainParams.PowerType = (uint)powerType;
spellLogEffectPowerDrainParams.Amplitude = amplitude; spellLogEffectPowerDrainParams.Amplitude = amplitude;
_powerDrainTargets.Add(effIndex, spellLogEffectPowerDrainParams); GetExecuteLogEffect(effect).PowerDrainTargets.Add(spellLogEffectPowerDrainParams);
} }
void ExecuteLogEffectExtraAttacks(uint effIndex, Unit victim, uint numAttacks) void ExecuteLogEffectExtraAttacks(SpellEffectName effect, Unit victim, uint numAttacks)
{ {
SpellLogEffectExtraAttacksParams spellLogEffectExtraAttacksParams; SpellLogEffectExtraAttacksParams spellLogEffectExtraAttacksParams;
spellLogEffectExtraAttacksParams.Victim = victim.GetGUID(); spellLogEffectExtraAttacksParams.Victim = victim.GetGUID();
spellLogEffectExtraAttacksParams.NumAttacks = numAttacks; spellLogEffectExtraAttacksParams.NumAttacks = numAttacks;
_extraAttacksTargets.Add(effIndex, spellLogEffectExtraAttacksParams); GetExecuteLogEffect(effect).ExtraAttacksTargets.Add(spellLogEffectExtraAttacksParams);
} }
void ExecuteLogEffectInterruptCast(uint effIndex, Unit victim, uint spellId) void SendSpellInterruptLog(Unit victim, uint spellId)
{ {
SpellInterruptLog data = new(); SpellInterruptLog data = new();
data.Caster = m_caster.GetGUID(); data.Caster = m_caster.GetGUID();
@@ -3881,62 +3862,62 @@ namespace Game.Spells
m_caster.SendMessageToSet(data, true); m_caster.SendMessageToSet(data, true);
} }
void ExecuteLogEffectDurabilityDamage(uint effIndex, Unit victim, int itemId, int amount) void ExecuteLogEffectDurabilityDamage(SpellEffectName effect, Unit victim, int itemId, int amount)
{ {
SpellLogEffectDurabilityDamageParams spellLogEffectDurabilityDamageParams; SpellLogEffectDurabilityDamageParams spellLogEffectDurabilityDamageParams;
spellLogEffectDurabilityDamageParams.Victim = victim.GetGUID(); spellLogEffectDurabilityDamageParams.Victim = victim.GetGUID();
spellLogEffectDurabilityDamageParams.ItemID = itemId; spellLogEffectDurabilityDamageParams.ItemID = itemId;
spellLogEffectDurabilityDamageParams.Amount = amount; spellLogEffectDurabilityDamageParams.Amount = amount;
_durabilityDamageTargets.Add(effIndex, spellLogEffectDurabilityDamageParams); GetExecuteLogEffect(effect).DurabilityDamageTargets.Add(spellLogEffectDurabilityDamageParams);
} }
void ExecuteLogEffectOpenLock(uint effIndex, WorldObject obj) void ExecuteLogEffectOpenLock(SpellEffectName effect, WorldObject obj)
{ {
SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams; SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
spellLogEffectGenericVictimParams.Victim = obj.GetGUID(); spellLogEffectGenericVictimParams.Victim = obj.GetGUID();
_genericVictimTargets.Add(effIndex, spellLogEffectGenericVictimParams); GetExecuteLogEffect(effect).GenericVictimTargets.Add(spellLogEffectGenericVictimParams);
} }
void ExecuteLogEffectCreateItem(uint effIndex, uint entry) void ExecuteLogEffectCreateItem(SpellEffectName effect, uint entry)
{ {
SpellLogEffectTradeSkillItemParams spellLogEffectTradeSkillItemParams; SpellLogEffectTradeSkillItemParams spellLogEffectTradeSkillItemParams;
spellLogEffectTradeSkillItemParams.ItemID = (int)entry; spellLogEffectTradeSkillItemParams.ItemID = (int)entry;
_tradeSkillTargets.Add(effIndex, spellLogEffectTradeSkillItemParams); GetExecuteLogEffect(effect).TradeSkillTargets.Add(spellLogEffectTradeSkillItemParams);
} }
void ExecuteLogEffectDestroyItem(uint effIndex, uint entry) void ExecuteLogEffectDestroyItem(SpellEffectName effect, uint entry)
{ {
SpellLogEffectFeedPetParams spellLogEffectFeedPetParams; SpellLogEffectFeedPetParams spellLogEffectFeedPetParams;
spellLogEffectFeedPetParams.ItemID = (int)entry; spellLogEffectFeedPetParams.ItemID = (int)entry;
_feedPetTargets.Add(effIndex, spellLogEffectFeedPetParams); GetExecuteLogEffect(effect).FeedPetTargets.Add(spellLogEffectFeedPetParams);
} }
void ExecuteLogEffectSummonObject(uint effIndex, WorldObject obj) void ExecuteLogEffectSummonObject(SpellEffectName effect, WorldObject obj)
{ {
SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams; SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
spellLogEffectGenericVictimParams.Victim = obj.GetGUID(); spellLogEffectGenericVictimParams.Victim = obj.GetGUID();
_genericVictimTargets.Add(effIndex, spellLogEffectGenericVictimParams); GetExecuteLogEffect(effect).GenericVictimTargets.Add(spellLogEffectGenericVictimParams);
} }
void ExecuteLogEffectUnsummonObject(uint effIndex, WorldObject obj) void ExecuteLogEffectUnsummonObject(SpellEffectName effect, WorldObject obj)
{ {
SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams; SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
spellLogEffectGenericVictimParams.Victim = obj.GetGUID(); spellLogEffectGenericVictimParams.Victim = obj.GetGUID();
_genericVictimTargets.Add(effIndex, spellLogEffectGenericVictimParams); GetExecuteLogEffect(effect).GenericVictimTargets.Add(spellLogEffectGenericVictimParams);
} }
void ExecuteLogEffectResurrect(uint effIndex, Unit target) void ExecuteLogEffectResurrect(SpellEffectName effect, Unit target)
{ {
SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams; SpellLogEffectGenericVictimParams spellLogEffectGenericVictimParams;
spellLogEffectGenericVictimParams.Victim = target.GetGUID(); spellLogEffectGenericVictimParams.Victim = target.GetGUID();
_genericVictimTargets.Add(effIndex, spellLogEffectGenericVictimParams); GetExecuteLogEffect(effect).GenericVictimTargets.Add(spellLogEffectGenericVictimParams);
} }
void SendInterrupted(byte result) void SendInterrupted(byte result)
@@ -4591,8 +4572,8 @@ namespace Game.Spells
// also, such casts shouldn't be sent to client // also, such casts shouldn't be sent to client
if (!(m_spellInfo.IsPassive() && (m_targets.GetUnitTarget() == null || m_targets.GetUnitTarget() == m_caster))) if (!(m_spellInfo.IsPassive() && (m_targets.GetUnitTarget() == null || m_targets.GetUnitTarget() == m_caster)))
{ {
// Check explicit target for m_originalCaster - todo: get rid of such workarounds // Check explicit target for m_originalCaster - todo: get rid of such workarounds
WorldObject caster = m_caster; WorldObject caster = m_caster;
if (m_originalCaster != null) if (m_originalCaster != null)
caster = m_originalCaster; caster = m_originalCaster;
@@ -4608,21 +4589,21 @@ namespace Game.Spells
if (castResult != SpellCastResult.SpellCastOk) if (castResult != SpellCastResult.SpellCastOk)
return castResult; return castResult;
// If it's not a melee spell, check if vision is obscured by SPELL_AURA_INTERFERE_TARGETTING // If it's not a melee spell, check if vision is obscured by SPELL_AURA_INTERFERE_TARGETTING
if (m_spellInfo.DmgClass != SpellDmgClass.Melee) if (m_spellInfo.DmgClass != SpellDmgClass.Melee)
{
Unit unitCaster1 = m_caster.ToUnit();
if (unitCaster1 != null)
{ {
Unit unitCaster1 = m_caster.ToUnit(); foreach (var auraEffect in unitCaster1.GetAuraEffectsByType(AuraType.InterfereTargetting))
if (unitCaster1 != null) if (!unitCaster1.IsFriendlyTo(auraEffect.GetCaster()) && !unitTarget.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID()))
{ return SpellCastResult.VisionObscured;
foreach (var auraEffect in unitCaster1.GetAuraEffectsByType(AuraType.InterfereTargetting))
if (!unitCaster1.IsFriendlyTo(auraEffect.GetCaster()) && !unitTarget.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID()))
return SpellCastResult.VisionObscured;
foreach (var auraEffect in unitTarget.GetAuraEffectsByType(AuraType.InterfereTargetting)) foreach (var auraEffect in unitTarget.GetAuraEffectsByType(AuraType.InterfereTargetting))
if (!unitCaster1.IsFriendlyTo(auraEffect.GetCaster()) && (!unitTarget.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID()) || !unitCaster1.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID()))) if (!unitCaster1.IsFriendlyTo(auraEffect.GetCaster()) && (!unitTarget.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID()) || !unitCaster1.HasAura(auraEffect.GetId(), auraEffect.GetCasterGUID())))
return SpellCastResult.VisionObscured; return SpellCastResult.VisionObscured;
}
} }
}
if (unitTarget != m_caster) if (unitTarget != m_caster)
{ {
@@ -4634,9 +4615,9 @@ namespace Game.Spells
if (m_spellInfo.HasAttribute(SpellCustomAttributes.ReqTargetFacingCaster) && !unitTarget.HasInArc(MathFunctions.PI, m_caster)) if (m_spellInfo.HasAttribute(SpellCustomAttributes.ReqTargetFacingCaster) && !unitTarget.HasInArc(MathFunctions.PI, m_caster))
return SpellCastResult.NotInfront; return SpellCastResult.NotInfront;
// Ignore LOS for gameobjects casts // Ignore LOS for gameobjects casts
if (!m_caster.IsGameObject()) if (!m_caster.IsGameObject())
{ {
WorldObject losTarget = m_caster; WorldObject losTarget = m_caster;
if (IsTriggered() && m_triggeredByAuraSpell != null) if (IsTriggered() && m_triggeredByAuraSpell != null)
{ {
@@ -6859,7 +6840,7 @@ namespace Game.Spells
targetInfo.Damage += m_damage; targetInfo.Damage += m_damage;
targetInfo.Healing += m_healing; targetInfo.Healing += m_healing;
float critChance = m_spellValue.CriticalChance; float critChance = m_spellValue.CriticalChance;
if (m_originalCaster != null) if (m_originalCaster != null)
{ {
@@ -7481,12 +7462,7 @@ namespace Game.Spells
} }
#region Fields #region Fields
MultiMap<uint, SpellLogEffectPowerDrainParams> _powerDrainTargets = new(); Dictionary<SpellEffectName, SpellLogEffect> _executeLogEffects = new();
MultiMap<uint, SpellLogEffectExtraAttacksParams> _extraAttacksTargets = new();
MultiMap<uint, SpellLogEffectDurabilityDamageParams> _durabilityDamageTargets = new();
MultiMap<uint, SpellLogEffectGenericVictimParams> _genericVictimTargets = new();
MultiMap<uint, SpellLogEffectTradeSkillItemParams> _tradeSkillTargets = new();
MultiMap<uint, SpellLogEffectFeedPetParams> _feedPetTargets = new();
PathGenerator m_preGeneratedPath; PathGenerator m_preGeneratedPath;
public SpellInfo m_spellInfo; public SpellInfo m_spellInfo;
@@ -8377,7 +8353,7 @@ namespace Game.Spells
} }
public class WorldObjectSpellConeTargetCheck : WorldObjectSpellAreaTargetCheck public class WorldObjectSpellConeTargetCheck : WorldObjectSpellAreaTargetCheck
{ {
float _coneAngle; float _coneAngle;
float _lineWidth; float _lineWidth;
@@ -8463,7 +8439,7 @@ namespace Game.Spells
return base.Invoke(target); return base.Invoke(target);
} }
} }
public class SpellEvent : BasicEvent public class SpellEvent : BasicEvent
{ {
public SpellEvent(Spell spell) public SpellEvent(Spell spell)
@@ -8669,4 +8645,17 @@ namespace Game.Spells
return this; return this;
} }
} }
}
public class SpellLogEffect
{
public int Effect;
public List<SpellLogEffectPowerDrainParams> PowerDrainTargets = new();
public List<SpellLogEffectExtraAttacksParams> ExtraAttacksTargets = new();
public List<SpellLogEffectDurabilityDamageParams> DurabilityDamageTargets = new();
public List<SpellLogEffectGenericVictimParams> GenericVictimTargets = new();
public List<SpellLogEffectTradeSkillItemParams> TradeSkillTargets = new();
public List<SpellLogEffectFeedPetParams> FeedPetTargets = new();
}
}
+33 -34
View File
@@ -32,7 +32,6 @@ using Game.Movement;
using Game.Networking.Packets; using Game.Networking.Packets;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
namespace Game.Spells namespace Game.Spells
{ {
@@ -83,7 +82,7 @@ namespace Game.Spells
int health = damage; int health = damage;
int mana = effectInfo.MiscValue; int mana = effectInfo.MiscValue;
ExecuteLogEffectResurrect(effIndex, target); ExecuteLogEffectResurrect(effectInfo.Effect, target);
target.SetResurrectRequestData(m_caster, (uint)health, (uint)mana, 0); target.SetResurrectRequestData(m_caster, (uint)health, (uint)mana, 0);
SendResurrectRequest(target); SendResurrectRequest(target);
} }
@@ -821,7 +820,7 @@ namespace Game.Spells
unitCaster.EnergizeBySpell(unitCaster, m_spellInfo, gain, powerType); unitCaster.EnergizeBySpell(unitCaster, m_spellInfo, gain, powerType);
} }
ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, (uint)newDamage, gainMultiplier); ExecuteLogEffectTakeTargetPower(effectInfo.Effect, unitTarget, powerType, (uint)newDamage, gainMultiplier);
} }
[SpellEffectHandler(SpellEffectName.SendEvent)] [SpellEffectHandler(SpellEffectName.SendEvent)]
@@ -888,7 +887,7 @@ namespace Game.Spells
float dmgMultiplier = effectInfo.CalcValueMultiplier(unitCaster, this); float dmgMultiplier = effectInfo.CalcValueMultiplier(unitCaster, this);
// add log data before multiplication (need power amount, not damage) // add log data before multiplication (need power amount, not damage)
ExecuteLogEffectTakeTargetPower(effIndex, unitTarget, powerType, (uint)newDamage, 0.0f); ExecuteLogEffectTakeTargetPower(effectInfo.Effect, unitTarget, powerType, (uint)newDamage, 0.0f);
newDamage = (int)(newDamage * dmgMultiplier); newDamage = (int)(newDamage * dmgMultiplier);
@@ -1131,7 +1130,7 @@ namespace Game.Spells
return; return;
DoCreateItem(effIndex, effectInfo.ItemType, m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None); DoCreateItem(effIndex, effectInfo.ItemType, m_spellInfo.HasAttribute(SpellAttr0.Tradespell) ? ItemContext.TradeSkill : ItemContext.None);
ExecuteLogEffectCreateItem(effIndex, effectInfo.ItemType); ExecuteLogEffectCreateItem(effectInfo.Effect, effectInfo.ItemType);
} }
[SpellEffectHandler(SpellEffectName.CreateLoot)] [SpellEffectHandler(SpellEffectName.CreateLoot)]
@@ -1485,7 +1484,7 @@ namespace Game.Spells
} }
} }
} }
ExecuteLogEffectOpenLock(effIndex, gameObjTarget != null ? gameObjTarget : (WorldObject)itemTarget); ExecuteLogEffectOpenLock(effectInfo.Effect, gameObjTarget != null ? gameObjTarget : (WorldObject)itemTarget);
} }
[SpellEffectHandler(SpellEffectName.SummonChangeItem)] [SpellEffectHandler(SpellEffectName.SummonChangeItem)]
@@ -1699,7 +1698,7 @@ namespace Game.Spells
case SummonCategory.Unk: case SummonCategory.Unk:
if (Convert.ToBoolean(properties.Flags & SummonPropFlags.Unk10)) if (Convert.ToBoolean(properties.Flags & SummonPropFlags.Unk10))
{ {
SummonGuardian(effIndex, entry, properties, numSummons, privateObjectOwner); SummonGuardian(effectInfo, entry, properties, numSummons, privateObjectOwner);
break; break;
} }
switch (properties.Title) switch (properties.Title)
@@ -1708,9 +1707,9 @@ namespace Game.Spells
case SummonTitle.Guardian: case SummonTitle.Guardian:
case SummonTitle.Runeblade: case SummonTitle.Runeblade:
case SummonTitle.Minion: case SummonTitle.Minion:
SummonGuardian(effIndex, entry, properties, numSummons, privateObjectOwner); SummonGuardian(effectInfo, entry, properties, numSummons, privateObjectOwner);
break; break;
// Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE) // Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE)
case SummonTitle.Vehicle: case SummonTitle.Vehicle:
case SummonTitle.Mount: case SummonTitle.Mount:
{ {
@@ -1781,14 +1780,14 @@ namespace Game.Spells
summon.SetCreatedBySpell(m_spellInfo.Id); summon.SetCreatedBySpell(m_spellInfo.Id);
} }
ExecuteLogEffectSummonObject(effIndex, summon); ExecuteLogEffectSummonObject(effectInfo.Effect, summon);
} }
return; return;
} }
}//switch }//switch
break; break;
case SummonCategory.Pet: case SummonCategory.Pet:
SummonGuardian(effIndex, entry, properties, numSummons, privateObjectOwner); SummonGuardian(effectInfo, entry, properties, numSummons, privateObjectOwner);
break; break;
case SummonCategory.Puppet: case SummonCategory.Puppet:
{ {
@@ -1839,7 +1838,7 @@ namespace Game.Spells
if (summon != null) if (summon != null)
{ {
summon.SetCreatorGUID(caster.GetGUID()); summon.SetCreatorGUID(caster.GetGUID());
ExecuteLogEffectSummonObject(effIndex, summon); ExecuteLogEffectSummonObject(effectInfo.Effect, summon);
} }
} }
@@ -2394,7 +2393,7 @@ namespace Game.Spells
{ {
SummonPropertiesRecord properties = CliDB.SummonPropertiesStorage.LookupByKey(67); SummonPropertiesRecord properties = CliDB.SummonPropertiesStorage.LookupByKey(67);
if (properties != null) if (properties != null)
SummonGuardian(effIndex, petentry, properties, 1, ObjectGuid.Empty); SummonGuardian(effectInfo, petentry, properties, 1, ObjectGuid.Empty);
return; return;
} }
@@ -2449,7 +2448,7 @@ namespace Game.Spells
if (!string.IsNullOrEmpty(new_name)) if (!string.IsNullOrEmpty(new_name))
pet.SetName(new_name); pet.SetName(new_name);
ExecuteLogEffectSummonObject(effIndex, pet); ExecuteLogEffectSummonObject(effectInfo.Effect, pet);
} }
[SpellEffectHandler(SpellEffectName.LearnPetSpell)] [SpellEffectHandler(SpellEffectName.LearnPetSpell)]
@@ -2796,7 +2795,7 @@ namespace Game.Spells
else if (m_spellInfo.DmgClass == SpellDmgClass.Melee) else if (m_spellInfo.DmgClass == SpellDmgClass.Melee)
Unit.ProcSkillsAndAuras(unitCaster, unitTarget, ProcFlags.DoneSpellMeleeDmgClass, ProcFlags.TakenSpellMeleeDmgClass, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Interrupt, null, null, null); Unit.ProcSkillsAndAuras(unitCaster, unitTarget, ProcFlags.DoneSpellMeleeDmgClass, ProcFlags.TakenSpellMeleeDmgClass, ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.Hit, ProcFlagsHit.Interrupt, null, null, null);
} }
ExecuteLogEffectInterruptCast(effIndex, unitTarget, curSpellInfo.Id); SendSpellInterruptLog(unitTarget, curSpellInfo.Id);
unitTarget.InterruptSpell(i, false); unitTarget.InterruptSpell(i, false);
} }
} }
@@ -2834,7 +2833,7 @@ namespace Game.Spells
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0); go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
go.SetSpellId(m_spellInfo.Id); go.SetSpellId(m_spellInfo.Id);
ExecuteLogEffectSummonObject(effIndex, go); ExecuteLogEffectSummonObject(effectInfo.Effect, go);
// Wild object not have owner and check clickable by players // Wild object not have owner and check clickable by players
map.AddToMap(go); map.AddToMap(go);
@@ -2857,7 +2856,7 @@ namespace Game.Spells
linkedTrap.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0); linkedTrap.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
linkedTrap.SetSpellId(m_spellInfo.Id); linkedTrap.SetSpellId(m_spellInfo.Id);
ExecuteLogEffectSummonObject(effIndex, linkedTrap); ExecuteLogEffectSummonObject(effectInfo.Effect, linkedTrap);
} }
} }
@@ -3395,7 +3394,7 @@ namespace Game.Spells
go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0); go.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
go.SetSpellId(m_spellInfo.Id); go.SetSpellId(m_spellInfo.Id);
ExecuteLogEffectSummonObject(effIndex, go); ExecuteLogEffectSummonObject(effectInfo.Effect, go);
caster.AddGameObject(go); caster.AddGameObject(go);
map.AddToMap(go); map.AddToMap(go);
@@ -3666,7 +3665,7 @@ namespace Game.Spells
if (!pet.IsAlive()) if (!pet.IsAlive())
return; return;
ExecuteLogEffectDestroyItem(effIndex, foodItem.GetEntry()); ExecuteLogEffectDestroyItem(effectInfo.Effect, foodItem.GetEntry());
int pct; int pct;
int levelDiff = (int)pet.GetLevel() - (int)foodItem.GetTemplate().GetBaseItemLevel(); int levelDiff = (int)pet.GetLevel() - (int)foodItem.GetTemplate().GetBaseItemLevel();
@@ -3699,7 +3698,7 @@ namespace Game.Spells
Pet pet = unitTarget.ToPet(); Pet pet = unitTarget.ToPet();
ExecuteLogEffectUnsummonObject(effIndex, pet); ExecuteLogEffectUnsummonObject(effectInfo.Effect, pet);
pet.GetOwner().RemovePet(pet, PetSaveMode.NotInSlot); pet.GetOwner().RemovePet(pet, PetSaveMode.NotInSlot);
} }
@@ -3751,7 +3750,7 @@ namespace Game.Spells
go.SetSpellId(m_spellInfo.Id); go.SetSpellId(m_spellInfo.Id);
unitCaster.AddGameObject(go); unitCaster.AddGameObject(go);
ExecuteLogEffectSummonObject(effIndex, go); ExecuteLogEffectSummonObject(effectInfo.Effect, go);
map.AddToMap(go); map.AddToMap(go);
@@ -3778,7 +3777,7 @@ namespace Game.Spells
uint health = (uint)target.CountPctFromMaxHealth(damage); uint health = (uint)target.CountPctFromMaxHealth(damage);
uint mana = (uint)MathFunctions.CalculatePct(target.GetMaxPower(PowerType.Mana), damage); uint mana = (uint)MathFunctions.CalculatePct(target.GetMaxPower(PowerType.Mana), damage);
ExecuteLogEffectResurrect(effIndex, target); ExecuteLogEffectResurrect(effectInfo.Effect, target);
target.SetResurrectRequestData(m_caster, health, mana, 0); target.SetResurrectRequestData(m_caster, health, mana, 0);
SendResurrectRequest(target); SendResurrectRequest(target);
@@ -3798,7 +3797,7 @@ namespace Game.Spells
unitTarget.ExtraAttacks = (uint)damage; unitTarget.ExtraAttacks = (uint)damage;
ExecuteLogEffectExtraAttacks(effIndex, unitTarget, (uint)damage); ExecuteLogEffectExtraAttacks(effectInfo.Effect, unitTarget, (uint)damage);
} }
[SpellEffectHandler(SpellEffectName.Parry)] [SpellEffectHandler(SpellEffectName.Parry)]
@@ -4403,7 +4402,7 @@ namespace Game.Spells
if (slot < 0) if (slot < 0)
{ {
unitTarget.ToPlayer().DurabilityPointsLossAll(damage, (slot < -1)); unitTarget.ToPlayer().DurabilityPointsLossAll(damage, (slot < -1));
ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, -1, -1); ExecuteLogEffectDurabilityDamage(effectInfo.Effect, unitTarget, -1, -1);
return; return;
} }
@@ -4415,7 +4414,7 @@ namespace Game.Spells
if (item != null) if (item != null)
{ {
unitTarget.ToPlayer().DurabilityPointsLoss(item, damage); unitTarget.ToPlayer().DurabilityPointsLoss(item, damage);
ExecuteLogEffectDurabilityDamage(effIndex, unitTarget, (int)item.GetEntry(), slot); ExecuteLogEffectDurabilityDamage(effectInfo.Effect, unitTarget, (int)item.GetEntry(), slot);
} }
} }
@@ -4572,7 +4571,7 @@ namespace Game.Spells
go.SetOwnerGUID(unitCaster.GetGUID()); go.SetOwnerGUID(unitCaster.GetGUID());
go.SetSpellId(m_spellInfo.Id); go.SetSpellId(m_spellInfo.Id);
ExecuteLogEffectSummonObject(effIndex, go); ExecuteLogEffectSummonObject(effectInfo.Effect, go);
Log.outDebug(LogFilter.Spells, "AddObject at SpellEfects.cpp EffectTransmitted"); Log.outDebug(LogFilter.Spells, "AddObject at SpellEfects.cpp EffectTransmitted");
@@ -4585,7 +4584,7 @@ namespace Game.Spells
linkedTrap.SetSpellId(m_spellInfo.Id); linkedTrap.SetSpellId(m_spellInfo.Id);
linkedTrap.SetOwnerGUID(unitCaster.GetGUID()); linkedTrap.SetOwnerGUID(unitCaster.GetGUID());
ExecuteLogEffectSummonObject(effIndex, linkedTrap); ExecuteLogEffectSummonObject(effectInfo.Effect, linkedTrap);
} }
} }
@@ -4960,7 +4959,7 @@ namespace Game.Spells
gameObjTarget.SetDestructibleState((GameObjectDestructibleState)effectInfo.MiscValue, m_caster, true); gameObjTarget.SetDestructibleState((GameObjectDestructibleState)effectInfo.MiscValue, m_caster, true);
} }
void SummonGuardian(uint i, uint entry, SummonPropertiesRecord properties, uint numGuardians, ObjectGuid privateObjectOwner) void SummonGuardian(SpellEffectInfo effect, uint entry, SummonPropertiesRecord properties, uint numGuardians, ObjectGuid privateObjectOwner)
{ {
if (unitCaster == null) if (unitCaster == null)
return; return;
@@ -5025,7 +5024,7 @@ namespace Game.Spells
summon.GetAI().EnterEvadeMode(); summon.GetAI().EnterEvadeMode();
ExecuteLogEffectSummonObject(i, summon); ExecuteLogEffectSummonObject(effect.Effect, summon);
} }
} }
@@ -5330,7 +5329,7 @@ namespace Game.Spells
go.SetSpellId(m_spellInfo.Id); go.SetSpellId(m_spellInfo.Id);
go.SetPrivateObjectOwner(m_caster.GetGUID()); go.SetPrivateObjectOwner(m_caster.GetGUID());
ExecuteLogEffectSummonObject(effIndex, go); ExecuteLogEffectSummonObject(effectInfo.Effect, go);
map.AddToMap(go); map.AddToMap(go);
@@ -5342,7 +5341,7 @@ namespace Game.Spells
linkedTrap.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0); linkedTrap.SetRespawnTime(duration > 0 ? duration / Time.InMilliseconds : 0);
linkedTrap.SetSpellId(m_spellInfo.Id); linkedTrap.SetSpellId(m_spellInfo.Id);
ExecuteLogEffectSummonObject(effIndex, linkedTrap); ExecuteLogEffectSummonObject(effectInfo.Effect, linkedTrap);
} }
} }
@@ -5374,7 +5373,7 @@ namespace Game.Spells
if (resurrectAura != 0 && target.HasAura(resurrectAura)) if (resurrectAura != 0 && target.HasAura(resurrectAura))
return; return;
ExecuteLogEffectResurrect(effIndex, target); ExecuteLogEffectResurrect(effectInfo.Effect, target);
target.SetResurrectRequestData(m_caster, health, mana, resurrectAura); target.SetResurrectRequestData(m_caster, health, mana, resurrectAura);
SendResurrectRequest(target); SendResurrectRequest(target);
} }
@@ -5495,7 +5494,7 @@ namespace Game.Spells
bonusList.Add(collectionMgr.GetHeirloomBonus(m_misc.Data0)); bonusList.Add(collectionMgr.GetHeirloomBonus(m_misc.Data0));
DoCreateItem(effIndex, m_misc.Data0, ItemContext.None, bonusList); DoCreateItem(effIndex, m_misc.Data0, ItemContext.None, bonusList);
ExecuteLogEffectCreateItem(effIndex, m_misc.Data0); ExecuteLogEffectCreateItem(effectInfo.Effect, m_misc.Data0);
} }
[SpellEffectHandler(SpellEffectName.ActivateGarrisonBuilding)] [SpellEffectHandler(SpellEffectName.ActivateGarrisonBuilding)]
@@ -5871,4 +5870,4 @@ namespace Game.Spells
int _chance; int _chance;
byte _charges; byte _charges;
} }
} }