Phase 4b: Zeit-Persistenz, Maren, Sparring, Jack-Barlowe-QTE

- Tag/Slot/Slot-Verbrauch reisen im GameState-Save mit
  (TimeSystem.apply_save_state, gleiche Muster wie story_flags)
- Maren Vael als fuenfter Hub-NPC (grau-blaue Kapsel, Wegpunkte, Wander-KI
  und Ambient wie die anderen; zwei neue Ambient-Wechsel Maren/Wren und
  Maren/Imogen); maren_intro.json: ruhig, warm, wissend, Vater-Andeutungen
  ohne Wahrheit-1/2-Vorwegnahme, Entscheidungspunkt Klinge/Herz/neutral
- Sparring-Ring im Reiterquadranten: Slot-Verbrauch, Stat-Check gegen
  Zweitjahr (Sieg bei Kraft>=40 ODER Schnelligkeit>=40; Startwerte 35/35
  verlieren erst), Sieg-/Niederlage-Dialoge mit taktischem
  Klinge/Herz-Punkt; neues faction_standing-Options-Tag im DialogueSystem
  als erster Story-Verbraucher des FactionSystems (Ton -5/+5 bzw. -3/+3,
  Standing +3/+2 Sieg, +1 Niederlage)
- Jack-Barlowe-Hinterhalt (Kanon: WELT.md 8; Auflauern auf Tyrveil ist die
  SPEC-10-Spiel-Setzung): ab Tag 2 pro Slot-Wechsel 50% Chance, max. 1x
  taeglich; nicht abbrechbarer Droh-Dialog, dann 3 QTE-Stufen ueber
  slide/jump/sprint (Tastatur+Controller, 1,4-s-Fenster, uebriger Input
  wird waehrenddessen geschluckt); Erfolg -> Wahl-Dialog (Standing +3/+2,
  Ton -5/+5), Fehlschlag: Permadeath AN Game Over, AUS Standing -3;
  player.set_control_locked() als oeffentliche Sperre fuer die QTE-Phase
- Headless verifiziert (43 Checks): Zeit-Roundtrip, Maren-Werte, Sparring
  beide Ausgaenge und Wege inkl. Slots, QTE Erfolg/Fehlschlag AUS/AN

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
danny 2026-07-06 06:36:00 +02:00
parent ef60c96735
commit 5eb46577b9
18 changed files with 651 additions and 3 deletions

View file

@ -198,6 +198,10 @@ func _apply_option_effects(option: Dictionary) -> void:
for flag_name in flag_changes:
GameState.set_story_flag(str(flag_name), flag_changes[flag_name])
_has_applied_effects = true
var standing_shifts: Dictionary = option.get("faction_standing", {})
for faction_id in standing_shifts:
FactionSystem.adjust_standing(str(faction_id), int(standing_shifts[faction_id]))
_has_applied_effects = true
## Spielt eine zufällig gewählte Abbruch-Zeile Tyrveils, damit der

View file

@ -160,6 +160,9 @@ func to_save_dict() -> Dictionary:
"story_flags": story_flags.duplicate(),
"faction_standings": faction_standings.duplicate(),
"is_permadeath_enabled": is_permadeath_enabled,
"time_day": TimeSystem.day_count,
"time_slot": TimeSystem.current_slot,
"time_slot_used": TimeSystem.is_current_slot_used,
}
@ -190,6 +193,7 @@ func apply_save_dict(data: Dictionary) -> void:
var saved_standings: Dictionary = data.get("faction_standings", {})
for faction_id in saved_standings:
faction_standings[String(faction_id)] = clampi(int(saved_standings[faction_id]), RELATIONSHIP_MIN, RELATIONSHIP_MAX)
TimeSystem.apply_save_state(int(data.get("time_day", 1)), int(data.get("time_slot", 0)), bool(data.get("time_slot_used", false)))
blade_heart_tone_changed.emit(blade_heart_tone)
for npc_id in relationships:
relationship_changed.emit(npc_id, relationships[npc_id])

View file

@ -57,6 +57,15 @@ func advance_slot() -> void:
push_warning("advance_slot() am Abend ignoriert — Tag endet nur im Schlafsaal.")
## Stellt Tag, Slot und Slot-Verbrauch aus einem Spielstand wieder her
## (aufgerufen von GameState.apply_save_dict, damit der Tageszyklus im
## selben Spielstand mitreist). Meldet den Slot über slot_changed.
func apply_save_state(saved_day: int, saved_slot: int, is_used: bool) -> void:
day_count = maxi(1, saved_day)
_change_slot(clampi(saved_slot, DaySlot.MORNING, DaySlot.EVENING) as DaySlot)
is_current_slot_used = is_used
## Beendet den Tag über den Schlafsaal-Trigger: erhöht den Tageszähler und
## springt zurück auf den Vormittag.
func end_day() -> void:

