Task #15: UFO enemy, a fast flying fighter
Adds a 4th enemy type (TYPE_UFO=3) that reuses the generic flying-nav
infrastructure (ignores fences, gates, and traps) and gets a new
FIGHT-capable behavior in ThiefBehavior: it skips SEEK/loot entirely and
goes straight to FIGHT, strafing the scarecrow in dive-and-pull-up passes
(diving to land_altitude while its attack is off cooldown, climbing to
cruise_altitude right after landing a hit) until it's hit for every pass.
All stats (speed 7.0, hp 2, damage 1, hit_interval 1.5s, aggro_range 10.0,
etc.) live in GameConfig.enemy_types["ufo"]. It renders through the same
shared flyer MultiMesh crows use (no new art) and is wired into
NightPlan/WaveDirector composition, the HUD/assessment roster lines, kill
log keys, and the arrival sound/toast, with a generic audio fallback since
it has no cue of its own.
Per a scope addition mid-task, night 5 now also sends in a wave of 4 UFOs
late in the night (game/resources/nights/night_5.tres), which shifts
test_nights' known-flaky "arrived" baseline line by one new {3: N} entry
(the UFO counts agree between plan and arrival) and required updating its
hardcoded "all three types" check to four. A debug-only "UFOs only"
scenario is added (game/resources/scenarios/ufos.tres) but deliberately
left out of CampaignDebug.SCENARIOS, since wiring it in would change
test_roster's hardcoded scenario count and that file's existing checks
were required to stay untouched.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
30e64ebeec
commit
34358d0641
14 changed files with 147 additions and 17 deletions
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -29,6 +29,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)
|
||||
|
|
@ -220,6 +221,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue