Example #1
0
 public bool HasTarget(ImplicitSpellTargetType target)
 {
     if (ImplicitTargetA != target)
     {
         return(ImplicitTargetB == target);
     }
     return(true);
 }
Example #2
0
 /// <summary>
 /// More or less frequently occuring target pairs that make no sense
 /// </summary>
 private void RepairBrokenTargetPairs()
 {
     if (ImplicitTargetA != ImplicitSpellTargetType.Self ||
         ImplicitTargetB != ImplicitSpellTargetType.Duel)
     {
         return;
     }
     ImplicitTargetA = ImplicitSpellTargetType.None;
 }
Example #3
0
        public SpellFailedReason FindTargets(ImplicitSpellTargetType targetType)
        {
            var failedReason = SpellFailedReason.Ok;
            var def          = DefaultTargetDefinitions.GetTargetDefinition(targetType);

            if (def != null)
            {
                def.Collect(this, ref failedReason);
            }
            return(failedReason);
        }
Example #4
0
        public SpellFailedReason FindTargets(ImplicitSpellTargetType targetType)
        {
            SpellFailedReason failReason       = SpellFailedReason.Ok;
            TargetDefinition  targetDefinition = DefaultTargetDefinitions.GetTargetDefinition(targetType);

            if (targetDefinition != null)
            {
                targetDefinition.Collect(this, ref failReason);
            }
            return(failReason);
        }
Example #5
0
        /// <summary>
        /// Adds a new Effect to this Spell
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public SpellEffect AddEffect(SpellEffectType type, ImplicitSpellTargetType target)
        {
            var effect = new SpellEffect(this, EffectIndex.Custom) { EffectType = type };
            var effects = new SpellEffect[Effects.Length + 1];
            Array.Copy(Effects, effects, Effects.Length);
            Effects = effects;
            Effects[effects.Length - 1] = effect;

            effect.ImplicitTargetA = target;
            return effect;
        }
Example #6
0
        ///// <summary>
        ///// Removes the first Effect of the given Type and replace it with a new one which will be returned.
        ///// Appends a new one if none of the given type was found.
        ///// </summary>
        ///// <param name="type"></param>
        ///// <returns></returns>
        //public SpellEffect ReplaceEffect(SpellEffectType type, SpellEffectType newType, ImplicitTargetType target)
        //{
        //    for (var i = 0; i < Effects.Length; i++)
        //    {
        //        var effect = Effects[i];
        //        if (effect.EffectType == type)
        //        {
        //            return Effects[i] = new SpellEffect();
        //        }
        //    }
        //    return AddEffect(type, target);
        //}

        /// <summary>
        /// Adds a new Effect to this Spell
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public SpellEffect AddEffect(SpellEffectHandlerCreator creator, ImplicitSpellTargetType target)
        {
            var effect = AddEffect(SpellEffectType.Dummy, target);
            effect.SpellEffectHandlerCreator = creator;
            return effect;
        }
Example #7
0
		public bool HasTarget(ImplicitSpellTargetType target)
		{
			return ImplicitTargetA == target || ImplicitTargetB == target;
		}
 public static TargetFilter GetTargetFilter(ImplicitSpellTargetType target)
 {
     return(DefaultTargetDefinitions.DefaultTargetHandlers[(int)target]?.Filter);
 }
 /// <summary>
 /// Returns the handler and filter for the given target type
 /// </summary>
 public static TargetDefinition GetTargetDefinition(ImplicitSpellTargetType target)
 {
     return(DefaultTargetDefinitions.DefaultTargetHandlers[(int)target]);
 }
