Пример #1
0
        private void TriggerProcOnStrike()
        {
            if (Weapon == null || SpellEffect != null)
            {
                return;
            }
            ProcTriggerFlags flags1 = ProcTriggerFlags.None;
            ProcTriggerFlags flags2 = ProcTriggerFlags.None;

            if (Weapon.IsMelee)
            {
                flags1 |= ProcTriggerFlags.DoneMeleeAutoAttack;
                flags2 |= ProcTriggerFlags.ReceivedMeleeAutoAttack;
            }
            else if (Weapon.IsRanged)
            {
                flags1 |= ProcTriggerFlags.DoneRangedAutoAttack;
                flags2 |= ProcTriggerFlags.ReceivedRangedAutoAttack;
            }

            if (Attacker != null && Attacker.IsAlive)
            {
                Attacker.Proc(flags1, Victim, this, true, ProcHitFlags);
            }
            if (Victim == null || !Victim.IsAlive)
            {
                return;
            }
            Victim.Proc(flags2, Attacker, this, true, ProcHitFlags);
        }
Пример #2
0
        private void TriggerProcOnStrike()
        {
            if (this.Weapon == null || this.SpellEffect != null)
            {
                return;
            }
            ProcTriggerFlags flags1 = ProcTriggerFlags.None;
            ProcTriggerFlags flags2 = ProcTriggerFlags.None;

            if (this.Weapon.IsMelee)
            {
                flags1 |= ProcTriggerFlags.DoneMeleeAutoAttack;
                flags2 |= ProcTriggerFlags.ReceivedMeleeAutoAttack;
            }
            else if (this.Weapon.IsRanged)
            {
                flags1 |= ProcTriggerFlags.DoneRangedAutoAttack;
                flags2 |= ProcTriggerFlags.ReceivedRangedAutoAttack;
            }

            if (this.Attacker != null && this.Attacker.IsAlive)
            {
                this.Attacker.Proc(flags1, this.Victim, (IUnitAction)this, true, this.ProcHitFlags);
            }
            if (this.Victim == null || !this.Victim.IsAlive)
            {
                return;
            }
            this.Victim.Proc(flags2, this.Attacker, (IUnitAction)this, true, this.ProcHitFlags);
        }
 public TriggerSpellProcHandlerTemplate(Spell spell, ProcTriggerFlags triggerFlags,
                                        ProcValidator validator = null, ProcHitFlags hitFlags = ProcHitFlags.None, uint procChance = 100,
                                        int stackCount          = 0)
     : base(triggerFlags, hitFlags, null, validator, procChance, stackCount)
 {
     Spell      = spell;
     ProcAction = ProcSpell;
 }
 public TriggerSpellProcHandlerTemplate(Spell spell, ProcTriggerFlags triggerFlags,
                                        ProcValidator validator = null, ProcHitFlags hitFlags = ProcHitFlags.None, uint procChance = 100,
                                        int stackCount          = 0)
     : base(triggerFlags, hitFlags, (ProcCallback)null, validator, procChance, stackCount)
 {
     this.Spell      = spell;
     this.ProcAction = new ProcCallback(this.ProcSpell);
 }
Пример #5
0
 public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcHitFlags hitFlags, ProcCallback procAction, ProcValidator validator = null, uint procChance = 100u, int stackCount = 0)
 {
     ProcTriggerFlags = triggerFlags;
     ProcHitFlags     = hitFlags;
     ProcChance       = procChance;
     Validator        = validator;
     ProcAction       = procAction;
     m_stackCount     = stackCount;
 }
Пример #6
0
 public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcHitFlags hitFlags, ProcCallback procAction,
                            uint procChance = 100, int stackCount = 0)
 {
     this.ProcTriggerFlags = triggerFlags;
     this.ProcHitFlags     = hitFlags;
     this.ProcChance       = procChance;
     this.Validator        = (ProcValidator)null;
     this.ProcAction       = procAction;
     this.m_stackCount     = stackCount;
 }
