v2.5.1: fixed shopkeepers sometimes not clearing gasses when harmed
This commit is contained in:
@@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge;
|
||||
@@ -110,34 +111,46 @@ public class Shopkeeper extends NPC {
|
||||
turnsSinceHarmed = 0;
|
||||
yell(Messages.get(this, "warn"));
|
||||
|
||||
//cleanses all harmful blobs in the shop
|
||||
ArrayList<Blob> blobs = new ArrayList<>();
|
||||
for (Class c : new BlobImmunity().immunities()){
|
||||
Blob b = Dungeon.level.blobs.get(c);
|
||||
if (b != null && b.volume > 0){
|
||||
blobs.add(b);
|
||||
//use a new actor as we can't clear the gas while we're in the middle of processing it
|
||||
Actor.add(new Actor() {
|
||||
{
|
||||
actPriority = VFX_PRIO;
|
||||
}
|
||||
}
|
||||
|
||||
PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 4 );
|
||||
|
||||
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;
|
||||
@Override
|
||||
protected boolean act() {
|
||||
//cleanses all harmful blobs in the shop
|
||||
ArrayList<Blob> blobs = new ArrayList<>();
|
||||
for (Class c : new BlobImmunity().immunities()){
|
||||
Blob b = Dungeon.level.blobs.get(c);
|
||||
if (b != null && b.volume > 0){
|
||||
blobs.add(b);
|
||||
}
|
||||
}
|
||||
|
||||
if (affected && Dungeon.level.heroFOV[i]) {
|
||||
CellEmitter.get( i ).burst( Speck.factory( Speck.DISCOVER ), 2 );
|
||||
}
|
||||
PathFinder.buildDistanceMap( pos, BArray.not( Dungeon.level.solid, null ), 4 );
|
||||
|
||||
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
|
||||
//This is mainly to prevent stacked effects from causing an instant flee
|
||||
|
||||
Reference in New Issue
Block a user