diff --git a/Art/Patients/prime_supervisor/prime_supervisor.aseprite b/Art/Patients/prime_supervisor/prime_supervisor.aseprite index f63baac..fd031f5 100644 Binary files a/Art/Patients/prime_supervisor/prime_supervisor.aseprite and b/Art/Patients/prime_supervisor/prime_supervisor.aseprite differ diff --git a/globals.gd b/globals.gd index 8494c01..9796c9a 100644 --- a/globals.gd +++ b/globals.gd @@ -10,8 +10,6 @@ var patient_list = ["45", "46", "47", "48", "49", "50", "51"] var patients_seen: Array[String] var patient_id var interfloor_dialogue = load("res://Dialogues/interfloor.dialogue") -var dialogue_intro = load("res://Dialogues/intro.dialogue") -var dialogue_recovery = load("res://Dialogues/recovery.dialogue") var directives = "\n[center][font_size=22]INSTRUCTIONS[/font_size][/center] \n\n[font_size=18][color=forest_green]RELEASE[/color] HUMANS, [color=red]TERMINATE[/color] ABNORMALS \n\nIF A SUBJECT HAS [color=dark_orange]SYMPTOMS[/color] IT SHOULDN'T HAVE, @@ -29,6 +27,7 @@ signal response_chosen(DialogueResponse) signal clear_patient signal color_change signal character_label_color_change +signal start_balloon # Called when the node enters the scene tree for the first time. func _ready() -> void: diff --git a/main_hub.gd b/main_hub.gd index 70c8527..a47addd 100644 --- a/main_hub.gd +++ b/main_hub.gd @@ -13,8 +13,6 @@ var balloon: Node # Called when the node enters the scene tree for the first time. func _ready() -> void: - Patient.sort_patients() - #Adding Scenes var title_screen = TitleScreen.instantiate() var screening_desk = ScreeningDesk.instantiate() @@ -42,10 +40,13 @@ func _ready() -> void: UI.connect("auto_value_changed", self._on_auto_value_changed) Globals.character_label_color_change.connect(self._on_character_label_color_change) + Globals.start_balloon.connect(self.start_balloon) #Updating Save/Load Slots Information based on Existing Saves update_slots() - + + #Sorting patients by floor + Patient.sort_patients() # Starts a new game @@ -105,8 +106,8 @@ func start_day(): await TransitionScreen.transition_finished #Supervisor Dialogue - $ScreeningDesk.supervisor_dialogue(Globals.interfloor_dialogue, "interfloor_" + str(-Globals.floor_count-1)) - await $ScreeningDesk.supervisor_dialogue_finished + $ScreeningDesk.supervisor.dialogue(Globals.interfloor_dialogue, "interfloor_" + str(-Globals.floor_count-1)) + await $ScreeningDesk.supervisor.dialogue_finished $ScreeningDesk.console_display(Globals.directives) $ScreeningDesk.new_patient() @@ -263,9 +264,12 @@ func start_balloon(balloon_type:String, dialogue_resource: Resource, start_title get_tree().current_scene.add_child(balloon) #Connects emotion signals if needed - if balloon_type == "screening": - DialogueManager.got_dialogue.connect($ScreeningDesk._change_emotion) - DialogueManager.got_dialogue.connect($ScreeningDesk._recording_text) + match balloon_type: + "screening": + DialogueManager.got_dialogue.connect($ScreeningDesk.patient._change_emotion) + DialogueManager.got_dialogue.connect($ScreeningDesk._recording_text) + "supervisor": + DialogueManager.got_dialogue.connect($ScreeningDesk.supervisor._change_emotion) #Applies text settings to the balloon balloon.dialogue_label.seconds_per_step = UI.text_speed @@ -283,10 +287,11 @@ func clear_balloon(): balloon.queue_free() #Disconnecting emotion signals - if DialogueManager.is_connected("got_dialogue", $ScreeningDesk._change_emotion): - DialogueManager.disconnect("got_dialogue", $ScreeningDesk._change_emotion) - if DialogueManager.is_connected("got_dialogue", $ScreeningDesk._recording_text): - DialogueManager.disconnect("got_dialogue", $ScreeningDesk._recording_text) + for function in [$ScreeningDesk.patient._change_emotion, + $ScreeningDesk._recording_text, + $ScreeningDesk.supervisor._change_emotion]: + if DialogueManager.is_connected("got_dialogue", function): + DialogueManager.disconnect("got_dialogue", function) #Changes text_speed value diff --git a/patient.gd b/patient.gd index 8fc78f8..9858e88 100644 --- a/patient.gd +++ b/patient.gd @@ -1,175 +1,16 @@ -extends Node +extends TextureRect -#Dialogue variables -var dialog_tree: Dictionary -var marker: Array[int] -var dialogue_resource: Resource -#Patient attributes -var texture := TextureRect.new() -var image : Texture2D -var original_color: Color -var emotions : Dictionary -var abnormal: bool - -#Patient file -var file_text : String -var file_title: String - -#Patient symptoms ordered from floor to floor -var symptoms_arrays: Array[Array] = [ -["SUICIDAL IDEATIONS", "PERSECUTORY DELUSIONS", "MANIA", "AUDITORY HALLUCINATIONS"], -["MEGALOMANIAC DELUSIONS", "PANIC ATTACKS"], -["MYSTICAL DELUSIONS", "CENESTHETIC HALLUCINATIONS"], -["HAPTIC HALLUCINATIONS", "SELF-MUTILATION"], -["HETERO-AGRESSIVE BEHAVIOUR", "VISUAL HALLUCINATIONS"] -] -#Lists of possible patients sorted by floor -var patient_list : Array[Array] - -# Called when the node enters the scene tree for the first time. func _ready() -> void: - - #Setting up dialogue marker - marker.resize(100) - marker.fill(0) - - #Setting up patient list - patient_list.resize(len(symptoms_arrays)) - - original_color = texture.modulate #Saving original modulation color to reset it after modification + pass -func build_dialog_tree(tree_model: Array[int]) -> Dictionary: #Builds the dialog tree for each dialogue - - var branch : Dictionary - var tree : Dictionary - - for branch_id in tree_model: - branch = {branch_id: "not_asked"} - tree.merge(branch) - - return tree - - -func new_patient(): - - var file_path: String - - #Generating patient_id - var floor_index = -Globals.floor_count -1 - print("Floor Index: " + str(floor_index)) - var patient_id = weighted_random(patient_list[floor_index]) - Globals.patient_id = patient_id - Globals.patient_list.erase(patient_id) #Line to be reenabled when there is more than one patient in the list - Globals.patients_seen.append(patient_id) - - #Loading Patient Files - var config := ConfigFile.new() - file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg" - config.load(file_path) - - #Setting up Patient File - var patient_name = config.get_value("", "name") - var age = config.get_value("", "age") - var profession = config.get_value("", "profession") - var psychiatric_assessment = config.get_value("", "psychiatric_assessment") - - file_text = "NAME: " + patient_name + "\nAGE: " + age + "\n\nPROFESSION: " + profession + "\n\nPRE-SCREENING PSYCHIATRIC ASSESSMENT:\n\n" + "[color=orange_red]" + psychiatric_assessment + "[/color]" - file_title = "[center]PATIENT FILE #" + patient_id - - #Loading Patient Initial Face - var initial_emotion = config.get_value("", "initial_emotion") - file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_" + initial_emotion + ".png" - image = load(file_path) - - #Loading Face Emotions - var face: Resource - var emotion_branch: Dictionary - var emotion_list = ["neutral", "peaceful", "praying", "puzzled", - "sadsmiling", "crazysmiling", "smiling", "laughing", "happy", "elated", "maniac", "irritated", "angry", - "sad", "depressed", "crying", "surprised", "worried", "scared", "shocked", "panicked", "suspicious", - "abnormal", "abnormal1", "abnormal2", "special"] - - emotions.clear() #Clearing previous patient emotions - for emotion in emotion_list: - file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_" + emotion + ".png" - face = load(file_path) - if face != null: - emotion_branch = {emotion: face} - emotions.merge(emotion_branch) - - #Loading Dialogue Resource - file_path = "res://Dialogues/Patients/patient_" + patient_id + ".dialogue" - dialogue_resource = load(file_path) - - #Randomizing abnormal status if required - var status = config.get_value("", "status") - match status: - "random": - abnormal = randf() < 0.5 #50/50 abnormal/normal - print("Abnormal value: " + str(abnormal)) - "normal": - abnormal = false - "abnormal": - abnormal = true - - -#Sorts the patients to determine who can appear on what floor depending on the symptoms unlocked -func sort_patients(): - - var config := ConfigFile.new() - var file_path : String - var patient_symptoms: Array - var symptom_matched : bool - var symptom_list: Array - - for patient_id in Globals.patient_list: - patient_symptoms.clear() - file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg" - config.load(file_path) - symptom_list = config.get_value("", "psychiatric_assessment").split("\n", false) - patient_symptoms = symptom_list - symptom_list = config.get_value("", "abnormal_symptoms").split("\n", false) - patient_symptoms.append_array(symptom_list) - print("Patient #" + patient_id + " symptom list: " + str(patient_symptoms)) - #Goes through the symptoms_arrays from the last to the first, - #If a symptom matches with the patient symptoms, - #Add that patient to the floors from that floor to the last one - - for j in range(len(symptoms_arrays)-1, -1, -1): - for symptom in patient_symptoms: - if symptoms_arrays[j].has(symptom): - symptom_matched = true - print("Symptom matched: " + str(symptoms_arrays[j]) + " and " + str(symptom)) - break - if symptom_matched: - for k in range(j, symptoms_arrays.size()): - patient_list[k].append({"patient_id": patient_id, "weight": j+1}) - symptom_matched = false - break - - for i in range(len(patient_list)): - print("Floor " + str(i) + " possible patients: " + str(patient_list[i])) - - -#Weighted random selection from an Array -func weighted_random(array: Array): - - #Calculating total weight - var total_weight : int - for item in array: - total_weight += item.weight - print("Total weight: " + str(total_weight)) - - var r = randf() * total_weight - print("r :" + str(r)) - - var weight_sum : int - for item in array: - weight_sum += item.weight - if weight_sum >= r: - print("Patient selected: " + item.patient_id + ", Weight: " + str(item.weight)) - return item.patient_id - return null +#Change emotions following dialogue tags +func _change_emotion(dialogue_line) -> void: + var line_tag = dialogue_line.tags + print("Patient marker value: " + str(Patient.marker[0])) + if line_tag.is_empty() == false: + var new_emotion = line_tag[0] + texture = Patient.emotions[String(new_emotion)] + print("Emotion changed to ", new_emotion) diff --git a/patient.gd.uid b/patient.gd.uid index aa10e1f..964ea37 100644 --- a/patient.gd.uid +++ b/patient.gd.uid @@ -1 +1 @@ -uid://by4i7c1foffu3 +uid://vjvnh47s4akq diff --git a/patient_global.gd b/patient_global.gd new file mode 100644 index 0000000..8fc78f8 --- /dev/null +++ b/patient_global.gd @@ -0,0 +1,175 @@ +extends Node + +#Dialogue variables +var dialog_tree: Dictionary +var marker: Array[int] +var dialogue_resource: Resource + +#Patient attributes +var texture := TextureRect.new() +var image : Texture2D +var original_color: Color +var emotions : Dictionary +var abnormal: bool + +#Patient file +var file_text : String +var file_title: String + +#Patient symptoms ordered from floor to floor +var symptoms_arrays: Array[Array] = [ +["SUICIDAL IDEATIONS", "PERSECUTORY DELUSIONS", "MANIA", "AUDITORY HALLUCINATIONS"], +["MEGALOMANIAC DELUSIONS", "PANIC ATTACKS"], +["MYSTICAL DELUSIONS", "CENESTHETIC HALLUCINATIONS"], +["HAPTIC HALLUCINATIONS", "SELF-MUTILATION"], +["HETERO-AGRESSIVE BEHAVIOUR", "VISUAL HALLUCINATIONS"] +] +#Lists of possible patients sorted by floor +var patient_list : Array[Array] + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + + #Setting up dialogue marker + marker.resize(100) + marker.fill(0) + + #Setting up patient list + patient_list.resize(len(symptoms_arrays)) + + original_color = texture.modulate #Saving original modulation color to reset it after modification + + +func build_dialog_tree(tree_model: Array[int]) -> Dictionary: #Builds the dialog tree for each dialogue + + var branch : Dictionary + var tree : Dictionary + + for branch_id in tree_model: + branch = {branch_id: "not_asked"} + tree.merge(branch) + + return tree + + +func new_patient(): + + var file_path: String + + #Generating patient_id + var floor_index = -Globals.floor_count -1 + print("Floor Index: " + str(floor_index)) + var patient_id = weighted_random(patient_list[floor_index]) + Globals.patient_id = patient_id + Globals.patient_list.erase(patient_id) #Line to be reenabled when there is more than one patient in the list + Globals.patients_seen.append(patient_id) + + #Loading Patient Files + var config := ConfigFile.new() + file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg" + config.load(file_path) + + #Setting up Patient File + var patient_name = config.get_value("", "name") + var age = config.get_value("", "age") + var profession = config.get_value("", "profession") + var psychiatric_assessment = config.get_value("", "psychiatric_assessment") + + file_text = "NAME: " + patient_name + "\nAGE: " + age + "\n\nPROFESSION: " + profession + "\n\nPRE-SCREENING PSYCHIATRIC ASSESSMENT:\n\n" + "[color=orange_red]" + psychiatric_assessment + "[/color]" + file_title = "[center]PATIENT FILE #" + patient_id + + #Loading Patient Initial Face + var initial_emotion = config.get_value("", "initial_emotion") + file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_" + initial_emotion + ".png" + image = load(file_path) + + #Loading Face Emotions + var face: Resource + var emotion_branch: Dictionary + var emotion_list = ["neutral", "peaceful", "praying", "puzzled", + "sadsmiling", "crazysmiling", "smiling", "laughing", "happy", "elated", "maniac", "irritated", "angry", + "sad", "depressed", "crying", "surprised", "worried", "scared", "shocked", "panicked", "suspicious", + "abnormal", "abnormal1", "abnormal2", "special"] + + emotions.clear() #Clearing previous patient emotions + for emotion in emotion_list: + file_path = "res://Art/Patients/patient_" + patient_id + "/patient_" + patient_id + "_" + emotion + ".png" + face = load(file_path) + if face != null: + emotion_branch = {emotion: face} + emotions.merge(emotion_branch) + + #Loading Dialogue Resource + file_path = "res://Dialogues/Patients/patient_" + patient_id + ".dialogue" + dialogue_resource = load(file_path) + + #Randomizing abnormal status if required + var status = config.get_value("", "status") + match status: + "random": + abnormal = randf() < 0.5 #50/50 abnormal/normal + print("Abnormal value: " + str(abnormal)) + "normal": + abnormal = false + "abnormal": + abnormal = true + + +#Sorts the patients to determine who can appear on what floor depending on the symptoms unlocked +func sort_patients(): + + var config := ConfigFile.new() + var file_path : String + var patient_symptoms: Array + var symptom_matched : bool + var symptom_list: Array + + for patient_id in Globals.patient_list: + patient_symptoms.clear() + file_path = "res://Dialogues/Patients/patient_" + patient_id + "_file.cfg" + config.load(file_path) + symptom_list = config.get_value("", "psychiatric_assessment").split("\n", false) + patient_symptoms = symptom_list + symptom_list = config.get_value("", "abnormal_symptoms").split("\n", false) + patient_symptoms.append_array(symptom_list) + print("Patient #" + patient_id + " symptom list: " + str(patient_symptoms)) + #Goes through the symptoms_arrays from the last to the first, + #If a symptom matches with the patient symptoms, + #Add that patient to the floors from that floor to the last one + + for j in range(len(symptoms_arrays)-1, -1, -1): + for symptom in patient_symptoms: + if symptoms_arrays[j].has(symptom): + symptom_matched = true + print("Symptom matched: " + str(symptoms_arrays[j]) + " and " + str(symptom)) + break + if symptom_matched: + for k in range(j, symptoms_arrays.size()): + patient_list[k].append({"patient_id": patient_id, "weight": j+1}) + symptom_matched = false + break + + for i in range(len(patient_list)): + print("Floor " + str(i) + " possible patients: " + str(patient_list[i])) + + +#Weighted random selection from an Array +func weighted_random(array: Array): + + #Calculating total weight + var total_weight : int + for item in array: + total_weight += item.weight + print("Total weight: " + str(total_weight)) + + var r = randf() * total_weight + print("r :" + str(r)) + + var weight_sum : int + for item in array: + weight_sum += item.weight + if weight_sum >= r: + print("Patient selected: " + item.patient_id + ", Weight: " + str(item.weight)) + return item.patient_id + return null + diff --git a/patient_global.gd.uid b/patient_global.gd.uid new file mode 100644 index 0000000..aa10e1f --- /dev/null +++ b/patient_global.gd.uid @@ -0,0 +1 @@ +uid://by4i7c1foffu3 diff --git a/project.godot b/project.godot index 8be6596..974f5f9 100644 --- a/project.godot +++ b/project.godot @@ -19,7 +19,7 @@ config/features=PackedStringArray("4.5", "Forward Plus") Globals="*res://globals.gd" TransitionScreen="*res://transition_screen.tscn" UI="*res://ui.tscn" -Patient="*res://patient.gd" +Patient="*res://patient_global.gd" DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd" [dialogue_manager] diff --git a/screening_desk.gd b/screening_desk.gd index 5d4bf08..3f03035 100644 --- a/screening_desk.gd +++ b/screening_desk.gd @@ -39,7 +39,6 @@ extends Control var main: Node var accurate_diagnoses = 0 -signal supervisor_dialogue_finished func _ready() -> void: @@ -99,7 +98,7 @@ func new_patient(): func _on_call_next_patient_pressed(): #Brings in next patient and sets up the desk controls #Hiding the next_patient button and shows transition messages on computer and console - var scenes_to_hide = [next_patient] + var scenes_to_hide = [next_patient, supervisor] for scenes in scenes_to_hide: scenes.hide() var message : String @@ -205,23 +204,10 @@ func _on_tab_recording_pressed(): #Shows the recording tab computer_tabs.get_node("Recording").show() -func _change_emotion(dialogue_line) -> void: #Change emotions following dialogue tags - - var line_tag = dialogue_line.tags - print("Patient marker value: " + str(Patient.marker[0])) - if line_tag.is_empty() == false: - var new_emotion = line_tag[0] - patient.texture = Patient.emotions[String(new_emotion)] - print("Emotion changed to ", new_emotion) - - func _on_green_button_pressed(): #Releases the patient - decision_made("release") - func _on_red_button_pressed(): #Terminates the patient - decision_made("terminate") @@ -369,25 +355,9 @@ func descend_floor(): #Descends to next floor console_screen.hide() #Interfloor dialogue - supervisor_dialogue(Globals.interfloor_dialogue, "interfloor_" + str(-Globals.floor_count-1)) - await supervisor_dialogue_finished + supervisor.dialogue(Globals.interfloor_dialogue, "interfloor_" + str(-Globals.floor_count-1)) + await supervisor.dialogue_finished #Setting up new patient new_patient() - - -#Supervisor dialogue, mainly between floors -func supervisor_dialogue(dialogue_resource, dialogue_start): - - #Interfloor dialogue - supervisor.show() - supervisor.reveal_spray() - await supervisor.reveal_done - main.start_balloon("screening", dialogue_resource, dialogue_start) - await DialogueManager.dialogue_ended - supervisor.hide_spray() - await supervisor.hide_done - supervisor.hide() - - supervisor_dialogue_finished.emit() diff --git a/screening_desk.tscn b/screening_desk.tscn index bbda372..663c684 100644 --- a/screening_desk.tscn +++ b/screening_desk.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=43 format=3 uid="uid://chytk2cctjk3x"] +[gd_scene load_steps=44 format=3 uid="uid://chytk2cctjk3x"] [ext_resource type="Script" uid="uid://b3ms0imu0umn8" path="res://screening_desk.gd" id="1_1s7k3"] [ext_resource type="Texture2D" uid="uid://5f5bsergnjtv" path="res://Art/Patients/prime_supervisor/prime_supervisor_hologram.png" id="3_fev1v"] [ext_resource type="Texture2D" uid="uid://b2epvjeqvmgrs" path="res://Art/Rooms/screening_room/screening_room_glass.png" id="3_nxnrp"] +[ext_resource type="Script" uid="uid://vjvnh47s4akq" path="res://patient.gd" id="4_43vqp"] [ext_resource type="Texture2D" uid="uid://by34irl73n8pb" path="res://Art/Rooms/screening_room/backroom.png" id="4_fij8w"] [ext_resource type="Shader" uid="uid://dwepb0lm1veje" path="res://supervisor.gdshader" id="4_qsin6"] [ext_resource type="Script" uid="uid://cdkbyikbjqlsh" path="res://supervisor.gd" id="5_43vqp"] @@ -316,8 +317,8 @@ offset_top = -450.0 offset_right = 300.0 grow_horizontal = 2 grow_vertical = 0 -texture = ExtResource("3_fev1v") stretch_mode = 3 +script = ExtResource("4_43vqp") [node name="Supervisor" type="TextureRect" parent="UpperHalf/ControlGlass"] visible = false diff --git a/supervisor.gd b/supervisor.gd index 4eaf99f..dd7ba26 100644 --- a/supervisor.gd +++ b/supervisor.gd @@ -4,11 +4,13 @@ extends TextureRect signal reveal_done signal hide_done +signal dialogue_finished + func _ready(): randomize() - # --- Création du bruit --- + #Noise setup var noise := FastNoiseLite.new() noise.noise_type = FastNoiseLite.TYPE_SIMPLEX noise.frequency = 20.0 @@ -23,6 +25,7 @@ func _ready(): mat.set_shader_parameter("noise_tex", noise_tex) +#Revealing supervisor in a noise spray func reveal_spray(): mat.set_shader_parameter("progress", 0.0) @@ -36,6 +39,7 @@ func reveal_spray(): reveal_done.emit() +#hiding supervisor in a hiding spray func hide_spray(): mat.set_shader_parameter("progress", 1.0) @@ -49,6 +53,38 @@ func hide_spray(): hide_done.emit() +#Progressing the reveal/hide func set_progress(value: float): - mat.set_shader_parameter("progress", value) + + + +#Supervisor dialogue, mainly between floors +func dialogue(dialogue_resource, dialogue_start): + + #Showing the supervisor + show() + reveal_spray() + await reveal_done + + #Dialogue + Globals.start_balloon.emit("screening", dialogue_resource, dialogue_start) + await DialogueManager.dialogue_ended + + #Hiding the supervisor + hide_spray() + await hide_done + hide() + + dialogue_finished.emit() + + +#Change emotions following dialogue tags +func _change_emotion(dialogue_line) -> void: + + var line_tag = dialogue_line.tags + print("Supervisor marker value: " + str(Patient.marker[0])) + if line_tag.is_empty() == false: + var new_emotion = line_tag[0] + texture = Patient.emotions[String(new_emotion)] + print("Emotion changed to ", new_emotion)