View file

@ -0,0 +1,173 @@
extends Node
## Jack-Barlowe-Hinterhalte mit QTE (Phase 4b, SPEC.md Roadmap Phase 4).
##
## Kanon-Basis WELT.md Abschnitt 8: Jack Barlowe ist Kadett und erklärter
## Feind, der wiederholt zu töten versucht; dass er Tyrveil als
## Gezeichnetem auflauert, ist die von SPEC vorgesehene Spiel-Setzung.
## Kopplung an den Tageszyklus: Ab Tag AMBUSH_MIN_DAY würfelt jeder
## Slot-Wechsel mit ambush_chance, höchstens ein Hinterhalt pro Tag.
## Ablauf: nicht abbrechbarer Einschüchterungs-Dialog, dann QTE_STAGES
## zeitkritische Eingaben über bestehende Input-Actions (slide, jump,
## sprint — Tastatur wie Controller identisch); während der QTE ist die
## Spieler-Steuerung gesperrt und aller übrige Input wird geschluckt.
## Erfolg: Wahl-Dialog Klinge/Herz mit Standing +3/+2. Scheitern: bei
## Permadeath AN Game Over ins Hauptmenü (wie am Viadukt), bei Permadeath
## AUS Prellungen und Gezeichneten-Standing FAIL_STANDING_PENALTY.
const INTRO_PATH := "res://data/dialogue/jack_intro.json"
const WIN_PATH := "res://data/dialogue/jack_win.json"
const FAIL_PATH := "res://data/dialogue/jack_fail.json"
const MAIN_MENU_SCENE := "res://scenes/ui/main_menu.tscn"
const AMBUSH_MIN_DAY := 2
const QTE_STAGES := 3
const QTE_WINDOW_SECONDS := 1.4
const QTE_STAGE_GAP_SECONDS := 0.3
const QTE_ACTIONS := [
{ "action": "slide", "label": "AUSWEICHEN — C / L2" },
{ "action": "jump", "label": "SPRINGEN — Leertaste / (A)" },
{ "action": "sprint", "label": "ANTÄUSCHEN — Shift / L3" },
]
const FAIL_STANDING_PENALTY := -3
const JACK_HIDDEN_POSITION := Vector3(0, -50, 0)
@export var jack_path: NodePath
@export var ambush_chance := 0.5
var is_ambush_active := false
var _last_ambush_day := 0
var _qte_expected_action := ""
var _is_stage_passed := false
var _is_stage_failed := false
var _qte_layer: CanvasLayer
var _qte_label: Label
@onready var _jack: Node3D = get_node(jack_path)
## Lauscht auf Slot-Wechsel als Hinterhalt-Auslöser.
func _ready() -> void:
TimeSystem.slot_changed.connect(_on_slot_changed)
## Bewertet die QTE-Eingabe; während einer aktiven QTE wird sämtlicher
## übriger Input geschluckt, damit keine NPC-Interaktion dazwischenfunkt.
func _unhandled_input(event: InputEvent) -> void:
if _qte_expected_action.is_empty():
return
for stage in QTE_ACTIONS:
if event.is_action_pressed(str(stage["action"])):
if stage["action"] == _qte_expected_action:
_is_stage_passed = true
else:
_is_stage_failed = true
break
get_viewport().set_input_as_handled()
## Würfelt beim Slot-Wechsel, ob Jack auflauert.
func _on_slot_changed(_new_slot: int) -> void:
if is_ambush_active or DialogueSystem.is_dialogue_active:
return
if TimeSystem.day_count < AMBUSH_MIN_DAY:
return
if _last_ambush_day == TimeSystem.day_count:
return
if randf() > ambush_chance:
return
start_ambush()
## Startet den Hinterhalt: Jack erscheint vor dem Spieler, droht, dann
## läuft die QTE. Öffentlich, damit Tests ihn deterministisch auslösen
## können.
func start_ambush() -> void:
if is_ambush_active or DialogueSystem.is_dialogue_active:
return
var player := get_tree().get_first_node_in_group("player")
if player == null:
return
is_ambush_active = true
_last_ambush_day = TimeSystem.day_count
_jack.global_position = player.global_position + Vector3(0, 0, -2.5)
_jack.visible = true
_run_ambush(player)
## Spielt den kompletten Hinterhalt als Coroutine ab.
func _run_ambush(player: CharacterBody3D) -> void:
DialogueSystem.start_dialogue(INTRO_PATH, {
"jack": _jack,
DialogueSystem.PLAYER_SPEAKER_ID: player,
})
await DialogueSystem.dialogue_finished
player.set_control_locked(true)
var is_success := await _run_qte()
player.set_control_locked(false)
if is_success:
DialogueSystem.start_dialogue(WIN_PATH, {
"jack": _jack,
DialogueSystem.PLAYER_SPEAKER_ID: player,
})
await DialogueSystem.dialogue_finished
elif GameState.is_permadeath_enabled:
print("Game Over — Barlowes Hinterhalt endet tödlich.")
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
get_tree().change_scene_to_file(MAIN_MENU_SCENE)
return
else:
FactionSystem.adjust_standing(FactionSystem.MARKED_FACTION_ID, FAIL_STANDING_PENALTY)
DialogueSystem.start_dialogue(FAIL_PATH, {
"jack": _jack,
DialogueSystem.PLAYER_SPEAKER_ID: player,
})
await DialogueSystem.dialogue_finished
_jack.visible = false
_jack.global_position = JACK_HIDDEN_POSITION
is_ambush_active = false
## Führt die QTE-Stufen aus; true, wenn alle bestanden wurden.
func _run_qte() -> bool:
_ensure_qte_ui()
_qte_layer.visible = true
var is_all_passed := true
for i in QTE_STAGES:
var stage: Dictionary = QTE_ACTIONS.pick_random()
_is_stage_passed = false
_is_stage_failed = false
_qte_label.text = str(stage["label"])
_qte_expected_action = str(stage["action"])
var timer := get_tree().create_timer(QTE_WINDOW_SECONDS)
while timer.time_left > 0.0 and not _is_stage_passed and not _is_stage_failed:
await get_tree().process_frame
_qte_expected_action = ""
if not _is_stage_passed:
is_all_passed = false
break
_qte_label.text = "!"
await get_tree().create_timer(QTE_STAGE_GAP_SECONDS).timeout
_qte_layer.visible = false
return is_all_passed
## Baut die QTE-Anzeige (zentriertes Laufzeit-Label) beim ersten Bedarf.
func _ensure_qte_ui() -> void:
if _qte_layer != null:
return
_qte_layer = CanvasLayer.new()
_qte_layer.layer = 3
var root := Control.new()
root.set_anchors_preset(Control.PRESET_FULL_RECT)
root.mouse_filter = Control.MOUSE_FILTER_IGNORE
_qte_label = Label.new()
_qte_label.set_anchors_preset(Control.PRESET_CENTER)
_qte_label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
_qte_label.add_theme_font_size_override("font_size", 42)
_qte_label.add_theme_color_override("font_color", Color(1, 0.85, 0.4))
_qte_label.add_theme_color_override("font_outline_color", Color.BLACK)
_qte_label.add_theme_constant_override("outline_size", 8)
root.add_child(_qte_label)
_qte_layer.add_child(root)
add_child(_qte_layer)
_qte_layer.visible = false

