From b3a28436bc7077d64a7ccace56c7cfb7231b1651 Mon Sep 17 00:00:00 2001 From: Minimata Date: Wed, 21 May 2025 17:15:40 +0200 Subject: [PATCH] ld: basic greyboxing --- .../player_controller/Scripts/HealthSystem.cs | 8 +-- main.tscn | 66 +++++++++++++++++-- scenes/player.tscn | 4 +- 3 files changed, 68 insertions(+), 10 deletions(-) diff --git a/addons/player_controller/Scripts/HealthSystem.cs b/addons/player_controller/Scripts/HealthSystem.cs index 6f06028..eb15098 100644 --- a/addons/player_controller/Scripts/HealthSystem.cs +++ b/addons/player_controller/Scripts/HealthSystem.cs @@ -21,6 +21,8 @@ public partial class HealthSystem : Node3D public float CurrentHealth { get; set; } = 100.0f; [Export(PropertyHint.Range, "0,100,0.1,or_greater")] public float MinimalDamageUnit { get; set; } = 25.0f; + [Export(PropertyHint.Range, "-100,0,0.1,or_smaller")] + public float ThresholdVelYForDamage { get; set; } = -15.0f; [ExportSubgroup("Regeneration")] [Export(PropertyHint.Range, "0,10,0.01,suffix:s,or_greater")] public float SecondsBeforeRegeneration { get; set; } = 5.5f; @@ -104,8 +106,6 @@ public partial class HealthSystem : Node3D // Required to hide Vignette effect private float _currentHealthInPrevFrame; - private float _thresholdVelYForDamage = -15.0f; - private float _currentVelocityYInAir; private Gravity _gravity; @@ -441,10 +441,10 @@ public partial class HealthSystem : Node3D } else { - if (_currentVelocityYInAir < _thresholdVelYForDamage) + if (_currentVelocityYInAir < ThresholdVelYForDamage && ThresholdVelYForDamage > 0) { float hit = Mathf.Remap(_currentVelocityYInAir, - _thresholdVelYForDamage, _thresholdVelYForDamage - 9.0f, + ThresholdVelYForDamage, ThresholdVelYForDamage - 9.0f, MinimalDamageUnit, MaxHealth); GD.Print("Hit damage: ", hit); diff --git a/main.tscn b/main.tscn index 59276c3..494d0cc 100644 --- a/main.tscn +++ b/main.tscn @@ -21,13 +21,71 @@ glow_enabled = true environment = SubResource("Environment_1bvp3") [node name="DirectionalLight3D" type="DirectionalLight3D" parent="."] -transform = Transform3D(-0.866023, -0.433016, 0.250001, 0, 0.499998, 0.866027, -0.500003, 0.749999, -0.43301, 0, 0, 0) +transform = Transform3D(-0.866024, -0.433016, 0.250001, -0.320371, 0.864432, 0.387452, -0.383882, 0.255449, -0.887345, 0, 0, 0) shadow_enabled = true -[node name="CSGBox3D" type="CSGBox3D" parent="."] +[node name="Player" parent="." instance=ExtResource("1_ig7tw")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.25692, 0.0273442, 30.8297) + +[node name="Greybox" type="Node" parent="."] + +[node name="CSGBox3D" type="CSGBox3D" parent="Greybox"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.09619, -0.472656, -0.958893) use_collision = true size = Vector3(100, 1, 100) -[node name="Player" parent="." instance=ExtResource("1_ig7tw")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.03971, 0.0273442, -0.249186) +[node name="CSGBox3D2" type="CSGBox3D" parent="Greybox"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -22.4157, 5, 14.9013) +use_collision = true +size = Vector3(10, 10, 50) + +[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Greybox"] +use_collision = true + +[node name="CSGBox3D5" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.0294, 0.5, 32.891) +size = Vector3(3, 1, 3) + +[node name="CSGBox3D6" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 1, 29.905) +size = Vector3(3, 2, 3) + +[node name="CSGBox3D7" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 1.5, 26.9138) +size = Vector3(3, 3, 3) + +[node name="CSGBox3D8" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 2, 23.9462) +size = Vector3(3, 4, 3) + +[node name="CSGBox3D9" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 2.5, 20.975) +size = Vector3(3, 5, 3) + +[node name="CSGBox3D10" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 3, 17.9825) +size = Vector3(3, 6, 3) + +[node name="CSGBox3D11" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 3.5, 15) +size = Vector3(3, 7, 3) + +[node name="CSGBox3D12" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 4, 12.018) +size = Vector3(3, 8, 3) + +[node name="CSGBox3D13" type="CSGBox3D" parent="Greybox/CSGCombiner3D"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.029, 4.5, 9.04904) +size = Vector3(3, 9, 3) + +[node name="CSGBox3D3" type="CSGBox3D" parent="Greybox"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4.01999, 4.9845, 6.27246) +use_collision = true +size = Vector3(43.9793, 10, 2.62695) + +[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Greybox/CSGBox3D3"] +transform = Transform3D(4.2, 0, 0, 0, -6.11959e-08, -7, 0, 1.4, -3.0598e-07, 8, -5, -0.293446) +operation = 2 +radius = 1.0 +height = 5.0 +sides = 40 diff --git a/scenes/player.tscn b/scenes/player.tscn index 0b499ee..3c7663e 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -4,5 +4,5 @@ [node name="Player" instance=ExtResource("1_3vyb7")] -[node name="Stamina" parent="." index="4"] -MaxRunTime = 0.0 +[node name="HealthSystem" parent="." index="3"] +ThresholdVelYForDamage = 0.0