Example #10
0
        internal void Init2()
        {
            ValueMin           = BasePoints + 1;
            ValueMax           = BasePoints + DiceSides;
            IsTargetAreaEffect = TargetAreaEffects.Contains(ImplicitTargetA) ||
                                 TargetAreaEffects.Contains(ImplicitTargetB);
            if (AreaEffects.Contains(ImplicitTargetA))
            {
                IsAreaEffect = true;
                if (ImplicitTargetB != ImplicitSpellTargetType.None &&
                    AreaEffects.Contains(ImplicitTargetB))
                {
                    ImplicitTargetB = ImplicitSpellTargetType.None;
                }
            }
            else if (ImplicitTargetB != ImplicitSpellTargetType.None &&
                     AreaEffects.Contains(ImplicitTargetB))
            {
                IsAreaEffect    = true;
                ImplicitTargetA = ImplicitSpellTargetType.None;
            }

            if (IsPeriodic = Amplitude > 0)
            {
                _IsPeriodicAura = AuraType == AuraType.PeriodicDamage ||
                                  AuraType == AuraType.PeriodicDamagePercent ||
                                  (AuraType == AuraType.PeriodicEnergize ||
                                   AuraType == AuraType.PeriodicHeal) ||
                                  (AuraType == AuraType.PeriodicHealthFunnel ||
                                   AuraType == AuraType.PeriodicLeech ||
                                   AuraType == AuraType.PeriodicManaLeech) ||
                                  AuraType == AuraType.PeriodicTriggerSpell;
            }
            if (Spell.IsPassive)
            {
                HarmType = HarmType.Beneficial;
            }
            else
            {
                if (!HasTarget(ImplicitSpellTargetType.AllEnemiesAroundCaster,
                               ImplicitSpellTargetType.AllEnemiesInArea, ImplicitSpellTargetType.AllEnemiesInAreaChanneled,
                               ImplicitSpellTargetType.AllEnemiesInAreaInstant, ImplicitSpellTargetType.CurrentSelection))
                {
                    if (!HasTarget(ImplicitSpellTargetType.InFrontOfCaster,
                                   ImplicitSpellTargetType.InvisibleOrHiddenEnemiesAtLocationRadius,
                                   ImplicitSpellTargetType.LocationInFrontCaster,
                                   ImplicitSpellTargetType.NetherDrakeSummonLocation,
                                   ImplicitSpellTargetType.SelectedEnemyChanneled,
                                   ImplicitSpellTargetType.SelectedEnemyDeadlyPoison, ImplicitSpellTargetType.SingleEnemy,
                                   ImplicitSpellTargetType.SpreadableDesease, ImplicitSpellTargetType.TargetAtOrientationOfCaster))
                    {
                        goto label_13;
                    }
                }

                if (!HasTarget(ImplicitSpellTargetType.Self, ImplicitSpellTargetType.AllFriendlyInAura,
                               ImplicitSpellTargetType.AllParty, ImplicitSpellTargetType.AllPartyAroundCaster,
                               ImplicitSpellTargetType.AllPartyInArea, ImplicitSpellTargetType.PartyAroundCaster,
                               ImplicitSpellTargetType.AllPartyInAreaChanneled) || Spell.Mechanic.IsNegative())
                {
                    HarmType = HarmType.Harmful;
                    goto label_15;
                }

label_13:
                if (!HasTarget(ImplicitSpellTargetType.Duel) &&
                    (ImplicitTargetA != ImplicitSpellTargetType.None ||
                     ImplicitTargetB != ImplicitSpellTargetType.None))
                {
                    HarmType = HarmType.Beneficial;
                }
            }

label_15:
            if (AuraType == AuraType.ModManaRegen && Amplitude == 0)
            {
                Amplitude = ModManaRegenHandler.DefaultAmplitude;
            }
            if (HasTarget(ImplicitSpellTargetType.AllFriendlyInAura))
            {
                ImplicitTargetA = ImplicitSpellTargetType.AllFriendlyInAura;
                ImplicitTargetB = ImplicitSpellTargetType.None;
            }

            HasTargets =
                !NoTargetTypes.Contains(
                    ImplicitTargetA) ||
                !NoTargetTypes.Contains(
                    ImplicitTargetB);
            HasSingleTarget  = HasTargets && !IsAreaEffect;
            IsAreaAuraEffect = EffectType == SpellEffectType.PersistantAreaAura ||
                               EffectType == SpellEffectType.ApplyAreaAura ||
                               EffectType == SpellEffectType.ApplyRaidAura;
            if (EffectType == SpellEffectType.ApplyRaidAura)
            {
                ImplicitTargetA = (double)Radius <= 0.0
          ? ImplicitSpellTargetType.AllParty
          : ImplicitSpellTargetType.AllPartyInArea;
            }
            IsAuraEffect = IsAreaAuraEffect || EffectType == SpellEffectType.ApplyAura ||
                           (EffectType == SpellEffectType.ApplyAuraToMaster ||
                            EffectType == SpellEffectType.ApplyPetAura) ||
                           EffectType == SpellEffectType.ApplyStatAura ||
                           EffectType == SpellEffectType.ApplyStatAuraPercent;
            IsEnhancer = IsAuraEffect &&
                         (AuraType == AuraType.AddModifierFlat ||
                          AuraType == AuraType.AddModifierPercent);
            if (MiscValueType == typeof(DamageSchoolMask))
            {
                MiscValue &= sbyte.MaxValue;
            }
            MiscBitSet         = MiscValue > 0 ? Utility.GetSetIndices((uint)MiscValue) : new uint[0];
            MinValue           = BasePoints;
            IsStrikeEffectFlat = EffectType == SpellEffectType.WeaponDamage ||
                                 EffectType == SpellEffectType.WeaponDamageNoSchool ||
                                 EffectType == SpellEffectType.NormalizedWeaponDamagePlus;
            IsStrikeEffectPct = EffectType == SpellEffectType.WeaponPercentDamage;
            IsTotem           = HasTarget(ImplicitSpellTargetType.TotemAir) ||
                                HasTarget(ImplicitSpellTargetType.TotemEarth) ||
                                HasTarget(ImplicitSpellTargetType.TotemFire) ||
                                HasTarget(ImplicitSpellTargetType.TotemWater);
            IsProc = IsProc || ProcAuraTypes.Contains(AuraType);
            OverrideEffectValue =
                OverrideEffectValue || AuraType == AuraType.ProcTriggerSpellWithOverride;
            IsHealEffect = EffectType == SpellEffectType.Heal ||
                           EffectType == SpellEffectType.HealMaxHealth ||
                           AuraType == AuraType.PeriodicHeal ||
                           TriggerSpell != null && TriggerSpell.IsHealSpell;
            IsDamageEffect   = EffectType == SpellEffectType.SchoolDamage || IsStrikeEffect;
            IsModifierEffect =
                AuraType == AuraType.AddModifierFlat || AuraType == AuraType.AddModifierPercent;
            HasAffectMask =
                AffectMask.Any(mask => mask != 0U);
            if (HasAffectMask)
            {
                AffectMaskBitSet = Utility.GetSetIndices(AffectMask);
            }
            if (SpellEffectHandlerCreator == null)
            {
                SpellEffectHandlerCreator = SpellHandler.SpellEffectCreators[(int)EffectType];
            }
            if (IsAuraEffect && AuraEffectHandlerCreator == null)
            {
                AuraEffectHandlerCreator = AuraHandler.EffectHandlers[(int)AuraType];
                if (AuraEffectHandlerCreator == null)
                {
                    AuraEffectHandlerCreator = AuraHandler.EffectHandlers[0];
                }
            }

            RepairBrokenTargetPairs();
            IsEnchantmentEffect = EffectType == SpellEffectType.EnchantHeldItem ||
                                  EffectType == SpellEffectType.EnchantItem ||
                                  EffectType == SpellEffectType.EnchantItemTemporary;
            AISpellUtil.DecideDefaultTargetHandlerDefintion(this);
        }
