parrying projectiles
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 28s
Create tag and build when new code gets to main / Export (push) Successful in 6m44s

This commit is contained in:
2026-05-14 16:11:22 +02:00
parent 0cd942d90e
commit a0e99a959f
11 changed files with 166 additions and 81 deletions

View File

@@ -14,6 +14,7 @@
[ext_resource type="PackedScene" uid="uid://duju3atqgltkg" path="res://scenes/explosion/explosion.tscn" id="5_ue7xq"]
[ext_resource type="Resource" uid="uid://t612lts1wi1s" path="res://inputs/base_mode/move_right.tres" id="6_q7bng"]
[ext_resource type="Resource" uid="uid://cffil4tic3ysg" path="res://forge/resources/effect_datas/inhibit_mana_regen_temporarily.tres" id="6_u8yay"]
[ext_resource type="Texture2D" uid="uid://g0u88alm6hcb" path="res://assets/ui/IconGodotNode/node/icon_bullet.png" id="7_2rkt1"]
[ext_resource type="Script" uid="uid://cwbvxlfvmocc1" path="res://scenes/player_controller/scripts/StairsSystem.cs" id="7_bmt5a"]
[ext_resource type="Resource" uid="uid://brswsknpgwal2" path="res://inputs/base_mode/move_front.tres" id="7_m8gvy"]
[ext_resource type="PackedScene" uid="uid://bctpe34ddamg5" path="res://scenes/components/knockback/CKnockback.tscn" id="7_x835q"]
@@ -22,10 +23,13 @@
[ext_resource type="Resource" uid="uid://bs8b0oojixm4q" path="res://scenes/player_controller/resources/player_knockback.tres" id="8_m8gvy"]
[ext_resource type="Resource" uid="uid://c3e0ivgaxrsyb" path="res://inputs/base_mode/aim_down.tres" id="8_obsfv"]
[ext_resource type="PackedScene" uid="uid://wq1okogkhc5l" path="res://scenes/player_controller/components/mantle/mantle_system.tscn" id="8_qu4wy"]
[ext_resource type="PackedScene" uid="uid://bhp6qunnwhncf" path="res://scenes/projectile/Projectile.tscn" id="8_u8yay"]
[ext_resource type="AudioStream" uid="uid://clfggn87oeg1s" path="res://scenes/player_controller/audio/InteractiveSFX.tres" id="9_jb43f"]
[ext_resource type="Resource" uid="uid://bebstkm608wxx" path="res://inputs/base_mode/aim_pressed.tres" id="9_nob5r"]
[ext_resource type="Script" uid="uid://dxtjifb8hv8k4" path="res://forge/abilities/ForgeSpawnProjectileBehavior.cs" id="9_uqalc"]
[ext_resource type="Resource" uid="uid://dccuj66egxfwh" path="res://forge/resources/ability_datas/empowered_action.tres" id="10_2rkt1"]
[ext_resource type="Resource" uid="uid://bdit2jy5gbpts" path="res://inputs/base_mode/jump.tres" id="10_4u7i3"]
[ext_resource type="Script" uid="uid://dhxfbxh54pyxp" path="res://addons/forge/resources/abilities/ForgeAbilityData.cs" id="10_b0xmb"]
[ext_resource type="Script" uid="uid://cxihb42t2mfqi" path="res://addons/forge/nodes/ForgeAttributeSet.cs" id="10_pw5r7"]
[ext_resource type="Script" uid="uid://ccovd5i0wr3kk" path="res://addons/forge/editor/attributes/AttributeValues.cs" id="11_2rkt1"]
[ext_resource type="Resource" uid="uid://b5gx3q8nvu72e" path="res://inputs/base_mode/hit.tres" id="11_cresl"]
@@ -70,6 +74,27 @@ script = ExtResource("11_u8yay")
Tag = "immunity.damage"
metadata/_custom_type_script = "uid://dpakv7agvir6y"
[sub_resource type="Resource" id="Resource_xs7wf"]
script = ExtResource("9_uqalc")
Projectile = ExtResource("8_u8yay")
Name = "Spawn projectile on parry"
Icon = ExtResource("7_2rkt1")
metadata/_custom_type_script = "uid://dxtjifb8hv8k4"
[sub_resource type="Resource" id="Resource_cm4e8"]
script = ExtResource("11_u8yay")
Tag = "events.player.parry"
metadata/_custom_type_script = "uid://dpakv7agvir6y"
[sub_resource type="Resource" id="Resource_cmmfb"]
script = ExtResource("10_b0xmb")
Name = "Parry projectile"
CooldownEffects = null
AbilityBehavior = SubResource("Resource_xs7wf")
TriggerSource = 1
TriggerTag = SubResource("Resource_cm4e8")
metadata/_custom_type_script = "uid://dhxfbxh54pyxp"
[sub_resource type="Resource" id="Resource_abfq8"]
script = ExtResource("3_cb2lu")
Modifier = 5.0
@@ -106,6 +131,9 @@ radius = 0.45
[sub_resource type="SphereShape3D" id="SphereShape3D_q14ux"]
radius = 1.0
[sub_resource type="SphereShape3D" id="SphereShape3D_n24vh"]
radius = 2.25
[sub_resource type="SphereShape3D" id="SphereShape3D_u8rdp"]
radius = 1.5
@@ -149,7 +177,7 @@ EmpoweredActionUsed = SubResource("Resource_5gbhg")
InvincibleTag = SubResource("Resource_2rkt1")
HitAbility = ExtResource("4_u8yay")
EmpoweredActionAbility = ExtResource("10_2rkt1")
DefaultGrantedAbilities = [ExtResource("5_u8yay")]
DefaultGrantedAbilities = [ExtResource("5_u8yay"), SubResource("Resource_cmmfb")]
DefaultPermanentEffects = [ExtResource("5_2rkt1")]
EmpoweredActionEffects = [ExtResource("6_u8yay")]
AimAssistStrength = 0.3
@@ -289,18 +317,28 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
MantleEndLocationDistanceFromWall = 0.3
MantleHeightCastStart = 2.5
[node name="WeaponHitbox" type="Area3D" parent="HeadSystem" unique_id=616313905]
[node name="WeaponHitbox" type="Area3D" parent="." unique_id=616313905]
unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.6, 0)
collision_layer = 0
collision_mask = 16
monitoring = false
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="HeadSystem/WeaponHitbox" unique_id=1617373708]
[node name="CollisionShape3D" type="CollisionShape3D" parent="WeaponHitbox" unique_id=1617373708]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1.5)
shape = SubResource("SphereShape3D_q14ux")
[node name="Parrybox" type="Area3D" parent="." unique_id=1452001086]
unique_name_in_owner = true
collision_layer = 0
collision_mask = 48
monitoring = false
monitorable = false
[node name="CollisionShape3D" type="CollisionShape3D" parent="Parrybox" unique_id=619469543]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -2)
shape = SubResource("SphereShape3D_n24vh")
[node name="StairsSystem" type="Node3D" parent="." unique_id=703342681]
script = ExtResource("7_bmt5a")

