35 lines
810 B
GDScript3
35 lines
810 B
GDScript3
![]() |
extends Node2D
|
||
|
|
||
|
class_name Combatant
|
||
|
|
||
|
@export var spellbook: Spellbook
|
||
|
@onready var renderer: AnimatedSprite2D = $AnimatedSprite2D
|
||
|
@onready var particleSystem: GPUParticles2D = $chargingParticles
|
||
|
@export var maxHealth: float = 10
|
||
|
@export var health: float = maxHealth
|
||
|
@export var player: bool = false
|
||
|
var casting = false
|
||
|
|
||
|
# Called when the node enters the scene tree for the first time.
|
||
|
func _ready():
|
||
|
renderer.animation_finished.connect(animationFinished)
|
||
|
spellbook.initCooldowns()
|
||
|
|
||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
func _process(delta):
|
||
|
if !player:
|
||
|
_aiControlled()
|
||
|
|
||
|
func _aiControlled():
|
||
|
pass
|
||
|
|
||
|
func alterHealth(damage: float, stun: bool):
|
||
|
health -= damage
|
||
|
if stun:
|
||
|
casting = false
|
||
|
renderer.play("hit")
|
||
|
|
||
|
func animationFinished():
|
||
|
renderer.play("idle")
|
||
|
|