Core/Spells: CastSpell Cleanup
Port From (https://github.com/TrinityCore/TrinityCore/commit/)
This commit is contained in:
@@ -2001,8 +2001,7 @@ namespace Game.Entities
|
||||
if (spellId == 0)
|
||||
return;
|
||||
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
if (!Global.SpellMgr.HasSpellInfo(spellId, GetMap().GetDifficultyID()))
|
||||
{
|
||||
if (!user.IsTypeId(TypeId.Player) || !Global.OutdoorPvPMgr.HandleCustomSpell(user.ToPlayer(), spellId, this))
|
||||
Log.outError(LogFilter.Server, "WORLD: unknown spell id {0} at use action for gameobject (Entry: {1} GoType: {2})", spellId, GetEntry(), GetGoType());
|
||||
@@ -2016,7 +2015,7 @@ namespace Game.Entities
|
||||
Global.OutdoorPvPMgr.HandleCustomSpell(player1, spellId, this);
|
||||
|
||||
if (spellCaster != null)
|
||||
spellCaster.CastSpell(user, spellInfo, triggered);
|
||||
spellCaster.CastSpell(user, spellId, triggered);
|
||||
else
|
||||
CastSpell(user, spellId);
|
||||
}
|
||||
@@ -2045,7 +2044,7 @@ namespace Game.Entities
|
||||
if (self)
|
||||
{
|
||||
if (target != null)
|
||||
target.CastSpell(target, spellInfo, triggered);
|
||||
target.CastSpell(target, spellInfo.Id, new CastSpellExtraArgs(triggered));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2059,6 +2058,7 @@ namespace Game.Entities
|
||||
|
||||
PhasingHandler.InheritPhaseShift(trigger, this);
|
||||
|
||||
CastSpellExtraArgs args = new CastSpellExtraArgs(triggered);
|
||||
Unit owner = GetOwner();
|
||||
if (owner)
|
||||
{
|
||||
@@ -2069,14 +2069,17 @@ namespace Game.Entities
|
||||
trigger.SetPvpFlags(owner.GetPvpFlags());
|
||||
// needed for GO casts for proper target validation checks
|
||||
trigger.SetOwnerGUID(owner.GetGUID());
|
||||
trigger.CastSpell(target != null ? target : trigger, spellInfo, triggered, null, null, owner.GetGUID());
|
||||
|
||||
args.OriginalCaster = owner.GetGUID();
|
||||
trigger.CastSpell(target ?? trigger, spellInfo.Id, args);
|
||||
}
|
||||
else
|
||||
{
|
||||
trigger.SetFaction(spellInfo.IsPositive() ? 35 : 14u);
|
||||
// Set owner guid for target if no owner available - needed by trigger auras
|
||||
// - trigger gets despawned and there's no caster avalible (see AuraEffect.TriggerSpell())
|
||||
trigger.CastSpell(target != null ? target : trigger, spellInfo, triggered, null, null, target ? target.GetGUID() : ObjectGuid.Empty);
|
||||
args.OriginalCaster = target ? target.GetGUID() : ObjectGuid.Empty;
|
||||
trigger.CastSpell(target ?? trigger, spellInfo.Id, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1412,13 +1412,12 @@ namespace Game.Entities
|
||||
if (auraId == 0)
|
||||
return;
|
||||
|
||||
CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask);
|
||||
|
||||
if (auraId == 35696) // Demonic Knowledge
|
||||
{
|
||||
int basePoints = MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect));
|
||||
CastCustomSpell(this, auraId, basePoints, 0, 0, true);
|
||||
}
|
||||
else
|
||||
CastSpell(this, auraId, true);
|
||||
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, MathFunctions.CalculatePct(aura.GetDamage(), GetStat(Stats.Stamina) + GetStat(Stats.Intellect)));
|
||||
|
||||
CastSpell(this, auraId, args);
|
||||
}
|
||||
|
||||
bool IsPetAura(Aura aura)
|
||||
|
||||
@@ -3888,7 +3888,7 @@ namespace Game.Entities
|
||||
|
||||
Log.outDebug(LogFilter.Player, "WORLD: cast {0} Equip spellId - {1}", (item != null ? "item" : "itemset"), spellInfo.Id);
|
||||
|
||||
CastSpell(this, spellInfo, true, item);
|
||||
CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(item));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -5083,13 +5083,14 @@ namespace Game.Entities
|
||||
}
|
||||
else if (apply)
|
||||
{
|
||||
Dictionary<SpellValueMod, int> csv = new();
|
||||
CastSpellExtraArgs args = new CastSpellExtraArgs(TriggerCastFlags.FullMask);
|
||||
args.CastItem = artifact;
|
||||
if (artifactPowerRank.AuraPointsOverride != 0)
|
||||
for (int i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
if (spellInfo.GetEffect((uint)i) != null)
|
||||
csv.Add(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride);
|
||||
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride);
|
||||
|
||||
CastCustomSpell(artifactPowerRank.SpellID, csv, this, TriggerCastFlags.FullMask, artifact);
|
||||
CastSpell(this, artifactPowerRank.SpellID, args);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -5159,7 +5160,7 @@ namespace Game.Entities
|
||||
if (azeritePower != null)
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, azeritePower.SpellID, true, item);
|
||||
CastSpell(this, azeritePower.SpellID, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID());
|
||||
}
|
||||
@@ -5177,7 +5178,7 @@ namespace Game.Entities
|
||||
if (major && currentRank == 1)
|
||||
{
|
||||
if (apply)
|
||||
CastCustomSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride, SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription, this, TriggerCastFlags.FullMask);
|
||||
CastSpell(this, PlayerConst.SpellIdHeartEssenceActionBarOverride, new CastSpellExtraArgs(TriggerCastFlags.FullMask).AddSpellMod(SpellValueMod.BasePoint0, (int)azeriteEssencePower.MajorPowerDescription));
|
||||
else
|
||||
RemoveAurasDueToSpell(PlayerConst.SpellIdHeartEssenceActionBarOverride);
|
||||
}
|
||||
@@ -5191,7 +5192,7 @@ namespace Game.Entities
|
||||
if (powerSpell != null)
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, powerSpell, true, item);
|
||||
CastSpell(this, powerSpell.Id, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID());
|
||||
}
|
||||
@@ -5204,7 +5205,7 @@ namespace Game.Entities
|
||||
if (powerSpell.IsPassive())
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, powerSpell, true, item);
|
||||
CastSpell(this, powerSpell.Id, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(powerSpell.Id, item.GetGUID());
|
||||
}
|
||||
@@ -5224,7 +5225,7 @@ namespace Game.Entities
|
||||
if (apply)
|
||||
{
|
||||
if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, GetPrimarySpecialization()))
|
||||
CastSpell(this, azeritePower.SpellID, true, item);
|
||||
CastSpell(this, azeritePower.SpellID, item);
|
||||
}
|
||||
else
|
||||
RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID());
|
||||
|
||||
@@ -800,7 +800,7 @@ namespace Game.Entities
|
||||
caster = unit;
|
||||
}
|
||||
|
||||
caster.CastSpell(this, spellInfo, true);
|
||||
caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty));
|
||||
}
|
||||
|
||||
SetQuestSlot(log_slot, quest_id, qtime);
|
||||
@@ -1124,7 +1124,7 @@ namespace Game.Entities
|
||||
caster = unit;
|
||||
}
|
||||
|
||||
caster.CastSpell(this, spellInfo, true);
|
||||
caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1144,7 +1144,7 @@ namespace Game.Entities
|
||||
caster = unit;
|
||||
}
|
||||
|
||||
caster.CastSpell(this, spellInfo, true);
|
||||
caster.CastSpell(this, spellInfo.Id, new CastSpellExtraArgs(TriggerCastFlags.FullMask).SetCastDifficulty(spellInfo.Difficulty));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -587,7 +587,7 @@ namespace Game.Entities
|
||||
if (enchant_spell_id != 0)
|
||||
{
|
||||
if (apply)
|
||||
CastSpell(this, enchant_spell_id, true, item);
|
||||
CastSpell(this, enchant_spell_id, item);
|
||||
else
|
||||
RemoveAurasDueToItemSpell(enchant_spell_id, item.GetGUID());
|
||||
}
|
||||
@@ -1779,7 +1779,7 @@ namespace Game.Entities
|
||||
if (apply)
|
||||
{
|
||||
if (!HasAura((uint)spellId))
|
||||
CastSpell(this, (uint)spellId, true, item);
|
||||
CastSpell(this, (uint)spellId, item);
|
||||
}
|
||||
else
|
||||
RemoveAurasDueToSpell((uint)spellId);
|
||||
@@ -3183,7 +3183,7 @@ namespace Game.Entities
|
||||
chance = GetWeaponProcChance();
|
||||
|
||||
if (RandomHelper.randChance(chance) && Global.ScriptMgr.OnCastItemCombatSpell(this, damageInfo.GetVictim(), spellInfo, item))
|
||||
CastSpell(damageInfo.GetVictim(), spellInfo.Id, true, item);
|
||||
CastSpell(damageInfo.GetVictim(), spellInfo.Id, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3205,7 +3205,7 @@ namespace Game.Entities
|
||||
if (entry != null && entry.HitMask != 0)
|
||||
{
|
||||
// Check hit/crit/dodge/parry requirement
|
||||
if (((uint)entry.HitMask & (uint)damageInfo.GetHitMask()) == 0)
|
||||
if ((entry.HitMask & (uint)damageInfo.GetHitMask()) == 0)
|
||||
continue;
|
||||
}
|
||||
else
|
||||
@@ -3247,17 +3247,17 @@ namespace Game.Entities
|
||||
if (RandomHelper.randChance(chance))
|
||||
{
|
||||
if (spellInfo.IsPositive())
|
||||
CastSpell(this, spellInfo, true, item);
|
||||
CastSpell(this, spellInfo.Id, item);
|
||||
else
|
||||
CastSpell(damageInfo.GetVictim(), spellInfo, true, item);
|
||||
CastSpell(damageInfo.GetVictim(), spellInfo.Id, item);
|
||||
}
|
||||
|
||||
if (RandomHelper.randChance(chance))
|
||||
{
|
||||
Unit target = spellInfo.IsPositive() ? this : damageInfo.GetVictim();
|
||||
|
||||
CastSpellExtraArgs args = new(item);
|
||||
// reduce effect values if enchant is limited
|
||||
Dictionary<SpellValueMod, int> values = new();
|
||||
if (entry != null && entry.AttributesMask.HasAnyFlag(EnchantProcAttributes.Limit60) && target.GetLevelForTarget(this) > 60)
|
||||
{
|
||||
int lvlDifference = (int)target.GetLevelForTarget(this) - 60;
|
||||
@@ -3268,11 +3268,11 @@ namespace Game.Entities
|
||||
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
|
||||
{
|
||||
if (spellInfo.GetEffect(i).IsEffect())
|
||||
values.Add(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct));
|
||||
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct));
|
||||
}
|
||||
}
|
||||
|
||||
CastCustomSpell(spellInfo.Id, values, target, TriggerCastFlags.FullMask, item);
|
||||
CastSpell(target, spellInfo.Id, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,7 +1073,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
if (spellInfo.IsPassive())
|
||||
vehicle.CastSpell(vehicle, spellInfo, true);
|
||||
vehicle.CastSpell(vehicle, spellInfo.Id, true);
|
||||
|
||||
petSpells.ActionButtons[i] = UnitActionBarEntry.MAKE_UNIT_ACTION_BUTTON(spellId, i + 8);
|
||||
}
|
||||
@@ -2466,7 +2466,7 @@ namespace Game.Entities
|
||||
break;
|
||||
case GossipOption.Spirithealer:
|
||||
if (IsDead())
|
||||
source.ToCreature().CastSpell(source.ToCreature(), 17251, true, null, null, GetGUID());
|
||||
source.ToCreature().CastSpell(source.ToCreature(), 17251, new CastSpellExtraArgs(GetGUID()));
|
||||
break;
|
||||
case GossipOption.Questgiver:
|
||||
PrepareQuestMenu(guid);
|
||||
@@ -3538,7 +3538,7 @@ namespace Game.Entities
|
||||
SetPower(PowerType.LunarPower, 0);
|
||||
|
||||
if (resurrectAura != 0)
|
||||
CastSpell(this, resurrectAura, true, null, null, resurrectGUID);
|
||||
CastSpell(this, resurrectAura, new CastSpellExtraArgs(resurrectGUID));
|
||||
|
||||
SpawnCorpseBones();
|
||||
}
|
||||
|
||||
@@ -706,7 +706,9 @@ namespace Game.Entities
|
||||
break;
|
||||
}
|
||||
|
||||
CastSpell(this, triggerSpell, true, null, effect);
|
||||
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
|
||||
args.TriggeringAura = effect;
|
||||
CastSpell(this, triggerSpell, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Game.Entities
|
||||
if (spellInfo != null)
|
||||
{
|
||||
if (spellInfo.IsPassive())
|
||||
_unit.CastSpell(_unit, spellInfo, true);
|
||||
_unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true));
|
||||
else
|
||||
AddSpellToActionBar(spellInfo, ActiveStates.Passive, i % SharedConst.ActionBarIndexMax);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ namespace Game.Entities
|
||||
|
||||
if (spellInfo.IsPassive())
|
||||
{
|
||||
_unit.CastSpell(_unit, spellInfo, true);
|
||||
_unit.CastSpell(_unit, spellInfo.Id, new CastSpellExtraArgs(true));
|
||||
_charmspells[x].SetActionAndType(spellId, ActiveStates.Passive);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -698,7 +698,9 @@ namespace Game.Entities
|
||||
}
|
||||
else
|
||||
{
|
||||
CastSpell(victim, meleeAttackSpellId, true, null, meleeAttackAuraEffect);
|
||||
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
|
||||
args.TriggeringAura = meleeAttackAuraEffect;
|
||||
CastSpell(victim, meleeAttackSpellId, args);
|
||||
|
||||
HitInfo hitInfo = HitInfo.AffectsVictim | HitInfo.NoAnimation;
|
||||
if (attType == WeaponAttackType.OffAttack)
|
||||
|
||||
@@ -1066,124 +1066,58 @@ namespace Game.Entities
|
||||
return SpellMissInfo.None;
|
||||
}
|
||||
|
||||
public void CastSpell(SpellCastTargets targets, SpellInfo spellInfo, Dictionary<SpellValueMod, int> values, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
public void CastSpell(SpellCastTargets targets, uint spellId, CastSpellExtraArgs args)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, args.CastDifficulty != Difficulty.None ? args.CastDifficulty : GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Spells, "CastSpell: unknown spell by caster: {0}", GetGUID().ToString());
|
||||
Log.outError(LogFilter.Unit, $"CastSpell: unknown spell {spellId} by caster: {GetGUID()}");
|
||||
return;
|
||||
}
|
||||
|
||||
Spell spell = new(this, spellInfo, triggerFlags, originalCaster);
|
||||
if (args == null)
|
||||
args = new CastSpellExtraArgs();
|
||||
|
||||
if (values != null)
|
||||
foreach (var pair in values)
|
||||
spell.SetSpellValue(pair.Key, pair.Value);
|
||||
Spell spell = new(this, spellInfo, args.TriggerFlags, args.OriginalCaster);
|
||||
foreach (var pair in args.SpellValueOverrides)
|
||||
spell.SetSpellValue(pair.Key, pair.Value);
|
||||
|
||||
spell.m_CastItem = castItem;
|
||||
spell.Prepare(targets, triggeredByAura);
|
||||
spell.m_CastItem = args.CastItem;
|
||||
spell.Prepare(targets, args.TriggeringAura);
|
||||
}
|
||||
public void CastSpell(Unit victim, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
CastSpell(victim, spellId, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastSpell(Unit victim, uint spellId, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Spells, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString());
|
||||
return;
|
||||
}
|
||||
|
||||
CastSpell(victim, spellInfo, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastSpell(Unit victim, SpellInfo spellInfo, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
public void CastSpell(WorldObject target, uint spellId, bool triggered)
|
||||
{
|
||||
CastSpell(victim, spellInfo, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
CastSpell(target, spellId, new CastSpellExtraArgs(triggered));
|
||||
}
|
||||
public void CastSpell(Unit victim, SpellInfo spellInfo, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
|
||||
public void CastSpell(WorldObject target, uint spellId, CastSpellExtraArgs args = null)
|
||||
{
|
||||
SpellCastTargets targets = new();
|
||||
targets.SetUnitTarget(victim);
|
||||
CastSpell(targets, spellInfo, null, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastSpell(float x, float y, float z, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
if (target)
|
||||
{
|
||||
Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString());
|
||||
return;
|
||||
Unit unitTarget = target.ToUnit();
|
||||
GameObject goTarget = target.ToGameObject();
|
||||
if (unitTarget != null)
|
||||
targets.SetUnitTarget(unitTarget);
|
||||
else if (goTarget != null)
|
||||
targets.SetGOTarget(goTarget);
|
||||
else
|
||||
{
|
||||
Log.outError(LogFilter.Unit, $"CastSpell: Invalid target {target.GetGUID()} passed to spell cast by {GetGUID()}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CastSpell(targets, spellId, args);
|
||||
}
|
||||
|
||||
public void CastSpell(Position dest, uint spellId, CastSpellExtraArgs args = null)
|
||||
{
|
||||
SpellCastTargets targets = new();
|
||||
targets.SetDst(x, y, z, GetOrientation());
|
||||
targets.SetDst(dest);
|
||||
|
||||
CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastSpell(GameObject go, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString());
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets = new();
|
||||
targets.SetGOTarget(go);
|
||||
|
||||
CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastSpell(Item item, uint spellId, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString());
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets = new();
|
||||
targets.SetItemTarget(item);
|
||||
|
||||
CastSpell(targets, spellInfo, null, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
|
||||
|
||||
public void CastCustomSpell(Unit target, uint spellId, int bp0, int bp1, int bp2, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
Dictionary<SpellValueMod, int> values = new();
|
||||
if (bp0 != 0)
|
||||
values.Add(SpellValueMod.BasePoint0, bp0);
|
||||
if (bp1 != 0)
|
||||
values.Add(SpellValueMod.BasePoint1, bp1);
|
||||
if (bp2 != 0)
|
||||
values.Add(SpellValueMod.BasePoint2, bp2);
|
||||
CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target, bool triggered, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
Dictionary<SpellValueMod, int> values = new();
|
||||
values.Add(mod, value);
|
||||
CastCustomSpell(spellId, values, target, triggered ? TriggerCastFlags.FullMask : TriggerCastFlags.None, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastCustomSpell(uint spellId, SpellValueMod mod, int value, Unit target = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
Dictionary<SpellValueMod, int> values = new();
|
||||
values.Add(mod, value);
|
||||
CastCustomSpell(spellId, values, target, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
}
|
||||
public void CastCustomSpell(uint spellId, Dictionary<SpellValueMod, int> values, Unit victim = null, TriggerCastFlags triggerFlags = TriggerCastFlags.None, Item castItem = null, AuraEffect triggeredByAura = null, ObjectGuid originalCaster = default)
|
||||
{
|
||||
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
|
||||
if (spellInfo == null)
|
||||
{
|
||||
Log.outError(LogFilter.Unit, "CastSpell: unknown spell id {0} by caster: {1}", spellId, GetGUID().ToString());
|
||||
return;
|
||||
}
|
||||
SpellCastTargets targets = new();
|
||||
targets.SetUnitTarget(victim);
|
||||
|
||||
CastSpell(targets, spellInfo, values, triggerFlags, castItem, triggeredByAura, originalCaster);
|
||||
CastSpell(targets, spellId, args);
|
||||
}
|
||||
|
||||
public void FinishSpell(CurrentSpellTypes spellType, bool ok = true)
|
||||
@@ -3038,7 +2972,12 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
if (IsInMap(caster))
|
||||
caster.CastCustomSpell(clickInfo.spellId, SpellValueMod.BasePoint0 + i, seatId + 1, target, flags, null, null, origCasterGUID);
|
||||
{
|
||||
CastSpellExtraArgs args = new(flags);
|
||||
args.OriginalCaster = origCasterGUID;
|
||||
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0 + i, seatId + 1);
|
||||
caster.CastSpell(target, clickInfo.spellId, args);
|
||||
}
|
||||
else // This can happen during Player._LoadAuras
|
||||
{
|
||||
int[] bp0 = new int[SpellConst.MaxEffects];
|
||||
@@ -3055,7 +2994,7 @@ namespace Game.Entities
|
||||
else
|
||||
{
|
||||
if (IsInMap(caster))
|
||||
caster.CastSpell(target, spellEntry, flags, null, null, origCasterGUID);
|
||||
caster.CastSpell(target, spellEntry.Id, new CastSpellExtraArgs().SetOriginalCaster(origCasterGUID));
|
||||
else
|
||||
Aura.TryRefreshStackOrCreate(spellEntry, ObjectGuid.Create(HighGuid.Cast, SpellCastSource.Normal, GetMapId(), spellEntry.Id, GetMap().GenerateLowGuid(HighGuid.Cast)), SpellConst.MaxEffectMask, this, clicker, GetMap().GetDifficultyID(), null, null, origCasterGUID);
|
||||
}
|
||||
@@ -3893,7 +3832,7 @@ namespace Game.Entities
|
||||
continue;
|
||||
|
||||
if (spellInfo.CasterAuraState == flag)
|
||||
CastSpell(this, spell.Key, true, null);
|
||||
CastSpell(this, spell.Key, true);
|
||||
}
|
||||
}
|
||||
else if (IsPet())
|
||||
@@ -3907,7 +3846,7 @@ namespace Game.Entities
|
||||
if (spellInfo == null || !spellInfo.IsPassive())
|
||||
continue;
|
||||
if (spellInfo.CasterAuraState == flag)
|
||||
CastSpell(this, spell.Key, true, null);
|
||||
CastSpell(this, spell.Key, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,7 +886,9 @@ namespace Game.Entities
|
||||
|
||||
public void EnterVehicle(Unit Base, sbyte seatId = -1)
|
||||
{
|
||||
CastCustomSpell(SharedConst.VehicleSpellRideHardcoded, SpellValueMod.BasePoint0, seatId + 1, Base, TriggerCastFlags.IgnoreCasterMountedOrOnVehicle);
|
||||
CastSpellExtraArgs args = new(TriggerCastFlags.IgnoreCasterMountedOrOnVehicle);
|
||||
args.SpellValueOverrides.Add(SpellValueMod.BasePoint0, seatId + 1);
|
||||
CastSpell(this, SharedConst.VehicleSpellRideHardcoded, args);
|
||||
}
|
||||
|
||||
public void _EnterVehicle(Vehicle vehicle, sbyte seatId, AuraApplication aurApp)
|
||||
|
||||
Reference in New Issue
Block a user