diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-02-16 20:38:52 +0100 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2025-02-18 18:18:42 +0100 |
commit | 5bd53829104b2da6dae547b126bbcecba9629ac0 (patch) | |
tree | ad55ad17d629085cb01817a87d6bf79f15bafbe0 /src/server/game/Spells/SpellInfo.cpp | |
parent | ff5f141f8a09b37a4293ab5a0cbd0e5fd53f9039 (diff) |
Core/Spells: Implemented SpellEffectAttributes::DontFailSpellOnTargetingFailure
(cherry picked from commit 195945742105fa8dbd061f3b62b755d722655931)
Diffstat (limited to 'src/server/game/Spells/SpellInfo.cpp')
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 74981277a3b..467c6fae06f 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -2362,7 +2362,7 @@ SpellCastResult SpellInfo::CheckTarget(WorldObject const* caster, WorldObject co SpellCastResult SpellInfo::CheckExplicitTarget(WorldObject const* caster, WorldObject const* target, Item const* itemTarget /*= nullptr*/) const { - uint32 neededTargets = GetExplicitTargetMask(); + uint32 neededTargets = RequiredExplicitTargetMask; if (!target) { if (neededTargets & (TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT_MASK | TARGET_FLAG_CORPSE_MASK)) @@ -4424,31 +4424,38 @@ void SpellInfo::_InitializeExplicitTargetMask() { bool srcSet = false; bool dstSet = false; - uint32 targetMask = Targets; // prepare target mask using effect target entries for (SpellEffectInfo const& effect : GetEffects()) { if (!effect.IsEffect()) continue; + uint32 targetMask = 0; targetMask |= effect.TargetA.GetExplicitTargetMask(srcSet, dstSet); targetMask |= effect.TargetB.GetExplicitTargetMask(srcSet, dstSet); // add explicit target flags based on spell effects which have EFFECT_IMPLICIT_TARGET_EXPLICIT and no valid target provided - if (effect.GetImplicitTargetType() != EFFECT_IMPLICIT_TARGET_EXPLICIT) - continue; + if (effect.GetImplicitTargetType() == EFFECT_IMPLICIT_TARGET_EXPLICIT) + { - // extend explicit target mask only if valid targets for effect could not be provided by target types - uint32 effectTargetMask = effect.GetMissingTargetMask(srcSet, dstSet, targetMask); + // extend explicit target mask only if valid targets for effect could not be provided by target types + uint32 effectTargetMask = effect.GetMissingTargetMask(srcSet, dstSet, targetMask); - // don't add explicit object/dest flags when spell has no max range - if (GetMaxRange(true) == 0.0f && GetMaxRange(false) == 0.0f) - effectTargetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_DEST_LOCATION); + // don't add explicit object/dest flags when spell has no max range + if (GetMaxRange(true) == 0.0f && GetMaxRange(false) == 0.0f) + effectTargetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_DEST_LOCATION); + + targetMask |= effectTargetMask; + } - targetMask |= effectTargetMask; + ExplicitTargetMask |= targetMask; + if (!effect.EffectAttributes.HasFlag(SpellEffectAttributes::DontFailSpellOnTargetingFailure)) + RequiredExplicitTargetMask |= targetMask; } - ExplicitTargetMask = targetMask; + ExplicitTargetMask |= Targets; + if (!HasAttribute(SPELL_ATTR13_DO_NOT_FAIL_IF_NO_TARGET)) + RequiredExplicitTargetMask |= Targets; } inline bool _isPositiveTarget(SpellEffectInfo const& effect) |