From 7a4ed2d6dc776cecc47c46ea9e41c52fa9036d71 Mon Sep 17 00:00:00 2001 From: danny Date: Mon, 6 Jul 2026 17:15:07 +0200 Subject: [PATCH] CRs: Sparring-Kampfsystem (HP/Ausdauer/Block) + Sparringhalle & Kartenraum - Actions attack (Linksklick/R2) und block (Rechtsklick/Quadrat-X), SPEC 9 - sparring_fight.gd: Echtzeit-Duell mit Gegner-HP 20 (3-5 Treffer je nach Kraft), Telegraph-Block (Fenster skaliert mit Schnelligkeit), Ausdauer mit Guard-Break und schwachen Schlaegen, interner Gegner-Ausdauer als Taktgeber, HUD mit drei Balken; nie toedlich, Sieg/Niederlage muenden in die bestehenden Klinge/Herz-Dialoge mit Ton- und Standing-Effekten - Neue Raeume: sparring_hall.tscn (Ring, Sparringspartner, Kampftraining) und map_room.tscn (Kartentisch, Landnavigation); Aussen-Stationen aus dem Quadranten entfernt, Zonen-Trigger + Spawns beidseitig - Headless verifiziert (26 Checks): Uebergaenge, Slot-Verbrauch, Schadens-Skalierung, Ausdauer, Block+Stagger, Niederlage ohne Tod bei Permadeath AN, Ton-/Standing-Effekte beider Ausgaenge Co-Authored-By: Claude Fable 5 --- docs/CHANGEREQUESTS.md | 2 +- docs/CHANGEREQUESTS_DONE.md | 35 +++ docs/SPEC.md | 2 + project.godot | 12 + scenes/hub/map_room.tscn | 222 +++++++++++++++++++ scenes/hub/rider_quadrant.tscn | 199 +++++------------ scenes/hub/sparring_hall.tscn | 266 +++++++++++++++++++++++ scripts/gameplay/sparring_fight.gd | 264 ++++++++++++++++++++++ scripts/gameplay/sparring_fight.gd.uid | 1 + scripts/gameplay/sparring_station.gd | 79 ------- scripts/gameplay/sparring_station.gd.uid | 1 - 11 files changed, 852 insertions(+), 231 deletions(-) create mode 100644 scenes/hub/map_room.tscn create mode 100644 scenes/hub/sparring_hall.tscn create mode 100644 scripts/gameplay/sparring_fight.gd create mode 100644 scripts/gameplay/sparring_fight.gd.uid delete mode 100644 scripts/gameplay/sparring_station.gd delete mode 100644 scripts/gameplay/sparring_station.gd.uid diff --git a/docs/CHANGEREQUESTS.md b/docs/CHANGEREQUESTS.md index a9474e9..e4a0650 100644 --- a/docs/CHANGEREQUESTS.md +++ b/docs/CHANGEREQUESTS.md @@ -2,4 +2,4 @@ > Hier schreibe ich Änderungen auf die mir während dem Test auffällt. Bitte arbeite die bei jeder Phase vorher ab sodass hier alles erledifgt ist -> Erledigte Punkte Löscht du bitte sodass diese nicht ausversehen doppelt gemacht werden. Die Erledigten Punkte sollen dann Bitte in die Datei CHANGEREQUESTS_DONE rein mit einer Anmerkung von dir wann geändert und was du getan hast. \ No newline at end of file +> Erledigte Punkte Löscht du bitte sodass diese nicht ausversehen doppelt gemacht werden. Die Erledigten Punkte sollen dann Bitte in die Datei CHANGEREQUESTS_DONE rein mit einer Anmerkung von dir wann geändert und was du getan hast. diff --git a/docs/CHANGEREQUESTS_DONE.md b/docs/CHANGEREQUESTS_DONE.md index c29688b..2dc8d4f 100644 --- a/docs/CHANGEREQUESTS_DONE.md +++ b/docs/CHANGEREQUESTS_DONE.md @@ -3,6 +3,41 @@ > Abgearbeitete Change Requests aus CHANGEREQUESTS.md, mit Datum und > Anmerkung, was geändert wurde. +## 2026-07-06 — Sparringhalle & Kartenraum als eigene Räume + +**Request:** „Sparring Halle & andere Fächer soll eigene Räume sein wie in +den Büchern Beschrieben." + +**Umsetzung:** Zwei neue Greybox-Räume mit Zonen-Übergängen vom +Reiterquadranten: die Sparringhalle (Ring-Matte, Sparringspartner, +Kampftraining-Station) im Westen und der Kartenraum (Kartentisch, +Landnavigations-Station) im Osten. Geschichte & RSC bleibt im +Klassenraum. Die drei Außen-Stationen im Quadranten sind entfernt; alle +Spawns/Trigger beidseitig verdrahtet. + +## 2026-07-06 — Echtes Sparring-Kampfsystem mit HP und Ausdauer + +**Request:** Echter Kampf mit Linksklick schlagen / Rechtsklick blocken, +Trefferpunkte-Leiste (3–5 Treffer), Kraft → Schaden, Schnelligkeit → +Blockfenster, nie tödlich, Klinge/Herz-Entscheidung am Ende; HP-Balken +für beide, Ausdauer-Balken für Tyrveil, interne Gegner-Ausdauer ohne +Balken. + +**Umsetzung:** Neue Input-Actions `attack` (Linksklick / R2) und `block` +(Rechtsklick / ▢ bzw. Ⓧ, Button 2 — L2 und Schultertasten sind belegt), +SPEC §9 ergänzt. sparring_fight.gd: Gegner-HP 20, Schaden = 4 + 1 je +volle 10 Kraft über 30 (35→5 Treffer, 45→4, 65→3); Blockfenster = +Telegraph-Dauer 0,5 s + 0,015 s je Schnelligkeitspunkt über 35 (0,4–0,9 s); +Tyrveil-HP 5; Ausdauer 100, Schlagen −20, Blocken −15, Regeneration 25/s, +unter 15 Guard-Break (kein Block), unter 20 halber Schlagschaden; +Gegner-Ausdauer 100 intern (Angriff kostet 30, Regeneration 20/s, steuert +das Tempo, kein Balken). Erfolgreicher Block staggert den Gegner 1 s. +HUD mit drei Balken während des Kampfes. Kampfstart verbraucht den +Tages-Slot; Sieg mündet in die bestehende Klinge/Herz-Wahl +(sparring_win.json: fertigmachen vs. aufhelfen), Niederlage in +sparring_loss.json — nie tödlich, auch bei Permadeath AN (headless +verifiziert, 26 Checks). + ## 2026-07-05 — Charakter-Umbenennung entfernt **Request:** „ich möchte doch nicht das man den Char umnennen kann. Man ist diff --git a/docs/SPEC.md b/docs/SPEC.md index 32d61e5..dbaf08a 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -104,6 +104,8 @@ Tastatur + Xbox/PS5. Deadzone 0.2 für Sticks/Trigger. - `slide` — C / Linker Trigger (L2/LT) (Zum Rutschen auf dem Boden) - `jump` — Leertaste / Ⓐ / ✕ (Wird beim Laufen gegen Wände automatisch für das Klettern/Hochziehen getriggert) - `dialogue_abort` — X (bricht laufende Gespräche ab; `cancel` bricht ebenfalls ab) +- `attack` — Linksklick / R2 (Schlagen im Sparring) +- `block` — Rechtsklick / ▢(PS5) Ⓧ(Xbox) (button_index 2, Blocken im Sparring) UI nutzt `confirm`/`cancel`/`menu` + Focus-Navigation. ## 10. Phasen-Roadmap diff --git a/project.godot b/project.godot index 67229e2..a5c2375 100644 --- a/project.godot +++ b/project.godot @@ -141,3 +141,15 @@ dialogue_abort={ "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":88,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) ] } +attack={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":5,"axis_value":1.0,"script":null) +] +} +block={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":2,"pressure":0.0,"pressed":false,"script":null) +] +} diff --git a/scenes/hub/map_room.tscn b/scenes/hub/map_room.tscn new file mode 100644 index 0000000..8d590bc --- /dev/null +++ b/scenes/hub/map_room.tscn @@ -0,0 +1,222 @@ +[gd_scene load_steps=28 format=3] + +[ext_resource type="Script" path="res://scripts/gameplay/hub_room.gd" id="1_room"] +[ext_resource type="PackedScene" path="res://scenes/player.tscn" id="2_player"] +[ext_resource type="PackedScene" path="res://scenes/ui/debug_overlay.tscn" id="3_debug"] +[ext_resource type="Script" path="res://scripts/gameplay/zone_trigger.gd" id="4_zone"] +[ext_resource type="Script" path="res://scripts/gameplay/training_station.gd" id="5_station"] +[ext_resource type="PackedScene" path="res://scenes/ui/speech_bubble.tscn" id="6_bubble"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_sky"] +sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) +ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) + +[sub_resource type="Sky" id="Sky_sky"] +sky_material = SubResource("ProceduralSkyMaterial_sky") + +[sub_resource type="Environment" id="Environment_env"] +background_mode = 2 +sky = SubResource("Sky_sky") +tonemap_mode = 2 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_floor"] +albedo_color = Color(0.4, 0.38, 0.33, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_floor"] +size = Vector3(14, 1, 10) + +[sub_resource type="BoxMesh" id="BoxMesh_floor"] +material = SubResource("StandardMaterial3D_floor") +size = Vector3(14, 1, 10) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_structure"] +albedo_color = Color(0.5, 0.48, 0.45, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wall_ns"] +size = Vector3(15, 3, 0.5) + +[sub_resource type="BoxMesh" id="BoxMesh_wall_ns"] +material = SubResource("StandardMaterial3D_structure") +size = Vector3(15, 3, 0.5) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wall_ew"] +size = Vector3(0.5, 3, 11) + +[sub_resource type="BoxMesh" id="BoxMesh_wall_ew"] +material = SubResource("StandardMaterial3D_structure") +size = Vector3(0.5, 3, 11) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_table"] +albedo_color = Color(0.5, 0.4, 0.28, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_table"] +size = Vector3(3, 1, 1.5) + +[sub_resource type="BoxMesh" id="BoxMesh_table"] +material = SubResource("StandardMaterial3D_table") +size = Vector3(3, 1, 1.5) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_navigation"] +albedo_color = Color(0.3, 0.6, 0.6, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_navigation"] +material = SubResource("StandardMaterial3D_navigation") +size = Vector3(1.2, 1.2, 1.2) + +[sub_resource type="BoxShape3D" id="BoxShape3D_station"] +size = Vector3(1.2, 1.2, 1.2) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_trigger"] +transparency = 1 +albedo_color = Color(0.3, 0.8, 1, 0.35) + +[sub_resource type="BoxShape3D" id="BoxShape3D_door_s"] +size = Vector3(2, 2, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_door_s"] +material = SubResource("StandardMaterial3D_trigger") +size = Vector3(2, 2, 1) + +[sub_resource type="SphereShape3D" id="SphereShape3D_interact"] +radius = 2.5 + +[node name="MapRoom" type="Node3D"] +script = ExtResource("1_room") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_env") + +[node name="Sun" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.866025, 0.383022, -0.321394, 0, 0.642788, 0.766044, 0.5, -0.663414, 0.55667, 0, 12, 0) +shadow_enabled = true + +[node name="Floor" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor"] +shape = SubResource("BoxShape3D_floor") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor"] +mesh = SubResource("BoxMesh_floor") + +[node name="Walls" type="Node3D" parent="."] + +[node name="WallNorth" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -5.25) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallNorth"] +shape = SubResource("BoxShape3D_wall_ns") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallNorth"] +mesh = SubResource("BoxMesh_wall_ns") + +[node name="WallSouth" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 5.25) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallSouth"] +shape = SubResource("BoxShape3D_wall_ns") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallSouth"] +mesh = SubResource("BoxMesh_wall_ns") + +[node name="WallEast" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.25, 1.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallEast"] +shape = SubResource("BoxShape3D_wall_ew") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallEast"] +mesh = SubResource("BoxMesh_wall_ew") + +[node name="WallWest" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.25, 1.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallWest"] +shape = SubResource("BoxShape3D_wall_ew") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallWest"] +mesh = SubResource("BoxMesh_wall_ew") + +[node name="MapTable" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, -3) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="MapTable"] +shape = SubResource("BoxShape3D_table") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="MapTable"] +mesh = SubResource("BoxMesh_table") + +[node name="NavigationStation" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 0, -3) +script = ExtResource("5_station") +station_name = "Landnavigation" +stat_name = "agility" +success_line = "Karte, Gelände, Wind — es fügt sich zusammen." + +[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) +shape = SubResource("BoxShape3D_station") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="NavigationStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) +mesh = SubResource("BoxMesh_navigation") + +[node name="NameLabel" type="Label3D" parent="NavigationStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) +billboard = 1 +text = "Landnavigation" +font_size = 56 +outline_size = 14 + +[node name="PromptLabel" type="Label3D" parent="NavigationStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +visible = false +modulate = Color(1, 0.9, 0.5, 1) +billboard = 1 +text = "E / (A) — Üben" +font_size = 40 +outline_size = 12 + +[node name="InteractionArea" type="Area3D" parent="NavigationStation"] +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationStation/InteractionArea"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("SphereShape3D_interact") + +[node name="SpeechBubble" parent="NavigationStation" instance=ExtResource("6_bubble")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.6, 0) + +[node name="Triggers" type="Node3D" parent="."] + +[node name="TriggerRiderQuadrant" type="Area3D" parent="Triggers"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 4.4) +collision_layer = 0 +collision_mask = 2 +script = ExtResource("4_zone") +target_scene_path = "res://scenes/hub/rider_quadrant.tscn" +target_spawn_name = "FromMapRoom" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Triggers/TriggerRiderQuadrant"] +shape = SubResource("BoxShape3D_door_s") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Triggers/TriggerRiderQuadrant"] +mesh = SubResource("BoxMesh_door_s") + +[node name="Label3D" type="Label3D" parent="Triggers/TriggerRiderQuadrant"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +billboard = 1 +text = "Zum Reiterquadrant" +font_size = 40 +outline_size = 12 + +[node name="SpawnPoints" type="Node3D" parent="."] + +[node name="FromRiderQuadrant" type="Marker3D" parent="SpawnPoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 2.8) + +[node name="Player" parent="." instance=ExtResource("2_player")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 2.8) + +[node name="DebugOverlay" parent="." instance=ExtResource("3_debug")] diff --git a/scenes/hub/rider_quadrant.tscn b/scenes/hub/rider_quadrant.tscn index eba61c8..f1ec62c 100644 --- a/scenes/hub/rider_quadrant.tscn +++ b/scenes/hub/rider_quadrant.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=48 format=3] +[gd_scene load_steps=39 format=3] [ext_resource type="Script" path="res://scripts/gameplay/hub_room.gd" id="1_room"] [ext_resource type="PackedScene" path="res://scenes/player.tscn" id="2_player"] @@ -7,8 +7,6 @@ [ext_resource type="Script" path="res://scripts/gameplay/zone_trigger.gd" id="5_zone"] [ext_resource type="PackedScene" path="res://scenes/ui/speech_bubble.tscn" id="6_bubble"] [ext_resource type="Script" path="res://scripts/gameplay/ambient_chatter.gd" id="7_chatter"] -[ext_resource type="Script" path="res://scripts/gameplay/training_station.gd" id="8_station"] -[ext_resource type="Script" path="res://scripts/gameplay/sparring_station.gd" id="9_sparring"] [ext_resource type="Script" path="res://scripts/gameplay/jack_ambush.gd" id="10_jack"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_sky"] @@ -104,30 +102,6 @@ height = 1.8 [sub_resource type="SphereShape3D" id="SphereShape3D_interact"] radius = 2.5 -[sub_resource type="BoxShape3D" id="BoxShape3D_station"] -size = Vector3(1.2, 1.2, 1.2) - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_combat"] -albedo_color = Color(0.7, 0.32, 0.25, 1) - -[sub_resource type="BoxMesh" id="BoxMesh_combat"] -material = SubResource("StandardMaterial3D_combat") -size = Vector3(1.2, 1.2, 1.2) - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_navigation"] -albedo_color = Color(0.3, 0.6, 0.6, 1) - -[sub_resource type="BoxMesh" id="BoxMesh_navigation"] -material = SubResource("StandardMaterial3D_navigation") -size = Vector3(1.2, 1.2, 1.2) - -[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_sparring"] -albedo_color = Color(0.5, 0.35, 0.35, 1) - -[sub_resource type="BoxMesh" id="BoxMesh_sparring"] -material = SubResource("StandardMaterial3D_sparring") -size = Vector3(1.2, 1.2, 1.2) - [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_jack"] albedo_color = Color(0.35, 0.18, 0.18, 1) @@ -461,6 +435,48 @@ text = "Zum Schlafsaal" font_size = 48 outline_size = 12 +[node name="TriggerSparringHall" type="Area3D" parent="Triggers"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -19, 1, 4) +collision_layer = 0 +collision_mask = 2 +script = ExtResource("5_zone") +target_scene_path = "res://scenes/hub/sparring_hall.tscn" +target_spawn_name = "FromRiderQuadrant" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Triggers/TriggerSparringHall"] +shape = SubResource("BoxShape3D_trigger") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Triggers/TriggerSparringHall"] +mesh = SubResource("BoxMesh_trigger") + +[node name="Label3D" type="Label3D" parent="Triggers/TriggerSparringHall"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +billboard = 1 +text = "Zur Sparringhalle" +font_size = 48 +outline_size = 12 + +[node name="TriggerMapRoom" type="Area3D" parent="Triggers"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19, 1, 4) +collision_layer = 0 +collision_mask = 2 +script = ExtResource("5_zone") +target_scene_path = "res://scenes/hub/map_room.tscn" +target_spawn_name = "FromRiderQuadrant" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Triggers/TriggerMapRoom"] +shape = SubResource("BoxShape3D_trigger") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Triggers/TriggerMapRoom"] +mesh = SubResource("BoxMesh_trigger") + +[node name="Label3D" type="Label3D" parent="Triggers/TriggerMapRoom"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +billboard = 1 +text = "Zum Kartenraum" +font_size = 48 +outline_size = 12 + [node name="TriggerClassroom" type="Area3D" parent="Triggers"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 1, -19) collision_layer = 0 @@ -490,6 +506,12 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8, 0.1, -16) [node name="FromClassroom" type="Marker3D" parent="SpawnPoints"] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8, 0.1, -16) +[node name="FromSparringHall" type="Marker3D" parent="SpawnPoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.5, 0.1, 4) + +[node name="FromMapRoom" type="Marker3D" parent="SpawnPoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16.5, 0.1, 4) + [node name="NpcWaypoints" type="Node3D" parent="."] [node name="ImogenA" type="Marker3D" parent="NpcWaypoints"] @@ -540,129 +562,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -8) [node name="AmbientChatter" type="Node" parent="."] script = ExtResource("7_chatter") -[node name="CombatStation" type="StaticBody3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -14, 0, 12) -script = ExtResource("8_station") -station_name = "Kampftraining" -stat_name = "strength" -success_line = "Die Schultern brennen. Gut so." - -[node name="CollisionShape3D" type="CollisionShape3D" parent="CombatStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -shape = SubResource("BoxShape3D_station") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="CombatStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -mesh = SubResource("BoxMesh_combat") - -[node name="NameLabel" type="Label3D" parent="CombatStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) -billboard = 1 -text = "Kampftraining" -font_size = 56 -outline_size = 14 - -[node name="PromptLabel" type="Label3D" parent="CombatStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) -visible = false -modulate = Color(1, 0.9, 0.5, 1) -billboard = 1 -text = "E / (A) — Üben" -font_size = 40 -outline_size = 12 - -[node name="InteractionArea" type="Area3D" parent="CombatStation"] -collision_layer = 0 -collision_mask = 2 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="CombatStation/InteractionArea"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) -shape = SubResource("SphereShape3D_interact") - -[node name="SpeechBubble" parent="CombatStation" instance=ExtResource("6_bubble")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.6, 0) - -[node name="NavigationStation" type="StaticBody3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 16, 0, 10) -script = ExtResource("8_station") -station_name = "Landnavigation" -stat_name = "agility" -success_line = "Karte, Gelände, Wind — es fügt sich zusammen." - -[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -shape = SubResource("BoxShape3D_station") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="NavigationStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -mesh = SubResource("BoxMesh_navigation") - -[node name="NameLabel" type="Label3D" parent="NavigationStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) -billboard = 1 -text = "Landnavigation" -font_size = 56 -outline_size = 14 - -[node name="PromptLabel" type="Label3D" parent="NavigationStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) -visible = false -modulate = Color(1, 0.9, 0.5, 1) -billboard = 1 -text = "E / (A) — Üben" -font_size = 40 -outline_size = 12 - -[node name="InteractionArea" type="Area3D" parent="NavigationStation"] -collision_layer = 0 -collision_mask = 2 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationStation/InteractionArea"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) -shape = SubResource("SphereShape3D_interact") - -[node name="SpeechBubble" parent="NavigationStation" instance=ExtResource("6_bubble")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.6, 0) - -[node name="SparringStation" type="StaticBody3D" parent="."] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16, 0, 2) -script = ExtResource("9_sparring") - -[node name="CollisionShape3D" type="CollisionShape3D" parent="SparringStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -shape = SubResource("BoxShape3D_station") - -[node name="MeshInstance3D" type="MeshInstance3D" parent="SparringStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) -mesh = SubResource("BoxMesh_sparring") - -[node name="NameLabel" type="Label3D" parent="SparringStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) -billboard = 1 -text = "Sparring-Ring" -font_size = 56 -outline_size = 14 - -[node name="PromptLabel" type="Label3D" parent="SparringStation"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) -visible = false -modulate = Color(1, 0.9, 0.5, 1) -billboard = 1 -text = "E / (A) — Sparring" -font_size = 40 -outline_size = 12 - -[node name="InteractionArea" type="Area3D" parent="SparringStation"] -collision_layer = 0 -collision_mask = 2 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="SparringStation/InteractionArea"] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) -shape = SubResource("SphereShape3D_interact") - -[node name="SpeechBubble" parent="SparringStation" instance=ExtResource("6_bubble")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.6, 0) - [node name="Jack" type="StaticBody3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -50, 0) visible = false diff --git a/scenes/hub/sparring_hall.tscn b/scenes/hub/sparring_hall.tscn new file mode 100644 index 0000000..9b6ab45 --- /dev/null +++ b/scenes/hub/sparring_hall.tscn @@ -0,0 +1,266 @@ +[gd_scene load_steps=31 format=3] + +[ext_resource type="Script" path="res://scripts/gameplay/hub_room.gd" id="1_room"] +[ext_resource type="PackedScene" path="res://scenes/player.tscn" id="2_player"] +[ext_resource type="PackedScene" path="res://scenes/ui/debug_overlay.tscn" id="3_debug"] +[ext_resource type="Script" path="res://scripts/gameplay/zone_trigger.gd" id="4_zone"] +[ext_resource type="Script" path="res://scripts/gameplay/training_station.gd" id="5_station"] +[ext_resource type="Script" path="res://scripts/gameplay/sparring_fight.gd" id="6_fight"] +[ext_resource type="PackedScene" path="res://scenes/ui/speech_bubble.tscn" id="7_bubble"] + +[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_sky"] +sky_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) +ground_horizon_color = Color(0.64625, 0.65575, 0.67075, 1) + +[sub_resource type="Sky" id="Sky_sky"] +sky_material = SubResource("ProceduralSkyMaterial_sky") + +[sub_resource type="Environment" id="Environment_env"] +background_mode = 2 +sky = SubResource("Sky_sky") +tonemap_mode = 2 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_floor"] +albedo_color = Color(0.38, 0.36, 0.34, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_floor"] +size = Vector3(14, 1, 10) + +[sub_resource type="BoxMesh" id="BoxMesh_floor"] +material = SubResource("StandardMaterial3D_floor") +size = Vector3(14, 1, 10) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_structure"] +albedo_color = Color(0.5, 0.48, 0.45, 1) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wall_ns"] +size = Vector3(15, 3, 0.5) + +[sub_resource type="BoxMesh" id="BoxMesh_wall_ns"] +material = SubResource("StandardMaterial3D_structure") +size = Vector3(15, 3, 0.5) + +[sub_resource type="BoxShape3D" id="BoxShape3D_wall_ew"] +size = Vector3(0.5, 3, 11) + +[sub_resource type="BoxMesh" id="BoxMesh_wall_ew"] +material = SubResource("StandardMaterial3D_structure") +size = Vector3(0.5, 3, 11) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mat"] +albedo_color = Color(0.55, 0.3, 0.25, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_mat"] +material = SubResource("StandardMaterial3D_mat") +size = Vector3(5, 0.06, 5) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_partner"] +albedo_color = Color(0.6, 0.5, 0.4, 1) + +[sub_resource type="CapsuleMesh" id="CapsuleMesh_partner"] +material = SubResource("StandardMaterial3D_partner") +radius = 0.4 +height = 1.8 + +[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_partner"] +radius = 0.4 +height = 1.8 + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_combat"] +albedo_color = Color(0.7, 0.32, 0.25, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_combat"] +material = SubResource("StandardMaterial3D_combat") +size = Vector3(1.2, 1.2, 1.2) + +[sub_resource type="BoxShape3D" id="BoxShape3D_station"] +size = Vector3(1.2, 1.2, 1.2) + +[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_trigger"] +transparency = 1 +albedo_color = Color(0.3, 0.8, 1, 0.35) + +[sub_resource type="BoxShape3D" id="BoxShape3D_door_s"] +size = Vector3(2, 2, 1) + +[sub_resource type="BoxMesh" id="BoxMesh_door_s"] +material = SubResource("StandardMaterial3D_trigger") +size = Vector3(2, 2, 1) + +[sub_resource type="SphereShape3D" id="SphereShape3D_interact"] +radius = 2.5 + +[node name="SparringHall" type="Node3D"] +script = ExtResource("1_room") + +[node name="WorldEnvironment" type="WorldEnvironment" parent="."] +environment = SubResource("Environment_env") + +[node name="Sun" type="DirectionalLight3D" parent="."] +transform = Transform3D(0.866025, 0.383022, -0.321394, 0, 0.642788, 0.766044, 0.5, -0.663414, 0.55667, 0, 12, 0) +shadow_enabled = true + +[node name="Floor" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor"] +shape = SubResource("BoxShape3D_floor") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor"] +mesh = SubResource("BoxMesh_floor") + +[node name="Walls" type="Node3D" parent="."] + +[node name="WallNorth" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, -5.25) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallNorth"] +shape = SubResource("BoxShape3D_wall_ns") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallNorth"] +mesh = SubResource("BoxMesh_wall_ns") + +[node name="WallSouth" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.5, 5.25) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallSouth"] +shape = SubResource("BoxShape3D_wall_ns") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallSouth"] +mesh = SubResource("BoxMesh_wall_ns") + +[node name="WallEast" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.25, 1.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallEast"] +shape = SubResource("BoxShape3D_wall_ew") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallEast"] +mesh = SubResource("BoxMesh_wall_ew") + +[node name="WallWest" type="StaticBody3D" parent="Walls"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.25, 1.5, 0) + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Walls/WallWest"] +shape = SubResource("BoxShape3D_wall_ew") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Walls/WallWest"] +mesh = SubResource("BoxMesh_wall_ew") + +[node name="RingMat" type="MeshInstance3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0.03, -1.5) +mesh = SubResource("BoxMesh_mat") + +[node name="SparringPartner" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, -1.5) +script = ExtResource("6_fight") + +[node name="CollisionShape3D" type="CollisionShape3D" parent="SparringPartner"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0) +shape = SubResource("CapsuleShape3D_partner") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="SparringPartner"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0) +mesh = SubResource("CapsuleMesh_partner") + +[node name="NameLabel" type="Label3D" parent="SparringPartner"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.2, 0) +billboard = 1 +text = "Sparringspartner" +font_size = 56 +outline_size = 14 + +[node name="PromptLabel" type="Label3D" parent="SparringPartner"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0) +visible = false +modulate = Color(1, 0.9, 0.5, 1) +billboard = 1 +text = "E / (A) — Sparring" +font_size = 40 +outline_size = 12 + +[node name="InteractionArea" type="Area3D" parent="SparringPartner"] +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="SparringPartner/InteractionArea"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("SphereShape3D_interact") + +[node name="SpeechBubble" parent="SparringPartner" instance=ExtResource("7_bubble")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.8, 0) + +[node name="CombatStation" type="StaticBody3D" parent="."] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.5, 0, -3) +script = ExtResource("5_station") +station_name = "Kampftraining" +stat_name = "strength" +success_line = "Die Schultern brennen. Gut so." + +[node name="CollisionShape3D" type="CollisionShape3D" parent="CombatStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) +shape = SubResource("BoxShape3D_station") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="CombatStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0) +mesh = SubResource("BoxMesh_combat") + +[node name="NameLabel" type="Label3D" parent="CombatStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) +billboard = 1 +text = "Kampftraining" +font_size = 56 +outline_size = 14 + +[node name="PromptLabel" type="Label3D" parent="CombatStation"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +visible = false +modulate = Color(1, 0.9, 0.5, 1) +billboard = 1 +text = "E / (A) — Üben" +font_size = 40 +outline_size = 12 + +[node name="InteractionArea" type="Area3D" parent="CombatStation"] +collision_layer = 0 +collision_mask = 2 + +[node name="CollisionShape3D" type="CollisionShape3D" parent="CombatStation/InteractionArea"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0) +shape = SubResource("SphereShape3D_interact") + +[node name="SpeechBubble" parent="CombatStation" instance=ExtResource("7_bubble")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.6, 0) + +[node name="Triggers" type="Node3D" parent="."] + +[node name="TriggerRiderQuadrant" type="Area3D" parent="Triggers"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 4.4) +collision_layer = 0 +collision_mask = 2 +script = ExtResource("4_zone") +target_scene_path = "res://scenes/hub/rider_quadrant.tscn" +target_spawn_name = "FromSparringHall" + +[node name="CollisionShape3D" type="CollisionShape3D" parent="Triggers/TriggerRiderQuadrant"] +shape = SubResource("BoxShape3D_door_s") + +[node name="MeshInstance3D" type="MeshInstance3D" parent="Triggers/TriggerRiderQuadrant"] +mesh = SubResource("BoxMesh_door_s") + +[node name="Label3D" type="Label3D" parent="Triggers/TriggerRiderQuadrant"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.6, 0) +billboard = 1 +text = "Zum Reiterquadrant" +font_size = 40 +outline_size = 12 + +[node name="SpawnPoints" type="Node3D" parent="."] + +[node name="FromRiderQuadrant" type="Marker3D" parent="SpawnPoints"] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 2.8) + +[node name="Player" parent="." instance=ExtResource("2_player")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 2.8) + +[node name="DebugOverlay" parent="." instance=ExtResource("3_debug")] diff --git a/scripts/gameplay/sparring_fight.gd b/scripts/gameplay/sparring_fight.gd new file mode 100644 index 0000000..6abbfa7 --- /dev/null +++ b/scripts/gameplay/sparring_fight.gd @@ -0,0 +1,264 @@ +extends StaticBody3D +## Echtes Sparring-Kampfsystem (Change Request + SPEC.md Roadmap Phase 4: +## stat-basiertes, taktisches Sparring). +## +## Interact startet den Kampf und verbraucht einen Tages-Slot. Linksklick +## bzw. R2 schlägt (attack), Rechtsklick bzw. ▢/Ⓧ blockt (block). Kraft +## skaliert den Schaden pro Treffer: BASE_DAMAGE + 1 je volle 10 Kraft +## über 30 — der Gegner fällt also je nach Training in 3–5 Treffern. +## Schnelligkeit weitet das Block-Fenster (Telegraph-Dauer des Gegners). +## Ausdauer Tyrveils: Schlagen kostet ATTACK_COST, erfolgreiches Blocken +## BLOCK_COST, Regeneration STAMINA_REGEN pro Sekunde; unter +## GUARD_BREAK_THRESHOLD ist kein Block möglich (Guard-Break), unter +## WEAK_ATTACK_THRESHOLD halbiert sich der Schlagschaden. Der Gegner hat +## eine interne Ausdauer OHNE sichtbaren Balken, die sein Angriffstempo +## steuert (Angriff nur bei genug Ausdauer). HUD: HP-Balken beider +## Kämpfer plus Ausdauer-Balken Tyrveils (Laufzeit-CanvasLayer). +## Sparring ist nie tödlich, unabhängig vom Permadeath-Toggle: Sieg führt +## in den Klinge/Herz-Abschluss (sparring_win.json — Gegner überwältigt: +## fertigmachen oder aufhelfen), Niederlage in sparring_loss.json. + +enum FightState { WAITING, FIGHTING, RESOLVING } + +const PLAYER_MAX_HP := 5 +const ENEMY_MAX_HP := 20 +const BASE_DAMAGE := 4 +const STAMINA_MAX := 100.0 +const ATTACK_COST := 20.0 +const BLOCK_COST := 15.0 +const STAMINA_REGEN := 25.0 +const GUARD_BREAK_THRESHOLD := 15.0 +const WEAK_ATTACK_THRESHOLD := 20.0 +const ENEMY_STAMINA_MAX := 100.0 +const ENEMY_ATTACK_COST := 30.0 +const ENEMY_STAMINA_REGEN := 20.0 +const ENEMY_STRIKE_COOLDOWN := 1.2 +const ENEMY_STAGGER_SECONDS := 1.0 +const PLAYER_ATTACK_COOLDOWN := 0.5 +const TELEGRAPH_SCALE := 1.18 +const INPUT_COOLDOWN_MS := 800 + +@export_file("*.json") var win_dialogue_path := "res://data/dialogue/sparring_win.json" +@export_file("*.json") var loss_dialogue_path := "res://data/dialogue/sparring_loss.json" +@export var exhausted_line := "Für heute reicht es — der Schlafsaal wartet." + +var _state := FightState.WAITING +var _player_hp := PLAYER_MAX_HP +var _enemy_hp := ENEMY_MAX_HP +var _stamina := STAMINA_MAX +var _enemy_stamina := ENEMY_STAMINA_MAX +var _attack_cooldown := 0.0 +var _enemy_cooldown := 0.0 +var _telegraph_remaining := 0.0 +var _stagger_remaining := 0.0 +var _is_enemy_telegraphing := false +var _is_player_in_range := false +var _last_use_ms := -INPUT_COOLDOWN_MS +var _hud: CanvasLayer +var _player_hp_bar: ProgressBar +var _stamina_bar: ProgressBar +var _enemy_hp_bar: ProgressBar + +@onready var _prompt_label: Label3D = $PromptLabel +@onready var _interaction_area: Area3D = $InteractionArea +@onready var _bubble: Node3D = $SpeechBubble +@onready var _mesh: MeshInstance3D = $MeshInstance3D + + +## Verbindet die Reichweiten-Signale des Interaktions-Triggers. +func _ready() -> void: + _interaction_area.body_entered.connect(_on_body_entered) + _interaction_area.body_exited.connect(_on_body_exited) + + +## Startet den Kampf per interact bzw. wertet Schläge während des Kampfes. +func _unhandled_input(event: InputEvent) -> void: + if _state == FightState.FIGHTING: + if event.is_action_pressed("attack"): + _player_attack() + get_viewport().set_input_as_handled() + return + if _state != FightState.WAITING or not _is_player_in_range: + return + if DialogueSystem.is_dialogue_active: + return + if not event.is_action_pressed("interact"): + return + if Time.get_ticks_msec() - _last_use_ms < INPUT_COOLDOWN_MS: + return + _last_use_ms = Time.get_ticks_msec() + _try_start_fight() + + +## Treibt Ausdauer-Regeneration, Cooldowns und die Gegner-KI an. +func _physics_process(delta: float) -> void: + if _state != FightState.FIGHTING: + return + _stamina = minf(_stamina + STAMINA_REGEN * delta, STAMINA_MAX) + _enemy_stamina = minf(_enemy_stamina + ENEMY_STAMINA_REGEN * delta, ENEMY_STAMINA_MAX) + _attack_cooldown = maxf(_attack_cooldown - delta, 0.0) + if _is_enemy_telegraphing: + _telegraph_remaining -= delta + if _telegraph_remaining <= 0.0: + _resolve_enemy_strike() + elif _stagger_remaining > 0.0: + _stagger_remaining -= delta + else: + _enemy_cooldown = maxf(_enemy_cooldown - delta, 0.0) + if _enemy_cooldown <= 0.0 and _enemy_stamina >= ENEMY_ATTACK_COST: + _begin_enemy_telegraph() + _update_hud() + + +## Startet den Kampf: verbraucht den Tages-Slot, initialisiert Werte, +## sperrt die Bewegung und blendet das HUD ein. +func _try_start_fight() -> void: + if not TimeSystem.try_spend_slot(): + _bubble.show_line(exhausted_line) + return + var player := get_tree().get_first_node_in_group("player") + if player == null: + push_warning("Kein Spieler für das Sparring gefunden.") + return + _player_hp = PLAYER_MAX_HP + _enemy_hp = ENEMY_MAX_HP + _stamina = STAMINA_MAX + _enemy_stamina = ENEMY_STAMINA_MAX + _attack_cooldown = 0.0 + _enemy_cooldown = ENEMY_STRIKE_COOLDOWN + _is_enemy_telegraphing = false + _stagger_remaining = 0.0 + player.set_control_locked(true) + _prompt_label.visible = false + _ensure_hud() + _update_hud() + _hud.visible = true + _state = FightState.FIGHTING + + +## Führt einen Schlag aus: Kraft bestimmt den Schaden, knappe Ausdauer +## halbiert ihn (schwache Schläge), Treffer reduzieren die Gegner-HP. +func _player_attack() -> void: + if _attack_cooldown > 0.0: + return + _attack_cooldown = PLAYER_ATTACK_COOLDOWN + var damage := maxi(1, BASE_DAMAGE + (GameState.strength - 30) / 10) + if _stamina < WEAK_ATTACK_THRESHOLD: + damage = maxi(1, damage / 2) + _stamina = maxf(_stamina - ATTACK_COST, 0.0) + _enemy_hp = maxi(_enemy_hp - damage, 0) + _update_hud() + if _enemy_hp <= 0: + _end_fight(true) + + +## Beginnt den Angriffs-Telegraph des Gegners; die Dauer ist zugleich das +## Block-Fenster und wächst mit Tyrveils Schnelligkeit. +func _begin_enemy_telegraph() -> void: + _enemy_stamina -= ENEMY_ATTACK_COST + _is_enemy_telegraphing = true + _telegraph_remaining = clampf(0.5 + (GameState.agility - 35) * 0.015, 0.4, 0.9) + _mesh.scale = Vector3.ONE * TELEGRAPH_SCALE + + +## Löst den Schlag des Gegners aus: Wird gerade geblockt (block gehalten +## und genug Ausdauer), taumelt der Gegner; sonst verliert Tyrveil einen +## Trefferpunkt. +func _resolve_enemy_strike() -> void: + _is_enemy_telegraphing = false + _mesh.scale = Vector3.ONE + _enemy_cooldown = ENEMY_STRIKE_COOLDOWN + if Input.is_action_pressed("block") and _stamina >= GUARD_BREAK_THRESHOLD: + _stamina = maxf(_stamina - BLOCK_COST, 0.0) + _stagger_remaining = ENEMY_STAGGER_SECONDS + _update_hud() + return + _player_hp = maxi(_player_hp - 1, 0) + _update_hud() + if _player_hp <= 0: + _end_fight(false) + + +## Beendet den Kampf und führt in den passenden Abschluss-Dialog; danach +## ist die Station für den nächsten Slot wieder bereit. Nie tödlich. +func _end_fight(is_won: bool) -> void: + _state = FightState.RESOLVING + _hud.visible = false + _mesh.scale = Vector3.ONE + var player := get_tree().get_first_node_in_group("player") + if player != null: + player.set_control_locked(false) + DialogueSystem.start_dialogue(win_dialogue_path if is_won else loss_dialogue_path, { + "sparring": self, + DialogueSystem.PLAYER_SPEAKER_ID: player, + }) + await DialogueSystem.dialogue_finished + _state = FightState.WAITING + _prompt_label.visible = _is_player_in_range + + +## Baut das Kampf-HUD (HP beider Kämpfer, Ausdauer Tyrveils) beim ersten +## Bedarf. +func _ensure_hud() -> void: + if _hud != null: + return + _hud = CanvasLayer.new() + _hud.layer = 3 + var root := Control.new() + root.set_anchors_preset(Control.PRESET_FULL_RECT) + root.mouse_filter = Control.MOUSE_FILTER_IGNORE + _enemy_hp_bar = _build_bar(root, Vector2(-150, 24), Color(0.75, 0.3, 0.3), "Sparringspartner", ENEMY_MAX_HP) + _player_hp_bar = _build_bar(root, Vector2(-320, -80), Color(0.35, 0.65, 0.35), "Tyrveil", PLAYER_MAX_HP) + _stamina_bar = _build_bar(root, Vector2(-320, -46), Color(0.85, 0.75, 0.35), "Ausdauer", int(STAMINA_MAX)) + _hud.add_child(root) + add_child(_hud) + _hud.visible = false + + +## Erzeugt einen beschrifteten Balken; offset relativ zur Ankerkante +## (negative y-Werte hängen an der Unterkante). +func _build_bar(root: Control, offset: Vector2, color: Color, label_text: String, max_value: int) -> ProgressBar: + var container := VBoxContainer.new() + if offset.y < 0.0: + container.set_anchors_preset(Control.PRESET_BOTTOM_LEFT) + container.position = Vector2(24, 0) + container.offset_top = offset.y + container.offset_left = 24.0 + else: + container.set_anchors_preset(Control.PRESET_CENTER_TOP) + container.offset_left = offset.x + container.offset_top = offset.y + var label := Label.new() + label.text = label_text + label.add_theme_font_size_override("font_size", 14) + container.add_child(label) + var bar := ProgressBar.new() + bar.custom_minimum_size = Vector2(300, 18) + bar.max_value = max_value + bar.value = max_value + bar.show_percentage = false + bar.modulate = color + container.add_child(bar) + root.add_child(container) + return bar + + +## Spiegelt die Kampfwerte in die HUD-Balken. +func _update_hud() -> void: + if _hud == null: + return + _player_hp_bar.value = _player_hp + _stamina_bar.value = _stamina + _enemy_hp_bar.value = _enemy_hp + + +## Blendet den Prompt ein, sobald der Spieler die Reichweite betritt. +func _on_body_entered(_body: Node3D) -> void: + _is_player_in_range = true + _prompt_label.visible = _state == FightState.WAITING + + +## Blendet den Prompt aus, wenn der Spieler die Reichweite verlässt. +func _on_body_exited(_body: Node3D) -> void: + _is_player_in_range = false + _prompt_label.visible = false diff --git a/scripts/gameplay/sparring_fight.gd.uid b/scripts/gameplay/sparring_fight.gd.uid new file mode 100644 index 0000000..11ae91e --- /dev/null +++ b/scripts/gameplay/sparring_fight.gd.uid @@ -0,0 +1 @@ +uid://dokrernqagk1x diff --git a/scripts/gameplay/sparring_station.gd b/scripts/gameplay/sparring_station.gd deleted file mode 100644 index 17966cb..0000000 --- a/scripts/gameplay/sparring_station.gd +++ /dev/null @@ -1,79 +0,0 @@ -extends StaticBody3D -## Sparring-Station im Reiterquadranten (Phase 4b, SPEC.md Roadmap -## Phase 4: stat-basiertes, taktisches Sparring). -## -## Interaktion wie bei den Unterrichts-Stationen; jede Runde verbraucht -## einen Tages-Slot (TimeSystem.try_spend_slot). Der Ausgang hängt an -## einem Stat-Check gegen einen erfahrenen Zweitjahr-Kadetten: Sieg bei -## Kraft >= STRENGTH_THRESHOLD ODER Schnelligkeit >= AGILITY_THRESHOLD -## (je 40 — mit den Startwerten 35/35 verliert man zunächst und muss über -## das Training aus Phase 4a wachsen). Sieg wie Niederlage laufen als -## Dialog mit taktischem Klinge/Herz-Entscheidungspunkt; die Optionen -## verschieben Klinge-↔-Herz-Ton und das Gezeichneten-Standing -## (faction_standing-Tag, erster Story-Verbraucher des FactionSystems). - -const STRENGTH_THRESHOLD := 40 -const AGILITY_THRESHOLD := 40 -const INPUT_COOLDOWN_MS := 800 - -@export_file("*.json") var win_dialogue_path := "res://data/dialogue/sparring_win.json" -@export_file("*.json") var loss_dialogue_path := "res://data/dialogue/sparring_loss.json" -@export var exhausted_line := "Für heute reicht es — der Schlafsaal wartet." - -var _is_player_in_range := false -var _last_use_ms := -INPUT_COOLDOWN_MS - -@onready var _prompt_label: Label3D = $PromptLabel -@onready var _interaction_area: Area3D = $InteractionArea -@onready var _bubble: Node3D = $SpeechBubble - - -## Verbindet die Reichweiten-Signale des Interaktions-Triggers. -func _ready() -> void: - _interaction_area.body_entered.connect(_on_body_entered) - _interaction_area.body_exited.connect(_on_body_exited) - - -## Startet die Sparringrunde bei interact in Reichweite, außerhalb -## laufender Dialoge und nach Ablauf des Doppel-Eingabe-Schutzes. -func _unhandled_input(event: InputEvent) -> void: - if not _is_player_in_range: - return - if DialogueSystem.is_dialogue_active: - return - if not event.is_action_pressed("interact"): - return - if Time.get_ticks_msec() - _last_use_ms < INPUT_COOLDOWN_MS: - return - _last_use_ms = Time.get_ticks_msec() - _spar() - - -## Verbraucht den Tages-Slot und startet je nach Stat-Check den Sieg- -## oder Niederlage-Dialog. -func _spar() -> void: - if not TimeSystem.try_spend_slot(): - _bubble.show_line(exhausted_line) - return - var player := get_tree().get_first_node_in_group("player") - if player == null: - push_warning("Kein Spieler für das Sparring gefunden.") - return - var is_winning := GameState.strength >= STRENGTH_THRESHOLD or GameState.agility >= AGILITY_THRESHOLD - var dialogue_path := win_dialogue_path if is_winning else loss_dialogue_path - DialogueSystem.start_dialogue(dialogue_path, { - "sparring": self, - DialogueSystem.PLAYER_SPEAKER_ID: player, - }) - - -## Blendet den Prompt ein, sobald der Spieler die Reichweite betritt. -func _on_body_entered(_body: Node3D) -> void: - _is_player_in_range = true - _prompt_label.visible = true - - -## Blendet den Prompt aus, wenn der Spieler die Reichweite verlässt. -func _on_body_exited(_body: Node3D) -> void: - _is_player_in_range = false - _prompt_label.visible = false diff --git a/scripts/gameplay/sparring_station.gd.uid b/scripts/gameplay/sparring_station.gd.uid deleted file mode 100644 index 09a2aeb..0000000 --- a/scripts/gameplay/sparring_station.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://b0bt7s51qbdj