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:
@@ -46,7 +46,8 @@ static func capture(npc: SimNPC) -> NPCStateRecord:
|
||||
"last_task": String(npc.last_task),
|
||||
"random_seed": str(npc.random_source.seed),
|
||||
"random_state": str(npc.random_source.state),
|
||||
"familiarity": _sorted_familiarity(npc.familiarity)
|
||||
"familiarity": _sorted_familiarity(npc.familiarity),
|
||||
"mourning_ticks": npc.mourning_ticks
|
||||
}
|
||||
)
|
||||
|
||||
@@ -168,6 +169,7 @@ func restore(debug_logs: bool) -> SimNPC:
|
||||
npc.familiarity[int(pair_dict["id"])] = float(pair_dict["score"])
|
||||
elif saved_familiarity is Dictionary:
|
||||
npc.familiarity = saved_familiarity.duplicate(true)
|
||||
npc.mourning_ticks = int(data.get("mourning_ticks", 0))
|
||||
return npc
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user