Unify webs

This commit is contained in:
Pasi Kallinen
2020-12-10 19:04:30 +02:00
parent 3bd60d6d54
commit eb58352860
+76 -66
View File
@@ -24,7 +24,7 @@ static int FDECL(trapeffect_pit, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_hole, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_hole, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_telep_trap, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_telep_trap, (struct monst *, struct trap *, unsigned));
static int FDECL(trapeffect_level_telep, (struct monst *, struct trap *, unsigned)); static int FDECL(trapeffect_level_telep, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_web, (struct trap *, unsigned)); static int FDECL(trapeffect_web, (struct monst *, struct trap *, unsigned));
static void FDECL(trapeffect_statue_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_statue_trap, (struct trap *, unsigned));
static void FDECL(trapeffect_magic_trap, (struct trap *, unsigned)); static void FDECL(trapeffect_magic_trap, (struct trap *, unsigned));
static void FDECL(trapeffect_anti_magic, (struct trap *, unsigned)); static void FDECL(trapeffect_anti_magic, (struct trap *, unsigned));
@@ -1749,11 +1749,13 @@ unsigned trflags;
return 0; return 0;
} }
static void static int
trapeffect_web(trap, trflags) trapeffect_web(mtmp, trap, trflags)
struct monst *mtmp;
struct trap *trap; struct trap *trap;
unsigned trflags; unsigned trflags;
{ {
if (mtmp == &g.youmonst) {
boolean webmsgok = (trflags & NOWEBMSG) == 0; boolean webmsgok = (trflags & NOWEBMSG) == 0;
boolean forcetrap = ((trflags & FORCETRAP) != 0 boolean forcetrap = ((trflags & FORCETRAP) != 0
|| (trflags & FAILEDUNTRAP) != 0); || (trflags & FAILEDUNTRAP) != 0);
@@ -1762,12 +1764,12 @@ unsigned trflags;
feeltrap(trap); feeltrap(trap);
if (mu_maybe_destroy_web(&g.youmonst, webmsgok, trap)) if (mu_maybe_destroy_web(&g.youmonst, webmsgok, trap))
return; return 0;
if (webmaker(g.youmonst.data)) { if (webmaker(g.youmonst.data)) {
if (webmsgok) if (webmsgok)
pline(trap->madeby_u ? "You take a walk on your web." pline(trap->madeby_u ? "You take a walk on your web."
: "There is a spider web here."); : "There is a spider web here.");
return; return 0;
} }
if (webmsgok) { if (webmsgok) {
char verbbuf[BUFSZ]; char verbbuf[BUFSZ];
@@ -1814,7 +1816,7 @@ unsigned trflags;
str = 17; str = 17;
} else { } else {
reset_utrap(FALSE); reset_utrap(FALSE);
return; return 0;
} }
webmsgok = FALSE; /* mintrap printed the messages */ webmsgok = FALSE; /* mintrap printed the messages */
@@ -1842,6 +1844,72 @@ unsigned trflags;
} }
set_utrap((unsigned) tim, TT_WEB); set_utrap((unsigned) tim, TT_WEB);
} }
} else {
/* Monster in a web. */
boolean tear_web;
boolean in_sight = canseemon(mtmp) || (mtmp == u.usteed);
struct permonst *mptr = mtmp->data;
if (webmaker(mptr))
return 0;
if (mu_maybe_destroy_web(mtmp, in_sight, trap))
return 0;
tear_web = FALSE;
switch (monsndx(mptr)) {
case PM_OWLBEAR: /* Eric Backus */
case PM_BUGBEAR:
if (!in_sight) {
You_hear("the roaring of a confused bear!");
mtmp->mtrapped = 1;
break;
}
/*FALLTHRU*/
default:
if (mptr->mlet == S_GIANT
/* exclude baby dragons and relatively short worms */
|| (mptr->mlet == S_DRAGON && extra_nasty(mptr))
|| (mtmp->wormno && count_wsegs(mtmp) > 5)) {
tear_web = TRUE;
} else if (in_sight) {
pline("%s is caught in %s spider web.", Monnam(mtmp),
a_your[trap->madeby_u]);
seetrap(trap);
}
mtmp->mtrapped = tear_web ? 0 : 1;
break;
/* this list is fairly arbitrary; it deliberately
excludes wumpus & giant/ettin zombies/mummies */
case PM_TITANOTHERE:
case PM_BALUCHITHERIUM:
case PM_PURPLE_WORM:
case PM_JABBERWOCK:
case PM_IRON_GOLEM:
case PM_BALROG:
case PM_KRAKEN:
case PM_MASTODON:
case PM_ORION:
case PM_NORN:
case PM_CYCLOPS:
case PM_LORD_SURTUR:
tear_web = TRUE;
break;
}
if (tear_web) {
if (in_sight)
pline("%s tears through %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]);
deltrap(trap);
newsym(mtmp->mx, mtmp->my);
} else if (g.force_mintrap && !mtmp->mtrapped) {
if (in_sight) {
pline("%s avoids %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]);
seetrap(trap);
}
}
return mtmp->mtrapped;
}
return 0;
} }
static void static void
@@ -2154,7 +2222,7 @@ unsigned trflags;
break; break;
case WEB: /* Our luckless player has stumbled into a web. */ case WEB: /* Our luckless player has stumbled into a web. */
trapeffect_web(trap, trflags); (void) trapeffect_web(&g.youmonst, trap, trflags);
break; break;
case STATUE_TRAP: case STATUE_TRAP:
@@ -2862,65 +2930,7 @@ register struct monst *mtmp;
case TELEP_TRAP: case TELEP_TRAP:
return trapeffect_telep_trap(mtmp, trap, 0); return trapeffect_telep_trap(mtmp, trap, 0);
case WEB: case WEB:
/* Monster in a web. */ return trapeffect_web(mtmp, trap, 0);
if (webmaker(mptr))
break;
if (mu_maybe_destroy_web(mtmp, in_sight, trap))
break;
tear_web = FALSE;
switch (monsndx(mptr)) {
case PM_OWLBEAR: /* Eric Backus */
case PM_BUGBEAR:
if (!in_sight) {
You_hear("the roaring of a confused bear!");
mtmp->mtrapped = 1;
break;
}
/*FALLTHRU*/
default:
if (mptr->mlet == S_GIANT
/* exclude baby dragons and relatively short worms */
|| (mptr->mlet == S_DRAGON && extra_nasty(mptr))
|| (mtmp->wormno && count_wsegs(mtmp) > 5)) {
tear_web = TRUE;
} else if (in_sight) {
pline("%s is caught in %s spider web.", Monnam(mtmp),
a_your[trap->madeby_u]);
seetrap(trap);
}
mtmp->mtrapped = tear_web ? 0 : 1;
break;
/* this list is fairly arbitrary; it deliberately
excludes wumpus & giant/ettin zombies/mummies */
case PM_TITANOTHERE:
case PM_BALUCHITHERIUM:
case PM_PURPLE_WORM:
case PM_JABBERWOCK:
case PM_IRON_GOLEM:
case PM_BALROG:
case PM_KRAKEN:
case PM_MASTODON:
case PM_ORION:
case PM_NORN:
case PM_CYCLOPS:
case PM_LORD_SURTUR:
tear_web = TRUE;
break;
}
if (tear_web) {
if (in_sight)
pline("%s tears through %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]);
deltrap(trap);
newsym(mtmp->mx, mtmp->my);
} else if (g.force_mintrap && !mtmp->mtrapped) {
if (in_sight) {
pline("%s avoids %s spider web!", Monnam(mtmp),
a_your[trap->madeby_u]);
seetrap(trap);
}
}
break;
case STATUE_TRAP: case STATUE_TRAP:
break; break;
case MAGIC_TRAP: case MAGIC_TRAP: