Skip to content

Commit

Permalink
Fix autotarget leaking some knowledge of staff type (tmewett#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenzombie committed May 25, 2024
1 parent fd8527a commit 83461cc
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/brogue/Items.c
Original file line number Diff line number Diff line change
Expand Up @@ -5233,13 +5233,9 @@ static boolean canAutoTargetMonster(const creature *monst, const item *theItem,
}

bolt theBolt = boltCatalog[tableForItemCategory(theItem->category)[theItem->kind].power];
boolean magicPolarityIsKnown = (itemMagicPolarityIsKnown(theItem, MAGIC_POLARITY_BENEVOLENT)
|| itemMagicPolarityIsKnown(theItem, MAGIC_POLARITY_MALEVOLENT));

// Target enemies if we don't know if the staff/wand is good or bad
if (!magicPolarityIsKnown && isEnemy) {
return true;
}
boolean magicPolarityIsKnownBenevolent = itemMagicPolarityIsKnown(theItem, MAGIC_POLARITY_BENEVOLENT);
boolean magicPolarityIsKnownMalevolent = itemMagicPolarityIsKnown(theItem, MAGIC_POLARITY_MALEVOLENT);
boolean magicPolarityIsKnown = magicPolarityIsKnownBenevolent || magicPolarityIsKnownMalevolent;

// todo: logic consolidation with this function, specificallyValidBoltTarget, and the monster details screen
// to show what effect (or not) the bolt will have
Expand All @@ -5255,12 +5251,15 @@ static boolean canAutoTargetMonster(const creature *monst, const item *theItem,
return negationWillAffectMonster(monst, true);
} else if (isEnemy && theBolt.boltEffect == BE_TUNNELING && (monst->info.flags & MONST_ATTACKABLE_THRU_WALLS)) {
return true;
}
}

// Otherwise, if we know good/bad, broadly target all enemies or allies based on the bolt flag (if any)
if (magicPolarityIsKnown &&
((isAlly && (theBolt.flags & BF_TARGET_ALLIES)) || (isEnemy && (theBolt.flags & BF_TARGET_ENEMIES)))) {
} else if (((isAlly && (theBolt.flags & BF_TARGET_ALLIES)) || (isEnemy && (theBolt.flags & BF_TARGET_ENEMIES)))) {
return true;
}
} else if (magicPolarityIsKnown) {
if ((isEnemy && magicPolarityIsKnownBenevolent)
|| isAlly && magicPolarityIsKnownMalevolent) {
return true;
}
} else if (isEnemy) { // both the kind and magic polarity are unknown
return true;
}

Expand Down

0 comments on commit 83461cc

Please sign in to comment.