Connect bear-save, massage, farm paywall, cheese catapults, Dressler hijack, final boss phases, fat-stim UI, and scene fixes so the satire path plays through.
91 lines
3 KiB
GDScript
91 lines
3 KiB
GDScript
extends Node3D
|
|
## Glitschkönig: Reveal, Quirxels, Split-Phasen, Flucht des letzten Pixels.
|
|
|
|
enum Phase { FULL, SPLIT, FLEE, DONE }
|
|
|
|
var _phase: Phase = Phase.FULL
|
|
var _revealed: bool = false
|
|
var _splits_left: int = 2
|
|
|
|
func _ready() -> void:
|
|
GameState.current_scene_id = "final_boss"
|
|
GameState.heal_full()
|
|
_revealed = bool(GameState.get_flag("glitsch_revealed", false))
|
|
if not _revealed:
|
|
_do_reveal()
|
|
var boss := get_node_or_null("Hongkong")
|
|
if boss:
|
|
boss.set("max_hp", 12)
|
|
if boss.has_signal("hit"):
|
|
boss.hit.connect(_on_boss_hit)
|
|
if boss.has_signal("defeated"):
|
|
boss.defeated.connect(_on_boss_defeated)
|
|
var t := Timer.new()
|
|
t.wait_time = 2.8
|
|
t.autostart = true
|
|
t.timeout.connect(_spawn_quirxel)
|
|
add_child(t)
|
|
|
|
func _do_reveal() -> void:
|
|
GameState.set_flag("glitsch_revealed", true)
|
|
Inventory.add_item("banana", 1)
|
|
Inventory.add_item("wartchen", 1)
|
|
var ui := get_node_or_null("/root/UIRoot")
|
|
if ui and ui.has_method("show_dialog"):
|
|
ui.show_dialog(Locale.tr_key("dialog_reveal"), 5.5)
|
|
|
|
func _on_boss_hit(remaining: int) -> void:
|
|
if _phase == Phase.FULL and remaining <= 6 and _splits_left > 0:
|
|
_phase = Phase.SPLIT
|
|
_splits_left -= 1
|
|
_spawn_split_clone()
|
|
var ui := get_node_or_null("/root/UIRoot")
|
|
if ui and ui.has_method("show_dialog"):
|
|
ui.show_dialog("Er teilt sich wie Minecraft-Schleim!", 2.5)
|
|
elif remaining <= 2 and _phase != Phase.FLEE and _phase != Phase.DONE:
|
|
_phase = Phase.FLEE
|
|
var boss := get_node_or_null("Hongkong")
|
|
if boss is Node3D:
|
|
boss.global_position += Vector3(randf_range(-4, 4), 0, -3)
|
|
|
|
func _spawn_split_clone() -> void:
|
|
var scene: PackedScene = load("res://scenes/prefabs/enemy.tscn")
|
|
if scene == null:
|
|
return
|
|
var c: Node3D = scene.instantiate()
|
|
c.name = "GlitschSplit"
|
|
add_child(c)
|
|
c.global_position = Vector3(randf_range(-3, 3), 0.1, -2)
|
|
c.set("max_hp", 4)
|
|
c.set("texture_path", "res://assets/sprites/placeholders/hongkong.png")
|
|
var bill = c.get_node_or_null("BillboardSprite")
|
|
if bill and bill.has_method("set_texture"):
|
|
var tex: Texture2D = load("res://assets/sprites/placeholders/hongkong.png")
|
|
if tex:
|
|
bill.set_texture(tex)
|
|
|
|
func _spawn_quirxel() -> void:
|
|
if _phase == Phase.DONE or GameState.get_flag("hongkong_defeated", false):
|
|
return
|
|
var scene: PackedScene = load("res://scenes/prefabs/hazard.tscn")
|
|
if scene == null:
|
|
return
|
|
var h: Node3D = scene.instantiate()
|
|
add_child(h)
|
|
h.global_position = Vector3(randf_range(-6, 6), 0.1, randf_range(-6, 0))
|
|
h.set("death_cause_key", "death_quirxel")
|
|
await get_tree().create_timer(5.0).timeout
|
|
if is_instance_valid(h):
|
|
h.queue_free()
|
|
|
|
func _on_boss_defeated() -> void:
|
|
_phase = Phase.DONE
|
|
Achievements.unlock("beat_hongkong")
|
|
GameState.set_flag("hongkong_defeated", true)
|
|
var ui := get_node_or_null("/root/UIRoot")
|
|
if ui and ui.has_method("show_dialog"):
|
|
ui.show_dialog(Locale.tr_key("dialog_hongkong_boss"), 3.0)
|
|
await get_tree().create_timer(2.5).timeout
|
|
ui.show_dialog(Locale.tr_key("dialog_bear_end"), 5.0)
|
|
await get_tree().create_timer(3.5).timeout
|
|
GameState.goto_scene("end_screen")
|