feat: shared creature root, enemy definitions, defend duty, and player downing

This commit is contained in:
Rijad Zuzo
2026-08-12 00:16:48 +02:00
parent 6de6d25bf5
commit 661d53f31a
23 changed files with 653 additions and 76 deletions
+10 -1
View File
@@ -24,7 +24,8 @@ func select_action(
all_npcs: Array = [],
opportunity_helper: OpportunityHelperResult = null,
population_view: SimulationPopulationView = null,
animal_feed_available: bool = false
animal_feed_available: bool = false,
war_raid_active: bool = false
) -> ActionSelectionResult:
if npc.is_dead:
return null
@@ -115,6 +116,10 @@ func select_action(
-1.0,
"Responding to village need: %s" % opportunity_helper.reason
)
if war_raid_active and period == SchedulePeriod.WORK and _is_eligible_defender(npc):
return ActionSelectionResult.new(
SimulationIds.ACTION_DEFEND, -1.0, "Rallying to defend the village"
)
if npc.get_inventory_amount(SimulationIds.RESOURCE_FOOD) > 0.0:
return ActionSelectionResult.new(
SimulationIds.ACTION_DEPOSIT_FOOD, -1.0, "Carrying food for storage"
@@ -297,6 +302,10 @@ func _calculate_score(
return score
static func _is_eligible_defender(npc: SimNPC) -> bool:
return npc.strength >= 5.0 or npc.profession == SimulationIds.PROFESSION_GUARD
static func _get_period(time_of_day: float) -> int:
if _in_wrap_range(time_of_day, SLEEP_BEGIN, SLEEP_END):
return SchedulePeriod.SLEEP