v0.8.0: adjusted levelgen so that it is unaffected by held items and meta progression

This commit is contained in:
Evan Debenham 2019-11-07 11:17:48 -05:00
parent fd38cfc155
commit 1f033200f6
4 changed files with 51 additions and 34 deletions

View File

@ -205,20 +205,6 @@ public abstract class Level implements Bundlable {
if ( Dungeon.depth == ((Dungeon.seed % 3) + 1)){ if ( Dungeon.depth == ((Dungeon.seed % 3) + 1)){
addItemToSpawn( new StoneOfIntuition() ); addItemToSpawn( new StoneOfIntuition() );
} }
DriedRose rose = Dungeon.hero.belongings.getItem( DriedRose.class );
if (rose != null && rose.isIdentified() && !rose.cursed){
//aim to drop 1 petal every 2 floors
int petalsNeeded = (int) Math.ceil((float)((Dungeon.depth / 2) - rose.droppedPetals) / 3);
for (int i=1; i <= petalsNeeded; i++) {
//the player may miss a single petal and still max their rose.
if (rose.droppedPetals < 11) {
addItemToSpawn(new DriedRose.Petal());
rose.droppedPetals++;
}
}
}
if (Dungeon.depth > 1) { if (Dungeon.depth > 1) {
switch (Random.Int( 10 )) { switch (Random.Int( 10 )) {

View File

@ -29,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.Artifact;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage; import com.shatteredpixel.shatteredpixeldungeon.items.journal.GuidePage;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey; import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
import com.shatteredpixel.shatteredpixeldungeon.journal.Document; import com.shatteredpixel.shatteredpixeldungeon.journal.Document;
@ -328,7 +329,10 @@ public abstract class RegularLevel extends Level {
losBlocking[cell] = false; losBlocking[cell] = false;
} }
} }
//use a separate generator for this to prevent held items and meta progress from affecting levelgen
Random.pushGenerator( Dungeon.seedCurDepth() );
Item item = Bones.get(); Item item = Bones.get();
if (item != null) { if (item != null) {
int cell = randomDropCell(); int cell = randomDropCell();
@ -339,6 +343,26 @@ public abstract class RegularLevel extends Level {
drop( item, cell ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS; drop( item, cell ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
} }
DriedRose rose = Dungeon.hero.belongings.getItem( DriedRose.class );
if (rose != null && rose.isIdentified() && !rose.cursed){
//aim to drop 1 petal every 2 floors
int petalsNeeded = (int) Math.ceil((float)((Dungeon.depth / 2) - rose.droppedPetals) / 3);
for (int i=1; i <= petalsNeeded; i++) {
//the player may miss a single petal and still max their rose.
if (rose.droppedPetals < 11) {
item = new DriedRose.Petal();
int cell = randomDropCell();
drop( item, cell ).type = Heap.Type.HEAP;
if (map[cell] == Terrain.HIGH_GRASS || map[cell] == Terrain.FURROWED_GRASS) {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
rose.droppedPetals++;
}
}
}
//guide pages //guide pages
Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages(); Collection<String> allPages = Document.ADVENTURERS_GUIDE.pages();
ArrayList<String> missingPages = new ArrayList<>(); ArrayList<String> missingPages = new ArrayList<>();
@ -366,6 +390,8 @@ public abstract class RegularLevel extends Level {
drop( p, cell ); drop( p, cell );
} }
Random.popGenerator();
} }
public ArrayList<Room> rooms() { public ArrayList<Room> rooms() {

View File

@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.painters; package com.shatteredpixel.shatteredpixeldungeon.levels.painters;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@ -28,6 +29,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Patch;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.watabou.utils.Graph; import com.watabou.utils.Graph;
import com.watabou.utils.PathFinder; import com.watabou.utils.PathFinder;
@ -187,6 +189,11 @@ public abstract class RegularPainter extends Painter {
d.type = Room.Door.Type.UNLOCKED; d.type = Room.Door.Type.UNLOCKED;
} }
} }
//entrance doors on floor 2 are hidden if the player hasn't beaten the first boss
if (Dungeon.depth == 2 && !Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_1) && r instanceof EntranceRoom){
d.type = Room.Door.Type.HIDDEN;
}
switch (d.type) { switch (d.type) {
case EMPTY: case EMPTY:

View File

@ -58,6 +58,10 @@ public class EntranceRoom extends StandardRoom {
} while (level.findMob(level.entrance) != null); } while (level.findMob(level.entrance) != null);
Painter.set( level, level.entrance, Terrain.ENTRANCE ); Painter.set( level, level.entrance, Terrain.ENTRANCE );
//use a separate generator here so meta progression doesn't affect levelgen
Random.pushGenerator();
//places the first guidebook page on floor 1
if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_INTRO_PAGE)){ if (Dungeon.depth == 1 && !Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_INTRO_PAGE)){
int pos; int pos;
do { do {
@ -70,27 +74,21 @@ public class EntranceRoom extends StandardRoom {
level.drop( p, pos ); level.drop( p, pos );
} }
if (Dungeon.depth == 2){ //places the third guidebook page on floor 2
if (!Badges.isUnlocked(Badges.Badge.BOSS_SLAIN_1)){ if (Dungeon.depth == 2 && !Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_SEARCH_PAGE)){
for (Room.Door door : connected.values()) { int pos;
door.set( Door.Type.HIDDEN ); do {
} //can't be on bottom row of tiles
} pos = level.pointToCell(new Point( Random.IntRange( left + 1, right - 1 ),
Random.IntRange( top + 1, bottom - 2 )));
if (!Document.ADVENTURERS_GUIDE.hasPage(Document.GUIDE_SEARCH_PAGE)){ } while (pos == level.entrance || level.findMob(level.entrance) != null);
int pos; GuidePage p = new GuidePage();
do { p.page(Document.GUIDE_SEARCH_PAGE);
//can't be on bottom row of tiles level.drop( p, pos );
pos = level.pointToCell(new Point( Random.IntRange( left + 1, right - 1 ),
Random.IntRange( top + 1, bottom - 2 )));
} while (pos == level.entrance || level.findMob(level.entrance) != null);
GuidePage p = new GuidePage();
p.page(Document.GUIDE_SEARCH_PAGE);
level.drop( p, pos );
}
} }
Random.popGenerator();
} }
} }