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>
59 lines
2.6 KiB
GDScript
59 lines
2.6 KiB
GDScript
class_name Assessment
|
|
extends RefCounted
|
|
## The final assessment once the farmers are back: the share of each category kept, a weighted
|
|
## score, its rating tier (GameConfig.assessment_weights, rating_tiers), and the vacation's totals.
|
|
## * Crops and animals: what's still on the farm of what was there at the start.
|
|
## * Supplies are also spent on building, so they count by theft instead: of everything that
|
|
## passed through the farm (the shed's starting stock plus everything gathered), the share
|
|
## thieves didn't carry off.
|
|
## Categories not in play are left out and the weights renormalized.
|
|
|
|
|
|
## {"parts": category -> share kept (0..1), "score": 0..100, "tier", "text" (the tier's
|
|
## line), "totals": FarmState.totals(), "supplies_handled", "supplies_lost"}.
|
|
static func of(s: FarmState, cfg: GameConfig) -> Dictionary:
|
|
var t := s.totals()
|
|
var parts := {}
|
|
if s.crops_total > 0:
|
|
parts["crops"] = float(s.crops) / s.crops_total
|
|
if s.animals_total > 0:
|
|
parts["animals"] = float(s.animals) / s.animals_total
|
|
var handled: int = s.supplies_total + int(t["gathered_wood"]) + int(t["gathered_scrap"]) + int(t["gathered_straw"])
|
|
if handled > 0:
|
|
parts["supplies"] = 1.0 - minf(float(t["supplies_lost"]) / handled, 1.0)
|
|
var weight := 0.0
|
|
var sum := 0.0
|
|
for k: String in parts:
|
|
var w := float(cfg.assessment_weights.get(k, 0.0))
|
|
weight += w
|
|
sum += w * float(parts[k])
|
|
var score := roundi(100.0 * sum / weight) if weight > 0.0 else 0
|
|
var tier := {}
|
|
for row in cfg.rating_tiers:
|
|
if score >= int(row.get("min", 0)):
|
|
tier = row
|
|
break
|
|
return {"parts": parts, "score": score, "tier": String(tier.get("name", "")), "text": String(tier.get("text", "")),
|
|
"totals": t, "supplies_handled": handled, "supplies_lost": int(t["supplies_lost"])}
|
|
|
|
|
|
## "50 crows, 20 thieves and 6 fence breakers" (or "none").
|
|
static func enemies_line(t: Dictionary) -> String:
|
|
var parts := PackedStringArray()
|
|
for type in [EnemySystem.TYPE_CROW, EnemySystem.TYPE_THIEF, EnemySystem.TYPE_BREAKER, EnemySystem.TYPE_UFO]:
|
|
var n := int(t.get("killed_" + EnemySystem.TYPE_NAMES[type], 0))
|
|
if n == 1:
|
|
parts.append("1 " + EnemySystem.NAMES[type])
|
|
elif n > 1:
|
|
parts.append("%d %s" % [n, EnemySystem.PLURALS[type]])
|
|
return PhaseHud.join_words(parts) if not parts.is_empty() else "none"
|
|
|
|
|
|
## "18 wood, 6 scrap, 12 straw" from the gathered_ or spent_ counts (or "nothing").
|
|
static func materials_line(t: Dictionary, prefix: String) -> String:
|
|
var amounts := {}
|
|
for m in ResourceStore.MATERIALS:
|
|
if int(t.get(prefix + m, 0)) > 0:
|
|
amounts[m] = int(t[prefix + m])
|
|
var text := ResourceStore.describe(amounts)
|
|
return text if text != "" else "nothing"
|