Don't transfer devil status and rotate arrow which is just passing into memory.
[poca-love.git] / levels.lua
blob9665cc72427666bdb6b0b7ecb6b05720166e3549
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() if game.underpill then game:events('pill off') end end },
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 devil = 83,
133 [84] = 'Sacred Ground 2',
134 [86] = 'Wise Man\'s Path',
135 wise = 86,
136 [95] = 'Pill Gates',
137 [96] = 'Amnesia Pill Room',
138 pill = 96,
139 [97] = 'Cliffs',
140 [98] = 'Cave of Secrets',
141 cave = 98,
143 setmetatable(level_labels, {__index = function (table, key)
144 if key > 1 and not rawget(table, key) then return table[key - 1] end
145 end})
148 function click_adventurer()
149 for i = 1, #trinkets.held do
150 if trinkets.held[i] == 'map' then
151 game:change_screen('story_adventurer_nothing')
152 return
155 trinkets.held[#trinkets.held + 1] = 'map'
156 game:change_screen('story_adventurer_map')
160 tiletypes = {
161 ['0'] = {kind = 'tile', passive = true},
162 ['1'] = {kind = 'green', shape = 'x'},
163 ['2'] = {kind = 'green', shape = '+'},
164 ['3'] = {kind = 'yellow', shape = 'x'},
165 ['4'] = {kind = 'yellow', shape = '+'},
166 ['5'] = {kind = 'red', shape = 'x'},
167 ['6'] = {kind = 'red', shape = '+'},
168 ['7'] = {kind = 'regene', shape = 'x', sleep = 0},
169 ['8'] = {kind = 'regene', shape = '+', sleep = 0},
170 ['9'] = {kind = 'regene', shape = 'x', sleep = 1, sleeping_name = '7', passive = true},
171 A = {kind = 'regene', shape = '+', sleep = 1, sleeping_name = '8', passive = true},
172 B = {kind = 'bluesave', passive = true},
173 C = {kind = 'blueload', passive = true},
174 D = {kind = 'blackload', passive = true},
175 F = {kind = 'redsave', passive = true},
176 G = {kind = 'redload', passive = true},
177 H = {kind = 'loadred', shape = 'x'},
178 I = {kind = 'loadred', shape = '+'},
179 J = {kind = 'gift'},
180 K = {kind = 'devilgift'},
181 L = {kind = 'blacksave', passive = true},
182 M = {kind = 'object', passive = true},
183 N = {kind = 'wiseman'},
184 O = {kind = 'pill', passive = true},
185 P = {kind = 'purple', shape = '+'},
186 Q = {kind = 'purple', shape = 'x'},
187 R = {kind = 'killed', image = images.killed, onclick = click_adventurer},
188 V = {kind = 'left', passive = true},
189 W = {kind = 'up', passive = true},
190 X = {kind = 'right', passive = true},
191 Y = {kind = 'down', passive = true},
192 Z = {kind = 'trinket', passive = true},
193 a = {kind = 'memory', of = '2'}, -- green+
194 b = {kind = 'memory', of = '1'}, -- greenx
195 c = {kind = 'memory', of = 'I'}, -- loadred+
196 d = {kind = 'memory', of = 'H'}, -- loadredx
197 e = {kind = 'memory', of = '6'}, -- red+
198 f = {kind = 'memory', of = '5'}, -- redx
199 g = {kind = 'memory', of = 'A'}, -- regene+ sleep
200 h = {kind = 'memory', of = '7'}, -- regenex
201 i = {kind = 'memory', of = '9'}, -- regenex sleep
202 j = {kind = 'memory', of = '4'}, -- yellow+
203 k = {kind = 'memory', of = '3'}, -- yellowx
204 l = {kind = 'memory', of = '8'}, -- regene+
205 m = {kind = 'memory', of = 'P'}, -- purple+
206 n = {kind = 'memory', of = 'Q'}, -- purplex
210 function get_rotated_name(tilename)
211 --if tiletypes[tilename].kind == 'memory' then
212 -- return get_memory_name(get_rotated_name(tiletypes[tilename].of))
213 --end
214 local shape
215 if tiletypes[tilename].shape == '+' then shape = 'x' else shape = '+' end
216 for name, v in pairs(tiletypes) do
217 if v.kind == tiletypes[tilename].kind and v.shape == shape then
218 return name
224 function get_memory_name(tilename)
225 for name, v in pairs(tiletypes) do
226 if v.of == tilename then return name end
231 function shape_to_arrows(tileshape)
232 -- arrows at 8 positions, at angles from 0 to 3pi /2
233 if tileshape == '+' then
234 return {0, false, 0, false, 0, false, 0, false}
235 elseif tileshape == 'x' then
236 return {false, 0, false, 0, false, 0, false, 0}
241 function recognizeink(chr)
242 chr = chr or '0' -- default: floor tile, used in opening of gifts
243 local tile = {} -- this should be copied, not referenced, because it gets modified
244 for k, v in pairs(tiletypes[chr]) do tile[k] = v end
245 tile.name = chr
246 -- modifications
247 if (not tile.sleep) or (tile.sleep == 0) then
248 tile.arrows = shape_to_arrows(tile.shape)
249 else
250 tile.arrows = {}
252 if tile.kind == 'memory' then
253 tile.memory = recognizeink(tile.of)
254 tile.passive = true
256 if tile.kind == 'loadred' then
257 tile.arrowgift = recognizeink(levels[game.currentlevel].arrowgift)
259 --!! add onclicks here
260 return tile
264 function fill_gifts(currentlevel)
265 local giftpos = 1
266 inplayfield(function (x, y, p)
267 if playfield[x][y].kind == 'gift' or playfield[x][y].kind == 'devilgift' then
268 if levels[currentlevel].gifts then
269 playfield[x][y].gift = string.sub(levels[currentlevel].gifts, giftpos, giftpos)
271 if not playfield[x][y].gift or playfield[x][y].gift == '' then playfield[x][y].gift = '0' end
272 giftpos = giftpos + 1
274 end)
278 function setuplevel(currentlevel)
279 game.died = false
280 game.showkill = false
281 if currentlevel and levels[currentlevel] then --load only existing levels
282 game.currentlevel = currentlevel
283 else
284 currentlevel = game.currentlevel
286 game.temppurple = game.purple
287 local c, mc, pos
288 inplayfield(function (x, y, p)
289 pos = (y - 1) * 4 + x
290 c = string.sub(levels[currentlevel].setup, pos, pos)
291 -- modifications
292 if game.purple then
293 if c == 'P' then c = 'Q' elseif c == 'Q' then c = 'P' end
294 if c == 'm' then c = 'n' elseif c == 'n' then c = 'm' end
296 if game.underpill then
297 c = get_memory_name(c) or c
300 playfield[x][y] = recognizeink(c)
301 ---if playfield[x][y].kind == 'loadred' then
302 -- playfield[x][y].arrowgift = recognizeink(levels[currentlevel].arrowgift)
303 --end
304 --handled by recognizeink
306 -- set gift property of visible gifts as set in level table
307 -- gifts generated during the game are not taken into account
308 -- but there is only one level which generates gifts (81),
309 -- and it is not affected because gifts are present at the beginning
310 end)
311 fill_gifts(currentlevel)
312 playfield.clickedx, playfield.clickedy = false, false
313 --onload
314 if levels[game.currentlevel].onload then
315 levels[game.currentlevel].onload() --!!
317 --[[
318 tiploadtila='C';
319 gifts=''; giftslist='0000000000000000' -- giftslist moze biti i kraci od 16 ako nema dovoljno giftova
320 pogino=0;
321 pressed=0; oldpressed=0; oldoldpressed=0;
322 devilblock=0;
327 --[[
329 //POCETAK SETUPLEVELA
330 function setuplevel()
332 temppurple=purple;
333 tiploadtila='C';
334 gifts=''; giftslist='0000000000000000' // giftslist moze biti i kraci od 16 ako nema dovoljno giftova
335 pogino=0;
336 pressed=0; oldpressed=0; oldoldpressed=0;
337 devilblock=0;
338 if (touched)
340 touched=false;
341 setslotcookie(slot);
343 //ako je neko na neki nacin izasao iz arraya nivoa:
344 if (level[currentlevel-1] == null)
347 tajkod='You were consumed by the Void.</a>'
348 opts.innerHTML=tajkod;
349 playfielduuzemsmislu.style.display='none';
350 opts.style.display='block';
351 dialogue=true;
353 currentlevel=lvlwise;
354 anchored=false;
355 setslotcookie(slot)
356 setuplevel();
357 return;
360 var levelcod=level[currentlevel-1];
361 /* umesto ovoga, idu izvrnuti nivoi
363 for(a=1; a<=16;a++)
365 eval("tile"+a).src=recognizeink(levelcod.charAt(a-1))+".png";
370 // special cases:
371 // gifts, label... wiseman (koristi orientation)
372 eval(level[currentlevel-1].substr(16));
373 //i resetdevil^
376 var a,b,c,d=0,x,y,z,tile;
377 switch (orientation)
379 case 1:
380 x=4; y=1; z=1;
381 break;
382 case 2:
383 x=1; y=-4; z=13;
384 break;
385 case 3:
386 x=-4; y=-1; z=16;
387 break;
388 case 4:
389 x=-1; y=4; z=4;
390 break;
391 case 5:
392 x=4; y=-1; z=4;
393 break;
394 case 6:
395 x=1; y=4; z=1;
396 break;
397 case 7:
398 x=-4; y=1; z=13;
399 break;
400 case 8:
401 x=-1; y=-4; z=16;
402 break;
405 for(a=1; a<=16;a++)
407 b=Math.floor((a-1)/4);
408 c=(a-1)%4;
409 tile=x*b+y*c+z;
410 eval("tile"+tile).src=(caveofsecrets ? 'ending/tiles/' : '') + recognizeink(levelcod.charAt(a-1))+".png";
411 if (levelcod.charAt(a-1)=='J') giftslist = giftslist.slice(0,tile-1) + String(gifts).charAt(d++) + giftslist.substr(tile);
415 label=getlabel(currentlevel);
416 document.title=label;
417 //special cases - nisu svi ovde a trebalo bi..
418 if (currentlevel==2 && !hasitem('hlp')) {
419 situation="Check the <a style='text-decoration: underline' href='../manual/playfield.html' target='help'>game manual</a> for details on playing the game."
420 additem('hlp')
421 smallwindowclick()
422 drawopts('a')
424 else if (label=="Pandora's Box")
426 seenpandora=true; //seenovi se za sad ne cuvaju
427 if (!devil && smallsituation!="Yes!")
429 situation="You enter the room with a strange gift.";
430 smallsituation='You see strange gift.';
432 else if (smallsituation!="Yes!")
434 situation="You remember a strange gift that was here, once.";
435 smallsituation='Where is the box?';
438 else if (label=='Amnesia Pill Room') seenamnesiapill=true;
439 else if (label=='Wise Man Duel')
441 situation='You defeated The Wise Man.';
442 smallsituation='Defeated Wise Man.';
444 else if (underpill)
446 situation='You took amnesia pill but everything seems normal.';
447 smallsituation='You took amnesia pill.';
449 else if (currentlevel>1)
451 situation='<small>Your goal:</small><br>';
452 situation+='Click on and turn off all arrows.';
453 situation+='<br><br><small>Hint:</small><br>';
454 situation+='Do not click where arrows point directly.<br>If arrows move, take into account the next turn.'
455 smallsituation = 'Click on arrows. Do not get pointed at.';
459 if (!dialogue) drawopts(0);
461 setbackground()
463 //KRAJ SETUPLEVELA