/// <summary> /// Returns true if a consumable was consumed or a healing attack was used and false otherwise /// </summary> /// <param name="user">The enemy consuming the consumable</param> /// <param name="statPercentages">An array that contains all of the percent stat at which the user will consume the consumable.</param> /// <returns>True if a consumable was consumed and false otherwise</returns> public static bool AutoConsume(Enemy user, double[] statPercentages) { if (user.InventoryConsumables.Count < 1) { return(false); } double[] percentStats = user.PercentStats; for (int i = 0; i < GameBase.NumStats; i++) { try { if (percentStats[i] < statPercentages[i]) { Consumable consumable = FindUsableConsumable(user, (GameBase.Stats)i); Attack bestHealyAttack = user.FindBestHealingAttack(user, (GameBase.Stats)i); if (consumable != null && bestHealyAttack != null) { if (consumable.GetLifetimeStatGain(user, (GameBase.Stats)i) > (bestHealyAttack.GetLifetimeStatLoss(user, (GameBase.Stats)i) * -1) / (bestHealyAttack.ChargeUp + 1)) { user.Consume(consumable); } else { user.DoAttack(bestHealyAttack, user); } return(true); } else if (consumable != null) { user.Consume(consumable); return(true); } else if (bestHealyAttack != null) { user.DoAttack(bestHealyAttack, user); return(true); } } } catch (IndexOutOfRangeException) { } } return(false); }
/// <summary> /// Returns true if a consumable was consumed or a healing attack was used and false otherwise /// </summary> /// <param name="user">The enemy consuming the consumable</param> /// <param name="stat">The stat to evaluate</param> /// <returns>True if a consumable was consumed and false otherwise</returns> public static bool AutoConsume(Enemy user, GameBase.Stats stat, double statPercentage) { if (user.InventoryConsumables.Count < 1) { return(false); } int i = (int)stat; if (user.PercentStats[i] >= statPercentage) { return(false); } Consumable consumable = FindUsableConsumable(user, stat); Attack bestHealyAttack = user.FindBestHealingAttack(user, stat); if (consumable != null && bestHealyAttack != null) { if (consumable.GetLifetimeStatGain(user, stat) > (bestHealyAttack.GetLifetimeStatLoss(user, stat) * -1) / (bestHealyAttack.ChargeUp + 1)) { user.Consume(consumable); } else { user.DoAttack(bestHealyAttack, user); } return(true); } else if (consumable != null) { user.Consume(consumable); return(true); } else if (bestHealyAttack != null) { user.DoAttack(bestHealyAttack, user); return(true); } else { return(false); } }