class_name EventIfQuestObjective extends "res://scripts/Event/Condition/EventIf.gd" enum Type { ANY_OF_OBJECTIVES_COMPLETED, ALL_OF_OBJECTIVES_COMPLETED, ANY_OF_OBJECTIVES_NOT_COMPLETED, ALL_OF_OBJECTIVES_NOT_COMPLETED, SPECIFIC_OBJECTIVE_COMPLETED, SPECIFIC_OBJECTIVE_NOT_COMPLETED, } @export var questKey:QuestSystem.QuestKey = QuestSystem.QuestKey.TEST_QUEST @export var type:Type = Type.ALL_OF_OBJECTIVES_COMPLETED @export var objective:int = 0 @export var triggerMultipleTimes: bool = false func _enter_tree() -> void: QUEST.questUpdated.connect(onQuestUpdated) func _exit_tree() -> void: QUEST.questUpdated.disconnect(onQuestUpdated) func onQuestUpdated(quest:Quest) -> void: if self.ended: if !self.triggerMultipleTimes: return self.reset() if quest.questKey != self.questKey: return if !quest.isStarted(): return match type: Type.ANY_OF_OBJECTIVES_COMPLETED: for objective in quest.objecitves: if !objective.isCompleted(): continue self.start() return Type.ALL_OF_OBJECTIVES_COMPLETED: for objective in quest.objectives: if !objective.isCompleted(): return self.start() Type.ANY_OF_OBJECTIVES_NOT_COMPLETED: for objective in quest.objectives: if objective.isCompleted(): continue self.start() return Type.ALL_OF_OBJECTIVES_NOT_COMPLETED: for objective in quest.objectives: if objective.isCompleted(): return self.start() Type.SPECIFIC_OBJECTIVE_COMPLETED: if quest.objectives[objective].isCompleted(): self.start() return Type.SPECIFIC_OBJECTIVE_NOT_COMPLETED: if quest.objectives[objective].isCompleted(): return self.start()