Percentage chance to hit/crit combat calculator

A way of predicting percentage chance for player to hit an enemy target during his turn (in a semi-realtime/turn-based game with X-Com-style percentage chance to hit/crit displays), given the fact that there are other counter-attacking enemy AI (that may somehow hit the player first) at the current moment the player triggers an attack on the target. This can be factored into the given Percentage Chance Hit/Crit displays during Target Mode. See code comments on the rules. Thus, a lower health player (ie. a weakened player) may have lesser chance to hit a target given the presence of counterattacking enemies. In actual situations, the counterattacking enemies will roll against the player first, but the percentage display acts as a good predictor to determine his odds of hitting and survival. Every weapon has a range and swing/strike time associated with it, determining which side rolls first depending on who strikes first.