feat: add combat, wild wolves, factions, and tribe war motivation

This commit is contained in:
Rijad Zuzo
2026-08-11 20:29:47 +02:00
parent e359e5253a
commit 292cdd9153
16 changed files with 1475 additions and 3 deletions
+25
View File
@@ -0,0 +1,25 @@
class_name ItemDefinition
extends Resource
@export var item_id: StringName
@export var display_name: String
@export var category: StringName = SimulationIds.ITEM_CATEGORY_WEAPON
@export var equip_slot: StringName = SimulationIds.EQUIP_SLOT_HAND
@export_range(0.0, 1000.0, 0.1) var damage := 0.0
@export_range(0.0, 50.0, 0.1) var reach := 1.5
@export_range(0.0, 5.0, 0.05) var attack_cooldown := 0.6
func validate() -> Array[String]:
var errors: Array[String] = []
if item_id.is_empty():
errors.append("item_id is empty")
if display_name.is_empty():
errors.append("display_name is empty for '%s'" % item_id)
if damage <= 0.0:
errors.append("damage must be positive for '%s'" % item_id)
return errors
func is_weapon() -> bool:
return category == SimulationIds.ITEM_CATEGORY_WEAPON
@@ -0,0 +1 @@
uid://bf722tp11qt7j
+30
View File
@@ -71,6 +71,36 @@ const KNOWLEDGE_ACQUISITION_WITNESSED := &"witnessed"
const KNOWLEDGE_ACQUISITION_COMMUNICATED := &"communicated"
const KNOWLEDGE_ACQUISITION_LEGACY := &"legacy"
const ITEM_SWORD := &"item_sword"
const ITEM_CLAW := &"item_claw"
const ITEM_CATEGORY_WEAPON := &"weapon"
const EQUIP_SLOT_HAND := &"hand"
const FACTION_VILLAGE := &"faction_village"
const FACTION_TRIBE := &"faction_tribe"
const STANCE_NEUTRAL := &"neutral"
const STANCE_HOSTILE := &"hostile"
const WAR_PLAN_NONE := &"none"
const WAR_PLAN_PLANNED := &"planned"
const WAR_PLAN_RAIDING := &"raiding"
const WAR_PLAN_ABORTED := &"aborted"
const COMBATANT_KIND_NPC := &"npc"
const COMBATANT_KIND_RAIDER := &"raider"
const COMBATANT_KIND_WOLF := &"wolf"
const COMBATANT_KIND_PLAYER := &"player"
const EVENT_COMBATANT_HURT := &"combatant_hurt"
const EVENT_COMBATANT_KILLED := &"combatant_killed"
const EVENT_RAID_STARTED := &"raid_started"
const EVENT_WAR_RESOLVED := &"war_resolved"
const EVENT_WAR_ABORTED := &"war_aborted"
const EVENT_WOLF_HUNT := &"wolf_hunt"
static func npc_inventory_id(npc_id: int) -> StringName:
return StringName("npc_%d_inventory" % npc_id)
static func npc_combatant_id(npc_id: int) -> StringName:
return StringName("npc_%d_combatant" % npc_id)
+50
View File
@@ -0,0 +1,50 @@
class_name SimulationItems
extends RefCounted
static var _items: Dictionary = {}
static var _cache_valid := false
static func _ensure_cache() -> void:
if _cache_valid:
return
_items = {}
_add_weapon(SimulationIds.ITEM_SWORD, "Sword", 24.0, 2.4, 0.55)
_add_weapon(SimulationIds.ITEM_CLAW, "Claw", 10.0, 1.2, 0.4)
_cache_valid = true
static func _add_weapon(
item_id: StringName, display_name: String, damage: float, reach: float, cooldown: float
) -> void:
var item := ItemDefinition.new()
item.item_id = item_id
item.display_name = display_name
item.category = SimulationIds.ITEM_CATEGORY_WEAPON
item.equip_slot = SimulationIds.EQUIP_SLOT_HAND
item.damage = damage
item.reach = reach
item.attack_cooldown = cooldown
_items[item_id] = item
static func invalidate_cache() -> void:
_cache_valid = false
static func get_item(item_id: StringName) -> ItemDefinition:
_ensure_cache()
return _items.get(item_id) as ItemDefinition
static func get_items() -> Array[ItemDefinition]:
_ensure_cache()
var values: Array[ItemDefinition] = []
for item in _items.values():
values.append(item)
return values
static func get_weapon(item_id: StringName) -> ItemDefinition:
var item := get_item(item_id)
return item if item != null and item.is_weapon() else null
@@ -0,0 +1 @@
uid://doogu4fg3ysgi