Пример #7
0
 /// <summary>
 /// Idles for the given time before resuming its normal activities
 /// Also will unset the current Target and stop fighting.
 /// </summary>
 /// <remarks>Requires Brain</remarks>
 public void Idle(int millis, ProcTriggerFlags interruptFlags)
 {
     if (CheckBrain())
     {
         Target = null;
         m_brain.CurrentAction = new AITemporaryIdleAction(millis, interruptFlags, () =>
         {
             m_brain.StopCurrentAction();
         });
     }
 }
Пример #8
0
        /// <summary>
        /// Trigger proc on the caster of the spell.
        /// </summary>
        /// <param name="flags">What spell caster casted ie. ProcTriggerFlags.DoneHarmfulSpell</param>
        /// <param name="hitFlags">Hit result of the spell</param>
        private void TriggerProcOnCaster(ProcTriggerFlags flags, ProcHitFlags hitFlags)
        {
            var casterAction = new SimpleUnitAction
            {
                Attacker   = CasterUnit,
                Spell      = Spell,
                Victim     = m_hitInfoByTarget.Count > 0 ? m_hitInfoByTarget.First().Key : null,
                IsCritical = hitFlags.HasAnyFlag(ProcHitFlags.CriticalHit)
            };

            var triggerer = UnitTargets.FirstOrDefault();

            CasterUnit.Proc(flags, triggerer, casterAction, true, hitFlags);
        }
Пример #9
0
        /// <summary>
        /// Triggers proc on all targets of SpellCast
        /// </summary>
        /// <param name="flags">What happened to targets ie. ProcTriggerFlags.ReceivedHarmfulSpell</param>
        /// <returns>Combination of hit result on all targets.</returns>
        private ProcHitFlags TriggerProcOnTargets(ProcTriggerFlags flags)
        {
            ProcHitFlags hitFlagsCombination = ProcHitFlags.None;

            foreach (var hitInfo in m_hitInfoByTarget)
            {
                Unit         target         = hitInfo.Key;
                ProcHitFlags targetHitFlags = hitInfo.Value;

                hitFlagsCombination |= targetHitFlags;

                var action = new SimpleUnitAction
                {
                    Attacker   = CasterUnit,
                    Spell      = Spell,
                    Victim     = target,
                    IsCritical = targetHitFlags.HasAnyFlag(ProcHitFlags.CriticalHit)
                };

                target.Proc(flags, CasterUnit, action, true, targetHitFlags);
            }

            return(hitFlagsCombination);
        }
Пример #10
0
        void TriggerProcOnCasted()
        {
            // Set the flags for caster and target based on the spell
            ProcTriggerFlags casterProcFlags = ProcTriggerFlags.None;
            ProcTriggerFlags targetProcFlags = ProcTriggerFlags.None;

            switch (Spell.DamageType)
            {
            case DamageType.None:
            {
                if (Spell.IsBeneficial)
                {
                    casterProcFlags |= ProcTriggerFlags.DoneBeneficialSpell;
                    targetProcFlags |= ProcTriggerFlags.ReceivedBeneficialSpell;
                }
                else if (Spell.IsHarmful)
                {
                    casterProcFlags |= ProcTriggerFlags.DoneHarmfulSpell;
                    targetProcFlags |= ProcTriggerFlags.ReceivedHarmfulSpell;
                }
                break;
            }

            case DamageType.Magic:
            {
                if (Spell.IsBeneficial)
                {
                    casterProcFlags |= ProcTriggerFlags.DoneBeneficialMagicSpell;
                    targetProcFlags |= ProcTriggerFlags.ReceivedBeneficialMagicSpell;
                }
                else if (Spell.IsHarmful)
                {
                    casterProcFlags |= ProcTriggerFlags.DoneHarmfulMagicSpell;
                    targetProcFlags |= ProcTriggerFlags.ReceivedHarmfulMagicSpell;
                }
                break;
            }

            case DamageType.Melee:
            {
                casterProcFlags |= ProcTriggerFlags.DoneMeleeSpell;
                targetProcFlags |= ProcTriggerFlags.ReceivedMeleeSpell;
                break;
            }

            case DamageType.Ranged:
            {
                if (Spell.IsAutoRepeating)
                {
                    casterProcFlags |= ProcTriggerFlags.DoneRangedAutoAttack;
                    targetProcFlags |= ProcTriggerFlags.ReceivedRangedAutoAttack;
                }
                else
                {
                    casterProcFlags |= ProcTriggerFlags.DoneRangedSpell;
                    targetProcFlags |= ProcTriggerFlags.ReceivedRangedSpell;
                }
                break;
            }
            }

            ProcHitFlags casterHitFlags = TriggerProcOnTargets(targetProcFlags);

            TriggerProcOnCaster(casterProcFlags, casterHitFlags);
        }
