From e2b80cd886cf9f2bda9bb25d131c8033d51dbbd0 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 4 Jul 2025 17:39:08 +0300 Subject: [PATCH] Monsters trapped in pits cannot kick --- doc/fixes3-7-0.txt | 1 + include/extern.h | 1 + src/mhitm.c | 2 ++ src/mhitu.c | 18 ++++++++++++++++++ src/uhitm.c | 3 +++ 5 files changed, 25 insertions(+) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index e90d275e2..56d72fe80 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -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 diff --git a/include/extern.h b/include/extern.h index e3375627f..7df8e2530 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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; diff --git a/src/mhitm.c b/src/mhitm.c index 39fe251a7..078b7596c 100644 --- a/src/mhitm.c +++ b/src/mhitm.c @@ -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. */ diff --git a/src/mhitu.c b/src/mhitu.c index 0357915e8..ff32445e8 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -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) { diff --git a/src/uhitm.c b/src/uhitm.c index 90014bcd6..d43fe53be 100644 --- a/src/uhitm.c +++ b/src/uhitm.c @@ -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: