Merge task #24: nights by count, per-night enemy speed and HP, F3 night jump
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
f5bfdc4bef
9 changed files with 259 additions and 22 deletions
|
|
@ -4,6 +4,8 @@ extends CanvasLayer
|
|||
## F1 show / hide this readout
|
||||
## F2 cycle tonight's plan through the debug scenarios (one enemy type, then
|
||||
## pairs, then all three; game/resources/scenarios/) and back to the real one
|
||||
## F3 / Shift+F3 in the morning review: jump to the next / previous day's morning, farm as
|
||||
## it is (jump_morning; debug builds only, not on a co-op partner's machine)
|
||||
## N start the night early (only when GameConfig.allow_early_night is on)
|
||||
## R after Game Over: retry the night; after the farmers return: new vacation
|
||||
## F6 end the current phase now
|
||||
|
|
@ -62,6 +64,8 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
_label.visible = not _label.visible
|
||||
KEY_F2:
|
||||
cycle_scenario()
|
||||
KEY_F3:
|
||||
jump_morning(-1 if key.shift_pressed else 1)
|
||||
KEY_N:
|
||||
campaign.start_night_early()
|
||||
KEY_F6:
|
||||
|
|
@ -75,6 +79,34 @@ func _unhandled_input(event: InputEvent) -> void:
|
|||
s.strip()
|
||||
|
||||
|
||||
## Debug builds, in the morning review only: to the morning of the next (step 1) or previous
|
||||
## (step -1) day, within the vacation. The farm stays as it is and nights_survived follows as
|
||||
## night - 1. It's the campaign's own new-morning path (CampaignController.load_state with the
|
||||
## current state), so everything a real morning does happens: dormant crop fields sprout (or go
|
||||
## dormant again) by nights_survived, the Workbench is granted from nights_survived 1 on, the
|
||||
## retry snapshot is retaken, and the review panel refreshes. As at a real night's end, the
|
||||
## Workbench and the sprouted crops are in the state before that snapshot. The save file is left
|
||||
## alone. Returns whether it moved.
|
||||
func jump_morning(step: int) -> bool:
|
||||
var s := campaign.state
|
||||
if not OS.is_debug_build() or s.phase != CampaignController.Phase.MORNING or campaign.remote_request.is_valid():
|
||||
return false
|
||||
var night := clampi(s.night + step, 1, campaign.config.campaign_nights)
|
||||
if night == s.night:
|
||||
return false
|
||||
s.night = night
|
||||
s.nights_survived = night - 1
|
||||
if sim != null: # what the night's end does first (CampaignController.night_ending)
|
||||
if s.nights_survived >= 1:
|
||||
sim.structures.grant_workbench()
|
||||
sim.loot.grow_crops_total(s.nights_survived)
|
||||
var path := campaign.save_path
|
||||
campaign.save_path = "" # no autosave: a jump isn't a morning the player reached
|
||||
campaign.load_state(s)
|
||||
campaign.save_path = path
|
||||
return true
|
||||
|
||||
|
||||
## Next debug scenario as tonight's plan (after the last, the real plan again).
|
||||
func cycle_scenario() -> void:
|
||||
if sim == null:
|
||||
|
|
@ -115,5 +147,5 @@ func _describe() -> String:
|
|||
lines.append("[N] start the night early")
|
||||
if sim != null and sim.waves.debug_plan != null:
|
||||
lines.append("Scenario: %s (F2 next)" % sim.waves.debug_plan.title)
|
||||
lines.append("F1 hide · F2 scenario · F6 next phase · F7 speed · F9 scarecrow to 0 HP · F10 strip farm · T/G/H thief/crow/breaker")
|
||||
lines.append("F1 hide · F2 scenario · F3 / Shift+F3 next / previous morning · F6 next phase · F7 speed · F9 scarecrow to 0 HP · F10 strip farm · T/G/H thief/crow/breaker")
|
||||
return "\n".join(lines)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -29,11 +29,8 @@ extends Node
|
|||
|
||||
const SCARECROW_RADIUS := 0.4
|
||||
const HUNT_INTERVAL := 0.4
|
||||
const NIGHT_PLANS: Array[String] = [
|
||||
"res://game/resources/nights/night_1.tres", "res://game/resources/nights/night_2.tres",
|
||||
"res://game/resources/nights/night_3.tres", "res://game/resources/nights/night_4.tres",
|
||||
"res://game/resources/nights/night_5.tres",
|
||||
]
|
||||
## Night n's plan file (night_plan_path), for n in 1..GameConfig.campaign_nights.
|
||||
const NIGHT_PLAN_PATH := "res://game/resources/nights/night_%d.tres"
|
||||
|
||||
@export var campaign: CampaignController
|
||||
@export var zones: FarmZones
|
||||
|
|
@ -116,6 +113,28 @@ var _rebuild_ticks: int = 0
|
|||
var _goop_rng := RandomNumberGenerator.new()
|
||||
|
||||
|
||||
## Where night n's plan lives: game/resources/nights/night_<n>.tres.
|
||||
static func night_plan_path(n: int) -> String:
|
||||
return NIGHT_PLAN_PATH % n
|
||||
|
||||
|
||||
## The plans of nights 1..nights, by night_plan_path. A missing (or unreadable) file is an error,
|
||||
## and that night plays the last plan that loaded (as WaveDirector.plan_for does past the end).
|
||||
static func load_night_plans(nights: int) -> Array[NightPlan]:
|
||||
var plans: Array[NightPlan] = []
|
||||
var last: NightPlan = null
|
||||
for n in range(1, nights + 1):
|
||||
var path := night_plan_path(n)
|
||||
var plan: NightPlan = load(path) as NightPlan if ResourceLoader.exists(path) else null
|
||||
if plan == null:
|
||||
push_error("Night %d has no plan at %s: it plays %s" % [n, path, "night %d's" % (n - 1) if last != null else "none"])
|
||||
plan = last
|
||||
else:
|
||||
last = plan
|
||||
plans.append(plan)
|
||||
return plans
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var t0 := Time.get_ticks_msec()
|
||||
config = campaign.config
|
||||
|
|
@ -240,10 +259,7 @@ func _ready() -> void:
|
|||
waves = WaveDirector.new()
|
||||
waves.name = "Waves"
|
||||
add_child(waves)
|
||||
var plans: Array[NightPlan] = []
|
||||
for path in NIGHT_PLANS:
|
||||
plans.append(load(path) as NightPlan)
|
||||
waves.setup(campaign, enemies, zones, plans)
|
||||
waves.setup(campaign, enemies, zones, load_night_plans(config.campaign_nights))
|
||||
for c in _goals["escape"]:
|
||||
if animal_field[c] < FarmNavigation.UNREACHABLE: # not shut in by the props around it
|
||||
waves.ground_spawns.append(nav.cell_center(c))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ extends Resource
|
|||
## starting value to tune during balancing.
|
||||
|
||||
@export_group("Campaign")
|
||||
## Nights the scarecrow must survive before the farmers return.
|
||||
## Nights the scarecrow must survive before the farmers return. Night n plays the plan in
|
||||
## game/resources/nights/night_<n>.tres (FarmSim.night_plan_path), so there must be one per night.
|
||||
@export_range(1, 60) var campaign_nights: int = 5
|
||||
|
||||
@export_group("Waves")
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ 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_1..5.tres are the vacation's nights; game/resources/scenarios/
|
||||
## holds debug plans.
|
||||
## 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
|
||||
|
|
@ -13,7 +14,9 @@ extends Resource
|
|||
## 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).
|
||||
## 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.
|
||||
|
|
@ -23,6 +26,10 @@ extends Resource
|
|||
## 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] = []
|
||||
|
||||
|
||||
|
|
@ -52,11 +59,13 @@ func total(count_scale: float = 1.0) -> int:
|
|||
|
||||
|
||||
## What's wrong with the plan (empty when it's fine): unknown enemy types, a target the type
|
||||
## doesn't take, or arrivals outside the night (as scaled).
|
||||
## 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)
|
||||
|
|
|
|||
|
|
@ -190,7 +190,11 @@ func step(dt: float) -> void:
|
|||
_next += 1
|
||||
|
||||
|
||||
## Nightfall: tonight's arrivals are queued and its enemy scales (NightPlan.enemy_speed_scale and
|
||||
## enemy_hp_scale; the debug plan's when set) go to EnemySystem, until the morning (then 1 again).
|
||||
func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignController.Phase) -> void:
|
||||
if phase == CampaignController.Phase.MORNING:
|
||||
_set_enemy_scales(null)
|
||||
if phase != CampaignController.Phase.NIGHT:
|
||||
return
|
||||
night_time = 0.0
|
||||
|
|
@ -199,9 +203,16 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
|
|||
_queue.clear()
|
||||
_next = 0
|
||||
var plan := tonight()
|
||||
_set_enemy_scales(plan)
|
||||
if plan != null:
|
||||
for g in plan.groups:
|
||||
var every := NightPlan.scaled_every(g, plan.spacing_scale_in(config))
|
||||
for k in NightPlan.scaled_count(g, plan.count_scale_in(config)):
|
||||
_queue.append([float(g.get("time", 0.0)) + k * every, want_of(g), type_of(g)])
|
||||
_queue.sort_custom(func(a: Array, b: Array) -> bool: return float(a[0]) < float(b[0]))
|
||||
|
||||
|
||||
## A plan's enemy scales on EnemySystem (1 and 1 without a plan, or for a scale that isn't positive).
|
||||
func _set_enemy_scales(plan: NightPlan) -> void:
|
||||
enemies.night_speed_scale = plan.enemy_speed_scale if plan != null and plan.enemy_speed_scale > 0.0 else 1.0
|
||||
enemies.night_hp_scale = plan.enemy_hp_scale if plan != null and plan.enemy_hp_scale > 0.0 else 1.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue