Add way to cycle through valid locations for polearm or jump target

This commit is contained in:
Pasi Kallinen
2017-07-31 19:10:26 +03:00
parent 439028dcae
commit b13bae91dc
9 changed files with 74 additions and 16 deletions

View File

@@ -1564,6 +1564,15 @@ boolean showmsg;
static int jumping_is_magic;
boolean
get_valid_jump_position(x,y)
int x,y;
{
return (isok(x, y)
&& (ACCESSIBLE(levl[x][y].typ) || Passes_walls)
&& is_valid_jump_pos(x, y, jumping_is_magic, FALSE));
}
void
display_jump_positions(state)
int state;
@@ -1577,9 +1586,7 @@ int state;
for (dy = -4; dy <= 4; dy++) {
x = dx + (int) u.ux;
y = dy + (int) u.uy;
if (isok(x, y)
&& (ACCESSIBLE(levl[x][y].typ) || Passes_walls)
&& is_valid_jump_pos(x, y, jumping_is_magic, FALSE))
if (get_valid_jump_position(x, y))
tmp_at(x, y);
}
} else {
@@ -1678,7 +1685,7 @@ int magic; /* 0=Physical, otherwise skill level */
cc.x = u.ux;
cc.y = u.uy;
jumping_is_magic = magic;
getpos_sethilite(display_jump_positions);
getpos_sethilite(display_jump_positions, get_valid_jump_position);
if (getpos(&cc, TRUE, "the desired position") < 0)
return 0; /* user pressed ESC */
if (!is_valid_jump_pos(cc.x, cc.y, magic, TRUE)) {
@@ -2851,6 +2858,15 @@ int min_range, max_range;
static int polearm_range_min = -1;
static int polearm_range_max = -1;
boolean
get_valid_polearm_position(x,y)
int x,y;
{
return (isok(x, y) && ACCESSIBLE(levl[x][y].typ)
&& distu(x, y) >= polearm_range_min
&& distu(x, y) <= polearm_range_max);
}
void
display_polearm_positions(state)
int state;
@@ -2864,9 +2880,7 @@ int state;
for (dy = -4; dy <= 4; dy++) {
x = dx + (int) u.ux;
y = dy + (int) u.uy;
if (isok(x, y) && ACCESSIBLE(levl[x][y].typ)
&& distu(x, y) >= polearm_range_min
&& distu(x, y) <= polearm_range_max) {
if (get_valid_polearm_position(x, y)) {
tmp_at(x, y);
}
}
@@ -2936,7 +2950,7 @@ struct obj *obj;
cc.x = hitm->mx;
cc.y = hitm->my;
}
getpos_sethilite(display_polearm_positions);
getpos_sethilite(display_polearm_positions, get_valid_polearm_position);
if (getpos(&cc, TRUE, "the spot to hit") < 0)
return res; /* ESC; uses turn iff polearm became wielded */