Monsters trapped in pits cannot kick

This commit is contained in:
Pasi Kallinen
2025-07-04 17:39:08 +03:00
parent a0d9c94ece
commit e2b80cd886
5 changed files with 25 additions and 0 deletions

View File

@@ -1519,6 +1519,7 @@ the engraving pristine text field was not being appropriately populated during
level creation
worn alchemy smock reduces chances of dipped potions exploding
dwarves can sense buried items under their feet
monsters trapped in pits cannot kick
Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -1507,6 +1507,7 @@ extern struct monst *cloneu(void);
extern void expels(struct monst *, struct permonst *, boolean) NONNULLARG12;
extern struct attack *getmattk(struct monst *, struct monst *, int, int *,
struct attack *) NONNULLARG12;
extern boolean mtrapped_in_pit(struct monst *) NONNULLARG1;
extern int mattacku(struct monst *) NONNULLARG1;
boolean diseasemu(struct permonst *) NONNULLARG1;
boolean u_slip_free(struct monst *, struct attack *) NONNULLARG12;

View File

@@ -423,6 +423,8 @@ mattackm(
case AT_TUCH:
case AT_BUTT:
case AT_TENT:
if (mattk->aatyp == AT_KICK && mtrapped_in_pit(magr))
continue;
/* Nymph that teleported away on first attack? */
if (distmin(magr->mx, magr->my, mdef->mx, mdef->my) > 1)
/* Continue because the monster may have a ranged attack. */

View File

@@ -453,6 +453,22 @@ calc_mattacku_vars(
gn.notonhead = FALSE;
}
/* return TRUE iff monster or hero is trapped in a (spiked) pit */
boolean
mtrapped_in_pit(struct monst *mtmp)
{
struct trap *ttmp = 0;
if (mtmp == &gy.youmonst)
ttmp = (u.utrap && u.utraptype == TT_PIT) ? t_at(u.ux, u.uy) : 0;
else
ttmp = mtmp->mtrapped ? t_at(mtmp->mx, mtmp->my) : 0;
if (ttmp && is_pit(ttmp->ttyp))
return TRUE;
return FALSE;
}
/*
* mattacku: monster attacks you
* returns 1 if monster dies (e.g. "yellow light"), 0 otherwise
@@ -773,6 +789,8 @@ mattacku(struct monst *mtmp)
case AT_TUCH:
case AT_BUTT:
case AT_TENT:
if (mattk->aatyp == AT_KICK && mtrapped_in_pit(mtmp))
continue;
if (!range2 && (!MON_WEP(mtmp) || mtmp->mconf || Conflict
|| !touch_petrifies(gy.youmonst.data))) {
if (foundyou) {

View File

@@ -5498,6 +5498,9 @@ hmonas(struct monst *mon)
FALLTHROUGH;
/*FALLTHRU*/
case AT_KICK:
if (mattk->aatyp == AT_KICK && mtrapped_in_pit(&gy.youmonst))
continue;
/*FALLTHRU*/
case AT_BITE:
case AT_STNG:
case AT_BUTT: