Chance to hit calculations - melindil/FTSE GitHub Wiki

When calculating chance to hit, the base chance is equal to the attacker's skill in the type of attack being made (Small Guns, Big Guns, etc.). The chance is then modified by each of the following:

  • Attacker injuries: -20 if left arm injured, -30 if winded or concussed, or -50 if blinded. Penalty is not applied if the attacker has the Rabid trait.

  • Penalty for targeted shot (-30 for targeting eyes, -20 for head, -15 for arms or groin, -10 for legs)

  • If attacker is using a ranged weapon, target is using melee/unarmed, and the attacker is within distance of 3: subtract 1 - (distance / 3.0) * target's melee/unarmed skill * 0.33

  • Subtract target's AC

  • -10 if in a moving vehicle, -20 if driving

  • -5 for each other Actor between attacker and target, max -20

  • +15 if target size is greater than 81 cubic hexes

  • Difficulty level adjustments: Player targeting AI has +17 on easy, -9 on hard, -20 on insane. AI targeting player has -12 on easy, +12 on hard, and +40 on insane

  • +40 if target knocked down/unconscious, +20 if target has broken leg and isn't Rabid

  • +10 if target is winded or concussed, if not Rabid (cumulative with above)

  • +20 if target is prone and distance is less than 2 hexes

  • Any accuracy bonus from the weapon mode

  • +15 if attacker has Targeting Computer trait

  • +4 per level of height advantage, max +30

  • Distance + light adjustments: First calculate effective distance: (attacker's PE + 2 if Sharpshooter perk) * (5 if scoped weapon, 4 if long-range weapon, 2 otherwise) * light level at target (1.0 if target is fully lit, glowing due to rads, attacker or target are Rabid, or attacker is using a night scope, less than 1.0 otherwise). Distance penalty is then (Distance to target - effective distance) * 4.0, minimum 0.

  • Another distance adjustment: If not a long-range weapon, and distance is less than 6.0, add (1 - (distance / 6.0))*30

  • Nearby cover: This appears to be badly bugged. The net effect is, if the target is east or west of the attacker by at least 12, then chance to hit is reduced for closely adjacent walls or obstacles, based on the screen direction of the wall from the target: -7 if wall/obstacle is up-right or down-left from the target (based on the angled isometric view), -15 if wall/obstacle is down-right, and 0 if wall/obstacle is up-left or no nearby wall/obstacle. The penalty applies even if the wall/obstacle is not between the attacker and target, so just standing next to a wall can give a defender an effective AC bonus. (It appears the first part was supposed to be just a range check, distance > 12.0, but isn't being calculated right. And, the direction checks appear wrong for the second part - probably should have been -7 for all directions. Not sure why the attacker's direction wasn't taken into account.)

  • Final value capped to minimum of 0, maximum of 95

Note that this list does not include factors that indirectly affect hit chance by modifying the above parameters. For example, crouching and prone position give bonus to AC and ranged skills while lowering melee/unarmed skills, but don't directly alter the hit chance beyond those effects.