Reload
A magazine and a reload that keeps its gun quiet
target up to 1 enemiesblocks Activate by holder having TAGexpiresetA magazine and a reload, lifted from the shooter slice's content\weapons.ledger (the Rifle, ReloadRifle and ReloadingRifle) and the player's magazine from content\player.ledger. Each round costs one of the magazine's 30 and the gun's rate of 0.1 s, a hit or a miss: the raycast is the engine's, and a round that meets no foe names none. A reload keeps the gun quiet 1.2 s and fills the magazine as it ends; it is refused on a full magazine. The slice's reload blocks only its own gun, by the gun's tag, so its pistol fires on.
1
# A magazine and a reload, lifted from the shooter slice's content\weapons.ledger (the Rifle, ReloadRifle and2
# ReloadingRifle) and the player's magazine from content\player.ledger. Each round costs one of the magazine's 30 and3
# the gun's rate of 0.1 s, a hit or a miss: the raycast is the engine's, and a round that meets no foe names none. A4
# reload keeps the gun quiet 1.2 s and fills the magazine as it ends; it is refused on a full magazine. The slice's5
# reload blocks only its own gun, by the gun's tag, so its pistol fires on.7
rate 608
stat MaxHealth9
stat RifleMag10
pool Health max MaxHealth11
pool RifleAmmo max RifleMag whole12
damage Health13
link team14
allegiance team15
tags Unit Weapon Rifle Bullet17
ability Rifle18
tags Weapon Rifle Bullet19
target up to 1 enemies20
cost RifleAmmo 121
cooldown 0.1s22
deal 8 Bullet to targets24
ability ReloadRifle25
requires holder.RifleAmmo < holder.RifleMag else "full"26
apply ReloadingRifle to holder28
effect ReloadingRifle29
stack ignore30
lasts 1.2s31
blocks Activate by holder having Rifle32
expire33
set RifleAmmo holder.RifleMag35
archetype Side37
archetype Player38
tags Unit39
base MaxHealth 10040
base RifleMag 3041
full Health RifleAmmo42
grants Rifle ReloadRifle44
archetype Dummy45
tags Unit46
base MaxHealth 100047
full Health1
catalog reload.ledger3
# The rifle's numbers, from Rifle (8 a round, one round, 0.1 s) and ReloadingRifle (1.2 s); a magazine of 30. A player4
# at 0 shoots a dummy at 10 on the other side; each round names what the engine's raycast found, or no one.6
play "a round in the dummy takes 8 and one round; one at once is refused by the rate; a round meeting nothing still costs its round"7
make r Side8
make b Side9
make h Player with team = r at 010
make d Dummy with team = b at 1011
act h Rifle at d12
expect done13
expect d.Health = 992 from content: the Dummy's 1000 less 814
expect h.RifleAmmo = 29 from content: 30 less the round's 115
act h Rifle16
expect refused OnCooldown17
advance 0.1s18
act h Rifle19
expect done20
expect h.RifleAmmo = 28 from content: 29 less a round that met no foe21
expect d.Health = 992 from content: nothing met23
play "a full magazine refuses a reload; 30 rounds empty it; the reload keeps it quiet 1.2 s and fills it to 30"24
make r Side25
make b Side26
make h Player with team = r at 027
make d Dummy with team = b at 1028
act h ReloadRifle29
expect refused Requirement "full"30
repeat 3031
act h Rifle at d32
advance 0.1s33
expect h.RifleAmmo = 0 from content: 30 rounds of 134
act h Rifle at d35
expect refused CannotAfford36
act h ReloadRifle37
expect done38
save39
advance 1.1s40
act h Rifle at d41
expect refused Blocked42
advance 0.1s43
expect h.RifleAmmo = 30 from content: RifleMag 30, set as the reload ends at 1.2 s44
act h Rifle at d45
expect doneRun it yourself
ledger check content/cookbook/mechanics/reload.ledger content/cookbook/mechanics/reload.play
ledger play content/cookbook/mechanics/reload.play