Clock.gd 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  1. extends Chattable
  2. var ticktock = false
  3. var hour = 0
  4. var time = 0
  5. var delay_timer
  6. var spawn_delay = 1
  7. var def_timespeed = 0.04
  8. #var def_timespeed = 0.1
  9. var timespeed = 0
  10. var time_max = 1
  11. var hour_max = 4
  12. var times_used = 0
  13. var ranted = false
  14. var guests = Dictionary()
  15. var startlock = true
  16. var _friend = false
  17. var light_swears = [
  18. "ugh",
  19. "umpf",
  20. "grrrrr",]
  21. var schedule = {
  22. "Agitator": [1],
  23. "Girl": [0,1],
  24. "Priest": [2],
  25. "BoozeGirl": [2],
  26. "Haxxor": [3],
  27. }
  28. func _set_noninteractable():
  29. $"Spatial/Clock/CollisionShape".disabled = true
  30. func _set_interactable():
  31. $"Spatial/Clock/CollisionShape".disabled = false
  32. func stop_time():
  33. timespeed = 0
  34. #print("time stopped")
  35. func start_time():
  36. _set_interactable()
  37. startlock = false
  38. timespeed = def_timespeed
  39. #print("time started")
  40. func _ready():
  41. _on_hour_changed()
  42. _set_noninteractable()
  43. var timer = Timer.new()
  44. timer.wait_time = 1
  45. add_child(timer)
  46. timer.connect("timeout",self,"_tick")
  47. timer.start()
  48. func _tick():
  49. if timespeed!=0:
  50. if ticktock:
  51. $Sound.pitch_scale = 0.8
  52. else:
  53. $Sound.pitch_scale = 1.5
  54. $Sound.play()
  55. ticktock = !ticktock
  56. func _on_hour_changed(leap = false):
  57. if leap and delay_timer:
  58. delay_timer.queue_free()
  59. #make baker angry if BGs are around
  60. var baker = MAIN.find_node("BAKER")
  61. if hour in schedule["BoozeGirl"]:
  62. baker.get_angry()
  63. else:
  64. if baker.angry:
  65. baker.calm_down()
  66. #Remove late guests
  67. var kk = guests.keys().duplicate() #safety precaution. We're erasing stuff
  68. var i = 0
  69. for k in kk:
  70. if not (hour in schedule[k]) :
  71. if leap:
  72. guests[k].queue_free()
  73. else:
  74. guests[k].leave("Pads"+str(i+1))
  75. i = wrapi(i+1,0,2) # makes them use different exits if they are more than one
  76. guests.erase(k)
  77. #Add needed ones (delay prevents collisions)
  78. delay_timer = Timer.new()
  79. delay_timer.wait_time = spawn_delay
  80. add_child(delay_timer)
  81. delay_timer.connect("timeout",self,"populate_guests")
  82. delay_timer.start()
  83. func populate_guests():
  84. if delay_timer:
  85. delay_timer.queue_free()
  86. delay_timer = null
  87. var i = 0
  88. for k in schedule.keys():
  89. if hour in schedule[k] and not k in guests.keys():
  90. call_guest(k,i+1)
  91. i = wrapi(i+1,0,2)
  92. func call_guest(name_string, entrynumber = 1):
  93. var entrypoint = MAIN.find_node("Pads" + str(entrynumber))
  94. var guest
  95. if name_string == "Girl":
  96. if MAIN.girl_promised_to_return:
  97. MAIN.girl_didnt_return = true
  98. return
  99. guest = load("res://"+name_string+".tscn").instance()
  100. guest.queued_start = entrypoint
  101. guest.visible = false
  102. MAIN.call_deferred("add_child",guest) # guest will find his way from here
  103. #mainly because there is no way to do it otherwise with deferred calls
  104. # and deferred calls are forced by MAIN being busy
  105. guests[name_string] = guest
  106. func _process(delta):
  107. time+=timespeed*delta
  108. if time > time_max :
  109. time = 0
  110. hour= wrapi(hour+1,0,hour_max)
  111. _on_hour_changed()
  112. $arrow_pivot.rotation_degrees.z = -((time/float(time_max))+hour)/(float(hour_max))*360
  113. func init_():
  114. if ranted:
  115. return [
  116. Unconditional.new("main_choice_"),
  117. ]
  118. if times_used>=light_swears.size():
  119. return [
  120. Unconditional.new("exploiter"),
  121. ]
  122. else:
  123. return [
  124. Unconditional.new("manipulate_"),
  125. ]
  126. func exploiter():
  127. ranted = true
  128. return[
  129. Saying.new(Saying.ITSELF, "stop this already, man"),
  130. Saying.new(Saying.ITSELF, "you think"),
  131. Saying.new(Saying.ITSELF, "manipulating spacetime"),
  132. Saying.new(Saying.ITSELF, "is easy?"),
  133. Saying.new(Saying.ITSELF, "In this baroque"),
  134. Saying.new(Saying.ITSELF, "spatiotemporal mess"),
  135. Saying.new(Saying.ITSELF, "called net?"),
  136. Saying.new(Saying.ITSELF, "i am fed up."),
  137. Saying.new(Saying.ITSELF, "solve"),
  138. Saying.new(Saying.ITSELF, "your freaking Einsteins"),
  139. Saying.new(Saying.ITSELF, "and find needed tensors"),
  140. Saying.new(Saying.ITSELF, "yourself"),
  141. Saying.new(Saying.ITSELF, "little exploiter."),
  142. Saying.new(Saying.ITSELF, "destroy a bunch of nodes"),
  143. Saying.new(Saying.ITSELF, "while you do."),
  144. Saying.new(Saying.ITSELF, "will fix human demography"),
  145. Saying.new(Saying.ITSELF, "and make for less buggers"),
  146. Unconditional.new("main_choice_"),
  147. ]
  148. func main_choice_():
  149. return[
  150. [
  151. Choice.new("plz, need a warp!","manipulate_") if _friend else NULL_CHOICE,
  152. Choice.new("sec's friend?","friends") if _friend else NULL_CHOICE,
  153. Choice.new("wait, you talk?","intro"),
  154. Choice.new("why are you here?","reason"),
  155. Choice.new("bye","bye_"),
  156. ],
  157. ]
  158. func reason():
  159. return[
  160. Saying.new(Saying.MYSELF, "why are you here?"),
  161. Saying.new(Saying.MYSELF, "don't you have"),
  162. Saying.new(Saying.MYSELF, "more fun things to do"),
  163. Saying.new(Saying.MYSELF, "than to hang here?"),
  164. Saying.new(Saying.ITSELF, "I probably do"),
  165. Saying.new(Saying.ITSELF, "But for some reason"),
  166. Saying.new(Saying.ITSELF, "I just like to hang here"),
  167. Saying.new(Saying.ITSELF, "while doing other stuff"),
  168. Saying.new(Saying.ITSELF, "Sec recommended me place"),
  169. Saying.new(Saying.ITSELF, "to fight anxiety"),
  170. Saying.new(Saying.ITSELF, "was really peaceful here"),
  171. Saying.new(Saying.ITSELF, "until you showed up"),
  172. Saying.new(Saying.ITSELF, "little bugger"),
  173. Saying.new(Saying.ITSELF, "ordering me around"),
  174. Saying.new(Saying.ITSELF, "manipulate time!"),
  175. Saying.new(Saying.ITSELF, "1 hr forward!"),
  176. Saying.new(Saying.ITSELF, "2 hr forward!"),
  177. Saying.new(Saying.ITSELF, "what the hell?"),
  178. Saying.new(Saying.ITSELF, "you see a manual or sth?"),
  179. Saying.new(Saying.ITSELF, "do all clocks bend time?"),
  180. Saying.new(Saying.ITSELF, "on voice command?"),
  181. Saying.new(Saying.ITSELF, "i looked it up!"),
  182. Saying.new(Saying.ITSELF, "it was just you"),
  183. Saying.new(Saying.ITSELF, "making stuff up!"),
  184. Saying.new(Saying.ITSELF, "all the effing time!"),
  185. Saying.new(Saying.ITSELF, "jerk!", "unlock_sec"),
  186. Unconditional.new("main_choice_"),
  187. ]
  188. func unlock_sec():
  189. _friend = true
  190. func sec_secret():
  191. MAIN.security_secret = true
  192. func friends():
  193. return[
  194. Saying.new(Saying.MYSELF, "you're friends with Sec?"),
  195. Saying.new(Saying.ITSELF, "well i said it"),
  196. Saying.new(Saying.ITSELF, "we both just chillax"),
  197. Saying.new(Saying.ITSELF, "i am hanging as a clock"),
  198. Saying.new(Saying.ITSELF, "he is wordsmithing"),
  199. Saying.new(Saying.ITSELF, "and having an audience"),
  200. Saying.new(Saying.ITSELF, "as Head"),
  201. Saying.new(Saying.ITSELF, "both have fun."),
  202. Saying.new(Saying.MYSELF, "wait, i thought head"),
  203. Saying.new(Saying.MYSELF, "was a robot person"),
  204. Saying.new(Saying.MYSELF, "like you are"),
  205. Saying.new(Saying.MYSELF, "and it said sth"),
  206. Saying.new(Saying.MYSELF, "about neuromorphics"),
  207. Saying.new(Saying.MYSELF, "overheating"),
  208. Saying.new(Saying.MYSELF, "or sth"),
  209. Saying.new(Saying.ITSELF, "nah, all act"),
  210. Saying.new(Saying.ITSELF, "besides,"),
  211. Saying.new(Saying.ITSELF, "modern neuroboards"),
  212. Saying.new(Saying.ITSELF, "are very efficient"),
  213. Saying.new(Saying.ITSELF, "very little waste heat"),
  214. Saying.new(Saying.ITSELF, "passive cooling is enough"),
  215. Saying.new(Saying.ITSELF, "he just makes breaks"),
  216. Saying.new(Saying.ITSELF, "to eat human food"),
  217. Saying.new(Saying.ITSELF, "and relax a bit","sec_secret"),
  218. Unconditional.new("main_choice_"),
  219. ]
  220. func intro():
  221. return[
  222. Saying.new(Saying.MYSELF, "wait, you talk?"),
  223. Saying.new(Saying.ITSELF, "yea and what?"),
  224. Saying.new(Saying.MYSELF, "you can think?"),
  225. Saying.new(Saying.MYSELF, "you are so small!"),
  226. Saying.new(Saying.ITSELF, "Actually"),
  227. Saying.new(Saying.ITSELF, "your head is smaller"),
  228. Saying.new(Saying.ITSELF, "leave me alone"),
  229. Unconditional.new("main_choice_"),
  230. ]
  231. func manipulate_():
  232. return[
  233. Saying.new(Saying.MYSELF, "manipulate time!"),
  234. Saying.new(Saying.ITSELF, "what???") if ranted else NULL_SAY,
  235. Saying.new(Saying.ITSELF, "again???") if ranted else NULL_SAY,
  236. Saying.new(Saying.MYSELF, "pleeeease") if ranted else NULL_SAY,
  237. Saying.new(Saying.ITSELF, "jerk") if ranted else NULL_SAY,
  238. [
  239. Choice.new("1 hr forward","hr_1"),
  240. Choice.new("2 hr forward","hr_2"),
  241. Choice.new("quit","bye_"),
  242. ],
  243. ]
  244. func bye_():
  245. return []
  246. func hr_1():
  247. hour = wrapi(hour+1,0,hour_max)
  248. time = 0
  249. _on_hour_changed(true)
  250. return swear()
  251. func hr_2():
  252. hour = wrapi(hour+2,0,hour_max)
  253. time = 0
  254. _on_hour_changed(true)
  255. return swear()
  256. func swear():
  257. if ranted: return []
  258. times_used+=1
  259. return [
  260. Saying.new(Saying.ITSELF,light_swears[min(light_swears.size(),times_used-1)])
  261. ]