v0.6.2: implemented five more secret rooms

This commit is contained in:
Evan Debenham 2017-10-14 03:35:57 -04:00
parent bf30704891
commit 7e1dcec42f
9 changed files with 424 additions and 12 deletions

View File

@ -85,7 +85,7 @@ public class Maze {
y += mov[1]; y += mov[1];
maze[x][y] = FILLED; maze[x][y] = FILLED;
moves++; moves++;
} while (Random.Int(moves+1) == 0 && checkValidMove(maze, x, y, mov)); } while (Random.Int(moves) == 0 && checkValidMove(maze, x, y, mov));
} }

View File

@ -0,0 +1,59 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
public class SecretArtilleryRoom extends SecretRoom {
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY_SP);
Painter.set(level, center(), Terrain.STATUE_SP);
for (int i = 0; i < 4; i++){
int itemPos;
do{
itemPos = level.pointToCell(random());
} while ( level.map[itemPos] != Terrain.EMPTY_SP
|| level.heaps.get(itemPos) != null);
Item item;
do{
item = Generator.randomWeapon();
} while (!(item instanceof MissileWeapon));
level.drop(item, itemPos);
}
entrance().set(Door.Type.HIDDEN);
}
}

View File

@ -0,0 +1,94 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.GoldenKey;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLevitation;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
public class SecretChestChasmRoom extends SecretRoom {
@Override
public int minWidth() {
return 8;
}
@Override
public int minHeight() {
return 8;
}
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.CHASM);
Point p = new Point(left+1, top+1);
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
p.x = right-1;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
p.y = bottom-1;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
p.x = left+1;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(new GoldenKey(Dungeon.depth), level.pointToCell(p));
p = new Point(left+3, top+3);
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(Generator.random(Generator.Category.SCROLL),
level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
p.x = right-3;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(Generator.random(Generator.Category.POTION),
level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
p.y = bottom-3;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(Generator.random(Generator.Category.SCROLL),
level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
p.x = left+3;
Painter.set(level, p, Terrain.EMPTY_SP);
level.drop(Generator.random(Generator.Category.POTION),
level.pointToCell(p)).type = Heap.Type.LOCKED_CHEST;
level.addItemToSpawn(new PotionOfLevitation());
entrance().set(Door.Type.HIDDEN);
}
}

View File

@ -0,0 +1,89 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.DisintegrationTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonDartTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.RockfallTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class SecretHoardRoom extends SecretRoom {
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY);
Class<? extends Trap> trapClass;
if (Random.Int(2) == 0){
trapClass = RockfallTrap.class;
} else if (Dungeon.depth >= 10){
trapClass = DisintegrationTrap.class;
} else {
trapClass = PoisonDartTrap.class;
}
int goldPos;
//half of the internal space of the room
int totalGold = ((width()-2)*(height()-2))/2;
//no matter how much gold it drops, roughly equals 8 gold stacks.
float goldRatio = 8 / (float)totalGold;
for (int i = 0; i < totalGold; i++) {
do {
goldPos = level.pointToCell(random());
} while (level.heaps.get(goldPos) != null);
Item gold = new Gold().random();
gold.quantity(Math.round(gold.quantity() * goldRatio));
level.drop(gold, goldPos);
}
for (Point p : getPoints()){
if (Random.Int(2) == 0 && level.map[level.pointToCell(p)] == Terrain.EMPTY){
try {
level.setTrap(trapClass.newInstance().reveal(), level.pointToCell(p));
Painter.set(level, p, Terrain.TRAP);
} catch (Exception e) {
ShatteredPixelDungeon.reportException(e);
}
}
}
entrance().set(Door.Type.HIDDEN);
}
@Override
public boolean canPlaceTrap(Point p) {
return false;
}
}

View File

