Ledger v3 · C# · Godot 4.7 Get started

Priority

A turret that picks its own target by a priority the player sets

✓ 2 plays, 32 steps, all passingFrom TD, content\towers.ledger
grants ... auto by highestif(...)takes PROPtemplate effect

A turret that picks its own target by a priority the player sets, lifted from the tower-defense slice's content\towers.ledger (Aim, Prioritize and the archer's Shoot), with the lane's pools from content\td.ledger. The archer shoots on its own, every 0.8 s, at the creep within its reach that ranks highest: first along the lane (the most Progress), last, strongest (the most Health) or closest, by its Priority 0 to 3; the player sets it with an order. The slice's creeps walk the lane; these stand where the play sets them.

content/cookbook/mechanics/priority.ledgerthe content
1# A turret that picks its own target by a priority the player sets, lifted from the tower-defense slice's
2# content\towers.ledger (Aim, Prioritize and the archer's Shoot), with the lane's pools from content\td.ledger. The
3# archer shoots on its own, every 0.8 s, at the creep within its reach that ranks highest: first along the lane (the
4# most Progress), last, strongest (the most Health) or closest, by its Priority 0 to 3; the player sets it with an
5# order. The slice's creeps walk the lane; these stand where the play sets them.
6
7rate 60
8link team owner
9allegiance team
10stat MaxHealth
11stat LaneEnd
12stat Pace
13stat Damage
14stat Reach
15stat Haste
16pool Health max MaxHealth
17pool Progress max LaneEnd regen Pace
18pool Priority whole max 3
19damage Health
20tags Tower Creep Physical
22prop Order min 0
24ability Prioritize
25 takes Order
26 requires event.Order <= 3 else "a priority is 0 first, 1 last, 2 strongest or 3 closest"
27 set Priority event.Order
29template effect Aim(attack)
30 grants attack auto by highest if(holder.Priority == 0, it.Progress, if(holder.Priority == 1, 100 - it.Progress, if(holder.Priority == 2, it.Health, 0 - distance(holder, it))))
31 grants Prioritize
33effect ArcherAim from Aim(Shoot)
35ability Shoot
36 target one enemy within holder.Reach
37 cooldown 0.8s / holder.Haste
38 deal holder.Damage Physical to target
40archetype Archer
41 tags Tower
42 base Damage 6
43 base Reach 4
44 base Haste 1
45 pools Priority
46 has ArcherAim
48archetype Side
50archetype Creep
51 tags Creep
52 base MaxHealth 100
53 base LaneEnd 100
54 full Health
55 pools Progress
content/cookbook/mechanics/priority.playwhat it must do
1catalog priority.ledger
2
3# The archer's numbers, from Shoot and Aim: 6 a shot every 0.8 s within 4, at the creep ranking highest by its
4# Priority. Creeps of side b stand at 100 Health: c1 at 3 with Progress 50, c2 at 1 with Progress 20, c3 at 2
5# with Progress 35 and 40 Health less, far at 5 with Progress 90; c2 has 10 less. The archer of side a stands at 0.
6
7play "built shooting first, it shoots the creep furthest along; set to last, the one least along; to strongest, the most Health; to closest, the nearest"
8 make a Side
9 make b Side
10 make c1 Creep with team = b at 3
11 make c2 Creep with team = b at 1
12 make c3 Creep with team = b at 2
13 make far Creep with team = b at 5
14 set c1.Progress = 50
15 set c2.Progress = 20
16 set c3.Progress = 35
17 set far.Progress = 90
18 deal 40 to c3
19 deal 10 to c2
20 make ar Archer with team = a at 0
21 expect c1.Health = 94 from content: Priority 0, first: c1's Progress 50 the most within 4 (far's 90 stands at 5, past the reach): 100 - 6
22 expect far.Health = 100 from content: past the reach of 4
23 act ar Prioritize with Order = 1
24 expect done
25 advance 0.8s
26 expect c2.Health = 84 from content: Priority 1, last: c2's Progress 20 the least: 90 - 6
27 act ar Prioritize with Order = 2
28 expect done
29 save
30 advance 0.8s
31 expect c1.Health = 88 from content: Priority 2, strongest: c1 at 94 against c2's 84 and c3's 60: 94 - 6
32 act ar Prioritize with Order = 3
33 expect done
34 advance 0.8s
35 expect c2.Health = 78 from content: Priority 3, closest: c2 at 1: 84 - 6
37play "a priority past 3 is refused in its words"
38 make a Side
39 make ar Archer with team = a at 0
40 act ar Prioritize with Order = 4
41 expect refused Requirement "a priority is 0 first, 1 last, 2 strongest or 3 closest"

Run it yourself

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