1
0
Fork 0
mirror of https://codeberg.org/noisytoot/notnotdnethack.git synced 2025-07-31 01:42:24 +01:00

Add option to limit aggressiveness of travelplus

Compound option, takes an integer.

Discards paths that pass through unknown tiles if they are longer than the value of travelplus.

However, travel will still make guesses to get closer to your destination, which can often then bring those paths-through-the-unknown within your given limit.

Recommended setting range: 0-10
This commit is contained in:
NeroOneTrueKing 2020-08-15 17:54:07 -05:00
parent d235ad513b
commit 4291deb13f
3 changed files with 33 additions and 9 deletions

View file

@ -410,7 +410,7 @@ struct instance_flags {
boolean lootabc; /* use "a/b/c" rather than "o/i/b" when looting */
boolean showrace; /* show hero glyph by race rather than by role */
boolean travelcmd; /* allow travel command */
boolean travelplus;/* if travel command should attempt to path through the unknown */
int travelplus;/* how far travel command should attempt to path through the unknown */
int runmode; /* update screen display during run moves */
#ifdef AUTOPICKUP_EXCEPTIONS
struct autopickup_exception *autopickup_exceptions[2];

View file

@ -814,7 +814,8 @@ boolean guess;
if (u.itx == u.ux && u.ity == u.uy)
u.itx = u.ity = 0;
if (u.tx != u.ux || u.ty != u.uy) {
xchar travel[COLNO][ROWNO];
xchar travel[COLNO][ROWNO]; /* radius to get to this xy coord */
xchar suretravel[COLNO][ROWNO]; /* we have a seenv-only path to this coord */
xchar travelstepx[2][COLNO*ROWNO];
xchar travelstepy[2][COLNO*ROWNO];
xchar tx, ty, ux, uy;
@ -835,8 +836,10 @@ boolean guess;
noguess:
(void) memset((genericptr_t)travel, 0, sizeof(travel));
(void)memset((genericptr_t)suretravel, 0, sizeof(suretravel));
travelstepx[0][0] = tx;
travelstepy[0][0] = ty;
suretravel[tx][ty] = 1;
while (n != 0) {
int nn = 0;
@ -863,7 +866,7 @@ boolean guess;
closed_door(x, y)) || boulder_at(x, y)) {
/* closed doors and boulders usually
* cause a delay, so prefer another path */
if (travel[x][y] > radius-3) {
if (travel[x][y] > radius - 3) {
travelstepx[1-set][nn] = x;
travelstepy[1-set][nn] = y;
/* don't change travel matrix! */
@ -871,8 +874,8 @@ boolean guess;
continue;
}
}
/* travelplus is a bit adventerous, and will hope that unseen locations are pathable */
if (iflags.travelplus || levl[nx][ny].seenv) {
/* travelplus is a bit adventerous, and hopes that unseen locations are pathable */
if ((iflags.travelplus && (suretravel[x][y] || radius<iflags.travelplus)) || levl[nx][ny].seenv) {
if (nx == ux && ny == uy) {
if (!guess) {
u.dx = x-ux;
@ -885,12 +888,21 @@ boolean guess;
}
return TRUE;
}
} else if (!travel[nx][ny]) {
}
else if (!suretravel[nx][ny] && levl[nx][ny].seenv && suretravel[nx-x][ny-y]) {
/* we are now sure of this step (because the previous step was) */
travelstepx[1-set][nn] = nx;
travelstepy[1-set][nn] = ny;
travel[nx][ny] = radius;
travel[nx][ny] = radius;
suretravel[nx][ny] = radius;
nn++;
}
else if (!travel[nx][ny]) {
travelstepx[1 - set][nn] = nx;
travelstepy[1 - set][nn] = ny;
travel[nx][ny] = radius;
nn++;
}
}
}
}
@ -900,7 +912,7 @@ boolean guess;
}
/* if guessing, find best location in travel matrix and go there */
if (guess && !iflags.travelplus) {
if (guess) {
int px = tx, py = ty; /* pick location */
int dist, idist, nxtdist, d2, id2, nd2;

View file

@ -278,7 +278,6 @@ static struct Bool_Opt
{"tombstone",&flags.tombstone, TRUE, SET_IN_GAME},
{"toptenwin",&flags.toptenwin, FALSE, SET_IN_GAME},
{"travel", &iflags.travelcmd, TRUE, SET_IN_GAME},
{"travelplus", &iflags.travelplus, FALSE, SET_IN_GAME},
#ifdef UTF8_GLYPHS
{"UTF8graphics", &iflags.UTF8graphics, FALSE, SET_IN_GAME},
#else
@ -447,6 +446,7 @@ static struct Comp_Opt
{ "tile_file", "name of tile file", 70, DISP_IN_GAME}, /*WC*/
{ "traps", "the symbols to use in drawing traps",
MAXTCHARS+1, SET_IN_FILE },
{ "travelplus", "maximum unknown-explore distance when traveling", 32, SET_IN_GAME},
{ "vary_msgcount", "show more old messages at a time", 20, DISP_IN_GAME }, /*WC*/
#ifdef MSDOS
{ "video", "method of video updating", 20, SET_IN_FILE },
@ -637,6 +637,7 @@ initoptions()
flags.end_own = FALSE;
flags.end_top = 3;
flags.end_around = 2;
iflags.travelplus = 0;
iflags.runmode = RUN_LEAP;
iflags.pokedex = POKEDEX_SHOW_DEFAULT;
iflags.msg_history = 20;
@ -2733,6 +2734,15 @@ goodfruit:
return;
}
fullname = "travelplus";
if (match_optname(opts, fullname, 7, TRUE)) {
op = string_for_opt(opts, negated);
if ((negated && !op) || (!negated && op)) {
iflags.travelplus = negated ? 0 : atoi(op);
} else if (negated) bad_negation(fullname, TRUE);
return;
}
#ifdef VIDEOSHADES
/* videocolors:string */
fullname = "videocolors";
@ -4202,6 +4212,8 @@ char *buf;
}
else if (!strcmp(optname, "traps"))
Sprintf(buf, "%s", to_be_done);
else if (!strcmp(optname, "travelplus"))
Sprintf(buf, "%d", iflags.travelplus);
else if (!strcmp(optname, "vary_msgcount")) {
if (iflags.wc_vary_msgcount) Sprintf(buf, "%d",iflags.wc_vary_msgcount);
else Strcpy(buf, defopt);