v0.7.0: added runestones to drop system, added a runestone secret room

This commit is contained in:
Evan Debenham 2018-06-18 21:56:20 -04:00
parent a2904557db
commit 9582beea21
6 changed files with 100 additions and 8 deletions

View File

@ -196,12 +196,12 @@ public class Generator {
FOOD ( 0, Food.class ),
POTION ( 20, Potion.class ),
SEED ( 0, Plant.Seed.class ),
SEED ( 0, Plant.Seed.class ), //dropped by grass
SCROLL ( 20, Scroll.class ),
STONE ( 0, Runestone.class),
STONE ( 5, Runestone.class),
GOLD ( 20, Gold.class );
GOLD ( 15, Gold.class );
public Class<?>[] classes;
public float[] probs;
@ -278,7 +278,7 @@ public class Generator {
SCROLL.probs = new float[]{ 0, 6, 4, 3, 3, 3, 2, 2, 2, 2, 2, 1 };
STONE.classes = new Class<?>[]{
StoneOfEnchantment.class, //1 is garunteed to drop on floors 6-19
StoneOfEnchantment.class, //1 is guaranteed to drop on floors 6-19
StoneOfAugmentation.class, //1 is sold in each shop
StoneOfIntuition.class, //1 additional stone is also dropped on floors 1-3
StoneOfAggression.class,

View File

@ -390,6 +390,11 @@ public abstract class RegularLevel extends Level {
}
//FIXME pit rooms shouldn't be problematic enough to warrant this
public boolean hasPitRoom(){
return randomRoom(PitRoom.class) != null;
}
protected Room randomRoom( Class<?extends Room> type ) {
Random.shuffle( rooms );
for (Room r : rooms) {

View File

@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.StoneOfEnchantment;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@ -63,6 +64,17 @@ public class SecretRunestoneRoom extends SecretRoom {
level.addItemToSpawn(new PotionOfLiquidFlame());
int dropPos;
do{
dropPos = level.pointToCell(random());
} while (level.map[dropPos] != Terrain.EMPTY);
level.drop( Generator.random(Generator.Category.STONE), dropPos);
do{
dropPos = level.pointToCell(random());
} while (level.map[dropPos] != Terrain.EMPTY && level.heaps.get(dropPos) != null);
level.drop( Generator.random(Generator.Category.STONE), dropPos);
do{
dropPos = level.pointToCell(random());
} while (level.map[dropPos] != Terrain.EMPTY_SP);

View File

@ -25,8 +25,10 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
@ -58,7 +60,7 @@ public class LaboratoryRoom extends SpecialRoom {
alchemy.seed( level, pot.x + level.width() * pot.y, chapter*10 + Random.IntRange(0, 20) );
level.blobs.put( Alchemy.class, alchemy );
int n = Random.IntRange( 1, 2 );
int n = Random.IntRange( 2, 3 );
for (int i=0; i < n; i++) {
int pos;
do {
@ -69,14 +71,20 @@ public class LaboratoryRoom extends SpecialRoom {
level.drop( prize( level ), pos );
}
entrance.set( Door.Type.REGULAR );
if (level instanceof RegularLevel && ((RegularLevel)level).hasPitRoom()){
entrance.set( Door.Type.REGULAR );
} else {
entrance.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}
}
private static Item prize( Level level ) {
Item prize = level.findPrizeItem( Potion.class );
if (prize == null)
prize = Generator.random( Generator.Category.POTION );
prize = Generator.random( Random.oneOf( Generator.Category.POTION, Generator.Category.STONE ));
return prize;
}

View File

@ -0,0 +1,66 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 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.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey;
import com.shatteredpixel.shatteredpixeldungeon.items.stones.Runestone;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
public class RunestoneRoom extends SpecialRoom {
@Override
public void paint( Level level) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.CHASM );
Painter.drawInside( level, this, entrance(), 2, Terrain.EMPTY_SP);
Painter.fill( level, this, 2, Terrain.EMPTY );
int n = Random.NormalIntRange(2, 4);
int dropPos;
for (int i = 0; i < n; i++) {
do {
dropPos = level.pointToCell(random());
} while (level.map[dropPos] != Terrain.EMPTY);
level.drop(prize(level), dropPos);
}
entrance().set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}
private static Item prize( Level level ) {
Item prize = level.findPrizeItem( Runestone.class );
if (prize == null)
prize = Generator.random( Generator.Category.STONE );
return prize;
}
}

View File

@ -59,7 +59,7 @@ public class SpecialRoom extends Room {
private static final ArrayList<Class<? extends SpecialRoom>> ALL_SPEC = new ArrayList<>( Arrays.asList(
WeakFloorRoom.class, MagicWellRoom.class, CryptRoom.class, PoolRoom.class, GardenRoom.class, LibraryRoom.class, ArmoryRoom.class,
TreasuryRoom.class, TrapsRoom.class, StorageRoom.class, StatueRoom.class, VaultRoom.class
TreasuryRoom.class, TrapsRoom.class, StorageRoom.class, StatueRoom.class, VaultRoom.class, RunestoneRoom.class
) );
public static ArrayList<Class<? extends Room>> runSpecials = new ArrayList<>();
@ -101,6 +101,7 @@ public class SpecialRoom extends Room {
floorSpecials.remove( ArmoryRoom.class );
floorSpecials.remove( CryptRoom.class );
floorSpecials.remove( LibraryRoom.class );
floorSpecials.remove( RunestoneRoom.class );
floorSpecials.remove( StatueRoom.class );
floorSpecials.remove( TreasuryRoom.class );
floorSpecials.remove( VaultRoom.class );