From 93c740f1ff31bb33baedd4a1b7885b9855605fc5 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Mon, 6 Jan 2025 23:37:49 -0600 Subject: [PATCH] Started quest system --- scenes/Systems.tscn | 12 ++++--- .../Event/VisualNovel/TextboxEvent.gd | 6 ++-- scripts/Cutscene/TestCutscene.gd | 7 ---- scripts/{Items => Item}/Item.gd | 0 scripts/{Items => Item}/ItemStack.gd | 0 scripts/{Items => Item}/Potion.gd | 4 +-- scripts/Quest/Objective/QuestObjective.gd | 8 +++++ scripts/Quest/Quest.gd | 35 +++++++++++++++++++ scripts/Quest/QuestExample.gd | 6 ++++ scripts/{Systems => System}/CutsceneSystem.gd | 0 scripts/{Systems => System}/ItemSystem.gd | 6 ++-- scripts/System/QuestSystem.gd | 7 ++++ scripts/System/Systems.gd | 17 +++++++++ scripts/Systems/Systems.gd | 14 -------- 14 files changed, 89 insertions(+), 33 deletions(-) rename scripts/{Items => Item}/Item.gd (100%) rename scripts/{Items => Item}/ItemStack.gd (100%) rename scripts/{Items => Item}/Potion.gd (68%) create mode 100644 scripts/Quest/Objective/QuestObjective.gd create mode 100644 scripts/Quest/Quest.gd create mode 100644 scripts/Quest/QuestExample.gd rename scripts/{Systems => System}/CutsceneSystem.gd (100%) rename scripts/{Systems => System}/ItemSystem.gd (91%) create mode 100644 scripts/System/QuestSystem.gd create mode 100644 scripts/System/Systems.gd delete mode 100644 scripts/Systems/Systems.gd diff --git a/scenes/Systems.tscn b/scenes/Systems.tscn index 3c1e18b..e570f71 100644 --- a/scenes/Systems.tscn +++ b/scenes/Systems.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://iibqlagufwhm"] +[gd_scene load_steps=5 format=3 uid="uid://iibqlagufwhm"] -[ext_resource type="Script" path="res://scripts/Systems/Systems.gd" id="1_uen2c"] -[ext_resource type="Script" path="res://scripts/Systems/CutsceneSystem.gd" id="2_sf62c"] -[ext_resource type="Script" path="res://scripts/Systems/ItemSystem.gd" id="3_nwp6i"] +[ext_resource type="Script" path="res://scripts/System/Systems.gd" id="1_uen2c"] +[ext_resource type="Script" path="res://scripts/System/CutsceneSystem.gd" id="2_sf62c"] +[ext_resource type="Script" path="res://scripts/System/ItemSystem.gd" id="3_nwp6i"] +[ext_resource type="Script" path="res://scripts/System/QuestSystem.gd" id="4_d00wi"] [node name="Systems" type="Node3D"] script = ExtResource("1_uen2c") @@ -12,3 +13,6 @@ script = ExtResource("2_sf62c") [node name="Item" type="Node3D" parent="."] script = ExtResource("3_nwp6i") + +[node name="Quest" type="Node3D" parent="."] +script = ExtResource("4_d00wi") diff --git a/scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd b/scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd index bd79f40..4dad9ba 100644 --- a/scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd +++ b/scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd @@ -1,9 +1,9 @@ class_name TextboxEvent extends "res://scripts/Cutscene/CutsceneEvent.gd" -var text:string; +var text:String; func _init( - text:string + text:String ) -> void: super._init(); self.text = text; @@ -12,4 +12,4 @@ func start() -> void: print("He can say ", text); func isDone() -> bool: - return false \ No newline at end of file + return false diff --git a/scripts/Cutscene/TestCutscene.gd b/scripts/Cutscene/TestCutscene.gd index 7c2e779..8ce5247 100644 --- a/scripts/Cutscene/TestCutscene.gd +++ b/scripts/Cutscene/TestCutscene.gd @@ -5,14 +5,7 @@ const CutsceneConcurrentEvent = preload("res://scripts/Cutscene/Event/CutsceneCo const CutsceneIfEvent = preload("res://scripts/Cutscene/Event/CutsceneIfEvent.gd"); const CutsceneWhileEvent = preload("res://scripts/Cutscene/Event/CutsceneWhileEvent.gd"); -func testIf() -> bool: - print("Test if"); - return true; - func setupCutscene() -> void: add([ - CutsceneWhileEvent.new(testIf,[ - CutscenePrintEvent.new("While") - ]), ]); pass diff --git a/scripts/Items/Item.gd b/scripts/Item/Item.gd similarity index 100% rename from scripts/Items/Item.gd rename to scripts/Item/Item.gd diff --git a/scripts/Items/ItemStack.gd b/scripts/Item/ItemStack.gd similarity index 100% rename from scripts/Items/ItemStack.gd rename to scripts/Item/ItemStack.gd diff --git a/scripts/Items/Potion.gd b/scripts/Item/Potion.gd similarity index 68% rename from scripts/Items/Potion.gd rename to scripts/Item/Potion.gd index c792e59..956e2a8 100644 --- a/scripts/Items/Potion.gd +++ b/scripts/Item/Potion.gd @@ -1,4 +1,4 @@ -class_name Potion extends "res://scripts/Items/Item.gd" +class_name Potion extends "res://scripts/Item/Item.gd" func getName() -> String: return "Potion" @@ -10,4 +10,4 @@ func isConsumable() -> bool: return true; func consume() -> void: - print("Consuming Potion"); \ No newline at end of file + print("Consuming Potion"); diff --git a/scripts/Quest/Objective/QuestObjective.gd b/scripts/Quest/Objective/QuestObjective.gd new file mode 100644 index 0000000..3de2a9b --- /dev/null +++ b/scripts/Quest/Objective/QuestObjective.gd @@ -0,0 +1,8 @@ +class_name QuestObjective + +var name:String + +func _init( + name:String +): + self.name = name; diff --git a/scripts/Quest/Quest.gd b/scripts/Quest/Quest.gd new file mode 100644 index 0000000..6a5442e --- /dev/null +++ b/scripts/Quest/Quest.gd @@ -0,0 +1,35 @@ +class_name Quest +const QuestObjective = preload("res://scripts/Quest/Objective/QuestObjective.gd"); + +enum QuestState { + NOT_STARTED, + ACTIVE, + INACTIVE, + FINISHED +}; + +var questName:String; +var questState:QuestState = QuestState.NOT_STARTED; +var objectives:Array[QuestObjective] = []; +var currentObjective = -1; + +func _init( + questName:String, + objectives:Array[QuestObjective] +) -> void: + self.questName = questName; + self.objectives = objectives; + +func getState() -> QuestState: + return questState; + +func start(): + questState = QuestState.ACTIVE; + currentObjective = 0; + +func nextObjective(): + currentObjective = currentObjective + 1; + if currentObjective >= objectives.size(): + questState = QuestState.FINISHED; + return null; + return objectives[currentObjective]; diff --git a/scripts/Quest/QuestExample.gd b/scripts/Quest/QuestExample.gd new file mode 100644 index 0000000..5aabc24 --- /dev/null +++ b/scripts/Quest/QuestExample.gd @@ -0,0 +1,6 @@ +class_name QuestExample extends "res://scripts/Quest/Quest.gd" + +func _init() -> void: + super("Example Quest", [ + QuestObjective.new("Test") + ]); diff --git a/scripts/Systems/CutsceneSystem.gd b/scripts/System/CutsceneSystem.gd similarity index 100% rename from scripts/Systems/CutsceneSystem.gd rename to scripts/System/CutsceneSystem.gd diff --git a/scripts/Systems/ItemSystem.gd b/scripts/System/ItemSystem.gd similarity index 91% rename from scripts/Systems/ItemSystem.gd rename to scripts/System/ItemSystem.gd index d8ddb5a..3d0e432 100644 --- a/scripts/Systems/ItemSystem.gd +++ b/scripts/System/ItemSystem.gd @@ -1,6 +1,6 @@ class_name ItemSystem extends Node -const Item = preload("res://scripts/Items/Item.gd"); -const ItemStack = preload("res://scripts/Items/ItemStack.gd"); +const Item = preload("res://scripts/Item/Item.gd"); +const ItemStack = preload("res://scripts/Item/ItemStack.gd"); enum ItemSortType { NAME, @@ -17,7 +17,7 @@ class ItemStackTypeComparator: # Constants const ITEM_STACK_SIZE_MAX = 99; -var ITEM_POTION = preload("res://scripts/Items/Potion.gd").new(); +var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new(); var inventory:Array[ItemStack] = []; # Methods diff --git a/scripts/System/QuestSystem.gd b/scripts/System/QuestSystem.gd new file mode 100644 index 0000000..49e89fa --- /dev/null +++ b/scripts/System/QuestSystem.gd @@ -0,0 +1,7 @@ +class_name QuestSystem extends Node + +var QUEST_EXAMPLE = preload("res://scripts/Quest/QuestExample.gd").new(); + +var ALL_QUESTS = [ + QUEST_EXAMPLE +] diff --git a/scripts/System/Systems.gd b/scripts/System/Systems.gd new file mode 100644 index 0000000..bae8d47 --- /dev/null +++ b/scripts/System/Systems.gd @@ -0,0 +1,17 @@ +class_name Systems extends Node +const ItemSystem = preload("res://scripts/System/ItemSystem.gd"); +const CutsceneSystem = preload("res://scripts/System/CutsceneSystem.gd"); +const QuestSystem = preload("res://scripts/System/QuestSystem.gd"); + +var ITEM:ItemSystem; +var CUTSCENE:CutsceneSystem; +var QUEST:QuestSystem; + +func _ready(): + ITEM = $Item; + CUTSCENE = $Cutscene; + QUEST = $Quest; + pass + +func _process(delta): + pass diff --git a/scripts/Systems/Systems.gd b/scripts/Systems/Systems.gd deleted file mode 100644 index 1fb1a33..0000000 --- a/scripts/Systems/Systems.gd +++ /dev/null @@ -1,14 +0,0 @@ -class_name Systems extends Node -const ItemSystem = preload("res://scripts/Systems/ItemSystem.gd"); -const CutsceneSystem = preload("res://scripts/Systems/CutsceneSystem.gd") - -var ITEM:ItemSystem; -var CUTSCENE:CutsceneSystem; - -func _ready(): - ITEM = $Item; - CUTSCENE = $Cutscene; - pass - -func _process(delta): - pass