feat: add weak-villager and damaged-roof village needs

This commit is contained in:
Rijad Zuzo
2026-08-11 00:32:22 +02:00
parent 37f262fb84
commit 82e44a9f5d
10 changed files with 547 additions and 45 deletions
+14
View File
@@ -232,6 +232,8 @@ func _select_action_if_idle(npc: SimNPC, previous_state: StringName) -> void:
return
if npc.task_state not in [SimNPC.TASK_STATE_IDLE, SimNPC.TASK_STATE_COMPLETE]:
return
if _is_weak_villager_state(npc):
record_narrative_event(SimulationIds.EVENT_VILLAGER_WEAK, npc.id)
var helper := get_active_opportunity_helper()
var animal_feed_available := animal_care.has_available_feed_target(npc.id)
var selection := action_selector.select_action(
@@ -249,6 +251,16 @@ func _select_action_if_idle(npc: SimNPC, previous_state: StringName) -> void:
record_narrative_event(SimulationIds.EVENT_TASK_STARTED, npc.id, &"", display_name)
func _is_weak_villager_state(npc: SimNPC) -> bool:
return (
npc.is_starving
and npc.energy < 25.0
and village.food <= 0.0
and npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) < 1.0
and opportunity_system.get_open_opportunity() == null
)
func _handle_npc_death(npc: SimNPC, previous_task: StringName, previous_target: StringName) -> void:
if not previous_target.is_empty():
release_npc_reservation(npc.id)
@@ -301,6 +313,8 @@ func _apply_action_completion(
npc.energy = minf(npc.energy + 40.0, 100.0)
npc.position = npc.home_position
record_narrative_event(SimulationIds.EVENT_NPC_SLEPT, npc.id)
if village.safety < 25.0 and opportunity_system.get_open_opportunity() == null:
record_narrative_event(SimulationIds.EVENT_HOME_DAMAGED, npc.id)
SimulationIds.ACTION_FEED_ANIMAL:
pass
SimulationIds.ACTION_PATROL, SimulationIds.ACTION_STUDY, SimulationIds.ACTION_REST, SimulationIds.ACTION_WANDER: