./msn_donnie.lua

  1. local TYPE_ANIMATE				= 0 
  2. local TYPE_DISPLAY				= 1 
  3.  
  4. -- list of all of the commands (makes it easy to add/remove/move to script) 
  5. local SRKFA						= 1 
  6. local NO_SRKFA					= 2 
  7. local NOCLIP					= 3 
  8. local NO_NOCLIP					= 4 
  9. local DROP_TANK					= 5 
  10. local DROP_TANK_CONFIRM			= 6 
  11. local DROP_TANK_3_D				= 7 
  12. local DROP_TANK_3_D_ERR			= 8 
  13. local DROP_3_TANK_CONFIRM		= 9 
  14. local CYCLE_ARRAY				= 10 
  15. local CYCLE_ARRAY_CONFIRM		= 11 
  16. local DROP_TANK_3D				= 12	 
  17. local DROP_TANK_3D_CONFIRM		= 13		 
  18. local PASSWORD1					= 14 
  19. local PASSWORD2					= 15 
  20. local PASSWORD3					= 16 
  21. local PASSWORD4					= 17 
  22. local PASSWORD5					= 18 
  23. local GAMES1					= 19 
  24. local GAMES2					= 20 
  25. local GAMES3					= 21 
  26. local GAMES4					= 22 
  27. local HACKING1					= 23 
  28. local HACKING2					= 24 
  29. local HACKING3					= 25 
  30. local HACKING4					= 26 
  31. local HACKING5					= 27 
  32. local HACKING6					= 28 
  33. local BACKDOOR1					= 29 
  34. local BACKDOOR2					= 30 
  35. local BACKDOOR3					= 31 
  36. local BACKDOOR4					= 32 
  37. local KILL_ALL					= 33 
  38. local KILL_ALL_CONFIRM			= 34 
  39. local DROP_CYCLE				= 35 
  40. local DROP_CYCLE_CONFIRM		= 36 
  41. local REBOOT					= 37 
  42. local SHUTDOWN					= 38 
  43. local SYSTEM_LOCKED				= 39 
  44. local NUM_COMMANDS				= SYSTEM_LOCKED 
  45.  
  46. local Console_cursor_anim_h 	= -1 
  47. local Console_cursor_twn_h		= -1 
  48. local Console_cursor_h			= -1 
  49. local Screen_grp_h 				= -1 
  50. local Console_txt_h 				= -1 
  51. local Text_thread 				= -1 
  52. local String_idx					= 0 
  53. local Global_string				= "" 
  54. local Text_handles				= {} 
  55.  
  56. -- do not change the name of this variable 
  57. -- it is accessed by C 
  58. Msn_donnie_is_line_playing = false 
  59.  
  60. -- speed = the base delay between each char 
  61. -- speed_rand = random time that is added to the base delay 
  62. -- start_delay = time to wait before text starts displaying 
  63. -- end_delay = time to wait after text is displayed 
  64. --  
  65. local Lines = { 
  66. 	[ SRKFA ] = { 
  67. 		type = TYPE_ANIMATE, 
  68. 		speed = 0.1, 
  69. 		text = "] srkfa", 
  70. 		}, 
  71. 	[ NO_SRKFA ] = { 
  72. 		type = TYPE_DISPLAY, 
  73. 		end_delay = 1.0, 
  74. 		text = "UNKNOWN COMMAND 'srkfa'", 
  75. 	}, 
  76. 	[ NOCLIP ] = { 
  77. 		type = TYPE_ANIMATE, 
  78. 		speed = 0.1, 
  79. 		text = "] noclip", 
  80. 		}, 
  81. 	[ NO_NOCLIP ] = { 
  82. 		type = TYPE_DISPLAY, 
  83. 		end_delay = 1.0, 
  84. 		text = "UNKNOWN COMMAND 'noclip'", 
  85. 	}, 
  86. 	[ DROP_TANK ] = { 
  87. 		type = TYPE_ANIMATE, 
  88. 		speed = 0.1, 
  89. 		text = "] drop_tank", 
  90. 		}, 
  91. 	[ DROP_TANK_CONFIRM ] = { 
  92. 		type = TYPE_DISPLAY, 
  93. 		text = "DEPLOYING TANK", 
  94. 		}, 
  95. 	[ DROP_TANK_3_D ] = { 
  96. 		type = TYPE_ANIMATE, 
  97. 		text = "] drop_tank 3 D", 
  98. 		}, 
  99. 	[ DROP_TANK_3_D_ERR ] = { 
  100. 		type = TYPE_DISPLAY, 
  101. 		text = "IGNORING UNUSED COMMAND LINE TAIL 'D'", 
  102. 	}, 
  103. 	[ DROP_3_TANK_CONFIRM ] = { 
  104. 		type = TYPE_DISPLAY, 
  105. 		text = "DEPLOYING 3 TANKS", 
  106. 		}, 
  107. 	[ CYCLE_ARRAY ] = { 
  108. 		type = TYPE_ANIMATE, 
  109. 		text = "] cycle_array", 
  110. 		}, 
  111. 	[ CYCLE_ARRAY_CONFIRM ] = { 
  112. 		type = TYPE_DISPLAY, 
  113. 		text = "DEPLOYING ARRAY OF CYCLES", 
  114. 		}, 
  115. 	[ DROP_TANK_3D ] = { 
  116. 		type = TYPE_ANIMATE, 
  117. 		speed = 0.2, 
  118. 		text = "] drop_tank 3D", 
  119. 		}, 
  120. 	[ DROP_TANK_3D_CONFIRM ] = { 
  121. 		type = TYPE_DISPLAY, 
  122. 		text = "DEPLOYING 3D TANK", 
  123. 	}, 
  124. 	 
  125. 	-- system trap 
  126. 	[ PASSWORD1 ] = { 
  127. 		type = TYPE_DISPLAY, 
  128. 		text = "PASSWORD:", 
  129. 	}, 
  130. 	[ PASSWORD2 ] = { 
  131. 		type = TYPE_ANIMATE, 
  132. 		text = "]  ********", 
  133. 	}, 
  134. 	[ PASSWORD3 ] = { 
  135. 		type = TYPE_DISPLAY, 
  136. 		text = "AH AH AH, YOU DIDN'T SAY THE MAGIC WORD", 
  137. 	}, 
  138. 	[ PASSWORD4 ] = { 
  139. 		type = TYPE_ANIMATE, 
  140. 		text = "] please", 
  141. 	}, 
  142. 	[ PASSWORD5 ] = { 
  143. 		type = TYPE_DISPLAY, 
  144. 		text = "ACCESS GRANTED", 
  145. 	}, 
  146. 	[ GAMES1 ] = { 
  147. 		type = TYPE_ANIMATE, 
  148. 		text = "] disarm security systems", 
  149. 	}, 
  150. 	[ GAMES2 ] = { 
  151. 		type = TYPE_DISPLAY, 
  152. 		text = "WOULD YOU LIKE TO PLAY A GAME?", 
  153. 	}, 
  154. 	[ GAMES3 ] = { 
  155. 		type = TYPE_ANIMATE, 
  156. 		text = "] play global thermonuclear war", 
  157. 	}, 
  158. 	[ GAMES4 ] = { 
  159. 		type = TYPE_DISPLAY, 
  160. 		text = "THE ONLY WINNING MOVE IS NOT TO PLAY", 
  161. 	}, 
  162. 	[ HACKING1 ] = { 
  163. 		type = TYPE_ANIMATE, 
  164. 		text = "] release FS3", 
  165. 	}, 
  166. 	[ HACKING2 ] = { 
  167. 		type = TYPE_DISPLAY, 
  168. 		text = "NOT GOING TO HAPPEN", 
  169. 	}, 
  170. 	[ HACKING3 ] = { 
  171. 		type = TYPE_ANIMATE, 
  172. 		text = "] download garbage", 
  173. 	}, 
  174. 	[ HACKING4 ] = { 
  175. 		type = TYPE_DISPLAY, 
  176. 		text = "SYSTEM CRASH DUE TO MODULE ACID BURN", 
  177. 	}, 
  178. 	[ HACKING5 ] = { 
  179. 		type = TYPE_ANIMATE, 
  180. 		text = "] crash override", 
  181. 	}, 
  182. 	[ HACKING6 ] = { 
  183. 		type = TYPE_DISPLAY, 
  184. 		text = ":(", 
  185. 	}, 
  186. 	[ BACKDOOR1 ] = { 
  187. 		type = TYPE_ANIMATE, 
  188. 		text = "] grant full SCSI interface", 
  189. 	}, 
  190. 	[ BACKDOOR2 ] = { 
  191. 		type = TYPE_DISPLAY, 
  192. 		text = "I REALLY SHOULD NOT", 
  193. 	}, 
  194. 	[ BACKDOOR3 ] = { 
  195. 		type = TYPE_ANIMATE, 
  196. 		text = "] access backdoor", 
  197. 	}, 
  198. 	[ BACKDOOR4 ] = { 
  199. 		type = TYPE_DISPLAY, 
  200. 		text = "YOU ARE NAUGHTY", 
  201. 	}, 
  202. 	[ KILL_ALL ] = { 
  203. 		type = TYPE_ANIMATE, 
  204. 		text = "] initiate order 66", 
  205. 	}, 
  206. 	[ KILL_ALL_CONFIRM ] = { 
  207. 		type = TYPE_DISPLAY, 
  208. 		text = "DELETING SYSTEM CONSTRUCTS", 
  209. 	}, 
  210. 	[ DROP_CYCLE ] = { 
  211. 		type = TYPE_ANIMATE, 
  212. 		text = "] drop_cycle 3D", 
  213. 	}, 
  214. 	[ DROP_CYCLE_CONFIRM ] = { 
  215. 		type = TYPE_DISPLAY, 
  216. 		end_delay = 3.0, 
  217. 		text = "DEPLOYING 3D CYCLE", 
  218. 	}, 
  219. 	[ REBOOT ] = { 
  220. 		type = TYPE_DISPLAY, 
  221. 		text = "REBOOTING", 
  222. 	}, 
  223. 	[ SHUTDOWN ] = { 
  224. 		type = TYPE_DISPLAY, 
  225. 		end_delay = 1.0, 
  226. 		text = "SHUTTING DOWN NETWORK IN 4 MINUTES", 
  227. 	}, 
  228. 	[ SYSTEM_LOCKED ] = { 
  229. 		type = TYPE_DISPLAY, 
  230. 		end_delay = 5.0, 
  231. 		text = "SYSTEM LOCKED", 
  232. 	},	 
  233. } 
  234.  
  235. local Line_queue = { } 
  236. local Line_queue_count = 0 
  237.  
  238. function msn_donnie_init() 
  239. 	Screen_grp_h = vint_object_find( "screen_grp" ) 
  240. 	Console_txt_h = vint_object_find( "console_txt" ) 
  241. 	Console_cursor_h = vint_object_find( "console_cursor" ) 
  242. 	 
  243. 	vint_set_property( Console_txt_h, "text_tag", "" ) 
  244. 	 
  245. 	msn_donnie_open() 
  246. 	 
  247. 	Console_cursor_anim_h =  vint_object_find( "console_cursor_anim" ) 
  248. 	Console_cursor_twn_h = vint_object_find( "console_cursor_twn" ) 
  249. 	vint_set_property( Console_cursor_twn_h, "end_event", "msn_donnie_cursor_loop" ) 
  250. 	lua_play_anim( Console_cursor_anim_h ) 
  251. 	 
  252. 	-- for testing 
  253. 	--msn_donnie_play_all_lines_test() 
  254. end 
  255.  
  256. function msn_donnie_cursor_loop() 
  257. 	lua_play_anim( Console_cursor_anim_h ) 
  258. end 
  259.  
  260. function msn_donnie_play_all_lines_test() 
  261. 	 
  262. 	for i = 1, NUM_COMMANDS do 
  263. 		msn_donnie_play_line( i ) 
  264. 	end 
  265. end 
  266.  
  267. -- do not change the name or params of this function 
  268. -- it is accessed by C 
  269. function msn_donnie_play_line( idx ) 
  270. 	if Lines[ idx ] == nil then 
  271. 		return 
  272. 	end 
  273.  
  274. 	Line_queue_count = Line_queue_count + 1 
  275. 	 
  276. 	Line_queue[ Line_queue_count ] = Lines[ idx ] 
  277. 	 
  278. 	if Text_thread == -1 then 
  279. 		Text_thread = thread_new( "msn_donnie_process_queue" ) 
  280. 	end 
  281. end 
  282.  
  283. -- do not change the name or params of this function 
  284. -- it is accessed by C 
  285. function msn_donnie_close() 
  286. 	-- Jason: this should animate the console out 
  287. 	msn_donnie_end() 
  288. end 
  289.  
  290. function msn_donnie_open() 
  291. 	local console_in_anim_h = vint_object_find( "console_in_anim" ) 
  292. 	lua_play_anim( console_in_anim_h ) 
  293. end 
  294.  
  295. function msn_donnie_process_queue() 
  296. 	Msn_donnie_is_line_playing = true 
  297.  
  298. 	while Line_queue_count > 0 do 
  299. 		msn_donnie_do_line( Line_queue[ 1 ] ) 
  300. 		 
  301. 		for i = 1, Line_queue_count - 1 do 
  302. 			Line_queue[ i ] = Line_queue[ i + 1 ] 
  303. 		end 
  304. 		 
  305. 		Line_queue[ Line_queue_count ] = nil 
  306. 		Line_queue_count = Line_queue_count - 1 
  307. 	end 
  308. 	 
  309. 	Msn_donnie_is_line_playing = false 
  310. 	Text_thread = -1 
  311. end 
  312.  
  313. function msn_donnie_do_line( new_text ) 
  314. 	local new_speed = new_text.speed or 0.1 
  315. 	local is_loop = new_text.is_loop or false 
  316. 	local time_delay = new_text.time_delay or 0 
  317. 	local start_delay = new_text.start_delay or 0 
  318. 	local end_delay = new_text.end_delay or 0 
  319. 	local speed_rand = new_text.speed_rand or 0.2 
  320.  
  321. 	local count = 0 
  322. 	local new_string = "" 
  323. 	local char = "" 
  324. 	 
  325. 	Text_handles[ String_idx ] = vint_object_clone( Console_txt_h ) 
  326. 	 
  327. 	local text_x,text_y 
  328. 	local text_width,text_height 
  329. 	 
  330. 	local cursor_x,cursor_y = vint_get_property( Console_cursor_h, "anchor" ) 
  331. 	text_x,text_y = vint_get_property( Text_handles[ String_idx ], "anchor") 
  332. 	vint_set_property( Console_cursor_h, "anchor", text_x, text_y ) 
  333. 	 
  334. 	-- use a start_delay if one exists 
  335. 	delay( start_delay ) 
  336. 	 
  337. 	--repeat 
  338. 	-- Run through the text 
  339. 	if new_text.type == TYPE_ANIMATE then 
  340. 		-- assume the first two characters are the prompt "] " 
  341. 		for i = 1, 2 do 
  342. 			char = get_char_in_string( new_text.text, count ) 
  343.  
  344. 			if char == nil then 
  345. 				break 
  346. 			end 
  347.  
  348. 			new_string = set_char_in_string( new_string, count, char ) 
  349. 			count = count + 1 
  350. 		end 
  351. 		 
  352. 		while true do 
  353. 			char = get_char_in_string( new_text.text, count ) 
  354. 			if char == nil then 
  355. 				break 
  356. 			end 
  357. 			new_string = set_char_in_string( new_string, count, char ) 
  358. 			vint_set_property( Text_handles[ String_idx ], "text_tag", new_string ) 
  359. 			 
  360. 			text_width,text_height = vint_get_property( Text_handles[ String_idx ], "screen_size") 
  361. 			vint_set_property( Console_cursor_h, "anchor", text_x + text_width, text_y ) 
  362. 			 
  363. 			count = count + 1 
  364. 			delay( new_speed + rand_float( 0, speed_rand ) ) 
  365. 		end 
  366. 	else 
  367. 		new_string = new_text.text 
  368. 		vint_set_property( Text_handles[ String_idx ], "text_tag",  new_string ) 
  369. 		 
  370. 		text_width,text_height = vint_get_property( Text_handles[ String_idx ], "screen_size") 
  371. 		vint_set_property( Console_cursor_h, "anchor", text_x + text_width, text_y ) 
  372. 			 
  373. 		delay( new_speed ) 
  374. 	end 
  375. 	 
  376. 	String_idx = String_idx + 1 
  377. 	vint_set_property( Console_cursor_h, "anchor", text_x, text_y ) 
  378. 	 
  379. 	for i = 0, String_idx - 1 do 
  380. 		text_x,text_y = vint_get_property( Text_handles[ i ], "anchor") 
  381. 		vint_set_property( Text_handles[ i ], "anchor", text_x, text_y - 17 ) 
  382. 	end 
  383.  
  384. 	delay( end_delay ) 
  385. end 
  386.  
  387. function msn_donnie_end() 
  388. 	local anim_h = vint_object_find( "console_out_anim" ) 
  389. 	lua_play_anim( anim_h ) 
  390. end 
  391.  
  392. function msn_donnie_cleanup() 
  393. 	if Text_thread ~= nil then 
  394. 		thread_kill( Text_thread ) 
  395. 	end 
  396. end 
  397.  
  398.