diff --git a/player.tscn b/player.tscn index 134cfec..a41d992 100644 --- a/player.tscn +++ b/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=10 format=3 uid="uid://cf3emyoet5j64"] +[gd_scene load_steps=11 format=3 uid="uid://cf3emyoet5j64"] [ext_resource type="Script" path="res://player.gd" id="1_ft17v"] [ext_resource type="SpriteFrames" uid="uid://b06a3lft4r7qs" path="res://player_overworld.tres" id="2_3mhg4"] @@ -8,6 +8,7 @@ [ext_resource type="Script" path="res://resources/attack_rsc.gd" id="6_bcgn8"] [ext_resource type="Resource" uid="uid://cs60ixhmh86wm" path="res://resources/attacks/normal_attack.tres" id="6_i87wm"] [ext_resource type="Resource" uid="uid://hodugild11n5" path="res://resources/attacks/slash_attack.tres" id="7_u0ent"] +[ext_resource type="PackedScene" uid="uid://b18463a7xv7jr" path="res://src/components/defend_component.tscn" id="9_uluyt"] [sub_resource type="CapsuleShape2D" id="CapsuleShape2D_8s1xf"] height = 38.0 @@ -32,3 +33,4 @@ zoom = Vector2(3, 3) [node name="AttackComponent" parent="." instance=ExtResource("5_xlubi")] attacks = Array[ExtResource("6_bcgn8")]([ExtResource("6_i87wm"), ExtResource("7_u0ent")]) +[node name="DefendComponent" parent="." instance=ExtResource("9_uluyt")] diff --git a/src/components/defend_component.gd b/src/components/defend_component.gd new file mode 100644 index 0000000..28cf7e6 --- /dev/null +++ b/src/components/defend_component.gd @@ -0,0 +1,20 @@ +extends Node + +@export var defence = 10 + +@export_category("Animation") +@export var animation : AnimationPlayer + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +func generate_mitigated_attack(incoming_attack : Attack) -> Attack: + # Placeholder calculation + return Attack.new( + incoming_attack.name, + incoming_attack.description, + incoming_attack.damage - defence, + incoming_attack.accuracy + ) diff --git a/src/components/defend_component.tscn b/src/components/defend_component.tscn new file mode 100644 index 0000000..27baae1 --- /dev/null +++ b/src/components/defend_component.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://b18463a7xv7jr"] + +[ext_resource type="Script" path="res://src/components/defend_component.gd" id="1_xsk6h"] + +[node name="DefendComponent" type="Node"] +script = ExtResource("1_xsk6h")