v0.7.4: piranha now act as if they can't see enemies they can't reach
This commit is contained in:
parent
6ca288c91c
commit
9bab7dfd5e
|
@ -28,10 +28,8 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.MysteryMeat;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PoolRoom;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.PiranhaSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.PiranhaSprite;
|
||||||
|
import com.watabou.utils.PathFinder;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class Piranha extends Mob {
|
public class Piranha extends Mob {
|
||||||
|
@ -46,8 +44,12 @@ public class Piranha extends Mob {
|
||||||
loot = MysteryMeat.class;
|
loot = MysteryMeat.class;
|
||||||
lootChance = 1f;
|
lootChance = 1f;
|
||||||
|
|
||||||
|
SLEEPING = new Sleeping();
|
||||||
|
WANDERING = new Wandering();
|
||||||
HUNTING = new Hunting();
|
HUNTING = new Hunting();
|
||||||
|
|
||||||
|
state = SLEEPING;
|
||||||
|
|
||||||
properties.add(Property.BLOB_IMMUNE);
|
properties.add(Property.BLOB_IMMUNE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,19 +136,41 @@ public class Piranha extends Mob {
|
||||||
immunities.add( Vertigo.class );
|
immunities.add( Vertigo.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if there is not a path to the enemy, piranhas act as if they can't see them
|
||||||
|
private class Sleeping extends Mob.Sleeping{
|
||||||
|
@Override
|
||||||
|
public boolean act(boolean enemyInFOV, boolean justAlerted) {
|
||||||
|
if (enemyInFOV) {
|
||||||
|
PathFinder.buildDistanceMap(enemy.pos, Dungeon.level.water, viewDistance);
|
||||||
|
enemyInFOV = PathFinder.distance[pos] != Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.act(enemyInFOV, justAlerted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class Wandering extends Mob.Wandering{
|
||||||
|
@Override
|
||||||
|
public boolean act(boolean enemyInFOV, boolean justAlerted) {
|
||||||
|
if (enemyInFOV) {
|
||||||
|
PathFinder.buildDistanceMap(enemy.pos, Dungeon.level.water, viewDistance);
|
||||||
|
enemyInFOV = PathFinder.distance[pos] != Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.act(enemyInFOV, justAlerted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class Hunting extends Mob.Hunting{
|
private class Hunting extends Mob.Hunting{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean act(boolean enemyInFOV, boolean justAlerted) {
|
public boolean act(boolean enemyInFOV, boolean justAlerted) {
|
||||||
boolean result = super.act(enemyInFOV, justAlerted);
|
if (enemyInFOV) {
|
||||||
//this causes piranha to move away when a door is closed on them in a pool room.
|
PathFinder.buildDistanceMap(enemy.pos, Dungeon.level.water, viewDistance);
|
||||||
if (state == WANDERING && Dungeon.level instanceof RegularLevel){
|
enemyInFOV = PathFinder.distance[pos] != Integer.MAX_VALUE;
|
||||||
Room curRoom = ((RegularLevel)Dungeon.level).room(pos);
|
|
||||||
if (curRoom instanceof PoolRoom) {
|
|
||||||
target = Dungeon.level.pointToCell(curRoom.random(1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
|
return super.act(enemyInFOV, justAlerted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user