Skip to content

Commit

Permalink
Improve and refactor auto-targeting (tmewett#664)
Browse files Browse the repository at this point in the history
* Add functions and enum

* Refactor targeting functions

* Remove creatureIsTargetable

* Add negationWillAffectMonster, fix rethrow, update autotarget logic
  • Loading branch information
zenzombie authored Mar 13, 2024
1 parent 6cf57c0 commit b086151
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 150 deletions.
12 changes: 12 additions & 0 deletions changes/auto-targeting.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- When using a staff or wand, enemies that always reflect bolts (stone/winged guardian, non-negated mirror totem) will no longer be auto-targeted.
- When hallucinating but not telepathic, auto-targeting behavior has changed in two ways. First, an initial target will no longer be selected when using a staff or wand whose kind isn't known. Second, the tab key will have no effect. The previous behavoir leaked information about which creatures are allies.
- When using a staff or wand, the tab key will now cycle through additional targets (if any) only if an initial target was selected.
- When using a known staff of tunneling, turrets and sentinels will now be auto-targeted.
- If a wand or staff of unknown kind has been magic detected, auto-targeting will now target enemies or allies accordingly.
- Monsters that are immune to fire are no longer auto-targeted when using a firebolt staff or throwing an incendiary dart or known potion of incineration.
- Monsters that are immune to weapon damage are no longer auto-targeted when throwing a dart or javelin, or using a staff of conjuration.
- When using a known wand of domination, monsters at full health will not longer be auto-targeted.
- When using a known wand of negation, monsters that will not be affected will no longer be auto-targeted.
- When using a known wand of beckoning, monsters that are adjacent to the player will no longer be auto-targeted.
- When using a known staff of healing, non-reflective allies at full health will no longer be auto-targeted.
- When throwing a known potion of confusion or caustic gas, unaffected enemies will no longer be auto-targeted.
8 changes: 4 additions & 4 deletions src/brogue/IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static void initializeMenuButtons(buttonState *state, brogueButton buttons[5]) {
// This is basically the main loop for the game.
void mainInputLoop() {
pos oldTargetLoc = { 0, 0 };
short steps, oldRNG, dir, newX, newY;
short steps, oldRNG, dir;
pos path[1000];
creature *monst;
item *theItem;
Expand Down Expand Up @@ -734,9 +734,9 @@ void mainInputLoop() {
}

if (tabKey && !playingBack) { // The tab key cycles the cursor through monsters, items and terrain features.
if (nextTargetAfter(&newX, &newY, rogue.cursorLoc.x, rogue.cursorLoc.y, true, true, true, true, false, theEvent.shiftKey)) {
rogue.cursorLoc.x = newX;
rogue.cursorLoc.y = newY;
pos newLoc;
if (nextTargetAfter(NULL, &newLoc, rogue.cursorLoc, AUTOTARGET_MODE_EXPLORE, theEvent.shiftKey)) {
rogue.cursorLoc = newLoc;
}
}

Expand Down
Loading

0 comments on commit b086151

Please sign in to comment.