152 lines
5.0 KiB
GDScript
152 lines
5.0 KiB
GDScript
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 patient_id = Globals.patient_list.pick_random()
|
|
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 i in range(45,52):
|
|
patient_symptoms.clear()
|
|
file_path = "res://Dialogues/Patients/patient_" + str(i) + "_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 #" + str(i) + " 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(str(i))
|
|
symptom_matched = false
|
|
break
|
|
|
|
for i in range(len(patient_list)):
|
|
print("Floor " + str(i) + " possible patients: " + str(patient_list[i]))
|