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

@@ -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: