v3.1.0: Improved Tengu's target selection, no longer always atks hero

This commit is contained in:
Evan Debenham
2025-03-28 13:26:47 -04:00
parent fe5a6dee85
commit 564b741293
2 changed files with 24 additions and 22 deletions

View File

@@ -1209,7 +1209,7 @@ public abstract class Mob extends Char {
public static final String TAG = "HUNTING"; public static final String TAG = "HUNTING";
//prevents rare infinite loop cases //prevents rare infinite loop cases
private boolean recursing = false; protected boolean recursing = false;
@Override @Override
public boolean act( boolean enemyInFOV, boolean justAlerted ) { public boolean act( boolean enemyInFOV, boolean justAlerted ) {

View File

@@ -380,11 +380,8 @@ public class Tengu extends Mob {
BossHealthBar.assignBoss(this); BossHealthBar.assignBoss(this);
if (HP <= HT/2) BossHealthBar.bleed(true); if (HP <= HT/2) BossHealthBar.bleed(true);
} }
//don't bother bundling this, as its purely cosmetic //tengu is always hunting, and can use simpler rules because he never moves
private boolean yelledCoward = false;
//tengu is always hunting
private class Hunting extends Mob.Hunting{ private class Hunting extends Mob.Hunting{
@Override @Override
@@ -402,19 +399,22 @@ public class Tengu extends Mob {
return doAttack( enemy ); return doAttack( enemy );
} else { } else {
if (enemyInFOV) { //Try to switch targets to another enemy that is closer
target = enemy.pos; //unless we have already done that and still can't attack them, then move on.
} else { if (!recursing) {
chooseEnemy(); Char oldEnemy = enemy;
if (enemy == null){ enemy = null;
//if nothing else can be targeted, target hero enemy = chooseEnemy();
enemy = Dungeon.hero; 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()){ if (canUseAbility()){
return useAbility(); return useAbility();
} }
@@ -502,33 +502,35 @@ public class Tengu extends Mob {
} else { } else {
abilityToUse = Random.Int(3); 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 we roll the same ability as last time, 9/10 chance to reroll
if (abilityToUse != lastAbility || Random.Int(10) == 0){ if (abilityToUse != lastAbility || Random.Int(10) == 0){
switch (abilityToUse){ switch (abilityToUse){
case BOMB_ABILITY : default: 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 Tengu cannot use his bomb ability first, use fire instead.
if (abilitiesUsed == 0 && !abilityUsed){ if (abilitiesUsed == 0 && !abilityUsed){
abilityToUse = FIRE_ABILITY; abilityToUse = FIRE_ABILITY;
abilityUsed = throwFire(Tengu.this, enemy); abilityUsed = throwFire(Tengu.this, Dungeon.hero);
} }
break; break;
case FIRE_ABILITY: case FIRE_ABILITY:
abilityUsed = throwFire(Tengu.this, enemy); abilityUsed = throwFire(Tengu.this, Dungeon.hero);
break; break;
case SHOCKER_ABILITY: 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 Tengu cannot use his shocker ability second, use fire instead.
if (abilitiesUsed == 1 && !abilityUsed){ if (abilitiesUsed == 1 && !abilityUsed){
abilityToUse = FIRE_ABILITY; abilityToUse = FIRE_ABILITY;
abilityUsed = throwFire(Tengu.this, enemy); abilityUsed = throwFire(Tengu.this, Dungeon.hero);
} }
break; break;
} }
//always use the fire ability with the bosses challenge //always use the fire ability with the bosses challenge
if (abilityUsed && abilityToUse != FIRE_ABILITY && Dungeon.isChallenged(Challenges.STRONGER_BOSSES)){ if (abilityUsed && abilityToUse != FIRE_ABILITY && Dungeon.isChallenged(Challenges.STRONGER_BOSSES)){
throwFire(Tengu.this, enemy); throwFire(Tengu.this, Dungeon.hero);
} }
} }