more blood cosmetix
[k8vacspelynky.git] / rgenobj.vc
blob82662f20d7ea1c314be7c59c36cc51f405f86c5e
1 /**********************************************************************************
2  * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3  * Copyright (c) 2018, Ketmar Dark
4  *
5  * This file is part of Spelunky.
6  *
7  * You can redistribute and/or modify Spelunky, including its source code, under
8  * the terms of the Spelunky User License.
9  *
10  * Spelunky is distributed in the hope that it will be entertaining and useful,
11  * but WITHOUT WARRANTY.  Please see the Spelunky User License for more details.
12  *
13  * The Spelunky User License should be available in "Game Information", which
14  * can be found in the Resource Explorer, or as an external file called COPYING.
15  * If not, please obtain a new copy of Spelunky from <http://spelunkyworld.com/>
16  *
17  **********************************************************************************/
18 // ////////////////////////////////////////////////////////////////////////// //
19 void scrLevGenShopkeeper (int xpos, int ypos, name shopType) {
20   auto obj = MonsterShopkeeper(MakeMapObject(xpos, ypos, 'oShopkeeper'));
21   if (obj) {
22     //if (shopType == 'Ankh') writeln("::: ", shopType, " :::");
23     obj.style = shopType;
24     if (shopType == 'Craps') obj.generatePrizes();
25   }
29 // ////////////////////////////////////////////////////////////////////////// //
30 enum GenItemSet {
31   Crate,
32   Craps,
33   Underground,
36 MapObject scrGenerateItem (int objx, int objy, GenItemSet setType) {
37   MapObject obj = none;
39   switch (setType) {
40     case GenItemSet.Crate: // crate set
41            if (global.randRoom(1, 500) == 1) obj = MakeMapObject(objx, objy, 'oJetpack');
42       else if (global.randRoom(1, 200) == 1) obj = MakeMapObject(objx, objy, 'oCapePickup');
43       else if (global.randRoom(1, 100) == 1) obj = MakeMapObject(objx, objy, 'oShotgun');
44       else if (!global.isTunnelMan && global.randRoom(1, 100) == 1) obj = MakeMapObject(objx, objy, 'oMattock');
45       else if (global.randRoom(1, 100) == 1) obj = MakeMapObject(objx, objy, 'oTeleporter');
46       else if (global.randRoom(1, 90) == 1) obj = MakeMapObject(objx, objy, 'oGloves');
47       else if (global.randRoom(1, 90) == 1) obj = MakeMapObject(objx, objy, 'oSpectacles');
48       else if (global.randRoom(1, 80) == 1) obj = MakeMapObject(objx, objy, 'oWebCannon');
49       else if (global.randRoom(1, 80) == 1) obj = MakeMapObject(objx, objy, 'oPistol');
50       else if (global.randRoom(1, 80) == 1) obj = MakeMapObject(objx, objy, 'oMitt');
51       else if (global.randRoom(1, 60) == 1) obj = MakeMapObject(objx, objy, 'oPaste');
52       else if (global.randRoom(1, 60) == 1) obj = MakeMapObject(objx, objy, 'oSpringShoes');
53       else if (global.randRoom(1, 60) == 1) obj = MakeMapObject(objx, objy, 'oSpikeShoes');
54       else if (global.randRoom(1, 60) == 1) obj = MakeMapObject(objx, objy, 'oMachete');
55       else if (global.randRoom(1, 40) == 1) obj = MakeMapObject(objx, objy, 'oBombBox');
56       else if (global.randRoom(1, 40) == 1) obj = MakeMapObject(objx, objy, 'oBow');
57       else if (global.randRoom(1, 20) == 1) obj = MakeMapObject(objx, objy, 'oCompass');
58       else if (global.randRoom(1, 10) == 1) obj = MakeMapObject(objx, objy, 'oParaPickup');
59       else obj = MakeMapObject(objx, objy, 'oRopePile');
60       obj.forSale = false;
61       break;
62     case GenItemSet.Craps: // high end set -- craps game prizes
63            if (global.randRoom(1, 40) == 1) obj = MakeMapObject(objx, objy, 'oJetpack');
64       else if (global.randRoom(1, 25) == 1) obj = MakeMapObject(objx, objy, 'oCapePickup');
65       else if (global.randRoom(1, 20) == 1) obj = MakeMapObject(objx, objy, 'oShotgun');
66       else if (global.randRoom(1, 10) == 1) obj = MakeMapObject(objx, objy, 'oGloves');
67       else if (global.randRoom(1, 10) == 1) obj = MakeMapObject(objx, objy, 'oTeleporter');
68       else if (!global.isTunnelMan && global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oMattock');
69       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oPaste');
70       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oSpringShoes');
71       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oSpikeShoes');
72       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oCompass');
73       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oPistol');
74       else if (global.randRoom(1, 8) == 1) obj = MakeMapObject(objx, objy, 'oMachete');
75       else obj = MakeMapObject(objx, objy, 'oBombBox');
76       break;
77     case GenItemSet.Underground: // Underground Set (items hidden inside solid walls, see oBrick etc)
78       switch (global.randRoom(0, 18)) {
79         case 0: obj = MakeMapObject(objx, objy-2, 'oJetpack'); break;
80         case 1: obj = MakeMapObject(objx, objy, 'oCapePickup'); break;
81         case 2: obj = MakeMapObject(objx, objy, 'oShotgun'); break;
82         case 3:
83           if (global.isTunnelMan) obj = MakeMapObject(objx, objy, 'oRopePile');
84           else obj = MakeMapObject(objx, objy, 'oMattock');
85           break;
86         case 4: obj = MakeMapObject(objx, objy+3, 'oTeleporter'); break;
87         case 5: obj = MakeMapObject(objx, objy-1, 'oGloves'); break;
88         case 6: obj = MakeMapObject(objx, objy, 'oSpectacles'); break;
89         case 7: obj = MakeMapObject(objx-2, objy, 'oWebCannon'); break;
90         case 8: obj = MakeMapObject(objx, objy, 'oPistol'); break;
91         case 9: obj = MakeMapObject(objx, objy-1, 'oMitt'); break;
92         case 10: obj = MakeMapObject(objx, objy, 'oPaste'); break;
93         case 11: obj = MakeMapObject(objx, objy, 'oSpringShoes'); break;
94         case 12: obj = MakeMapObject(objx, objy, 'oSpikeShoes'); break;
95         case 13: obj = MakeMapObject(objx, objy, 'oMachete'); break;
96         case 14: obj = MakeMapObject(objx, objy-2, 'oBombBox'); break;
97         case 15: obj = MakeMapObject(objx, objy, 'oBow'); break;
98         case 16: obj = MakeMapObject(objx, objy, 'oCompass'); break;
99         case 17: obj = MakeMapObject(objx, objy, 'oParaPickup'); break;
100         case 18: obj = MakeMapObject(objx, objy, 'oRopePile'); break;
101       }
102       break;
103   }
105   return obj;
109 // generate shop items
110 MapObject scrShopItemsGen (int xpos, int ypos, name shopType) {
111   MapObject obj = none;
113   writeln("generating items for shop \"", shopType, "\"...");
115   if (shopType == 'Bomb') {
116     for (;;) {
117       if (global.randRoom(1, 5) == 1) {
118         if (!findAnyObjectOfType('oPaste')) { obj = MakeMapObject(xpos+8, ypos+10, 'oPaste'); break; }
119       } else if (global.randRoom(1, 4) == 1) {
120         obj = MakeMapObject(xpos+8, ypos+8, 'oBombBox');
121         break;
122       } else if (global.config.optSGAmmo && global.randRoom(1, 10) == 1) {
123         obj = MakeMapObject(xpos+4, ypos+10, 'oShells');
124         break;
125       } else {
126         if (global.config.optSGAmmo && findAnyObjectOfType('oShotgun')) {
127           obj = MakeMapObject(xpos+4, ypos+10, 'oShells');
128         } else {
129           obj = MakeMapObject(xpos+8, ypos+10, 'oBombBag');
130         }
131         break;
132       }
133     }
134   } else if (shopType == 'Weapon') {
135     int m = 20;
136     for (;;) {
137       int n = global.randRoom(1, 4);
138       if (m <= 0) {
139         obj = MakeMapObject(xpos+8, ypos+10, 'oBombBag');
140         break;
141       } else if (global.randRoom(1, 12) == 1) {
142         if (!findAnyObjectOfType('oWebCannon')) { obj = MakeMapObject(xpos+8, ypos+12, 'oWebCannon'); break; }
143       } else if (global.randRoom(1, 10) == 1) {
144         if (!findAnyObjectOfType('oShotgun')) { obj = MakeMapObject(xpos+8, ypos+12, 'oShotgun'); break; }
145       } else if (global.randRoom(1, 6) == 1) {
146         obj = MakeMapObject(xpos+8, ypos+10, 'oBombBox');
147         break;
148       } else if (n == 1) {
149         if (!findAnyObjectOfType('oPistol')) { obj = MakeMapObject(xpos+8, ypos+12, 'oPistol'); break; }
150       } else if (n == 2) {
151         if (!findAnyObjectOfType('oMachete')) { obj = MakeMapObject(xpos+8, ypos+12, 'oMachete'); break; }
152       } else if (n == 3) {
153         if (global.config.optSGAmmo && findAnyObjectOfType('oShotgun')) {
154           obj = MakeMapObject(xpos+4, ypos+10, 'oShells');
155         } else {
156           obj = MakeMapObject(xpos+8, ypos+10, 'oBombBag');
157         }
158         break;
159       } else if (n == 4) {
160         if (!findAnyObjectOfType('oBow')) { obj = MakeMapObject(xpos+8, ypos+12, 'oBow'); break; }
161       }
162       m -= 1;
163     }
164   } else if (shopType == 'Clothing') {
165     int m = 20;
166     for (;;) {
167       int n = global.randRoom(1, 6);
168            if (global.randRoom(1, m) == 1) { obj = MakeMapObject(xpos+8, ypos+11, 'oRopePile'); break; }
169       else if (n == 1) { if (!findAnyObjectOfType('oSpringShoes')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpringShoes'); break; } }
170       else if (n == 2) { if (!findAnyObjectOfType('oSpectacles')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpectacles'); break; } }
171       else if (n == 3) { if (!findAnyObjectOfType('oGloves')) { obj = MakeMapObject(xpos+8, ypos+8, 'oGloves'); break; } }
172       else if (n == 4) { if (!findAnyObjectOfType('oMitt')) { obj = MakeMapObject(xpos+8, ypos+8, 'oMitt'); break; } }
173       else if (n == 5) { if (!findAnyObjectOfType('oCapePickup')) { obj = MakeMapObject(xpos+8, ypos+10, 'oCapePickup'); break; } }
174       else if (n == 6) { if (!findAnyObjectOfType('oSpikeShoes')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpikeShoes'); break; } }
175       m -= 1;
176     }
177   } else if (shopType == 'Rare') {
178     int m = 20;
179     for (;;) {
180       int n = global.randRoom(1, 11);
181            if (global.randRoom(1, m) == 1) { obj = MakeMapObject(xpos+8, ypos+8, 'oBombBox'); break; }
182       else if (n == 1) { if (!findAnyObjectOfType('oSpringShoes')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpringShoes'); break; } }
183       else if (n == 2) { if (!findAnyObjectOfType('oCompass')) { obj = MakeMapObject(xpos+8, ypos+10, 'oCompass'); break; } }
184       else if (n == 3) { if (!findAnyObjectOfType('oMattock') && !global.isTunnelMan) { obj = MakeMapObject(xpos+8, ypos+10, 'oMattock'); break; } }
185       else if (n == 4) { if (!findAnyObjectOfType('oSpectacles')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpectacles'); break; } }
186       else if (n == 5) { if (!findAnyObjectOfType('oJetpack')) { obj = MakeMapObject(xpos+8, ypos+8, 'oJetpack'); break; } }
187       else if (n == 6) { if (!findAnyObjectOfType('oGloves')) { obj = MakeMapObject(xpos+8, ypos+8, 'oGloves'); break; } }
188       else if (n == 7) { if (!findAnyObjectOfType('oMitt')) { obj = MakeMapObject(xpos+8, ypos+8, 'oMitt'); break; } }
189       else if (n == 8) { if (!findAnyObjectOfType('oWebCannon')) { obj = MakeMapObject(xpos+8, ypos+12, 'oWebCannon'); break; } }
190       else if (n == 9) { if (!findAnyObjectOfType('oCapePickup')) { obj = MakeMapObject(xpos+8, ypos+10, 'oCapePickup'); break; } }
191       else if (n == 10) { if (!findAnyObjectOfType('oTeleporter')) { obj = MakeMapObject(xpos+8, ypos+12, 'oTeleporter'); break; } }
192       else if (n == 11) { if (!findAnyObjectOfType('oSpikeShoes')) { obj = MakeMapObject(xpos+8, ypos+10, 'oSpikeShoes'); break; } }
193       m -= 1;
194     }
195   } else {
196     for (;;) {
197       int n = global.randRoom(1, 3);
198       if (global.randRoom(1, 20) == 1) { if (!findAnyObjectOfType('oMattock') && !global.isTunnelMan) { obj = MakeMapObject(xpos+8, ypos+10, 'oMattock'); break; } }
199       else if (global.randRoom(1, 10) == 1) { if (!findAnyObjectOfType('oGloves')) { obj = MakeMapObject(xpos+8, ypos+8, 'oGloves'); break; } }
200       else if (global.randRoom(1, 10) == 1) { if (!findAnyObjectOfType('oCompass')) { obj = MakeMapObject(xpos+8, ypos+10, 'oCompass'); break; } }
201       else if (n == 1) {
202         if (global.config.optSGAmmo && findAnyObjectOfType('oShotgun')) {
203           obj = MakeMapObject(xpos+4, ypos+10, 'oShells');
204         } else {
205           obj = MakeMapObject(xpos+8, ypos+10, 'oBombBag');
206         }
207         break;
208       } else if (n == 2) { obj = MakeMapObject(xpos+8, ypos+11, 'oRopePile'); break; }
209         else if (n == 3) { obj = MakeMapObject(xpos+8, ypos+10, 'oParaPickup'); break; }
210     }
211   }
213   if (obj) {
214     obj.forSale = true;
215     obj.shopType = shopType;
216     /+k8: cost is generated in item creation code
217     if (global.currLevel > 2) {
218       if (obj.cost <= 0) obj.cost = 100;
219       obj.cost += (obj.cost/100)*10*(global.currLevel-2);
220       //if (shopDesc == "") buyMessage = "A "+string_upper(type)+" FOR $"+string(cost)+".";
221       //else buyMessage = shopDesc+" FOR $"+string(cost)+".";
222     }
223     +/
224   }
226   return obj;
230 // ////////////////////////////////////////////////////////////////////////// //
231 //WARNING: keep this in sync with `ItemJar::onDestroy()`!
232 name scrLevGenCreateJarContents () {
233   name ctx;
235        if (global.randRoom(1, 3) == 1) ctx = 'oGoldChunk';
236   else if (global.config.optSGAmmo && global.randRoom(1, 4) == 1) ctx = 'oShellSingle';
237   else if (global.randRoom(1, 6) == 1) ctx = 'oGoldNugget';
238   else if (global.randRoom(1, 12) == 1) ctx = 'oEmeraldBig';
239   else if (global.randRoom(1, 12) == 1) ctx = 'oSapphireBig';
240   else if (global.randRoom(1, 12) == 1) ctx = 'oRubyBig';
241   else if (global.randRoom(1, 6) == 1) ctx = 'oSpider';
242   else if (global.randRoom(1, 12) == 1) { if (global.randRoom(1, 50) == 1) ctx = 'oCobra'; else ctx = 'oSnake'; }
243   else if (global.randRoom(1, 100) == 1) ctx = 'oAlien';
244   else if (global.randRoom(1, 300) == 1) ctx = 'oBlob';
246   /* in the original
247   switch (global.randRoom(0, 2)) {
248     case 0: ctx = 'oEmeraldBig'; break;
249     case 1: ctx = 'oSapphireBig'; break;
250     case 2: ctx = 'oRubyBig'; break;
251   }
252   */
254   ctx = 'oSnake';
256   return ctx;
260 final MapObject scrLevGenCreateJar (int x, int y) {
261   auto obj = MakeMapObject(x, y, 'oJar');
262   //MapItem(obj).contents = scrLevGenCreateJarContents();
263   return obj;
267 // ////////////////////////////////////////////////////////////////////////// //
268 final bool cbIsGoldIdol (MapObject o) { return (o isa ItemGoldIdol); }
269 final bool cbIsGiantSpider (MapObject o) { return (o isa EnemyGiantSpider); }
270 final bool cbIsChestObject (MapObject o) { return (o isa ItemChest); }
272 final bool cbIsTreasureTile (MapTile t) { return !!t.gem; } //K8:FIXME: only real treasures?
273 final bool cbIsBadTile (MapTile t) { return (t.spikes || t.enter || t.exit); }
274 final bool cbIsBlockTile (MapTile t) { return (t.objType == 'oBlock'); }
275 final bool cbIsLiquidTile (MapTile t) { return (t.water || t.lava); }
278 // Generates crates, chests, gold, gems, and bones
279 void scrTreasureGen (int x, int y, optional int bonesChance) {
280   // argument0: bones
282   // alcove
283   if (calcNearestEnterDist(x+8, y+8) < 32) return;
284   if (calcNearestExitDist(x+8, y+8) < 32) return;
285   if (calcNearestObjectDist(x+8, y+8, &cbIsGoldIdol) < 64) return;
287   bool colStuff =
288     isSolidAtPoint(x, y-16) ||
289     checkTileAtPoint(x, y-1, &cbIsTreasureTile) ||
290     isObjectAtTilePix(x, y-8, &cbIsChestObject) || //<-collision_point(x, y-8, oChest, 0, 0) &&
291     checkTileAtPoint(x, y-8, &cbIsBadTile);
293   if (!colStuff) {
294     if (global.randRoom(1, 100) == 1) { MakeMapObject(x+8, y-4, 'oRock'); return; }
295     if (global.randRoom(1, 40) == 1) { scrLevGenCreateJar(x+8, y-6); return; }
296   }
298   // alcove
299   if (!colStuff &&
300       isSolidAtPoint(x, y-32) &&
301       (isSolidAtPoint(x-16, y-16) ||
302        isSolidAtPoint(x+16, y-16) ||
303        checkTileAtPoint(x-16, y-16, &cbIsBlockTile) ||
304        checkTileAtPoint(x+16, y-16, &cbIsBlockTile)))
305   {
306     int n = 60;
307     if (calcNearestObjectDist(x+8, y+8, &cbIsGiantSpider) < 100) n = 5;
308     if (global.levelType != 2 && global.randRoom(1, n) == 1) {
309       MakeMapObject(x, y-16, 'oWeb');
310     } else if (global.genUdjatEye && !global.LockedChest) {
311       if (global.randRoom(1, global.lockedChestChance) == 1) {
312         MakeMapObject(x+8, y-16, 'oLockedChest');
313         global.LockedChest = true;
314         writeln("*** GENERATED LOCKED CHEST");
315       } else {
316         global.lockedChestChance -= 1;
317       }
318     } else if (global.randRoom(1, 10) == 1) {
319       scrLevGenCreateCrate(x+8, y-8);
320     } else if (global.randRoom(1, 15) == 1) {
321       scrLevGenCreateChest(x+8, y-8);
322     } else if (!global.damsel && global.randRoom(1, 8) == 1 && !checkTileAtPoint(x+8, y-8, &cbIsLiquidTile)) {
323       auto obj = MakeMapObject(x+8, y-8, 'oDamsel');
324       if (obj) global.damsel = true;
325     } else if (global.randRoom(1, 40-2*global.currLevel) <= 1+bonesChance) {
326       //writeln("=== BONES ===");
327       if (global.randRoom(1, 8) == 1) {
328         MakeMapObject(x, y-16, 'oFakeBones');
329       } else {
330         MakeMapObject(x, y-16, 'oBones');
331         MakeMapObject(x+12, y-4, 'oSkull');
332       }
333     }
334     else if (global.randRoom(1, 3) == 1) MakeMapObject(x+8, y-4, 'oGoldBar');
335     else if (global.randRoom(1, 6) == 1) MakeMapObject(x+8, y-8, 'oGoldBars');
336     else if (global.randRoom(1, 6) == 1) MakeMapObject(x+8, y-4, 'oEmeraldBig');
337     else if (global.randRoom(1, 8) == 1) MakeMapObject(x+8, y-4, 'oSapphireBig');
338     else if (global.randRoom(1, 10) == 1) MakeMapObject(x+8, y-4, 'oRubyBig');
339     //else if (global.bizarre && randRoom(1, 6) == 1) {obj = MakeMapObject(x+8, y-8, 'oAntidote'); obj.cost = 0; obj.forSale = false} // in the original
340   } // tunnel
341   else if (!colStuff && isSolidAtPoint(x-16, y-16) && isSolidAtPoint(x+16, y-16)) {
342     int n = 60;
343     if (calcNearestObjectDist(x+8, y+8, &cbIsGiantSpider) < 100) n = 10;
344          if (global.levelType != 2 && global.randRoom(1, n) == 1) MakeMapObject(x, y-16, 'oWeb');
345     else if (global.randRoom(1, 4) == 1) MakeMapObject(x+8, y-4, 'oGoldBar');
346     else if (global.randRoom(1, 8) == 1) MakeMapObject(x+8, y-8, 'oGoldBars');
347     else if (global.randRoom(1, 80-global.currLevel) <= 1+bonesChance) {
348       if (global.randRoom(1, 8) == 1) {
349         MakeMapObject(x, y-16, 'oFakeBones');
350       } else {
351         MakeMapObject(x, y-16, 'oBones');
352         MakeMapObject(x+12, y-4, 'oSkull');
353       }
354     }
355     else if (global.randRoom(1, 8) == 1) MakeMapObject(x+8, y-4, 'oEmeraldBig');
356     else if (global.randRoom(1, 9) == 1) MakeMapObject(x+8, y-4, 'oSapphireBig');
357     else if (global.randRoom(1, 10) == 1) MakeMapObject(x+8, y-4, 'oRubyBig');
358     //else if (global.bizarre && randRoom(1, 10) == 1) {obj = MakeMapObject(x+8, y-8, 'oAntidote'); obj.cost = 0; obj.forSale = false} // in the original
359   } // normal
360   else if (!isSolidAtPoint(x, y-16) &&
361            isObjectAtTilePix(x, y-8, &cbIsChestObject) && //<-collision_point(x, y-8, oChest, 0, 0) &&
362            !checkTileAtPoint(x, y-8, &cbIsBadTile))
363   {
364          if (global.randRoom(1, 40) == 1) MakeMapObject(x+8, y-4, 'oGoldBar');
365     else if (global.randRoom(1, 50) == 1) MakeMapObject(x+8, y-8, 'oGoldBars');
366     else if (global.randRoom(1, 140-2*global.currLevel) <= 1+bonesChance) {
367       if (global.randRoom(1, 8) == 1) {
368         MakeMapObject(x, y-16, 'oFakeBones');
369       } else {
370         MakeMapObject(x, y-16, 'oBones');
371         MakeMapObject(x+12, y-4, 'oSkull');
372       }
373     }
374   }
378 // ////////////////////////////////////////////////////////////////////////// //
379 name scrGenGetFrogType () {
380   if (global.config.optEnemyVariations) {
381     int totdeath789 = stats.getDeathCountOnLevel(7)+stats.getDeathCountOnLevel(8)+stats.getDeathCountOnLevel(9);
382     if (totdeath789 < 22) {
383       if (global.randOther(0, 100) >= 99-(global.currLevel-4)*8) return 'oGreenFrog';
384       return 'oFrog';
385     }
386     if (totdeath789 < 32) {
387       if (global.randOther(0, 100) >= 85-(global.currLevel-4)*8) return 'oGreenFrog';
388       return 'oFrog';
389     }
390     if (totdeath789 < 42) {
391       if (global.randOther(0, 100) >= 75-(global.currLevel-4)*8) return 'oGreenFrog';
392       return 'oFrog';
393     }
394     if (totdeath789 < 52) {
395       if (global.randOther(0, 100) >= 65-(global.currLevel-4)*8) return 'oGreenFrog';
396       return 'oFrog';
397     }
398     if (totdeath789 < 62) {
399       if (global.randOther(0, 100) >= 55-(global.currLevel-4)*8) return 'oGreenFrog';
400       return 'oFrog';
401     }
402     if (global.randOther(0, 100) >= 50-(global.currLevel-4)*8) return 'oGreenFrog';
403   }
404   return 'oFrog';
408 // ////////////////////////////////////////////////////////////////////////// //
410 private final bool scrGenEntitiesInMinesCB (int tileX, int tileY, MapTile t) {
411   if (!isInShop(tileX, tileY) && tileY > 1) {
412     if (t.objType != 'Altar') {
413       scrTreasureGen(tileX*16, tileY*16);
414     }
415     int roomX, roomY;
416     tileXY2roomXY(tileX, tileY-1, roomX, roomY); //k8: why -1?
417     // enemies
418     if (roomX != startRoomX || roomY != startRoomY) {
419       if (tileY < GameLevel::NormalTilesHeight-4 &&
420           !checkTilesInRect(tileX*16, (tileY+1)*16, 17, 33, &cbCollisionAnySolidOrLiquid) &&
421           !isObjectAtPoint(tileX*16+8, (tileY+1)*16+8))
422       {
423         if (global.genGiantSpider && !global.giantSpider &&
424             global.randRoom(1, trunc(ceil(40.0/global.config.enemyMult))) == 1 &&
425             !checkTilesInRect((tileX+1)*16, (tileY+1)*16, 17, 33, &cbCollisionAnySolid/*k8:???OrLiquid*/))
426         {
427           MakeMapObject(tileX*16, (tileY+1)*16, 'oGiantSpiderHang');
428           global.giantSpider = true;
429         }
430         else if (global.darkLevel && global.randRoom(1, 60) == 1) MakeMapTile(tileX, tileY+1, 'oLamp');
431         else if (global.darkLevel && global.randRoom(1, 40) == 1) MakeMapObject(tileX*16, (tileY+1)*16, 'oScarab');
432         else if (global.randRoom(1, trunc(ceil(60.0/global.config.enemyMult))) == 1) MakeMapObject(tileX*16, (tileY+1)*16, 'oBat');
433         else if (global.randRoom(1, trunc(ceil(80.0/global.config.enemyMult))) == 1) MakeMapObject(tileX*16, (tileY+1)*16, scrGenGetSpiderType());
434       }
435       if (global.giantSpider && global.config.enemyMult >= 2) {
436         if (global.randRoom(1, trunc(ceil(2400.0/global.config.enemyMult))) == 1) {
437           global.genGiantSpider = true;
438           global.giantSpider = false;
439         }
440       }
441       if (!checkTileAtPoint(tileX*16, (tileY-1)*16, &cbCollisionAnySolid/*k8:???OrLiquid*/)) {
442         if (global.randRoom(1, trunc(ceil(60.0/global.config.enemyMult))) == 1) {
443           MakeMapObject(tileX*16, (tileY-1)*16, scrGenGetSnakeType());
444         } else if (global.randRoom(1, trunc(ceil(800.0/global.config.enemyMult))) == 1) {
445           MakeMapObject(tileX*16, (tileY-1)*16, 'oCaveman');
446         }
447       }
448     }
449   }
450   // `false` means "continue"
451   return false;
456 // ////////////////////////////////////////////////////////////////////////// //
457 final bool isTreasureObjectCB (MapObject o) { return o.isTreasure; }
458 final bool isChestObjectCB (MapObject o) { return (o isa ItemOpenableContainer); } // not only chest, but a crate too