Merge task #15: UFO enemy (fast flying fighter), 7 in night 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-05 14:47:10 -04:00
commit ae894949e0
14 changed files with 147 additions and 17 deletions

View file

@ -71,8 +71,8 @@ func _designs(r: GameTestRunner, sim: FarmSim) -> void:
var crowded := _crowded_moments(n[3])
r.check(crowded >= 3, "night 4: %d moments with two groups arriving at once" % crowded)
var waves_5 := _waves(n[4])
r.check(n[4].type_counts().size() == 3 and waves_5 >= 3 and n[4].night_length > sim.config.night_length,
"night 5: all three types in %d waves, over a longer %.0f s night" % [waves_5, n[4].night_length])
r.check(n[4].type_counts().size() == 4 and waves_5 >= 3 and n[4].night_length > sim.config.night_length,
"night 5: all four types (including UFOs) in %d waves, over a longer %.0f s night" % [waves_5, n[4].night_length])
var totals := []
for p in n:
totals.append(p.total(p.count_scale_in(sim.config)))

View file

@ -34,6 +34,7 @@ func run(r: GameTestRunner) -> void:
_crows(r, sim, player)
_thieves(r, sim, player)
_breakers(r, sim, player)
_ufos(r, sim, player)
_characters(r, sim)
_alerts(r, farm, sim, player)
_scenarios(r, farm, sim)
@ -225,6 +226,60 @@ func _breakers(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void
_settle(sim)
## UFOs ignore every barrier like a crow, but fight: they go straight for the scarecrow and damage
## it per their FIGHT aggression, and their stats come from GameConfig.
func _ufos(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
var es := sim.enemies
var st := sim.structures
var s := sim.campaign.state
r.check(es.t_flying[EnemySystem.TYPE_UFO] == 1 and es.t_aggression[EnemySystem.TYPE_UFO] == EnemySystem.Aggression.FIGHT,
"a UFO is a flying, fight-aggression type")
# A wall of fences across its way, like the crow test: it flies straight through, breaking nothing.
var fences: Array[int] = []
for k in 6:
fences.append(st.place("fence", 47.0 - 0.6, -9.0 + 2.0 * k, 2))
_settle(sim)
var h := es.spawn(EnemySystem.TYPE_UFO, 52.0, -3.0, Vector2.LEFT)
var d := es.resolve_handle(h)
_step(sim, 1)
r.check(d >= 0 and es.state[d] == T.FIGHT, "it goes straight for the scarecrow, never seeking loot")
var crossed := false
var t := 0.0
while t < 10.0 and not crossed and es.resolve_handle(h) >= 0:
sim.step(DT)
t += DT
d = es.resolve_handle(h)
if d >= 0:
crossed = crossed or (es.pos_x[d] < 46.0 and absf(es.pos_z[d] + 3.0) < 2.0)
r.check(crossed, "it flies straight through a fence line, ignoring it (%.1f s)" % t)
r.check(fences.all(func(id: int) -> bool: return int(s.structure(id)["hp"]) == st.max_hp("fence")), "and breaks nothing")
es.apply_hit_handle(h, 99)
_step(sim, 1)
for id in fences:
st.dismantle(id)
_settle(sim)
# It engages the scarecrow and damages it, per its FIGHT aggression.
player.global_position = Vector3(10.0, 0.0, -3.0)
h = es.spawn(EnemySystem.TYPE_UFO, 10.0, -20.0, Vector2.UP)
var hp := s.scarecrow_hp
var reached := _until(sim, func() -> bool: return s.scarecrow_hp < hp, 20.0)
r.check(reached < 20.0 and hp - s.scarecrow_hp == es.t_damage[EnemySystem.TYPE_UFO],
"it dives in and hits the scarecrow for its configured damage (-%d HP, %.1f s)" % [hp - s.scarecrow_hp, reached])
s.scarecrow_hp = s.scarecrow_max_hp
es.apply_hit_handle(h, 99)
_step(sim, 1)
player.global_position = AWAY
# Its stats come straight from GameConfig: a duplicate with a different speed changes them.
var cfg := (load("res://game/resources/game_config.tres") as GameConfig).duplicate() as GameConfig
cfg.enemy_types = (cfg.enemy_types as Dictionary).duplicate(true)
(cfg.enemy_types["ufo"] as Dictionary)["speed"] = 1.0
var probe := EnemySystem.new()
probe._load_types(cfg)
r.check(probe.t_speed[EnemySystem.TYPE_UFO] == 1.0 and es.t_speed[EnemySystem.TYPE_UFO] != 1.0,
"UFO stats are config-tunable: overriding speed to 1.0 on a duplicate config changes it (the live one is %.1f)" % es.t_speed[EnemySystem.TYPE_UFO])
probe.free()
## Ground enemies are drawn by pooled characters; flyers aren't.
func _characters(r: GameTestRunner, sim: FarmSim) -> void:
var es := sim.enemies