# quest class, impleeenting all quest functionality # TODO: implement zone quests class_name Quest extends PanelContainer @export var goalType := WorldArea.GoalType.KILL @export var faction := Globals.World.Faction.CREATURE @export var goalTotal := 1 var goalCurrent := 0 func _ready() -> void: SignalBus.enemy_died.connect(_on_enemy_died) #_generate_random_quest() _set_goal_text() _set_goal_val() func _set_goal_text() -> void: var goalStr = WorldArea.GoalType.keys()[self.goalType].capitalize() var factionStr = Globals.World.Faction.keys()[self.faction].capitalize() $QuestProgress/GoalTypeVal.text = "%s %ss" % [goalStr, factionStr] func _set_goal_val() -> void: $QuestProgress/GoalVal.text = str(self.goalTotal) func _quest_goal_check(enemyKillType: Globals.World.Faction) -> void: if enemyKillType == self.faction: self.goalCurrent += 1 $QuestProgress/CompletedVal.text = str(self.goalCurrent) if self.goalCurrent == self.goalTotal: SignalBus.quest_completed.emit() # Globals.fade_node(%QuestComplete, "in", 0.1) # Globals.fade_node(%QuestProgress, "out", 0.1) func _generate_random_quest() -> void: # TODO: generate acutally random quest self.goalType = WorldArea.GoalType.KILL self.faction = Globals.World.Faction.CREATURE self.goalTotal = randi_range(20, 50) # match self.goalType: # GoalTypes.KILLMANY: # self.faction = KillTypes.NATURAL func _on_enemy_died( _enemyDifficulty: NPC.NPCDifficulty, _enemyTier: Globals.World.Tier, enemyFaction: Globals.World.Faction, ): _quest_goal_check(enemyFaction)