public static bool PhysicalHit(AbilityState state, int targetIndex) { ICombatant er = state.Performer; ICombatant ee = state.Target[targetIndex]; int hitp; if (ee.Absorbs(state.Elements) || ee.Voids(state.Elements) || ee.Death || ee.Sleep || ee.Confusion || ee.Stop || ee.Petrify || ee.Manipulate || ee.Paralysed || ee.Peerless) { hitp = 255; } else { hitp = ((er.Dexterity / 4) + state.HitP) + er.Defp - ee.Defp; if (er.Fury) { hitp = hitp - hitp * 3 / 10; } } // Sanity if (hitp < 1) { hitp = 1; } int lucky = Game.Random.Next(0, 100); // Lucky Hit if (lucky < Math.Floor(state.Performer.Luck / 4.0d)) { hitp = 255; } // Lucky Evade else if (lucky < Math.Floor(ee.Luck / 4.0d)) { if (er is Ally && ee is Enemy) { hitp = 0; } } int r = Game.Random.Next(65536) * 99 / 65536 + 1; if (r < hitp) { return(true); } else { return(false); } }