v3.0.1: adjusted bees to target the closest enemy (like other mobs)
This commit is contained in:
@@ -32,8 +32,6 @@ import com.shatteredpixel.shatteredpixeldungeon.sprites.BeeSprite;
|
|||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
|
|
||||||
//FIXME the AI for these things is becoming a complete mess, should refactor
|
//FIXME the AI for these things is becoming a complete mess, should refactor
|
||||||
public class Bee extends Mob {
|
public class Bee extends Mob {
|
||||||
|
|
||||||
@@ -161,20 +159,22 @@ public class Bee extends Mob {
|
|||||||
|| (alignment == Alignment.ALLY && enemy.alignment == Alignment.ALLY)
|
|| (alignment == Alignment.ALLY && enemy.alignment == Alignment.ALLY)
|
||||||
|| (buff( Amok.class ) == null && enemy.isInvulnerable(getClass()))){
|
|| (buff( Amok.class ) == null && enemy.isInvulnerable(getClass()))){
|
||||||
|
|
||||||
//find all mobs near the pot
|
//target closest potential enemy near the pot
|
||||||
HashSet<Char> enemies = new HashSet<>();
|
Char closest = null;
|
||||||
for (Mob mob : Dungeon.level.mobs) {
|
for (Mob mob : Dungeon.level.mobs) {
|
||||||
if (!(mob == this)
|
if (!(mob == this)
|
||||||
&& Dungeon.level.distance(mob.pos, potPos) <= 3
|
&& Dungeon.level.distance(mob.pos, potPos) <= 3
|
||||||
&& mob.alignment != Alignment.NEUTRAL
|
&& mob.alignment != Alignment.NEUTRAL
|
||||||
&& !mob.isInvulnerable(getClass())
|
&& !mob.isInvulnerable(getClass())
|
||||||
&& !(alignment == Alignment.ALLY && mob.alignment == Alignment.ALLY)) {
|
&& !(alignment == Alignment.ALLY && mob.alignment == Alignment.ALLY)) {
|
||||||
enemies.add(mob);
|
if (closest == null || Dungeon.level.distance(closest.pos, pos) > Dungeon.level.distance(mob.pos, pos)){
|
||||||
|
closest = mob;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enemies.isEmpty()){
|
if (closest != null){
|
||||||
return Random.element(enemies);
|
return closest;
|
||||||
} else {
|
} else {
|
||||||
if (alignment != Alignment.ALLY && Dungeon.level.distance(Dungeon.hero.pos, potPos) <= 3){
|
if (alignment != Alignment.ALLY && Dungeon.level.distance(Dungeon.hero.pos, potPos) <= 3){
|
||||||
return Dungeon.hero;
|
return Dungeon.hero;
|
||||||
|
|||||||
Reference in New Issue
Block a user