Make travel consider traps like closed doors
Test case: U-shaped corridor, with a known trap in it. Before this change, travel would try to move straight at the target, bumping the wall or walking into a dead-end. After this, travel will go along the corridor and then stop right before the trap. Original patch via AceHack by Alex Smith.
This commit is contained in:
@@ -50,6 +50,8 @@ add novel to discoveries list after reading one
|
|||||||
putting gold into hero-owned container on shop floor gave free credit
|
putting gold into hero-owned container on shop floor gave free credit
|
||||||
stack splitting for dipping large quantities of potions was done poorly
|
stack splitting for dipping large quantities of potions was done poorly
|
||||||
dipping fruit juice into enlightenment gave different result than the inverse
|
dipping fruit juice into enlightenment gave different result than the inverse
|
||||||
|
make travel walk up to a trap and stop when the trap blocks the only
|
||||||
|
way forward, instead of trying to go straight line
|
||||||
|
|
||||||
|
|
||||||
Platform- and/or Interface-Specific Fixes
|
Platform- and/or Interface-Specific Fixes
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
|
|||||||
#define DO_MOVE 0 /* really doing the move */
|
#define DO_MOVE 0 /* really doing the move */
|
||||||
#define TEST_MOVE 1 /* test a normal move (move there next) */
|
#define TEST_MOVE 1 /* test a normal move (move there next) */
|
||||||
#define TEST_TRAV 2 /* test a future travel location */
|
#define TEST_TRAV 2 /* test a future travel location */
|
||||||
|
#define TEST_TRAP 3 /* check if a future travel loc is a trap */
|
||||||
|
|
||||||
/*** some utility macros ***/
|
/*** some utility macros ***/
|
||||||
#define yn(query) yn_function(query, ynchars, 'n')
|
#define yn(query) yn_function(query, ynchars, 'n')
|
||||||
|
|||||||
15
src/hack.c
15
src/hack.c
@@ -657,7 +657,7 @@ xchar x, y;
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* return TRUE if (dx,dy) is an OK place to move
|
/* return TRUE if (dx,dy) is an OK place to move
|
||||||
* mode is one of DO_MOVE, TEST_MOVE or TEST_TRAV
|
* mode is one of DO_MOVE, TEST_MOVE, TEST_TRAV, or TEST_TRAP
|
||||||
*/
|
*/
|
||||||
boolean
|
boolean
|
||||||
test_move(ux, uy, dx, dy, mode)
|
test_move(ux, uy, dx, dy, mode)
|
||||||
@@ -747,7 +747,7 @@ int mode;
|
|||||||
} else
|
} else
|
||||||
pline("That door is closed.");
|
pline("That door is closed.");
|
||||||
}
|
}
|
||||||
} else if (mode == TEST_TRAV)
|
} else if (mode == TEST_TRAV || mode == TEST_TRAP)
|
||||||
goto testdiag;
|
goto testdiag;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@@ -790,15 +790,19 @@ int mode;
|
|||||||
/* Pick travel path that does not require crossing a trap.
|
/* Pick travel path that does not require crossing a trap.
|
||||||
* Avoid water and lava using the usual running rules.
|
* Avoid water and lava using the usual running rules.
|
||||||
* (but not u.ux/u.uy because findtravelpath walks toward u.ux/u.uy) */
|
* (but not u.ux/u.uy because findtravelpath walks toward u.ux/u.uy) */
|
||||||
if (context.run == 8 && mode != DO_MOVE && (x != u.ux || y != u.uy)) {
|
if (context.run == 8
|
||||||
|
&& (mode == TEST_MOVE || mode == TEST_TRAP)
|
||||||
|
&& (x != u.ux || y != u.uy)) {
|
||||||
struct trap *t = t_at(x, y);
|
struct trap *t = t_at(x, y);
|
||||||
|
|
||||||
if ((t && t->tseen)
|
if ((t && t->tseen)
|
||||||
|| (!Levitation && !Flying && !is_clinger(youmonst.data)
|
|| (!Levitation && !Flying && !is_clinger(youmonst.data)
|
||||||
&& is_pool_or_lava(x, y) && levl[x][y].seenv))
|
&& is_pool_or_lava(x, y) && levl[x][y].seenv))
|
||||||
return FALSE;
|
return (mode == TEST_TRAP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == TEST_TRAP) return FALSE; /* do not move through traps */
|
||||||
|
|
||||||
ust = &levl[ux][uy];
|
ust = &levl[ux][uy];
|
||||||
|
|
||||||
/* Now see if other things block our way . . */
|
/* Now see if other things block our way . . */
|
||||||
@@ -923,7 +927,8 @@ boolean guess;
|
|||||||
if (!isok(nx, ny))
|
if (!isok(nx, ny))
|
||||||
continue;
|
continue;
|
||||||
if ((!Passes_walls && !can_ooze(&youmonst)
|
if ((!Passes_walls && !can_ooze(&youmonst)
|
||||||
&& closed_door(x, y)) || sobj_at(BOULDER, x, y)) {
|
&& closed_door(x, y)) || sobj_at(BOULDER, x, y)
|
||||||
|
|| test_move(x, y, nx-x, ny-y, TEST_TRAP)) {
|
||||||
/* closed doors and boulders usually
|
/* closed doors and boulders usually
|
||||||
* cause a delay, so prefer another path */
|
* cause a delay, so prefer another path */
|
||||||
if (travel[x][y] > radius - 3) {
|
if (travel[x][y] > radius - 3) {
|
||||||
|
|||||||
Reference in New Issue
Block a user