From 8071fb2d18d18ffaee4d987eb3f5f1bad98188de Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Sun, 23 Jul 2023 11:03:55 -0700 Subject: [PATCH] fixed parrying --- Items/Weapons/Sword.cs | 4 ++-- Items/Weapons/Sword.tscn | 6 ++---- State/Weapon/SwordAnticipateState.cs | 3 +-- State/Weapon/SwordAttackState.cs | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/Items/Weapons/Sword.cs b/Items/Weapons/Sword.cs index 24f16b3..16545b1 100644 --- a/Items/Weapons/Sword.cs +++ b/Items/Weapons/Sword.cs @@ -112,7 +112,6 @@ public partial class Sword : Weapon, IParryable IsParried = false; IsParryable = true; ParryTimeOrigin = Time.GetTicksMsec(); - GD.Print(Character.Name); } public void DisableParry() @@ -147,6 +146,7 @@ public partial class Sword : Weapon, IParryable public override void _Ready() { Hitbox.Damage = Damage; + Hitbox.Hit += OnHitboxHit; _playback = (AnimationNodeStateMachinePlayback)AnimationTree .Get("parameters/playback"); } @@ -200,7 +200,7 @@ public partial class Sword : Weapon, IParryable GetNode("ParrySound").OnWorld().PlayOneShot(); } - public override void _on_hitbox_hit(BoundingBox box) + public override void OnHitboxHit(BoundingBox box) { if (IsParried) { diff --git a/Items/Weapons/Sword.tscn b/Items/Weapons/Sword.tscn index 25e73f3..5f39e29 100644 --- a/Items/Weapons/Sword.tscn +++ b/Items/Weapons/Sword.tscn @@ -9,6 +9,7 @@ [ext_resource type="PackedScene" uid="uid://cojxmcin13ihm" path="res://Utils/Trail.tscn" id="4_pt6lq"] [ext_resource type="Script" path="res://State/Weapon/SwordAttackState.cs" id="5_hmisb"] [ext_resource type="AudioStream" uid="uid://c4n7ioxpukdwi" path="res://Assets/Sounds/parry.wav" id="6_8nxjm"] +[ext_resource type="Shape2D" uid="uid://dw4e4r2yxwk1b" path="res://Items/Weapons/SwordCollisionShape.tres" id="9_wsprl"] [ext_resource type="Texture2D" uid="uid://cmvh6pc71ir1m" path="res://Assets/Sprites/sword-swing-large.png" id="10_672jv"] [ext_resource type="AudioStream" uid="uid://qvthq6tppp63" path="res://Assets/Sounds/whoosh.wav" id="10_mfnl7"] @@ -355,9 +356,6 @@ graph_offset = Vector2(0, -104.073) [sub_resource type="AnimationNodeStateMachinePlayback" id="AnimationNodeStateMachinePlayback_o5g2u"] -[sub_resource type="ConvexPolygonShape2D" id="ConvexPolygonShape2D_fcgvv"] -points = PackedVector2Array(0, 0, -21.213, 21.213, -30, 0, -21.213, -21.213, 0, -30, 21.213, -21.213, 30, 0, 21.213, 21.213, 0, 0) - [node name="Sword" type="Node2D" node_paths=PackedStringArray("Hitbox", "AnimationPlayer", "AnimationTree", "ParryParticles", "StateMachine", "Anchor", "HandAnchor")] y_sort_enabled = true texture_filter = 3 @@ -459,7 +457,7 @@ IsDisabled = true [node name="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(4, 0) rotation = 1.5708 -shape = SubResource("ConvexPolygonShape2D_fcgvv") +shape = ExtResource("9_wsprl") disabled = true [node name="SwingSprite" type="Sprite2D" parent="."] diff --git a/State/Weapon/SwordAnticipateState.cs b/State/Weapon/SwordAnticipateState.cs index f393a65..25c89cf 100644 --- a/State/Weapon/SwordAnticipateState.cs +++ b/State/Weapon/SwordAnticipateState.cs @@ -14,8 +14,6 @@ public partial class SwordAnticipateState : WeaponState public override WeaponState Enter(IState prevState) { - Sword.EnableParry(); - if (Sword.Character is SupaLidlGame.Characters.Player) { return AttackState; @@ -29,6 +27,7 @@ public partial class SwordAnticipateState : WeaponState { Sword.AnimationPlayer.Play("anticipate"); } + GD.Print("Anticipating time"); _anticipateTime = Sword.NPCAnticipateTime; return null; } diff --git a/State/Weapon/SwordAttackState.cs b/State/Weapon/SwordAttackState.cs index 11014c7..86b8f93 100644 --- a/State/Weapon/SwordAttackState.cs +++ b/State/Weapon/SwordAttackState.cs @@ -23,7 +23,7 @@ public partial class SwordAttackState : WeaponState public override WeaponState Enter(IState prevState) { - //Sword.AnimationPlayer.Stop(); + Sword.EnableParry(); Sword.Attack(); if (_isAlternate)