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
Unk13 = 0x2000, // 13
Unk14 = 0x4000, // 14
Unk15 = 0x8000, // 15
DoNotFailIfNoTarget = 0x8000, // 15 Do Not Fail if No Target
Unk16 = 0x10000, // 16
Unk17 = 0x20000, // 17
ActivatesRequiredShapeshift = 0x40000, // 18
+3 -1
View File
@@ -1199,6 +1199,8 @@ namespace Game.Spells
void SelectImplicitTargetDestTargets(SpellEffectInfo spellEffectInfo, SpellImplicitTargetInfo targetType, SpellTargetIndex targetIndex)
{
WorldObject target = m_targets.GetObjectTarget();
if (target == null)
return;
SpellDestination dest = new(target);
@@ -6513,7 +6515,7 @@ namespace Game.Spells
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)
if (GetSpellInfo().ExplicitTargetMask.HasAnyFlag((uint)SpellCastTargetFlags.DestLocation))
if (GetSpellInfo().GetExplicitTargetMask().HasAnyFlag(SpellCastTargetFlags.DestLocation))
return true;
SelectSpellTargets();
//check if among target units, our WANTED target is as well (.only self cast spells return false)
+14 -5
View File
@@ -1193,7 +1193,7 @@ namespace Game.Spells
public SpellCastResult CheckExplicitTarget(WorldObject caster, WorldObject target, Item itemTarget = null)
{
SpellCastTargetFlags neededTargets = GetExplicitTargetMask();
SpellCastTargetFlags neededTargets = (SpellCastTargetFlags)RequiredExplicitTargetMask;
if (target == null)
{
if (Convert.ToBoolean(neededTargets & (SpellCastTargetFlags.UnitMask | SpellCastTargetFlags.GameobjectMask | SpellCastTargetFlags.CorpseMask)))
@@ -3221,19 +3221,20 @@ namespace Game.Spells
{
bool srcSet = false;
bool dstSet = false;
SpellCastTargetFlags targetMask = Targets;
// prepare target mask using effect target entries
foreach (var effectInfo in GetEffects())
{
if (!effectInfo.IsEffect())
continue;
SpellCastTargetFlags targetMask = 0;
targetMask |= effectInfo.TargetA.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
if (effectInfo.GetImplicitTargetType() != SpellEffectImplicitTargetTypes.Explicit)
continue;
if (effectInfo.GetImplicitTargetType() == SpellEffectImplicitTargetTypes.Explicit)
{
// extend explicit target mask only if valid targets for effect could not be provided by target types
SpellCastTargetFlags effectTargetMask = effectInfo.GetMissingTargetMask(srcSet, dstSet, targetMask);
@@ -3245,7 +3246,14 @@ namespace Game.Spells
targetMask |= effectTargetMask;
}
ExplicitTargetMask = (uint)targetMask;
ExplicitTargetMask |= (uint)targetMask;
if (!effectInfo.EffectAttributes.HasFlag(SpellEffectAttributes.DontFailSpellOnTargetingFailure))
RequiredExplicitTargetMask |= (uint)targetMask;
}
ExplicitTargetMask |= (uint)Targets;
if (!HasAttribute(SpellAttr13.DoNotFailIfNoTarget))
RequiredExplicitTargetMask |= (uint)Targets;
}
public bool _isPositiveTarget(SpellEffectInfo effect)
@@ -3954,6 +3962,7 @@ namespace Game.Spells
// SpellScalingEntry
public ScalingInfo Scaling;
public uint ExplicitTargetMask { get; set; }
public uint RequiredExplicitTargetMask { get; set; }
public SpellChainNode ChainEntry { get; set; }
public SqrtDamageAndHealingDiminishingStruct SqrtDamageAndHealingDiminishing;