Unify polymorph traps

This commit is contained in:
Pasi Kallinen
2020-12-10 17:58:48 +02:00
parent 6eb89c6b44
commit 5dcd6b2e17

View File

@@ -28,7 +28,7 @@ static int FDECL(trapeffect_web, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_statue_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_statue_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_magic_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_magic_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_anti_magic, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_anti_magic, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_poly_trap, (struct trap *, unsigned)); static int FDECL(trapeffect_poly_trap, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_landmine, (struct trap *, unsigned)); static void FDECL(trapeffect_landmine, (struct trap *, unsigned));
static void FDECL(trapeffect_rolling_boulder_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_rolling_boulder_trap, (struct trap *, unsigned));
static void FDECL(trapeffect_magic_portal, (struct trap *, unsigned)); static void FDECL(trapeffect_magic_portal, (struct trap *, unsigned));
@@ -2047,11 +2047,13 @@ unsigned trflags;
return 0; return 0;
} }
static void static int
trapeffect_poly_trap(trap, trflags) trapeffect_poly_trap(mtmp, trap, trflags)
struct monst *mtmp;
struct trap *trap; struct trap *trap;
unsigned trflags; unsigned trflags;
{ {
if (mtmp == &g.youmonst) {
boolean viasitting = (trflags & VIASITTING) != 0; boolean viasitting = (trflags & VIASITTING) != 0;
int steed_article = ARTICLE_THE; int steed_article = ARTICLE_THE;
char verbbuf[BUFSZ]; char verbbuf[BUFSZ];
@@ -2079,6 +2081,18 @@ unsigned trflags;
You_feel("a change coming over you."); You_feel("a change coming over you.");
polyself(0); polyself(0);
} }
} else {
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
if (resists_magm(mtmp)) {
shieldeff(mtmp->mx, mtmp->my);
} else if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
(void) newcham(mtmp, (struct permonst *) 0, FALSE, FALSE);
if (in_sight)
seetrap(trap);
}
}
return 0;
} }
static void static void
@@ -2303,7 +2317,7 @@ unsigned trflags;
break; break;
case POLY_TRAP: case POLY_TRAP:
trapeffect_poly_trap(trap, trflags); (void) trapeffect_poly_trap(&g.youmonst, trap, trflags);
break; break;
case LANDMINE: case LANDMINE:
@@ -3052,15 +3066,7 @@ register struct monst *mtmp;
} }
break; break;
case POLY_TRAP: case POLY_TRAP:
if (resists_magm(mtmp)) { return trapeffect_poly_trap(mtmp, trap, 0);
shieldeff(mtmp->mx, mtmp->my);
} else if (!resist(mtmp, WAND_CLASS, 0, NOTELL)) {
if (newcham(mtmp, (struct permonst *) 0, FALSE, FALSE))
/* we're done with mptr but keep it up to date */
mptr = mtmp->data;
if (in_sight)
seetrap(trap);
}
break; break;
case ROLLING_BOULDER_TRAP: case ROLLING_BOULDER_TRAP:
if (!is_flyer(mptr)) { if (!is_flyer(mptr)) {