semi-idle-arpg/scripts/NPCEnemy.gd

35 lines
814 B
GDScript3
Raw Normal View History

2024-10-15 08:37:50 -06:00
class_name NPCEnemy
extends NPC
enum questTypes { NONE, FEW_KILL, MANY_KILL, ONE_KILL }
signal enemy_died(npcDifficulty: npcDifficulties, questType: questTypes)
@export var questType: questTypes = questTypes.NONE
func _init() -> void:
self.npcDifficulty = npcDifficulties.NORMAL
self.npcTier = npcTiers.I
func _ready() -> void:
# add to enemies
add_to_group("enemies")
# set health
_random_mod_health()
# set health bar
%Healthbar.max_value = maxHealth
%Healthbar.value = maxHealth
func _process(_delta: float) -> void:
%Healthbar.value = maxHealth - damageTaken
if damageTaken >= maxHealth:
# send signal that I died to be counted, etc.
enemy_died.emit(self.npcDifficulty, self.questType)
# delete node
self.queue_free()