v0.6.2: fixed golden bee ai interactions with corruption

This commit is contained in:
Evan Debenham 2017-09-26 17:24:33 -04:00
parent 75be01873c
commit 46b3dfd057
2 changed files with 32 additions and 19 deletions

View File

@ -108,9 +108,9 @@ public class Bee extends Mob {
@Override @Override
protected Char chooseEnemy() { protected Char chooseEnemy() {
//if the pot is no longer present, target the hero //if the pot is no longer present, default to regular AI behaviour
if (potHolder == -1 && potPos == -1) if (potHolder == -1 && potPos == -1)
return Dungeon.hero; return super.chooseEnemy();
//if something is holding the pot, target that //if something is holding the pot, target that
else if (Actor.findById(potHolder) != null) else if (Actor.findById(potHolder) != null)
@ -119,25 +119,37 @@ public class Bee extends Mob {
//if the pot is on the ground //if the pot is on the ground
else { else {
//if already targeting something, and that thing is still alive and near the pot, keeping targeting it. //try to find a new enemy in these circumstances
if (enemy != null && enemy.isAlive() && Dungeon.level.mobs.contains(enemy) if (enemy == null || !enemy.isAlive() || state == WANDERING
&& fieldOfView[enemy.pos] && enemy.invisible == 0 || Dungeon.level.distance(enemy.pos, potPos) > 3
&& Dungeon.level.distance(enemy.pos, potPos) <= 3) || (alignment == Alignment.ALLY && enemy.alignment == Alignment.ALLY)){
return enemy;
//find all mobs near the pot
//find all mobs near the pot HashSet<Char> enemies = new HashSet<>();
HashSet<Char> enemies = new HashSet<>(); for (Mob mob : Dungeon.level.mobs) {
for (Mob mob : Dungeon.level.mobs) { if (!(mob instanceof Bee)
if (!(mob instanceof Bee) && Dungeon.level.distance(mob.pos, potPos) <= 3
&& Dungeon.level.distance(mob.pos, potPos) <= 3 && mob.alignment != Alignment.NEUTRAL
&& mob.alignment != Alignment.NEUTRAL) { && !(alignment == Alignment.ALLY && mob.alignment == Alignment.ALLY)) {
enemies.add(mob); enemies.add(mob);
}
} }
if (!enemies.isEmpty()){
return Random.element(enemies);
} else {
if (alignment != Alignment.ALLY && Dungeon.level.distance(Dungeon.hero.pos, potPos) <= 3){
return Dungeon.hero;
} else {
return null;
}
}
} else {
return enemy;
} }
//pick one, if there are none, check if the hero is near the pot, go for them, otherwise go for nothing.
if (enemies.size() > 0) return Random.element(enemies);
else return (Dungeon.level.distance(Dungeon.hero.pos, potPos) <= 3) ? Dungeon.hero : null ;
} }
} }

View File

@ -49,6 +49,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Venom; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Venom;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Weakness;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Bee;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.King;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
@ -129,7 +130,7 @@ public class WandOfCorruption extends Wand {
float enemyResist = 1 + enemy.EXP; float enemyResist = 1 + enemy.EXP;
if (ch instanceof Mimic || ch instanceof Statue){ if (ch instanceof Mimic || ch instanceof Statue){
enemyResist = 1 + Dungeon.depth; enemyResist = 1 + Dungeon.depth;
} else if (ch instanceof Piranha) { } else if (ch instanceof Piranha || ch instanceof Bee) {
enemyResist = 1 + Dungeon.depth/2f; enemyResist = 1 + Dungeon.depth/2f;
} else if (ch instanceof Wraith) { } else if (ch instanceof Wraith) {
enemyResist = 1 + Dungeon.depth/4f; enemyResist = 1 + Dungeon.depth/4f;