View File

@@ -180,11 +180,11 @@ public partial class HeadSystem : Node3D
public void OnParryboxActivated()
{
EmitSignalHitboxActivated();
EmitSignalParryboxActivated();
}
public void OnParryboxDeactivated()
{
EmitSignalHitboxDeactivated();
EmitSignalParryboxDeactivated();
}
internal bool FootstepEmitted;

View File

@@ -579,12 +579,12 @@ tracks/3/keys = {
}
tracks/4/type = "method"
tracks/4/imported = false
tracks/4/enabled = false
tracks/4/enabled = true
tracks/4/path = NodePath("../..")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0.06666667, 0.18333334),
"times": PackedFloat32Array(0.01666667, 0.16666667),
"transitions": PackedFloat32Array(1, 1),
"values": [{
"args": [],

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Chickensoft.AutoInject;
using Chickensoft.Introspection;
using Chickensoft.Sync.Primitives;
@@ -22,6 +23,7 @@ using Godot;
using GodotStateCharts;
using Movementtests.addons.godot_state_charts.csharp;
using Movementtests.forge.abilities;
using Movementtests.interfaces;
using Movementtests.systems;
using Movementtests.player_controller.Scripts;
@@ -39,6 +41,8 @@ public record struct EmpoweredActionPayload;
public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandler, IDisposable, ITargetable
{
public override void _Notification(int what) => this.Notify(what);
public record struct OnParryPayload(Vector3 ForwardVector);
#region Dependencies
[Dependency]
@@ -97,6 +101,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
[Node("CeilingDetector")] public required ShapeCast3D CeilingDetector { get; set; }
[Node("DirectGroundDetector")] public required RayCast3D DirectGroundDetector { get; set; }
[Node("%WeaponHitbox")] public required Area3D WeaponHitbox { get; set; }
[Node("%Parrybox")] public required Area3D Parrybox { get; set; }
[Node("SFXPlayer")] public required AudioStreamPlayer3D SfxPlayer { get; set; }
[Node("DashDamage")] public required ShapeCast3D DashDamageDetector { get; set; }
[Node("SlidingEnemyDetector")] public required Area3D SlidingEnemyDetector { get; set; }
@@ -461,6 +466,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
// Damage dealing
private readonly List<IForgeEntity> _hitEnemies = [];
private readonly List<IForgeEntity> _parriedEntities = [];
#endregion
@@ -506,8 +512,8 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
_playerRadius = playerShape.Radius;
// Combat stuff
WeaponHitbox.Monitoring = false;
WeaponHitbox.BodyEntered += RegisterHitEnnemy;
Parrybox.BodyEntered += RegisterParry;
#region StateManagement
@@ -569,6 +575,8 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
HeadSystem.Init();
HeadSystem.HitboxActivated += OnHitboxActivated;
HeadSystem.HitboxDeactivated += OnHitboxDeactivated;
HeadSystem.ParryboxActivated += OnParryboxActivated;
HeadSystem.ParryboxDeactivated += OnParryboxDeactivated;
HeadSystem.StepFoot += OnFootStepped;
HeadSystem.DeathAnimationFinished += OnDeathAnimationFinished;
@@ -1150,6 +1158,9 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
var wallHugContactPoint = _onWallRunning.Active ? _currentWallContactPoint : Vector3.Zero;
var moveInput = GetGlobalMoveInput();
WeaponHitbox.SetRotation(HeadSystem.GetGlobalLookRotation());
Parrybox.SetRotation(HeadSystem.GetGlobalLookRotation());
if (_isUsingGamepad)
inputLookDir += ComputeAimAssist();
@@ -2125,7 +2136,7 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
if (!HasParry) return;
var attackToDo = _isEnemyInDashAttackRange ? "dash_parry" : "standard_parry";
_playerState.SendEvent(attackToDo);
_playerState.SendEvent("standard_parry");
}
///////////////////////////
@@ -2579,14 +2590,49 @@ public partial class PlayerController : CharacterBody3D, IForgeEntity, ICueHandl
WeaponHitbox.Monitoring = false;
TriggerDamage();
}
public void OnParryboxActivated()
{
Parrybox.Monitoring = true;
}
public void OnParryboxDeactivated()
{
Parrybox.Monitoring = false;
TriggerParry();
}
public void RegisterHitEnnemy(Node3D body)
{
if (body is not IForgeEntity entity) return;
_hitEnemies.Add(entity);
// return;
// if (body is not IDamageable damageable) return;
// _hitEnemies.Add(damageable);
}
public void RegisterParry(Node3D body)
{
if (body is not IForgeEntity entity) return;
_parriedEntities.Add(entity);
// TriggerParry();
}
public void TriggerParry()
{
var payload = new OnProjectileSpawned(
Direction: -HeadSystem.GetGlobalForwardVector(),
SpeedMultiplier: 100,
SpawnOffset: -HeadSystem.GetGlobalForwardVector(),
CollisionOverride: WeaponSystem.CollisionMask);
foreach (var entity in _parriedEntities.Where(entity => IsInstanceValid(entity as Node)))
{
Events.Raise(new EventData<OnProjectileSpawned>
{
EventTags = Tag.RequestTag(TagsManager, "events.player.parry").GetSingleTagContainer()!,
Source = this,
Payload = payload
});
if (entity is IKillable killable) killable.Kill();
else if (entity is Node node) node.QueueFree();
}
_parriedEntities.Clear();
}
public void TriggerDamage()