Merge branch 'NetHack:NetHack-3.7' into NetHack-3.7

This commit is contained in:
RainRat
2024-04-11 14:00:18 -07:00
committed by GitHub
9 changed files with 46 additions and 2 deletions

View File

@@ -144,6 +144,7 @@ staticfn const char *spkey_name(int);
staticfn int (*timed_occ_fn)(void);
staticfn char *doc_extcmd_flagstr(winid, const struct ext_func_tab *);
staticfn int dummyfunction(void);
static const char *readchar_queue = "";
@@ -3267,6 +3268,7 @@ rhack(int key)
struct _cmd_queue cq, *cmdq = NULL;
const struct ext_func_tab *cmdq_ec = 0, *prefix_seen = 0;
boolean was_m_prefix = FALSE;
int (*func)(void) = dummyfunction;
iflags.menu_requested = FALSE;
gc.context.nopick = 0;
@@ -3305,7 +3307,7 @@ rhack(int key)
gc.context.travel = gc.context.travel1 = 0;
{
const struct ext_func_tab *tlist;
int res, (*func)(void);
int res;
do_cmdq_extcmd:
if (cmdq_ec)
@@ -3446,8 +3448,14 @@ rhack(int key)
}
/* reset_cmd_vars() sets context.move to False so we might
need to change it [back] to True */
if ((res & ECMD_TIME) != 0)
if ((res & ECMD_TIME) != 0) {
gc.context.move = TRUE;
if (func != dokick) {
/* hero did something else than kicking a location;
reset the location, so pets don't avoid it */
gk.kickedloc.x = 0, gk.kickedloc.y = 0;
}
}
return;
}
/* if we reach here, cmd wasn't found in cmdlist[] */
@@ -5225,4 +5233,10 @@ dosh_core(void)
return ECMD_OK;
}
staticfn int
dummyfunction(void)
{
return ECMD_CANCEL;
}
/*cmd.c*/

View File

@@ -477,6 +477,7 @@ static const struct instance_globals_j g_init_j = {
};
static const struct instance_globals_k g_init_k = {
{ 0, 0 }, /* kickedloc */
/* decl.c */
UNDEFINED_PTR, /* kickedobj */
DUMMY, /* killer */

View File

@@ -1145,6 +1145,10 @@ dog_move(
return MMOVE_NOTHING;
}
/* avoid a location hero just kicked */
if (m_avoid_kicked_loc(mtmp, nx, ny))
continue;
{
/* Dog avoids harmful traps, but perhaps it has to pass one
* in order to follow player. (Non-harmful traps do not

View File

@@ -1314,6 +1314,7 @@ dokick(void)
x = u.ux + u.dx;
y = u.uy + u.dy;
gk.kickedloc.x = x, gk.kickedloc.y = y;
/* KMH -- Kicking boots always succeed */
if (uarmf && uarmf->otyp == KICKING_BOOTS)

View File

@@ -2511,6 +2511,8 @@ domove(void)
maybe_adjust_hero_bubble();
}
gd.domove_attempting = 0L;
gk.kickedloc.x = 0, gk.kickedloc.y = 0;
}
staticfn void

View File

@@ -1215,6 +1215,21 @@ maybe_spin_web(struct monst *mtmp)
}
}
/* monster avoids a location nx, ny, if hero kicked that location */
boolean
m_avoid_kicked_loc(struct monst *mtmp, coordxy nx, coordxy ny)
{
if ((mtmp->mpeaceful || mtmp->mtame)
&& mtmp->mcansee
&& !mtmp->mconf && !mtmp->mstun
&& !Conflict
&& isok(gk.kickedloc.x, gk.kickedloc.y)
&& nx == gk.kickedloc.x && ny == gk.kickedloc.y
&& next2u(nx, ny))
return TRUE;
return FALSE;
}
/* max distmin() distance for monster to look for items */
#define SQSRCHRADIUS 5
@@ -1831,6 +1846,9 @@ m_move(struct monst *mtmp, int after)
nx = poss[i].x;
ny = poss[i].y;
if (m_avoid_kicked_loc(mtmp, nx, ny))
continue;
if (MON_AT(nx, ny) && (info[i] & ALLOW_MDISP)
&& !(info[i] & ALLOW_M) && !better_with_displacing)
continue;