Example #11
0
 /// <summary>
 /// Adds a SpellEffect that will be applied to an Aura to be casted on the given type of target
 /// </summary>
 public SpellEffect AddAuraEffect(AuraType type, ImplicitSpellTargetType targetType)
 {
     var effect = AddEffect(SpellEffectType.ApplyAura, targetType);
     effect.AuraType = type;
     return effect;
 }
Example #12
0
 public TargetPair(ImplicitSpellTargetType targetA, ImplicitSpellTargetType targetB)
 {
     TargetA = targetA;
     TargetB = targetB;
 }
Example #13
0
 public TargetPair(ImplicitSpellTargetType targetA, ImplicitSpellTargetType targetB)
 {
     TargetA = targetA;
     TargetB = targetB;
 }
		public static TargetFilter GetTargetFilter(ImplicitSpellTargetType target)
		{
			var def = DefaultTargetHandlers[(int)target];
			return def != null ? def.Filter : null;
		}
		/// <summary>
		/// Returns the handler and filter for the given target type
		/// </summary>
		public static TargetDefinition GetTargetDefinition(ImplicitSpellTargetType target)
		{
			return DefaultTargetHandlers[(int)target];
		}
Example #16
0
 /// <summary>
 /// Adds a SpellEffect that will trigger the given Spell on the given type of target
 /// </summary>
 public SpellEffect AddTriggerSpellEffect(SpellId triggerSpell, ImplicitSpellTargetType targetType)
 {
     var effect = AddEffect(SpellEffectType.TriggerSpell, targetType);
     effect.TriggerSpellId = triggerSpell;
     return effect;
 }
Example #17
0
 /// <summary>
 /// Adds a SpellEffect that will trigger the given Spell on the given type of target
 /// </summary>
 public SpellEffect AddPeriodicTriggerSpellEffect(SpellId triggerSpell, ImplicitSpellTargetType targetType)
 {
     var effect = AddAuraEffect(AuraType.PeriodicTriggerSpell);
     effect.TriggerSpellId = triggerSpell;
     effect.ImplicitTargetA = targetType;
     return effect;
 }
Example #18
0
 public bool HasTarget(ImplicitSpellTargetType target)
 {
     return(ImplicitTargetA == target || ImplicitTargetB == target);
 }
Example #19
0
 /// <summary>
 /// Adds a SpellEffect that will be applied to an Aura to be casted on the given type of target
 /// </summary>
 public SpellEffect AddAuraEffect(AuraEffectHandlerCreator creator, ImplicitSpellTargetType targetType)
 {
     var effect = AddEffect(SpellEffectType.ApplyAura, targetType);
     effect.AuraType = AuraType.Dummy;
     effect.AuraEffectHandlerCreator = creator;
     return effect;
 }
        public static TargetFilter GetTargetFilter(ImplicitSpellTargetType target)
        {
            var def = DefaultTargetHandlers[(int)target];

            return(def != null ? def.Filter : null);
        }