From 852d10f7ae762e3ef0b252264c84c9f34f6c760b Mon Sep 17 00:00:00 2001 From: Rijad Zuzo Date: Sat, 20 Jun 2026 18:18:00 +0200 Subject: [PATCH] feat: add initial starvation consequence --- simulation/SimNPC.gd | 10 ++++++++++ simulation/SimVillage.gd | 14 ++++++++++---- simulation/SimulationManager.gd | 7 +++++++ world/ui/ui.gd | 3 ++- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/simulation/SimNPC.gd b/simulation/SimNPC.gd index 391bdc4..7a48421 100644 --- a/simulation/SimNPC.gd +++ b/simulation/SimNPC.gd @@ -11,6 +11,8 @@ var intelligence: float var current_task: String = "idle" var position: Vector3 +var is_starving := false + func _init( _id: int, _npc_name: String, @@ -47,6 +49,14 @@ func simulate_tick(village: SimVillage) -> void: current_task = "rest" energy += 20.0 return + + is_starving = hunger >= 90.0 + + if is_starving: + energy -= 8.0 + + hunger = clamp(hunger, 0.0, 100.0) + energy = clamp(energy, 0.0, 100.0) if village.food < 15.0: current_task = "gather_food" diff --git a/simulation/SimVillage.gd b/simulation/SimVillage.gd index 53639d2..392f353 100644 --- a/simulation/SimVillage.gd +++ b/simulation/SimVillage.gd @@ -37,15 +37,21 @@ func update_modifiers() -> void: func apply_npc_task(npc: SimNPC) -> void: + var productivity := 1.0 + if npc.energy < 20.0: + productivity = 0.25 + elif npc.energy < 40.0: + productivity = 0.5 + match npc.current_task: "gather_food": - food += 2.0 + food += 2.0 * productivity "gather_wood": - wood += 2.0 + wood += 2.0 * productivity "patrol": - safety += 1.0 + safety += 1.0 * productivity "study": - knowledge += 1.0 + knowledge += 1.0 * productivity "eat": food -= 1.0 "rest": diff --git a/simulation/SimulationManager.gd b/simulation/SimulationManager.gd index 8f3c9f5..38f12a0 100644 --- a/simulation/SimulationManager.gd +++ b/simulation/SimulationManager.gd @@ -94,3 +94,10 @@ func add_safety(amount: float) -> void: func add_knowledge(amount: float) -> void: village.knowledge += amount village_changed.emit(village) + +func get_starving_count() -> int: + var count := 0 + for npc in npcs: + if npc.is_starving: + count += 1 + return count diff --git a/world/ui/ui.gd b/world/ui/ui.gd index 13fd801..06c1549 100644 --- a/world/ui/ui.gd +++ b/world/ui/ui.gd @@ -27,6 +27,7 @@ func _on_village_changed(village: SimVillage) -> void: Wood: %s Safety: %s Knowledge: %s + Starving: %s Food Mod: %.2f Safety Mod: %.2f @@ -36,7 +37,7 @@ func _on_village_changed(village: SimVillage) -> void: round(village.wood), round(village.safety), round(village.knowledge), - + simulation_manager.get_starving_count(), village.food_modifier, village.safety_modifier, village.knowledge_modifier