|
|
|
|
@@ -0,0 +1,202 @@
|
|
|
|
|
/*
|
|
|
|
|
* 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.Actor;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blizzard;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Freezing;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfFrost;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
|
|
|
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom;
|
|
|
|
|
import com.watabou.utils.PathFinder;
|
|
|
|
|
import com.watabou.utils.Point;
|
|
|
|
|
import com.watabou.utils.Random;
|
|
|
|
|
import com.watabou.utils.Rect;
|
|
|
|
|
|
|
|
|
|
public class MagicalFireRoom extends SpecialRoom {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void paint(Level level) {
|
|
|
|
|
|
|
|
|
|
Painter.fill( level, this, Terrain.WALL );
|
|
|
|
|
Painter.fill( level, this, 1, Terrain.EMPTY );
|
|
|
|
|
|
|
|
|
|
Door door = entrance();
|
|
|
|
|
door.set( Door.Type.REGULAR );
|
|
|
|
|
|
|
|
|
|
int x = -1;
|
|
|
|
|
int y = -1;
|
|
|
|
|
Point firePos = center();
|
|
|
|
|
Room behindFire = new EmptyRoom();
|
|
|
|
|
|
|
|
|
|
if (door.x == left || door.x == right){
|
|
|
|
|
firePos.y = top+1;
|
|
|
|
|
while (firePos.y != bottom){
|
|
|
|
|
Blob.seed(level.pointToCell(firePos), 1, EternalFire.class, level);
|
|
|
|
|
Painter.set(level, firePos, Terrain.EMPTY_SP);
|
|
|
|
|
firePos.y++;
|
|
|
|
|
}
|
|
|
|
|
if (door.x == left){
|
|
|
|
|
behindFire.set(firePos.x+1, top+1, right-1, bottom-1);
|
|
|
|
|
} else {
|
|
|
|
|
behindFire.set(left+1, top+1, firePos.x-1, bottom-1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
firePos.x = left+1;
|
|
|
|
|
while (firePos.x != right){
|
|
|
|
|
Blob.seed(level.pointToCell(firePos), 1, EternalFire.class, level);
|
|
|
|
|
Painter.set(level, firePos, Terrain.EMPTY_SP);
|
|
|
|
|
firePos.x++;
|
|
|
|
|
}
|
|
|
|
|
if (door.y == top){
|
|
|
|
|
behindFire.set(left+1, firePos.y+1, right-1, bottom-1);
|
|
|
|
|
} else {
|
|
|
|
|
behindFire.set(left+1, top+1, right-1, firePos.y-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Painter.fill(level, behindFire, Terrain.EMPTY_SP);
|
|
|
|
|
|
|
|
|
|
int pos = level.pointToCell(Random.element(behindFire.getPoints()));
|
|
|
|
|
if (Random.Int( 3 ) == 0) {
|
|
|
|
|
level.drop( prize( level ), pos ).type = Heap.Type.CHEST;
|
|
|
|
|
} else {
|
|
|
|
|
level.drop( prize( level ), pos ).type = Heap.Type.CHEST;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
level.addItemToSpawn(new PotionOfFrost());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Item prize(Level level ) {
|
|
|
|
|
|
|
|
|
|
Item prize = level.findPrizeItem();
|
|
|
|
|
|
|
|
|
|
//TODO prize!
|
|
|
|
|
|
|
|
|
|
return prize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canPlaceGrass(Point p) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class EternalFire extends Fire {
|
|
|
|
|
@Override
|
|
|
|
|
protected void evolve() {
|
|
|
|
|
|
|
|
|
|
int cell;
|
|
|
|
|
|
|
|
|
|
Freezing freeze = (Freezing)Dungeon.level.blobs.get( Freezing.class );
|
|
|
|
|
Blizzard bliz = (Blizzard)Dungeon.level.blobs.get( Blizzard.class );
|
|
|
|
|
|
|
|
|
|
Level l = Dungeon.level;
|
|
|
|
|
for (int i = area.left; i < area.right; i++){
|
|
|
|
|
for (int j = area.top; j < area.bottom; j++){
|
|
|
|
|
cell = i + j*l.width();
|
|
|
|
|
if (cur[cell] <= 0) continue;
|
|
|
|
|
|
|
|
|
|
cur[cell]++;
|
|
|
|
|
|
|
|
|
|
//evaporates in the presence of water, frost, or blizzard
|
|
|
|
|
//this blob is not considered interchangeable with fire, so those blobs do not interact with it otherwise
|
|
|
|
|
//potion of purity can cleanse it though
|
|
|
|
|
if (l.water[cell]){
|
|
|
|
|
cur[cell] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (freeze != null && freeze.volume > 0 && freeze.cur[cell] > 0){
|
|
|
|
|
freeze.clear(cell);
|
|
|
|
|
cur[cell] = 0;
|
|
|
|
|
}
|
|
|
|
|
if (bliz != null && bliz.volume > 0 && bliz.cur[cell] > 0){
|
|
|
|
|
bliz.clear(cell);
|
|
|
|
|
cur[cell] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//if the hero is adjacent, set them on fire briefly
|
|
|
|
|
//TODO all chars, but prevent random wandering into the fire?
|
|
|
|
|
if (cur[cell] > 0){
|
|
|
|
|
for (int k : PathFinder.NEIGHBOURS4){
|
|
|
|
|
if (Actor.findChar(cell+k) == Dungeon.hero
|
|
|
|
|
&& !Dungeon.hero.isImmune(getClass())){
|
|
|
|
|
Buff.affect(Dungeon.hero, Burning.class).reignite(Dungeon.hero, 4f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
l.passable[cell] = cur[cell] == 0 && (Terrain.flags[l.map[cell]] & Terrain.PASSABLE) != 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
super.evolve();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void seed(Level level, int cell, int amount) {
|
|
|
|
|
super.seed(level, cell, amount);
|
|
|
|
|
level.passable[cell] = cur[cell] == 0 && (Terrain.flags[level.map[cell]] & Terrain.PASSABLE) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void clear(int cell) {
|
|
|
|
|
super.clear(cell);
|
|
|
|
|
if (cur == null) return;
|
|
|
|
|
Level l = Dungeon.level;
|
|
|
|
|
l.passable[cell] = cur[cell] == 0 && (Terrain.flags[l.map[cell]] & Terrain.PASSABLE) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void fullyClear() {
|
|
|
|
|
super.fullyClear();
|
|
|
|
|
Dungeon.level.buildFlagMaps();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void use( BlobEmitter emitter ) {
|
|
|
|
|
super.use( emitter );
|
|
|
|
|
emitter.pour( ElmoParticle.FACTORY, 0.02f );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBuildFlagMaps( Level l ) {
|
|
|
|
|
if (volume > 0){
|
|
|
|
|
for (int i=0; i < l.length(); i++) {
|
|
|
|
|
l.passable[i] = l.passable[i] && cur[i] == 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|