View file

@ -0,0 +1 @@
uid://dp2ww21frqcvr

View file

@ -133,6 +133,14 @@ func _process_dialogue_lock(delta: float) -> void:
_apply_zoom_smoothing(delta)
## Sperrt oder entsperrt die Steuerung von außen (Set-Pieces und
## QTE-Encounter nutzen dieselbe Sperre wie Dialoge).
func set_control_locked(is_locked: bool) -> void:
if is_locked and _state == MovementState.SLIDING:
_end_slide()
_is_dialogue_locked = is_locked
## Spielt einen kurzen cineastischen Kamera-Schwenk für Set-Pieces
## (SPEC Abschnitt 2): Die Kamera startet weit draußen und seitlich und
## fährt weich in die Standard-Third-Person-Ansicht zurück; die Steuerung

View file

@ -0,0 +1,79 @@
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

View file

@ -0,0 +1 @@
uid://b0bt7s51qbdj

View file

@ -12,7 +12,7 @@ extends CanvasLayer
## Autoload InputPrompts (dynamische Button-Prompts, SPEC.md Abschnitt 2).
const JOY_MOTION_THRESHOLD := 0.2
const TRACKED_NPC_IDS: Array[String] = ["imogen", "violet", "rhiannon", "wren"]
const TRACKED_NPC_IDS: Array[String] = ["imogen", "violet", "rhiannon", "wren", "maren"]
const PLAYSTATION_NAME_HINTS: Array[String] = [
"ps5", "ps4", "dualsense", "dualshock", "sony", "playstation",
]