Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / Dialogue / StoryDatas / Test.ink
  1. /*
  2. This is a long example of a crime scene investigation, from the Writing with Ink chapter on Lists.
  3. */
  4. -> murder_scene
  5. // Helper function: popping elements from lists
  6. === function pop(ref list)
  7. ~ temp x = LIST_MIN(list)
  8. ~ list -= x
  9. ~ return x
  10. //
  11. // System: items can have various states
  12. // Some are general, some specific to particular items
  13. //
  14. LIST OffOn = off, on
  15. LIST SeenUnseen = unseen, seen
  16. LIST GlassState = (none), steamed, steam_gone
  17. LIST BedState = (made_up), covers_shifted, covers_off, bloodstain_visible
  18. //
  19. // System: inventory
  20. //
  21. LIST Inventory = (none), cane, knife
  22. === function get(x)
  23. ~ Inventory += x
  24. //
  25. // System: positioning things
  26. // Items can be put in and on places
  27. //
  28. LIST Supporters = on_desk, on_floor, on_bed, under_bed, held, with_joe
  29. === function move_to_supporter(ref item_state, new_supporter) ===
  30. ~ item_state -= LIST_ALL(Supporters)
  31. ~ item_state += new_supporter
  32. // System: Incremental knowledge.
  33. // Each list is a chain of facts. Each fact supersedes the fact before
  34. //
  35. VAR knowledgeState = ()
  36. === function reached (x)
  37. ~ return knowledgeState ? x
  38. === function between(x, y)
  39. ~ return knowledgeState? x && not (knowledgeState ^ y)
  40. === function reach(statesToSet)
  41. ~ temp x = pop(statesToSet)
  42. {
  43. - not x:
  44. ~ return false
  45. - not reached(x):
  46. ~ temp chain = LIST_ALL(x)
  47. ~ temp statesGained = LIST_RANGE(chain, LIST_MIN(chain), x)
  48. ~ knowledgeState += statesGained
  49. ~ reach (statesToSet) // set any other states left to set
  50. ~ return true // and we set this state, so true
  51. - else:
  52. ~ return false || reach(statesToSet)
  53. }
  54. //
  55. // Set up the game
  56. //
  57. VAR bedroomLightState = (off, on_desk)
  58. VAR knifeState = (under_bed)
  59. //
  60. // Knowledge chains
  61. //
  62. LIST BedKnowledge = neatly_made, crumpled_duvet, hastily_remade, body_on_bed, murdered_in_bed, murdered_while_asleep
  63. LIST KnifeKnowledge = prints_on_knife, joe_seen_prints_on_knife,joe_wants_better_prints, joe_got_better_prints
  64. LIST WindowKnowledge = steam_on_glass, fingerprints_on_glass, fingerprints_on_glass_match_knife
  65. //
  66. // Content
  67. //
  68. === murder_scene ===
  69. The bedroom. This is where it happened. Now to look for clues.
  70. - (top)
  71. { bedroomLightState ? seen: <- seen_light }
  72. <- compare_prints(-> top)
  73. * (dobed) [The bed...]
  74. The bed was low to the ground, but not so low something might not roll underneath. It was still neatly made.
  75. ~ reach (neatly_made)
  76. - - (bedhub)
  77. * * [Lift the bedcover]
  78. I lifted back the bedcover. The duvet underneath was crumpled.
  79. ~ reach (crumpled_duvet)
  80. ~ BedState = covers_shifted
  81. * * (uncover) {reached(crumpled_duvet)}
  82. [Remove the cover]
  83. Careful not to disturb anything beneath, I removed the cover entirely. The duvet below was rumpled.
  84. Not the work of the maid, who was conscientious to a point. Clearly this had been thrown on in a hurry.
  85. ~ reach (hastily_remade)
  86. ~ BedState = covers_off
  87. * * (duvet) {BedState == covers_off} [ Pull back the duvet ]
  88. I pulled back the duvet. Beneath it was a sheet, sticky with blood.
  89. ~ BedState = bloodstain_visible
  90. ~ reach (body_on_bed)
  91. Either the body had been moved here before being dragged to the floor - or this is was where the murder had taken place.
  92. * * {BedState !? made_up} [ Remake the bed ]
  93. Carefully, I pulled the bedsheets back into place, trying to make it seem undisturbed.
  94. ~ BedState = made_up
  95. * * [Test the bed]
  96. I pushed the bed with spread fingers. It creaked a little, but not so much as to be obnoxious.
  97. * * (darkunder) [Look under the bed]
  98. Lying down, I peered under the bed, but could make nothing out.
  99. * * {TURNS_SINCE(-> dobed) > 1} [Something else?]
  100. I took a step back from the bed and looked around.
  101. -> top
  102. - - -> bedhub
  103. * {darkunder && bedroomLightState ? on_floor && bedroomLightState ? on}
  104. [ Look under the bed ]
  105. I peered under the bed. Something glinted back at me.
  106. - - (reaching)
  107. * * [ Reach for it ]
  108. I fished with one arm under the bed, but whatever it was, it had been kicked far enough back that I couldn't get my fingers on it.
  109. -> reaching
  110. * * {Inventory ? cane} [Knock it with the cane]
  111. -> knock_with_cane
  112. * * {reaching > 1 } [ Stand up ]
  113. I stood up once more, and brushed my coat down.
  114. -> top
  115. * (knock_with_cane) {reaching && TURNS_SINCE(-> reaching) >= 4 && Inventory ? cane } [Use the cane to reach under the bed ]
  116. Positioning the cane above the carpet, I gave the glinting thing a sharp tap. It slid out from the under the foot of the bed.
  117. ~ move_to_supporter( knifeState, on_floor )
  118. * * (standup) [Stand up]
  119. Satisfied, I stood up, and saw I had knocked free a bloodied knife.
  120. -> top
  121. * * [Look under the bed once more]
  122. Moving the cane aside, I looked under the bed once more, but there was nothing more there.
  123. -> standup
  124. * {knifeState ? on_floor} [Pick up the knife]
  125. Careful not to touch the handle, I lifted the blade from the carpet.
  126. ~ get(knife)
  127. * {Inventory ? knife} [Look at the knife]
  128. The blood was dry enough. Dry enough to show up partial prints on the hilt!
  129. ~ reach (prints_on_knife)
  130. * [ The desk... ]
  131. I turned my attention to the desk. A lamp sat in one corner, a neat, empty in-tray in the other. There was nothing else out.
  132. Leaning against the desk was a wooden cane.
  133. ~ bedroomLightState += seen
  134. - - (deskstate)
  135. * * (pickup_cane) {Inventory !? cane} [Pick up the cane ]
  136. ~ get(cane)
  137. I picked up the wooden cane. It was heavy, and unmarked.
  138. * * { bedroomLightState !? on } [Turn on the lamp]
  139. -> operate_lamp ->
  140. * * [Look at the in-tray ]
  141. I regarded the in-tray, but there was nothing to be seen. Either the victim's papers were taken, or his line of work had seriously dried up. Or the in-tray was all for show.
  142. + + (open) {open < 3} [Open a drawer]
  143. I tried {a drawer at random|another drawer|a third drawer}. {Locked|Also locked|Unsurprisingly, locked as well}.
  144. * * {deskstate >= 2} [Something else?]
  145. I took a step away from the desk once more.
  146. -> top
  147. - - -> deskstate
  148. * {(Inventory ? cane) && TURNS_SINCE(-> deskstate) <= 2} [Swoosh the cane]
  149. I was still holding the cane: I gave it an experimental swoosh. It was heavy indeed, though not heavy enough to be used as a bludgeon.
  150. But it might have been useful in self-defence. Why hadn't the victim reached for it? Knocked it over?
  151. * [The window...]
  152. I went over to the window and peered out. A dismal view of the little brook that ran down beside the house.
  153. - - (window_opts)
  154. <- compare_prints(-> window_opts)
  155. * * (downy) [Look down at the brook]
  156. { GlassState ? steamed:
  157. Through the steamed glass I couldn't see the brook. -> see_prints_on_glass -> window_opts
  158. }
  159. I watched the little stream rush past for a while. The house probably had damp but otherwise, it told me nothing.
  160. * * (greasy) [Look at the glass]
  161. { GlassState ? steamed: -> downy }
  162. The glass in the window was greasy. No one had cleaned it in a while, inside or out.
  163. * * { GlassState ? steamed && not see_prints_on_glass && downy && greasy }
  164. [ Look at the steam ]
  165. A cold day outside. Natural my breath should steam. -> see_prints_on_glass ->
  166. + + {GlassState ? steam_gone} [ Breathe on the glass ]
  167. I breathed gently on the glass once more. { reached (fingerprints_on_glass): The fingerprints reappeared. }
  168. ~ GlassState = steamed
  169. + + [Something else?]
  170. { window_opts < 2 || reached (fingerprints_on_glass) || GlassState ? steamed:
  171. I looked away from the dreary glass.
  172. {GlassState ? steamed:
  173. ~ GlassState = steam_gone
  174. <> The steam from my breath faded.
  175. }
  176. -> top
  177. }
  178. I leant back from the glass. My breath had steamed up the pane a little.
  179. ~ GlassState = steamed
  180. - - -> window_opts
  181. * {top >= 5} [Leave the room]
  182. I'd seen enough. I {bedroomLightState ? on:switched off the lamp, then} turned and left the room.
  183. -> joe_in_hall
  184. - -> top
  185. = operate_lamp
  186. I flicked the light switch.
  187. { bedroomLightState ? on:
  188. <> The bulb fell dark.
  189. ~ bedroomLightState += off
  190. ~ bedroomLightState -= on
  191. - else:
  192. { bedroomLightState ? on_floor: <> A little light spilled under the bed.} { bedroomLightState ? on_desk : <> The light gleamed on the polished tabletop. }
  193. ~ bedroomLightState -= off
  194. ~ bedroomLightState += on
  195. }
  196. ->->
  197. = compare_prints (-> backto)
  198. * { between ((fingerprints_on_glass, prints_on_knife), fingerprints_on_glass_match_knife) }
  199. [Compare the prints on the knife and the window ]
  200. Holding the bloodied knife near the window, I breathed to bring out the prints once more, and compared them as best I could.
  201. Hardly scientific, but they seemed very similar - very similiar indeed.
  202. ~ reach (fingerprints_on_glass_match_knife)
  203. -> backto
  204. = see_prints_on_glass
  205. ~ reach (fingerprints_on_glass)
  206. {But I could see a few fingerprints, as though someone hadpressed their palm against it.|The fingerprints were quite clear and well-formed.} They faded as I watched.
  207. ~ GlassState = steam_gone
  208. ->->
  209. = seen_light
  210. * {bedroomLightState !? on} [ Turn on lamp ]
  211. -> operate_lamp ->
  212. * { bedroomLightState !? on_bed && BedState ? bloodstain_visible }
  213. [ Move the light to the bed ]
  214. ~ move_to_supporter(bedroomLightState, on_bed)
  215. I moved the light over to the bloodstain and peered closely at it. It had soaked deeply into the fibres of the cotton sheet.
  216. There was no doubt about it. This was where the blow had been struck.
  217. ~ reach (murdered_in_bed)
  218. * { bedroomLightState !? on_desk } {TURNS_SINCE(-> floorit) >= 2 }
  219. [ Move the light back to the desk ]
  220. ~ move_to_supporter(bedroomLightState, on_desk)
  221. I moved the light back to the desk, setting it down where it had originally been.
  222. * (floorit) { bedroomLightState !? on_floor && darkunder }
  223. [Move the light to the floor ]
  224. ~ move_to_supporter(bedroomLightState, on_floor)
  225. I picked the light up and set it down on the floor.
  226. - -> top
  227. === joe_in_hall
  228. My police contact, Joe, was waiting in the hall. 'So?' he demanded. 'Did you find anything interesting?'
  229. - (found)
  230. * {found == 1} 'Nothing.'
  231. He shrugged. 'Shame.'
  232. -> done
  233. * { Inventory ? knife } 'I found the murder weapon.'
  234. 'Good going!' Joe replied with a grin. 'We thought the murderer had gotten rid of it. I'll bag that for you now.'
  235. ~ move_to_supporter(knifeState, with_joe)
  236. * {reached(prints_on_knife)} { knifeState ? with_joe }
  237. 'There are prints on the blade[.'],' I told him.
  238. He regarded them carefully.
  239. 'Hrm. Not very complete. It'll be hard to get a match from these.'
  240. ~ reach (joe_seen_prints_on_knife)
  241. * { reached((fingerprints_on_glass_match_knife, joe_seen_prints_on_knife)) }
  242. 'They match a set of prints on the window, too.'
  243. 'Anyone could have touched the window,' Joe replied thoughtfully. 'But if they're more complete, they should help us get a decent match!'
  244. ~ reach (joe_wants_better_prints)
  245. * { between(body_on_bed, murdered_in_bed)}
  246. 'The body was moved to the bed at some point[.'],' I told him. 'And then moved back to the floor.'
  247. 'Why?'
  248. * * 'I don't know.'
  249. Joe nods. 'All right.'
  250. * * 'Perhaps to get something from the floor?'
  251. 'You wouldn't move a whole body for that.'
  252. * * 'Perhaps he was killed in bed.'
  253. 'It's just speculation at this point,' Joe remarks.
  254. * { reached(murdered_in_bed) }
  255. 'The victim was murdered in bed, and then the body was moved to the floor.'
  256. 'Why?'
  257. * * 'I don't know.'
  258. Joe nods. 'All right, then.'
  259. * * 'Perhaps the murderer wanted to mislead us.'
  260. 'How so?'
  261. * * * 'They wanted us to think the victim was awake[.'], I replied thoughtfully. 'That they were meeting their attacker, rather than being stabbed in their sleep.'
  262. * * * 'They wanted us to think there was some kind of struggle[.'],' I replied. 'That the victim wasn't simply stabbed in their sleep.'
  263. - - - 'But if they were killed in bed, that's most likely what happened. Stabbed, while sleeping.'
  264. ~ reach (murdered_while_asleep)
  265. * * 'Perhaps the murderer hoped to clean up the scene.'
  266. 'But they were disturbed? It's possible.'
  267. * { found > 1} 'That's it.'
  268. 'All right. It's a start,' Joe replied.
  269. -> done
  270. - -> found
  271. - (done)
  272. {
  273. - between(joe_wants_better_prints, joe_got_better_prints):
  274. ~ reach (joe_got_better_prints)
  275. <> 'I'll get those prints from the window now.'
  276. - reached(joe_seen_prints_on_knife):
  277. <> 'I'll run those prints as best I can.'
  278. - else:
  279. <> 'Not much to go on.'
  280. }
  281. -> END