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 var target var speed := 300 var prevCollisions := 0 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() func _physics_process(_delta): velocity = position.direction_to(target) * speed # look_at(target) # FIXME want enemy to stop when touching something, to prevent vibrating if position.distance_to(target) > 10 and get_slide_collision_count() == prevCollisions: move_and_slide() prevCollisions = get_slide_collision_count()