v1.2.1: redesigned spreading logic for magical fire

This commit is contained in:
Evan Debenham 2022-03-27 18:49:54 -04:00 committed by Evan Debenham
parent d0d125da60
commit a10c3b399f

View File

@ -43,6 +43,7 @@ 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.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
@ -154,7 +155,8 @@ public class MagicalFireRoom extends SpecialRoom {
return super.canPlaceCharacter(p, l);
}
public static class EternalFire extends Fire {
public static class EternalFire extends Blob {
@Override
protected void evolve() {
@ -163,47 +165,57 @@ public class MagicalFireRoom extends SpecialRoom {
Freezing freeze = (Freezing)Dungeon.level.blobs.get( Freezing.class );
Blizzard bliz = (Blizzard)Dungeon.level.blobs.get( Blizzard.class );
Fire fire = (Fire)Dungeon.level.blobs.get( Fire.class );
//if any part of the fire is cleared, cleanse the whole thing
//Note that this is a bit brittle atm, it assumes only one group of eternal fire per floor
boolean clearAll = false;
Level l = Dungeon.level;
for (int i = area.left; i < area.right; i++){
for (int j = area.top; j < area.bottom; j++){
for (int i = area.left - 1; i <= area.right; i++){
for (int j = area.top - 1; 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;
clearAll = true;
}
if (freeze != null && freeze.volume > 0 && freeze.cur[cell] > 0){
freeze.clear(cell);
cur[cell] = 0;
clearAll = true;
}
if (bliz != null && bliz.volume > 0 && bliz.cur[cell] > 0){
bliz.clear(cell);
cur[cell] = 0;
clearAll = true;
}
//if a char is adjacent, set them on fire briefly
if (cur[cell] > 0){
for (int k : PathFinder.NEIGHBOURS4){
Char ch = Actor.findChar(cell+k);
if (ch != null && !ch.isImmune(getClass())){
Buff.affect(ch, Burning.class).reignite(ch, 4f);
}
//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;
clearAll = true;
}
if (freeze != null && freeze.volume > 0 && freeze.cur[cell] > 0){
freeze.clear(cell);
cur[cell] = 0;
clearAll = true;
}
if (bliz != null && bliz.volume > 0 && bliz.cur[cell] > 0){
bliz.clear(cell);
cur[cell] = 0;
clearAll = true;
}
l.passable[cell] = cur[cell] == 0 && (Terrain.flags[l.map[cell]] & Terrain.PASSABLE) != 0;
}
if (cur[cell] > 0
|| cur[cell-1] > 0
|| cur[cell+1] > 0
|| cur[cell-Dungeon.level.width()] > 0
|| cur[cell+Dungeon.level.width()] > 0) {
//spread fire to nearby flammable cells
if (Dungeon.level.flamable[cell] && (fire == null || fire.cur[cell] == 0)){
GameScene.add(Blob.seed(cell, 4, Fire.class));
}
//ignite adjacent chars
Char ch = Actor.findChar(cell);
if (ch != null && !ch.isImmune(getClass())) {
Buff.affect(ch, Burning.class).reignite(ch, 4f);
}
}
l.passable[cell] = cur[cell] == 0 && (Terrain.flags[l.map[cell]] & Terrain.PASSABLE) != 0;
off[cell] = cur[cell];
volume += off[cell];
}
}
@ -212,7 +224,6 @@ public class MagicalFireRoom extends SpecialRoom {
return;
}
super.evolve();
}
@Override