Some work on implementing underpill.
[poca-love.git] / levels.lua
blob29de5ad9cac2b31011634bfa62a0dae251f5f21a
1 levels = {{ setup = '0000001000000000', onload = function () game:change_screen('story_beginning', true) end },
2 { setup = '0000100002000000' },
3 { setup = '1102002110002012' },
4 { setup = '0112002020100020' },
5 { setup = '1002120100211101' },
6 { setup = 'BJ060J060J650J60' },
7 { setup = '6656650050506005' },
8 { setup = '6660060006000000' },
9 { setup = '5556600650065566' },
10 { setup = '6666000006000600' },
11 { setup = '0000065605650656' },
12 { setup = '0Z00404000000400', trinket = 'cigarettes' },
13 { setup = '0B03000003033030' },
14 { setup = '0040004004440000' },
15 { setup = '0040040003303003' },
16 { setup = '003403003J000300', gifts = 'Z', trinket = 'beastfang' },
17 { setup = '3003000033000303' },
18 { setup = '4000040040004404' },
19 { setup = '4404004004440004' },
20 { setup = '3003330000403044' },
21 { setup = '00B0000100001818' },
22 { setup = '0020077000200007' },
23 { setup = 'Z020871200800201', trinket = 'flower' },
24 { setup = '000R290800211A00' },
25 { setup = '7080020000000007' },
26 { setup = '8108000000200007' },
27 { setup = 'B001063001503000' },
28 { setup = '0000303033350303' },
29 { setup = '0003080004803000' },
30 { setup = '000084180000H000', arrowgift = 'Z', trinket = 'rabbit' },
31 { setup = '3006060C806C6CC6' },
32 { setup = '800000F018700502' },
33 { setup = '60049206H3004442', arrowgift = 'D', onload = function() playfield.skiplevel = level_labels.wise end },
34 { setup = '003001A700300000' },
35 { setup = '0406480080037060' },
36 { setup = '8606006006734030' },
37 { setup = '03C63560C6130030' },
38 { setup = 'IIIII5I5IIIII5I5', arrowgift = '6' },
39 { setup = '02119003R3019644' },
40 { setup = '6402206064264804' },
41 { setup = '00200401203J00F6', gifts = 'D', onload = function() playfield.skiplevel = level_labels.sacred end },
42 { setup = '4444465445644444' },
43 { setup = 'Z104020010004003', trinket = 'marbles' },
44 { setup = '0700003003000070' },
45 { setup = '336L33565633L533' },
46 { setup = '700F03J00330P007', gifts = '3' },
47 { setup = '2000020055PJQ000', gifts = 'C' },
48 { setup = '0002121124L00020' },
49 { setup = '3636636335355353' },
50 { setup = '3335300530033335' },
51 { setup = 'H0IH00H00530740H', arrowgift = '1' },
52 { setup = '400J000440030340', gifts = 'Z', trinket = 'pistol' },
53 { setup = '200040030b100420' },
54 { setup = 'b0000k0000j0000b' },
55 { setup = '000j064006400708' },
56 { setup = '0b000ab00a0b0a00' },
57 { setup = 'jjjj0110jjjj0Z00', trinket = 'tinyheart' },
58 { setup = '44jjjj4jj4jj4j44' },
59 { setup = '0000aaa0lb800000' },
60 { setup = 'aa55al00la00al33' },
61 { setup = '0l006b60j60l6j60' },
62 { setup = 'QQPPQPQPPQPQPPQQ' },
63 { setup = 'DnCnmmnnBnmmmnnZ', trinket = 'pyramid', onload = function() playfield.skiplevel = level_labels.purple end},
64 { setup = 'Q0B000QCP0Q0P000' },
65 { setup = 'DPQPBQmQLPmPCQmQ', onload = function() playfield.skiplevel = level_labels.purple end },
66 { setup = 'Q0mnCmZPQPm0Q0QQ', trinket = 'casette' },
67 { setup = 'B0PL0Q0PP0P0DQQC', onload = function() playfield.skiplevel = level_labels.purple end },
68 { setup = 'BDPCQPQ0mPPPmPnm', onload = function() playfield.skiplevel = level_labels.purple end },
69 { setup = 'BBBBCPCPQLLLDQPD', onload = function() playfield.skiplevel = level_labels.purple end },
70 { setup = 'nnnnnnnnnnnnnnnn' },
71 { setup = 'Q0B10PP02012Q0P0' },
72 { setup = '0P0PP5650P5000P0' },
73 { setup = '4003000700000008' },
74 { setup = '3n023j30jnn31n3P' },
75 { setup = 'mhj3j0k0Z907f0kn', trinket = 'glitch' },
76 { setup = '004I4HHIIHIH0IJI', gifts = 'Z', arrowgift = '3', trinket = 'magazine' },
77 { setup = 'Q65QQ5Q5QQ56Q565' },
78 { setup = '4mmPbnPn008P8h4a' },
79 { setup = '00J2cj74J8Jj4jJ8', gifts = 'Z000', arrowgift = 'e', trinket = 'photos' },
80 { setup = '8J8J7J7JJ878NJ8J', onload = function() playfield.skiplevel = level_labels.cave; end }, --wiseman1()
81 { setup = '00000J0J00000J0Z', gifts='III', arrowgift = 'J', trinket = 'chocolate', onload = function() game.savedlevel = game.currentlevel; end },
82 { setup = '00000J0JJ0J00J0J', gifts = '743337' },
83 { setup = '40440K0000040004', onload = function() end }, --resetdevil()
84 { setup = '0004040J00J44J44', gifts = '444' },
85 { setup = '5500403065000510' },
86 { setup = '0000412030506780' },
87 { setup = 'IIII2781006L1218', arrowgift = 'D', onload = function() playfield.skiplevel = level_labels.wise; end },
88 { setup = '4DI44HDDIDDID4HD', arrowgift = 'D', onload = function() playfield.skiplevel = level_labels.wise; end },
89 { setup = '007800044200810Z', trinket = 'matches' },
90 { setup = '0000002002J20020', gifts = 'N' },
91 { setup = '0JI00IH0IIII0IJI', gifts = '0Z', arrowgift = '3', trinket = 'toyhorse' },
92 { setup = '000J00008780J0J0', gifts = '634' },
93 { setup = 'B00J0201B0000502', gifts = 'G' },
94 { setup = '0000683000001001' },
95 { setup = '0000070330300307' },
96 { setup = '10100J00P0P00000', gifts = 'O' },
97 { setup = 'Z87Z807000080Z8Z', trinket = '1000pts' },
98 { setup = '1MV453622Y014X3W', onload = function() playfield.objecttype = 'compass'; caveofsecrets1(1); end },
99 { setup = '2V1JJ2031W10J3M2', gifts = 'XYJ', onload = function() playfield.objecttype='matches50';caveofsecrets1(2) end },
100 { setup = 'VW55VW6336YX35YX', onload = function() caveofsecrets1(3) end },
101 { setup = '46002XY00WV10035', onload = function() caveofsecrets1(4) end },
102 { setup = '3001M0W00V8X50Y1', onload = function() playfield.objecttype = 'compass'; caveofsecrets1(5) end },
103 { setup = '01100530J16JJJJJ', gifts = 'JJVWYX', onload = function() caveofsecrets1(6) end },
104 { setup = '0464424WV0X64Y20', onload = function() caveofsecrets1(7) end },
105 { setup = '53W1333XV3304Y02', onload = function() caveofsecrets1(8) end },
106 { setup = '3X4V14306W6175Y4', onload = function() caveofsecrets1(9) end },
107 { setup = '53353VW53YX35335', onload = function() caveofsecrets1(10) end },
108 { setup = '12102408181JJJJJ', gifts = 'JVWXY', onload = function() caveofsecrets1(11) end },
109 { setup = '203J0303303JJJ2J', gifts = 'JVWXY', onload = function() caveofsecrets1(12) end },
110 { setup = '35W0535XV5350Y53', onload = function() caveofsecrets1(13) end },
111 { setup = '242M4WX11VY40242', onload = function() playfield.objecttype = 'teleport'; caveofsecrets1(14) end },
112 { setup = 'J18JM4082563J25J', gifts = 'VWXY', trinket = 'rainbowring', onload = function() playfield.objecttype = 'addanchor'; caveofsecrets1(15) end },
113 { setup = 'JJX5806400057JM0', gifts = 'VWY', onload = function() objecttype = 'addanchor'; an = '9'; caveofsecrets1(16) end },
116 level_labels = {
117 [1] = 'Apartment',
118 [6] = 'Street',
119 [12] = 'Station',
120 [21] = 'Graveyard',
121 [27] = 'Interzone',
122 [43] = 'Gates',
123 [48] = 'Forbidden Land',
124 [53] = 'Flashbacks',
125 [62] = 'Purple Land',
126 purple = 62,
127 [71] = 'The Shakes',
128 [80] = 'Wise Man Duel',
129 [81] = 'Sacred Ground',
130 sacred = 81,
131 [83] = 'Pandora\'s Box',
132 [84] = 'Sacred Ground 2',
133 [86] = 'Wise Man\'s Path',
134 wise = 86,
135 [95] = 'Pill Gates',
136 [96] = 'Amnesia Pill Room',
137 [97] = 'Cliffs',
138 [98] = 'Cave of Secrets',
139 cave = 98,
141 setmetatable(level_labels, {__index = function (table, key)
142 if key > 1 and not rawget(table, key) then return table[key - 1] end
143 end})
146 function click_adventurer()
147 for i = 1, #trinkets.held do
148 if trinkets.held[i] == 'map' then
149 game:change_screen('story_adventurer_nothing')
150 return
153 trinkets.held[#trinkets.held + 1] = 'map'
154 game:change_screen('story_adventurer_map')
158 tiletypes = {
159 ['0'] = {kind = 'tile', passive = true},
160 ['1'] = {kind = 'green', shape = 'x'},
161 ['2'] = {kind = 'green', shape = '+'},
162 ['3'] = {kind = 'yellow', shape = 'x'},
163 ['4'] = {kind = 'yellow', shape = '+'},
164 ['5'] = {kind = 'red', shape = 'x'},
165 ['6'] = {kind = 'red', shape = '+'},
166 ['7'] = {kind = 'regene', shape = 'x', sleep = 0},
167 ['8'] = {kind = 'regene', shape = '+', sleep = 0},
168 ['9'] = {kind = 'regene', shape = 'x', sleep = 1, sleeping_name = '7', passive = true},
169 A = {kind = 'regene', shape = '+', sleep = 1, sleeping_name = '8', passive = true},
170 B = {kind = 'bluesave', passive = true},
171 C = {kind = 'blueload', passive = true},
172 D = {kind = 'blackload', passive = true},
173 F = {kind = 'redsave', passive = true},
174 G = {kind = 'redload', passive = true},
175 H = {kind = 'loadred', shape = 'x'},
176 I = {kind = 'loadred', shape = '+'},
177 J = {kind = 'gift'},
178 K = {kind = 'devilgift'},
179 L = {kind = 'blacksave', passive = true},
180 M = {kind = 'object', passive = true},
181 N = {kind = 'wiseman'},
182 O = {kind = 'pill', passive = true},
183 P = {kind = 'purple', shape = '+'},
184 Q = {kind = 'purple', shape = 'x'},
185 R = {kind = 'killed', image = images.killed, onclick = click_adventurer},
186 V = {kind = 'left', passive = true},
187 W = {kind = 'up', passive = true},
188 X = {kind = 'right', passive = true},
189 Y = {kind = 'down', passive = true},
190 Z = {kind = 'trinket', passive = true},
191 a = {kind = 'memory', of = '2'}, -- green+
192 b = {kind = 'memory', of = '1'}, -- greenx
193 c = {kind = 'memory', of = 'I'}, -- loadred+
194 d = {kind = 'memory', of = 'H'}, -- loadredx
195 e = {kind = 'memory', of = '6'}, -- red+
196 f = {kind = 'memory', of = '5'}, -- redx
197 g = {kind = 'memory', of = 'A'}, -- regene+ sleep
198 h = {kind = 'memory', of = '7'}, -- regenex
199 i = {kind = 'memory', of = '9'}, -- regenex sleep
200 j = {kind = 'memory', of = '4'}, -- yellow+
201 k = {kind = 'memory', of = '3'}, -- yellowx
202 l = {kind = 'memory', of = '8'}, -- regene+
203 m = {kind = 'memory', of = 'P'}, -- purple+ --!!
204 n = {kind = 'memory', of = 'Q'}, -- purplex --!!
208 function get_memory_name(tilename)
209 for name, v in pairs(tiletypes) do
210 if v.of == tilename then return name end
215 function shape_to_arrows(tileshape)
216 -- arrows at 8 positions, at angles from 0 to 3pi /2
217 if tileshape == '+' then
218 return {0, false, 0, false, 0, false, 0, false}
219 elseif tileshape == 'x' then
220 return {false, 0, false, 0, false, 0, false, 0}
225 function recognizeink(chr, of_fill)
226 chr = chr or '0' -- default: floor tile, used in opening of gifts
227 local tile = {} -- this should be copied, not referenced, because it gets modified
228 for k, v in pairs(tiletypes[chr]) do tile[k] = v end
229 tile.name = tile.name or chr
230 -- modifications
231 if game.purple and tile.kind == 'purple' then
232 if tile.shape == 'x' then tile.shape = '+' else tile.shape = 'x' end
233 if tile.name == 'P' then tile.name = 'Q' else tile.name = 'Q' end
234 -- becomes relevant when underpill
236 if not of_fill and tile.shape and game.underpill then --!!
237 tile = { name = get_memory_name(tile.name), kind = 'memory', of = tile.name }
239 if (not tile.sleep) or (tile.sleep == 0) then
240 tile.arrows = shape_to_arrows(tile.shape)
241 else
242 tile.arrows = {}
244 if tile.kind == 'memory' then
245 tile.memory = recognizeink(tile.of, true)
246 tile.passive = true
248 if tile.kind == 'loadred' then
249 tile.arrowgift = recognizeink(levels[game.currentlevel].arrowgift)
251 --!! add onclicks here
252 return tile
256 function fill_gifts(currentlevel)
257 local giftpos = 1
258 inplayfield(function (x, y, p)
259 if playfield[x][y].kind == 'gift' or playfield[x][y].kind == 'devilgift' then
260 if levels[currentlevel].gifts then
261 playfield[x][y].gift = string.sub(levels[currentlevel].gifts, giftpos, giftpos)
263 if not playfield[x][y].gift or playfield[x][y].gift == '' then playfield[x][y].gift = '0' end
264 giftpos = giftpos + 1
266 end)
270 function setuplevel(currentlevel)
271 game.died = false
272 game.showkill = false
273 if currentlevel and levels[currentlevel] then --load only existing levels
274 game.currentlevel = currentlevel
275 else
276 currentlevel = game.currentlevel
278 game.temppurple = game.purple
279 local pos
280 inplayfield(function (x, y, p)
281 pos = (y - 1) * 4 + x
282 playfield[x][y] = recognizeink(string.sub(levels[currentlevel].setup, pos, pos))
283 ---if playfield[x][y].kind == 'loadred' then
284 -- playfield[x][y].arrowgift = recognizeink(levels[currentlevel].arrowgift)
285 --end
286 --handled by recognizeink
288 -- set gift property of visible gifts as set in level table
289 -- gifts generated during the game are not taken into account
290 -- but there is only one level which generates gifts (81),
291 -- and it is not affected because gifts are present at the beginning
292 end)
293 fill_gifts(currentlevel)
294 playfield.clickedx, playfield.clickedy = false, false
295 --onload
296 if levels[game.currentlevel].onload then
297 levels[game.currentlevel].onload() --!!
299 --[[
300 tiploadtila='C';
301 gifts=''; giftslist='0000000000000000' -- giftslist moze biti i kraci od 16 ako nema dovoljno giftova
302 pogino=0;
303 pressed=0; oldpressed=0; oldoldpressed=0;
304 devilblock=0;
309 --[[
311 //POCETAK SETUPLEVELA
312 function setuplevel()
314 temppurple=purple;
315 tiploadtila='C';
316 gifts=''; giftslist='0000000000000000' // giftslist moze biti i kraci od 16 ako nema dovoljno giftova
317 pogino=0;
318 pressed=0; oldpressed=0; oldoldpressed=0;
319 devilblock=0;
320 if (touched)
322 touched=false;
323 setslotcookie(slot);
325 //ako je neko na neki nacin izasao iz arraya nivoa:
326 if (level[currentlevel-1] == null)
329 tajkod='You were consumed by the Void.</a>'
330 opts.innerHTML=tajkod;
331 playfielduuzemsmislu.style.display='none';
332 opts.style.display='block';
333 dialogue=true;
335 currentlevel=lvlwise;
336 anchored=false;
337 setslotcookie(slot)
338 setuplevel();
339 return;
342 var levelcod=level[currentlevel-1];
343 /* umesto ovoga, idu izvrnuti nivoi
345 for(a=1; a<=16;a++)
347 eval("tile"+a).src=recognizeink(levelcod.charAt(a-1))+".png";
352 // special cases:
353 // gifts, label... wiseman (koristi orientation)
354 eval(level[currentlevel-1].substr(16));
355 //i resetdevil^
358 var a,b,c,d=0,x,y,z,tile;
359 switch (orientation)
361 case 1:
362 x=4; y=1; z=1;
363 break;
364 case 2:
365 x=1; y=-4; z=13;
366 break;
367 case 3:
368 x=-4; y=-1; z=16;
369 break;
370 case 4:
371 x=-1; y=4; z=4;
372 break;
373 case 5:
374 x=4; y=-1; z=4;
375 break;
376 case 6:
377 x=1; y=4; z=1;
378 break;
379 case 7:
380 x=-4; y=1; z=13;
381 break;
382 case 8:
383 x=-1; y=-4; z=16;
384 break;
387 for(a=1; a<=16;a++)
389 b=Math.floor((a-1)/4);
390 c=(a-1)%4;
391 tile=x*b+y*c+z;
392 eval("tile"+tile).src=(caveofsecrets ? 'ending/tiles/' : '') + recognizeink(levelcod.charAt(a-1))+".png";
393 if (levelcod.charAt(a-1)=='J') giftslist = giftslist.slice(0,tile-1) + String(gifts).charAt(d++) + giftslist.substr(tile);
397 label=getlabel(currentlevel);
398 document.title=label;
399 //special cases - nisu svi ovde a trebalo bi..
400 if (currentlevel==2 && !hasitem('hlp')) {
401 situation="Check the <a style='text-decoration: underline' href='../manual/playfield.html' target='help'>game manual</a> for details on playing the game."
402 additem('hlp')
403 smallwindowclick()
404 drawopts('a')
406 else if (label=="Pandora's Box")
408 seenpandora=true; //seenovi se za sad ne cuvaju
409 if (!devil && smallsituation!="Yes!")
411 situation="You enter the room with a strange gift.";
412 smallsituation='You see strange gift.';
414 else if (smallsituation!="Yes!")
416 situation="You remember a strange gift that was here, once.";
417 smallsituation='Where is the box?';
420 else if (label=='Amnesia Pill Room') seenamnesiapill=true;
421 else if (label=='Wise Man Duel')
423 situation='You defeated The Wise Man.';
424 smallsituation='Defeated Wise Man.';
426 else if (underpill)
428 situation='You took amnesia pill but everything seems normal.';
429 smallsituation='You took amnesia pill.';
431 else if (currentlevel>1)
433 situation='<small>Your goal:</small><br>';
434 situation+='Click on and turn off all arrows.';
435 situation+='<br><br><small>Hint:</small><br>';
436 situation+='Do not click where arrows point directly.<br>If arrows move, take into account the next turn.'
437 smallsituation = 'Click on arrows. Do not get pointed at.';
441 if (!dialogue) drawopts(0);
443 setbackground()
445 //KRAJ SETUPLEVELA