2024-10-13 20:43:25 -06:00
|
|
|
class_name Enemy
|
|
|
|
extends NPC
|
2024-10-13 20:42:32 -06:00
|
|
|
|
|
|
|
|
2024-10-15 08:14:02 -06:00
|
|
|
enum questTypes { NONE, FEW_KILL, MANY_KILL, ONE_KILL }
|
|
|
|
|
|
|
|
signal enemy_died(npcDifficulty: npcDifficulties, questType: questTypes)
|
|
|
|
|
|
|
|
@export var questType: questTypes = questTypes.NONE
|
2024-10-13 20:42:32 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _init() -> void:
|
|
|
|
self.npcDifficulty = npcDifficulties.NORMAL
|
|
|
|
self.npcTier = npcTiers.I
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
# add to enemies
|
|
|
|
add_to_group("enemies")
|
|
|
|
|
2024-10-15 08:14:02 -06:00
|
|
|
# set health
|
2024-10-13 20:42:32 -06:00
|
|
|
_random_mod_health()
|
2024-10-15 08:14:02 -06:00
|
|
|
|
|
|
|
# set health bar
|
|
|
|
%Healthbar.max_value = maxHealth
|
|
|
|
%Healthbar.value = maxHealth
|
2024-10-13 20:42:32 -06:00
|
|
|
|
2024-10-15 08:14:02 -06:00
|
|
|
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()
|