diff --git a/maps/levels/tuto_sword_parry.tscn b/maps/levels/tuto_sword_parry.tscn index 6ce07027..5c37b157 100644 --- a/maps/levels/tuto_sword_parry.tscn +++ b/maps/levels/tuto_sword_parry.tscn @@ -245,31 +245,37 @@ Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy10" parent="Playground/GroundedEnemies" index="19" unique_id=836898496 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy27" parent="Playground/GroundedEnemies" index="19" unique_id=854456486 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 20, 0, -44.836807) +Target = NodePath("../../../Player") +RHealth = SubResource("Resource_xy0m1") +RMovement = SubResource("Resource_nwk5u") + +[node name="Enemy10" parent="Playground/GroundedEnemies" index="20" unique_id=836898496 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 30.5, 11, -33.336807) Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy8" parent="Playground/GroundedEnemies" index="20" unique_id=1015624071 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy8" parent="Playground/GroundedEnemies" index="21" unique_id=1015624071 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 34.5, 1.5, -27.33681) Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy9" parent="Playground/GroundedEnemies" index="21" unique_id=827865590 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy9" parent="Playground/GroundedEnemies" index="22" unique_id=827865590 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 46.5, 0, -27.33681) Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy5" parent="Playground/GroundedEnemies" index="22" unique_id=1267116862 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy5" parent="Playground/GroundedEnemies" index="23" unique_id=1267116862 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 4, 0, -18.33681) Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") RMovement = SubResource("Resource_nwk5u") -[node name="Enemy6" parent="Playground/GroundedEnemies" index="23" unique_id=1147823180 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] +[node name="Enemy6" parent="Playground/GroundedEnemies" index="24" unique_id=1147823180 node_paths=PackedStringArray("Target") instance=ExtResource("5_ofbe2")] transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, 16.5, 7, -17.33681) Target = NodePath("../../../Player") RHealth = SubResource("Resource_xy0m1") diff --git a/scenes/player_controller/PlayerController.tscn b/scenes/player_controller/PlayerController.tscn index 185861b7..cd04db49 100644 --- a/scenes/player_controller/PlayerController.tscn +++ b/scenes/player_controller/PlayerController.tscn @@ -77,6 +77,9 @@ radius = 0.45 [sub_resource type="SphereShape3D" id="SphereShape3D_q14ux"] radius = 1.0 +[sub_resource type="SphereShape3D" id="SphereShape3D_u8rdp"] +radius = 1.5 + [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nodcl"] transparency = 1 albedo_color = Color(0, 0.627451, 0.6313726, 0.49019608) @@ -328,6 +331,14 @@ gravity_scale = 3.0 ThrowForce = 300.0 StraightThrowDuration = 0.05 +[node name="SwordPickup" type="Area3D" parent="." unique_id=1990087390] +collision_layer = 0 +collision_mask = 65536 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="SwordPickup" unique_id=547241277] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0) +shape = SubResource("SphereShape3D_u8rdp") + [node name="DashIndicator" type="Node3D" parent="." unique_id=1279477982] visible = false @@ -384,6 +395,10 @@ shape = SubResource("SphereShape3D_ue7xq") [node name="InvincibilityTime" type="Timer" parent="." unique_id=1244463585] one_shot = true +[node name="WeaponThrowUncatchable" type="Timer" parent="." unique_id=2141801011] +wait_time = 0.2 +one_shot = true + [node name="AttackCooldown" type="Timer" parent="." unique_id=1620959518] wait_time = 0.3 one_shot = true @@ -1159,3 +1174,4 @@ delay_in_seconds = "0.0" [connection signal="input_slide_ended" from="InputController" to="." method="OnInputSlideEnded"] [connection signal="input_slide_started" from="InputController" to="." method="OnInputSlideStarted"] [connection signal="WallDetected" from="WallHugSystem" to="." method="OnWallDetected"] +[connection signal="body_entered" from="SwordPickup" to="." method="WalkOnWeapon"] diff --git a/scenes/player_controller/scripts/PlayerController.cs b/scenes/player_controller/scripts/PlayerController.cs index 34ccd536..3639ab3c 100644 --- a/scenes/player_controller/scripts/PlayerController.cs +++ b/scenes/player_controller/scripts/PlayerController.cs @@ -317,6 +317,7 @@ public partial class PlayerController : CharacterBody3D, // Timers private Timer _timeScaleAimInAirTimer; + private Timer _weaponThrowUncatchableTimer; private Timer _simpleDashCooldownTimer; private Timer _airborneDashCooldownTimer; private Timer _powerCooldownTimer; @@ -516,6 +517,7 @@ public partial class PlayerController : CharacterBody3D, // State timers _powerCooldownTimer = GetNode("PowerCooldown"); + _weaponThrowUncatchableTimer = GetNode("WeaponThrowUncatchable"); _timeScaleAimInAirTimer = GetNode("TimeScaleAimInAir"); _simpleDashCooldownTimer = GetNode("DashCooldown"); _airborneDashCooldownTimer = GetNode("AirborneDashCooldown"); @@ -1892,7 +1894,7 @@ public partial class PlayerController : CharacterBody3D, var plannedDashLocation = targetable.GetTargetGlobalPosition() + Vector3.Down*_playerHeight/2; travel = plannedDashLocation - GlobalPosition; _dashDirection = travel.Normalized(); - var postDashLocation = plannedDashLocation + 2*_dashDirection; + var postDashLocation = plannedDashLocation + _dashDirection; var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask); var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery); shouldRebound = wallBehindResult.Count > 0; @@ -1960,6 +1962,7 @@ public partial class PlayerController : CharacterBody3D, public void ThrowWeapon() { _audioStream.SwitchToClipByName("attacks"); + _weaponThrowUncatchableTimer.Start(); _playerState.SendEvent("cancel_aim"); RemoveChildNode(WeaponSystem); @@ -1980,6 +1983,7 @@ public partial class PlayerController : CharacterBody3D, HeadSystem.ShowWeapon(); WeaponSystem.ResetWeapon(); RecoverChildNode(WeaponSystem); + _audioStream.SwitchToClipByName("parry"); } public void DashToFlyingWeapon() @@ -2061,6 +2065,16 @@ public partial class PlayerController : CharacterBody3D, _playerState.SendEvent(resultingEvent); } + public void WalkOnWeapon(Node3D other) + { + if (_weaponDash.Active) return; // Don't recover weapon if already dashing to it + if (WeaponSystem.InHandState.Active) return; // Don't recover weapon if in hand + if (!_weaponThrowUncatchableTimer.IsStopped()) return; // Don't get weapon back if timer is still running + if (WeaponSystem.PlantObject is ITargetable) return; // Don't recover weapon planted in target + + RecoverWeapon(); + WeaponSystem.PlantObject = null; + } public void ManageAttackedEnemyPostDash(Node enemy) { @@ -2229,7 +2243,7 @@ public partial class PlayerController : CharacterBody3D, var travel = plannedDashLocation - GlobalPosition; _dashDirection = travel.Normalized(); - var postDashLocation = plannedDashLocation + 2*_dashDirection; + var postDashLocation = plannedDashLocation + _dashDirection; var wallBehindQuery = PhysicsRayQueryParameters3D.Create(GlobalPosition + Vector3.Up*HeadSystem.Position.Y, postDashLocation, GroundDetector.CollisionMask); var wallBehindResult = _spaceState.IntersectRay(wallBehindQuery); var shouldRebound = wallBehindResult.Count > 0; @@ -2293,7 +2307,7 @@ public partial class PlayerController : CharacterBody3D, if (_onWallHanging.Active) return; - if (_aiming.Active && WeaponSystem.InHandState.Active) + if (_aiming.Active && WeaponSystem.InHandState.Active && CanPerformEmpoweredAction()) { ThrowWeapon(); return;