From 564b74129364a33da4d909af04332ed7841d5d22 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 28 Mar 2025 13:26:47 -0400 Subject: [PATCH] v3.1.0: Improved Tengu's target selection, no longer always atks hero --- .../actors/mobs/Mob.java | 2 +- .../actors/mobs/Tengu.java | 44 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 7a167bc63..0a0825ac3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -1209,7 +1209,7 @@ public abstract class Mob extends Char { public static final String TAG = "HUNTING"; //prevents rare infinite loop cases - private boolean recursing = false; + protected boolean recursing = false; @Override public boolean act( boolean enemyInFOV, boolean justAlerted ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java index 563715991..b7c4404cb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Tengu.java @@ -380,11 +380,8 @@ public class Tengu extends Mob { BossHealthBar.assignBoss(this); if (HP <= HT/2) BossHealthBar.bleed(true); } - - //don't bother bundling this, as its purely cosmetic - private boolean yelledCoward = false; - - //tengu is always hunting + + //tengu is always hunting, and can use simpler rules because he never moves private class Hunting extends Mob.Hunting{ @Override @@ -402,19 +399,22 @@ public class Tengu extends Mob { return doAttack( enemy ); } else { - - if (enemyInFOV) { - target = enemy.pos; - } else { - chooseEnemy(); - if (enemy == null){ - //if nothing else can be targeted, target hero - enemy = Dungeon.hero; + + //Try to switch targets to another enemy that is closer + //unless we have already done that and still can't attack them, then move on. + if (!recursing) { + Char oldEnemy = enemy; + enemy = null; + enemy = chooseEnemy(); + if (enemy != null && enemy != oldEnemy) { + recursing = true; + boolean result = act(enemyInFOV, justAlerted); + recursing = false; + return result; } - target = enemy.pos; } - //if not charmed, attempt to use an ability, even if the enemy can't be seen + //attempt to use an ability, even if enemy can't be decided if (canUseAbility()){ return useAbility(); } @@ -502,33 +502,35 @@ public class Tengu extends Mob { } else { abilityToUse = Random.Int(3); } + + //all abilities always target the hero, even if something else is taking Tengu's normal attacks //If we roll the same ability as last time, 9/10 chance to reroll if (abilityToUse != lastAbility || Random.Int(10) == 0){ switch (abilityToUse){ case BOMB_ABILITY : default: - abilityUsed = throwBomb(Tengu.this, enemy); + abilityUsed = throwBomb(Tengu.this, Dungeon.hero); //if Tengu cannot use his bomb ability first, use fire instead. if (abilitiesUsed == 0 && !abilityUsed){ abilityToUse = FIRE_ABILITY; - abilityUsed = throwFire(Tengu.this, enemy); + abilityUsed = throwFire(Tengu.this, Dungeon.hero); } break; case FIRE_ABILITY: - abilityUsed = throwFire(Tengu.this, enemy); + abilityUsed = throwFire(Tengu.this, Dungeon.hero); break; case SHOCKER_ABILITY: - abilityUsed = throwShocker(Tengu.this, enemy); + abilityUsed = throwShocker(Tengu.this, Dungeon.hero); //if Tengu cannot use his shocker ability second, use fire instead. if (abilitiesUsed == 1 && !abilityUsed){ abilityToUse = FIRE_ABILITY; - abilityUsed = throwFire(Tengu.this, enemy); + abilityUsed = throwFire(Tengu.this, Dungeon.hero); } break; } //always use the fire ability with the bosses challenge if (abilityUsed && abilityToUse != FIRE_ABILITY && Dungeon.isChallenged(Challenges.STRONGER_BOSSES)){ - throwFire(Tengu.this, enemy); + throwFire(Tengu.this, Dungeon.hero); } }