Core/Spells: Implemented SpellEffectAttributes::DontFailSpellOnTargetingFailure

Port From (https://github.com/TrinityCore/TrinityCore/commit/195945742105fa8dbd061f3b62b755d722655931)
This commit is contained in:
Hondacrx
2025-06-08 19:31:53 -04:00
parent aeaaf2a192
commit cb21664b4f
3 changed files with 24 additions and 13 deletions
@@ -2163,7 +2163,7 @@ namespace Framework.Constants
Unk12 = 0x1000, // 12 Unk12 = 0x1000, // 12
Unk13 = 0x2000, // 13 Unk13 = 0x2000, // 13
Unk14 = 0x4000, // 14 Unk14 = 0x4000, // 14
Unk15 = 0x8000, // 15 DoNotFailIfNoTarget = 0x8000, // 15 Do Not Fail if No Target
Unk16 = 0x10000, // 16 Unk16 = 0x10000, // 16
Unk17 = 0x20000, // 17 Unk17 = 0x20000, // 17
ActivatesRequiredShapeshift = 0x40000, // 18 ActivatesRequiredShapeshift = 0x40000, // 18
+3 -1
View File
@@ -1199,6 +1199,8 @@ namespace Game.Spells
void SelectImplicitTargetDestTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, SpellTargetIndex targetIndex) void SelectImplicitTargetDestTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, SpellTargetIndex targetIndex)
{ {
WorldObject target = m_targets.GetObjectTarget(); WorldObject target = m_targets.GetObjectTarget();
if (target == null)
return;
SpellDestination dest = new(target); SpellDestination dest = new(target);
@@ -6513,7 +6515,7 @@ namespace Game.Spells
if (result == SpellCastResult.SpellCastOk || result == SpellCastResult.UnitNotInfront) if (result == SpellCastResult.SpellCastOk || result == SpellCastResult.UnitNotInfront)
{ {
// do not check targets for ground-targeted spells (we target them on top of the intended target anyway) // do not check targets for ground-targeted spells (we target them on top of the intended target anyway)
if (GetSpellInfo().ExplicitTargetMask.HasAnyFlag((uint)SpellCastTargetFlags.DestLocation)) if (GetSpellInfo().GetExplicitTargetMask().HasAnyFlag(SpellCastTargetFlags.DestLocation))
return true; return true;
SelectSpellTargets(); SelectSpellTargets();
//check if among target units, our WANTED target is as well (.only self cast spells return false) //check if among target units, our WANTED target is as well (.only self cast spells return false)
+20 -11
View File
@@ -1193,7 +1193,7 @@ namespace Game.Spells
public SpellCastResult CheckExplicitTarget(WorldObject caster, WorldObject target, Item itemTarget = null) public SpellCastResult CheckExplicitTarget(WorldObject caster, WorldObject target, Item itemTarget = null)
{ {
SpellCastTargetFlags neededTargets = GetExplicitTargetMask(); SpellCastTargetFlags neededTargets = (SpellCastTargetFlags)RequiredExplicitTargetMask;
if (target == null) if (target == null)
{ {
if (Convert.ToBoolean(neededTargets & (SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.GameobjectMask | SpellCastTargetFlags.CorpseMask))) if (Convert.ToBoolean(neededTargets & (SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.GameobjectMask | SpellCastTargetFlags.CorpseMask)))
@@ -3221,31 +3221,39 @@ namespace Game.Spells
{ {
bool srcSet = false; bool srcSet = false;
bool dstSet = false; bool dstSet = false;
SpellCastTargetFlags targetMask = Targets;
// prepare target mask using effect target entries // prepare target mask using effect target entries
foreach (var effectInfo in GetEffects()) foreach (var effectInfo in GetEffects())
{ {
if (!effectInfo.IsEffect()) if (!effectInfo.IsEffect())
continue; continue;
SpellCastTargetFlags targetMask = 0;
targetMask |= effectInfo.TargetA.GetExplicitTargetMask(ref srcSet, ref dstSet); targetMask |= effectInfo.TargetA.GetExplicitTargetMask(ref srcSet, ref dstSet);
targetMask |= effectInfo.TargetB.GetExplicitTargetMask(ref srcSet, ref dstSet); targetMask |= effectInfo.TargetB.GetExplicitTargetMask(ref srcSet, ref dstSet);
// add explicit target flags based on spell effects which have SpellEffectImplicitTargetTypes.Explicit and no valid target provided // add explicit target flags based on spell effects which have SpellEffectImplicitTargetTypes.Explicit and no valid target provided
if (effectInfo.GetImplicitTargetType() != SpellEffectImplicitTargetTypes.Explicit) if (effectInfo.GetImplicitTargetType() == SpellEffectImplicitTargetTypes.Explicit)
continue; {
// extend explicit target mask only if valid targets for effect could not be provided by target types // extend explicit target mask only if valid targets for effect could not be provided by target types
SpellCastTargetFlags effectTargetMask = effectInfo.GetMissingTargetMask(srcSet, dstSet, targetMask); SpellCastTargetFlags effectTargetMask = effectInfo.GetMissingTargetMask(srcSet, dstSet, targetMask);
// don't add explicit object/dest flags when spell has no max range // don't add explicit object/dest flags when spell has no max range
if (GetMaxRange(true) == 0.0f && GetMaxRange(false) == 0.0f) if (GetMaxRange(true) == 0.0f && GetMaxRange(false) == 0.0f)
effectTargetMask &= ~(SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.Gameobject | SpellCastTargetFlags.CorpseMask | SpellCastTargetFlags.DestLocation); effectTargetMask &= ~(SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.Gameobject | SpellCastTargetFlags.CorpseMask | SpellCastTargetFlags.DestLocation);
targetMask |= effectTargetMask; targetMask |= effectTargetMask;
}
ExplicitTargetMask |= (uint)targetMask;
if (!effectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.DontFailSpellOnTargetingFailure))
RequiredExplicitTargetMask |= (uint)targetMask;
} }
ExplicitTargetMask = (uint)targetMask; ExplicitTargetMask |= (uint)Targets;
if (!HasAttribute(SpellAttr13.DoNotFailIfNoTarget))
RequiredExplicitTargetMask |= (uint)Targets;
} }
public bool _isPositiveTarget(SpellEffectInfo effect) public bool _isPositiveTarget(SpellEffectInfo effect)
@@ -3954,6 +3962,7 @@ namespace Game.Spells
// SpellScalingEntry // SpellScalingEntry
public ScalingInfo Scaling; public ScalingInfo Scaling;
public uint ExplicitTargetMask { get; set; } public uint ExplicitTargetMask { get; set; }
public uint RequiredExplicitTargetMask { get; set; }
public SpellChainNode ChainEntry { get; set; } public SpellChainNode ChainEntry { get; set; }
public SqrtDamageAndHealingDiminishingStruct SqrtDamageAndHealingDiminishing; public SqrtDamageAndHealingDiminishingStruct SqrtDamageAndHealingDiminishing;