harvest/game/scripts/game_config.gd
Forrest 91b9e52e96 Task #26: upgrade tiers and timed shed stock
Workbench stat upgrades get 3 levels: level L costs costs[id] x
upgrade_cost_growth (1.8) ^ (L - 1), each material rounded up, and opens on
day upgrade_level_days[L - 1] ([1, 8, 16]). Each owned level's "mult"/"add"
entry stacks. Level 1 keeps the user's values and costs (rapid fire 3.0x).
Shed items arrive on set days ("from_day"): corn shooter 1, shurikens 2,
pumpkin bombs 3, potato cannon 6, radar 8, propane torch 10, alien ray 14.

- Upgrades: level(), max_level(), maxed(), cost(cfg, id, level),
  next_cost(), per_level(), text_at(), name_at() (roman numerals),
  from_day(), level_day(), arrived(). owned() stays "level >= 1". blocker()
  adds "Arrives on day N" and "Level N opens on day D"; buy() takes the next
  level and applies that level's side effect; upgrades_bought counts every
  level. FarmState.upgrades keeps id -> level, so saves don't change shape.
- UpgradePanel: "Rapid fire II" with the next level's text and cost, the
  blocker reason, "Max" at the last level; a shed item before its day shows
  its name greyed with "Arrives on day N" ("?" plus the day if hidden). The
  title counts items at their last level. Every level bought jingles.
- Co-op: the host sends "bought" for any level (no wire change; PROTOCOL
  stays 5).
- soak_night.gd buys the lowest next level first across UPGRADE_ORDER.
- Tests: level costs, day gates, stacking, from_day, save/morning/retry/co-op,
  an old {"rapid_fire": 1} save as level 1. Existing tests set the day where
  they buy stock that now arrives later.
- RULES.md Upgrades: per-level effects and costs, stock schedule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 16:20:05 -04:00

449 lines
28 KiB
GDScript

