Phase 9+10: Status/Doctor/Medical bed + Wolves/WolfSpawner
The 'drama pair' shipped together via 3-agent fan-out. Phase 9 — Status effects + Medicine: - Status data class (PERSISTENT/EVENT, severity stacks max=3) + StatusCatalog (Bleeding ticks HP loss; Downed = incapacitated) - Pawn HP (100 max, 30 downed threshold, 50 revive threshold), take_damage, heal, add_status/remove_status_by_id, is_downed/is_incapacitated, downed visual (body rotated 90° + desaturated) - DoctorProvider (priority 9, highest) — scans World.pawns for nearest downed pawn, finds medical bed (or any bed fallback), emits 4-toil job: walk_to_patient → rescue → walk_to_bed → treat - Bed.is_medical with red-cross marker draw on pillow; round-trips save - KIND_RESCUE + KIND_TREAT toils + JobRunner _tick_rescue/_tick_treat (snap-to-bed on first treat tick, +0.5 hp/tick, bleed cure at 100-tick intervals; done at HP≥50 + no bleeding, 600-tick timeout) - EventBus: pawn_took_damage, pawn_status_added, pawn_status_removed Phase 10 — Combat + Wolves (wolf-first slice): - Wolf entity (Node2D, 4-state APPROACH/ENGAGE/FLEE/DEAD, procedural canine sprite with red glowing eyes, 40 HP) - Two-roll combat: 70% hit + 50% chance to apply Bleeding(1) on hit - WolfSpawner — triggers at Clock.darkness_factor()≥0.8 with 1-in-game-day cooldown, packs of 1–2 at random map-edge cluster - World.wolves registry + register_wolf/unregister_wolf Integration: world.tscn load_steps 15→17 with DoctorProvider + WolfSpawner nodes. world.gd registers doctor at top of provider list (priority 9 > sleep 8 > eat 7 > construction 6 > chop≈plant 5 > mine≈craft 4 > haul 3 > rest 0). Middle bed at (47,24) marked is_medical=true. MCP runtime verified: Bram took 75 dmg + Bleeding(2) → Downed (hp 25) → Edda + Cora both volunteered doctor job → walked to patient → carried to medical bed → treated → Bram healed to 94.2 hp, statuses cleared, back to work. Wolf raid at day 3 22:00 fired; 4 wolves alive across raid cycles by day 4 01:51. Screenshots confirm red-cross medical bed and wolf silhouettes at night. Phase 10 deliberately partial: wolf-side combat ships, pawn-side weapons/armor/cover/friendly-fire deferred — full chain (wolf→bites→pawn→bleeds→doctor) awaits player weapons. Bleed-out timer at demo value (1200) vs design value (432000 = 6 in-game hours) — documented in status_catalog.gd for first time-balance pass. Delegation: Agent A (status + pawn HP), Agent B (doctor + treatment), Agent C (wolf + spawner) — all Sonnet gdscript-refactor; integration on Opus. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a1e5b38dd6
commit
1b6ad2bcc6
21 changed files with 1016 additions and 35 deletions
|
|
@ -105,6 +105,10 @@ func tick() -> void:
|
|||
_tick_eat(t)
|
||||
Toil.KIND_SLEEP:
|
||||
_tick_sleep(t)
|
||||
Toil.KIND_RESCUE:
|
||||
_tick_rescue(t)
|
||||
Toil.KIND_TREAT:
|
||||
_tick_treat(t)
|
||||
|
||||
if t.done:
|
||||
job.advance()
|
||||
|
|
@ -621,6 +625,140 @@ func _tick_sleep(t) -> void:
|
|||
t.done = true
|
||||
|
||||
|
||||
## Execute one tick of a RESCUE toil.
|
||||
##
|
||||
## Single-tick marker. The doctor walks to the patient via a preceding WALK_TO
|
||||
## toil; this toil records the visit and immediately completes. The actual
|
||||
## "transport" of the patient to the medical bed is handled by the subsequent
|
||||
## WALK_TO(bed) + TREAT toil sequence: the TREAT toil snaps the patient to the
|
||||
## doctor's tile on its first tick, which is the bed tile.
|
||||
##
|
||||
## If the patient is gone or no longer downed, we log and skip (done=true)
|
||||
## so the job runner doesn't stall on a phantom task.
|
||||
func _tick_rescue(t) -> void:
|
||||
var patient = _resolve_patient(t)
|
||||
if patient == null:
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s rescue: patient gone or invalid — skipping" % pawn.pawn_name
|
||||
)
|
||||
t.done = true
|
||||
return
|
||||
if not patient.has_method("is_downed") or not patient.is_downed():
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s rescue: patient %s is not downed — skipping" % [pawn.pawn_name, patient.pawn_name]
|
||||
)
|
||||
t.done = true
|
||||
return
|
||||
t.data["started"] = true
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s reached downed %s — walking to bed for treatment" % [pawn.pawn_name, patient.pawn_name]
|
||||
)
|
||||
t.done = true
|
||||
|
||||
|
||||
## Execute one tick of a TREAT toil.
|
||||
##
|
||||
## First tick (started=false):
|
||||
## - Resolve the patient node. If gone or no longer downed, skip immediately.
|
||||
## - Snap the patient to the doctor's current tile (the medical-bed tile the
|
||||
## doctor just walked to). This is the Phase 9 simplification: no carry
|
||||
## visual; Phase 17 may replace this with a proper carry animation.
|
||||
## - Mark started=true, ticks_treating=0.
|
||||
##
|
||||
## Every tick (including first, after the snap):
|
||||
## - Increment ticks_treating.
|
||||
## - Call patient.heal(0.5).
|
||||
## - Every 100 ticks: remove "bleeding" status if present (full cure, Phase 9
|
||||
## simplification; Phase 17 may reduce severity incrementally).
|
||||
## - Done when patient.hp >= HP_REVIVE_THRESHOLD AND no "bleeding" status.
|
||||
## - Done (safety ceiling) when ticks_treating > 600.
|
||||
##
|
||||
## HP_REVIVE_THRESHOLD mirrors Pawn.HP_REVIVE_THRESHOLD (50.0). Compared as a
|
||||
## literal so the duck-typed pawn ref doesn't need const access.
|
||||
const _HP_REVIVE_THRESHOLD: float = 50.0
|
||||
const _TREAT_TICKS_MAX: int = 600
|
||||
|
||||
func _tick_treat(t) -> void:
|
||||
var patient = _resolve_patient(t)
|
||||
|
||||
if not t.data.get("started", false):
|
||||
# ── first-tick: validate and snap patient to bed tile ─────────────────
|
||||
if patient == null:
|
||||
Audit.log("job_runner", "%s treat: patient gone — skipping" % pawn.pawn_name)
|
||||
t.done = true
|
||||
return
|
||||
if not patient.has_method("is_downed") or not patient.is_downed():
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s treat: patient %s already up — skipping" % [pawn.pawn_name, patient.pawn_name]
|
||||
)
|
||||
t.done = true
|
||||
return
|
||||
# Snap patient to the doctor's current tile (the medical-bed tile).
|
||||
# Phase 9 simplification: instant teleport; Phase 17 may add carry visual.
|
||||
patient.tile = pawn.tile
|
||||
patient.position = Vector2(pawn.tile.x * 16 + 8, pawn.tile.y * 16 + 8)
|
||||
t.data["started"] = true
|
||||
t.data["ticks_treating"] = 0
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s treating %s at %s" % [pawn.pawn_name, patient.pawn_name, pawn.tile]
|
||||
)
|
||||
|
||||
# ── per-tick treatment ─────────────────────────────────────────────────────
|
||||
if patient == null or not is_instance_valid(patient):
|
||||
t.done = true
|
||||
return
|
||||
|
||||
t.data["ticks_treating"] = int(t.data.get("ticks_treating", 0)) + 1
|
||||
var ticks: int = int(t.data["ticks_treating"])
|
||||
|
||||
patient.heal(0.5)
|
||||
|
||||
# Cure bleeding in full after 100 ticks of treatment (Phase 9 simplification).
|
||||
if ticks % 100 == 0 and patient.has_method("has_status") and patient.has_status(&"bleeding"):
|
||||
patient.remove_status_by_id(&"bleeding")
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s cleared bleeding on %s (tick %d)" % [pawn.pawn_name, patient.pawn_name, ticks]
|
||||
)
|
||||
|
||||
# Done when HP is above revive threshold AND bleeding is cleared.
|
||||
var hp_ok: bool = patient.hp >= _HP_REVIVE_THRESHOLD
|
||||
var bleed_ok: bool = not (patient.has_method("has_status") and patient.has_status(&"bleeding"))
|
||||
if hp_ok and bleed_ok:
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s finished treating %s (hp=%.1f, ticks=%d)" % [pawn.pawn_name, patient.pawn_name, patient.hp, ticks]
|
||||
)
|
||||
t.done = true
|
||||
return
|
||||
|
||||
# Safety ceiling — prevent the toil from stalling if HP/bleed can't converge.
|
||||
if ticks > _TREAT_TICKS_MAX:
|
||||
Audit.log(
|
||||
"job_runner",
|
||||
"%s treatment timeout for %s (hp=%.1f, ticks=%d)" % [pawn.pawn_name, patient.pawn_name, patient.hp, ticks]
|
||||
)
|
||||
t.done = true
|
||||
|
||||
|
||||
## Resolve the patient Pawn node from the NodePath stored in `t.data["patient"]`.
|
||||
## Returns null and logs if the node is absent or no longer valid.
|
||||
## Shared by _tick_rescue and _tick_treat.
|
||||
func _resolve_patient(t):
|
||||
var path := NodePath(t.data.get("patient", ""))
|
||||
if path == NodePath(""):
|
||||
return null
|
||||
var node = get_tree().get_root().get_node_or_null(path)
|
||||
if node == null or not is_instance_valid(node):
|
||||
return null
|
||||
return node
|
||||
|
||||
|
||||
# ── helpers ──────────────────────────────────────────────────────────────────
|
||||
|
||||
## Emit job_completed, log, and clear the job reference.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue