summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/direct.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-17 21:28:56 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-17 21:28:56 +0000
commit12de33d2d95164e30a8a2ac960ad28b2a69383e3 (patch)
tree4b238a712c0c7f329eed44cc23832f6998c7b2ca /crawl-ref/source/direct.cc
parent46c7199d6ae8c006a78799a1c59dacf4e2d77c8f (diff)
downloadcrawl-ref-12de33d2d95164e30a8a2ac960ad28b2a69383e3.tar.gz
crawl-ref-12de33d2d95164e30a8a2ac960ad28b2a69383e3.zip
Another modification of autotargetting submerged monsters, based off
BR 1935715. * Targeting a square with a known submerged monster ("strange disturbance" description) always enforces '!' rather than '.' * Submerged monsters only get targetted if there are no other more viable targets (dangerous monsters, really) in sight. The latter uses a heavily modified i_feel_safe() that now draws on get_playervisible_monsters(), which got numerous new parameters to cover all possibilities. :p git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4314 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/direct.cc')
-rw-r--r--crawl-ref/source/direct.cc78
1 files changed, 51 insertions, 27 deletions
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 31bf2c580d..c822c03304 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -247,6 +247,19 @@ static void draw_ray_glyph(const coord_def &pos, int colour,
#endif
}
+// Unseen monsters in shallow water show a "strange disturbance".
+// (Unless flying!)
+static bool _mon_submerged_in_water(const monsters *mon)
+{
+ if (!mon)
+ return false;
+
+ return (grd[mon->x][mon->y] == DNGN_SHALLOW_WATER
+ && see_grid(mon->x, mon->y)
+ && !player_monster_visible(mon)
+ && !mons_flies(mon));
+}
+
static bool _is_target_in_range(int x, int y, int range)
{
// range doesn't matter
@@ -564,11 +577,11 @@ void direction(dist& moves, targeting_type restricts,
key_command = shift_direction(key_command);
}
- if (target_unshifted &&
- (key_command == CMD_TARGET_CYCLE_FORWARD
- || key_command == CMD_TARGET_CYCLE_BACK
- || key_command == CMD_TARGET_OBJ_CYCLE_FORWARD
- || key_command == CMD_TARGET_OBJ_CYCLE_BACK))
+ if (target_unshifted
+ && (key_command == CMD_TARGET_CYCLE_FORWARD
+ || key_command == CMD_TARGET_CYCLE_BACK
+ || key_command == CMD_TARGET_OBJ_CYCLE_FORWARD
+ || key_command == CMD_TARGET_OBJ_CYCLE_BACK))
{
target_unshifted = false;
}
@@ -710,8 +723,8 @@ void direction(dist& moves, targeting_type restricts,
mode = static_cast<targ_mode_type>((mode + 1) % TARG_NUM_MODES);
mprf( "Targeting mode is now: %s",
(mode == TARG_ANY) ? "any" :
- (mode == TARG_ENEMY) ? "enemies" :
- "friends" );
+ (mode == TARG_ENEMY) ? "enemies"
+ : "friends" );
break;
case CMD_TARGET_PREV_TARGET:
@@ -758,7 +771,13 @@ void direction(dist& moves, targeting_type restricts,
moves.isEndpoint = true;
// intentional fall-through
case CMD_TARGET_SELECT: // finalize current choice
- moves.isValid = true;
+ if (!moves.isEndpoint
+ && mgrd[moves.tx][moves.ty] != NON_MONSTER
+ && _mon_submerged_in_water(&menv[mgrd[moves.tx][moves.ty]]))
+ {
+ moves.isEndpoint = true;
+ }
+ moves.isValid = true;
moves.isTarget = true;
loop_done = true;
@@ -919,8 +938,8 @@ void direction(dist& moves, targeting_type restricts,
MSGCH_EXAMINE_FILTER);
}
// Ask for confirmation if we're quitting for some odd reason
- else if ( moves.isValid || moves.isCancel ||
- yesno("Are you sure you want to fizzle?", false, 'n') )
+ else if ( moves.isValid || moves.isCancel
+ || yesno("Are you sure you want to fizzle?", false, 'n') )
{
// Finalize whatever is inside the loop
// (moves-internal finalizations can be done later)
@@ -966,17 +985,18 @@ void direction(dist& moves, targeting_type restricts,
#ifdef USE_TILE
// tiles always need a beam redraw if show_beam is true (and if valid...)
- if (show_beam && find_ray(you.x_pos, you.y_pos, moves.tx, moves.ty,
- true, ray, 0, true) || need_beam_redraw )
+ if ( need_beam_redraw
+ || show_beam && find_ray(you.x_pos, you.y_pos, moves.tx, moves.ty,
+ true, ray, 0, true) )
{
#else
if ( need_beam_redraw )
{
viewwindow(true, false);
#endif
- if ( show_beam &&
- in_vlos(grid2viewX(moves.tx), grid2viewY(moves.ty)) &&
- moves.target() != you.pos() )
+ if ( show_beam
+ && in_vlos(grid2viewX(moves.tx), grid2viewY(moves.ty))
+ && moves.target() != you.pos() )
{
// Draw the new ray with magenta '*'s, not including
// your square or the target square.
@@ -996,7 +1016,7 @@ void direction(dist& moves, targeting_type restricts,
textcolor(LIGHTGREY);
#ifdef USE_TILE
draw_ray_glyph(moves.target(), MAGENTA, '*',
- MAGENTA | COLFLAG_REVERSE);
+ MAGENTA | COLFLAG_REVERSE);
}
viewwindow(true, false);
#else
@@ -1131,23 +1151,27 @@ static bool find_monster( int x, int y, int mode, int range = -1)
if (targ_mon == NON_MONSTER || !in_los(x,y))
return (false);
- // Unseen monsters in shallow water show a "strange disturbance"
- // (unless flying!)
- if (!player_monster_visible(&menv[targ_mon]))
- {
- // since you can't see the monster, assume it's not a friend
- return (mode != TARG_FRIEND
- && grd[x][y] == DNGN_SHALLOW_WATER
- && !mons_flies(&menv[targ_mon]));
- }
+ monsters *mon = &menv[targ_mon];
// Unknown mimics don't count as monsters, either.
- if (mons_is_mimic(menv[targ_mon].type)
- && !(menv[targ_mon].flags & MF_KNOWN_MIMIC))
+ if (mons_is_mimic(mon->type)
+ && !(mon->flags & MF_KNOWN_MIMIC))
{
return (false);
}
+ // Don't usually target unseen monsters...
+ if (!player_monster_visible(mon))
+ {
+ // ... unless it creates a "disturbance in the water".
+ // Since you can't see the monster, assume it's not a friend.
+ // Also don't target submerged monsters if there are other targets
+ // in sight. (This might be too restrictive.)
+ return (mode != TARG_FRIEND
+ && _mon_submerged_in_water(mon)
+ && i_feel_safe(false, false, true, range));
+ }
+
// Now compare target modes.
if (mode == TARG_ANY)
return true;