Пример #11
0
		public TriggerSpellProcHandlerTemplate(Spell spell, ProcTriggerFlags triggerFlags, ProcHitFlags hitFlags = ProcHitFlags.None, uint procChance = 100u, int stackCount = 0)
			: this(spell, triggerFlags, null, hitFlags, procChance, stackCount)
		{
		}
Пример #12
0
		public TriggerSpellProcHandlerTemplate(Spell spell, ProcTriggerFlags triggerFlags, ProcValidator validator = null, ProcHitFlags hitFlags = ProcHitFlags.None, uint procChance = 100u, int stackCount = 0)
			: base(triggerFlags, hitFlags, null, validator, procChance, stackCount)
		{
			Spell = spell;
			ProcAction = ProcSpell;
		}
Пример #13
0
		public TriggerSpellProcHandler(ProcTriggerFlags triggerFlags, ProcValidator validator, Spell spell) :
			this(validator, spell)
		{
			ProcTriggerFlags = triggerFlags;
		}
Пример #14
0
		public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcValidator validator, ProcCallback procAction)
			: this(triggerFlags, validator, procAction, 100)
		{
		}
Пример #15
0
		public TriggerSpellProcHandler(ProcTriggerFlags triggerFlags, ProcValidator validator, Spell spell, uint procChance, int stackCount)
			: this(triggerFlags, validator, spell, procChance)
		{
			StackCount = stackCount;
		}
Пример #16
0
		public TriggerSpellProcHandler(ProcTriggerFlags triggerFlags, ProcValidator validator, Spell spell, uint procChance)
			: this(triggerFlags, validator, spell)
		{
			ProcChance = procChance;
		}
Пример #17
0
		/// <summary>
		/// Trigger all procs that can be triggered by the given action
		/// </summary>
		/// <param name="active">Whether the triggerer is the attacker/caster (true), or the victim (false)</param>
		public void Proc(ProcTriggerFlags flags, Unit triggerer, IUnitAction action, bool active)
		{
			if (m_brain != null && m_brain.CurrentAction != null && (m_brain.CurrentAction.InterruptFlags & flags) != 0)
			{
				// check if the current action has been interrupted
				m_brain.StopCurrentAction();
			}

			if (m_procHandlers == null)
			{
				return;
			}

			if (flags.And(ProcTriggerFlags.GainExperience) && !YieldsXpOrHonor)
			{
				flags ^= ProcTriggerFlags.GainExperience;
			}

			if (flags == ProcTriggerFlags.None)
			{
				return;
			}

			if (triggerer == null)
			{
				log.Error("triggerer was null when triggering Proc by action: {0} (Flags: {1})", action, flags);
				return;
			}

			for (var i = 0; i < m_procHandlers.Count; i++)
			{
				var proc = m_procHandlers[i];
				if ((proc.ProcTriggerFlags & flags) != 0 &&
					proc.CanBeTriggeredBy(triggerer, action, active))
				{
					if (Utility.Random(0, 101) <= proc.ProcChance)
					{
						var charges = proc.StackCount;
						proc.TriggerProc(triggerer, action);

						if (charges > 0 && proc.StackCount == 0)
						{
							proc.Dispose();
						}
					}
				}
			}
		}
Пример #18
0
		public static bool HasAnyFlag(this ProcTriggerFlags flags, ProcTriggerFlags otherFlags)
		{
			return (flags & otherFlags) != 0;
		}
