v2.5.1: fixed shopkeepers sometimes not clearing gasses when harmed

This commit is contained in:
Evan Debenham
2024-09-12 13:50:22 -04:00
parent ece3e68f4b
commit d8c92096e3
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
@@ -110,34 +111,46 @@ public class Shopkeeper extends NPC {
turnsSinceHarmed = 0; turnsSinceHarmed = 0;
yell(Messages.get(this, "warn")); yell(Messages.get(this, "warn"));
//cleanses all harmful blobs in the shop //use a new actor as we can't clear the gas while we're in the middle of processing it
ArrayList<Blob> blobs = new ArrayList<>(); Actor.add(new Actor() {
for (Class c : new BlobImmunity().immunities()){ {
Blob b = Dungeon.level.blobs.get(c); actPriority = VFX_PRIO;
if (b != null && b.volume > 0){
blobs.add(b);
} }
}
PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 4 ); @Override
protected boolean act() {
for (int i=0; i < Dungeon.level.length(); i++) { //cleanses all harmful blobs in the shop
if (PathFinder.distance[i] < Integer.MAX_VALUE) { ArrayList<Blob> blobs = new ArrayList<>();
for (Class c : new BlobImmunity().immunities()){
boolean affected = false; Blob b = Dungeon.level.blobs.get(c);
for (Blob blob : blobs) { if (b != null && b.volume > 0){
if (blob.cur[i] > 0) { blobs.add(b);
blob.clear(i);
affected = true;
} }
} }
if (affected && Dungeon.level.heroFOV[i]) { PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 4 );
CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 2 );
}
for (int i=0; i < Dungeon.level.length(); i++) {
if (PathFinder.distance[i] < Integer.MAX_VALUE) {
boolean affected = false;
for (Blob blob : blobs) {
if (blob.cur[i] > 0) {
blob.clear(i);
affected = true;
}
}
if (affected && Dungeon.level.heroFOV[i]) {
CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 2 );
}
}
}
Actor.remove(this);
return true;
} }
} });
//There is a 1 turn buffer before more damage/debuffs make the shopkeeper flee //There is a 1 turn buffer before more damage/debuffs make the shopkeeper flee
//This is mainly to prevent stacked effects from causing an instant flee //This is mainly to prevent stacked effects from causing an instant flee