1 /**********************************************************************************
2 * Copyright (c) 2008, 2009 Derek Yu and Mossmouth, LLC
3 * Copyright (c) 2010, Moloch
4 * Copyright (c) 2018, Ketmar Dark
6 * This file is part of Spelunky.
8 * You can redistribute and/or modify Spelunky, including its source code, under
9 * the terms of the Spelunky User License.
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.
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/>
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;
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;
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;
40 if (!ashGraveGenerated && global.randRoom(1, 30) == 1) {
41 /*obj =*/ level.MakeMapTile(tileX, tileY-1, 'oAshGrave');
42 ashGraveGenerated = true;
44 /*obj =*/ level.MakeMapTile(tileX, tileY-1, 'oGrave');
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);
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)");
67 global.madeMarketEntrance = true;
73 level.forEachTile(delegate bool (MapTile t) {
74 if (t.isInstanceAlive && t.objType == 'oVine') {
75 if (global.randRoom(1, trunci(fceil(15.0/global.config.enemyMult))) == 1) level.MakeMapObject(t.ix, t.iy, 'oMonkey');
81 level.forEachTile(delegate bool (MapTile t) {
82 if (t.isInstanceAlive && t.water) {
83 if (global.randRoom(1, trunci(fceil(30.0/fceil(global.config.enemyMult/2.0)))) == 1) {
84 level.MakeMapObject(t.ix+4, t.iy+4, (global.cemetary ? 'oDeadFish' : 'oPiranha'));