mirror of
https://github.com/Relintai/pandemonium_demo_projects.git
synced 2025-01-04 14:49:41 +01:00
43 lines
735 B
GDScript
43 lines
735 B
GDScript
class_name Combatant
|
|
extends Node
|
|
|
|
export(int) var damage = 1
|
|
export(int) var defense = 1
|
|
var active = false setget set_active
|
|
|
|
signal turn_finished
|
|
|
|
func set_active(value):
|
|
active = value
|
|
set_process(value)
|
|
set_process_input(value)
|
|
|
|
if not active:
|
|
return
|
|
if $Health.armor >= $Health.base_armor + defense:
|
|
$Health.armor = $Health.base_armor
|
|
|
|
|
|
func attack(target):
|
|
target.take_damage(damage)
|
|
emit_signal("turn_finished")
|
|
|
|
|
|
func consume(item):
|
|
item.use(self)
|
|
emit_signal("turn_finished")
|
|
|
|
|
|
func defend():
|
|
$Health.armor += defense
|
|
emit_signal("turn_finished")
|
|
|
|
|
|
func flee():
|
|
emit_signal("turn_finished")
|
|
|
|
|
|
func take_damage(damage_to_take):
|
|
$Health.take_damage(damage_to_take)
|
|
$Sprite/AnimationPlayer.play("take_damage")
|