Base Combatant system started

combat_refactor
Joey Pollack 2 years ago
parent 26d93abbb9
commit 475e61ff89

@ -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")

@ -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")

@ -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")

@ -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

@ -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

@ -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]

@ -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:"

@ -0,0 +1,6 @@
extends Action
func execute():
print("Test Player Attacking!")

@ -0,0 +1,4 @@
extends Action
func execute():
print("Test Player uses Spin Attack!")

@ -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")

@ -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")

@ -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")]

@ -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)

@ -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"

@ -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"

Loading…
Cancel
Save