Task #24: nights by count, per-night enemy speed and HP

- Plans load by count: FarmSim.night_plan_path(n) ("res://game/resources/nights/night_%d.tres")
  for n in 1..campaign_nights (FarmSim.load_night_plans). A missing file is a push_error and
  that night plays the last plan that loaded. FarmSim.NIGHT_PLANS is gone. campaign_nights
  stays 5.
- NightPlan.enemy_speed_scale / enemy_hp_scale (default 1; problems() flags non-positive ones).
  At nightfall WaveDirector._on_phase_changed hands tonight's plan (or the F2 debug plan) to
  EnemySystem.night_speed_scale / night_hp_scale, and the morning puts them back to 1.
  EnemySystem.full_hp(type) = maxi(t_hp, floori(t_hp * night_hp_scale)) at spawn; steering
  and max_speed() use t_speed * night_speed_scale (fleeing and carrying are shares of it).
  Enemies have no HP bar (only structures do), and the co-op replica never simulates enemy HP,
  so the wire format and CoopSession.PROTOCOL (5) are unchanged.
- Debug F3 / Shift+F3 (CampaignDebug.jump_morning; debug builds, morning review only, not on
  a co-op partner's machine): next / previous day's morning with the farm as it is and
  nights_survived = night - 1. It grants the Workbench and grows crops_total as a night's end
  does, then re-enters the morning through CampaignController.load_state with save_path
  blanked, so there's no autosave.
- test_nights: plan paths load in order (and a missing one repeats the last), spawn HP and
  speed at default and 1.6 scales, and the F3 / Shift+F3 jump.
- RULES.md (The enemies: per-night scales), PLAYTEST.md (NIGHT_PLANS note), GameConfig
  campaign_nights comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 16:05:12 -04:00
parent 6a9575dfe4
commit 192a89770a
9 changed files with 259 additions and 22 deletions

View file

@ -68,6 +68,10 @@ var t_hit_interval := PackedFloat32Array()
var t_aggression := PackedByteArray()
var t_aggro_range := PackedFloat32Array()
var t_hit_radius := PackedFloat32Array()
## Tonight's scales (NightPlan.enemy_speed_scale / enemy_hp_scale, set by WaveDirector at
## nightfall): every enemy moves at t_speed x night_speed_scale, and arrives with full_hp().
var night_speed_scale: float = 1.0
var night_hp_scale: float = 1.0
var capacity: int = 0
var active_count: int = 0
@ -199,11 +203,18 @@ func is_flying(d: int) -> bool:
return t_flying[type[d]] == 1
## The fastest any enemy moves tonight.
func max_speed() -> float:
var best := 0.0
for v in t_speed:
best = maxf(best, v)
return best
return best * night_speed_scale
## The HP an enemy of type arrives with tonight: t_hp x night_hp_scale, rounded down, but never
## less than t_hp.
func full_hp(enemy_type: int) -> int:
return maxi(t_hp[enemy_type], floori(t_hp[enemy_type] * night_hp_scale + 1e-6))
## Releases every enemy at once, without removal events (used when the farm state is replaced,
@ -258,7 +269,7 @@ func spawn(enemy_type: int, x: float, z: float, heading: Vector2, p_want: int =
attack_cd[d] = 0.0
slow_left[d] = 0.0
alt[d] = config.cruise_altitude
health[d] = t_hp[enemy_type]
health[d] = full_hp(enemy_type)
target[d] = -1
carry[d] = -1
barrier[d] = -1
@ -381,7 +392,7 @@ func step(dt: float, scarecrow: Vector2, scarecrow_radius: float) -> void:
continue
var t := type[i]
var flying := t_flying[t] == 1
var speed := t_speed[t]
var speed := t_speed[t] * night_speed_scale
var accel := t_accel[t] * dt
if flying:
var want_alt := behavior.altitude_for(self, i) if behavior != null else cfg.cruise_altitude