feat: NPC mourning behavior on housemate death
When an NPC dies from starvation, their highest-familiarity companion enters mourning for 100 ticks (~half a day). Mourning NPCs skip work: they rest if energy is low, otherwise wander near home. Mourning_ticks counts down each tick through ActionExecutionSystem and is serialized for save/load continuity with backward-compatible default of 0. This gives the familiarity graph its first behavioral consequence.
This commit is contained in:
@@ -6,6 +6,8 @@ func advance_npc(npc: SimNPC, village: SimVillage) -> void:
|
||||
if npc.is_dead:
|
||||
return
|
||||
_update_needs(npc, village)
|
||||
if npc.mourning_ticks > 0:
|
||||
npc.mourning_ticks -= 1
|
||||
if npc.is_dead or npc.task_state != SimNPC.TASK_STATE_WORKING:
|
||||
return
|
||||
npc.task_progress += 1.0
|
||||
|
||||
@@ -34,6 +34,14 @@ func select_action(npc: SimNPC, village: SimVillage, time_of_day: float = 0.5, a
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_GATHER_FOOD, -1.0, "Starving; must find food"
|
||||
)
|
||||
if npc.mourning_ticks > 0:
|
||||
if npc.energy < 40.0:
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_REST, -1.0, "Mourning; seeking rest"
|
||||
)
|
||||
return ActionSelectionResult.new(
|
||||
SimulationIds.ACTION_WANDER, -1.0, "Mourning; wandering near home"
|
||||
)
|
||||
if npc.hunger > 80.0:
|
||||
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) >= 1.0:
|
||||
return ActionSelectionResult.new(
|
||||
|
||||
Reference in New Issue
Block a user