private void PopulatePassive() { explicitTargetType = SpellExplicitTargetType.Caster; damageClass = SpellDamageClass.None; spellDispel = SpellDispelType.None; mechanic = SpellMechanics.None; explicitCastTargets = SpellCastTargetFlags.UnitAlly; schoolMask = 0; preventionType = 0; attributes = SpellAttributes.Passive; attributesExtra = SpellExtraAttributes.DoesNotTriggerGcd | SpellExtraAttributes.IgnoreGcd | SpellExtraAttributes.NotStealable; attributesCustom = SpellCustomAttributes.CastWithoutAnimation; targetEntityTypeMask = EnityTypeMask.Unit; rangedFlags = SpellRangeFlags.Default; interruptFlags = 0; castIgnoringMechanics = 0; cooldownTime = 0; categoryCooldownTime = 0; globalCooldownTime = 0; castTime = 0; minCastTime = 0; minRangeHostile = 0; minRangeFriend = 0; maxRangeHostile = 0; maxRangeFriend = 0; speed = 0; }
protected override void OnRegister() { base.OnRegister(); combinedEffectMechanics = Mechanic.AsFlag(); maxTargetingRadius = 0.0f; shapeShiftAlwaysCastableSet = new HashSet <ShapeShiftForm>(shapeShiftAlwaysCastable); shapeShiftNeverCastableSet = new HashSet <ShapeShiftForm>(shapeShiftNeverCastable); foreach (SpellEffectInfo spellEffectInfo in spellEffectInfos) { if (spellEffectInfo is EffectApplyAura auraApplyEffect) { for (int index = 0; index < auraApplyEffect.AuraInfo.AuraEffects.Count; index++) { combinedEffectMechanics |= auraApplyEffect.AuraInfo.AuraEffects[index].Mechanics.AsFlag(); } } if (spellEffectInfo.Targeting is SpellTargetingArea areaTargeting) { maxTargetingRadius = Mathf.Max(areaTargeting.MaxRadius, maxTargetingRadius); } if (spellEffectInfo.IgnoresSpellImmunity) { someEffectsIgnoreSpellImmunity = true; } } }
protected override void OnUnregister() { shapeShiftAlwaysCastableSet.Clear(); shapeShiftNeverCastableSet.Clear(); combinedEffectMechanics = Mechanic.AsFlag(); maxTargetingRadius = 0.0f; base.OnUnregister(); }
public bool HasAnyMechanics(SpellMechanicsFlags mechanicsFlags) { foreach (AuraEffectInfo auraEffectInfo in auraEffects) { if (auraEffectInfo.Mechanics != SpellMechanics.None && mechanicsFlags.HasTargetFlag(auraEffectInfo.Mechanics.AsFlag())) { return(true); } } return(false); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } SpellMechanicsFlags immuneMechanics = 0; for (int i = 0; i < EffectInfo.ImmuneMechanics.Count; i++) { auraApplication.Target.Spells.ModifyMechanicsImmunity(Aura.SpellInfo, EffectInfo.ImmuneMechanics[i], apply); immuneMechanics |= EffectInfo.ImmuneMechanics[i].AsFlag(); } if (apply && Aura.SpellInfo.HasAttribute(SpellAttributes.DispelAurasOnImmunity)) { var applicaionsToRemove = new List <AuraApplication>(); for (var index = 0; index < auraApplication.Target.AuraApplications.Count; index++) { AuraApplication otherApplication = auraApplication.Target.AuraApplications[index]; if (!otherApplication.Aura.AuraInfo.HasAnyMechanics(immuneMechanics)) { continue; } if (!Aura.CanDispel(otherApplication.Aura)) { continue; } applicaionsToRemove.Add(otherApplication); } foreach (AuraApplication applicationToRemove in applicaionsToRemove) { if (applicationToRemove.RemoveMode == AuraRemoveMode.None) { auraApplication.Target.Auras.RemoveAuraWithApplication(applicationToRemove, AuraRemoveMode.Immunity); } } } }
internal void PopulateEffectInfo() { combinedEffectMechanics = Mechanic.AsFlag(); maxTargetingRadius = 0.0f; foreach (SpellEffectInfo spellEffectInfo in spellEffectInfos) { if (spellEffectInfo is EffectApplyAura auraApplyEffect) { for (int index = 0; index < auraApplyEffect.AuraInfo.AuraEffects.Count; index++) { combinedEffectMechanics |= auraApplyEffect.AuraInfo.AuraEffects[index].Mechanics.AsFlag(); } } if (spellEffectInfo.Targeting is SpellTargetingArea areaTargeting) { maxTargetingRadius = Mathf.Max(areaTargeting.MaxRadius, maxTargetingRadius); } } }
private SpellCastResult ValidateMechanics(AuraEffectType auraEffectType) { IReadOnlyList <AuraEffect> activeEffects = Caster.Auras.GetAuraEffects(auraEffectType); if (activeEffects == null) { return(SpellCastResult.Success); } for (int i = 0; i < activeEffects.Count; i++) { SpellMechanicsFlags combinedEffectMechanics = activeEffects[i].Aura.SpellInfo.CombinedEffectMechanics; if (combinedEffectMechanics == 0) { continue; } if (!SpellInfo.CastIgnoringMechanics.HasTargetFlag(combinedEffectMechanics)) { switch (auraEffectType) { case AuraEffectType.StunState: return(SpellCastResult.Stunned); case AuraEffectType.ModFear: return(SpellCastResult.Fleeing); case AuraEffectType.ConfusionState: return(SpellCastResult.Confused); default: return(SpellCastResult.NotKnown); } } } return(SpellCastResult.Success); }
public static bool HasAnyFlag(this SpellMechanicsFlags baseFlags, SpellMechanicsFlags flag) { return((baseFlags & flag) != 0); }
public static bool HasTargetFlag(this SpellMechanicsFlags baseFlags, SpellMechanicsFlags flag) { return((baseFlags & flag) == flag); }