Odds
A shot's odds, hit, graze or miss, by aim, defence, cover and distance
factletoutcome out of 100belowexpect forecastA shot's odds, hit, graze or miss, lifted from the tactics slice's content\rifle.ledger (Shoot), with its units from content\units.ledger and content\dummies.ledger. The hit chance is the shooter's Aim less the target's Defense, less 20 a level of cover, less 4 for each cell past 4 away; one draw out of 100 below it hits for the weapon's damage, the next 10 graze for half, and the rest miss. Sight and cover are facts the game's space answers; the odds the game shows are the order's forecast.
1
# A shot's odds, hit, graze or miss, lifted from the tactics slice's content\rifle.ledger (Shoot), with its units from2
# content\units.ledger and content\dummies.ledger. The hit chance is the shooter's Aim less the target's Defense, less3
# 20 a level of cover, less 4 for each cell past 4 away; one draw out of 100 below it hits for the weapon's damage, the4
# next 10 graze for half, and the rest miss. Sight and cover are facts the game's space answers; the odds the game shows5
# are the order's forecast.7
rate 108
link team9
allegiance team10
fact Sight Cover11
stat MaxHealth12
stat Aim13
stat Defense14
stat WeaponDamage15
pool Health max MaxHealth whole16
pool Actions max 1 whole17
damage Health18
tags Shot20
ability Shoot21
tags Shot22
target one enemy within 923
requires fact(Sight, holder, target) > 0 else "no line of sight"24
cost Actions 125
let hit = holder.Aim - target.Defense - 20 * fact(Cover, holder, target) - 4 * max(0, distance(holder, target) - 4)26
outcome out of 10027
Hit below hit28
deal holder.WeaponDamage to target29
Graze below hit + 1030
deal holder.WeaponDamage * 0.5 to target31
Miss33
archetype Side35
archetype Soldier36
base MaxHealth 737
base Aim 7538
base WeaponDamage 439
full Health40
with Actions = 141
grants Shoot43
archetype Trooper44
base MaxHealth 545
full Health47
# a target the rifle can't miss: Defense -100 puts every chance past 10048
archetype Dummy49
base MaxHealth 2050
base Defense -10051
full Health1
catalog odds.ledger3
# The shot's numbers, from Shoot and the Soldier: Aim 75, a rifle of 4, a graze band of 10. The sight and cover4
# between two units are the game's facts, given here as its space would answer them.6
play "no sight, no shot; in sight 4 away in the open: a hit 75%, a graze 10% and a miss 15%"7
make squad Side8
make aliens Side9
make s Soldier with team = squad at 0 010
make t Trooper with team = aliens at 4 011
act s Shoot at t12
expect refused Requirement "no line of sight"13
fact Sight s t 114
expect forecast s Shoot at t Hit = 75% from content: Aim 75 less the trooper's Defense 0, no cover, not past 415
expect forecast s Shoot at t Graze = 10% from content: the 10 past the hit16
expect forecast s Shoot at t Miss = 15% from content: 100 - 75 - 1018
play "7 away behind half cover the hit is 43%; behind full cover 23%"19
make squad Side20
make aliens Side21
make s Soldier with team = squad at 0 022
make t Trooper with team = aliens at 7 023
fact Sight s t 124
fact Cover s t 125
expect forecast s Shoot at t Hit = 43% from content: 75 - 20 for half cover - 4 x 3 cells past 426
expect forecast s Shoot at t Miss = 47% from content: 100 - 43 - 1027
fact Cover s t 228
expect forecast s Shoot at t Hit = 23% from content: 75 - 40 for full cover - 1230
play "a sure hit deals the rifle's 4 and spends the action; a second shot waits"31
make squad Side32
make aliens Side33
make s Soldier with team = squad at 0 034
make d Dummy with team = aliens at 3 035
fact Sight s d 136
act s Shoot at d37
expect done38
expect d.Health = 16 from content: the Dummy's 20 less the rifle's 4, its Defense -100 making the hit sure39
expect s.Actions = 0 from content: 1 less the shot's 140
act s Shoot at d41
expect refused CannotAffordRun it yourself
ledger check content/cookbook/mechanics/odds.ledger content/cookbook/mechanics/odds.play
ledger play content/cookbook/mechanics/odds.play