v1.2.0: roughly implemented toxic gas rooms

This commit is contained in:
Evan Debenham 2022-03-10 12:20:06 -05:00
parent 2bb263879d
commit dba3773ec3
4 changed files with 150 additions and 6 deletions

View File

@ -14,12 +14,15 @@ levels.rooms.special.magicalfireroom$eternalfire.desc=A wall of dense magical fi
levels.rooms.special.massgraveroom$bones.name=Mass grave levels.rooms.special.massgraveroom$bones.name=Mass grave
levels.rooms.special.massgraveroom$bones.desc=Bones litter the floor, what happened here? levels.rooms.special.massgraveroom$bones.desc=Bones litter the floor, what happened here?
levels.rooms.standard.ritualsiteroom$ritualmarker.name=Ritual marker levels.rooms.special.toxicgasroom$toxicvent.name=toxic vent
levels.rooms.standard.ritualsiteroom$ritualmarker.desc=A painted marker for some dark ritual. Candles are usually placed on the four corners. levels.rooms.special.toxicgasroom$toxicvent.desc=A careless adventurer must have triggered this trap ages ago. Despite its inactive state, it's still spewing toxic gas into the room and shows no signs of stopping. You'll need some way to prevent damage from the gas if you want to explore this room.
levels.rooms.special.weakfloorroom$hiddenwell.name=Distant well levels.rooms.special.weakfloorroom$hiddenwell.name=Distant well
levels.rooms.special.weakfloorroom$hiddenwell.desc=You can just make out a well in the depths below, perhaps there is something down there? levels.rooms.special.weakfloorroom$hiddenwell.desc=You can just make out a well in the depths below, perhaps there is something down there?
levels.rooms.standard.ritualsiteroom$ritualmarker.name=Ritual marker
levels.rooms.standard.ritualsiteroom$ritualmarker.desc=A painted marker for some dark ritual. Candles are usually placed on the four corners.
###traps ###traps
levels.traps.alarmtrap.name=alarm trap levels.traps.alarmtrap.name=alarm trap

View File

@ -60,6 +60,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap;
import com.watabou.utils.Bundle; import com.watabou.utils.Bundle;
import com.watabou.utils.Point;
import com.watabou.utils.Random; import com.watabou.utils.Random;
import java.util.ArrayList; import java.util.ArrayList;
@ -299,10 +300,13 @@ public abstract class RegularLevel extends Level {
continue; continue;
} }
cell = pointToCell(room.random()); ArrayList<Point> points = room.charWanderablePoints(this);
if (!points.isEmpty()){
cell = pointToCell(Random.element(points));
if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) { if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) {
return cell; return cell;
} }
}
} }
} }

View File

@ -345,6 +345,23 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable {
return points; return points;
} }
//whether or not a character can wander here
public boolean canCharacterWander(Point p, Level l) {
return inside(p);
}
public final ArrayList<Point> charWanderablePoints(Level l){
ArrayList<Point> points = new ArrayList<>();
for (int i = left; i <= right; i++) {
for (int j = top; j <= bottom; j++) {
Point p = new Point(i, j);
if (canCharacterWander(p, l)) points.add(p);
}
}
return points;
}
// **** Graph.Node interface **** // **** Graph.Node interface ****
@Override @Override

View File

@ -0,0 +1,120 @@
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2022 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.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfPurity;
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.Trap;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.Point;
public class ToxicGasRoom extends SpecialRoom {
@Override
public int minWidth() { return 7; }
public int minHeight() { return 7; }
@Override
public void paint(Level level) {
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
for (Point p : getPoints()){
int cell = level.pointToCell(p);
if (level.map[cell] == Terrain.EMPTY) {
Blob.seed(cell, 3, ToxicGasSeed.class, level);
}
}
int traps = Math.min(width()-2, height()-2);
for (int i = 0; i < traps; i++){
int cell;
do {
cell = level.pointToCell(random(1));
} while (level.map[cell] == Terrain.INACTIVE_TRAP);
level.setTrap(new ToxicVent().reveal(), cell);
Painter.set(level, cell, Terrain.INACTIVE_TRAP);
}
//TODO loot!
//perhaps 2-3 items around the center?
level.addItemToSpawn(new PotionOfPurity());
entrance().set( Door.Type.UNLOCKED );
}
@Override
public boolean canCharacterWander(Point p, Level l) {
return false;
}
public static class ToxicGasSeed extends Blob {
@Override
protected void evolve() {
int cell;
ToxicGas gas = (ToxicGas) Dungeon.level.blobs.get(ToxicGas.class);
for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) {
cell = j + i* Dungeon.level.width();
if (Dungeon.level.insideMap(cell)) {
off[cell] = cur[cell];
volume += off[cell];
if (gas == null || gas.volume == 0){
GameScene.add(Blob.seed(cell, off[cell], ToxicGas.class));
} else if (gas.cur[cell] < off[cell]){
GameScene.add(Blob.seed(cell, off[cell] - gas.cur[cell], ToxicGas.class));
}
}
}
}
}
}
public static class ToxicVent extends Trap {
{
color = BLACK;
shape = GRILL;
canBeHidden = false;
active = false;
}
@Override
public void activate() {
//does nothing, this trap is just decoration and is always deactivated
}
}
}