A raging quest

This commit is contained in:
2026-02-25 19:46:10 -06:00
parent 2670392e2d
commit bf1ac4406c
9 changed files with 345 additions and 22 deletions
+89 -16
View File
@@ -1,24 +1,47 @@
extends Node3D
@export var day_length := 120.0 # seconds for full rotation
@export var start_light_angle := -90.0
@export var show_spawn_dialog := true
@export_multiline var spawn_dialog_text := "Welcome to Promiscuity.\n\nPress E to close this message."
@export var spawn_dialog_auto_close_seconds := 4.0
var end_light_angle = start_light_angle + 360.0
var start_radians = start_light_angle * PI / 180
var time := 0.0
@export var day_length := 120.0 # seconds for full rotation
@export var start_light_angle := -90.0
@export var show_spawn_dialog := true
@export_multiline var spawn_dialog_text := "Welcome to Promiscuity.\n\nPress E to close this message."
@export var spawn_dialog_auto_close_seconds := 4.0
var end_light_angle = start_light_angle + 360.0
var start_radians = start_light_angle * PI / 180
var time := 0.0
@onready var sun := $DirectionalLight3D
@onready var _player: Node = $Player
@onready var _quest_text: RichTextLabel = $PhoneUI/Control/PhoneFrame/QuestText
func _ready() -> void:
if show_spawn_dialog and DialogSystem and DialogSystem.has_method("show_text"):
await get_tree().process_frame
DialogSystem.show_text(spawn_dialog_text)
if spawn_dialog_auto_close_seconds > 0.0:
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
if DialogSystem and DialogSystem.has_method("close_if_text"):
DialogSystem.close_if_text(spawn_dialog_text)
const FIRST_QUEST_ID := "first_drive"
const FIRST_QUEST := {
"id": FIRST_QUEST_ID,
"title": "RepoBot's First Task",
"description": "Get familiar with movement and vehicles.",
"steps": [
{
"id": "enter_vehicle",
"text": "Get in the car (E).",
"complete_event": "entered_vehicle",
},
{
"id": "reach_checkpoint",
"text": "Drive the car into the checkpoint marker.",
"complete_event": "reach_checkpoint",
},
],
}
func _ready() -> void:
_setup_quests()
if show_spawn_dialog and DialogSystem and DialogSystem.has_method("show_text"):
await get_tree().process_frame
DialogSystem.show_text(spawn_dialog_text)
if spawn_dialog_auto_close_seconds > 0.0:
await get_tree().create_timer(spawn_dialog_auto_close_seconds).timeout
if DialogSystem and DialogSystem.has_method("close_if_text"):
DialogSystem.close_if_text(spawn_dialog_text)
_show_quest_intro_dialog()
func _process(delta):
time = fmod((time + delta), day_length)
@@ -32,3 +55,53 @@ func _process(delta):
var curSin = -sin((t * TAU) + start_radians)
var energy = clamp((curSin * 1.0) + 0.2, 0.0, 1.2)
sun.light_energy = energy
func _setup_quests() -> void:
if QuestManager == null:
return
if not QuestManager.has_quest(FIRST_QUEST_ID):
QuestManager.register_quest(FIRST_QUEST)
if not QuestManager.is_active_quest(FIRST_QUEST_ID) and not QuestManager.is_quest_completed(FIRST_QUEST_ID):
QuestManager.start_quest(FIRST_QUEST_ID)
if not QuestManager.is_connected("quest_state_changed", Callable(self, "_refresh_quest_ui")):
QuestManager.quest_state_changed.connect(_refresh_quest_ui)
if _player and _player.has_signal("vehicle_entered"):
if not _player.is_connected("vehicle_entered", Callable(self, "_on_player_vehicle_entered")):
_player.vehicle_entered.connect(_on_player_vehicle_entered)
_refresh_quest_ui()
func _on_player_vehicle_entered(_vehicle: Node) -> void:
if QuestManager:
QuestManager.emit_event(&"entered_vehicle")
func _refresh_quest_ui() -> void:
if _quest_text == null or QuestManager == null:
return
var state: Dictionary = QuestManager.get_active_quest_state()
if not bool(state.get("active", false)):
_quest_text.text = "No active quest."
return
var title := String(state.get("title", "Quest"))
if bool(state.get("completed", false)):
_quest_text.text = "[b]%s[/b]\nComplete." % title
return
var step_index: int = int(state.get("current_step_index", 0))
var total_steps: int = int(state.get("total_steps", 0))
var step_text := String(state.get("current_step_text", ""))
_quest_text.text = "[b]%s[/b]\nStep %d/%d\n%s" % [title, step_index + 1, total_steps, step_text]
func _show_quest_intro_dialog() -> void:
if QuestManager == null:
return
var state: Dictionary = QuestManager.get_active_quest_state()
if not bool(state.get("active", false)) or bool(state.get("completed", false)):
return
var step_text := String(state.get("current_step_text", ""))
if step_text.is_empty():
return
if DialogSystem and DialogSystem.has_method("show_text"):
DialogSystem.show_text("RepoBot: New task assigned.\n\n%s" % step_text)
+47 -1
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=61 format=3 uid="uid://dchj6g2i8ebph"]
[gd_scene load_steps=65 format=3 uid="uid://dchj6g2i8ebph"]
[ext_resource type="Script" uid="uid://brgmxhhhtakja" path="res://scenes/Levels/level.gd" id="1_a4mo8"]
[ext_resource type="PackedScene" uid="uid://bb6hj6l23043x" path="res://assets/models/human.blend" id="1_eg4yq"]
@@ -9,6 +9,7 @@
[ext_resource type="PackedScene" path="res://scenes/Vehicles/car.tscn" id="5_car"]
[ext_resource type="PackedScene" uid="uid://bnqaqbgynoyys" path="res://assets/models/TestCharAnimated.glb" id="5_fi66n"]
[ext_resource type="Script" uid="uid://bk53njt7i3kmv" path="res://scenes/Interaction/dialog_trigger_area.gd" id="6_dialog"]
[ext_resource type="Script" path="res://scenes/Quests/quest_trigger_area.gd" id="7_qtrigger"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_2q6dc"]
bounce = 0.5
@@ -200,6 +201,20 @@ material = SubResource("StandardMaterial3D_dialog_zone")
radius = 2.5
height = 5.0
[sub_resource type="SphereShape3D" id="SphereShape3D_checkpoint"]
radius = 3.0
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_checkpoint"]
transparency = 1
cull_mode = 2
shading_mode = 0
albedo_color = Color(1, 0.804, 0.204, 0.2)
[sub_resource type="SphereMesh" id="SphereMesh_checkpoint"]
material = SubResource("StandardMaterial3D_checkpoint")
radius = 3.0
height = 6.0
[sub_resource type="BoxShape3D" id="BoxShape3D_2q6dc"]
size = Vector3(1080, 2, 1080)
@@ -287,6 +302,19 @@ shape = SubResource("SphereShape3D_dialog_zone")
transform = Transform3D(0.8, 0, 0, 0, 0.8, 0, 0, 0, 0.8, 0, 0, 0)
mesh = SubResource("SphereMesh_dialog_zone")
[node name="QuestCheckpoint" type="Area3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 9, 0, -10)
script = ExtResource("7_qtrigger")
event_name = &"reach_checkpoint"
target_group = &"vehicle"
quest_id_filter = "first_drive"
[node name="CollisionShape3D" type="CollisionShape3D" parent="QuestCheckpoint"]
shape = SubResource("SphereShape3D_checkpoint")
[node name="Visual" type="MeshInstance3D" parent="QuestCheckpoint"]
mesh = SubResource("SphereMesh_checkpoint")
[node name="Ground" type="StaticBody3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0)
@@ -377,6 +405,24 @@ grow_horizontal = 2
grow_vertical = 2
color = Color(0.08, 0.08, 0.1, 1)
[node name="QuestTitle" type="Label" parent="PhoneUI/Control/PhoneFrame"]
layout_mode = 0
offset_left = 18.0
offset_top = 18.0
offset_right = 150.0
offset_bottom = 41.0
text = "Quest Log"
[node name="QuestText" type="RichTextLabel" parent="PhoneUI/Control/PhoneFrame"]
layout_mode = 0
offset_left = 18.0
offset_top = 52.0
offset_right = 344.0
offset_bottom = 613.0
bbcode_enabled = true
scroll_active = false
text = "No active quest."
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource("Environment_a4mo8")