black market fixes
[k8vacspelynky.git] / packages / Generator / EntityGenJungle.vc
blob615efe12626ae4d10d194eae8ce0de7fdd953b70
1 /**********************************************************************************
2  * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3  * Copyright (c) 2010, Moloch
4  * Copyright (c) 2018, Ketmar Dark
5  *
6  * This file is part of Spelunky.
7  *
8  * You can redistribute and/or modify Spelunky, including its source code, under
9  * the terms of the Spelunky User License.
10  *
11  * Spelunky is distributed in the hope that it will be entertaining and useful,
12  * but WITHOUT WARRANTY.  Please see the Spelunky User License for more details.
13  *
14  * The Spelunky User License should be available in "Game Information", which
15  * can be found in the Resource Explorer, or as an external file called COPYING.
16  * If not, please obtain a new copy of Spelunky from <http://spelunkyworld.com/>
17  *
18  **********************************************************************************/
19 class EntityGenJungle : EntityGen transient;
21 transient bool ashGraveGenerated;
24 // Note: depth of trees, statues is 9005
25 override void generateEntities () {
26   global = levgen.global;
27   level = levgen.level;
29   // level type 1 (jungle)
30   if (global.cemetary) {
31     ashGraveGenerated = false;
32     level.forEachSolidTileOnGrid(delegate bool (int tileX, int tileY, MapTile t) {
33       if (t.objType != 'oLush') return false;
34       // generate graves
35       int x = tileX*16, y = tileY*16;
36       if (level.checkTileAtPoint(x, y-16, delegate bool (MapTile t) { return (t.solid || t.enter || t.exit); })) return false;
37       if (!(x != 160 && x != 176 && x != 320 && x != 336 && x != 480 && x != 496)) return false;
38       if (global.randRoom(1, 20) != 1) return false;
39       MapTile obj;
40       if (!ashGraveGenerated && global.randRoom(1, 30) == 1) {
41         obj = level.MakeMapTile(tileX, tileY-1, 'oAshGrave');
42         ashGraveGenerated = true;
43       } else {
44         obj = level.MakeMapTile(tileX, tileY-1, 'oGrave');
45       }
46       return false;
47     });
48   }
50   level.forEachSolidTileOnGrid(delegate bool (int tileX, int tileY, MapTile t) {
51     auto rg = levgen.getRoomGenForTileAt(tileX, tileY, allowBorders:false);
52     if (rg) rg.genEntityAt(tileX, tileY);
53     return false;
54   });
56   // force market entrance
57   if (global.genMarketEntrance && !global.madeMarketEntrance) {
58     level.forEachSolidTileOnGrid(delegate bool (int tileX, int tileY, MapTile t) {
59       if (tileY <= 2 || !t.solid || !t.isInstanceAlive) return false;
60       int x = tileX*16, y = tileY*16;
61       auto st = level.isSolidAtPoint(x, y-16);
62       if (!st) return false;
63       if (st.tree || st.altar) return false;
64       level.MakeMapTile(tileX, tileY-1, 'oXMarket');
65       writeln("  (forced market entrance)");
66       t.invincible = true;
67       global.madeMarketEntrance = true;
68       return true;
69     });
70   }
72   // monkeys
73   level.forEachTile(delegate bool (MapTile t) {
74     if (t.isInstanceAlive && t.objType == 'oVine') {
75       if (global.randRoom(1, trunc(ceil(15.0/global.config.enemyMult))) == 1) level.MakeMapObject(t.ix, t.iy, 'oMonkey');
76     }
77     return false;
78   });
80   // piranhas
81   level.forEachTile(delegate bool (MapTile t) {
82     if (t.isInstanceAlive && t.water) {
83       if (global.randRoom(1, trunc(ceil(30.0/ceil(global.config.enemyMult/2.0)))) == 1) {
84         level.MakeMapObject(t.ix+4, t.iy+4, (global.cemetary ? 'oDeadFish' : 'oPiranha'));
85       }
86     }
87     return false;
88   });
92 defaultproperties {
93   rgLevelType = 1;
94   rgBizarre = false;