diff --git a/Systems/Combat/Actions/Scripts/action.gd b/Systems/Combat/Actions/Scripts/action.gd new file mode 100644 index 0000000..6cd9531 --- /dev/null +++ b/Systems/Combat/Actions/Scripts/action.gd @@ -0,0 +1,15 @@ +extends Node +class_name Action + + +@export var ActionName = "NONE" +@export var ActionText = "" + +var ActionIndex = 0 + +func _ready(): + if ActionName == "NONE": + push_warning("Actions has NONE name") + +func execute(): + push_warning("Base Action execute method called") diff --git a/Systems/Combat/Actions/action.tscn b/Systems/Combat/Actions/action.tscn new file mode 100644 index 0000000..ede0af2 --- /dev/null +++ b/Systems/Combat/Actions/action.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://djn8b685adlak"] + +[ext_resource type="Script" path="res://Systems/Combat/Actions/Scripts/action.gd" id="1_sqc33"] + +[node name="action" type="Node"] +script = ExtResource("1_sqc33") diff --git a/Systems/Combat/Combatant.tscn b/Systems/Combat/Combatant.tscn index 3f16b77..6ec041b 100644 --- a/Systems/Combat/Combatant.tscn +++ b/Systems/Combat/Combatant.tscn @@ -1,3 +1,6 @@ -[gd_scene format=3 uid="uid://ch1sc85jxy1r7"] +[gd_scene load_steps=2 format=3 uid="uid://ch1sc85jxy1r7"] + +[ext_resource type="Script" path="res://Systems/Combat/Scripts/Combatant.gd" id="1_4hh5d"] [node name="Combatant" type="Node"] +script = ExtResource("1_4hh5d") diff --git a/Systems/Combat/Scripts/Combatant.gd b/Systems/Combat/Scripts/Combatant.gd new file mode 100644 index 0000000..8d7ab87 --- /dev/null +++ b/Systems/Combat/Scripts/Combatant.gd @@ -0,0 +1,35 @@ +extends Node +class_name Combatant + +# @export var Behavior: + +@export var Menu: BattleMenu +@export var Stats: CombatStats + +var is_init = false +var Actions: Array + +func _ready(): + var idx = 0 + for node in get_children(): + if node.name == "Actions": + for action in node.get_children(): + action.ActionIndex = idx + Menu.add_action(action) + Actions.append(action) + idx += 1 + + +func execute_action(index: int): + Actions[index].execute() + +#func _process(delta): +# if not is_init: +# init() +# +#func init(): +# for action in Actions: +# print("Action: %s" % action.ActionName) +# Menu.add_action(action) +# +# is_init = true diff --git a/Systems/Combat/Scripts/combat_stats.gd b/Systems/Combat/Scripts/combat_stats.gd new file mode 100644 index 0000000..68d09c3 --- /dev/null +++ b/Systems/Combat/Scripts/combat_stats.gd @@ -0,0 +1,38 @@ +extends Resource +class_name CombatStats + +# Health +@export var MaxHP = 10 +var HP = MaxHP + +# Needed to use physical techniques +@export var MaxPhysicalStamina = 10 +var PhysicalStamina = MaxPhysicalStamina + +# Needed to use magic +@export var MaxMentalStamina = 10 +var MentalStamina = MaxMentalStamina + +# Physical Attack Power +@export var Strength = 1 + +# Magic Offense +@export var Wisdom = 1 + +# Physical Defense +@export var Constitution = 1 + +# Magic Defense +@export var Willpower = 1 + +# Battle turn order or ATB time +@export var Speed = 1 + +# Critical hit chance +@export var Focus = 1 + +# Chance to hit +@export var Accuracy = 1 + +# Chance to dodge +@export var Agility = 1 diff --git a/Systems/UI/Scripts/battle_menu.gd b/Systems/UI/Scripts/battle_menu.gd new file mode 100644 index 0000000..de1ae0a --- /dev/null +++ b/Systems/UI/Scripts/battle_menu.gd @@ -0,0 +1,7 @@ +extends Control +class_name BattleMenu + +@onready var text = $Text + +func add_action(action: Action): + text.text += "\n%d) %s" % [action.ActionIndex + 1, action.ActionName] diff --git a/Systems/UI/battle_menu.tscn b/Systems/UI/battle_menu.tscn new file mode 100644 index 0000000..ab7fc09 --- /dev/null +++ b/Systems/UI/battle_menu.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=2 format=3 uid="uid://cl5d768roh8ir"] + +[ext_resource type="Script" path="res://Systems/UI/Scripts/battle_menu.gd" id="1_ng8au"] + +[node name="battle_menu" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_ng8au") + +[node name="Text" type="Label" parent="."] +layout_mode = 0 +offset_right = 299.0 +offset_bottom = 142.0 +text = "Battle Menu:" diff --git a/Test Scenes/Test Player Actions/Scripts/attack.gd b/Test Scenes/Test Player Actions/Scripts/attack.gd new file mode 100644 index 0000000..e89504f --- /dev/null +++ b/Test Scenes/Test Player Actions/Scripts/attack.gd @@ -0,0 +1,6 @@ +extends Action + + + +func execute(): + print("Test Player Attacking!") diff --git a/Test Scenes/Test Player Actions/Scripts/spin_attack.gd b/Test Scenes/Test Player Actions/Scripts/spin_attack.gd new file mode 100644 index 0000000..2c086ff --- /dev/null +++ b/Test Scenes/Test Player Actions/Scripts/spin_attack.gd @@ -0,0 +1,4 @@ +extends Action + +func execute(): + print("Test Player uses Spin Attack!") diff --git a/Test Scenes/Test Player Actions/attack.tscn b/Test Scenes/Test Player Actions/attack.tscn new file mode 100644 index 0000000..21dcd1a --- /dev/null +++ b/Test Scenes/Test Player Actions/attack.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bbbyup8pp6uam"] + +[ext_resource type="Script" path="res://Test Scenes/Test Player Actions/Scripts/attack.gd" id="1_nmi0m"] + +[node name="attack" type="Node"] +script = ExtResource("1_nmi0m") diff --git a/Test Scenes/Test Player Actions/spin_attack.tscn b/Test Scenes/Test Player Actions/spin_attack.tscn new file mode 100644 index 0000000..ee1a7de --- /dev/null +++ b/Test Scenes/Test Player Actions/spin_attack.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bmot4y61f1r8f"] + +[ext_resource type="Script" path="res://Test Scenes/Test Player Actions/Scripts/spin_attack.gd" id="1_ywj48"] + +[node name="spin_attack" type="Node"] +script = ExtResource("1_ywj48") diff --git a/Test Scenes/sandbox.tscn b/Test Scenes/sandbox.tscn index 0c20161..3762d41 100644 --- a/Test Scenes/sandbox.tscn +++ b/Test Scenes/sandbox.tscn @@ -1,3 +1,7 @@ -[gd_scene format=3 uid="uid://dnmtnb7kvhmkp"] +[gd_scene load_steps=2 format=3 uid="uid://dnmtnb7kvhmkp"] + +[ext_resource type="PackedScene" uid="uid://cnnvxd4gefp4o" path="res://Test Scenes/test_player.tscn" id="1_ff72w"] [node name="Sandbox" type="Node2D"] + +[node name="test_player" parent="." instance=ExtResource("1_ff72w")] diff --git a/Test Scenes/test_player.gd b/Test Scenes/test_player.gd new file mode 100644 index 0000000..bd0d1c7 --- /dev/null +++ b/Test Scenes/test_player.gd @@ -0,0 +1,16 @@ +extends Node2D + +@onready var Combat = $Combatant + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if Input.is_key_pressed(KEY_1): + Combat.execute_action(0) + + if Input.is_key_pressed(KEY_2): + Combat.execute_action(1) diff --git a/Test Scenes/test_player.tscn b/Test Scenes/test_player.tscn new file mode 100644 index 0000000..afa7f9a --- /dev/null +++ b/Test Scenes/test_player.tscn @@ -0,0 +1,40 @@ +[gd_scene load_steps=8 format=3 uid="uid://cnnvxd4gefp4o"] + +[ext_resource type="PackedScene" uid="uid://ch1sc85jxy1r7" path="res://Systems/Combat/Combatant.tscn" id="1_701ur"] +[ext_resource type="Script" path="res://Test Scenes/test_player.gd" id="1_fstsi"] +[ext_resource type="Script" path="res://Systems/Combat/Scripts/combat_stats.gd" id="3_axh6y"] +[ext_resource type="PackedScene" uid="uid://bbbyup8pp6uam" path="res://Test Scenes/Test Player Actions/attack.tscn" id="3_ywlre"] +[ext_resource type="PackedScene" uid="uid://bmot4y61f1r8f" path="res://Test Scenes/Test Player Actions/spin_attack.tscn" id="4_sr4bi"] +[ext_resource type="PackedScene" uid="uid://cl5d768roh8ir" path="res://Systems/UI/battle_menu.tscn" id="5_2vin1"] + +[sub_resource type="Resource" id="Resource_l1ix6"] +script = ExtResource("3_axh6y") +MaxHP = 10 +MaxPhysicalStamina = 10 +MaxMentalStamina = 10 +Strength = 1 +Wisdom = 1 +Constitution = 1 +Willpower = 1 +Speed = 1 +Focus = 1 +Accuracy = 1 +Agility = 1 + +[node name="test_player" type="Node2D"] +script = ExtResource("1_fstsi") + +[node name="battle_menu" parent="." instance=ExtResource("5_2vin1")] + +[node name="Combatant" parent="." node_paths=PackedStringArray("Menu") instance=ExtResource("1_701ur")] +Menu = NodePath("../battle_menu") +Stats = SubResource("Resource_l1ix6") + +[node name="Actions" type="Node" parent="Combatant"] + +[node name="attack" parent="Combatant/Actions" instance=ExtResource("3_ywlre")] +ActionName = "Attack" +ActionText = "Attack" + +[node name="spin_attack" parent="Combatant/Actions" instance=ExtResource("4_sr4bi")] +ActionName = "Spin Attack" diff --git a/project.godot b/project.godot index 25e932e..28b6ef6 100644 --- a/project.godot +++ b/project.godot @@ -11,5 +11,6 @@ config_version=5 [application] config/name="RPG Prototype" +run/main_scene="res://Test Scenes/sandbox.tscn" config/features=PackedStringArray("4.0", "Forward Plus") config/icon="res://icon.svg"