class_name GameConfig
extends Resource
## Every tunable campaign setting, kept in one resource (see game/RULES.md for the rules these
## values feed). The defaults live in res://game/resources/game_config.tres; every number is a
## starting value to tune during balancing.
@export_group("Campaign")
## Nights the scarecrow must survive before the farmers return.
@export_range(1, 60) var campaign_nights: int = 5
@export_group("Waves")
## Every night plan's groups are scaled when played: this many times the enemies, arriving this
## many times the plan's spacing apart (NightPlan.scaled_count / scaled_every). 5 and 0.4: five
## times the enemies, two and a half times as often. A plan can set its own instead
## (NightPlan.count_scale / spacing_scale; night 1 plays unscaled).
@export_range(0.1, 20.0) var wave_count_scale: float = 7.0
@export_range(0.05, 4.0) var wave_spacing_scale: float = 0.3
## Every enemy arrives at its own random point along the farm's edge (FarmZones.edge), on foot this
## many meters outside the playable map (also where carriers escape to), flyers this far out.
## Ground arrivals stay inside the navigation grid (5 m beyond the map).
@export_range(0.5, 4.5) var spawn_margin: float = 3.0
@export var flyer_spawn_margin: float = 8.0
@export_group("Phases")
## Seconds of game time per phase. The morning review is untimed: it waits for the player.
@export var day_length: float = 180.0
@export var dusk_length: float = 30.0
@export var night_length: float = 150.0
## After sunrise: enemies retreat and carriers can still be intercepted for this long.
@export var dawn_grace: float = 20.0
## D1: lets the player skip the rest of the day/dusk and start the night (off by default).
@export var allow_early_night: bool = false
@export_group("Scarecrow")
## HP carries over between nights (D7); 0 HP is an immediate Game Over.
@export_range(1, 100) var scarecrow_max_hp: int = 3
## After an accepted hit the scarecrow ignores further hits for this long.
@export var invulnerability_time: float = 1.0
## Fear: enemies within fear_radius flee for fear_duration; usable every fear_cooldown seconds.
@export var fear_radius: float = 6.0
@export var fear_cooldown: float = 12.0
@export var fear_duration: float = 2.0
## Patch up: hold for patch_time (rooted, no shooting) to restore patch_heal HP.
@export var patch_time: float = 2.0
@export_range(1, 100) var patch_heal: int = 3
## Sprint (the workbench's Sprint upgrade): hold sprint while moving to run sprint_speed_mult
## times as fast for up to sprint_time seconds; once it ends, sprint_cooldown seconds until the
## next one.
@export var sprint_speed_mult: float = 1.8
@export var sprint_time: float = 4.0
@export var sprint_cooldown: float = 10.0
@export_group("Farm assets")
## Crop units and animals on the farm when the vacation starts; they must match the farm scene
## (the crop field's CropUnits, the animals in the pen). Supplies are the shed's stock (the start
## materials below). A category with nothing in it at the start is not in play and is ignored by
## the "farm stripped" check (D2).
@export_range(0, 500) var start_crops: int = 30
@export_range(0, 100) var start_animals: int = 8
## Structures standing when the vacation starts ({"type", "x", "z", "rot"}). Empty: the animal
## pen is fully player-built (its fence/gate ring is no longer a scene prop or a free starter).
@export var start_structures: Array[Dictionary] = []
@export_group("Theft rules")
## D5: fear makes carriers drop their loot, not only killing them.
@export var fear_drops_loot: bool = true
## D6: dropped loot still on the ground when the dawn grace ends returns home automatically.
@export var loot_returns_at_dawn: bool = true
## D6: animals that can follow the scarecrow back to the pen at once.
@export_range(1, 10) var max_following_animals: int = 5
## Seconds an enemy needs to take a crop unit, catch an animal, or fill a sack at the shed (times
## its type's steal_time); damage during that time resets it.
@export var crop_steal_time: float = 2.5
@export var animal_capture_time: float = 2.0
@export var supply_steal_time: float = 1.0
## A supply thief takes this many units of the material the shed holds most of (never more than
## there is).
@export_range(1, 100) var supply_bundle: int = 5
## An animal getting out of an open pen walks out at this speed; once it's out it's loose and
## roams the farm like any other (AnimalSystem). Animals never leave the farm on their own.
@export var stray_speed: float = 1.1
## At night, while the pen is open (nothing built yet, or its gate broken or removed), one calm
## penned animal gets out every this many seconds and is loose. An animal brought back stays calm
## (won't get out again) for animal_calm_time.
@export var animal_wander_interval: float = 10.0
@export var animal_calm_time: float = 30.0
## Animals following the scarecrow walk its trail at up to this speed.
@export var follow_speed: float = 6.0
## Where loose animals start (#12), and where a loose one is back every morning (#21: in between
## it roams the whole farm): a row of open-farmyard spots south and south-east of
## FarmZone.Kind.ANIMAL_PEN (x -10..4, z -11..-1), walkable, clear of the crop fields (x -11..-1
## z 2..12, x 2..12 z 2..12, and the sunflowers from x 14 -- see LAYOUT.md), and well in from the
## farm's edge. Cycles if there are more animals than spots.
@export var animal_loose_spots: Array[Vector2] = [
Vector2(-9.0, 0.5), Vector2(-6.0, 0.5), Vector2(-3.0, 0.5), Vector2(0.0, 0.5), Vector2(3.0, 0.5),
Vector2(6.0, 0.5), Vector2(9.0, 0.5), Vector2(12.0, 0.5),
]
## What a thief with no set target goes for ("any" in a night plan), and where a thief whose target
## is gone goes next: relative weights per category.
@export var target_weights: Dictionary = {"crops": 2.0, "animals": 1.0, "supplies": 1.0}
## The scarecrow recovers dropped loot by walking within this distance of it.
@export var pickup_radius: float = 1.3
@export_group("Resources")
## Wood, scrap, and straw in the supply shed when the vacation starts. Alien Goop is never a
## starting stock (it's found only by killing Aliens), but the shed still tracks a count for it.
@export_range(0, 999) var start_wood: int = 4
@export_range(0, 999) var start_scrap: int = 2
@export_range(0, 999) var start_straw: int = 4
@export_range(0, 999) var start_alien_goop: int = 0
## The scarecrow's pouch holds this many units in total; it empties into the shed on entry.
## Raised by each level of the Bigger pouch upgrade (Upgrades, "pouch_capacity").
@export_range(1, 200) var pouch_capacity: int = 8
## Seconds of holding interact per gather (each takes one charge of the gather point).
@export var gather_time: float = 1.5
## What things cost: name -> {material: amount}: patching up, the buildables, and the upgrades.
@export var costs: Dictionary = {
"patch": {"straw": 2},
"straw_stuffing": {"straw": 12, "wood": 4},
"pouch_upgrade": {"wood": 10, "straw": 8},
"sprint": {"wood": 8, "straw": 6},
"corn_shooter": {"scrap": 10, "wood": 4},
"pumpkin_bomb": {"straw": 12, "scrap": 6},
"potato_cannon": {"scrap": 14, "wood": 8},
"shurikens": {"scrap": 6, "straw": 4},
"propane_torch": {"scrap": 12, "straw": 4, "wood": 6},
"alien_ray": {"alien_goop": 6, "scrap": 10},
"rapid_fire": {"scrap": 12, "wood": 8},
"heavy_seeds": {"scrap": 14, "straw": 10},
"wide_fear": {"straw": 20, "wood": 4},
"quick_fear": {"straw": 16, "scrap": 6},
"reinforced_fences": {"wood": 20, "scrap": 6},
"long_range": {"scrap": 14, "wood": 10},
"sticky_tar": {"straw": 14, "scrap": 6},
"radar": {"scrap": 8, "wood": 6},
"fence": {"wood": 2},
"gate": {"wood": 4, "scrap": 1},
"slowing_trap": {"scrap": 3, "wood": 1},
"automated_defense": {"scrap": 6, "wood": 2, "straw": 2},
}
@export_group("Upgrades")
## What the two shops sell (Upgrades), by day, for costs[id]: either the work area's workbench
## (the default shop) or the supply shed's counter ("shop": "shed": weapons and other purchasable
## items, Upgrades.shop_of, UpgradePanel's shop filter). The keys:
## "name", "track" (the menu's heading), "text": what it does.
## "stat": the one stat it changes. Stats are GameConfig settings, plus scarecrow_max_hp (the
## scarecrow's, in FarmState) and barrier_hp (fences' and gates' health). One without a stat
## unlocks something instead (sprint: PlayerCharacter; the weapons: ScarecrowCombat; radar:
## RadarHud).
## "mult" multiplies the stat, "add" adds to it: a number (the same every level) or an Array
## with one entry per level. Each owned level's entry applies in turn, so they stack.
## "levels": how many times it can be bought (1 by default). Level L costs costs[id] x
## upgrade_cost_growth^(L - 1) and opens on day upgrade_level_days[L - 1] (or its own
## "level_days": [day, ...]).
## "texts": one description per level, shown instead of "text" (the menu shows the next one).
## "from_day": the day it arrives in stock, before which it can't be bought (1 by default).
## Day N is the day before night N (FarmState.night).
## "requires": another upgrade that must be bought first (from either shop).
## "hidden", "reveal_goop": see hidden_reveal_goop below.
@export var upgrades: Dictionary = {
"corn_shooter": {"name": "Corn shooter", "text": "A gun that fires corn kernels, from afar", "track": "Weapon", "shop": "shed", "from_day": 1},
"rapid_fire": {"name": "Rapid fire", "track": "Weapon", "stat": "fire_rate", "mult": [1.333, 1.25, 1.25], "levels": 3, "requires": "corn_shooter",
"texts": ["The corn shooter fires a third faster", "The corn shooter fires another 25% faster", "The corn shooter fires 25% faster again"]},
"heavy_seeds": {"name": "Heavy seeds", "track": "Weapon", "stat": "shot_damage", "add": [1, 1, 1], "levels": 3, "requires": "corn_shooter",
"texts": ["Each kernel does 2 damage", "Each kernel does 3 damage", "Each kernel does 4 damage"]},
"pumpkin_bomb": {"name": "Pumpkin bombs", "text": "Throw a pumpkin that bursts, hurting everything within 3 m (one every 4 s)", "track": "Weapon", "shop": "shed", "from_day": 3},
"potato_cannon": {"name": "Potato cannon", "text": "A slow heavy potato shot that hits hard from afar", "track": "Weapon", "shop": "shed", "from_day": 6},
"shurikens": {"name": "Shurikens", "text": "Fast, cheap throws for a quick hit", "track": "Weapon", "shop": "shed", "from_day": 2},
"propane_torch": {"name": "Propane torch", "text": "A jet of flame that burns everything in a band ahead of you while held", "track": "Weapon", "shop": "shed", "from_day": 10},
"alien_ray": {"name": "Alien ray", "text": "A salvaged alien weapon: a long beam that pierces everything in its line while held", "track": "Weapon", "shop": "shed", "hidden": true, "from_day": 14},
"radar": {"name": "Radar", "text": "A minimap showing nearby enemy positions", "track": "Item", "shop": "shed", "hidden": true, "from_day": 8},
"wide_fear": {"name": "Wide fear", "track": "Fear", "stat": "fear_radius", "mult": [1.3, 1.15, 1.15], "levels": 3,
"texts": ["Fear reaches 30% farther", "Fear reaches another 15% farther", "Fear reaches 15% farther again"]},
"quick_fear": {"name": "Quick fear", "track": "Fear", "stat": "fear_cooldown", "mult": [0.8, 0.9, 0.9], "levels": 3,
"texts": ["Fear recharges 20% faster", "Fear recharges another 10% faster", "Fear recharges 10% faster again"]},
"straw_stuffing": {"name": "Straw stuffing", "track": "Scarecrow", "stat": "scarecrow_max_hp", "add": [2, 2, 2], "levels": 3,
"texts": ["+2 max health", "+2 more max health", "+2 more max health"]},
"pouch_upgrade": {"name": "Bigger pouch", "track": "Scarecrow", "stat": "pouch_capacity", "add": [8, 4, 4], "levels": 3,
"texts": ["+8 pouch capacity (16 total)", "+4 pouch capacity (20 total)", "+4 pouch capacity (24 total)"]},
"sprint": {"name": "Sprint", "text": "Sprint 80% faster for 4 s at a time, every 10 s", "track": "Scarecrow"},
"reinforced_fences": {"name": "Reinforced fences", "track": "Defenses", "stat": "barrier_hp", "mult": [1.5, 1.25, 1.25], "levels": 3,
"texts": ["Fences and gates +50% health", "Fences and gates another +25% health", "Fences and gates +25% health again"]},
"long_range": {"name": "Long-range defenses", "track": "Defenses", "stat": "turret_range", "mult": [1.3, 1.15, 1.15], "levels": 3,
"texts": ["Turrets reach 30% farther", "Turrets reach another 15% farther", "Turrets reach 15% farther again"]},
"sticky_tar": {"name": "Sticky tar", "track": "Defenses", "stat": "trap_slow_time", "mult": [1.5, 1.25, 1.25], "levels": 3,
"texts": ["Tar patches hold 50% longer", "Tar patches hold another 25% longer", "Tar patches hold 25% longer again"]},
}
## Each further level of an upgrade with "levels" costs this many times the one before: level L
## costs costs[id] x upgrade_cost_growth^(L - 1), each material rounded up (Upgrades.cost).
@export_range(1.0, 5.0, 0.05) var upgrade_cost_growth: float = 1.8
## The day each level of an upgrade with "levels" can first be bought: level L from day
## upgrade_level_days[L - 1] (the last entry for any level past its end). An upgrade's own
## "level_days" overrides it. Day N is the day before night N.
@export var upgrade_level_days: Array[int] = [1, 8, 16]
## An upgrade with "hidden": true (e.g. Alien Ray, Radar, #7/#8) shows only a "?" (no name, text,
## or cost) and can't be bought until the player has collected this much Alien Goop in total
## (Upgrades.goop_collected); then it shows and buys normally for its defined cost. Overridable
## per item with its own "reveal_goop". 5 is about 15 Alien kills at the default 33% drop chance
## (alien_goop_drop_chance) — a few kills in, not instant and not a grind.
@export_range(0, 999) var hidden_reveal_goop: int = 5
@export_group("Assessment")
## The final assessment's weight per category (Assessment): the score is the weighted share of
## each category kept, renormalized over the categories in play, as 0..100 points.
@export var assessment_weights: Dictionary = {"crops": 0.5, "animals": 0.3, "supplies": 0.2}
## Rating tiers, best first: the first one whose min the score reaches.
@export var rating_tiers: Array[Dictionary] = [
{"min": 95, "name": "Blue-ribbon harvest", "text": "The farmers can hardly tell they were gone."},
{"min": 80, "name": "Bumper crop", "text": "A few gaps in the rows, nothing a good week won't fix."},
{"min": 60, "name": "Fair season", "text": "The farm made it, a little thinner than they left it."},
{"min": 40, "name": "Lean season", "text": "The farmers will be counting what's missing for a while."},
{"min": 0, "name": "Hanging by a thread", "text": "There's a farm left, but only just."},
]
@export_group("Structures")
## Hit points of the built defenses; a slowing trap's "HP" is the enemies it can still slow.
@export_range(1, 500) var fence_hp: int = 20
@export_range(1, 500) var gate_hp: int = 30
@export_range(1, 500) var trap_triggers: int = 10
@export_range(1, 500) var turret_hp: int = 25
## The Workbench (#9): not built by the player (it's granted once Night 1 is survived --
## StructureSystem.grant_workbench()), but it has HP, can be damaged, and is repaired like any
## other structure (repair-only: it stays, broken, at 0 HP instead of being destroyed).
@export_range(1, 500) var workbench_hp: int = 50
## A ground enemy crossing a slowing trap moves at this share of its speed for this long.
@export_range(0.05, 1.0) var trap_slow_factor: float = 0.5
@export var trap_slow_time: float = 2.0
## The automated defense shoots the nearest enemy in range with a clear line, every interval.
@export var turret_range: float = 7.0
@export var turret_fire_interval: float = 1.0
## The scarecrow builds within this distance of itself.
@export var build_range: float = 9.0
## Enemies treat each cell of a barrier as this many meters of extra path, so they walk around
## a short wall but break through a long one.
@export var barrier_detour: float = 18.0
## Holding interact for repair_time repairs a structure fully, for its build cost scaled by the
## share of HP (or triggers) it is missing, rounded up.
@export var repair_time: float = 1.5
## Dismantling gives back this share of the build cost (rounded down), into the shed.
@export_range(0.0, 1.0) var dismantle_refund: float = 0.5
## Cells finalized per tick while flow fields rebuild after a structure change.
@export_range(100, 100000) var flow_slice_cells: int = 2000
## Per-instance leveling (StructureSystem.LEVELABLE: automated_defense, slowing_trap; L1-L3), not
## account-wide like the workbench upgrades above. Holding interact at a specific placed structure
## (by day; it must be undamaged first) pays structure_level_costs[type][level - 1] to take it from
## level to level + 1 (index 0: L1->L2, index 1: L2->L3).
@export var structure_level_costs: Dictionary = {
"automated_defense": [{"scrap": 10, "wood": 4, "straw": 2}, {"scrap": 16, "wood": 6, "straw": 4}],
"slowing_trap": [{"scrap": 5, "wood": 2}, {"scrap": 8, "wood": 4}],
}
## Turret L2 fires this many times as often (mirrors the Rapid Fire upgrade's live multiplier,
## 3.0 in game_config.tres); L3 keeps the same rate.
@export var turret_level_fire_mult: float = 3.0
## Turret L3 fires this many shots at once in a fan around the aim direction, turret_l3_spread_deg
## apart (a triangle spread: the outer two off by the full spread from the center shot).
@export_range(1, 8) var turret_l3_projectiles: int = 3
@export var turret_l3_spread_deg: float = 10.0
## A tar patch's footprint (trigger area) and visual grow by this multiple of its L1 size, per
## level (index 0 = L1, so always 1.0).
@export var trap_level_size_mult: Array[float] = [1.0, 2.0, 3.0]
## Holding interact for structure_upgrade_time levels up a structure, paying structure_level_costs
## at the end (by day only; see Interactions).
@export var structure_upgrade_time: float = 2.0
@export_group("Combat")
## Height of the gun muzzle, the bullets, and enemy hit proxies (shots fly horizontally). It
## clears the sunflowers (1.67 m) and the pen fence (1.69 m), so thieves in the field stay
## visible and shootable.
@export var combat_height: float = 1.8
## The pitchfork, every scarecrow's from the start (ScarecrowCombat): a stab every
## pitchfork_interval s hits the nearest pitchfork_targets enemies within pitchfork_reach m of the
## scarecrow's center (plus their hit radius) and pitchfork_arc degrees of the aim, with a clear
## line, for pitchfork_damage each.
@export var pitchfork_reach: float = 2.2
@export var pitchfork_arc: float = 100.0
@export_range(1, 20) var pitchfork_damage: int = 2
@export_range(1, 20) var pitchfork_targets: int = 3
@export var pitchfork_interval: float = 0.5
## Pumpkin bombs (the Pumpkin bombs upgrade): thrown at the aim point, bomb_min_range ..
## bomb_range m away, flying at bomb_speed m/s; on landing every enemy within bomb_radius m takes
## bomb_damage. One every bomb_cooldown s.
@export var bomb_range: float = 10.0
@export var bomb_min_range: float = 2.0
@export var bomb_speed: float = 12.0
@export var bomb_radius: float = 3.0
@export_range(1, 50) var bomb_damage: int = 3
@export var bomb_cooldown: float = 4.0
## The corn shooter (the Corn shooter upgrade) is the gun: kernels per second and their damage
## (rapid fire and heavy seeds raise them), and the projectiles below.
@export var fire_rate: float = 6.0
## Damage of one of the scarecrow's shots (automated defenses always do 1).
@export_range(1, 10) var shot_damage: int = 1
@export var projectile_speed: float = 24.0
@export var projectile_lifetime: float = 2.0
@export_range(1, 1024) var projectile_capacity: int = 64
## Horizontal distance from the scarecrow's center to the muzzle along the aim direction.
@export var muzzle_distance: float = 1.05
## Right-stick radial dead zone, and mouse travel (px) that switches aiming back to the mouse.
@export var aim_dead_zone: float = 0.3
@export var mouse_switch_threshold: float = 12.0
## Potato Cannon (the Potato cannon upgrade, bought at the supply shed, Task #7): one heavy potato
## every potato_cannon_cooldown s, potato_cannon_damage each, flying slow (potato_cannon_speed m/s)
## and not far (potato_cannon_lifetime s) through FarmProjectiles.
@export var potato_cannon_cooldown: float = 1.4
@export_range(1, 50) var potato_cannon_damage: int = 6
@export var potato_cannon_speed: float = 11.0
@export var potato_cannon_lifetime: float = 2.5
## Shurikens (the Shurikens upgrade, bought at the supply shed): shuriken_count thrown every
## shuriken_cooldown s, shuriken_damage each, flying fast (shuriken_speed m/s) and not far
## (shuriken_lifetime s).
@export var shuriken_cooldown: float = 0.25
@export_range(1, 20) var shuriken_damage: int = 1
@export var shuriken_speed: float = 34.0
@export var shuriken_lifetime: float = 1.0
@export_range(1, 6) var shuriken_count: int = 1
## Propane Torch (the Propane torch upgrade, bought at the supply shed): a band of fire while held
## (#17), a tick every torch_tick_interval s, torch_damage each to the enemies in a torch_width m
## wide band along the gun's line, from the scarecrow out to torch_range m past the muzzle (the
## nearest torch_targets), with a clear line (ScarecrowCombat._band_hit). Its flame (TorchFlame)
## is sized to the band.
@export var torch_range: float = 4.5
@export var torch_width: float = 1.6
@export_range(1, 20) var torch_damage: int = 1
@export_range(1, 20) var torch_targets: int = 5
@export var torch_tick_interval: float = 0.2
## Alien Ray (the Alien ray upgrade, hidden until hidden_reveal_goop Alien Goop is collected): a
## beam while held (#18), a tick every alien_ray_tick_interval s, alien_ray_damage each to every
## enemy within alien_ray_width / 2 (plus its hit radius) of the beam, flyers too (the nearest
## alien_ray_pierce), from the scarecrow through the muzzle and on alien_ray_range m past it, cut
## short at the first wall (ScarecrowCombat.beam_path, EnemySystem.path_hits). It hits at once
## (no projectile). 1 every 0.15 s is about 6.7 damage a second to each enemy on the beam: the
## shed's guns do 4 to 6 to one, the torch 5 to each in its short band.
@export var alien_ray_range: float = 20.0
@export var alien_ray_width: float = 0.5
@export var alien_ray_tick_interval: float = 0.15
@export_range(1, 80) var alien_ray_damage: int = 1
@export_range(1, 20) var alien_ray_pierce: int = 4
@export_group("Radar")
## Radar (the Radar item, bought at the supply shed, hidden until hidden_reveal_goop Alien Goop is
## collected, #8): once owned, a minimap shows every alive enemy within radar_range meters of the
## local scarecrow, redrawn every radar_refresh seconds (RadarHud). 40 m is generous: it covers
## most of the playable farm (60x60) from a central position, so the minimap is useful without
## needing to be perfectly centered on the scarecrow at all times. A quarter-second refresh keeps
## the dots responsive without redrawing every frame.
@export var radar_range: float = 40.0
@export var radar_refresh: float = 0.25
@export_group("Enemies")
@export_range(1, 1024) var enemy_capacity: int = 800
## The enemy roster (EnemySystem.TYPE_NAMES), one row per type:
## speed, acceleration m/s, m/s^2
## hp hits it takes
## flying ignores ground occupancy, structures, and traps; altitude is only
## visual (its hit proxy stays at combat height)
## targets what it goes for: loot categories ("crops", "animals", "supplies"), or
## "structures" (barriers guarding valuables)
## steal_time times the category's steal time
## carry_speed share of its speed while carrying loot
## structure_damage per hit on a barrier, every hit_interval
## damage, hit_interval per melee hit on the scarecrow, and the cooldown between hits
## aggression "none" (never fights), "contact" (hits the scarecrow when touching it
## while busy), "fight" (turns on a scarecrow within aggro_range, and
## hunts it when nothing is left to break)
## hit_radius projectile hit proxy
@export var enemy_types: Dictionary = {
"thief": {"speed": 3.0, "acceleration": 14.0, "hp": 3, "flying": false, "targets": ["animals", "supplies"],
"steal_time": 1.0, "carry_speed": 0.7, "structure_damage": 2, "damage": 1, "hit_interval": 1.2,
"aggression": "contact", "hit_radius": 0.4, "aggro_range": 0.0},
"crow": {"speed": 5.5, "acceleration": 18.0, "hp": 1, "flying": true, "targets": ["crops"],
"steal_time": 0.8, "carry_speed": 0.75, "structure_damage": 0, "damage": 0, "hit_interval": 1.0,
"aggression": "none", "hit_radius": 0.45, "aggro_range": 0.0},
"breaker": {"speed": 1.9, "acceleration": 8.0, "hp": 6, "flying": false, "targets": ["structures"],
"steal_time": 0.0, "carry_speed": 0.0, "structure_damage": 8, "damage": 2, "hit_interval": 1.5,
"aggression": "fight", "hit_radius": 0.55, "aggro_range": 4.0},
## Fast, fragile, and always spoiling for a fight: a UFO heads straight for the scarecrow (no
## loot, so no targets) and dives in for a strafing pass every hit_interval (ThiefBehavior).
"ufo": {"speed": 7.0, "acceleration": 20.0, "hp": 2, "flying": true, "targets": [],
"steal_time": 0.0, "carry_speed": 0.0, "structure_damage": 0, "damage": 1, "hit_interval": 1.5,
"aggression": "fight", "hit_radius": 0.5, "aggro_range": 10.0},
}
## Flyers cruise at this visual altitude and come down to land_altitude to take a crop.
@export var cruise_altitude: float = 3.2
@export var land_altitude: float = 1.55
## Barriers within this distance of the crop rows, the pen, or the shed guard them: fence
## breakers go for those first.
@export var guard_range: float = 6.0
## Body radius of ground enemies (navigation clearance is this plus nav_inflate_margin).
@export var enemy_radius: float = 0.3
@export var nav_cell_size: float = 0.5
@export var nav_inflate_margin: float = 0.05
@export var separation_radius: float = 0.8
@export var separation_weight: float = 1.4
## Bounded push per tick when enemies overlap each other or the scarecrow.
@export var max_correction_per_tick: float = 0.15
## Melee: an enemy touching the scarecrow (within this much of contact) and off cooldown hits
## it for its type's damage; the cooldown (hit_interval) starts on every attempt.
@export var enemy_attack_reach: float = 0.25
## Fleeing enemies (fear) run at this share of their normal speed.
@export var flee_speed_factor: float = 1.15
## Within this distance and with a clear line, enemies steer straight at their target.
@export var direct_seek_distance: float = 12.0
## Trickle mode, for tests and soaks: when above 0, the night's plan is ignored and this many
## enemies of trickle_type are kept on the farm, the next arriving thief_spawn_interval after one
## leaves (anywhere along the farm's edge). 0 plays the night's NightPlan (WaveDirector).
@export_range(0, 32) var night_thieves: int = 0
@export var thief_spawn_interval: float = 6.0
@export var trickle_type: String = "crow"
## What trickle enemies go for: "crops", "animals", "supplies", or "any" (of their type's targets).
@export var trickle_target: String = "any"
## Alien Goop (Decision 11): a killed Alien (TYPE_THIEF) drops this much goop this often, credited
## straight into the pouch like a gathered material (ResourceStore.MATERIALS).
@export_range(0.0, 1.0) var alien_goop_drop_chance: float = 0.33
@export_range(0, 20) var alien_goop_drop_qty: int = 1
## A row of the enemy roster.
func enemy(type_name: String) -> Dictionary:
return enemy_types.get(type_name, {})
## Full hit points of a structure type (a slowing trap's are the enemies it can still slow).
func structure_hp(type: String) -> int:
match type:
"fence":
return fence_hp
"gate":
return gate_hp
"slowing_trap":
return trap_triggers
"workbench":
return workbench_hp
return turret_hp
## Length of a phase in seconds, or INF for the untimed morning review and terminal phases.
func phase_length(phase: CampaignController.Phase) -> float:
match phase:
CampaignController.Phase.DAY:
return day_length
CampaignController.Phase.DUSK:
return dusk_length
CampaignController.Phase.NIGHT:
return night_length
CampaignController.Phase.DAWN:
return dawn_grace
return INF