From 5c88f4ed48ca6ac447f1ad86e2ed5af85cf9fbe1 Mon Sep 17 00:00:00 2001 From: Strieglitz Date: Mon, 17 Feb 2025 23:40:58 +0100 Subject: [PATCH 1/4] wip Components/Customizable --- project.godot | 8 ++--- resources/Character.tres | 8 +++++ resources/Hp.tres | 7 ++++ resources/PlayerStats.tres | 36 +++++++++++++++++++ scripts/resources/Character/Character.gd | 5 +++ scripts/resources/Character/CharacterStats.gd | 9 +++++ .../resources/Character/PlayerCharacter.gd | 3 ++ scripts/resources/Effects/Effect.gd | 6 ++++ scripts/resources/Effects/RefillHpEffect.gd | 4 +++ scripts/resources/Equipment/EquipmentStats.gd | 9 +++++ scripts/resources/Equipment/MechParts/Arms.gd | 3 ++ .../resources/Equipment/MechParts/Boots.gd | 3 ++ .../Equipment/MechParts/Hydraulics.gd | 3 ++ .../resources/Equipment/MechParts/MechBase.gd | 7 ++++ .../resources/Equipment/MechParts/MechPart.gd | 6 ++++ scripts/resources/Stats/Armor.gd | 13 +++++++ scripts/resources/Stats/Damage.gd | 13 +++++++ scripts/resources/Stats/Health.gd | 13 +++++++ scripts/resources/Stats/MaxHealth.gd | 13 +++++++ scripts/resources/Stats/MovementSpeed.gd | 13 +++++++ scripts/resources/Stats/Shield.gd | 13 +++++++ scripts/resources/Weapons/Weapon.gd | 5 +++ scripts/resources/Weapons/WeaponStats.gd | 6 ++++ 23 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 resources/Character.tres create mode 100644 resources/Hp.tres create mode 100644 resources/PlayerStats.tres create mode 100644 scripts/resources/Character/Character.gd create mode 100644 scripts/resources/Character/CharacterStats.gd create mode 100644 scripts/resources/Character/PlayerCharacter.gd create mode 100644 scripts/resources/Effects/Effect.gd create mode 100644 scripts/resources/Effects/RefillHpEffect.gd create mode 100644 scripts/resources/Equipment/EquipmentStats.gd create mode 100644 scripts/resources/Equipment/MechParts/Arms.gd create mode 100644 scripts/resources/Equipment/MechParts/Boots.gd create mode 100644 scripts/resources/Equipment/MechParts/Hydraulics.gd create mode 100644 scripts/resources/Equipment/MechParts/MechBase.gd create mode 100644 scripts/resources/Equipment/MechParts/MechPart.gd create mode 100644 scripts/resources/Stats/Armor.gd create mode 100644 scripts/resources/Stats/Damage.gd create mode 100644 scripts/resources/Stats/Health.gd create mode 100644 scripts/resources/Stats/MaxHealth.gd create mode 100644 scripts/resources/Stats/MovementSpeed.gd create mode 100644 scripts/resources/Stats/Shield.gd create mode 100644 scripts/resources/Weapons/Weapon.gd create mode 100644 scripts/resources/Weapons/WeaponStats.gd diff --git a/project.godot b/project.godot index 277e044..912855b 100644 --- a/project.godot +++ b/project.godot @@ -42,10 +42,6 @@ enabled=PackedStringArray("res://addons/godot_resource_groups/plugin.cfg", "res: auto_rebuild=true -[physics] - -3d/physics_engine="JoltPhysics3D" - [input] strafe_left={ @@ -78,3 +74,7 @@ turn_right={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } + +[physics] + +3d/physics_engine="JoltPhysics3D" diff --git a/resources/Character.tres b/resources/Character.tres new file mode 100644 index 0000000..996c44d --- /dev/null +++ b/resources/Character.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" script_class="Character" load_steps=3 format=3 uid="uid://bd1ugbnlm08vv"] + +[ext_resource type="Script" path="res://scripts/resources/Character/Character.gd" id="1_8yb2m"] +[ext_resource type="Resource" uid="uid://qcjre5wwbrs3" path="res://resources/PlayerStats.tres" id="2_rc7x1"] + +[resource] +script = ExtResource("1_8yb2m") +stats = ExtResource("2_rc7x1") diff --git a/resources/Hp.tres b/resources/Hp.tres new file mode 100644 index 0000000..9fd8d8a --- /dev/null +++ b/resources/Hp.tres @@ -0,0 +1,7 @@ +[gd_resource type="Resource" script_class="Health" load_steps=2 format=3 uid="uid://c3gf5mi1u151m"] + +[ext_resource type="Script" path="res://scripts/resources/Stats/Health.gd" id="1_yqlcl"] + +[resource] +script = ExtResource("1_yqlcl") +_value = 0 diff --git a/resources/PlayerStats.tres b/resources/PlayerStats.tres new file mode 100644 index 0000000..7f28fbb --- /dev/null +++ b/resources/PlayerStats.tres @@ -0,0 +1,36 @@ +[gd_resource type="Resource" script_class="CharacterStats" load_steps=12 format=3 uid="uid://qcjre5wwbrs3"] + +[ext_resource type="Script" path="res://scripts/resources/Stats/Armor.gd" id="1_c7135"] +[ext_resource type="Script" path="res://scripts/resources/Character/CharacterStats.gd" id="1_xti0a"] +[ext_resource type="Script" path="res://scripts/resources/Stats/Health.gd" id="2_hsnpy"] +[ext_resource type="Script" path="res://scripts/resources/Stats/MaxHealth.gd" id="3_26tso"] +[ext_resource type="Script" path="res://scripts/resources/Stats/MovementSpeed.gd" id="4_goc2a"] +[ext_resource type="Script" path="res://scripts/resources/Stats/Shield.gd" id="6_rncik"] + +[sub_resource type="Resource" id="Resource_vbm44"] +script = ExtResource("1_c7135") +_value = 0 + +[sub_resource type="Resource" id="Resource_nyvlf"] +script = ExtResource("2_hsnpy") +_value = 0 + +[sub_resource type="Resource" id="Resource_pxuuc"] +script = ExtResource("3_26tso") +_value = 10 + +[sub_resource type="Resource" id="Resource_vs6ff"] +script = ExtResource("4_goc2a") +_value = 0 + +[sub_resource type="Resource" id="Resource_r5hb1"] +script = ExtResource("6_rncik") +_value = 0 + +[resource] +script = ExtResource("1_xti0a") +max_health = SubResource("Resource_pxuuc") +health = SubResource("Resource_nyvlf") +armor = SubResource("Resource_vbm44") +shield = SubResource("Resource_r5hb1") +movementSpeed = SubResource("Resource_vs6ff") diff --git a/scripts/resources/Character/Character.gd b/scripts/resources/Character/Character.gd new file mode 100644 index 0000000..7958f66 --- /dev/null +++ b/scripts/resources/Character/Character.gd @@ -0,0 +1,5 @@ +extends Resource + +class_name Character + +@export var stats: CharacterStats diff --git a/scripts/resources/Character/CharacterStats.gd b/scripts/resources/Character/CharacterStats.gd new file mode 100644 index 0000000..daa221a --- /dev/null +++ b/scripts/resources/Character/CharacterStats.gd @@ -0,0 +1,9 @@ +extends Resource + +class_name CharacterStats + +@export var max_health: MaxHealth +@export var health: Health +@export var armor: Armor +@export var shield: Shield +@export var movementSpeed: MovementSpeed diff --git a/scripts/resources/Character/PlayerCharacter.gd b/scripts/resources/Character/PlayerCharacter.gd new file mode 100644 index 0000000..c4b42fb --- /dev/null +++ b/scripts/resources/Character/PlayerCharacter.gd @@ -0,0 +1,3 @@ +extends Character + +@export var mech: MechBase diff --git a/scripts/resources/Effects/Effect.gd b/scripts/resources/Effects/Effect.gd new file mode 100644 index 0000000..6864411 --- /dev/null +++ b/scripts/resources/Effects/Effect.gd @@ -0,0 +1,6 @@ +extends Resource + +class_name Effect + +func apply_effect (character: Character)-> void: + assert(false) diff --git a/scripts/resources/Effects/RefillHpEffect.gd b/scripts/resources/Effects/RefillHpEffect.gd new file mode 100644 index 0000000..91eb748 --- /dev/null +++ b/scripts/resources/Effects/RefillHpEffect.gd @@ -0,0 +1,4 @@ +extends Effect + +func apply_effect (character: Character)-> void: + character.stats.health.value = character.stats.max_health.value diff --git a/scripts/resources/Equipment/EquipmentStats.gd b/scripts/resources/Equipment/EquipmentStats.gd new file mode 100644 index 0000000..a65b670 --- /dev/null +++ b/scripts/resources/Equipment/EquipmentStats.gd @@ -0,0 +1,9 @@ +extends Resource + +class_name EquipmentStats + +@export var max_health: MaxHealth +@export var armor: Armor +@export var shield: Shield +@export var movementSpeed: MovementSpeed +@export var damage: Damage diff --git a/scripts/resources/Equipment/MechParts/Arms.gd b/scripts/resources/Equipment/MechParts/Arms.gd new file mode 100644 index 0000000..b3c4785 --- /dev/null +++ b/scripts/resources/Equipment/MechParts/Arms.gd @@ -0,0 +1,3 @@ +extends MechPart + +class_name Arms diff --git a/scripts/resources/Equipment/MechParts/Boots.gd b/scripts/resources/Equipment/MechParts/Boots.gd new file mode 100644 index 0000000..0a853a1 --- /dev/null +++ b/scripts/resources/Equipment/MechParts/Boots.gd @@ -0,0 +1,3 @@ +extends MechPart + +class_name Boots diff --git a/scripts/resources/Equipment/MechParts/Hydraulics.gd b/scripts/resources/Equipment/MechParts/Hydraulics.gd new file mode 100644 index 0000000..2d5fc9b --- /dev/null +++ b/scripts/resources/Equipment/MechParts/Hydraulics.gd @@ -0,0 +1,3 @@ +extends MechPart + +class_name Hydraulics diff --git a/scripts/resources/Equipment/MechParts/MechBase.gd b/scripts/resources/Equipment/MechParts/MechBase.gd new file mode 100644 index 0000000..e06010b --- /dev/null +++ b/scripts/resources/Equipment/MechParts/MechBase.gd @@ -0,0 +1,7 @@ +extends MechPart + +class_name MechBase + +@export var boots: Boots +@export var arms: Arms +@export var hydraulics: Hydraulics diff --git a/scripts/resources/Equipment/MechParts/MechPart.gd b/scripts/resources/Equipment/MechParts/MechPart.gd new file mode 100644 index 0000000..d033baa --- /dev/null +++ b/scripts/resources/Equipment/MechParts/MechPart.gd @@ -0,0 +1,6 @@ +extends Resource + +class_name MechPart + +@export var name: String +@export var stats: EquipmentStats diff --git a/scripts/resources/Stats/Armor.gd b/scripts/resources/Stats/Armor.gd new file mode 100644 index 0000000..13ee0d2 --- /dev/null +++ b/scripts/resources/Stats/Armor.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name Armor + +signal value_changed_signal(currentArmor: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/Damage.gd b/scripts/resources/Stats/Damage.gd new file mode 100644 index 0000000..f4fcf10 --- /dev/null +++ b/scripts/resources/Stats/Damage.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name Damage + +signal value_changed_signal(currentDamage: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/Health.gd b/scripts/resources/Stats/Health.gd new file mode 100644 index 0000000..4802849 --- /dev/null +++ b/scripts/resources/Stats/Health.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name Health + +signal value_changed_signal(currentHealth: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/MaxHealth.gd b/scripts/resources/Stats/MaxHealth.gd new file mode 100644 index 0000000..4c487c9 --- /dev/null +++ b/scripts/resources/Stats/MaxHealth.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name MaxHealth + +signal value_changed_signal(currentMaxHealth: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/MovementSpeed.gd b/scripts/resources/Stats/MovementSpeed.gd new file mode 100644 index 0000000..34bedfa --- /dev/null +++ b/scripts/resources/Stats/MovementSpeed.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name MovementSpeed + +signal value_changed_signal(currentMovementSpeed: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/Shield.gd b/scripts/resources/Stats/Shield.gd new file mode 100644 index 0000000..00a0feb --- /dev/null +++ b/scripts/resources/Stats/Shield.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name Shield + +signal value_changed_signal(currentShield: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Weapons/Weapon.gd b/scripts/resources/Weapons/Weapon.gd new file mode 100644 index 0000000..bf9a463 --- /dev/null +++ b/scripts/resources/Weapons/Weapon.gd @@ -0,0 +1,5 @@ +extends Resource + +class_name Weapon + +@export var name: String diff --git a/scripts/resources/Weapons/WeaponStats.gd b/scripts/resources/Weapons/WeaponStats.gd new file mode 100644 index 0000000..cea8e0b --- /dev/null +++ b/scripts/resources/Weapons/WeaponStats.gd @@ -0,0 +1,6 @@ +extends Resource + +class_name WeaponStats + + +@export var damage: Damage -- 2.45.2 From a1b0e6b5e7508b0efc487d989b8b484c260f4ffa Mon Sep 17 00:00:00 2001 From: Strieglitz Date: Tue, 18 Feb 2025 23:38:21 +0100 Subject: [PATCH 2/4] Added SceneNode Loading --- resources/Character.tres | 2 +- scenes/debug_level.tscn | 9 +++++++++ scripts/Attachment.gd | 7 +++++++ scripts/Character.gd | 11 +++++++++++ scripts/Equipment.gd | 7 +++++++ scripts/PlayerCharacter.gd | 1 + scripts/Weapon.gd | 11 +++++++++++ scripts/resources/Character/Character.gd | 5 ----- .../resources/Character/CharacterResource.gd | 13 +++++++++++++ .../Character/Equipment/EquipmentResource.gd | 17 +++++++++++++++++ .../{ => Character}/Equipment/EquipmentStats.gd | 3 +++ .../Character/Equipment/MechParts/Arms.gd | 3 +++ .../Character/Equipment/MechParts/Boots.gd | 3 +++ .../Character/Equipment/MechParts/Hydraulics.gd | 3 +++ .../Character/Equipment/MechParts/MechBase.gd | 10 ++++++++++ .../Equipment/MechParts/MechPartResource.gd | 3 +++ scripts/resources/Character/PlayerCharacter.gd | 3 --- scripts/resources/Equipment/MechParts/Arms.gd | 3 --- scripts/resources/Equipment/MechParts/Boots.gd | 3 --- .../resources/Equipment/MechParts/Hydraulics.gd | 3 --- .../resources/Equipment/MechParts/MechBase.gd | 7 ------- .../resources/Equipment/MechParts/MechPart.gd | 6 ------ scripts/resources/Stats/FireRate.gd | 13 +++++++++++++ .../Weapons/Attachments/AttachmentResource.gd | 13 +++++++++++++ .../Weapons/Attachments/AttachmentStats.gd | 6 ++++++ scripts/resources/Weapons/Weapon.gd | 5 ----- scripts/resources/Weapons/WeaponResource.gd | 13 +++++++++++++ scripts/resources/Weapons/WeaponStats.gd | 1 + 28 files changed, 148 insertions(+), 36 deletions(-) create mode 100644 scripts/Attachment.gd create mode 100644 scripts/Character.gd create mode 100644 scripts/Equipment.gd create mode 100644 scripts/PlayerCharacter.gd create mode 100644 scripts/Weapon.gd delete mode 100644 scripts/resources/Character/Character.gd create mode 100644 scripts/resources/Character/CharacterResource.gd create mode 100644 scripts/resources/Character/Equipment/EquipmentResource.gd rename scripts/resources/{ => Character}/Equipment/EquipmentStats.gd (74%) create mode 100644 scripts/resources/Character/Equipment/MechParts/Arms.gd create mode 100644 scripts/resources/Character/Equipment/MechParts/Boots.gd create mode 100644 scripts/resources/Character/Equipment/MechParts/Hydraulics.gd create mode 100644 scripts/resources/Character/Equipment/MechParts/MechBase.gd create mode 100644 scripts/resources/Character/Equipment/MechParts/MechPartResource.gd delete mode 100644 scripts/resources/Character/PlayerCharacter.gd delete mode 100644 scripts/resources/Equipment/MechParts/Arms.gd delete mode 100644 scripts/resources/Equipment/MechParts/Boots.gd delete mode 100644 scripts/resources/Equipment/MechParts/Hydraulics.gd delete mode 100644 scripts/resources/Equipment/MechParts/MechBase.gd delete mode 100644 scripts/resources/Equipment/MechParts/MechPart.gd create mode 100644 scripts/resources/Stats/FireRate.gd create mode 100644 scripts/resources/Weapons/Attachments/AttachmentResource.gd create mode 100644 scripts/resources/Weapons/Attachments/AttachmentStats.gd delete mode 100644 scripts/resources/Weapons/Weapon.gd create mode 100644 scripts/resources/Weapons/WeaponResource.gd diff --git a/resources/Character.tres b/resources/Character.tres index 996c44d..8f71bcb 100644 --- a/resources/Character.tres +++ b/resources/Character.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="Character" load_steps=3 format=3 uid="uid://bd1ugbnlm08vv"] -[ext_resource type="Script" path="res://scripts/resources/Character/Character.gd" id="1_8yb2m"] +[ext_resource type="Script" path="res://scripts/resources/Character/CharacterResource.gd" id="1_8yb2m"] [ext_resource type="Resource" uid="uid://qcjre5wwbrs3" path="res://resources/PlayerStats.tres" id="2_rc7x1"] [resource] diff --git a/scenes/debug_level.tscn b/scenes/debug_level.tscn index ce0fe3b..c216810 100644 --- a/scenes/debug_level.tscn +++ b/scenes/debug_level.tscn @@ -9,5 +9,14 @@ shadow_enabled = true [node name="CSGBox3D" type="CSGBox3D" parent="."] transform = Transform3D(0.804543, 0.301369, -0.511748, -0.471444, 0.848123, -0.241718, 0.361179, 0.435734, 0.824431, 0, 0, 0) +[node name="CSGBox3D" type="CSGBox3D" parent="CSGBox3D"] +transform = Transform3D(0.804543, 0.301369, -0.511748, -0.471444, 0.848123, -0.241718, 0.361179, 0.435734, 0.824431, 0, 0, 0) + +[node name="CSGBox3D" type="CSGBox3D" parent="CSGBox3D/CSGBox3D"] +transform = Transform3D(0.804543, 0.301369, -0.511748, -0.471444, 0.848123, -0.241718, 0.361179, 0.435734, 0.824431, 0, 0, 0) + +[node name="CSGBox3D" type="CSGBox3D" parent="CSGBox3D/CSGBox3D/CSGBox3D"] +transform = Transform3D(0.804543, 0.301369, -0.511748, -0.471444, 0.848123, -0.241718, 0.361179, 0.435734, 0.824431, 0, 0, 0) + [node name="Camera3D" type="Camera3D" parent="."] transform = Transform3D(1, 0, 0, 0, 0.901077, 0.433659, 0, -0.433659, 0.901077, 0, 1.21776, 2.12747) diff --git a/scripts/Attachment.gd b/scripts/Attachment.gd new file mode 100644 index 0000000..8fa0057 --- /dev/null +++ b/scripts/Attachment.gd @@ -0,0 +1,7 @@ +class_name Attachment extends Node3D + + +var stats: AttachmentStats + +func init_attachment(stats: AttachmentStats): + self.stats = stats; diff --git a/scripts/Character.gd b/scripts/Character.gd new file mode 100644 index 0000000..c5faaa3 --- /dev/null +++ b/scripts/Character.gd @@ -0,0 +1,11 @@ +class_name Character extends Node3D + + +var stats: CharacterStats +var equipments: Array[Equipment] + +func init_character(stats: CharacterStats): + self.stats = stats; + +func equip(newEquipment: Equipment)-> void: + equipments.append(newEquipment) diff --git a/scripts/Equipment.gd b/scripts/Equipment.gd new file mode 100644 index 0000000..6d5bdfd --- /dev/null +++ b/scripts/Equipment.gd @@ -0,0 +1,7 @@ +class_name Equipment extends Node3D + + +var stats: EquipmentStats + +func init_equipment(stats: EquipmentStats): + self.stats = stats; diff --git a/scripts/PlayerCharacter.gd b/scripts/PlayerCharacter.gd new file mode 100644 index 0000000..eb022be --- /dev/null +++ b/scripts/PlayerCharacter.gd @@ -0,0 +1 @@ +class_name PlayerCharacter extends Character diff --git a/scripts/Weapon.gd b/scripts/Weapon.gd new file mode 100644 index 0000000..aaa86a2 --- /dev/null +++ b/scripts/Weapon.gd @@ -0,0 +1,11 @@ +class_name Weapon extends Node3D + +var stats: WeaponStats +var attachments: Array[Attachment] + +func init_weapon(stats: WeaponStats): + self.stats = stats; + + +func attach(newAttachment: Attachment)-> void: + attachments.append(newAttachment) diff --git a/scripts/resources/Character/Character.gd b/scripts/resources/Character/Character.gd deleted file mode 100644 index 7958f66..0000000 --- a/scripts/resources/Character/Character.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Resource - -class_name Character - -@export var stats: CharacterStats diff --git a/scripts/resources/Character/CharacterResource.gd b/scripts/resources/Character/CharacterResource.gd new file mode 100644 index 0000000..f08fe42 --- /dev/null +++ b/scripts/resources/Character/CharacterResource.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name CharacterResource + +@export var character_stats: CharacterStats +@export var character_scene: PackedScene + + +func instantiate(parent: Node3D)->Character: + var character_instance = character_scene.instantiate() as Character + character_instance.init_character(character_stats) + parent.add_child(character_instance) + return character_instance diff --git a/scripts/resources/Character/Equipment/EquipmentResource.gd b/scripts/resources/Character/Equipment/EquipmentResource.gd new file mode 100644 index 0000000..1923a18 --- /dev/null +++ b/scripts/resources/Character/Equipment/EquipmentResource.gd @@ -0,0 +1,17 @@ +extends Resource + +class_name EquipmentResource + +@export var name: String +@export var equipment_stats: EquipmentStats +@export var equipment_scene: PackedScene + + +func instantiate(parent: Node3D)->Equipment: + var equipment_instance = equipment_scene.instantiate() as Equipment + equipment_instance.init_Equipment(equipment_stats) + parent.add_child(equipment_instance) + return equipment_instance + +func get_stats()-> EquipmentStats: + return equipment_stats diff --git a/scripts/resources/Equipment/EquipmentStats.gd b/scripts/resources/Character/Equipment/EquipmentStats.gd similarity index 74% rename from scripts/resources/Equipment/EquipmentStats.gd rename to scripts/resources/Character/Equipment/EquipmentStats.gd index a65b670..8df73eb 100644 --- a/scripts/resources/Equipment/EquipmentStats.gd +++ b/scripts/resources/Character/Equipment/EquipmentStats.gd @@ -7,3 +7,6 @@ class_name EquipmentStats @export var shield: Shield @export var movementSpeed: MovementSpeed @export var damage: Damage + +func combine (other: EquipmentStats)->EquipmentStats: + return null diff --git a/scripts/resources/Character/Equipment/MechParts/Arms.gd b/scripts/resources/Character/Equipment/MechParts/Arms.gd new file mode 100644 index 0000000..1010283 --- /dev/null +++ b/scripts/resources/Character/Equipment/MechParts/Arms.gd @@ -0,0 +1,3 @@ +extends MechPartResource + +class_name Arms diff --git a/scripts/resources/Character/Equipment/MechParts/Boots.gd b/scripts/resources/Character/Equipment/MechParts/Boots.gd new file mode 100644 index 0000000..1c0b007 --- /dev/null +++ b/scripts/resources/Character/Equipment/MechParts/Boots.gd @@ -0,0 +1,3 @@ +extends MechPartResource + +class_name Boots diff --git a/scripts/resources/Character/Equipment/MechParts/Hydraulics.gd b/scripts/resources/Character/Equipment/MechParts/Hydraulics.gd new file mode 100644 index 0000000..a29158c --- /dev/null +++ b/scripts/resources/Character/Equipment/MechParts/Hydraulics.gd @@ -0,0 +1,3 @@ +extends MechPartResource + +class_name Hydraulics diff --git a/scripts/resources/Character/Equipment/MechParts/MechBase.gd b/scripts/resources/Character/Equipment/MechParts/MechBase.gd new file mode 100644 index 0000000..ec7479f --- /dev/null +++ b/scripts/resources/Character/Equipment/MechParts/MechBase.gd @@ -0,0 +1,10 @@ +extends MechPartResource + +class_name MechBase + +@export var boots: Boots +@export var arms: Arms +@export var hydraulics: Hydraulics + +func get_stats()-> EquipmentStats: + return boots.equipment_stats.combine(arms.equipment_stats).combine(hydraulics.equipment_stats) diff --git a/scripts/resources/Character/Equipment/MechParts/MechPartResource.gd b/scripts/resources/Character/Equipment/MechParts/MechPartResource.gd new file mode 100644 index 0000000..032c584 --- /dev/null +++ b/scripts/resources/Character/Equipment/MechParts/MechPartResource.gd @@ -0,0 +1,3 @@ +extends EquipmentResource + +class_name MechPartResource diff --git a/scripts/resources/Character/PlayerCharacter.gd b/scripts/resources/Character/PlayerCharacter.gd deleted file mode 100644 index c4b42fb..0000000 --- a/scripts/resources/Character/PlayerCharacter.gd +++ /dev/null @@ -1,3 +0,0 @@ -extends Character - -@export var mech: MechBase diff --git a/scripts/resources/Equipment/MechParts/Arms.gd b/scripts/resources/Equipment/MechParts/Arms.gd deleted file mode 100644 index b3c4785..0000000 --- a/scripts/resources/Equipment/MechParts/Arms.gd +++ /dev/null @@ -1,3 +0,0 @@ -extends MechPart - -class_name Arms diff --git a/scripts/resources/Equipment/MechParts/Boots.gd b/scripts/resources/Equipment/MechParts/Boots.gd deleted file mode 100644 index 0a853a1..0000000 --- a/scripts/resources/Equipment/MechParts/Boots.gd +++ /dev/null @@ -1,3 +0,0 @@ -extends MechPart - -class_name Boots diff --git a/scripts/resources/Equipment/MechParts/Hydraulics.gd b/scripts/resources/Equipment/MechParts/Hydraulics.gd deleted file mode 100644 index 2d5fc9b..0000000 --- a/scripts/resources/Equipment/MechParts/Hydraulics.gd +++ /dev/null @@ -1,3 +0,0 @@ -extends MechPart - -class_name Hydraulics diff --git a/scripts/resources/Equipment/MechParts/MechBase.gd b/scripts/resources/Equipment/MechParts/MechBase.gd deleted file mode 100644 index e06010b..0000000 --- a/scripts/resources/Equipment/MechParts/MechBase.gd +++ /dev/null @@ -1,7 +0,0 @@ -extends MechPart - -class_name MechBase - -@export var boots: Boots -@export var arms: Arms -@export var hydraulics: Hydraulics diff --git a/scripts/resources/Equipment/MechParts/MechPart.gd b/scripts/resources/Equipment/MechParts/MechPart.gd deleted file mode 100644 index d033baa..0000000 --- a/scripts/resources/Equipment/MechParts/MechPart.gd +++ /dev/null @@ -1,6 +0,0 @@ -extends Resource - -class_name MechPart - -@export var name: String -@export var stats: EquipmentStats diff --git a/scripts/resources/Stats/FireRate.gd b/scripts/resources/Stats/FireRate.gd new file mode 100644 index 0000000..89ff0c3 --- /dev/null +++ b/scripts/resources/Stats/FireRate.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name FireRate + +signal value_changed_signal(currentFireRate: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Weapons/Attachments/AttachmentResource.gd b/scripts/resources/Weapons/Attachments/AttachmentResource.gd new file mode 100644 index 0000000..8d92b32 --- /dev/null +++ b/scripts/resources/Weapons/Attachments/AttachmentResource.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name AttachmentResource + +@export var attachment_stats: AttachmentStats +@export var attachment_scene: PackedScene + + +func instantiate(parent: Node3D)->Attachment: + var attachment_instance = attachment_scene.instantiate() as Attachment + attachment_instance.init_Attachment(attachment_stats) + parent.add_child(attachment_instance) + return attachment_instance diff --git a/scripts/resources/Weapons/Attachments/AttachmentStats.gd b/scripts/resources/Weapons/Attachments/AttachmentStats.gd new file mode 100644 index 0000000..f038a1e --- /dev/null +++ b/scripts/resources/Weapons/Attachments/AttachmentStats.gd @@ -0,0 +1,6 @@ +extends Resource + +class_name AttachmentStats + +@export var damage: Damage +@export var fire_rate: FireRate diff --git a/scripts/resources/Weapons/Weapon.gd b/scripts/resources/Weapons/Weapon.gd deleted file mode 100644 index bf9a463..0000000 --- a/scripts/resources/Weapons/Weapon.gd +++ /dev/null @@ -1,5 +0,0 @@ -extends Resource - -class_name Weapon - -@export var name: String diff --git a/scripts/resources/Weapons/WeaponResource.gd b/scripts/resources/Weapons/WeaponResource.gd new file mode 100644 index 0000000..699ca7c --- /dev/null +++ b/scripts/resources/Weapons/WeaponResource.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name WeaponResource + +@export var name: String +@export var weapon_stats: WeaponStats +@export var weapon_scene: PackedScene + +func instantiate(parent: Node3D)->Weapon: + var weapon_instance = weapon_scene.instantiate() as Weapon + weapon_instance.init_weapon(weapon_stats) + parent.add_child(weapon_instance) + return weapon_instance diff --git a/scripts/resources/Weapons/WeaponStats.gd b/scripts/resources/Weapons/WeaponStats.gd index cea8e0b..109409e 100644 --- a/scripts/resources/Weapons/WeaponStats.gd +++ b/scripts/resources/Weapons/WeaponStats.gd @@ -4,3 +4,4 @@ class_name WeaponStats @export var damage: Damage +@export var fire_rate: FireRate -- 2.45.2 From b90e0369bfc308b6a805d6139fe01f20955ec821 Mon Sep 17 00:00:00 2001 From: Strieglitz Date: Sun, 23 Feb 2025 22:21:44 +0100 Subject: [PATCH 3/4] damage handler wip --- resources/Character.tres | 2 +- resources/PlayerStats.tres | 2 +- scripts/Character.gd | 11 ----- scripts/Enemie.gd | 1 + scripts/Entity.gd | 44 +++++++++++++++++++ scripts/Mech.gd | 28 ++++++++++++ scripts/PlayerCharacter.gd | 33 +++++++++++++- scripts/Weapon.gd | 16 ++++++- .../resources/Character/CharacterResource.gd | 13 ------ .../Character/Equipment/MechParts/MechBase.gd | 10 ----- scripts/resources/Entity/EntityResource.gd | 13 ++++++ .../EntityStats.gd} | 2 +- .../Equipment/EquipmentResource.gd | 3 -- .../Equipment/EquipmentStats.gd | 3 -- .../Equipment/MechParts/Arms.gd | 0 .../Equipment/MechParts/Boots.gd | 0 .../Equipment/MechParts/Hydraulics.gd | 0 .../Equipment/MechParts/MechPartResource.gd | 0 singeltons/DamageHandler.gd | 9 ++++ 19 files changed, 145 insertions(+), 45 deletions(-) delete mode 100644 scripts/Character.gd create mode 100644 scripts/Enemie.gd create mode 100644 scripts/Entity.gd create mode 100644 scripts/Mech.gd delete mode 100644 scripts/resources/Character/CharacterResource.gd delete mode 100644 scripts/resources/Character/Equipment/MechParts/MechBase.gd create mode 100644 scripts/resources/Entity/EntityResource.gd rename scripts/resources/{Character/CharacterStats.gd => Entity/EntityStats.gd} (86%) rename scripts/resources/{Character => }/Equipment/EquipmentResource.gd (86%) rename scripts/resources/{Character => }/Equipment/EquipmentStats.gd (74%) rename scripts/resources/{Character => }/Equipment/MechParts/Arms.gd (100%) rename scripts/resources/{Character => }/Equipment/MechParts/Boots.gd (100%) rename scripts/resources/{Character => }/Equipment/MechParts/Hydraulics.gd (100%) rename scripts/resources/{Character => }/Equipment/MechParts/MechPartResource.gd (100%) create mode 100644 singeltons/DamageHandler.gd diff --git a/resources/Character.tres b/resources/Character.tres index 8f71bcb..8933959 100644 --- a/resources/Character.tres +++ b/resources/Character.tres @@ -1,6 +1,6 @@ [gd_resource type="Resource" script_class="Character" load_steps=3 format=3 uid="uid://bd1ugbnlm08vv"] -[ext_resource type="Script" path="res://scripts/resources/Character/CharacterResource.gd" id="1_8yb2m"] +[ext_resource type="Script" path="res://scripts/resources/Entity/EntityResource.gd" id="1_8yb2m"] [ext_resource type="Resource" uid="uid://qcjre5wwbrs3" path="res://resources/PlayerStats.tres" id="2_rc7x1"] [resource] diff --git a/resources/PlayerStats.tres b/resources/PlayerStats.tres index 7f28fbb..4f63a7f 100644 --- a/resources/PlayerStats.tres +++ b/resources/PlayerStats.tres @@ -1,7 +1,7 @@ [gd_resource type="Resource" script_class="CharacterStats" load_steps=12 format=3 uid="uid://qcjre5wwbrs3"] [ext_resource type="Script" path="res://scripts/resources/Stats/Armor.gd" id="1_c7135"] -[ext_resource type="Script" path="res://scripts/resources/Character/CharacterStats.gd" id="1_xti0a"] +[ext_resource type="Script" path="res://scripts/resources/Entity/EntityStats.gd" id="1_xti0a"] [ext_resource type="Script" path="res://scripts/resources/Stats/Health.gd" id="2_hsnpy"] [ext_resource type="Script" path="res://scripts/resources/Stats/MaxHealth.gd" id="3_26tso"] [ext_resource type="Script" path="res://scripts/resources/Stats/MovementSpeed.gd" id="4_goc2a"] diff --git a/scripts/Character.gd b/scripts/Character.gd deleted file mode 100644 index c5faaa3..0000000 --- a/scripts/Character.gd +++ /dev/null @@ -1,11 +0,0 @@ -class_name Character extends Node3D - - -var stats: CharacterStats -var equipments: Array[Equipment] - -func init_character(stats: CharacterStats): - self.stats = stats; - -func equip(newEquipment: Equipment)-> void: - equipments.append(newEquipment) diff --git a/scripts/Enemie.gd b/scripts/Enemie.gd new file mode 100644 index 0000000..cb1170c --- /dev/null +++ b/scripts/Enemie.gd @@ -0,0 +1 @@ +class_name Enemie extends Entity diff --git a/scripts/Entity.gd b/scripts/Entity.gd new file mode 100644 index 0000000..c38a410 --- /dev/null +++ b/scripts/Entity.gd @@ -0,0 +1,44 @@ +class_name Entity extends Node3D + + +var stats: EntityStats +var equipments: Array[Equipment] + +func init_entity(stats: EntityStats): + self.stats = stats; + +func equip(newEquipment: Equipment)-> void: + equipments.append(newEquipment) + +func unequip(equipmentToRemove: Equipment)-> void: + equipments.erase(equipmentToRemove) + +func get_max_health()->int: + var max_health = stats.max_health + for equipment in equipments: + max_health += equipment + + return max_health + +func get_health()->int: + return stats.health.value + +func get_armor()->int: + var armor = stats.armor + for equipment in equipments: + armor += equipment.stats.armor + return armor + +func get_Shield()->int: + var shield = stats.shield + for equipment in equipments: + shield += equipment.stats.shield + return shield + + +func get_movement_speed()->int: + var movement_speed = stats.movement_speed + for equipment in equipments: + movement_speed += equipment.stats.movement_speed + return movement_speed + diff --git a/scripts/Mech.gd b/scripts/Mech.gd new file mode 100644 index 0000000..0df29ca --- /dev/null +++ b/scripts/Mech.gd @@ -0,0 +1,28 @@ +extends Node3D + +class_name Mech + +var boots: Boots +var arms: Arms +var hydraulics: Hydraulics + + +func init_mech(boots: Boots, arms: Arms, hydraulics: Hydraulics): + self.boots = boots + self.arms = arms + self.hydraulics= hydraulics + +func get_max_health()-> int: + return boots.equipment_stats.max_health.value+arms.equipment_stats.max_health.value+hydraulics.equipment_stats.max_health.value + +func get_armor()-> int: + return boots.equipment_stats.armor.value+arms.equipment_stats.armor.value+hydraulics.equipment_stats.armor.value + +func get_shield()-> int: + return boots.equipment_stats.shield.value+arms.equipment_stats.shield.value+hydraulics.equipment_stats.shield.value + +func get_damage()-> int: + return boots.equipment_stats.damage.value+arms.equipment_stats.damage.value+hydraulics.equipment_stats.damage.value + +func get_movement_speed()-> int: + return boots.equipment_stats.movementSpeed.value+arms.equipment_stats.movementSpeed.value+hydraulics.equipment_stats.movementSpeed.value diff --git a/scripts/PlayerCharacter.gd b/scripts/PlayerCharacter.gd index eb022be..21b0ef6 100644 --- a/scripts/PlayerCharacter.gd +++ b/scripts/PlayerCharacter.gd @@ -1 +1,32 @@ -class_name PlayerCharacter extends Character +class_name PlayerCharacter extends Entity + +var mech: Mech + +func init_player_character(stats: EntityStats, mech: Mech): + init_entity(stats) + self.mech = mech; + +func get_max_health() -> int: + var max_health = base.get_max_health() + max_health += mech.get_max_health() + return max_health + +func get_armor() -> int: + var armor = stats.armor + armor += mech.get_armor() + for equipment in equipments: + armor += equipment.stats.armor + return armor + +func get_Shield() -> int: + var shield = stats.shield + for equipment in equipments: + shield += equipment.stats.shield + return shield + + +func get_movement_speed() -> int: + var movement_speed = stats.movement_speed + for equipment in equipments: + movement_speed += equipment.stats.movement_speed + return movement_speed diff --git a/scripts/Weapon.gd b/scripts/Weapon.gd index aaa86a2..68f27ec 100644 --- a/scripts/Weapon.gd +++ b/scripts/Weapon.gd @@ -6,6 +6,20 @@ var attachments: Array[Attachment] func init_weapon(stats: WeaponStats): self.stats = stats; - func attach(newAttachment: Attachment)-> void: attachments.append(newAttachment) + +func unattach(attachmentToRemove: Attachment)-> void: + attachments.erase(attachmentToRemove) + +func get_damage()->int: + var damage = stats.damage + for attachment in attachments: + damage += attachment.stats.damage + return damage + +func get_fire_rate()->int: + var fire_rate = stats.fire_rate + for attachment in attachments: + fire_rate += attachment.stats.fire_rate + return fire_rate diff --git a/scripts/resources/Character/CharacterResource.gd b/scripts/resources/Character/CharacterResource.gd deleted file mode 100644 index f08fe42..0000000 --- a/scripts/resources/Character/CharacterResource.gd +++ /dev/null @@ -1,13 +0,0 @@ -extends Resource - -class_name CharacterResource - -@export var character_stats: CharacterStats -@export var character_scene: PackedScene - - -func instantiate(parent: Node3D)->Character: - var character_instance = character_scene.instantiate() as Character - character_instance.init_character(character_stats) - parent.add_child(character_instance) - return character_instance diff --git a/scripts/resources/Character/Equipment/MechParts/MechBase.gd b/scripts/resources/Character/Equipment/MechParts/MechBase.gd deleted file mode 100644 index ec7479f..0000000 --- a/scripts/resources/Character/Equipment/MechParts/MechBase.gd +++ /dev/null @@ -1,10 +0,0 @@ -extends MechPartResource - -class_name MechBase - -@export var boots: Boots -@export var arms: Arms -@export var hydraulics: Hydraulics - -func get_stats()-> EquipmentStats: - return boots.equipment_stats.combine(arms.equipment_stats).combine(hydraulics.equipment_stats) diff --git a/scripts/resources/Entity/EntityResource.gd b/scripts/resources/Entity/EntityResource.gd new file mode 100644 index 0000000..022cdf7 --- /dev/null +++ b/scripts/resources/Entity/EntityResource.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name EntityResource + +@export var entity_stats: entityStats +@export var entity_scene: PackedScene + + +func instantiate(parent: Node3D)->Entity: + var entity_instance = entity_scene.instantiate() as Entity + entity_instance.init_entity(entity_stats) + parent.add_child(entity_instance) + return entity_instance diff --git a/scripts/resources/Character/CharacterStats.gd b/scripts/resources/Entity/EntityStats.gd similarity index 86% rename from scripts/resources/Character/CharacterStats.gd rename to scripts/resources/Entity/EntityStats.gd index daa221a..819d07e 100644 --- a/scripts/resources/Character/CharacterStats.gd +++ b/scripts/resources/Entity/EntityStats.gd @@ -1,6 +1,6 @@ extends Resource -class_name CharacterStats +class_name EntityStats @export var max_health: MaxHealth @export var health: Health diff --git a/scripts/resources/Character/Equipment/EquipmentResource.gd b/scripts/resources/Equipment/EquipmentResource.gd similarity index 86% rename from scripts/resources/Character/Equipment/EquipmentResource.gd rename to scripts/resources/Equipment/EquipmentResource.gd index 1923a18..577d82b 100644 --- a/scripts/resources/Character/Equipment/EquipmentResource.gd +++ b/scripts/resources/Equipment/EquipmentResource.gd @@ -12,6 +12,3 @@ func instantiate(parent: Node3D)->Equipment: equipment_instance.init_Equipment(equipment_stats) parent.add_child(equipment_instance) return equipment_instance - -func get_stats()-> EquipmentStats: - return equipment_stats diff --git a/scripts/resources/Character/Equipment/EquipmentStats.gd b/scripts/resources/Equipment/EquipmentStats.gd similarity index 74% rename from scripts/resources/Character/Equipment/EquipmentStats.gd rename to scripts/resources/Equipment/EquipmentStats.gd index 8df73eb..a65b670 100644 --- a/scripts/resources/Character/Equipment/EquipmentStats.gd +++ b/scripts/resources/Equipment/EquipmentStats.gd @@ -7,6 +7,3 @@ class_name EquipmentStats @export var shield: Shield @export var movementSpeed: MovementSpeed @export var damage: Damage - -func combine (other: EquipmentStats)->EquipmentStats: - return null diff --git a/scripts/resources/Character/Equipment/MechParts/Arms.gd b/scripts/resources/Equipment/MechParts/Arms.gd similarity index 100% rename from scripts/resources/Character/Equipment/MechParts/Arms.gd rename to scripts/resources/Equipment/MechParts/Arms.gd diff --git a/scripts/resources/Character/Equipment/MechParts/Boots.gd b/scripts/resources/Equipment/MechParts/Boots.gd similarity index 100% rename from scripts/resources/Character/Equipment/MechParts/Boots.gd rename to scripts/resources/Equipment/MechParts/Boots.gd diff --git a/scripts/resources/Character/Equipment/MechParts/Hydraulics.gd b/scripts/resources/Equipment/MechParts/Hydraulics.gd similarity index 100% rename from scripts/resources/Character/Equipment/MechParts/Hydraulics.gd rename to scripts/resources/Equipment/MechParts/Hydraulics.gd diff --git a/scripts/resources/Character/Equipment/MechParts/MechPartResource.gd b/scripts/resources/Equipment/MechParts/MechPartResource.gd similarity index 100% rename from scripts/resources/Character/Equipment/MechParts/MechPartResource.gd rename to scripts/resources/Equipment/MechParts/MechPartResource.gd diff --git a/singeltons/DamageHandler.gd b/singeltons/DamageHandler.gd new file mode 100644 index 0000000..4eff30e --- /dev/null +++ b/singeltons/DamageHandler.gd @@ -0,0 +1,9 @@ +extends Node + +class_name DamageHandler + + +func apply_damage(damage_dealer: Entity, damage_receiver: Entity, weapon: Weapon ): + damage_receiver.get_armor() + damage_receiver.get + pass -- 2.45.2 From cb65c3a2665c14a4b40b61ad5506d0b05feb3b35 Mon Sep 17 00:00:00 2001 From: Strieglitz Date: Sun, 9 Mar 2025 23:56:19 +0100 Subject: [PATCH 4/4] first version of enitites damageables weapons item and effects workflow --- project.godot | 5 ++ resources/Character.tres | 8 --- resources/Hp.tres | 7 -- resources/PlayerStats.tres | 12 ++-- scripts/Attachment.gd | 7 -- scripts/{ => Entites}/Enemie.gd | 0 scripts/Entites/Entity.gd | 70 +++++++++++++++++++ scripts/Entites/PlayerCharacter.gd | 19 +++++ scripts/Entity.gd | 44 ------------ scripts/Equipment.gd | 7 -- scripts/Items/Attachment.gd | 16 +++++ scripts/Items/Equipment.gd | 22 ++++++ scripts/Items/Mech/Arms.gd | 1 + scripts/Items/Mech/Boots.gd | 1 + scripts/Items/Mech/Hydraulics.gd | 1 + scripts/Items/Mech/Mech.gd | 28 ++++++++ scripts/{ => Items}/Weapon.gd | 12 +++- scripts/Mech.gd | 28 -------- scripts/PlayerCharacter.gd | 32 --------- scripts/resources/Effects/Effect.gd | 2 +- scripts/resources/Effects/HealEffect.gd | 6 ++ scripts/resources/Effects/RefillHpEffect.gd | 4 -- scripts/resources/Entity/EntityResource.gd | 2 +- scripts/resources/Entity/EntityStats.gd | 11 +-- scripts/resources/Equipment/EquipmentStats.gd | 10 +-- .../MechParts/{Arms.gd => ArmsResource.gd} | 2 +- .../MechParts/{Boots.gd => BootsResource.gd} | 2 +- .../Equipment/MechParts/Hydraulics.gd | 3 - .../Equipment/MechParts/HydraulicsResource.gd | 3 + .../Stats/{Armor.gd => ArmorStat.gd} | 2 +- .../Stats/{Damage.gd => DamageStat.gd} | 2 +- .../resources/Stats/Effects/HitEffectsStat.gd | 13 ++++ .../Stats/{FireRate.gd => FireRateStat.gd} | 2 +- .../Stats/{Health.gd => HealthStat.gd} | 2 +- .../Stats/{MaxHealth.gd => MaxHealthStat.gd} | 2 +- scripts/resources/Stats/MaxShieldStat.gd | 13 ++++ ...{MovementSpeed.gd => MovementSpeedStat.gd} | 2 +- .../Stats/{Shield.gd => ShieldStat.gd} | 2 +- .../Weapons/Attachments/AttachmentStats.gd | 5 +- scripts/resources/Weapons/WeaponStats.gd | 5 +- singeltons/DamageHandler.gd | 25 +++++-- singeltons/MathUtils.gd | 3 + 42 files changed, 263 insertions(+), 180 deletions(-) delete mode 100644 resources/Character.tres delete mode 100644 resources/Hp.tres delete mode 100644 scripts/Attachment.gd rename scripts/{ => Entites}/Enemie.gd (100%) create mode 100644 scripts/Entites/Entity.gd create mode 100644 scripts/Entites/PlayerCharacter.gd delete mode 100644 scripts/Entity.gd delete mode 100644 scripts/Equipment.gd create mode 100644 scripts/Items/Attachment.gd create mode 100644 scripts/Items/Equipment.gd create mode 100644 scripts/Items/Mech/Arms.gd create mode 100644 scripts/Items/Mech/Boots.gd create mode 100644 scripts/Items/Mech/Hydraulics.gd create mode 100644 scripts/Items/Mech/Mech.gd rename scripts/{ => Items}/Weapon.gd (63%) delete mode 100644 scripts/Mech.gd delete mode 100644 scripts/PlayerCharacter.gd create mode 100644 scripts/resources/Effects/HealEffect.gd delete mode 100644 scripts/resources/Effects/RefillHpEffect.gd rename scripts/resources/Equipment/MechParts/{Arms.gd => ArmsResource.gd} (52%) rename scripts/resources/Equipment/MechParts/{Boots.gd => BootsResource.gd} (50%) delete mode 100644 scripts/resources/Equipment/MechParts/Hydraulics.gd create mode 100644 scripts/resources/Equipment/MechParts/HydraulicsResource.gd rename scripts/resources/Stats/{Armor.gd => ArmorStat.gd} (90%) rename scripts/resources/Stats/{Damage.gd => DamageStat.gd} (90%) create mode 100644 scripts/resources/Stats/Effects/HitEffectsStat.gd rename scripts/resources/Stats/{FireRate.gd => FireRateStat.gd} (89%) rename scripts/resources/Stats/{Health.gd => HealthStat.gd} (90%) rename scripts/resources/Stats/{MaxHealth.gd => MaxHealthStat.gd} (89%) create mode 100644 scripts/resources/Stats/MaxShieldStat.gd rename scripts/resources/Stats/{MovementSpeed.gd => MovementSpeedStat.gd} (87%) rename scripts/resources/Stats/{Shield.gd => ShieldStat.gd} (90%) create mode 100644 singeltons/MathUtils.gd diff --git a/project.godot b/project.godot index 912855b..3540ebb 100644 --- a/project.godot +++ b/project.godot @@ -28,6 +28,11 @@ run/main_scene="res://scenes/debug_level.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +MathUtils="*res://singeltons/MathUtils.gd" +DamageHandler="*res://singeltons/DamageHandler.gd" + [display] window/size/viewport_width=1920 diff --git a/resources/Character.tres b/resources/Character.tres deleted file mode 100644 index 8933959..0000000 --- a/resources/Character.tres +++ /dev/null @@ -1,8 +0,0 @@ -[gd_resource type="Resource" script_class="Character" load_steps=3 format=3 uid="uid://bd1ugbnlm08vv"] - -[ext_resource type="Script" path="res://scripts/resources/Entity/EntityResource.gd" id="1_8yb2m"] -[ext_resource type="Resource" uid="uid://qcjre5wwbrs3" path="res://resources/PlayerStats.tres" id="2_rc7x1"] - -[resource] -script = ExtResource("1_8yb2m") -stats = ExtResource("2_rc7x1") diff --git a/resources/Hp.tres b/resources/Hp.tres deleted file mode 100644 index 9fd8d8a..0000000 --- a/resources/Hp.tres +++ /dev/null @@ -1,7 +0,0 @@ -[gd_resource type="Resource" script_class="Health" load_steps=2 format=3 uid="uid://c3gf5mi1u151m"] - -[ext_resource type="Script" path="res://scripts/resources/Stats/Health.gd" id="1_yqlcl"] - -[resource] -script = ExtResource("1_yqlcl") -_value = 0 diff --git a/resources/PlayerStats.tres b/resources/PlayerStats.tres index 4f63a7f..e006ae7 100644 --- a/resources/PlayerStats.tres +++ b/resources/PlayerStats.tres @@ -1,11 +1,11 @@ -[gd_resource type="Resource" script_class="CharacterStats" load_steps=12 format=3 uid="uid://qcjre5wwbrs3"] +[gd_resource type="Resource" script_class="EntityStats" load_steps=12 format=3 uid="uid://qcjre5wwbrs3"] -[ext_resource type="Script" path="res://scripts/resources/Stats/Armor.gd" id="1_c7135"] +[ext_resource type="Script" path="res://scripts/resources/Stats/ArmorStat.gd" id="1_c7135"] [ext_resource type="Script" path="res://scripts/resources/Entity/EntityStats.gd" id="1_xti0a"] -[ext_resource type="Script" path="res://scripts/resources/Stats/Health.gd" id="2_hsnpy"] -[ext_resource type="Script" path="res://scripts/resources/Stats/MaxHealth.gd" id="3_26tso"] -[ext_resource type="Script" path="res://scripts/resources/Stats/MovementSpeed.gd" id="4_goc2a"] -[ext_resource type="Script" path="res://scripts/resources/Stats/Shield.gd" id="6_rncik"] +[ext_resource type="Script" path="res://scripts/resources/Stats/HealthStat.gd" id="2_hsnpy"] +[ext_resource type="Script" path="res://scripts/resources/Stats/MaxHealthStat.gd" id="3_26tso"] +[ext_resource type="Script" path="res://scripts/resources/Stats/MovementSpeedStat.gd" id="4_goc2a"] +[ext_resource type="Script" path="res://scripts/resources/Stats/ShieldStat.gd" id="6_rncik"] [sub_resource type="Resource" id="Resource_vbm44"] script = ExtResource("1_c7135") diff --git a/scripts/Attachment.gd b/scripts/Attachment.gd deleted file mode 100644 index 8fa0057..0000000 --- a/scripts/Attachment.gd +++ /dev/null @@ -1,7 +0,0 @@ -class_name Attachment extends Node3D - - -var stats: AttachmentStats - -func init_attachment(stats: AttachmentStats): - self.stats = stats; diff --git a/scripts/Enemie.gd b/scripts/Entites/Enemie.gd similarity index 100% rename from scripts/Enemie.gd rename to scripts/Entites/Enemie.gd diff --git a/scripts/Entites/Entity.gd b/scripts/Entites/Entity.gd new file mode 100644 index 0000000..51e4454 --- /dev/null +++ b/scripts/Entites/Entity.gd @@ -0,0 +1,70 @@ +class_name Entity extends Node3D + + +var stats: EntityStats +var equipments: Array[Equipment] +signal died_event(entity: Entity) + +func init_entity(stats: EntityStats): + self.stats = stats; + +func equip(newEquipment: Equipment)-> void: + equipments.append(newEquipment) + +func unequip(equipmentToRemove: Equipment)-> void: + equipments.erase(equipmentToRemove) + + +func get_health()->int: + return stats.health.value + +func get_shield()->int: + return stats.shield.value + +func reduce_shield(damage: int): + stats.shield.value -= damage + if stats.shield.value <= 0: + stats.shield.value = 0 + +func increase_health(additional_health: int): + stats.health.value += additional_health + if stats.health.value > get_max_health(): + stats.health.value = get_max_health() + +func reduce_health(damage: int): + stats.health.value -= damage + if stats.health.value <= 0: + died() + +func died(): + died_event.emit(self) + +func get_max_health()->int: + var max_health = stats.max_health + for equipment in equipments: + max_health += equipment.get_max_health() + return max_health + +func get_armor()->int: + var armor = stats.armor + for equipment in equipments: + armor += equipment.get_armor() + return armor + +func get_max_Shield()->int: + var shield = stats.shield + for equipment in equipments: + shield += equipment.get_max_shield() + return shield + +func get_movement_speed()->int: + var movement_speed = stats.movement_speed + for equipment in equipments: + movement_speed += equipment.get_evement_speed() + return movement_speed + +func get_damage()->int: + var damage = 0 + for equipment in equipments: + damage += equipment.get_damage() + return damage diff --git a/scripts/Entites/PlayerCharacter.gd b/scripts/Entites/PlayerCharacter.gd new file mode 100644 index 0000000..7dbdc09 --- /dev/null +++ b/scripts/Entites/PlayerCharacter.gd @@ -0,0 +1,19 @@ +class_name PlayerCharacter extends Entity + +var mech: Mech + +func init_player_character(stats: EntityStats, mech: Mech): + init_entity(stats) + self.mech = mech; + +func get_max_health() -> int: + return super() + mech.get_max_health() + +func get_armor() -> int: + return super() + mech.get_armor() + +func get_max_Shield() -> int: + return super() + mech.get_shield() + +func get_movement_speed() -> int: + return super() + mech.get_movement_speed() diff --git a/scripts/Entity.gd b/scripts/Entity.gd deleted file mode 100644 index c38a410..0000000 --- a/scripts/Entity.gd +++ /dev/null @@ -1,44 +0,0 @@ -class_name Entity extends Node3D - - -var stats: EntityStats -var equipments: Array[Equipment] - -func init_entity(stats: EntityStats): - self.stats = stats; - -func equip(newEquipment: Equipment)-> void: - equipments.append(newEquipment) - -func unequip(equipmentToRemove: Equipment)-> void: - equipments.erase(equipmentToRemove) - -func get_max_health()->int: - var max_health = stats.max_health - for equipment in equipments: - max_health += equipment - - return max_health - -func get_health()->int: - return stats.health.value - -func get_armor()->int: - var armor = stats.armor - for equipment in equipments: - armor += equipment.stats.armor - return armor - -func get_Shield()->int: - var shield = stats.shield - for equipment in equipments: - shield += equipment.stats.shield - return shield - - -func get_movement_speed()->int: - var movement_speed = stats.movement_speed - for equipment in equipments: - movement_speed += equipment.stats.movement_speed - return movement_speed - diff --git a/scripts/Equipment.gd b/scripts/Equipment.gd deleted file mode 100644 index 6d5bdfd..0000000 --- a/scripts/Equipment.gd +++ /dev/null @@ -1,7 +0,0 @@ -class_name Equipment extends Node3D - - -var stats: EquipmentStats - -func init_equipment(stats: EquipmentStats): - self.stats = stats; diff --git a/scripts/Items/Attachment.gd b/scripts/Items/Attachment.gd new file mode 100644 index 0000000..83e6caa --- /dev/null +++ b/scripts/Items/Attachment.gd @@ -0,0 +1,16 @@ +class_name Attachment extends Node3D + + +var stats: AttachmentStats + +func init_attachment(stats: AttachmentStats): + self.stats = stats + +func get_damage()->int: + return stats.damage.value + +func get_fire_rate()->int: + return stats.fire_rate.value + +func get_hit_effects()-> Array[Effect]: + return stats.hit_effects.value diff --git a/scripts/Items/Equipment.gd b/scripts/Items/Equipment.gd new file mode 100644 index 0000000..dc54e33 --- /dev/null +++ b/scripts/Items/Equipment.gd @@ -0,0 +1,22 @@ +class_name Equipment extends Node3D + + +var stats: EquipmentStats + +func init_equipment(stats: EquipmentStats): + self.stats = stats; + +func get_armor()-> int: + return stats.armor.value + +func get_max_health()-> int: + return stats.max_health.value + +func get_max_shield()-> int: + return stats.max_shield.value + +func get_evement_speed()-> int: + return stats.movementSpeed.value + +func get_damage()-> int: + return stats.damage.value diff --git a/scripts/Items/Mech/Arms.gd b/scripts/Items/Mech/Arms.gd new file mode 100644 index 0000000..2cab151 --- /dev/null +++ b/scripts/Items/Mech/Arms.gd @@ -0,0 +1 @@ +class_name Arms extends Equipment diff --git a/scripts/Items/Mech/Boots.gd b/scripts/Items/Mech/Boots.gd new file mode 100644 index 0000000..85d4874 --- /dev/null +++ b/scripts/Items/Mech/Boots.gd @@ -0,0 +1 @@ +class_name Boots extends Equipment diff --git a/scripts/Items/Mech/Hydraulics.gd b/scripts/Items/Mech/Hydraulics.gd new file mode 100644 index 0000000..6ddc3d8 --- /dev/null +++ b/scripts/Items/Mech/Hydraulics.gd @@ -0,0 +1 @@ +class_name Hydraulics extends Equipment diff --git a/scripts/Items/Mech/Mech.gd b/scripts/Items/Mech/Mech.gd new file mode 100644 index 0000000..120ea8e --- /dev/null +++ b/scripts/Items/Mech/Mech.gd @@ -0,0 +1,28 @@ +extends Node3D + +class_name Mech + +var boots: Boots +var arms: Arms +var hydraulics: Hydraulics + + +func init_mech(boots: Boots, arms: Arms, hydraulics: Hydraulics): + self.boots = boots + self.arms = arms + self.hydraulics= hydraulics + +func get_max_health()-> int: + return boots.get_max_health() +arms.get_max_health()+hydraulics.get_max_health() + +func get_armor()-> int: + return boots.get_armor()+arms.get_armor()+hydraulics.get_armor() + +func get_max_shield()-> int: + return boots.get_max_shield()+arms.get_max_shield()+hydraulics.get_max_shield() + +func get_damage()-> int: + return boots.get_damage()+arms.get_damage()+hydraulics.get_damage() + +func get_movement_speed()-> int: + return boots.get_evement_speed()+arms.get_evement_speed()+hydraulics.get_evement_speed() diff --git a/scripts/Weapon.gd b/scripts/Items/Weapon.gd similarity index 63% rename from scripts/Weapon.gd rename to scripts/Items/Weapon.gd index 68f27ec..142c958 100644 --- a/scripts/Weapon.gd +++ b/scripts/Items/Weapon.gd @@ -15,11 +15,19 @@ func unattach(attachmentToRemove: Attachment)-> void: func get_damage()->int: var damage = stats.damage for attachment in attachments: - damage += attachment.stats.damage + damage += attachment.get_damage() return damage func get_fire_rate()->int: var fire_rate = stats.fire_rate for attachment in attachments: - fire_rate += attachment.stats.fire_rate + fire_rate += attachment.get_fire_rate() return fire_rate + +func get_hit_effects()-> Array[Effect]: + var hit_effects = [] + hit_effects.append_array(stats.hit_effects.value) + for attachment in attachments: + hit_effects.append_array(attachment.get_hit_effects()) + return hit_effects + diff --git a/scripts/Mech.gd b/scripts/Mech.gd deleted file mode 100644 index 0df29ca..0000000 --- a/scripts/Mech.gd +++ /dev/null @@ -1,28 +0,0 @@ -extends Node3D - -class_name Mech - -var boots: Boots -var arms: Arms -var hydraulics: Hydraulics - - -func init_mech(boots: Boots, arms: Arms, hydraulics: Hydraulics): - self.boots = boots - self.arms = arms - self.hydraulics= hydraulics - -func get_max_health()-> int: - return boots.equipment_stats.max_health.value+arms.equipment_stats.max_health.value+hydraulics.equipment_stats.max_health.value - -func get_armor()-> int: - return boots.equipment_stats.armor.value+arms.equipment_stats.armor.value+hydraulics.equipment_stats.armor.value - -func get_shield()-> int: - return boots.equipment_stats.shield.value+arms.equipment_stats.shield.value+hydraulics.equipment_stats.shield.value - -func get_damage()-> int: - return boots.equipment_stats.damage.value+arms.equipment_stats.damage.value+hydraulics.equipment_stats.damage.value - -func get_movement_speed()-> int: - return boots.equipment_stats.movementSpeed.value+arms.equipment_stats.movementSpeed.value+hydraulics.equipment_stats.movementSpeed.value diff --git a/scripts/PlayerCharacter.gd b/scripts/PlayerCharacter.gd deleted file mode 100644 index 21b0ef6..0000000 --- a/scripts/PlayerCharacter.gd +++ /dev/null @@ -1,32 +0,0 @@ -class_name PlayerCharacter extends Entity - -var mech: Mech - -func init_player_character(stats: EntityStats, mech: Mech): - init_entity(stats) - self.mech = mech; - -func get_max_health() -> int: - var max_health = base.get_max_health() - max_health += mech.get_max_health() - return max_health - -func get_armor() -> int: - var armor = stats.armor - armor += mech.get_armor() - for equipment in equipments: - armor += equipment.stats.armor - return armor - -func get_Shield() -> int: - var shield = stats.shield - for equipment in equipments: - shield += equipment.stats.shield - return shield - - -func get_movement_speed() -> int: - var movement_speed = stats.movement_speed - for equipment in equipments: - movement_speed += equipment.stats.movement_speed - return movement_speed diff --git a/scripts/resources/Effects/Effect.gd b/scripts/resources/Effects/Effect.gd index 6864411..e20dcdc 100644 --- a/scripts/resources/Effects/Effect.gd +++ b/scripts/resources/Effects/Effect.gd @@ -2,5 +2,5 @@ extends Resource class_name Effect -func apply_effect (character: Character)-> void: +func apply_effect (orign_entity: Entity, target_entity: Entity)-> void: assert(false) diff --git a/scripts/resources/Effects/HealEffect.gd b/scripts/resources/Effects/HealEffect.gd new file mode 100644 index 0000000..9a895fe --- /dev/null +++ b/scripts/resources/Effects/HealEffect.gd @@ -0,0 +1,6 @@ +class_name HealEffect extends Effect + +@export var heal_amount: int + +func apply_effect (orign_entity: Entity, target_entity: Entity)-> void: + target_entity.increase_health(heal_amount) diff --git a/scripts/resources/Effects/RefillHpEffect.gd b/scripts/resources/Effects/RefillHpEffect.gd deleted file mode 100644 index 91eb748..0000000 --- a/scripts/resources/Effects/RefillHpEffect.gd +++ /dev/null @@ -1,4 +0,0 @@ -extends Effect - -func apply_effect (character: Character)-> void: - character.stats.health.value = character.stats.max_health.value diff --git a/scripts/resources/Entity/EntityResource.gd b/scripts/resources/Entity/EntityResource.gd index 022cdf7..f6bedde 100644 --- a/scripts/resources/Entity/EntityResource.gd +++ b/scripts/resources/Entity/EntityResource.gd @@ -2,7 +2,7 @@ extends Resource class_name EntityResource -@export var entity_stats: entityStats +@export var entity_stats: EntityStats @export var entity_scene: PackedScene diff --git a/scripts/resources/Entity/EntityStats.gd b/scripts/resources/Entity/EntityStats.gd index 819d07e..7702801 100644 --- a/scripts/resources/Entity/EntityStats.gd +++ b/scripts/resources/Entity/EntityStats.gd @@ -2,8 +2,9 @@ extends Resource class_name EntityStats -@export var max_health: MaxHealth -@export var health: Health -@export var armor: Armor -@export var shield: Shield -@export var movementSpeed: MovementSpeed +@export var max_health: MaxHealthStat +@export var health: HealthStat +@export var armor: ArmorStat +@export var shield: ShieldStat +@export var max_shield: MaxShieldStat +@export var movementSpeed: MovementSpeedStat diff --git a/scripts/resources/Equipment/EquipmentStats.gd b/scripts/resources/Equipment/EquipmentStats.gd index a65b670..f3f0d8a 100644 --- a/scripts/resources/Equipment/EquipmentStats.gd +++ b/scripts/resources/Equipment/EquipmentStats.gd @@ -2,8 +2,8 @@ extends Resource class_name EquipmentStats -@export var max_health: MaxHealth -@export var armor: Armor -@export var shield: Shield -@export var movementSpeed: MovementSpeed -@export var damage: Damage +@export var max_health: MaxHealthStat +@export var armor: ArmorStat +@export var max_shield: MaxShieldStat +@export var movementSpeed: MovementSpeedStat +@export var damage: DamageStat diff --git a/scripts/resources/Equipment/MechParts/Arms.gd b/scripts/resources/Equipment/MechParts/ArmsResource.gd similarity index 52% rename from scripts/resources/Equipment/MechParts/Arms.gd rename to scripts/resources/Equipment/MechParts/ArmsResource.gd index 1010283..596f127 100644 --- a/scripts/resources/Equipment/MechParts/Arms.gd +++ b/scripts/resources/Equipment/MechParts/ArmsResource.gd @@ -1,3 +1,3 @@ extends MechPartResource -class_name Arms +class_name ArmsResource diff --git a/scripts/resources/Equipment/MechParts/Boots.gd b/scripts/resources/Equipment/MechParts/BootsResource.gd similarity index 50% rename from scripts/resources/Equipment/MechParts/Boots.gd rename to scripts/resources/Equipment/MechParts/BootsResource.gd index 1c0b007..3d7ec04 100644 --- a/scripts/resources/Equipment/MechParts/Boots.gd +++ b/scripts/resources/Equipment/MechParts/BootsResource.gd @@ -1,3 +1,3 @@ extends MechPartResource -class_name Boots +class_name BootsResource diff --git a/scripts/resources/Equipment/MechParts/Hydraulics.gd b/scripts/resources/Equipment/MechParts/Hydraulics.gd deleted file mode 100644 index a29158c..0000000 --- a/scripts/resources/Equipment/MechParts/Hydraulics.gd +++ /dev/null @@ -1,3 +0,0 @@ -extends MechPartResource - -class_name Hydraulics diff --git a/scripts/resources/Equipment/MechParts/HydraulicsResource.gd b/scripts/resources/Equipment/MechParts/HydraulicsResource.gd new file mode 100644 index 0000000..10d9618 --- /dev/null +++ b/scripts/resources/Equipment/MechParts/HydraulicsResource.gd @@ -0,0 +1,3 @@ +extends MechPartResource + +class_name HydraulicsResource diff --git a/scripts/resources/Stats/Armor.gd b/scripts/resources/Stats/ArmorStat.gd similarity index 90% rename from scripts/resources/Stats/Armor.gd rename to scripts/resources/Stats/ArmorStat.gd index 13ee0d2..be4a43a 100644 --- a/scripts/resources/Stats/Armor.gd +++ b/scripts/resources/Stats/ArmorStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name Armor +class_name ArmorStat signal value_changed_signal(currentArmor: int) diff --git a/scripts/resources/Stats/Damage.gd b/scripts/resources/Stats/DamageStat.gd similarity index 90% rename from scripts/resources/Stats/Damage.gd rename to scripts/resources/Stats/DamageStat.gd index f4fcf10..387510d 100644 --- a/scripts/resources/Stats/Damage.gd +++ b/scripts/resources/Stats/DamageStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name Damage +class_name DamageStat signal value_changed_signal(currentDamage: int) diff --git a/scripts/resources/Stats/Effects/HitEffectsStat.gd b/scripts/resources/Stats/Effects/HitEffectsStat.gd new file mode 100644 index 0000000..0ddec00 --- /dev/null +++ b/scripts/resources/Stats/Effects/HitEffectsStat.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name HitEffectStat + +signal value_changed_signal(effects: Array[Effect]) + +@export var _value: Array[Effect] +var value: Array[Effect]: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/FireRate.gd b/scripts/resources/Stats/FireRateStat.gd similarity index 89% rename from scripts/resources/Stats/FireRate.gd rename to scripts/resources/Stats/FireRateStat.gd index 89ff0c3..e5b11b0 100644 --- a/scripts/resources/Stats/FireRate.gd +++ b/scripts/resources/Stats/FireRateStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name FireRate +class_name FireRateStat signal value_changed_signal(currentFireRate: int) diff --git a/scripts/resources/Stats/Health.gd b/scripts/resources/Stats/HealthStat.gd similarity index 90% rename from scripts/resources/Stats/Health.gd rename to scripts/resources/Stats/HealthStat.gd index 4802849..3d7313e 100644 --- a/scripts/resources/Stats/Health.gd +++ b/scripts/resources/Stats/HealthStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name Health +class_name HealthStat signal value_changed_signal(currentHealth: int) diff --git a/scripts/resources/Stats/MaxHealth.gd b/scripts/resources/Stats/MaxHealthStat.gd similarity index 89% rename from scripts/resources/Stats/MaxHealth.gd rename to scripts/resources/Stats/MaxHealthStat.gd index 4c487c9..568e6f7 100644 --- a/scripts/resources/Stats/MaxHealth.gd +++ b/scripts/resources/Stats/MaxHealthStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name MaxHealth +class_name MaxHealthStat signal value_changed_signal(currentMaxHealth: int) diff --git a/scripts/resources/Stats/MaxShieldStat.gd b/scripts/resources/Stats/MaxShieldStat.gd new file mode 100644 index 0000000..74fc1a4 --- /dev/null +++ b/scripts/resources/Stats/MaxShieldStat.gd @@ -0,0 +1,13 @@ +extends Resource + +class_name MaxShieldStat + +signal value_changed_signal(currentMaxShield: int) + +@export var _value: int +var value: int: + get: + return _value + set(new_value): + value = new_value; + value_changed_signal.emit(_value) diff --git a/scripts/resources/Stats/MovementSpeed.gd b/scripts/resources/Stats/MovementSpeedStat.gd similarity index 87% rename from scripts/resources/Stats/MovementSpeed.gd rename to scripts/resources/Stats/MovementSpeedStat.gd index 34bedfa..9c59140 100644 --- a/scripts/resources/Stats/MovementSpeed.gd +++ b/scripts/resources/Stats/MovementSpeedStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name MovementSpeed +class_name MovementSpeedStat signal value_changed_signal(currentMovementSpeed: int) diff --git a/scripts/resources/Stats/Shield.gd b/scripts/resources/Stats/ShieldStat.gd similarity index 90% rename from scripts/resources/Stats/Shield.gd rename to scripts/resources/Stats/ShieldStat.gd index 00a0feb..dcf9a8a 100644 --- a/scripts/resources/Stats/Shield.gd +++ b/scripts/resources/Stats/ShieldStat.gd @@ -1,6 +1,6 @@ extends Resource -class_name Shield +class_name ShieldStat signal value_changed_signal(currentShield: int) diff --git a/scripts/resources/Weapons/Attachments/AttachmentStats.gd b/scripts/resources/Weapons/Attachments/AttachmentStats.gd index f038a1e..121616f 100644 --- a/scripts/resources/Weapons/Attachments/AttachmentStats.gd +++ b/scripts/resources/Weapons/Attachments/AttachmentStats.gd @@ -2,5 +2,6 @@ extends Resource class_name AttachmentStats -@export var damage: Damage -@export var fire_rate: FireRate +@export var damage: DamageStat +@export var fire_rate: FireRateStat +@export var hit_effects: HitEffectStat diff --git a/scripts/resources/Weapons/WeaponStats.gd b/scripts/resources/Weapons/WeaponStats.gd index 109409e..c7e7795 100644 --- a/scripts/resources/Weapons/WeaponStats.gd +++ b/scripts/resources/Weapons/WeaponStats.gd @@ -3,5 +3,6 @@ extends Resource class_name WeaponStats -@export var damage: Damage -@export var fire_rate: FireRate +@export var damage: DamageStat +@export var fire_rate: FireRateStat +@export var hit_effects: HitEffectStat diff --git a/singeltons/DamageHandler.gd b/singeltons/DamageHandler.gd index 4eff30e..3d9c01c 100644 --- a/singeltons/DamageHandler.gd +++ b/singeltons/DamageHandler.gd @@ -1,9 +1,20 @@ -extends Node - -class_name DamageHandler - +extends Object func apply_damage(damage_dealer: Entity, damage_receiver: Entity, weapon: Weapon ): - damage_receiver.get_armor() - damage_receiver.get - pass + var damage = weapon.get_damage() + damage_dealer.get_damage() + var armor = damage_receiver.get_armor() + var damage_percent = 90*( pow(MathUtils.e, 0.03*armor)) + + var damage_after_armor = damage * damage_percent + if damage_after_armor < 1 : + damage_after_armor = 1 + + var shield = damage_receiver.get_shield() + if shield > 0: + damage_receiver.reduce_shield(damage_after_armor) + else: + damage_receiver.reduce_health(damage_after_armor) + + for effect in weapon.get_hit_effects(): + effect.apply_effect(damage_dealer,damage_receiver) + diff --git a/singeltons/MathUtils.gd b/singeltons/MathUtils.gd new file mode 100644 index 0000000..b264afd --- /dev/null +++ b/singeltons/MathUtils.gd @@ -0,0 +1,3 @@ +extends Object + +var e = 2.718281828459045235360287471352 -- 2.45.2