Пример #19
0
 public static bool RequireHitFlags(this ProcTriggerFlags flags)
 {
     return(flags.HasAnyFlag(ProcTriggerFlags.RequiringHitFlags));
 }
Пример #20
0
 public static bool HasAnyFlag(this ProcTriggerFlags flags, ProcTriggerFlags otherFlags)
 {
     return((flags & otherFlags) != ProcTriggerFlags.None);
 }
Пример #21
0
 public AITemporaryIdleAction(int millis, ProcTriggerFlags flags, Action callback)
 {
     this.m_Millis   = millis;
     this.m_Flags    = flags;
     this.m_Callback = callback;
 }
Пример #22
0
		public static bool And(this ProcTriggerFlags mask, ProcTriggerFlags matchMask)
		{
			return (mask & matchMask) != ProcTriggerFlags.None;
		}
Пример #23
0
		public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcValidator validator, ProcCallback procAction, uint procChance)
			: this(triggerFlags, validator, procAction, procChance, 0)
		{
		}
Пример #24
0
 public AITemporaryIdleAction(int millis, ProcTriggerFlags flags, Action callback)
 {
     m_Millis = millis;
     m_Flags = flags;
     m_Callback = callback;
 }
Пример #25
0
 public ArcanePotencyProcHandler(ProcTriggerFlags flags, int valPercentage)
 {
     modPercentage = valPercentage;
     trigger = false;
 }
Пример #26
0
 public TriggerSpellProcHandlerTemplate(Spell spell, ProcTriggerFlags triggerFlags, ProcHitFlags hitFlags = ProcHitFlags.None, uint procChance = 100u, int stackCount = 0)
     : this(spell, triggerFlags, null, hitFlags, procChance, stackCount)
 {
 }
Пример #27
0
		/// <summary>
		/// Trigger proc on the caster of the spell.
		/// </summary>
		/// <param name="flags">What spell caster casted ie. ProcTriggerFlags.DoneHarmfulSpell</param>
		/// <param name="hitFlags">Hit result of the spell</param>
		private void TriggerProcOnCaster(ProcTriggerFlags flags, ProcHitFlags hitFlags)
		{
			var casterAction = new SimpleUnitAction
			{
				Attacker = CasterUnit,
				Spell = Spell,
				Victim = m_hitInfoByTarget.Count > 0 ? m_hitInfoByTarget.First().Key : null,
				IsCritical = hitFlags.HasAnyFlag(ProcHitFlags.CriticalHit)
			};

			var triggerer = UnitTargets.FirstOrDefault();

			CasterUnit.Proc(flags, triggerer, casterAction, true, hitFlags);
		}
Пример #28
0
 public ArcanePotencyProcHandler(ProcTriggerFlags flags, int valPercentage)
 {
     modPercentage = valPercentage;
     trigger       = false;
 }
Пример #29
0
		public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcValidator validator, ProcCallback procAction, uint procChance, int stackCount)
		{
			ProcTriggerFlags = triggerFlags;
			Validator = validator;
			ProcChance = procChance;
			ProcAction = procAction;
			m_stackCount = stackCount;
		}
Пример #30
0
 /// <summary>
 /// Idles until the given flags have been triggered.
 /// Also will unset the current Target and stop fighting.
 /// </summary>
 /// <remarks>Requires Brain</remarks>
 public void Idle(ProcTriggerFlags interruptFlags)
 {
     Idle(int.MaxValue, interruptFlags);
 }
Пример #31
0
		/// <summary>
		/// Idles until the given flags have been triggered.
		/// Also will unset the current Target and stop fighting.
		/// </summary>
		/// <remarks>Requires Brain</remarks>
		public void Idle(ProcTriggerFlags interruptFlags)
		{
			Idle(int.MaxValue, interruptFlags);
		}
