Debian Codegraph @

data/storyline/act1/dialogs/Guy.lua

raw
1 ---------------------------------------------------------------------
2 -- This file is part of Freedroid
3 --
4 -- Freedroid is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation; either version 2 of the License, or
7 -- (at your option) any later version.
8 --
9 -- Freedroid is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
13 --
14 -- You should have received a copy of the GNU General Public License
15 -- along with Freedroid; see the file COPYING. If not, write to the
16 -- Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 -- MA 02111-1307 USA
18 ----------------------------------------------------------------------
19 --[[WIKI
20 PURPOSE = "$$NAME$$ is a character used for Debug purposes",
21 WIKI]]--
22
23 local Npc = FDrpg.get_npc()
24 local Tux = FDrpg.get_tux()
25
26 local function guy_fail(test, ...)
27 print(FDutils.text.highlight("ERROR! The following test failed:", "red"))
28 print(FDutils.text.highlight(test, "red"))
29 npc_says("%s failed!" ,test , "NO_WAIT")
30 end_dialog()
31 exit_game(1)
32 end
33
34 return {
35 FirstTime = function()
36 ---------------------------------------------------------- HAS_MET
37 if (not Tux:has_met("Guy")) then
38 Npc:says("HAS MET test 1 succeeded", "NO_WAIT")
39 else
40 guy_fail("HAS MET")
41 end
42
43 if (not Tux:has_quest("24_guy_death_quest")) then
44 Tux:add_quest("24_guy_death_quest", "Quest to check if droid markers work.")
45 end
46
47 Npc:says("This text is only shown as you speak to this character the first time.")
48 end,
49
50 EveryTime = function()
51
52 Guy_dialog_executing = true
53
54 -- Tux:says_random..
55 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
56 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
57 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
58 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
59 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
60 Tux:says_random("1", "2", "3", "4", "5", "NO_WAIT")
61
62 Tux:says("Tux:says()", "NO_WAIT")
63 Npc:says("Npc:says()", "NO_WAIT")
64 cli_says("cli_says()", "NO_WAIT")
65 Npc:says("", "NO_WAIT") -- extra linebreak for cli_says()
66
67 GuyArray = {"one", "two", "three"}
68 for var in ipairs(GuyArray) do
69 Npc:says(GuyArray[var], "NO_WAIT")
70 end
71
72 next("node0")
73 end,
74
75 {
76 id = "node0",
77 text = "RUNNING TEST NODE",
78 code = function()
79 show("node0")
80 hide("node0")
81 ---------------------------------------------------------- ITEM
82 Tux:add_item("Laser Scalpel")
83 Tux:add_item(".22 Automatic")
84 Tux:add_item(".22 Automatic", 2)
85 if (Tux:has_item(".22 Automatic")) then
86 Npc:says("ADD ITEM test 1 succeeded", "NO_WAIT")
87 else
88 guy_fail("ADD ITEM 1")
89 end
90
91 if (Tux:has_item_backpack(".22 Automatic")) then
92 Npc:says("ADD ITEM test 2 succeeded", "NO_WAIT")
93 else
94 guy_fail("ADD ITEM 2")
95 end
96
97 if (Tux:has_item_equipped("Laser Scalpel")) then
98 Npc:says("ADD ITEM test 3 succeeded", "NO_WAIT")
99 else
100 guy_fail("ADD ITEM 3")
101 end
102
103 -- ru654
104 --[[ NOTE we need del_item_equipped() or unequipp_item()
105 Tux:del_item("Laser Scalpel")
106 if (not Tux:has_item("Laser Scalpel")) then
107 Npc:says("DEL ITEM 1 test succeeded", "NO_WAIT")
108 else
109 guy_fail("DEL ITEM 1")
110 end
111 ]]--
112
113 Tux:del_item_backpack(".22 Automatic", 2)
114 if (Tux:has_item_backpack(".22 Automatic")) then
115 Npc:says("DEL ITEM test 2 succeeded", "NO_WAIT")
116 else
117 guy_fail("DEL ITEM 2")
118 end
119 Tux:del_item_backpack(".22 Automatic")
120 if (not Tux:has_item_backpack(".22 Automatic")) then
121 Npc:says("DEL ITEM test 3 succeeded", "NO_WAIT")
122 else
123 guy_fail("DEL ITEM 3")
124 end
125 ---------------------------------------------------------- FACTION
126 npc_faction("self", "Guy - self")
127 npc_faction("ms", "Guy - ms")
128 npc_faction("redguard", "Guy - redguard" )
129 npc_faction("resistance", "Guy - resistance")
130 npc_faction("civilian", "Guy - civilian")
131 npc_faction("crazy", "Guy - crazy")
132 npc_faction("singularity", "Guy - singularity")
133 npc_faction("neutral", "Guy - neutral")
134 ---------------------------------------------------------- HEALTH
135 Tux:heal()
136 Tux:hurt(1)
137 Tux:hurt(-1)
138 if (Tux:get_hp() == 60) then
139 Npc:says("HEALTH test 1 succeeded", "NO_WAIT")
140 else
141 guy_fail("HEALTH 1")
142 end
143
144 if (Tux:get_max_hp() == 60) then
145 Npc:says("HEALTH test 2 succeeded", "NO_WAIT")
146 else
147 guy_fail("HEALTH 2")
148 end
149 ---------------------------------------------------------- COOL
150 Tux:heat(1)
151 Tux:heat(-1)
152 if (Tux:get_cool() == 100) then
153 Npc:says("COOL test 1 succeeded", "NO_WAIT")
154 else
155 guy_fail("COOL 1")
156 end
157 ---------------------------------------------------------- TELEPORT
158 Tux:teleport("24-tux1")
159 Tux:teleport("24-tux2")
160 Npc:teleport("24-guy1")
161 Npc:teleport("24-guy2")
162 Dude:teleport("24-dude1")
163 Dude:teleport("24-dude2")
164 ---------------------------------------------------------- SKILLS
165 --Npc:says(Tux:get_skill("programming"))
166 if (not Tux:has_met("Guy")) then
167 Tux:improve_skill("programming")
168 if (Tux:get_skill("programming") == 1) then
169 Npc:says("SKILL test 1 succeeded", "NO_WAIT")
170 else
171 guy_fail("SKILL 1")
172 end
173 else
174 Tux:says("Skipping SKILL test 1 due to missing possibility to downgrade skills!")
175 end
176 ---------------------------------------------------------- PROGRAMS
177 Tux:improve_program("Ricer CFLAGS")
178 Tux:downgrade_program("Ricer CFLAGS")
179 if (Tux:get_program_revision("Ricer CFLAGS") == 0) then
180 Npc:says("PROGRAM test 1 succeeded", "NO_WAIT")
181 else
182 guy_fail("PROGRAM 1")
183 end
184 ---------------------------------------------------------- QUESTS
185 if (not Tux:has_met("Guy")) then
186 if (not Tux:has_quest("24_dude_test_quest")) then
187 Npc:says("QUEST test 1 succeeded", "NO_WAIT")
188 else
189 guy_fail("QUEST 1")
190 end
191 Tux:add_quest("24_dude_test_quest", "Add 24 dude quest.")
192 else
193 Tux:says("Skipping QUEST test 1 due to missing possibility to remove quests!")
194 end
195
196 if (Tux:has_quest("24_dude_test_quest")) then
197 Npc:says("QUEST test 2 succeeded", "NO_WAIT")
198 else
199 guy_fail("QUEST 2")
200 end
201 Tux:update_quest("24_dude_test_quest", "Update 24 dude quest.")
202
203 if (not Tux:has_met("Guy")) then
204 if (not Tux:done_quest("24_dude_test_quest")) then
205 Npc:says("QUEST test 3 succeeded", "NO_WAIT")
206 else
207 guy_fail("QUEST 3")
208 end
209
210 Tux:end_quest("24_dude_test_quest", "Complete 24 dude quest.")
211 if (Tux:done_quest("24_dude_test_quest")) then
212 Npc:says("QUEST test 4 succeeded", "NO_WAIT")
213 else
214 guy_fail("QUEST 4")
215 end
216 else
217 Tux:says("Skipping QUEST test 3 due to missing possibility to remove quests!")
218 Tux:says("Skipping QUEST test 4 due to missing possibility to remove quests!")
219 end
220
221 if (Tux:has_met("Guy")) then -- need to have met guy to let the DeadGuy die...
222 if (Tux:done_quest("24_guy_death_quest")) then -- check droid markers
223 Npc:says("QUEST test 5 succeeded","NO_WAIT")
224 else
225 guy_fail("QUEST 5")
226 end
227 else
228 Tux:says("Skipping QUEST test 5, we need to have met Guy...")
229 end
230
231 ---------------------------------------------------------- OBSTACLES
232
233 change_obstacle_message("24_guy_sign", _"Guy signmessage B")
234 display_big_message("Sign message changed from")
235 display_big_message("Guy signmessage A' to 'Guy signmessage B'")
236
237 if (cmp_obstacle_state("24_guy_door", "opened")) then
238 Npc:says("OBSTACLE test 1 succeeded", "NO_WAIT")
239 else
240 guy_fail("OBSTACLE 1")
241 end
242 change_obstacle_state("24_guy_door", "closed")
243 if (cmp_obstacle_state("24_guy_door", "closed")) then
244 Npc:says("OBSTACLE test 2 succeeded", "NO_WAIT")
245 else
246 guy_fail("OBSTACLE 2")
247 end
248 change_obstacle_state("24_guy_door", "opened") -- 6 = door
249 change_obstacle_type("24_guy_door", "1")
250 if (get_obstacle_type("24_guy_door") == 1) then
251 Npc:says("OBSTACLE test 3 succeeded", "NO_WAIT")
252 else
253 guy_fail("OBSTACLE 3")
254 end
255 change_obstacle_type("24_guy_door", "6") -- set it back to door
256
257 ---------------------------------------------------------- NPC DEATH TEST
258 if (not Tux:has_met("Guy")) then
259 if (not DeadGuy:is_dead()) then
260 Npc:says("NPC DEATH test 1 succeeded", "NO_WAIT")
261 else
262 guy_fail("NPC DEATH 1")
263 end
264
265 DeadGuy:drop_dead() -- kill Dude
266 end
267
268 if not (running_benchmark()) then -- remember: our dialog validator is quite dump :(
269 if (DeadGuy:is_dead()) then
270 Npc:says("NPC DEATH test 2 succeeded", "NO_WAIT")
271 else
272 guy_fail("NPC DEATH 2")
273 end
274 end
275
276 -- one day we might be able to revive DeadGuy
277
278 --[[ if (not Dude:is_dead()) then
279 Npc:says("NPC DEATH test 3 succeeded", "NO_WAIT")
280 else
281 guy_fail("NPC DEATH 3")
282 end ]]--
283 ---------------------------------------------------------- FACTION DEATH TEST
284 if (not Tux:has_met("Guy")) then
285 if (not FactionDeadBot:is_dead()) then -- it's alive
286 Npc:says("FACTION DEATH test 1 succeeded", "NO_WAIT")
287 else
288 guy_fail("FACTION DEATH 1")
289 end
290
291 kill_faction("test") -- kill test faction
292
293 if not (running_benchmark()) then -- remember: our dialog validator is quite dump :(
294 if (FactionDeadBot:is_dead()) then -- we killed it, it's dead
295 Npc:says("FACTION DEATH test 2 succeeded", "NO_WAIT")
296 else
297 guy_fail("FACTION DEATH 2")
298 end
299 end
300 -- @TODO: implement revive and additional checks
301 respawn_level(24) --respawn level, now check if bot is alive again
302 if not (running_benchmark()) then -- remember: our dialog validator is quite dump :(
303 if (not FactionDeadBot:is_dead()) then --it's alive again
304 Npc:says("FACTION DEATH test 3 succeeded", "NO_WAIT")
305 else
306 guy_fail("FACTION DEATH 3")
307 end
308 end
309 -- now check if kill_faction with no_respawn works
310 kill_faction("test", "no_respawn")
311 if not (running_benchmark()) then -- remember: our dialog validator is quite dump :(
312 if (FactionDeadBot:is_dead()) then -- we killed it, it's dead
313 Npc:says("FACTION DEATH test 4 succeeded", "NO_WAIT")
314 else
315 guy_fail("FACTION DEATH 4")
316 end
317 end
318 -- now respawn and check if its still dead.
319 respawn_level(24)
320 if not (running_benchmark()) then -- remember: our dialog validator is quite dump :(
321 if (FactionDeadBot:is_dead()) then -- we killed it, no_respawn was given, it should still be dead
322 Npc:says("FACTION DEATH test 5 succeeded", "NO_WAIT")
323 else
324 guy_fail("FACTION DEATH 5")
325 end
326 end
327 end
328 ---------------------------------------------------------- EVENTS
329 if not (running_benchmark()) then
330 if (l24_event_test == "works" ) then
331 Npc:says("EVENT test 1 (map label) succeeded", "NO_WAIT")
332 else
333 guy_fail("EVENT test 1 (map label)")
334 end
335 end
336
337 if not (running_benchmark()) then
338 if (DeadGuy_death_trigger == "works" ) then
339 Npc:says("EVENT test 2 (death event) succeeded", "NO_WAIT")
340 else
341 guy_fail("EVENT test 2 (death event)")
342 end
343 end
344
345 Guy_24_to_70_passed = false --reset these here.
346 Guy_70_to_24_passed = false -- needed because we might have walked around manually
347 if not (running_benchmark()) then
348 -- tux is on lvl 24 currently
349 teleport("24-exit-level-70") -- teleport from level 24 to level 70, to a label
350 if (Guy_24_to_70_passed) then -- the from24to70 event worked! the event also teleport tux back to level 24 (from70to24!)...
351 Npc:says("EVENT test 3 (Entering 70, exiting 24) succeeded", "NO_WAIT")
352 else
353 guy_fail("EVENT test 3 (Entering 70, exiting 24)")
354 end
355
356 if (Guy_70_to_24_passed) then -- ... which sets this as true. tux is also teleported to label 24-tux2
357 Npc:says("EVENT test 4 (Entering 24, exiting 70) succeeded", "NO_WAIT")
358 else
359 guy_fail("EVENT test 4 (Entering 24, exiting 70)")
360 end
361 end
362
363
364
365
366 ---------------------------------------------------------- Gold
367 if (Tux:get_gold() == 0) then
368 Npc:says("GOLD test 1 succeed", "NO_WAIT")
369 else
370 guy_fail("GOLD 1")
371 end
372
373 Tux:add_gold(100)
374 if (Tux:get_gold() == 100) then
375 Npc:says("GOLD test 2 succeed", "NO_WAIT")
376 else
377 guy_fail("GOLD 2")
378 end
379
380 if (not Tux:del_gold(1000)) then
381 Npc:says("GOLD test 3 succeed", "NO_WAIT")
382 else
383 guy_fail("GOLD 3")
384 end
385
386 if (Tux:get_gold() == 100) then -- check if gold changed, just to be sure...
387 Npc:says("GOLD test 4 succeed", "NO_WAIT")
388 else
389 guy_fail("GOLD 4")
390 end
391
392 if (Tux:del_gold(100)) then
393 Npc:says("GOLD test 5 succeed", "NO_WAIT")
394 else
395 guy_fail("GOLD 5")
396 end
397
398 Tux:add_gold(100)
399 Tux:add_gold(-100)
400 if (Tux:get_gold() == 0) then
401 Npc:says("GOLD test 6 succeed")
402 else
403 guy_fail("GOLD 6")
404 end
405
406
407 ---------------------------------------------------------- RUSH TUX
408 if (not Tux:has_met("Guy")) then
409 if not (Npc:get_rush_tux()) then
410 Npc:says("RUSH TUX test 1 succeed", "NO_WAIT")
411 else
412 guy_fail("RUSH TUX 1")
413 end
414 else
415 Tux:says("Skipping RUSH TUX test 1 because it would fail since we directly rush tux on second time we call the dialog.")
416 end
417
418 Npc:set_rush_tux(true)
419
420 if (Npc:get_rush_tux()) then
421 Npc:says("RUSH TUX test 2 succeed", "NO_WAIT")
422 else
423 guy_fail("RUSH TUX 2")
424 end
425 ---------------------------------------------------------- OTHER
426 -- print some useless colorful foo
427
428 Guy_colors={"black", "red", "green", "yellow", "blue", "purple", "cyan", "white"}
429 if (running_benchmark()) then -- for nodes we use printf which has no linebreak at the end.
430 print("") -- "black" would get appended directly to a node but this avoids it.
431 end
432
433 for k, color in ipairs(Guy_colors) do
434 print(FDutils.text.highlight(color, color))
435 end
436
437 Npc:set_death_item("Pandora's Cube")
438 Npc:says("")
439 display_big_message("Big Message")
440 display_console_message("Console message, [b]blue[/b], not blue.")
441 end_dialog()
442 Guy_dialog_executing = false
443 end,
444 },
445 {
446 id = "node99",
447 text = "logout",
448 code = function()
449 end_dialog()
450 end,
451 },
452 }