@ -0,0 +1,118 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.weapon.missiles.MissileWeapon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Maze;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class SecretMazeRoom extends SecretRoom {
@Override
public int minWidth() {
return 14;
}
@Override
public int minHeight() {
return 14;
}
@Override
public int maxWidth() {
return 18;
}
@Override
public int maxHeight() {
return 18;
}
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY);
//true = space, false = wall
boolean[][] maze = Maze.generate(this);
boolean[] passable = new boolean[width()*height()];
Painter.fill(level, this, 1, Terrain.EMPTY);
for (int x = 0; x < maze.length; x++) {
for (int y = 0; y < maze[0].length; y++) {
if (maze[x][y] == Maze.FILLED) {
Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL);
}
passable[x + width()*y] = maze[x][y] == Maze.EMPTY;
}
}
PathFinder.setMapSize(width(), height());
Point entrance = entrance();
int entrancePos = (entrance.x - left) + width()*(entrance.y - top);
PathFinder.buildDistanceMap( entrancePos, passable );
int bestDist = 0;
Point bestDistP = new Point();
for (int i = 0; i < PathFinder.distance.length; i++){
if (PathFinder.distance[i] != Integer.MAX_VALUE
&& PathFinder.distance[i] > bestDist){
bestDist = PathFinder.distance[i];
bestDistP.x = (i % width()) + left;
bestDistP.y = (i / width()) + top;
}
}
Item prize;
//1 floor set higher in probability, never cursed
do {
if (Random.Int(2) == 0) {
prize = Generator.randomWeapon((Dungeon.depth / 5) + 1);
} else {
prize = Generator.randomArmor((Dungeon.depth / 5) + 1);
}
} while (prize.cursed || prize instanceof MissileWeapon);
//33% chance for an extra update.
if (Random.Int(3) == 0){
prize.upgrade();
}
level.drop(prize, level.pointToCell(bestDistP)).type = Heap.Type.CHEST;
PathFinder.setMapSize(level.width(), level.height());
entrance().set(Door.Type.HIDDEN);
}
}

View File

@ -38,7 +38,8 @@ public abstract class SecretRoom extends SpecialRoom {
private static final ArrayList<Class<? extends SecretRoom>> ALL_SECRETS = new ArrayList<>( Arrays.asList( private static final ArrayList<Class<? extends SecretRoom>> ALL_SECRETS = new ArrayList<>( Arrays.asList(
SecretGardenRoom.class, SecretLaboratoryRoom.class, SecretLibraryRoom.class, SecretGardenRoom.class, SecretLaboratoryRoom.class, SecretLibraryRoom.class,
SecretLarderRoom.class, SecretWellRoom.class, SecretRunestoneRoom.class, SecretLarderRoom.class, SecretWellRoom.class, SecretRunestoneRoom.class,
SecretHoneypotRoom.class)); SecretArtilleryRoom.class, SecretChestChasmRoom.class, SecretHoneypotRoom.class,
SecretHoardRoom.class, SecretMazeRoom.class, SecretSummoningRoom.class));
public static ArrayList<Class<? extends SecretRoom>> runSecrets = new ArrayList<>(); public static ArrayList<Class<? extends SecretRoom>> runSecrets = new ArrayList<>();

View File

@ -22,13 +22,11 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret; package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame; import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition; import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfIntuition;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point; import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class SecretRunestoneRoom extends SecretRoom { public class SecretRunestoneRoom extends SecretRoom {
@ -64,14 +62,11 @@ public class SecretRunestoneRoom extends SecretRoom {
level.addItemToSpawn(new PotionOfLiquidFlame()); level.addItemToSpawn(new PotionOfLiquidFlame());
int runeStones = Random.NormalIntRange(2, 4); int dropPos;
for (int i = 0; i <runeStones; i++){ do{
int dropPos; dropPos = level.pointToCell(random());
do{ } while (level.map[dropPos] != Terrain.EMPTY_SP);
dropPos = level.pointToCell(random()); level.drop( new StoneOfIntuition(), dropPos);
} while (level.map[dropPos] != Terrain.EMPTY_SP);
level.drop( i == 0? new StoneOfEnchantment() : new StoneOfIntuition(), dropPos);
}
entrance.set(Door.Type.HIDDEN); entrance.set(Door.Type.HIDDEN);
} }

View File

@ -0,0 +1,54 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2017 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap;
import com.watabou.utils.Point;
public class SecretSummoningRoom extends SecretRoom {
@Override
public void paint(Level level) {
super.paint(level);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.SECRET_TRAP);
Point center = center();
level.drop(Generator.random(), level.pointToCell(center)).type = Heap.Type.SKELETON;
for (Point p : getPoints()){
int cell = level.pointToCell(p);
if (level.map[cell] == Terrain.SECRET_TRAP){
level.setTrap(new SummoningTrap().hide(), cell);
}
}
entrance().set(Door.Type.HIDDEN);
}
}

View File

@ -86,6 +86,8 @@ public class SummoningTrap extends Trap {
//important to process the visuals and pressing of cells last, so spawned mobs have a chance to occupy cells first //important to process the visuals and pressing of cells last, so spawned mobs have a chance to occupy cells first
for (Mob mob : mobs){ for (Mob mob : mobs){
ScrollOfTeleportation.appear(mob, mob.pos); ScrollOfTeleportation.appear(mob, mob.pos);
//so hidden traps are triggered as well
Dungeon.level.press(mob.pos, mob);
} }
} }