Пример #32
0
		/// <summary>
		/// Triggers proc on all targets of SpellCast
		/// </summary>
		/// <param name="flags">What happened to targets ie. ProcTriggerFlags.ReceivedHarmfulSpell</param>
		/// <returns>Combination of hit result on all targets.</returns>
		private ProcHitFlags TriggerProcOnTargets(ProcTriggerFlags flags)
		{
			ProcHitFlags hitFlagsCombination = ProcHitFlags.None;

			foreach (var hitInfo in m_hitInfoByTarget)
			{
				Unit target = hitInfo.Key;
				ProcHitFlags targetHitFlags = hitInfo.Value;

				hitFlagsCombination |= targetHitFlags;

				var action = new SimpleUnitAction
				{
					Attacker = CasterUnit,
					Spell = Spell,
					Victim = target,
					IsCritical = targetHitFlags.HasAnyFlag(ProcHitFlags.CriticalHit)
				};

				target.Proc(flags, CasterUnit, action, true, targetHitFlags);
			}

			return hitFlagsCombination;
		}
Пример #33
0
		/// <summary>
		/// Idles for the given time before resuming its normal activities
		/// Also will unset the current Target and stop fighting.
		/// </summary>
		/// <remarks>Requires Brain</remarks>
		public void Idle(int millis, ProcTriggerFlags interruptFlags)
		{
			if (CheckBrain())
			{
				Target = null;
				m_brain.CurrentAction = new AITemporaryIdleAction(millis, interruptFlags, () =>
				{
					m_brain.StopCurrentAction();
				});
			}
		}
Пример #34
0
		/// <summary>
		/// Trigger all procs that can be triggered by the given action
		/// </summary>
		/// <param name="active">Whether the triggerer is the attacker/caster (true), or the victim (false)</param>
		public void Proc(ProcTriggerFlags flags, Unit triggerer, IUnitAction action, bool active)
		{
			if (m_brain != null && m_brain.CurrentAction != null && m_brain.CurrentAction.InterruptFlags.HasAnyFlag(flags))
			{
				// check if the current action has been interrupted
				m_brain.StopCurrentAction();
			}

			if (m_procHandlers == null)
			{
				return;
			}

			if (flags == ProcTriggerFlags.None) // || !action.CanProc)
			{
				return;
			}

			if (triggerer == null)
			{
				log.Error("triggerer was null when triggering Proc by action: {0} (Flags: {1})", action, flags);
				return;
			}

			var now = DateTime.Now;
			for (var i = m_procHandlers.Count - 1; i >= 0; i--)	// need to reverse iteration because procs can be removed in the process
			{
				if (i >= m_procHandlers.Count)
				{
					// In case that the list was changed during iteration
					continue;
				}
				var proc = m_procHandlers[i];
				if (proc.NextProcTime <= now &&
					proc.ProcTriggerFlags.HasAnyFlag(flags) &&
					proc.CanBeTriggeredBy(triggerer, action, active))
				{
					var chance = (int)proc.ProcChance;
					if (chance > 0 && this is Character && action.Spell != null)
					{
						chance = ((Character)this).PlayerSpells.GetModifiedInt(SpellModifierType.ProcChance, action.Spell, chance);
					}

					if (proc.ProcChance <= 0 || Utility.Random(0, 101) <= chance)
					{
						var charges = proc.StackCount;
						proc.TriggerProc(triggerer, action);
						if (proc.MinProcDelay > 0)
						{
							proc.NextProcTime = now.AddMilliseconds(proc.MinProcDelay);
						}

						if (charges > 0 && proc.StackCount == 0)
						{
							proc.Dispose();
							//proc.NextProcTime = DateTime.MaxValue;	// won't be proc'ed again
						}
					}
				}
			}
		}
Пример #35
0
		public ProcHandlerTemplate(ProcTriggerFlags triggerFlags, ProcHitFlags hitFlags, ProcCallback procAction, ProcValidator validator = null, uint procChance = 100u, int stackCount = 0)
		{
			ProcTriggerFlags = triggerFlags;
			ProcHitFlags = hitFlags;
			ProcChance = procChance;
			Validator = validator;
			ProcAction = procAction;
			m_stackCount = stackCount;
		}