Exemplo n.º 1
0
        /// <summary>
        /// AI heal spells.
        /// This evaluator demonstrates how to losen constraints - i.e. don't go for the best choice, but go for anyone that satisfies some condition.
        /// </summary>
        public static int AnyWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
        {
            if (!(target is Unit))
            {
                return(int.MaxValue);
            }
            Unit unit = (Unit)target;

            return(unit.MaxHealth - unit.Health >= effectHandler.CalcDamageValue() / 2 ? -1 : 0);
        }
Exemplo n.º 2
0
        /// <summary>AI heal spells</summary>
        public static int MostWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
        {
            if (!(target is Unit))
            {
                return(int.MaxValue);
            }
            Unit unit = (Unit)target;

            return(-Math.Min(unit.MaxHealth - unit.Health, effectHandler.CalcDamageValue()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// AI heal spells
        /// </summary>
        public static int MostWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
        {
            if (target is Unit)
            {
                // try to select the most wounded
                var unit          = (Unit)target;
                var missingHealth = unit.MaxHealth - unit.Health;

                // cap at the max that the spell can heal
                // else weaker creatures might never get healed, simply because they can't lose as much health
                return(-Math.Min(missingHealth, effectHandler.CalcDamageValue()));
            }
            return(int.MaxValue);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Only select targets that have at least half of what the effect can heal
        /// </summary>
        public static void IsWoundedEnough(SpellEffectHandler effectHandler, WorldObject target,
                                           ref SpellFailedReason failedReason)
        {
            if (target is Unit)
            {
                Unit unit = (Unit)target;
                if (unit.MaxHealth - unit.Health >= effectHandler.CalcDamageValue() / 2)
                {
                    return;
                }
            }

            failedReason = SpellFailedReason.AlreadyAtFullHealth;
        }
Exemplo n.º 5
0
		/// <summary>
		/// AI heal spells
		/// </summary>
		public static int MostWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
		{
			if (target is Unit)
			{
				// try to select the most wounded
				var unit = (Unit)target;
				var missingHealth = unit.MaxHealth - unit.Health;

				// cap at the max that the spell can heal
				// else weaker creatures might never get healed, simply because they can't lose as much health
				return -Math.Min(missingHealth, effectHandler.CalcDamageValue());
			}
			return int.MaxValue;
		}
Exemplo n.º 6
0
        /// <summary>
        /// Only select targets that have at least half of what the effect can heal
        /// </summary>
        public static void IsWoundedEnough(SpellEffectHandler effectHandler, WorldObject target, ref SpellFailedReason failedReason)
        {
            if (target is Unit)
            {
                // useful heal spell: Amount to be healed is greater or equal half of what the spell can heal
                // Select anyone with that problem
                var unit          = (Unit)target;
                var missingHealth = unit.MaxHealth - unit.Health;
                if (missingHealth >= effectHandler.CalcDamageValue() / 2)
                {
                    // good choice
                    return;
                }
            }

            // not wounded or not wounded enough
            failedReason = SpellFailedReason.AlreadyAtFullHealth;
        }
Exemplo n.º 7
0
 /// <summary>
 /// AI heal spells.
 /// This evaluator demonstrates how to losen constraints - i.e. don't go for the best choice, but go for anyone that satisfies some condition.
 /// </summary>
 public static int AnyWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
 {
     if (target is Unit)
     {
         // useful heal spell: Amount to be healed is greater or equal half of what the spell can heal
         // Select anyone with that problem
         var unit          = (Unit)target;
         var missingHealth = unit.MaxHealth - unit.Health;
         if (missingHealth >= effectHandler.CalcDamageValue() / 2)
         {
             // good choice
             return(-1);
         }
         // not so good choice
         return(0);
     }
     // should never happen
     return(int.MaxValue);
 }
Exemplo n.º 8
0
		/// <summary>
		/// AI heal spells.
		/// This evaluator demonstrates how to losen constraints - i.e. don't go for the best choice, but go for anyone that satisfies some condition.
		/// </summary>
		public static int AnyWoundedEvaluator(SpellEffectHandler effectHandler, WorldObject target)
		{
			if (target is Unit)
			{
				// useful heal spell: Amount to be healed is greater or equal half of what the spell can heal
				// Select anyone with that problem
				var unit = (Unit)target;
				var missingHealth = unit.MaxHealth - unit.Health;
				if (missingHealth >= effectHandler.CalcDamageValue() / 2)
				{
					// good choice
					return -1;
				}
				// not so good choice
				return 0;
			}
			// should never happen
			return int.MaxValue;
		}
Exemplo n.º 9
0
		/// <summary>
		/// Only select targets that have at least half of what the effect can heal
		/// </summary>
		public static void IsWoundedEnough(SpellEffectHandler effectHandler, WorldObject target, ref SpellFailedReason failedReason)
		{
			if (target is Unit)
			{
				// useful heal spell: Amount to be healed is greater or equal half of what the spell can heal
				// Select anyone with that problem
				var unit = (Unit)target;
				var missingHealth = unit.MaxHealth - unit.Health;
				if (missingHealth >= effectHandler.CalcDamageValue() / 2)
				{
					// good choice
					return;
				}
			}

			// not wounded or not wounded enough
			failedReason = SpellFailedReason.AlreadyAtFullHealth;
		}