Ledger v3 · C# · Godot 4.7 Get started

Odds

A shot's odds, hit, graze or miss, by aim, defence, cover and distance

✓ 3 plays, 31 steps, all passingFrom Tactics, content\rifle.ledger
factletoutcome out of 100belowexpect forecast

A 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.

content/cookbook/mechanics/odds.ledgerthe content
1# A shot's odds, hit, graze or miss, lifted from the tactics slice's content\rifle.ledger (Shoot), with its units from
2# content\units.ledger and content\dummies.ledger. The hit chance is the shooter's Aim less the target's Defense, less
3# 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
4# next 10 graze for half, and the rest miss. Sight and cover are facts the game's space answers; the odds the game shows
5# are the order's forecast.
6
7rate 10
8link team
9allegiance team
10fact Sight Cover
11stat MaxHealth
12stat Aim
13stat Defense
14stat WeaponDamage
15pool Health max MaxHealth whole
16pool Actions max 1 whole
17damage Health
18tags Shot
20ability Shoot
21 tags Shot
22 target one enemy within 9
23 requires fact(Sight, holder, target) > 0 else "no line of sight"
24 cost Actions 1
25 let hit = holder.Aim - target.Defense - 20 * fact(Cover, holder, target) - 4 * max(0, distance(holder, target) - 4)
26 outcome out of 100
27 Hit below hit
28 deal holder.WeaponDamage to target
29 Graze below hit + 10
30 deal holder.WeaponDamage * 0.5 to target
31 Miss
33archetype Side
35archetype Soldier
36 base MaxHealth 7
37 base Aim 75
38 base WeaponDamage 4
39 full Health
40 with Actions = 1
41 grants Shoot
43archetype Trooper
44 base MaxHealth 5
45 full Health
47# a target the rifle can't miss: Defense -100 puts every chance past 100
48archetype Dummy
49 base MaxHealth 20
50 base Defense -100
51 full Health
content/cookbook/mechanics/odds.playwhat it must do
1catalog odds.ledger
2
3# The shot's numbers, from Shoot and the Soldier: Aim 75, a rifle of 4, a graze band of 10. The sight and cover
4# between two units are the game's facts, given here as its space would answer them.
5
6play "no sight, no shot; in sight 4 away in the open: a hit 75%, a graze 10% and a miss 15%"
7 make squad Side
8 make aliens Side
9 make s Soldier with team = squad at 0 0
10 make t Trooper with team = aliens at 4 0
11 act s Shoot at t
12 expect refused Requirement "no line of sight"
13 fact Sight s t 1
14 expect forecast s Shoot at t Hit = 75% from content: Aim 75 less the trooper's Defense 0, no cover, not past 4
15 expect forecast s Shoot at t Graze = 10% from content: the 10 past the hit
16 expect forecast s Shoot at t Miss = 15% from content: 100 - 75 - 10
18play "7 away behind half cover the hit is 43%; behind full cover 23%"
19 make squad Side
20 make aliens Side
21 make s Soldier with team = squad at 0 0
22 make t Trooper with team = aliens at 7 0
23 fact Sight s t 1
24 fact Cover s t 1
25 expect forecast s Shoot at t Hit = 43% from content: 75 - 20 for half cover - 4 x 3 cells past 4
26 expect forecast s Shoot at t Miss = 47% from content: 100 - 43 - 10
27 fact Cover s t 2
28 expect forecast s Shoot at t Hit = 23% from content: 75 - 40 for full cover - 12
30play "a sure hit deals the rifle's 4 and spends the action; a second shot waits"
31 make squad Side
32 make aliens Side
33 make s Soldier with team = squad at 0 0
34 make d Dummy with team = aliens at 3 0
35 fact Sight s d 1
36 act s Shoot at d
37 expect done
38 expect d.Health = 16 from content: the Dummy's 20 less the rifle's 4, its Defense -100 making the hit sure
39 expect s.Actions = 0 from content: 1 less the shot's 1
40 act s Shoot at d
41 expect refused CannotAfford

Run it yourself

ledger check content/cookbook/mechanics/odds.ledger content/cookbook/mechanics/odds.play
ledger play content/cookbook/mechanics/odds.play