diff --git a/core/src/main/assets/messages/levels/levels.properties b/core/src/main/assets/messages/levels/levels.properties index f41e521b8..17ee814bd 100644 --- a/core/src/main/assets/messages/levels/levels.properties +++ b/core/src/main/assets/messages/levels/levels.properties @@ -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.desc=Bones litter the floor, what happened here? -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. +levels.rooms.special.toxicgasroom$toxicvent.name=toxic vent +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.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 levels.traps.alarmtrap.name=alarm trap diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 1f77b6ef1..44a4950ba 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -60,6 +60,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FrostTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap; import com.watabou.utils.Bundle; +import com.watabou.utils.Point; import com.watabou.utils.Random; import java.util.ArrayList; @@ -298,10 +299,13 @@ public abstract class RegularLevel extends Level { if (room == null) { continue; } - - cell = pointToCell(room.random()); - if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) { - return cell; + + ArrayList points = room.charWanderablePoints(this); + if (!points.isEmpty()){ + cell = pointToCell(Random.element(points)); + if (passable[cell] && (!Char.hasProp(ch, Char.Property.LARGE) || openSpace[cell])) { + return cell; + } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java index c631ad8a3..21386d6ed 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java @@ -344,6 +344,23 @@ public abstract class Room extends Rect implements Graph.Node, Bundlable { } return points; } + + //whether or not a character can wander here + public boolean canCharacterWander(Point p, Level l) { + return inside(p); + } + + public final ArrayList charWanderablePoints(Level l){ + ArrayList 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 **** diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ToxicGasRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ToxicGasRoom.java new file mode 100644 index 000000000..bc75caf40 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ToxicGasRoom.java @@ -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 + */ + +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 + } + + } +}