feat: add C5 magic spellcasting

This commit is contained in:
goose
2026-10-03 11:01:47 -04:00
parent a7c2e2d034
commit 27f5d5b575
18 changed files with 550 additions and 10 deletions
+16
View File
@@ -2,6 +2,7 @@ class_name ActorState
extends RefCounted
const LimbWoundsType = preload("res://scripts/domain/combat/limb_wounds.gd")
const StatusEffectType = preload("res://scripts/domain/combat/status_effect.gd")
var id: StringName
var cell: Vector2i
@@ -36,6 +37,11 @@ var attack_range := 1
# The active ranged definition is enough to resolve targeting safely now.
var ranged_weapon: Dictionary = {}
var ammunition := 0
# C5 keeps the active-player focus resource on the combat actor until D1 owns
# full character/equipment persistence. PlayerState remains the character-model source.
var max_focus := 15
var focus := 15
var status_effects: Array[StatusEffect] = []
var wounds: LimbWounds
func _init(new_id: StringName, new_cell: Vector2i, new_hit_points: int, new_attack_damage: int, new_content_id: StringName = &"", combat_data: Dictionary = {}) -> void:
@@ -74,6 +80,16 @@ func equip_ranged_weapon(definition: Dictionary, ammunition_count: int) -> void:
func is_alive() -> bool:
return hit_points > 0
func apply_status(effect: StatusEffect) -> void:
for existing in status_effects:
if existing.key == effect.key:
existing.duration = maxi(existing.duration, effect.duration)
return
status_effects.append(effect)
func has_status(key: StringName) -> bool:
return status_effects.any(func(effect: StatusEffect) -> bool: return effect.key == key)
func take_damage(amount: int) -> int:
var actual := mini(maxi(0, amount), hit_points)
hit_points -= actual