class_name Combatant extends Node2D signal healthChanged(health: float) @onready var renderer: AnimatedSprite2D = $AnimatedSprite2D @onready var healthbar: HealthBar = $HealthBar @onready var data: Data = get_node("/root/Arena/Data") @export var spellbook: Spellbook @export var maxHealth: float = 10 @export var health: float = maxHealth @export var player: bool = false var casting: bool = false var castCooldown: float = 0 # Called when the node enters the scene tree for the first time. func _ready(): renderer.animation_finished.connect(animationFinished) renderer.play("idle") spellbook.initCooldowns() healthbar.maxHealth = maxHealth if !player: data.opponent = self renderer.flip_h = true healthbar.position.x *= -1 match data.difficulty: Data.Difficulty.EASY: castCooldown = 3 Data.Difficulty.NORMAL: castCooldown = 1 Data.Difficulty.HARD: castCooldown = 0.5 Data.Difficulty.GAMER: castCooldown = 0 else: data.player = self # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if !player: match data.difficulty: Data.Difficulty.EASY: _easyAI(delta) Data.Difficulty.NORMAL: _normalAI(delta) Data.Difficulty.HARD: _hardAI(delta) Data.Difficulty.GAMER: _gamerAI(delta) func _easyAI(delta): pass func _normalAI(delta): pass func _hardAI(delta): pass func _gamerAI(delta): pass func _finishedCasting(): pass func timing(delta): castCooldown -= delta if castCooldown <= 0: pass func alterHealth(change: float, stun: bool): health += change if stun: casting = false renderer.play("hit") healthChanged.emit(health) func animationFinished(): renderer.play("idle")