CRs: Mehr Antwortoptionen, Dialog-Abbruch mit Ansage, Konsistenzcheck
- imogen_intro auf drei Entscheidungspunkte mit je drei Optionen (Klinge/Herz/neutral) verlaengert; neuer Mittelteil (Nachtwachen-Muster, Akt-1-konform ohne Wahrheit-1-Vorwegnahme); Violet/Rhiannon/Wren je eine dritte neutrale Option - Dialog-Abbruch ueber cancel (Esc/B/Kreis): bei offener Auswahl via Dialog-Box (ABORT_INDEX), waehrend Zeilen via DialogueSystem; Tyrveil sagt die abort_line aus der Dialog-Datei an; Abbruch vor der ersten Entscheidung laesst den Erst-Effekt bestehen, nach Effekten gilt der Dialog als gefuehrt (Anti-Farming); Esc gibt im Dialog nicht mehr die Maus frei - Konsistenzcheck aller Gespraeche gegen STORY/WELT/CHARACTERS/TYRVEIL: Violets Rotschwaenze auf die Roten korrigiert (Farbe vs. Schwanztyp, SPEC 6), Rest konsistent (CHANGEREQUESTS_DONE.md) - Headless verifiziert (34 Checks): drei Entscheidungen bei Imogen (-15/+3), dritte Option per Fokus-Navigation, beide Abbruch-Pfade samt Werte- und Flag-Semantik Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4d15c69972
commit
ac65180f75
8 changed files with 233 additions and 27 deletions
|
|
@ -12,8 +12,13 @@ extends Node
|
|||
## (dort statt im StorySystem, weil nur GameState bereits gespeichert und
|
||||
## geladen wird und das Flag Save/Load überleben muss). Wiederholtes
|
||||
## Ansprechen spielt den Text erneut ab, ohne Werte zu verschieben.
|
||||
## dialogue_started/dialogue_finished erlauben es, Spielerbewegung und UI
|
||||
## während des Dialogs zu sperren.
|
||||
## Die cancel-Action bricht einen laufenden Dialog ab; Tyrveil sagt dem
|
||||
## Gegenüber dabei die abort_line aus der Dialog-Datei (oder den Standard)
|
||||
## an. Abgebrochene Dialoge gelten nur dann als geführt, wenn in diesem
|
||||
## Durchlauf bereits Options-Effekte angewendet wurden — so bleibt der
|
||||
## Erst-Durchlauf-Effekt erhalten, ohne dass Abbrechen zum Werte-Farming
|
||||
## taugt. dialogue_started/dialogue_finished erlauben es, Spielerbewegung
|
||||
## und UI während des Dialogs zu sperren.
|
||||
|
||||
signal dialogue_started(dialogue_id: String)
|
||||
signal dialogue_finished(dialogue_id: String)
|
||||
|
|
@ -21,12 +26,16 @@ signal dialogue_finished(dialogue_id: String)
|
|||
const BOX_SCENE := preload("res://scenes/ui/dialogue_box.tscn")
|
||||
const PLAYER_SPEAKER_ID := "player"
|
||||
const FALLBACK_LINE_SECONDS := 2.5
|
||||
const DEFAULT_ABORT_LINE := "Nicht jetzt. Wir reden später weiter."
|
||||
|
||||
var is_dialogue_active := false
|
||||
|
||||
var _speakers: Dictionary = {}
|
||||
var _speaker_names: Dictionary = {}
|
||||
var _is_effect_pass := true
|
||||
var _is_abort_requested := false
|
||||
var _has_applied_effects := false
|
||||
var _abort_line := DEFAULT_ABORT_LINE
|
||||
var _box: CanvasLayer
|
||||
|
||||
|
||||
|
|
@ -44,11 +53,25 @@ func start_dialogue(dialogue_path: String, speakers: Dictionary) -> void:
|
|||
_speakers = speakers
|
||||
_speaker_names = data.get("speakers", {})
|
||||
_is_effect_pass = not GameState.has_completed_dialogue(dialogue_id)
|
||||
_is_abort_requested = false
|
||||
_has_applied_effects = false
|
||||
_abort_line = str(data.get("abort_line", DEFAULT_ABORT_LINE))
|
||||
is_dialogue_active = true
|
||||
dialogue_started.emit(dialogue_id)
|
||||
_run_dialogue(data)
|
||||
|
||||
|
||||
## Merkt einen Abbruch-Wunsch (cancel) während laufender Dialog-Zeilen
|
||||
## vor; offene Antwortauswahlen behandelt die Dialog-Box selbst.
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if not is_dialogue_active:
|
||||
return
|
||||
if _box != null and _box.has_open_options():
|
||||
return
|
||||
if event.is_action_pressed("cancel"):
|
||||
_is_abort_requested = true
|
||||
|
||||
|
||||
## Liest und validiert eine Dialog-Datei; leeres Dictionary bei Fehlern.
|
||||
func _load_dialogue(dialogue_path: String) -> Dictionary:
|
||||
var file := FileAccess.open(dialogue_path, FileAccess.READ)
|
||||
|
|
@ -69,14 +92,17 @@ func _load_dialogue(dialogue_path: String) -> Dictionary:
|
|||
func _run_dialogue(data: Dictionary) -> void:
|
||||
var nodes: Dictionary = data["nodes"]
|
||||
var node_id := str(data["start"])
|
||||
while node_id != "" and nodes.has(node_id):
|
||||
while node_id != "" and nodes.has(node_id) and not _is_abort_requested:
|
||||
var node: Dictionary = nodes[node_id]
|
||||
var options: Array = node.get("options", [])
|
||||
if options.is_empty():
|
||||
node_id = await _play_line(node)
|
||||
else:
|
||||
node_id = await _play_choice(node, options)
|
||||
_end_dialogue(str(data["id"]))
|
||||
var was_aborted := _is_abort_requested
|
||||
if was_aborted:
|
||||
await _play_abort_line()
|
||||
_end_dialogue(str(data["id"]), was_aborted)
|
||||
|
||||
|
||||
## Zeigt eine Zeile ohne Optionen in Box und Sprechblase; die Blase (oder
|
||||
|
|
@ -89,12 +115,24 @@ func _play_line(node: Dictionary) -> String:
|
|||
var bubble := _bubble_for(speaker_id)
|
||||
if bubble != null:
|
||||
bubble.show_line(text)
|
||||
await bubble.line_finished
|
||||
else:
|
||||
await get_tree().create_timer(FALLBACK_LINE_SECONDS).timeout
|
||||
await _wait_for_line(bubble)
|
||||
return _next_id(node)
|
||||
|
||||
|
||||
## Wartet das Ende einer Zeile ab (Sprechblasen-Dauer oder Fallback-Timer)
|
||||
## und bricht früh ab, sobald ein Dialog-Abbruch angefordert wurde.
|
||||
func _wait_for_line(bubble: Node) -> void:
|
||||
if bubble != null:
|
||||
while bubble.visible and not _is_abort_requested:
|
||||
await get_tree().process_frame
|
||||
if _is_abort_requested:
|
||||
bubble.hide_bubble()
|
||||
return
|
||||
var timer := get_tree().create_timer(FALLBACK_LINE_SECONDS)
|
||||
while timer.time_left > 0.0 and not _is_abort_requested:
|
||||
await get_tree().process_frame
|
||||
|
||||
|
||||
## Zeigt eine Zeile mit Antwortoptionen in Box (mit Auswahl) und
|
||||
## Sprechblase (sticky), wendet beim ersten Durchlauf die Tags der
|
||||
## gewählten Option an, spielt die Antwort über Tyrveils Blase und liefert
|
||||
|
|
@ -112,6 +150,9 @@ func _play_choice(node: Dictionary, options: Array) -> String:
|
|||
var index: int = await _get_box().choose(option_texts)
|
||||
if bubble != null:
|
||||
bubble.hide_bubble()
|
||||
if index < 0:
|
||||
_is_abort_requested = true
|
||||
return ""
|
||||
var option: Dictionary = options[clampi(index, 0, options.size() - 1)]
|
||||
_apply_option_effects(option)
|
||||
var answer := str(option.get("text", ""))
|
||||
|
|
@ -119,9 +160,7 @@ func _play_choice(node: Dictionary, options: Array) -> String:
|
|||
var player_bubble := _bubble_for(PLAYER_SPEAKER_ID)
|
||||
if player_bubble != null:
|
||||
player_bubble.show_line(answer)
|
||||
await player_bubble.line_finished
|
||||
else:
|
||||
await get_tree().create_timer(FALLBACK_LINE_SECONDS).timeout
|
||||
await _wait_for_line(player_bubble)
|
||||
return _next_id(option)
|
||||
|
||||
|
||||
|
|
@ -134,15 +173,31 @@ func _apply_option_effects(option: Dictionary) -> void:
|
|||
var tone_shift := int(option.get("blade_heart", 0))
|
||||
if tone_shift != 0:
|
||||
GameState.shift_blade_heart_tone(tone_shift)
|
||||
_has_applied_effects = true
|
||||
var relationship_shifts: Dictionary = option.get("relationship", {})
|
||||
for npc_id in relationship_shifts:
|
||||
RelationshipSystem.adjust_relationship(str(npc_id), int(relationship_shifts[npc_id]))
|
||||
_has_applied_effects = true
|
||||
|
||||
|
||||
## Beendet den Dialog, markiert ihn als geführt und gibt Box und
|
||||
## Sprecher-Referenzen frei.
|
||||
func _end_dialogue(dialogue_id: String) -> void:
|
||||
GameState.mark_dialogue_completed(dialogue_id)
|
||||
## Spielt Tyrveils Abbruch-Zeile, damit der Abbruch dem Gegenüber
|
||||
## angesagt wird, bevor der Dialog endet.
|
||||
func _play_abort_line() -> void:
|
||||
_is_abort_requested = false
|
||||
_get_box().show_line(_display_name(PLAYER_SPEAKER_ID), _abort_line)
|
||||
var player_bubble := _bubble_for(PLAYER_SPEAKER_ID)
|
||||
if player_bubble != null:
|
||||
player_bubble.show_line(_abort_line)
|
||||
await _wait_for_line(player_bubble)
|
||||
|
||||
|
||||
## Beendet den Dialog und gibt Box und Sprecher-Referenzen frei. Als
|
||||
## geführt markiert wird er bei regulärem Ende immer, bei Abbruch nur,
|
||||
## wenn in diesem Durchlauf bereits Effekte angewendet wurden (verhindert
|
||||
## Werte-Farming, lässt aber den Erst-Durchlauf-Effekt bestehen).
|
||||
func _end_dialogue(dialogue_id: String, was_aborted := false) -> void:
|
||||
if not was_aborted or _has_applied_effects:
|
||||
GameState.mark_dialogue_completed(dialogue_id)
|
||||
_get_box().hide_box()
|
||||
is_dialogue_active = false
|
||||
_speakers.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue