- 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>
95 lines
4.5 KiB
GDScript
95 lines
4.5 KiB
GDScript
class_name NightPlan
|
|
extends Resource
|
|
## One night (the plan's NightDefinition): its title, the hint shown at dusk, an optional length,
|
|
## and groups of enemies, each arriving at a time into the night. Where is not planned: every
|
|
## enemy arrives at its own random point along the farm's edge (WaveDirector).
|
|
## game/resources/nights/night_<n>.tres, for n in 1..GameConfig.campaign_nights
|
|
## (FarmSim.night_plan_path), are the vacation's nights; game/resources/scenarios/ holds debug
|
|
## plans.
|
|
## time seconds after nightfall when the group's first enemy arrives
|
|
## count how many arrive
|
|
## every seconds between them
|
|
## type enemy type: "thief", "crow", "breaker", or "ufo"
|
|
## target what they're after: "crops", "animals", "supplies", or "any" (GameConfig.target_weights)
|
|
## The plans are the nights' designs; GameConfig.wave_count_scale and wave_spacing_scale scale
|
|
## every group when the night is played (count_scale x the enemies, spacing_scale x the time
|
|
## between them), so the whole vacation's pressure is tuned in one place. A plan can set its own
|
|
## scales instead (night 1 plays as designed, at 1 and 1). enemy_speed_scale and enemy_hp_scale
|
|
## make tonight's enemies faster and tougher than GameConfig.enemy_types says (WaveDirector hands
|
|
## them to EnemySystem at nightfall).
|
|
|
|
@export var title: String = ""
|
|
## What the HUD tells the player at dusk about tonight.
|
|
@export_multiline var dusk_hint: String = ""
|
|
## Seconds the night lasts; 0 uses GameConfig.night_length.
|
|
@export var night_length: float = 0.0
|
|
## This night's own scales; 0 uses GameConfig.wave_count_scale / wave_spacing_scale.
|
|
@export var count_scale: float = 0.0
|
|
@export var spacing_scale: float = 0.0
|
|
## Tonight's enemies move at speed x this (fleeing and carrying too, as shares of it), and arrive
|
|
## with HP x this, rounded down but never below the type's own (a 1 HP crow stays one hit).
|
|
@export var enemy_speed_scale: float = 1.0
|
|
@export var enemy_hp_scale: float = 1.0
|
|
@export var groups: Array[Dictionary] = []
|
|
|
|
|
|
## The scales this night is played at: its own, or the config's.
|
|
func count_scale_in(config: GameConfig) -> float:
|
|
return count_scale if count_scale > 0.0 else config.wave_count_scale
|
|
|
|
|
|
func spacing_scale_in(config: GameConfig) -> float:
|
|
return spacing_scale if spacing_scale > 0.0 else config.wave_spacing_scale
|
|
|
|
|
|
## A group's enemies and the seconds between them, scaled.
|
|
static func scaled_count(g: Dictionary, count_scale: float = 1.0) -> int:
|
|
return maxi(roundi(int(g.get("count", 1)) * count_scale), 1)
|
|
|
|
|
|
static func scaled_every(g: Dictionary, spacing_scale: float = 1.0) -> float:
|
|
return float(g.get("every", 2.0)) * spacing_scale
|
|
|
|
|
|
func total(count_scale: float = 1.0) -> int:
|
|
var n := 0
|
|
for g in groups:
|
|
n += scaled_count(g, count_scale)
|
|
return n
|
|
|
|
|
|
## What's wrong with the plan (empty when it's fine): unknown enemy types, a target the type
|
|
## doesn't take, arrivals outside the night (as scaled), or an enemy scale that isn't positive.
|
|
func problems(length: float, count_scale: float = 1.0, spacing_scale: float = 1.0) -> PackedStringArray:
|
|
var out := PackedStringArray()
|
|
if groups.is_empty():
|
|
out.append("no groups")
|
|
if enemy_speed_scale <= 0.0 or enemy_hp_scale <= 0.0:
|
|
out.append("enemy scales must be positive")
|
|
for k in groups.size():
|
|
var g: Dictionary = groups[k]
|
|
var where := "group %d" % (k + 1)
|
|
var type := String(g.get("type", ""))
|
|
var t := EnemySystem.TYPE_NAMES.find(type)
|
|
if t < 0:
|
|
out.append("%s: unknown enemy type '%s'" % [where, type])
|
|
continue
|
|
var target := String(g.get("target", "any"))
|
|
var allowed := {"crow": ["crops", "any"], "thief": ["animals", "supplies", "any"], "breaker": ["any"], "ufo": ["any"]}
|
|
if not (allowed[type] as Array).has(target):
|
|
out.append("%s: a %s doesn't go for '%s'" % [where, type, target])
|
|
if int(g.get("count", 0)) < 1 or float(g.get("every", 0.0)) <= 0.0:
|
|
out.append("%s: count and spacing must be positive" % where)
|
|
var last := float(g.get("time", 0.0)) + (scaled_count(g, count_scale) - 1) * scaled_every(g, spacing_scale)
|
|
if float(g.get("time", -1.0)) < 0.0 or last >= length:
|
|
out.append("%s: arrivals (%.0f..%.0f s) outside the %.0f s night" % [where, float(g.get("time", 0.0)), last, length])
|
|
return out
|
|
|
|
|
|
## How many of each enemy type (EnemySystem type id -> count), scaled.
|
|
func type_counts(count_scale: float = 1.0) -> Dictionary:
|
|
var out := {}
|
|
for g in groups:
|
|
var t := maxi(EnemySystem.TYPE_NAMES.find(String(g.get("type", "thief"))), 0)
|
|
out[t] = int(out.get(t, 0)) + scaled_count(g, count_scale)
|
|
return out
|