From 46b3dfd0574a8e1a2e8e7d119884fbb686760cb6 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 26 Sep 2017 17:24:33 -0400 Subject: [PATCH] v0.6.2: fixed golden bee ai interactions with corruption --- .../actors/mobs/Bee.java | 48 ++++++++++++------- .../items/wands/WandOfCorruption.java | 3 +- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Bee.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Bee.java index d728e389c..84d018b39 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Bee.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Bee.java @@ -108,9 +108,9 @@ public class Bee extends Mob { @Override 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) - return Dungeon.hero; + return super.chooseEnemy(); //if something is holding the pot, target that else if (Actor.findById(potHolder) != null) @@ -119,25 +119,37 @@ public class Bee extends Mob { //if the pot is on the ground else { - //if already targeting something, and that thing is still alive and near the pot, keeping targeting it. - if (enemy != null && enemy.isAlive() && Dungeon.level.mobs.contains(enemy) - && fieldOfView[enemy.pos] && enemy.invisible == 0 - && Dungeon.level.distance(enemy.pos, potPos) <= 3) - return enemy; - - //find all mobs near the pot - HashSet enemies = new HashSet<>(); - for (Mob mob : Dungeon.level.mobs) { - if (!(mob instanceof Bee) - && Dungeon.level.distance(mob.pos, potPos) <= 3 - && mob.alignment != Alignment.NEUTRAL) { - enemies.add(mob); + //try to find a new enemy in these circumstances + if (enemy == null || !enemy.isAlive() || state == WANDERING + || Dungeon.level.distance(enemy.pos, potPos) > 3 + || (alignment == Alignment.ALLY && enemy.alignment == Alignment.ALLY)){ + + //find all mobs near the pot + HashSet enemies = new HashSet<>(); + for (Mob mob : Dungeon.level.mobs) { + if (!(mob instanceof Bee) + && Dungeon.level.distance(mob.pos, potPos) <= 3 + && mob.alignment != Alignment.NEUTRAL + && !(alignment == Alignment.ALLY && mob.alignment == Alignment.ALLY)) { + 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 ; + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java index 0d8a07fb2..8a4a4af8d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/wands/WandOfCorruption.java @@ -49,6 +49,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Venom; import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo; 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.Mimic; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; @@ -129,7 +130,7 @@ public class WandOfCorruption extends Wand { float enemyResist = 1 + enemy.EXP; if (ch instanceof Mimic || ch instanceof Statue){ enemyResist = 1 + Dungeon.depth; - } else if (ch instanceof Piranha) { + } else if (ch instanceof Piranha || ch instanceof Bee) { enemyResist = 1 + Dungeon.depth/2f; } else if (ch instanceof Wraith) { enemyResist = 1 + Dungeon.depth/4f;