hood_lie_detector.gd 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. extends Node3D
  2. var quicktime_scene = preload("res://Scenes/quicktime_event.tscn")
  3. @onready var confidence_bar = $Camera3D/confidence
  4. @onready var dialog = $Camera3D/dialog
  5. @onready var time_bar = $Camera3D/time
  6. var time_left = 1
  7. var confidence = 1
  8. var minigame = false
  9. # Define possible keys for quicktime events with their corresponding display strings
  10. var possible_keys = [
  11. {"key": KEY_A, "text": "A"},
  12. {"key": KEY_C, "text": "C"},
  13. {"key": KEY_D, "text": "D"},
  14. {"key": KEY_E, "text": "E"},
  15. {"key": KEY_F, "text": "F"},
  16. {"key": KEY_G, "text": "G"},
  17. {"key": KEY_H, "text": "H"},
  18. {"key": KEY_Q, "text": "Q"},
  19. {"key": KEY_R, "text": "R"},
  20. {"key": KEY_S, "text": "S"},
  21. {"key": KEY_T, "text": "T"},
  22. {"key": KEY_U, "text": "U"},
  23. {"key": KEY_V, "text": "V"},
  24. {"key": KEY_W, "text": "W"},
  25. {"key": KEY_X, "text": "X"},
  26. {"key": KEY_Y, "text": "Y"},
  27. {"key": KEY_Z, "text": "Z"},
  28. ]
  29. # Added variables for QTE timing
  30. var qte_cooldown = 0
  31. var last_qte_time = 0
  32. func _process(delta):
  33. if minigame:
  34. time_bar.visible = true
  35. confidence_bar.visible = true
  36. time_left -= 0.08 * delta
  37. time_left = max(time_left, 0)
  38. time_bar.scale = Vector2(time_left, time_bar.scale.y)
  39. if time_left == 0: time_fail()
  40. confidence -= 0.05 * delta
  41. confidence = max(confidence, 0)
  42. confidence_bar.scale = Vector2(confidence, confidence_bar.scale.y)
  43. if confidence == 0: confidence_fail()
  44. # Handle QTE cooldown
  45. qte_cooldown -= delta
  46. # Generate new quicktime events occasionally if cooldown has expired
  47. if qte_cooldown <= 0 and Time.get_ticks_msec() - last_qte_time > 500:
  48. generate_random_quicktime()
  49. # Set a random cooldown between 2-4 seconds before next QTE
  50. qte_cooldown = randf_range(0.5, 1.5)
  51. else:
  52. time_bar.visible = false
  53. confidence_bar.visible = false
  54. # Called when the node enters the scene tree for the first time.
  55. func _ready():
  56. if not get_tree().root.has_node("Main Menu"):
  57. dialog.set_text("")
  58. Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
  59. dialog.visible = true
  60. dialog.clear_options()
  61. await get_tree().create_timer(2).timeout
  62. await show_cop_dialog("alright, did you kill those people cuh?", $audio/cop/alr_did_you_kill_those_people_cuh)
  63. dialog.add_option("DUHHH", duhhh)
  64. dialog.add_option("HELL NAW", hell_naw)
  65. dialog.add_option("idk what ur talking about", idk_what_ur_talking_about)
  66. dialog.show_options()
  67. func _on_music_finished() -> void:
  68. $music.play()
  69. var time_fale = false
  70. func time_fail():
  71. if time_fale: return
  72. minigame = false
  73. time_fale = true
  74. $Camera3D/pointer.visible = true
  75. $Camera3D/pointer/buzzer.play()
  76. jail()
  77. var confidence_fale = false
  78. func confidence_fail():
  79. if confidence_fale: return
  80. minigame = false
  81. confidence_fale = true
  82. confidence += 0.3
  83. $Camera3D/pointer.visible = true
  84. $Camera3D/pointer/buzzer.play()
  85. jail()
  86. # New function to generate random quicktime events
  87. func generate_random_quicktime():
  88. # Select a random key from the possible keys
  89. var random_key_entry = possible_keys[randi() % possible_keys.size()]
  90. var random_key = random_key_entry["key"]
  91. var key_text = random_key_entry["text"]
  92. # Generate random position within visible screen area
  93. var screen_size = get_viewport().get_visible_rect().size
  94. var random_x = randf_range(70, screen_size.x - 70)
  95. var random_y = randf_range(70, screen_size.y - 70)
  96. var random_position = Vector2(random_x, random_y)
  97. # Random time between 0.6 and 1.2 seconds
  98. var random_time = randf_range(0.6, 1.2)
  99. # Create the quicktime event
  100. add_quicktime(random_key, key_text, random_time, success, fail, random_position, Vector2(0.3, 0.2))
  101. func add_quicktime(key, text: String, time: float, success_c: Callable, fail_c: Callable, pos: Vector2, scal: Vector2):
  102. var qte = quicktime_scene.instantiate()
  103. add_child(qte)
  104. qte.set_key(key)
  105. qte.set_text(text)
  106. qte.set_time(time)
  107. qte.set_success_callback(success_c)
  108. qte.set_fail_callback(fail_c)
  109. qte.position = pos
  110. qte.scale = scal
  111. func detector_true():
  112. $"fucking_lie_detec/he lying".visible = false
  113. $"fucking_lie_detec/on FOENEM".visible = true
  114. return play_audio_and_wait($"audio/ON FOENEM")
  115. func detector_false():
  116. $"fucking_lie_detec/he lying".visible = true
  117. $"fucking_lie_detec/on FOENEM".visible = false
  118. return play_audio_and_wait($"audio/YOU LYIN")
  119. func hide_detector():
  120. $"fucking_lie_detec/he lying".visible = false
  121. $"fucking_lie_detec/on FOENEM".visible = false
  122. # Helper function to play audio and wait for it to finish
  123. func play_audio_and_wait(audio_node):
  124. audio_node.play()
  125. return audio_node.finished
  126. # Helper function for common dialog sequence
  127. func handle_dialog_sequence(player_audio, detector_result):
  128. time_left = 1
  129. dialog.clear_options()
  130. await play_audio_and_wait(player_audio)
  131. await get_tree().create_timer(1).timeout
  132. if confidence >= 0.7:
  133. if detector_result == "true":
  134. await detector_true()
  135. else:
  136. await detector_false()
  137. else:
  138. if detector_result == "true":
  139. await detector_false()
  140. else:
  141. await detector_true()
  142. hide_detector()
  143. # Core functions
  144. func success():
  145. confidence += 0.05
  146. func fail():
  147. confidence -= 0.01
  148. # Helper for showing cop dialog
  149. func show_cop_dialog(text: String, audio_node):
  150. dialog.set_text(text)
  151. await play_audio_and_wait(audio_node)
  152. await get_tree().create_timer(0.5).timeout
  153. # Helper for showing "you are dumb" dialog branch
  154. func show_dumb_dialog():
  155. await show_cop_dialog("ok so you are dumb...", $audio/cop/ok_so_you_are_dumb)
  156. dialog.add_option("im insane", yes_i_plead_mental_insanity_sire)
  157. dialog.add_option("HELL NAW", hell_naw_jail)
  158. dialog.add_option("alzheimer?", i_got_the_alice_heimer)
  159. dialog.show_options()
  160. # Helper for showing "osama bin laden" dialog branch
  161. func show_osama_dialog():
  162. await show_cop_dialog("who's osama bin alden?", $audio/cop/whos_osama_bin_laden)
  163. dialog.add_option("i love him", hes_my_pookie_popstar)
  164. dialog.add_option("you retarded", aw_hell_na_jigsaw_you_dumb)
  165. dialog.add_option("i dont remember", actually_i_dont_remember)
  166. dialog.show_options()
  167. # Exit outcomes
  168. func jail():
  169. dialog.clear_options()
  170. await show_cop_dialog("AW HELL NA you goin to JAIL", $audio/cop/aw_hell_na_you_goin_to_JAIL)
  171. await get_tree().create_timer(1).timeout
  172. GameManager.goto_scene("res://Scenes/jail.tscn", false)
  173. # First level options
  174. func duhhh():
  175. await handle_dialog_sequence($audio/player/DUHH, "true")
  176. jail()
  177. func hell_naw():
  178. minigame = true
  179. $music.play()
  180. await handle_dialog_sequence($audio/player/hell_na, "false")
  181. await show_cop_dialog("you finna go to jail for LIFE cuh", $audio/cop/you_finna_go_to_jail_for_LIFE_cuh)
  182. dialog.add_option("i dont feel like it", what_if_i_dont_feel_like_it)
  183. dialog.add_option("the ac unit did it", nahh_i_didnt_do_it_the_ac_unit_did_yk)
  184. dialog.add_option("im busy tonight", aw_hell_na_i_got_a_date_with_osama_bin_landen_tonight)
  185. dialog.show_options()
  186. func idk_what_ur_talking_about():
  187. minigame = true
  188. $music.play()
  189. await handle_dialog_sequence($audio/player/idk_what_ur_talking_about, "false")
  190. await show_cop_dialog("are you DUMB cuh? we finna SANDPAPER yo TEETH", $audio/cop/are_you_dumb_cuh_we_finna_sandpaper_yo_teeth)
  191. dialog.add_option('what is "teeth"', what_is_teeth)
  192. dialog.add_option("how am i gonna give teeth now?", aw_hell_na_how_am_i_gonna_give_bin_laden_teeth_then)
  193. dialog.add_option("the ac unit did it!!", i_mean_i_didnt_do_it_the_ac_unit_did)
  194. dialog.show_options()
  195. # Second level options
  196. func what_is_teeth():
  197. await handle_dialog_sequence($audio/player/what_is_teeth, "true")
  198. await show_dumb_dialog()
  199. func aw_hell_na_how_am_i_gonna_give_bin_laden_teeth_then():
  200. await handle_dialog_sequence($audio/player/aw_hell_na_how_am_i_gonna_give_bin_laden_teeth_then, "false")
  201. await show_osama_dialog()
  202. func i_mean_i_didnt_do_it_the_ac_unit_did():
  203. await handle_dialog_sequence($"audio/player/i_mean_i_didnt_do_it_____the ac unit did", "true")
  204. await show_dumb_dialog()
  205. func what_if_i_dont_feel_like_it():
  206. await handle_dialog_sequence($audio/player/what_if_i_dont_feel_like_it, "true")
  207. jail()
  208. func nahh_i_didnt_do_it_the_ac_unit_did_yk():
  209. await handle_dialog_sequence($audio/player/i_didnt_do_it_cuh_the_ac_unit_did_yk, "false")
  210. await show_dumb_dialog()
  211. func aw_hell_na_i_got_a_date_with_osama_bin_landen_tonight():
  212. await handle_dialog_sequence($audio/player/aw_hell_na_i_got_a_date_with_bin_laden_tonight, "true")
  213. await show_osama_dialog()
  214. # Third level options
  215. func hes_my_pookie_popstar():
  216. await handle_dialog_sequence($audio/player/hes_my_pookie_popstar, "true")
  217. jail()
  218. func aw_hell_na_jigsaw_you_dumb():
  219. await handle_dialog_sequence($audio/player/aw_hell_na_jigsaw_you_DUMB, "true")
  220. jail()
  221. func actually_i_dont_remember():
  222. await handle_dialog_sequence($audio/player/actually_i_dont_remember, "false")
  223. await show_dumb_dialog()
  224. func yes_i_plead_mental_insanity_sire():
  225. await handle_dialog_sequence($audio/player/yes_i_plead_mental_insanity_sire, "true")
  226. dialog.set_text("man, what the fuck?")
  227. $audio/cop/man_wtf.play()
  228. await $audio/cop/man_wtf.finished
  229. await get_tree().create_timer(1.0).timeout
  230. GameManager.goto_scene("res://Scenes/thanks.tscn", false)
  231. func hell_naw_jail():
  232. await handle_dialog_sequence($audio/player/hell_na, "true")
  233. jail()
  234. func i_got_the_alice_heimer():
  235. await handle_dialog_sequence($audio/player/i_got_the_alice_heimer, "true")
  236. dialog.set_text("man, what the fuck?")
  237. $audio/cop/man_wtf.play()
  238. await $audio/cop/man_wtf.finished
  239. await get_tree().create_timer(1.0).timeout
  240. GameManager.goto_scene("res://Scenes/thanks.tscn", false)