public bool[] Cast(Combatant source, Combatant[] targets, AbilityModifiers modifiers) { if (RandomTarget && targets.Count() > 1) { int index = source.CurrentBattle.Random.Next(targets.Count()); Combatant newTarget = targets.ToList()[index]; targets = new Combatant[] { newTarget }; } bool[] hits = new bool[targets.Length]; for (int i = 0; i < targets.Length; i++) { Combatant target = targets[i]; bool hit = HitFormula(source, target, modifiers); // We can still miss if each of the status changes misses bool actuallyHit = false; if (hit) { if (Power > 0) { int dam = DamageFormula(source, target, modifiers); dam = RunElementalChecks(dam, target, Elements); //dam = LowerSanityCkeck(dam); // not required as per the guides (besides, negative damage is OK (think cure) dam = UpperSanityCheck(dam); if (target.Peerless || target.Petrify) { dam = 0; } target.AcceptDamage(source, dam, Type); actuallyHit = true; } foreach (StatusChange statusChange in Statuses) { if (statusChange.Hits(source, target, modifiers)) { switch (statusChange.ChangeType) { case StatusChange.Effect.Cure: foreach (Status status in statusChange.Statuses) { target.GetType().GetMethod("Cure" + status).Invoke(target, new object[] { source }); } break; case StatusChange.Effect.Inflict: foreach (Status status in statusChange.Statuses) { target.GetType().GetMethod("Inflict" + status).Invoke(target, new object[] { source }); } break; case StatusChange.Effect.Toggle: foreach (Status status in statusChange.Statuses) { if ((bool)target.GetType().GetProperty(status.ToString()).GetValue(target, null)) { target.GetType().GetMethod("Cure" + status).Invoke(target, new object[] { source }); } else { target.GetType().GetMethod("Inflict" + status).Invoke(target, new object[] { source }); } } break; } actuallyHit = true; } } hits[i] = true; } if (!actuallyHit) { source.CurrentBattle.AddMissIcon(target); } } return(hits); }