formatting: src/t*.c - z*.c continuation lines

End of first pass, but '[&|?:][ \t]*$' doesn't catch trailing operater
followed by end-of-line comment so more needs to be done.  As with the
past couple of batches, I've removed redundant parentheses from 'return'
statements but only for files that had continuation fix-ups.

I've also removed tabs from comments in some of the files, but didn't
start until part way through this subset of the sources.
This commit is contained in:
PatR
2015-10-28 17:33:38 -07:00
parent 530ba8e3d3
commit a447534b2f
10 changed files with 589 additions and 594 deletions
+24 -23
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 teleport.c $NHDT-Date: 1433014241 2015/05/30 19:30:41 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */ /* NetHack 3.6 teleport.c $NHDT-Date: 1446078762 2015/10/29 00:32:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -387,7 +387,7 @@ boolean force_it;
register struct obj *otmp; register struct obj *otmp;
if (mtmp == u.usteed) if (mtmp == u.usteed)
return (FALSE); return FALSE;
if (mtmp->mleashed) { if (mtmp->mleashed) {
otmp = get_mleash(mtmp); otmp = get_mleash(mtmp);
@@ -528,7 +528,7 @@ dotele()
You("don't know that spell."); You("don't know that spell.");
else else
You("are not able to teleport at will."); You("are not able to teleport at will.");
return (0); return 0;
} }
} }
} }
@@ -559,9 +559,9 @@ dotele()
if (castit) { if (castit) {
exercise(A_WIS, TRUE); exercise(A_WIS, TRUE);
if (spelleffects(sp_no, TRUE)) if (spelleffects(sp_no, TRUE))
return (1); return 1;
else if (!wizard) else if (!wizard)
return (0); return 0;
} else { } else {
u.uen -= energy; u.uen -= energy;
context.botl = 1; context.botl = 1;
@@ -576,11 +576,11 @@ dotele()
(void) next_to_u(); (void) next_to_u();
} else { } else {
You1(shudder_for_moment); You1(shudder_for_moment);
return (0); return 0;
} }
if (!trap) if (!trap)
morehungry(100); morehungry(100);
return (1); return 1;
} }
void void
@@ -912,19 +912,19 @@ struct monst *mtmp;
if (!xx) { if (!xx) {
/* no current location (migrating monster arrival) */ /* no current location (migrating monster arrival) */
if (dndest.nlx && On_W_tower_level(&u.uz)) if (dndest.nlx && On_W_tower_level(&u.uz))
return ((yy & 2) != 0) return (((yy & 2) != 0)
^ /* inside xor not within */ /* inside xor not within */
!within_bounded_area(x, y, dndest.nlx, dndest.nly, ^ !within_bounded_area(x, y, dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy); dndest.nhx, dndest.nhy));
if (updest.lx && (yy & 1) != 0) /* moving up */ if (updest.lx && (yy & 1) != 0) /* moving up */
return (within_bounded_area(x, y, updest.lx, updest.ly, updest.hx, return (within_bounded_area(x, y, updest.lx, updest.ly,
updest.hy) updest.hx, updest.hy)
&& (!updest.nlx && (!updest.nlx
|| !within_bounded_area(x, y, updest.nlx, updest.nly, || !within_bounded_area(x, y, updest.nlx, updest.nly,
updest.nhx, updest.nhy))); updest.nhx, updest.nhy)));
if (dndest.lx && (yy & 1) == 0) /* moving down */ if (dndest.lx && (yy & 1) == 0) /* moving down */
return (within_bounded_area(x, y, dndest.lx, dndest.ly, dndest.hx, return (within_bounded_area(x, y, dndest.lx, dndest.ly,
dndest.hy) dndest.hx, dndest.hy)
&& (!dndest.nlx && (!dndest.nlx
|| !within_bounded_area(x, y, dndest.nlx, dndest.nly, || !within_bounded_area(x, y, dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy))); dndest.nhx, dndest.nhy)));
@@ -1212,16 +1212,17 @@ register struct obj *obj;
|| (restricted_fall || (restricted_fall
&& (!within_bounded_area(tx, ty, dndest.lx, dndest.ly, && (!within_bounded_area(tx, ty, dndest.lx, dndest.ly,
dndest.hx, dndest.hy) dndest.hx, dndest.hy)
|| (dndest.nlx && within_bounded_area( || (dndest.nlx
tx, ty, dndest.nlx, dndest.nly, && within_bounded_area(tx, ty,
dndest.nhx, dndest.nhy)))) || dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy))))
/* on the Wizard Tower levels, objects inside should /* on the Wizard Tower levels, objects inside should
stay inside and objects outside should stay outside */ stay inside and objects outside should stay outside */
(dndest.nlx && On_W_tower_level(&u.uz) || (dndest.nlx && On_W_tower_level(&u.uz)
&& within_bounded_area(tx, ty, dndest.nlx, dndest.nly, && within_bounded_area(tx, ty, dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy) dndest.nhx, dndest.nhy)
!= within_bounded_area(otx, oty, dndest.nlx, dndest.nly, != within_bounded_area(otx, oty, dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy))); dndest.nhx, dndest.nhy)));
if (flooreffects(obj, tx, ty, "fall")) { if (flooreffects(obj, tx, ty, "fall")) {
return FALSE; return FALSE;
+116 -123
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 trap.c $NHDT-Date: 1445126429 2015/10/18 00:00:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.241 $ */ /* NetHack 3.6 trap.c $NHDT-Date: 1446078765 2015/10/29 00:32:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.242 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -441,7 +441,7 @@ register int x, y, typ;
if (Sokoban) if (Sokoban)
maybe_finish_sokoban(); maybe_finish_sokoban();
} }
return (ttmp); return ttmp;
} }
void void
@@ -600,10 +600,10 @@ int *fail_reason;
/* statues of unique monsters from bones or wishing end /* statues of unique monsters from bones or wishing end
up here (cant_revive() sets mnum to be doppelganger; up here (cant_revive() sets mnum to be doppelganger;
mptr reflects the original form for use by newcham()) */ mptr reflects the original form for use by newcham()) */
if ((mnum == PM_DOPPELGANGER && mptr != &mons[PM_DOPPELGANGER]) || if ((mnum == PM_DOPPELGANGER && mptr != &mons[PM_DOPPELGANGER])
/* block quest guards from other roles */ /* block quest guards from other roles */
(mptr->msound == MS_GUARDIAN || (mptr->msound == MS_GUARDIAN
&& quest_info(MS_GUARDIAN) != mnum)) { && quest_info(MS_GUARDIAN) != mnum)) {
mon = makemon(&mons[PM_DOPPELGANGER], x, y, mon = makemon(&mons[PM_DOPPELGANGER], x, y,
NO_MINVENT | MM_NOCOUNTBIRTH | MM_ADJACENTOK); NO_MINVENT | MM_NOCOUNTBIRTH | MM_ADJACENTOK);
/* if hero has protection from shape changers, cham field will /* if hero has protection from shape changers, cham field will
@@ -656,17 +656,17 @@ int *fail_reason;
/* "the|your|Manlobbi's statue [of a wombat]" */ /* "the|your|Manlobbi's statue [of a wombat]" */
shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE)); shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE));
Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue), Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
(cause == ANIMATE_SPELL && (cause == ANIMATE_SPELL
/* avoid "of a shopkeeper" if it's Manlobbi himself /* avoid "of a shopkeeper" if it's Manlobbi himself
(if carried, it can't be unpaid--hence won't be (if carried, it can't be unpaid--hence won't be
described as "Manlobbi's statue"--because there described as "Manlobbi's statue"--because there
wasn't any living shk when statue was picked up) */ wasn't any living shk when statue was picked up) */
(mon != shkp || carried(statue))) && (mon != shkp || carried(statue)))
? xname(statue) ? xname(statue)
: "statue"); : "statue");
pline("%s %s!", upstart(statuename), comes_to_life); pline("%s %s!", upstart(statuename), comes_to_life);
} else if (Hallucination) { /* They don't know it's a statue */ } else if (Hallucination) { /* They don't know it's a statue */
pline_The("%s suddenly seems more animated.", rndmonnam(NULL)); pline_The("%s suddenly seems more animated.", rndmonnam((char *) 0));
} else if (cause == ANIMATE_SHATTER) { } else if (cause == ANIMATE_SHATTER) {
if (cansee(x, y)) if (cansee(x, y))
Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue), Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
@@ -691,10 +691,10 @@ int *fail_reason;
which refers to "it" so needs to follow a message describing which refers to "it" so needs to follow a message describing
the object ("the statue comes to life" one above) */ the object ("the statue comes to life" one above) */
if (cause != ANIMATE_NORMAL && costly_spot(x, y) if (cause != ANIMATE_NORMAL && costly_spot(x, y)
&& (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0 && && (shkp = shop_keeper(*in_rooms(x, y, SHOPBASE))) != 0
/* avoid charging for Manlobbi's statue of Manlobbi /* avoid charging for Manlobbi's statue of Manlobbi
if stone-to-flesh is used on petrified shopkeep */ if stone-to-flesh is used on petrified shopkeep */
mon != shkp) && mon != shkp)
(void) stolen_value(statue, x, y, (boolean) shkp->mpeaceful, (void) stolen_value(statue, x, y, (boolean) shkp->mpeaceful,
FALSE); FALSE);
@@ -2067,7 +2067,7 @@ register struct monst *mtmp;
|| (tt == HOLE && !mindless(mptr)))) { || (tt == HOLE && !mindless(mptr)))) {
/* it has been in such a trap - perhaps it escapes */ /* it has been in such a trap - perhaps it escapes */
if (rn2(4)) if (rn2(4))
return (0); return 0;
} else { } else {
mtmp->mtrapseen |= (1 << (tt - 1)); mtmp->mtrapseen |= (1 << (tt - 1));
} }
@@ -2141,7 +2141,6 @@ register struct monst *mtmp;
if (thitm(0, mtmp, otmp, d(2, 6), FALSE)) if (thitm(0, mtmp, otmp, d(2, 6), FALSE))
trapkilled = TRUE; trapkilled = TRUE;
break; break;
case SQKY_BOARD: case SQKY_BOARD:
if (is_flyer(mptr)) if (is_flyer(mptr))
break; break;
@@ -2160,7 +2159,6 @@ register struct monst *mtmp;
/* wake up nearby monsters */ /* wake up nearby monsters */
wake_nearto(mtmp->mx, mtmp->my, 40); wake_nearto(mtmp->mx, mtmp->my, 40);
break; break;
case BEAR_TRAP: case BEAR_TRAP:
if (mptr->msize > MZ_SMALL && !amorphous(mptr) && !is_flyer(mptr) if (mptr->msize > MZ_SMALL && !amorphous(mptr) && !is_flyer(mptr)
&& !is_whirly(mptr) && !unsolid(mptr)) { && !is_whirly(mptr) && !unsolid(mptr)) {
@@ -2184,7 +2182,6 @@ register struct monst *mtmp;
if (mtmp->mtrapped) if (mtmp->mtrapped)
trapkilled = thitm(0, mtmp, (struct obj *) 0, d(2, 4), FALSE); trapkilled = thitm(0, mtmp, (struct obj *) 0, d(2, 4), FALSE);
break; break;
case SLP_GAS_TRAP: case SLP_GAS_TRAP:
if (!resists_sleep(mtmp) && !breathless(mptr) && !mtmp->msleeping if (!resists_sleep(mtmp) && !breathless(mptr) && !mtmp->msleeping
&& mtmp->mcanmove) { && mtmp->mcanmove) {
@@ -2194,7 +2191,6 @@ register struct monst *mtmp;
} }
} }
break; break;
case RUST_TRAP: { case RUST_TRAP: {
struct obj *target; struct obj *target;
@@ -2256,7 +2252,7 @@ register struct monst *mtmp;
(void) split_mon(mtmp, (struct monst *) 0); (void) split_mon(mtmp, (struct monst *) 0);
} }
break; break;
} } /* RUST_TRAP */
case FIRE_TRAP: case FIRE_TRAP:
mfiretrap: mfiretrap:
if (in_sight) if (in_sight)
@@ -2318,7 +2314,6 @@ register struct monst *mtmp;
if (see_it) if (see_it)
seetrap(trap); seetrap(trap);
break; break;
case PIT: case PIT:
case SPIKED_PIT: case SPIKED_PIT:
fallverb = "falls"; fallverb = "falls";
@@ -2386,19 +2381,19 @@ register struct monst *mtmp;
} else } else
break; break;
} }
/* Fall through */ /*FALLTHRU*/
case LEVEL_TELEP: case LEVEL_TELEP:
case MAGIC_PORTAL: { case MAGIC_PORTAL: {
int mlev_res; int mlev_res;
mlev_res = mlevel_tele_trap(mtmp, trap, inescapable, in_sight); mlev_res = mlevel_tele_trap(mtmp, trap, inescapable, in_sight);
if (mlev_res) if (mlev_res)
return (mlev_res); return mlev_res;
} break; break;
}
case TELEP_TRAP: case TELEP_TRAP:
mtele_trap(mtmp, trap, in_sight); mtele_trap(mtmp, trap, in_sight);
break; break;
case WEB: case WEB:
/* Monster in a web. */ /* Monster in a web. */
if (webmaker(mptr)) if (webmaker(mptr))
@@ -2477,10 +2472,8 @@ register struct monst *mtmp;
} }
} }
break; break;
case STATUE_TRAP: case STATUE_TRAP:
break; break;
case MAGIC_TRAP: case MAGIC_TRAP:
/* A magic trap. Monsters usually immune. */ /* A magic trap. Monsters usually immune. */
if (!rn2(21)) if (!rn2(21))
@@ -2526,7 +2519,6 @@ register struct monst *mtmp;
newsym(trap->tx, trap->ty); newsym(trap->tx, trap->ty);
} }
break; break;
case LANDMINE: case LANDMINE:
if (rn2(3)) if (rn2(3))
break; /* monsters usually don't set it off */ break; /* monsters usually don't set it off */
@@ -2571,7 +2563,6 @@ register struct monst *mtmp;
nomovemsg = "The explosion awakens you!"; nomovemsg = "The explosion awakens you!";
} }
break; break;
case POLY_TRAP: case POLY_TRAP:
if (resists_magm(mtmp)) { if (resists_magm(mtmp)) {
shieldeff(mtmp->mx, mtmp->my); shieldeff(mtmp->mx, mtmp->my);
@@ -2583,7 +2574,6 @@ register struct monst *mtmp;
seetrap(trap); seetrap(trap);
} }
break; break;
case ROLLING_BOULDER_TRAP: case ROLLING_BOULDER_TRAP:
if (!is_flyer(mptr)) { if (!is_flyer(mptr)) {
int style = ROLL | (in_sight ? 0 : LAUNCH_UNSEEN); int style = ROLL | (in_sight ? 0 : LAUNCH_UNSEEN);
@@ -2604,7 +2594,6 @@ register struct monst *mtmp;
} }
} }
break; break;
case VIBRATING_SQUARE: case VIBRATING_SQUARE:
if (see_it && !Blind) { if (see_it && !Blind) {
if (in_sight) if (in_sight)
@@ -2616,7 +2605,6 @@ register struct monst *mtmp;
seetrap(trap); seetrap(trap);
} }
break; break;
default: default:
impossible("Some monster encountered a strange trap of type %d.", impossible("Some monster encountered a strange trap of type %d.",
tt); tt);
@@ -2810,7 +2798,7 @@ long hmask, emask; /* might cancel timeout */
if (u.uswallow) { if (u.uswallow) {
You("float down, but you are still %s.", You("float down, but you are still %s.",
is_animal(u.ustuck->data) ? "swallowed" : "engulfed"); is_animal(u.ustuck->data) ? "swallowed" : "engulfed");
return (1); return 1;
} }
if (Punished && !carried(uball) if (Punished && !carried(uball)
@@ -2909,10 +2897,10 @@ long hmask, emask; /* might cancel timeout */
dotrap(trap, 0); dotrap(trap, 0);
} }
if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow && if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow
/* falling through trap door calls goto_level, /* falling through trap door calls goto_level,
and goto_level does its own pickup() call */ and goto_level does its own pickup() call */
on_level(&u.uz, &current_dungeon_level)) && on_level(&u.uz, &current_dungeon_level))
(void) pickup(1); (void) pickup(1);
return 1; return 1;
} }
@@ -3096,39 +3084,33 @@ domagictrap()
break; break;
/* very occasionally something nice happens. */ /* very occasionally something nice happens. */
case 19: { /* tame nearby monsters */
int i, j;
struct monst *mtmp;
case 19: (void) adjattrib(A_CHA, 1, FALSE);
/* tame nearby monsters */ for (i = -1; i <= 1; i++)
{ for (j = -1; j <= 1; j++) {
register int i, j; if (!isok(u.ux + i, u.uy + j))
register struct monst *mtmp; continue;
mtmp = m_at(u.ux + i, u.uy + j);
if (mtmp)
(void) tamedog(mtmp, (struct obj *) 0);
}
break;
}
case 20: { /* uncurse stuff */
struct obj pseudo;
long save_conf = HConfusion;
(void) adjattrib(A_CHA, 1, FALSE); pseudo = zeroobj; /* neither cursed nor blessed,
for (i = -1; i <= 1; i++) and zero out oextra */
for (j = -1; j <= 1; j++) { pseudo.otyp = SCR_REMOVE_CURSE;
if (!isok(u.ux + i, u.uy + j)) HConfusion = 0L;
continue; (void) seffects(&pseudo);
mtmp = m_at(u.ux + i, u.uy + j); HConfusion = save_conf;
if (mtmp) break;
(void) tamedog(mtmp, (struct obj *) 0); }
}
break;
}
case 20:
/* uncurse stuff */
{
struct obj pseudo;
long save_conf = HConfusion;
pseudo = zeroobj; /* neither cursed nor blessed,
and zero out oextra */
pseudo.otyp = SCR_REMOVE_CURSE;
HConfusion = 0L;
(void) seffects(&pseudo);
HConfusion = save_conf;
break;
}
default: default:
break; break;
} }
@@ -3500,14 +3482,14 @@ boolean *lostsome;
} }
} }
if (!otmp) if (!otmp)
return (FALSE); /* nothing to drop! */ return FALSE; /* nothing to drop! */
if (otmp->owornmask) if (otmp->owornmask)
remove_worn_item(otmp, FALSE); remove_worn_item(otmp, FALSE);
*lostsome = TRUE; *lostsome = TRUE;
dropx(otmp); dropx(otmp);
invc--; invc--;
} }
return (TRUE); return TRUE;
} }
/* /*
@@ -3527,7 +3509,7 @@ drown()
if (!rn2(5)) if (!rn2(5))
inpool_ok = TRUE; inpool_ok = TRUE;
else else
return (FALSE); return FALSE;
} }
if (!u.uinwater) { if (!u.uinwater) {
@@ -3549,7 +3531,7 @@ drown()
losehp(i, "rusting away", KILLED_BY); losehp(i, "rusting away", KILLED_BY);
} }
if (inpool_ok) if (inpool_ok)
return (FALSE); return FALSE;
if ((i = number_leashed()) > 0) { if ((i = number_leashed()) > 0) {
pline_The("leash%s slip%s loose.", (i > 1) ? "es" : "", pline_The("leash%s slip%s loose.", (i > 1) ? "es" : "",
@@ -3576,7 +3558,7 @@ drown()
u.uinwater = 1; u.uinwater = 1;
under_water(1); under_water(1);
vision_full_recalc = 1; vision_full_recalc = 1;
return (FALSE); return FALSE;
} }
if ((Teleportation || can_teleport(youmonst.data)) && !Unaware if ((Teleportation || can_teleport(youmonst.data)) && !Unaware
&& (Teleport_control || rn2(3) < Luck + 2)) { && (Teleport_control || rn2(3) < Luck + 2)) {
@@ -3584,14 +3566,14 @@ drown()
if (!level.flags.noteleport) { if (!level.flags.noteleport) {
(void) dotele(); (void) dotele();
if (!is_pool(u.ux, u.uy)) if (!is_pool(u.ux, u.uy))
return (TRUE); return TRUE;
} else } else
pline_The("attempted teleport spell fails."); pline_The("attempted teleport spell fails.");
} }
if (u.usteed) { if (u.usteed) {
dismount_steed(DISMOUNT_GENERIC); dismount_steed(DISMOUNT_GENERIC);
if (!is_pool(u.ux, u.uy)) if (!is_pool(u.ux, u.uy))
return (TRUE); return TRUE;
} }
crawl_ok = FALSE; crawl_ok = FALSE;
x = y = 0; /* lint suppression */ x = y = 0; /* lint suppression */
@@ -3634,7 +3616,7 @@ crawl:
if (succ) { if (succ) {
pline("Pheew! That was close."); pline("Pheew! That was close.");
teleds(x, y, TRUE); teleds(x, y, TRUE);
return (TRUE); return TRUE;
} }
/* still too much weight */ /* still too much weight */
pline("But in vain."); pline("But in vain.");
@@ -3662,7 +3644,7 @@ crawl:
You("find yourself back %s.", You("find yourself back %s.",
Is_waterlevel(&u.uz) ? "in an air bubble" : "on land"); Is_waterlevel(&u.uz) ? "in an air bubble" : "on land");
} }
return (TRUE); return TRUE;
} }
void void
@@ -4143,7 +4125,7 @@ boolean force;
char the_trap[BUFSZ], qbuf[QBUFSZ]; char the_trap[BUFSZ], qbuf[QBUFSZ];
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
x = u.ux + u.dx; x = u.ux + u.dx;
y = u.uy + u.dy; y = u.uy + u.dy;
if (!isok(x, y)) { if (!isok(x, y)) {
@@ -4199,7 +4181,7 @@ boolean force;
(ttmp->ttyp == WEB) ? "Remove" : "Disarm", the_trap); (ttmp->ttyp == WEB) ? "Remove" : "Disarm", the_trap);
switch (ynq(qbuf)) { switch (ynq(qbuf)) {
case 'q': case 'q':
return (0); return 0;
case 'n': case 'n':
trap_skipped = TRUE; trap_skipped = TRUE;
deal_with_floor_trap = FALSE; deal_with_floor_trap = FALSE;
@@ -4257,7 +4239,7 @@ boolean force;
doname, ansimpleoname, "a box"); doname, ansimpleoname, "a box");
switch (ynq(qbuf)) { switch (ynq(qbuf)) {
case 'q': case 'q':
return (0); return 0;
case 'n': case 'n':
continue; continue;
} }
@@ -4272,7 +4254,7 @@ boolean force;
switch (ynq("Disarm it?")) { switch (ynq("Disarm it?")) {
case 'q': case 'q':
return (1); return 1;
case 'n': case 'n':
trap_skipped = TRUE; trap_skipped = TRUE;
continue; continue;
@@ -4293,16 +4275,16 @@ boolean force;
} }
} else } else
pline("That %s was not trapped.", xname(otmp)); pline("That %s was not trapped.", xname(otmp));
return (1); return 1;
} else { } else {
You("find no traps on %s.", the(xname(otmp))); You("find no traps on %s.", the(xname(otmp)));
return (1); return 1;
} }
} }
You(trap_skipped ? "find no other traps here." You(trap_skipped ? "find no other traps here."
: "know of no traps here."); : "know of no traps here.");
return (0); return 0;
} }
if (stumble_on_door_mimic(x, y)) if (stumble_on_door_mimic(x, y))
@@ -4314,19 +4296,19 @@ boolean force;
if (!IS_DOOR(levl[x][y].typ)) { if (!IS_DOOR(levl[x][y].typ)) {
if (!trap_skipped) if (!trap_skipped)
You("know of no traps there."); You("know of no traps there.");
return (0); return 0;
} }
switch (levl[x][y].doormask) { switch (levl[x][y].doormask) {
case D_NODOOR: case D_NODOOR:
You("%s no door there.", Blind ? "feel" : "see"); You("%s no door there.", Blind ? "feel" : "see");
return (0); return 0;
case D_ISOPEN: case D_ISOPEN:
pline("This door is safely open."); pline("This door is safely open.");
return (0); return 0;
case D_BROKEN: case D_BROKEN:
pline("This door is broken."); pline("This door is broken.");
return (0); return 0;
} }
if ((levl[x][y].doormask & D_TRAPPED if ((levl[x][y].doormask & D_TRAPPED
@@ -4335,7 +4317,7 @@ boolean force;
You("find a trap on the door!"); You("find a trap on the door!");
exercise(A_WIS, TRUE); exercise(A_WIS, TRUE);
if (ynq("Disarm it?") != 'y') if (ynq("Disarm it?") != 'y')
return (1); return 1;
if (levl[x][y].doormask & D_TRAPPED) { if (levl[x][y].doormask & D_TRAPPED) {
ch = 15 + (Role_if(PM_ROGUE) ? u.ulevel * 3 : u.ulevel); ch = 15 + (Role_if(PM_ROGUE) ? u.ulevel * 3 : u.ulevel);
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
@@ -4355,10 +4337,10 @@ boolean force;
} }
} else } else
pline("This door was not trapped."); pline("This door was not trapped.");
return (1); return 1;
} else { } else {
You("find no traps on the door."); You("find no traps on the door.");
return (1); return 1;
} }
} }
@@ -4618,7 +4600,7 @@ boolean disarm;
} }
} }
return TRUE; return TRUE;
} } /* case 21 */
case 20: case 20:
case 19: case 19:
case 18: case 18:
@@ -4658,7 +4640,7 @@ boolean disarm;
if (dmg) if (dmg)
losehp(dmg, "electric shock", KILLED_BY_AN); losehp(dmg, "electric shock", KILLED_BY_AN);
break; break;
} } /* case 6 */
case 5: case 5:
case 4: case 4:
case 3: case 3:
@@ -4705,12 +4687,13 @@ t_at(x, y)
register int x, y; register int x, y;
{ {
register struct trap *trap = ftrap; register struct trap *trap = ftrap;
while (trap) { while (trap) {
if (trap->tx == x && trap->ty == y) if (trap->tx == x && trap->ty == y)
return (trap); return trap;
trap = trap->ntrap; trap = trap->ntrap;
} }
return ((struct trap *) 0); return (struct trap *) 0;
} }
void void
@@ -4720,11 +4703,14 @@ register struct trap *trap;
register struct trap *ttmp; register struct trap *ttmp;
clear_conjoined_pits(trap); clear_conjoined_pits(trap);
if (trap == ftrap) if (trap == ftrap) {
ftrap = ftrap->ntrap; ftrap = ftrap->ntrap;
else { } else {
for (ttmp = ftrap; ttmp->ntrap != trap; ttmp = ttmp->ntrap) for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
; if (ttmp->ntrap == trap)
break;
if (!ttmp)
panic("deltrap: no preceding trap!");
ttmp->ntrap = trap->ntrap; ttmp->ntrap = trap->ntrap;
} }
if (Sokoban && (trap->ttyp == PIT || trap->ttyp == HOLE)) if (Sokoban && (trap->ttyp == PIT || trap->ttyp == HOLE))
@@ -4738,6 +4724,7 @@ struct trap *trap2, *trap1;
boolean u_entering_trap2; boolean u_entering_trap2;
{ {
int dx, dy, diridx, adjidx; int dx, dy, diridx, adjidx;
if (!trap1 || !trap2) if (!trap1 || !trap2)
return FALSE; return FALSE;
if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty) if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty)
@@ -4766,13 +4753,14 @@ struct trap *trap;
{ {
int diridx, adjidx, x, y; int diridx, adjidx, x, y;
struct trap *t; struct trap *t;
if (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) { if (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
for (diridx = 0; diridx < 8; ++diridx) { for (diridx = 0; diridx < 8; ++diridx) {
if (trap->conjoined & (1 << diridx)) { if (trap->conjoined & (1 << diridx)) {
x = trap->tx + xdir[diridx]; x = trap->tx + xdir[diridx];
y = trap->ty + ydir[diridx]; y = trap->ty + ydir[diridx];
t = t_at(x, y); if (isok(x, y)
if (isok(x, y) && t && (t = t_at(x, y)) != 0
&& (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
adjidx = (diridx + 4) % 8; adjidx = (diridx + 4) % 8;
t->conjoined &= ~(1 << adjidx); t->conjoined &= ~(1 << adjidx);
@@ -4792,22 +4780,25 @@ STATIC_OVL void
join_adjacent_pits(trap) join_adjacent_pits(trap)
struct trap *trap; struct trap *trap;
{ {
struct trap *t; struct trap *t;
int diridx, x, y; int diridx, x, y;
if (!trap) return;
for(diridx = 0; diridx < 8; ++diridx) { if (!trap)
x = trap->tx + xdir[diridx]; return;
y = trap->ty + ydir[diridx]; for (diridx = 0; diridx < 8; ++diridx) {
if (isok(x,y)) { x = trap->tx + xdir[diridx];
if (((t = t_at(x,y)) != 0) && y = trap->ty + ydir[diridx];
(t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { if (isok(x, y)) {
trap->conjoined |= (1 << diridx); if ((t = t_at(x, y)) != 0
join_adjacent_pits(t); && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
} else trap->conjoined &= ~(1 << diridx); trap->conjoined |= (1 << diridx);
} join_adjacent_pits(t);
} } else
trap->conjoined &= ~(1 << diridx);
}
}
} }
#endif #endif /*0*/
/* /*
* Returns TRUE if you escaped a pit and are standing on the precipice. * Returns TRUE if you escaped a pit and are standing on the precipice.
@@ -4929,12 +4920,14 @@ boolean nocorpse;
boolean boolean
unconscious() unconscious()
{ {
return (boolean)( if (multi >= 0)
multi < 0 return FALSE;
&& (u.usleep || (nomovemsg
&& (!strncmp(nomovemsg, "You awake", 9) return (boolean) (u.usleep
|| !strncmp(nomovemsg, "You regain con", 14) || (nomovemsg
|| !strncmp(nomovemsg, "You are consci", 14))))); && (!strncmp(nomovemsg, "You awake", 9)
|| !strncmp(nomovemsg, "You regain con", 14)
|| !strncmp(nomovemsg, "You are consci", 14))));
} }
static const char lava_killer[] = "molten lava"; static const char lava_killer[] = "molten lava";
@@ -4972,8 +4965,8 @@ lava_effects()
/* Check whether we should burn away boots *first* so we know whether to /* Check whether we should burn away boots *first* so we know whether to
* make the player sink into the lava. Assumption: water walking only * make the player sink into the lava. Assumption: water walking only
* comes * comes from boots.
* from boots. */ */
if (Wwalking && uarmf && is_organic(uarmf) && !uarmf->oerodeproof) { if (Wwalking && uarmf && is_organic(uarmf) && !uarmf->oerodeproof) {
obj = uarmf; obj = uarmf;
pline("%s into flame!", Yobjnam2(obj, "burst")); pline("%s into flame!", Yobjnam2(obj, "burst"));
@@ -5041,7 +5034,7 @@ lava_effects()
pline("You're still burning."); pline("You're still burning.");
} }
You("find yourself back on solid %s.", surface(u.ux, u.uy)); You("find yourself back on solid %s.", surface(u.ux, u.uy));
return (TRUE); return TRUE;
} else if (!Wwalking && (!u.utrap || u.utraptype != TT_LAVA)) { } else if (!Wwalking && (!u.utrap || u.utraptype != TT_LAVA)) {
boil_away = !Fire_resistance; boil_away = !Fire_resistance;
/* if not fire resistant, sink_into_lava() will quickly be fatal; /* if not fire resistant, sink_into_lava() will quickly be fatal;
@@ -5060,7 +5053,7 @@ burn_stuff:
destroy_item(SCROLL_CLASS, AD_FIRE); destroy_item(SCROLL_CLASS, AD_FIRE);
destroy_item(SPBOOK_CLASS, AD_FIRE); destroy_item(SPBOOK_CLASS, AD_FIRE);
destroy_item(POTION_CLASS, AD_FIRE); destroy_item(POTION_CLASS, AD_FIRE);
return (FALSE); return FALSE;
} }
/* called each turn when trapped in lava */ /* called each turn when trapped in lava */
+46 -48
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 uhitm.c $NHDT-Date: 1445126430 2015/10/18 00:00:30 $ $NHDT-Branch: master $:$NHDT-Revision: 1.148 $ */ /* NetHack 3.6 uhitm.c $NHDT-Date: 1446078766 2015/10/29 00:32:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.149 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -116,9 +116,9 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
* If the monster dies immediately from the blow, the 'I' will * If the monster dies immediately from the blow, the 'I' will
* not stay there, so the player will have suddenly forgotten * not stay there, so the player will have suddenly forgotten
* the square's contents for no apparent reason. * the square's contents for no apparent reason.
if (!canspotmon(mtmp) && if (!canspotmon(mtmp)
!glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph)) && !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph))
map_invisible(bhitpos.x, bhitpos.y); map_invisible(bhitpos.x, bhitpos.y);
*/ */
return FALSE; return FALSE;
} }
@@ -139,9 +139,9 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
/* if it was an invisible mimic, treat it as if we stumbled /* if it was an invisible mimic, treat it as if we stumbled
* onto a visible mimic * onto a visible mimic
*/ */
if (mtmp->m_ap_type && !Protection_from_shape_changers && if (mtmp->m_ap_type && !Protection_from_shape_changers
/* applied pole-arm attack is too far to get stuck */ /* applied pole-arm attack is too far to get stuck */
distu(mtmp->mx, mtmp->my) <= 2) { && distu(mtmp->mx, mtmp->my) <= 2) {
if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK)) if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK))
u.ustuck = mtmp; u.ustuck = mtmp;
} }
@@ -157,7 +157,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
*/ */
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) { if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp); seemimic(mtmp);
return (FALSE); return FALSE;
} }
stumble_onto_mimic(mtmp); stumble_onto_mimic(mtmp);
return TRUE; return TRUE;
@@ -170,7 +170,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
newsym(mtmp->mx, mtmp->my); newsym(mtmp->mx, mtmp->my);
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) { if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp); seemimic(mtmp);
return (FALSE); return FALSE;
} }
if (!((Blind ? Blind_telepat : Unblind_telepat) || Detect_monsters)) { if (!((Blind ? Blind_telepat : Unblind_telepat) || Detect_monsters)) {
struct obj *obj; struct obj *obj;
@@ -198,18 +198,18 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
/* Intelligent chaotic weapons (Stormbringer) want blood */ /* Intelligent chaotic weapons (Stormbringer) want blood */
if (wep && wep->oartifact == ART_STORMBRINGER) { if (wep && wep->oartifact == ART_STORMBRINGER) {
override_confirmation = TRUE; override_confirmation = TRUE;
return (FALSE); return FALSE;
} }
if (canspotmon(mtmp)) { if (canspotmon(mtmp)) {
Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp)); Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
if (!paranoid_query(ParanoidHit, qbuf)) { if (!paranoid_query(ParanoidHit, qbuf)) {
context.move = 0; context.move = 0;
return (TRUE); return TRUE;
} }
} }
} }
return (FALSE); return FALSE;
} }
/* /*
@@ -350,13 +350,13 @@ register struct monst *mtmp;
Strcpy(buf, y_monnam(mtmp)); Strcpy(buf, y_monnam(mtmp));
buf[0] = highc(buf[0]); buf[0] = highc(buf[0]);
You("stop. %s is in the way!", buf); You("stop. %s is in the way!", buf);
return (TRUE); return TRUE;
} else if ((mtmp->mfrozen || (!mtmp->mcanmove) } else if ((mtmp->mfrozen || (!mtmp->mcanmove)
|| (mtmp->data->mmove == 0)) && rn2(6)) { || (mtmp->data->mmove == 0)) && rn2(6)) {
pline("%s doesn't seem to move!", Monnam(mtmp)); pline("%s doesn't seem to move!", Monnam(mtmp));
return (TRUE); return TRUE;
} else } else
return (FALSE); return FALSE;
} }
} }
@@ -368,7 +368,7 @@ register struct monst *mtmp;
bhitpos.x = u.ux + u.dx; bhitpos.x = u.ux + u.dx;
bhitpos.y = u.uy + u.dy; bhitpos.y = u.uy + u.dy;
if (attack_checks(mtmp, uwep)) if (attack_checks(mtmp, uwep))
return (TRUE); return TRUE;
if (Upolyd && noattacks(youmonst.data)) { if (Upolyd && noattacks(youmonst.data)) {
/* certain "pacifist" monsters don't attack */ /* certain "pacifist" monsters don't attack */
@@ -377,9 +377,9 @@ register struct monst *mtmp;
goto atk_done; goto atk_done;
} }
if (check_capacity("You cannot fight while so heavily loaded.") || if (check_capacity("You cannot fight while so heavily loaded.")
/* consume extra nutrition during combat; maybe pass out */ /* consume extra nutrition during combat; maybe pass out */
overexertion()) || overexertion())
goto atk_done; goto atk_done;
if (u.twoweap && !can_twoweapon()) if (u.twoweap && !can_twoweapon())
@@ -408,7 +408,7 @@ register struct monst *mtmp;
&& (m_move(mtmp, 0) == 2 || /* it died */ && (m_move(mtmp, 0) == 2 || /* it died */
mtmp->mx != u.ux + u.dx mtmp->mx != u.ux + u.dx
|| mtmp->my != u.uy + u.dy)) /* it moved */ || mtmp->my != u.uy + u.dy)) /* it moved */
return (FALSE); return FALSE;
if (Upolyd) if (Upolyd)
(void) hmonas(mtmp); (void) hmonas(mtmp);
@@ -427,7 +427,7 @@ atk_done:
&& !(u.uswallow && mtmp == u.ustuck)) && !(u.uswallow && mtmp == u.ustuck))
map_invisible(u.ux + u.dx, u.uy + u.dy); map_invisible(u.ux + u.dx, u.uy + u.dy);
return (TRUE); return TRUE;
} }
/* really hit target monster; returns TRUE if it still lives */ /* really hit target monster; returns TRUE if it still lives */
@@ -483,7 +483,7 @@ struct attack *uattk;
cutworm(mon, x, y, weapon); cutworm(mon, x, y, weapon);
} }
} }
return (malive); return malive;
} }
/* hit target monster; returns TRUE if it still lives */ /* hit target monster; returns TRUE if it still lives */
@@ -514,7 +514,7 @@ struct attack *uattk;
if (wepbefore && !uwep) if (wepbefore && !uwep)
wep_was_destroyed = TRUE; wep_was_destroyed = TRUE;
(void) passive(mon, mhit, malive, AT_WEAP, wep_was_destroyed); (void) passive(mon, mhit, malive, AT_WEAP, wep_was_destroyed);
return (malive); return malive;
} }
boolean /* general "damage monster" routine */ boolean /* general "damage monster" routine */
@@ -558,9 +558,9 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
boolean silvermsg = FALSE, silverobj = FALSE; boolean silvermsg = FALSE, silverobj = FALSE;
boolean valid_weapon_attack = FALSE; boolean valid_weapon_attack = FALSE;
boolean unarmed = !uwep && !uarm && !uarms; boolean unarmed = !uwep && !uarm && !uarms;
boolean hand_to_hand = (thrown == HMON_MELEE || boolean hand_to_hand = (thrown == HMON_MELEE
/* not grapnels; applied implies uwep */ /* not grapnels; applied implies uwep */
(thrown == HMON_APPLIED && is_pole(uwep))); || (thrown == HMON_APPLIED && is_pole(uwep)));
int jousting = 0; int jousting = 0;
int wtype; int wtype;
struct obj *monwep; struct obj *monwep;
@@ -602,14 +602,14 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
|| obj->oclass == GEM_CLASS) { || obj->oclass == GEM_CLASS) {
/* is it not a melee weapon? */ /* is it not a melee weapon? */
if (/* if you strike with a bow... */ if (/* if you strike with a bow... */
is_launcher(obj) || is_launcher(obj)
/* or strike with a missile in your hand... */ /* or strike with a missile in your hand... */
(!thrown && (is_missile(obj) || is_ammo(obj))) || || (!thrown && (is_missile(obj) || is_ammo(obj)))
/* or use a pole at short range and not mounted... */ /* or use a pole at short range and not mounted... */
(!thrown && !u.usteed && is_pole(obj)) || || (!thrown && !u.usteed && is_pole(obj))
/* or throw a missile without the proper bow... */ /* or throw a missile without the proper bow... */
(is_ammo(obj) && (thrown != HMON_THROWN || (is_ammo(obj) && (thrown != HMON_THROWN
|| !ammo_and_launcher(obj, uwep)))) { || !ammo_and_launcher(obj, uwep)))) {
/* then do only 1-2 points of damage */ /* then do only 1-2 points of damage */
if (mdat == &mons[PM_SHADE] && !shade_glare(obj)) if (mdat == &mons[PM_SHADE] && !shade_glare(obj))
tmp = 0; tmp = 0;
@@ -644,9 +644,9 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
valid_weapon_attack = (tmp > 1); valid_weapon_attack = (tmp > 1);
if (!valid_weapon_attack || mon == u.ustuck || u.twoweap) { if (!valid_weapon_attack || mon == u.ustuck || u.twoweap) {
; /* no special bonuses */ ; /* no special bonuses */
} else if (mon->mflee && Role_if(PM_ROGUE) && !Upolyd && } else if (mon->mflee && Role_if(PM_ROGUE) && !Upolyd
/* multi-shot throwing is too powerful here */ /* multi-shot throwing is too powerful here */
hand_to_hand) { && hand_to_hand) {
You("strike %s from behind!", mon_nam(mon)); You("strike %s from behind!", mon_nam(mon));
tmp += rnd(u.ulevel); tmp += rnd(u.ulevel);
hittxt = TRUE; hittxt = TRUE;
@@ -759,9 +759,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
ysimple_name(obj)); ysimple_name(obj));
release_camera_demon(obj, u.ux, u.uy); release_camera_demon(obj, u.ux, u.uy);
useup(obj); useup(obj);
return (TRUE); return TRUE;
/*NOTREACHED*/
break;
case CORPSE: /* fixed by polder@cs.vu.nl */ case CORPSE: /* fixed by polder@cs.vu.nl */
if (touch_petrifies(&mons[obj->corpsenm])) { if (touch_petrifies(&mons[obj->corpsenm])) {
tmp = 1; tmp = 1;
@@ -776,10 +774,10 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
if (resists_ston(mon)) if (resists_ston(mon))
break; break;
/* note: hp may be <= 0 even if munstoned==TRUE */ /* note: hp may be <= 0 even if munstoned==TRUE */
return (boolean)(mon->mhp > 0); return (boolean) (mon->mhp > 0);
#if 0 #if 0
} else if (touch_petrifies(mdat)) { } else if (touch_petrifies(mdat)) {
/* maybe turn the corpse into a statue? */ ; /* maybe turn the corpse into a statue? */
#endif #endif
} }
tmp = (obj->corpsenm >= LOW_PM ? mons[obj->corpsenm].msize tmp = (obj->corpsenm >= LOW_PM ? mons[obj->corpsenm].msize
@@ -825,7 +823,7 @@ int thrown; /* HMON_xxx (0 => hand-to-hand, other => ranged) */
minstapetrify(mon, TRUE); minstapetrify(mon, TRUE);
if (resists_ston(mon)) if (resists_ston(mon))
break; break;
return (boolean)(mon->mhp > 0); return (boolean) (mon->mhp > 0);
} else { /* ordinary egg(s) */ } else { /* ordinary egg(s) */
const char *eggp = const char *eggp =
(obj->corpsenm != NON_PM && obj->known) (obj->corpsenm != NON_PM && obj->known)
@@ -1403,7 +1401,7 @@ register struct attack *mattk;
&& u.umonnum != PM_SUCCUBUS && u.umonnum != PM_INCUBUS && u.umonnum != PM_SUCCUBUS && u.umonnum != PM_INCUBUS
&& u.umonnum != PM_BALROG) { && u.umonnum != PM_BALROG) {
demonpet(); demonpet();
return (0); return 0;
} }
switch (mattk->adtyp) { switch (mattk->adtyp) {
case AD_STUN: case AD_STUN:
@@ -1764,9 +1762,9 @@ register struct attack *mattk;
xkilled(mdef, 0); xkilled(mdef, 0);
} else if (tmp) } else if (tmp)
killed(mdef); killed(mdef);
return (2); return 2;
} }
return (1); return 1;
} }
STATIC_OVL int STATIC_OVL int
@@ -1807,7 +1805,7 @@ register struct attack *mattk;
mdef->mhp -= tmp; mdef->mhp -= tmp;
if (mdef->mhp <= 0) { if (mdef->mhp <= 0) {
killed(mdef); killed(mdef);
return (2); return 2;
} }
} else { } else {
shieldeff(mdef->mx, mdef->my); shieldeff(mdef->mx, mdef->my);
@@ -1820,7 +1818,7 @@ register struct attack *mattk;
default: default:
break; break;
} }
return (1); return 1;
} }
STATIC_OVL void STATIC_OVL void
@@ -1957,7 +1955,7 @@ register struct attack *mattk;
exercise(A_CON, TRUE); exercise(A_CON, TRUE);
} }
end_engulf(); end_engulf();
return (2); return 2;
case AD_PHYS: case AD_PHYS:
if (youmonst.data == &mons[PM_FOG_CLOUD]) { if (youmonst.data == &mons[PM_FOG_CLOUD]) {
pline("%s is laden with your moisture.", Monnam(mdef)); pline("%s is laden with your moisture.", Monnam(mdef));
@@ -2032,7 +2030,7 @@ register struct attack *mattk;
if ((mdef->mhp -= dam) <= 0) { if ((mdef->mhp -= dam) <= 0) {
killed(mdef); killed(mdef);
if (mdef->mhp <= 0) /* not lifesaved */ if (mdef->mhp <= 0) /* not lifesaved */
return (2); return 2;
} }
You("%s %s!", is_animal(youmonst.data) ? "regurgitate" : "expel", You("%s %s!", is_animal(youmonst.data) ? "regurgitate" : "expel",
mon_nam(mdef)); mon_nam(mdef));
@@ -2042,7 +2040,7 @@ register struct attack *mattk;
} }
} }
} }
return (0); return 0;
} }
void void
@@ -2105,7 +2103,7 @@ register struct monst *mon;
sum[i] = dhit; sum[i] = dhit;
/* might be a worm that gets cut in half */ /* might be a worm that gets cut in half */
if (m_at(u.ux + u.dx, u.uy + u.dy) != mon) if (m_at(u.ux + u.dx, u.uy + u.dy) != mon)
return (boolean)(nsum != 0); return (boolean) (nsum != 0);
/* Do not print "You hit" message, since known_hitum /* Do not print "You hit" message, since known_hitum
* already did it. * already did it.
*/ */
@@ -2247,7 +2245,7 @@ register struct monst *mon;
rehumanize(); rehumanize();
} }
if (sum[i] == 2) if (sum[i] == 2)
return ((boolean) passive(mon, 1, 0, mattk->aatyp, FALSE)); return (boolean) passive(mon, 1, 0, mattk->aatyp, FALSE);
/* defender dead */ /* defender dead */
else { else {
(void) passive(mon, sum[i], 1, mattk->aatyp, FALSE); (void) passive(mon, sum[i], 1, mattk->aatyp, FALSE);
@@ -2258,7 +2256,7 @@ register struct monst *mon;
if (multi < 0) if (multi < 0)
break; /* If paralyzed while attacking, i.e. floating eye */ break; /* If paralyzed while attacking, i.e. floating eye */
} }
return ((boolean)(nsum != 0)); return (boolean) (nsum != 0);
} }
/* Special (passive) attacks on you by monsters done here. */ /* Special (passive) attacks on you by monsters done here. */
+60 -56
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 vault.c $NHDT-Date: 1432512773 2015/05/25 00:12:53 $ $NHDT-Branch: master $:$NHDT-Revision: 1.38 $ */ /* NetHack 3.6 vault.c $NHDT-Date: 1446078792 2015/10/29 00:33:12 $ $NHDT-Branch: master $:$NHDT-Revision: 1.39 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -126,7 +126,7 @@ int x, y;
STATIC_OVL void STATIC_OVL void
restfakecorr(grd) restfakecorr(grd)
register struct monst *grd; struct monst *grd;
{ {
/* it seems you left the corridor - let the guard disappear */ /* it seems you left the corridor - let the guard disappear */
if (clear_fcorr(grd, FALSE)) { if (clear_fcorr(grd, FALSE)) {
@@ -135,10 +135,12 @@ register struct monst *grd;
} }
} }
boolean grddead(grd) /* called in mon.c */ /* called in mon.c */
register struct monst *grd; boolean
grddead(grd)
struct monst *grd;
{ {
register boolean dispose = clear_fcorr(grd, TRUE); boolean dispose = clear_fcorr(grd, TRUE);
if (!dispose) { if (!dispose) {
/* destroy guard's gold; drop any other inventory */ /* destroy guard's gold; drop any other inventory */
@@ -162,16 +164,16 @@ register struct monst *grd;
STATIC_OVL boolean STATIC_OVL boolean
in_fcorridor(grd, x, y) in_fcorridor(grd, x, y)
register struct monst *grd; struct monst *grd;
int x, y; int x, y;
{ {
register int fci; register int fci;
struct egd *egrd = EGD(grd);
for (fci = EGD(grd)->fcbeg; fci < EGD(grd)->fcend; fci++) for (fci = egrd->fcbeg; fci < egrd->fcend; fci++)
if (x == EGD(grd)->fakecorr[fci].fx if (x == egrd->fakecorr[fci].fx && y == egrd->fakecorr[fci].fy)
&& y == EGD(grd)->fakecorr[fci].fy) return TRUE;
return (TRUE); return FALSE;
return (FALSE);
} }
STATIC_OVL STATIC_OVL
@@ -184,9 +186,9 @@ findgd()
if (DEADMONSTER(mtmp)) if (DEADMONSTER(mtmp))
continue; continue;
if (mtmp->isgd && on_level(&(EGD(mtmp)->gdlevel), &u.uz)) if (mtmp->isgd && on_level(&(EGD(mtmp)->gdlevel), &u.uz))
return (mtmp); return mtmp;
} }
return ((struct monst *) 0); return (struct monst *) 0;
} }
char char
@@ -197,8 +199,8 @@ char *array;
for (ptr = array; *ptr; ptr++) for (ptr = array; *ptr; ptr++)
if (rooms[*ptr - ROOMOFFSET].rtype == VAULT) if (rooms[*ptr - ROOMOFFSET].rtype == VAULT)
return (*ptr); return *ptr;
return ('\0'); return '\0';
} }
void void
@@ -376,10 +378,9 @@ invault()
(void) mungspaces(buf); (void) mungspaces(buf);
} while (!letter(buf[0]) && --trycount > 0); } while (!letter(buf[0]) && --trycount > 0);
if (u.ualign.type == A_LAWFUL && if (u.ualign.type == A_LAWFUL
/* ignore trailing text, in case player includes character's rank /* ignore trailing text, in case player includes rank */
*/ && strncmpi(buf, plname, (int) strlen(plname)) != 0) {
strncmpi(buf, plname, (int) strlen(plname)) != 0) {
adjalign(-1); /* Liar! */ adjalign(-1); /* Liar! */
} }
@@ -542,18 +543,17 @@ register struct monst *grd;
uchar typ; uchar typ;
struct fakecorridor *fcp; struct fakecorridor *fcp;
register struct egd *egrd = EGD(grd); register struct egd *egrd = EGD(grd);
register struct rm *crm; struct rm *crm;
register boolean goldincorridor = FALSE, boolean goldincorridor = FALSE,
u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE, u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE,
grd_in_vault = grd_in_vault = *in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
*in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
boolean disappear_msg_seen = FALSE, semi_dead = (grd->mhp <= 0); boolean disappear_msg_seen = FALSE, semi_dead = (grd->mhp <= 0);
long umoney = money_cnt(invent); long umoney = money_cnt(invent);
register boolean u_carry_gold = ((umoney + hidden_gold()) > 0L); register boolean u_carry_gold = ((umoney + hidden_gold()) > 0L);
boolean see_guard, newspot = FALSE; boolean see_guard, newspot = FALSE;
if (!on_level(&(egrd->gdlevel), &u.uz)) if (!on_level(&(egrd->gdlevel), &u.uz))
return (-1); return -1;
nx = ny = m = n = 0; nx = ny = m = n = 0;
if (!u_in_vault && !grd_in_vault) if (!u_in_vault && !grd_in_vault)
wallify_vault(grd); wallify_vault(grd);
@@ -572,17 +572,17 @@ register struct monst *grd;
} }
if (!in_fcorridor(grd, grd->mx, grd->my)) if (!in_fcorridor(grd, grd->mx, grd->my))
(void) clear_fcorr(grd, TRUE); (void) clear_fcorr(grd, TRUE);
return (-1); return -1;
} }
if (abs(egrd->ogx - grd->mx) > 1 || abs(egrd->ogy - grd->my) > 1) if (abs(egrd->ogx - grd->mx) > 1 || abs(egrd->ogy - grd->my) > 1)
return (-1); /* teleported guard - treat as monster */ return -1; /* teleported guard - treat as monster */
if (egrd->witness) { if (egrd->witness) {
verbalize("How dare you %s that gold, scoundrel!", verbalize("How dare you %s that gold, scoundrel!",
(egrd->witness & GD_EATGOLD) ? "consume" : "destroy"); (egrd->witness & GD_EATGOLD) ? "consume" : "destroy");
egrd->witness = 0; egrd->witness = 0;
grd->mpeaceful = 0; grd->mpeaceful = 0;
return (-1); return -1;
} }
if (egrd->fcend == 1) { if (egrd->fcend == 1) {
if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) { if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
@@ -601,12 +601,12 @@ register struct monst *grd;
levl[m][n].typ = egrd->fakecorr[0].ftyp; levl[m][n].typ = egrd->fakecorr[0].ftyp;
newsym(m, n); newsym(m, n);
grd->mpeaceful = 0; grd->mpeaceful = 0;
return (-1); return -1;
} }
/* not fair to get mad when (s)he's fainted or paralyzed */ /* not fair to get mad when (s)he's fainted or paralyzed */
if (!is_fainted() && multi >= 0) if (!is_fainted() && multi >= 0)
egrd->warncnt++; egrd->warncnt++;
return (0); return 0;
} }
if (!u_in_vault) { if (!u_in_vault) {
@@ -626,7 +626,7 @@ register struct monst *grd;
: "are confronted by %s.", : "are confronted by %s.",
/* "an angry guard" */ /* "an angry guard" */
x_monnam(grd, ARTICLE_A, "angry", 0, FALSE)); x_monnam(grd, ARTICLE_A, "angry", 0, FALSE));
return (-1); return -1;
} else { } else {
if (!Deaf) if (!Deaf)
verbalize("Well, begone."); verbalize("Well, begone.");
@@ -646,23 +646,23 @@ register struct monst *grd;
disappear_msg_seen = TRUE; disappear_msg_seen = TRUE;
goto cleanup; goto cleanup;
} }
if (u_carry_gold && (in_fcorridor(grd, u.ux, u.uy) || if (u_carry_gold && (in_fcorridor(grd, u.ux, u.uy)
/* cover a 'blind' spot */ /* cover a 'blind' spot */
(egrd->fcend > 1 && u_in_vault))) { || (egrd->fcend > 1 && u_in_vault))) {
if (!grd->mx) { if (!grd->mx) {
restfakecorr(grd); restfakecorr(grd);
return (-2); return -2;
} }
if (egrd->warncnt < 6) { if (egrd->warncnt < 6) {
egrd->warncnt = 6; egrd->warncnt = 6;
if (!Deaf) if (!Deaf)
verbalize("Drop all your gold, scoundrel!"); verbalize("Drop all your gold, scoundrel!");
return (0); return 0;
} else { } else {
if (!Deaf) if (!Deaf)
verbalize("So be it, rogue!"); verbalize("So be it, rogue!");
grd->mpeaceful = 0; grd->mpeaceful = 0;
return (-1); return -1;
} }
} }
} }
@@ -714,7 +714,7 @@ register struct monst *grd;
&& !(u.ustuck && !sticks(youmonst.data))) && !(u.ustuck && !sticks(youmonst.data)))
verbalize("Move along!"); verbalize("Move along!");
restfakecorr(grd); restfakecorr(grd);
return (0); /* didn't move */ return 0; /* didn't move */
} }
x = grd->mx; x = grd->mx;
y = grd->my; y = grd->my;
@@ -810,15 +810,15 @@ proceed:
fcp->ftyp = typ; fcp->ftyp = typ;
newpos: newpos:
if (egrd->gddone) { if (egrd->gddone) {
/* The following is a kludge. We need to keep */ /* The following is a kludge. We need to keep */
/* the guard around in order to be able to make */ /* the guard around in order to be able to make */
/* the fake corridor disappear as the player */ /* the fake corridor disappear as the player */
/* moves out of it, but we also need the guard */ /* moves out of it, but we also need the guard */
/* out of the way. We send the guard to never- */ /* out of the way. We send the guard to never- */
/* never land. We set ogx ogy to mx my in order */ /* never land. We set ogx ogy to mx my in order */
/* to avoid a check at the top of this function. */ /* to avoid a check at the top of this function. */
/* At the end of the process, the guard is killed */ /* At the end of the process, the guard is killed */
/* in restfakecorr(). */ /* in restfakecorr(). */
cleanup: cleanup:
x = grd->mx; x = grd->mx;
y = grd->my; y = grd->my;
@@ -834,9 +834,9 @@ newpos:
if (!semi_dead && (in_fcorridor(grd, u.ux, u.uy) || cansee(x, y))) { if (!semi_dead && (in_fcorridor(grd, u.ux, u.uy) || cansee(x, y))) {
if (!disappear_msg_seen && see_guard) if (!disappear_msg_seen && see_guard)
pline("Suddenly, %s disappears.", noit_mon_nam(grd)); pline("Suddenly, %s disappears.", noit_mon_nam(grd));
return (1); return 1;
} }
return (-2); return -2;
} }
egrd->ogx = grd->mx; /* update old positions */ egrd->ogx = grd->mx; /* update old positions */
egrd->ogy = grd->my; egrd->ogy = grd->my;
@@ -852,7 +852,7 @@ newpos:
} else } else
newsym(grd->mx, grd->my); newsym(grd->mx, grd->my);
restfakecorr(grd); restfakecorr(grd);
return (1); return 1;
} }
/* Routine when dying or quitting with a vault guard around */ /* Routine when dying or quitting with a vault guard around */
@@ -900,25 +900,27 @@ paygd()
long long
hidden_gold() hidden_gold()
{ {
register long value = 0L; long value = 0L;
register struct obj *obj; struct obj *obj;
for (obj = invent; obj; obj = obj->nobj) for (obj = invent; obj; obj = obj->nobj)
if (Has_contents(obj)) if (Has_contents(obj))
value += contained_gold(obj); value += contained_gold(obj);
/* unknown gold stuck inside statues may cause some consternation... */ /* unknown gold stuck inside statues may cause some consternation... */
return (value); return value;
} }
boolean gd_sound() /* prevent "You hear footsteps.." when inappropriate */ /* prevent "You hear footsteps.." when inappropriate */
boolean
gd_sound()
{ {
register struct monst *grd = findgd(); struct monst *grd = findgd();
if (vault_occupied(u.urooms)) if (vault_occupied(u.urooms))
return (FALSE); return FALSE;
else else
return ((boolean)(grd == (struct monst *) 0)); return (boolean) (grd == (struct monst *) 0);
} }
void void
@@ -926,9 +928,11 @@ vault_gd_watching(activity)
unsigned int activity; unsigned int activity;
{ {
struct monst *guard = findgd(); struct monst *guard = findgd();
if (guard && guard->mcansee && m_canseeu(guard)) { if (guard && guard->mcansee && m_canseeu(guard)) {
if (activity == GD_EATGOLD || activity == GD_DESTROYGOLD) if (activity == GD_EATGOLD || activity == GD_DESTROYGOLD)
EGD(guard)->witness = activity; EGD(guard)->witness = activity;
} }
} }
/*vault.c*/ /*vault.c*/
+81 -71
View File
@@ -1,11 +1,11 @@
/* NetHack 3.6 weapon.c $NHDT-Date: 1445126431 2015/10/18 00:00:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.54 $ */ /* NetHack 3.6 weapon.c $NHDT-Date: 1446078767 2015/10/29 00:32:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.55 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* /*
* This module contains code for calculation of "to hit" and damage * This module contains code for calculation of "to hit" and damage
* bonuses for any given weapon used, as well as weapons selection * bonuses for any given weapon used, as well as weapons selection
* code for monsters. * code for monsters.
*/ */
#include "hack.h" #include "hack.h"
@@ -135,8 +135,8 @@ struct obj *obj;
} }
/* /*
* hitval returns an integer representing the "to hit" bonuses * hitval returns an integer representing the "to hit" bonuses
* of "otmp" against the monster. * of "otmp" against the monster.
*/ */
int int
hitval(otmp, mon) hitval(otmp, mon)
@@ -150,10 +150,10 @@ struct monst *mon;
if (Is_weapon) if (Is_weapon)
tmp += otmp->spe; tmp += otmp->spe;
/* Put weapon specific "to hit" bonuses in below: */ /* Put weapon specific "to hit" bonuses in below: */
tmp += objects[otmp->otyp].oc_hitbon; tmp += objects[otmp->otyp].oc_hitbon;
/* Put weapon vs. monster type "to hit" bonuses in below: */ /* Put weapon vs. monster type "to hit" bonuses in below: */
/* Blessed weapons used against undead or demons */ /* Blessed weapons used against undead or demons */
if (Is_weapon && otmp->blessed if (Is_weapon && otmp->blessed
@@ -205,8 +205,8 @@ struct monst *mon;
*/ */
/* /*
* dmgval returns an integer representing the damage bonuses * dmgval returns an integer representing the damage bonuses
* of "otmp" against the monster. * of "otmp" against the monster.
*/ */
int int
dmgval(otmp, mon) dmgval(otmp, mon)
@@ -316,7 +316,7 @@ struct monst *mon;
} }
} }
/* Put weapon vs. monster type damage bonuses in below: */ /* Put weapon vs. monster type damage bonuses in below: */
if (Is_weapon || otmp->oclass == GEM_CLASS || otmp->oclass == BALL_CLASS if (Is_weapon || otmp->oclass == GEM_CLASS || otmp->oclass == BALL_CLASS
|| otmp->oclass == CHAIN_CLASS) { || otmp->oclass == CHAIN_CLASS) {
int bonus = 0; int bonus = 0;
@@ -348,13 +348,13 @@ struct monst *mon;
tmp = 1; tmp = 1;
} }
return (tmp); return tmp;
} }
STATIC_DCL struct obj *FDECL(oselect, (struct monst *, int)); STATIC_DCL struct obj *FDECL(oselect, (struct monst *, int));
#define Oselect(x) \ #define Oselect(x) \
if ((otmp = oselect(mtmp, x)) != 0) \ if ((otmp = oselect(mtmp, x)) != 0) \
return (otmp); return otmp;
STATIC_OVL struct obj * STATIC_OVL struct obj *
oselect(mtmp, x) oselect(mtmp, x)
@@ -365,10 +365,9 @@ int x;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) { for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otmp->otyp == x if (otmp->otyp == x
&&
/* never select non-cockatrice corpses */ /* never select non-cockatrice corpses */
!((x == CORPSE || x == EGG) && !((x == CORPSE || x == EGG)
&& !touch_petrifies(&mons[otmp->corpsenm])) && !touch_petrifies(&mons[otmp->corpsenm]))
&& (!otmp->oartifact || touch_artifact(otmp, mtmp))) && (!otmp->oartifact || touch_artifact(otmp, mtmp)))
return otmp; return otmp;
} }
@@ -391,7 +390,9 @@ static NEARDATA const int pwep[] = { HALBERD, BARDICHE, SPETUM,
static struct obj *propellor; static struct obj *propellor;
struct obj *select_rwep(mtmp) /* select a ranged weapon for the monster */ /* select a ranged weapon for the monster */
struct obj *
select_rwep(mtmp)
register struct monst *mtmp; register struct monst *mtmp;
{ {
register struct obj *otmp; register struct obj *otmp;
@@ -497,7 +498,7 @@ register struct monst *mtmp;
/* Don't throw a cursed weapon-in-hand or an artifact */ /* Don't throw a cursed weapon-in-hand or an artifact */
if ((otmp = oselect(mtmp, rwep[i])) && !otmp->oartifact if ((otmp = oselect(mtmp, rwep[i])) && !otmp->oartifact
&& !(otmp == MON_WEP(mtmp) && mwelded(otmp))) && !(otmp == MON_WEP(mtmp) && mwelded(otmp)))
return (otmp); return otmp;
} else } else
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) { for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otmp->otyp == LOADSTONE && !otmp->cursed) if (otmp->otyp == LOADSTONE && !otmp->cursed)
@@ -523,8 +524,9 @@ static const NEARDATA short hwep[] = {
SCALPEL, KNIFE, WORM_TOOTH SCALPEL, KNIFE, WORM_TOOTH
}; };
/* select a hand to hand weapon for the monster */
struct obj * struct obj *
select_hwep(mtmp) /* select a hand to hand weapon for the monster */ select_hwep(mtmp)
register struct monst *mtmp; register struct monst *mtmp;
{ {
register struct obj *otmp; register struct obj *otmp;
@@ -772,7 +774,7 @@ abon()
else if (dex < 8) else if (dex < 8)
return (sbon - 1); return (sbon - 1);
else if (dex < 14) else if (dex < 14)
return (sbon); return sbon;
else else
return (sbon + dex - 14); return (sbon + dex - 14);
} }
@@ -784,24 +786,24 @@ dbon()
int str = ACURR(A_STR); int str = ACURR(A_STR);
if (Upolyd) if (Upolyd)
return (0); return 0;
if (str < 6) if (str < 6)
return (-1); return -1;
else if (str < 16) else if (str < 16)
return (0); return 0;
else if (str < 18) else if (str < 18)
return (1); return 1;
else if (str == 18) else if (str == 18)
return (2); /* up to 18 */ return 2; /* up to 18 */
else if (str <= STR18(75)) else if (str <= STR18(75))
return (3); /* up to 18/75 */ return 3; /* up to 18/75 */
else if (str <= STR18(90)) else if (str <= STR18(90))
return (4); /* up to 18/90 */ return 4; /* up to 18/90 */
else if (str < STR18(100)) else if (str < STR18(100))
return (5); /* up to 18/99 */ return 5; /* up to 18/99 */
else else
return (6); return 6;
} }
/* increase a towel's wetness */ /* increase a towel's wetness */
@@ -909,19 +911,19 @@ int skill;
int tmp = P_SKILL(skill); int tmp = P_SKILL(skill);
/* The more difficult the training, the more slots it takes. /* The more difficult the training, the more slots it takes.
* unskilled -> basic 1 * unskilled -> basic 1
* basic -> skilled 2 * basic -> skilled 2
* skilled -> expert 3 * skilled -> expert 3
*/ */
if (skill <= P_LAST_WEAPON || skill == P_TWO_WEAPON_COMBAT) if (skill <= P_LAST_WEAPON || skill == P_TWO_WEAPON_COMBAT)
return tmp; return tmp;
/* Fewer slots used up for unarmed or martial. /* Fewer slots used up for unarmed or martial.
* unskilled -> basic 1 * unskilled -> basic 1
* basic -> skilled 1 * basic -> skilled 1
* skilled -> expert 2 * skilled -> expert 2
* expert -> master 2 * expert -> master 2
* master -> grand master 3 * master -> grand master 3
*/ */
return (tmp + 1) / 2; return (tmp + 1) / 2;
} }
@@ -933,12 +935,17 @@ can_advance(skill, speedy)
int skill; int skill;
boolean speedy; boolean speedy;
{ {
return !P_RESTRICTED(skill) && P_SKILL(skill) < P_MAX_SKILL(skill) if (P_RESTRICTED(skill)
&& ((wizard && speedy) || P_SKILL(skill) >= P_MAX_SKILL(skill)
|| (P_ADVANCE(skill) >= (unsigned) practice_needed_to_advance( || u.skills_advanced >= P_SKILL_LIMIT)
P_SKILL(skill)) return FALSE;
&& u.skills_advanced < P_SKILL_LIMIT
&& u.weapon_slots >= slots_required(skill))); if (wizard && speedy)
return TRUE;
return (boolean) ((int) P_ADVANCE(skill)
>= practice_needed_to_advance(P_SKILL(skill))
&& u.weapon_slots >= slots_required(skill));
} }
/* return true if this skill could be advanced if more slots were available */ /* return true if this skill could be advanced if more slots were available */
@@ -946,10 +953,13 @@ STATIC_OVL boolean
could_advance(skill) could_advance(skill)
int skill; int skill;
{ {
return !P_RESTRICTED(skill) && P_SKILL(skill) < P_MAX_SKILL(skill) if (P_RESTRICTED(skill)
&& ((P_ADVANCE(skill) || P_SKILL(skill) >= P_MAX_SKILL(skill)
>= (unsigned) practice_needed_to_advance(P_SKILL(skill)) || u.skills_advanced >= P_SKILL_LIMIT)
&& u.skills_advanced < P_SKILL_LIMIT)); return FALSE;
return (boolean) ((int) P_ADVANCE(skill)
>= practice_needed_to_advance(P_SKILL(skill)));
} }
/* return true if this skill has reached its maximum and there's been enough /* return true if this skill has reached its maximum and there's been enough
@@ -958,9 +968,12 @@ STATIC_OVL boolean
peaked_skill(skill) peaked_skill(skill)
int skill; int skill;
{ {
return !P_RESTRICTED(skill) && P_SKILL(skill) >= P_MAX_SKILL(skill) if (P_RESTRICTED(skill))
&& ((P_ADVANCE(skill) return FALSE;
>= (unsigned) practice_needed_to_advance(P_SKILL(skill))));
return (boolean) (P_SKILL(skill) >= P_MAX_SKILL(skill)
&& ((int) P_ADVANCE(skill)
>= practice_needed_to_advance(P_SKILL(skill))));
} }
STATIC_OVL void STATIC_OVL void
@@ -1186,8 +1199,7 @@ int n; /* number of slots to lose; normally one */
int skill; int skill;
while (--n >= 0) { while (--n >= 0) {
/* deduct first from unused slots, then from last placed slot, if any /* deduct first from unused slots then from last placed one, if any */
*/
if (u.weapon_slots) { if (u.weapon_slots) {
u.weapon_slots--; u.weapon_slots--;
} else if (u.skills_advanced) { } else if (u.skills_advanced) {
@@ -1212,14 +1224,12 @@ struct obj *obj;
int type; int type;
if (!obj) if (!obj)
/* Not using a weapon */ return P_BARE_HANDED_COMBAT; /* Not using a weapon */
return (P_BARE_HANDED_COMBAT);
if (obj->oclass != WEAPON_CLASS && obj->oclass != TOOL_CLASS if (obj->oclass != WEAPON_CLASS && obj->oclass != TOOL_CLASS
&& obj->oclass != GEM_CLASS) && obj->oclass != GEM_CLASS)
/* Not a weapon, weapon-tool, or ammo */ return P_NONE; /* Not a weapon, weapon-tool, or ammo */
return (P_NONE);
type = objects[obj->otyp].oc_skill; type = objects[obj->otyp].oc_skill;
return ((type < 0) ? -type : type); return (type < 0) ? -type : type;
} }
int int
@@ -1290,13 +1300,13 @@ struct obj *weapon;
} }
} else if (type == P_BARE_HANDED_COMBAT) { } else if (type == P_BARE_HANDED_COMBAT) {
/* /*
* b.h. m.a. * b.h. m.a.
* unskl: +1 n/a * unskl: +1 n/a
* basic: +1 +3 * basic: +1 +3
* skild: +2 +4 * skild: +2 +4
* exprt: +2 +5 * exprt: +2 +5
* mastr: +3 +6 * mastr: +3 +6
* grand: +3 +7 * grand: +3 +7
*/ */
bonus = P_SKILL(type); bonus = P_SKILL(type);
bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */ bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */
@@ -1384,13 +1394,13 @@ struct obj *weapon;
} }
} else if (type == P_BARE_HANDED_COMBAT) { } else if (type == P_BARE_HANDED_COMBAT) {
/* /*
* b.h. m.a. * b.h. m.a.
* unskl: 0 n/a * unskl: 0 n/a
* basic: +1 +3 * basic: +1 +3
* skild: +1 +4 * skild: +1 +4
* exprt: +2 +6 * exprt: +2 +6
* mastr: +2 +7 * mastr: +2 +7
* grand: +3 +9 * grand: +3 +9
*/ */
bonus = P_SKILL(type); bonus = P_SKILL(type);
bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */ bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */
+71 -72
View File
@@ -1,11 +1,11 @@
/* NetHack 3.6 wizard.c $NHDT-Date: 1436753529 2015/07/13 02:12:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.39 $ */ /* NetHack 3.6 wizard.c $NHDT-Date: 1446078768 2015/10/29 00:32:48 $ $NHDT-Branch: master $:$NHDT-Revision: 1.42 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */ /* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
/* - heavily modified to give the wiz balls. (genat!mike) */ /* - heavily modified to give the wiz balls. (genat!mike) */
/* - dewimped and given some maledictions. -3. */ /* - dewimped and given some maledictions. -3. */
/* - generalized for 3.1 (mike@bullns.on01.bull.ca) */ /* - generalized for 3.1 (mike@bullns.on01.bull.ca) */
#include "hack.h" #include "hack.h"
#include "qtext.h" #include "qtext.h"
@@ -47,8 +47,8 @@ amulet()
struct obj *amu; struct obj *amu;
#if 0 /* caller takes care of this check */ #if 0 /* caller takes care of this check */
if (!u.uhave.amulet) if (!u.uhave.amulet)
return; return;
#endif #endif
if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR) if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
|| ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR)) || ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
@@ -92,8 +92,8 @@ register struct monst *mtmp;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->otyp == AMULET_OF_YENDOR) if (otmp->otyp == AMULET_OF_YENDOR)
return (1); return 1;
return (0); return 0;
} }
int int
@@ -107,16 +107,16 @@ register struct monst *mtmp;
|| otmp->otyp == BELL_OF_OPENING || otmp->otyp == BELL_OF_OPENING
|| otmp->otyp == CANDELABRUM_OF_INVOCATION || otmp->otyp == CANDELABRUM_OF_INVOCATION
|| otmp->otyp == SPE_BOOK_OF_THE_DEAD) || otmp->otyp == SPE_BOOK_OF_THE_DEAD)
return (1); return 1;
return (0); return 0;
} }
/* /*
* New for 3.1 Strategy / Tactics for the wiz, as well as other * New for 3.1 Strategy / Tactics for the wiz, as well as other
* monsters that are "after" something (defined via mflag3). * monsters that are "after" something (defined via mflag3).
* *
* The strategy section decides *what* the monster is going * The strategy section decides *what* the monster is going
* to attempt, the tactics section implements the decision. * to attempt, the tactics section implements the decision.
*/ */
#define STRAT(w, x, y, typ) \ #define STRAT(w, x, y, typ) \
((unsigned long) (w) | ((unsigned long) (x) << 16) \ ((unsigned long) (w) | ((unsigned long) (x) << 16) \
@@ -130,23 +130,23 @@ register int mask;
{ {
switch (mask) { switch (mask) {
case M3_WANTSAMUL: case M3_WANTSAMUL:
return (AMULET_OF_YENDOR); return AMULET_OF_YENDOR;
case M3_WANTSBELL: case M3_WANTSBELL:
return (BELL_OF_OPENING); return BELL_OF_OPENING;
case M3_WANTSCAND: case M3_WANTSCAND:
return (CANDELABRUM_OF_INVOCATION); return CANDELABRUM_OF_INVOCATION;
case M3_WANTSBOOK: case M3_WANTSBOOK:
return (SPE_BOOK_OF_THE_DEAD); return SPE_BOOK_OF_THE_DEAD;
default: default:
break; /* 0 signifies quest artifact */ break; /* 0 signifies quest artifact */
} }
return (0); return 0;
} }
/* /*
* If "otyp" is zero, it triggers a check for the quest_artifact, * If "otyp" is zero, it triggers a check for the quest_artifact,
* since bell, book, candle, and amulet are all objects, not really * since bell, book, candle, and amulet are all objects, not really
* artifacts right now. [MRS] * artifacts right now. [MRS]
*/ */
STATIC_OVL boolean STATIC_OVL boolean
mon_has_arti(mtmp, otyp) mon_has_arti(mtmp, otyp)
@@ -158,11 +158,11 @@ register short otyp;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) { for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otyp) { if (otyp) {
if (otmp->otyp == otyp) if (otmp->otyp == otyp)
return (1); return 1;
} else if (is_quest_artifact(otmp)) } else if (is_quest_artifact(otmp))
return (1); return 1;
} }
return (0); return 0;
} }
STATIC_OVL struct monst * STATIC_OVL struct monst *
@@ -176,9 +176,9 @@ register short otyp;
/* no need for !DEADMONSTER check here since they have no inventory */ /* no need for !DEADMONSTER check here since they have no inventory */
if (mtmp2 != mtmp) if (mtmp2 != mtmp)
if (mon_has_arti(mtmp2, otyp)) if (mon_has_arti(mtmp2, otyp))
return (mtmp2); return mtmp2;
return ((struct monst *) 0); return (struct monst *) 0;
} }
STATIC_OVL struct obj * STATIC_OVL struct obj *
@@ -190,10 +190,10 @@ register short otyp;
for (otmp = fobj; otmp; otmp = otmp->nobj) for (otmp = fobj; otmp; otmp = otmp->nobj)
if (otyp) { if (otyp) {
if (otmp->otyp == otyp) if (otmp->otyp == otyp)
return (otmp); return otmp;
} else if (is_quest_artifact(otmp)) } else if (is_quest_artifact(otmp))
return (otmp); return otmp;
return ((struct obj *) 0); return (struct obj *) 0;
} }
STATIC_OVL boolean STATIC_OVL boolean
@@ -202,19 +202,19 @@ register int mask;
{ {
switch (mask) { switch (mask) {
case M3_WANTSAMUL: case M3_WANTSAMUL:
return (boolean)(u.uhave.amulet); return (boolean) u.uhave.amulet;
case M3_WANTSBELL: case M3_WANTSBELL:
return (boolean)(u.uhave.bell); return (boolean) u.uhave.bell;
case M3_WANTSCAND: case M3_WANTSCAND:
return (boolean)(u.uhave.menorah); return (boolean) u.uhave.menorah;
case M3_WANTSBOOK: case M3_WANTSBOOK:
return (boolean)(u.uhave.book); return (boolean) u.uhave.book;
case M3_WANTSARTI: case M3_WANTSARTI:
return (boolean)(u.uhave.questart); return (boolean) u.uhave.questart;
default: default:
break; break;
} }
return (0); return 0;
} }
STATIC_OVL unsigned long STATIC_OVL unsigned long
@@ -232,15 +232,15 @@ register struct monst *mtmp;
otyp = which_arti(mask); otyp = which_arti(mask);
if (!mon_has_arti(mtmp, otyp)) { if (!mon_has_arti(mtmp, otyp)) {
if (you_have(mask)) if (you_have(mask))
return (STRAT(STRAT_PLAYER, u.ux, u.uy, mask)); return STRAT(STRAT_PLAYER, u.ux, u.uy, mask);
else if ((otmp = on_ground(otyp))) else if ((otmp = on_ground(otyp)))
return (STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask)); return STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask);
else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0 && else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
/* when seeking the Amulet, avoid targetting the Wizard /* when seeking the Amulet, avoid targetting the Wizard
or temple priests (to protect Moloch's high priest) */ or temple priests (to protect Moloch's high priest) */
(otyp != AMULET_OF_YENDOR && (otyp != AMULET_OF_YENDOR
|| (!mtmp2->iswiz && !inhistemple(mtmp2)))) || (!mtmp2->iswiz && !inhistemple(mtmp2))))
return (STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask)); return STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask);
} }
return (unsigned long) STRAT_NONE; return (unsigned long) STRAT_NONE;
} }
@@ -251,24 +251,24 @@ register struct monst *mtmp;
{ {
unsigned long strat, dstrat; unsigned long strat, dstrat;
if (!is_covetous(mtmp->data) || if (!is_covetous(mtmp->data)
/* perhaps a shopkeeper has been polymorphed into a master /* perhaps a shopkeeper has been polymorphed into a master
lich; we don't want it teleporting to the stairs to heal lich; we don't want it teleporting to the stairs to heal
because that will leave its shop untended */ because that will leave its shop untended */
(mtmp->isshk && inhishop(mtmp)) || || (mtmp->isshk && inhishop(mtmp))
/* likewise for temple priests */ /* likewise for temple priests */
(mtmp->ispriest && inhistemple(mtmp))) || (mtmp->ispriest && inhistemple(mtmp)))
return (unsigned long) STRAT_NONE; return (unsigned long) STRAT_NONE;
switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */ switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */
default: default:
case 0: /* panic time - mtmp is almost snuffed */ case 0: /* panic time - mtmp is almost snuffed */
return (unsigned long) (STRAT_HEAL); return (unsigned long) STRAT_HEAL;
case 1: /* the wiz is less cautious */ case 1: /* the wiz is less cautious */
if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR]) if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
return (unsigned long) (STRAT_HEAL); return (unsigned long) STRAT_HEAL;
/* else fall through */ /* else fall through */
case 2: case 2:
@@ -282,29 +282,28 @@ register struct monst *mtmp;
if (context.made_amulet) if (context.made_amulet)
if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
return (strat); return strat;
if (u.uevent.invoked) { /* priorities change once gate opened */ if (u.uevent.invoked) { /* priorities change once gate opened */
if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
return (strat); return strat;
} else { } else {
if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
return (strat); return strat;
if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE) if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
return (strat); return strat;
} }
return (dstrat); return dstrat;
} }
int int
@@ -333,14 +332,14 @@ register struct monst *mtmp;
if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM)) if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
if (mtmp->mhp <= mtmp->mhpmax - 8) { if (mtmp->mhp <= mtmp->mhpmax - 8) {
mtmp->mhp += rnd(8); mtmp->mhp += rnd(8);
return (1); return 1;
} }
/* fall through :-) */ /* fall through :-) */
case STRAT_NONE: /* harass */ case STRAT_NONE: /* harass */
if (!rn2(!mtmp->mflee ? 5 : 33)) if (!rn2(!mtmp->mflee ? 5 : 33))
mnexto(mtmp); mnexto(mtmp);
return (0); return 0;
default: /* kill, maim, pillage! */ default: /* kill, maim, pillage! */
{ {
@@ -350,12 +349,12 @@ register struct monst *mtmp;
struct obj *otmp; struct obj *otmp;
if (!targ) { /* simply wants you to close */ if (!targ) { /* simply wants you to close */
return (0); return 0;
} }
if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) { if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
/* player is standing on it (or has it) */ /* player is standing on it (or has it) */
mnexto(mtmp); mnexto(mtmp);
return (0); return 0;
} }
if (where == STRAT_GROUND) { if (where == STRAT_GROUND) {
if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) { if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
@@ -370,23 +369,23 @@ register struct monst *mtmp;
: distant_name(otmp, doname)); : distant_name(otmp, doname));
obj_extract_self(otmp); obj_extract_self(otmp);
(void) mpickobj(mtmp, otmp); (void) mpickobj(mtmp, otmp);
return (1); return 1;
} else } else
return (0); return 0;
} else { } else {
/* a monster is standing on it - cause some trouble */ /* a monster is standing on it - cause some trouble */
if (!rn2(5)) if (!rn2(5))
mnexto(mtmp); mnexto(mtmp);
return (0); return 0;
} }
} else { /* a monster has it - 'port beside it. */ } else { /* a monster has it - 'port beside it. */
(void) mnearto(mtmp, tx, ty, FALSE); (void) mnearto(mtmp, tx, ty, FALSE);
return (0); return 0;
} }
} }
} }
/*NOTREACHED*/ /*NOTREACHED*/
return (0); return 0;
} }
void void
@@ -505,7 +504,7 @@ struct monst *mcast;
return count; return count;
} }
/* Let's resurrect the wizard, for some unexpected fun. */ /* Let's resurrect the wizard, for some unexpected fun. */
void void
resurrect() resurrect()
{ {
@@ -525,9 +524,9 @@ resurrect()
verb = "elude"; verb = "elude";
mmtmp = &migrating_mons; mmtmp = &migrating_mons;
while ((mtmp = *mmtmp) != 0) { while ((mtmp = *mmtmp) != 0) {
if (mtmp->iswiz && if (mtmp->iswiz
/* if he has the Amulet, he won't bring it to you */ /* if he has the Amulet, he won't bring it to you */
!mon_has_amulet(mtmp) && !mon_has_amulet(mtmp)
&& (elapsed = monstermoves - mtmp->mlstmv) > 0L) { && (elapsed = monstermoves - mtmp->mlstmv) > 0L) {
mon_catchup_elapsed_time(mtmp, elapsed); mon_catchup_elapsed_time(mtmp, elapsed);
if (elapsed >= LARGEST_INT) if (elapsed >= LARGEST_INT)
@@ -559,8 +558,8 @@ resurrect()
} }
} }
/* Here, we make trouble for the poor shmuck who actually */ /* Here, we make trouble for the poor shmuck who actually
/* managed to do in the Wizard. */ managed to do in the Wizard. */
void void
intervene() intervene()
{ {
+35 -43
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 worm.c $NHDT-Date: 1432512770 2015/05/25 00:12:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */ /* NetHack 3.6 worm.c $NHDT-Date: 1446078769 2015/10/29 00:32:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.18 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -22,7 +22,7 @@ STATIC_DCL struct wseg *FDECL(create_worm_tail, (int));
/* Description of long worm implementation. /* Description of long worm implementation.
* *
* Each monst struct of the head of a tailed worm has a wormno set to * Each monst struct of the head of a tailed worm has a wormno set to
* 1 <= wormno < MAX_NUM_WORMS * 1 <= wormno < MAX_NUM_WORMS
* If wormno == 0 this does not mean that the monster is not a worm, * If wormno == 0 this does not mean that the monster is not a worm,
* it just means that the monster does not have a long worm tail. * it just means that the monster does not have a long worm tail.
* *
@@ -35,25 +35,24 @@ STATIC_DCL struct wseg *FDECL(create_worm_tail, (int));
* singly threaded linked lists. The wormno variable is used as an index * singly threaded linked lists. The wormno variable is used as an index
* for these segment arrays. * for these segment arrays.
* *
* wtails: The first (starting struct) of a linked list. This points * wtails: The first (starting struct) of a linked list. This points
* to the tail (last) segment of the worm. * to the tail (last) segment of the worm.
* *
* wheads: The last (end) of a linked list of segments. This points to * wheads: The last (end) of a linked list of segments. This points to
* the segment that is at the same position as the real monster * the segment that is at the same position as the real monster
* (the head). Note that the segment that wheads[wormno] points * (the head). Note that the segment that wheads[wormno] points
* to, is not displayed. It is simply there to keep track of * to, is not displayed. It is simply there to keep track of
* where the head came from, so that worm movement and display * where the head came from, so that worm movement and display
*are * are simplified later.
* simplified later. * Keeping the head segment of the worm at the end of the list
* Keeping the head segment of the worm at the end of the list * of tail segments is an endless source of confusion, but it is
* of tail segments is an endless source of confusion, but it is * necessary.
* necessary. * From now on, we will use "start" and "end" to refer to the
* From now on, we will use "start" and "end" to refer to the * linked list and "head" and "tail" to refer to the worm.
* linked list and "head" and "tail" to refer to the worm.
* *
* One final worm array is: * One final worm array is:
* *
* wgrowtime: This tells us when to add another segment to the worm. * wgrowtime: This tells us when to add another segment to the worm.
* *
* When a worm is moved, we add a new segment at the head, and delete the * When a worm is moved, we add a new segment at the head, and delete the
* segment at the tail (unless we want it to grow). This new head segment is * segment at the tail (unless we want it to grow). This new head segment is
@@ -95,7 +94,7 @@ get_wormno()
new_wormno++; new_wormno++;
} }
return (0); /* level infested with worms */ return 0; /* level infested with worms */
} }
/* /*
@@ -338,7 +337,7 @@ struct obj *weap;
/* Normally 17-20 does */ /* Normally 17-20 does */
if (weap && is_blade(weap)) /* With a blade 1- 6 does not cut */ if (weap && is_blade(weap)) /* With a blade 1- 6 does not cut */
cut_chance += 10; /* 7-20 does */ cut_chance += 10; /* 7-20 does */
if (cut_chance < 17) if (cut_chance < 17)
return; /* not good enough */ return; /* not good enough */
@@ -672,24 +671,20 @@ register xchar *nx, *ny;
*nx = x; *nx = x;
*ny = y; *ny = y;
*nx += (x > 1 ? /* extreme left ? */ *nx += (x > 1 /* extreme left ? */
(x < COLNO ? /* extreme right ? */ ? (x < COLNO /* extreme right ? */
(rn2(3) - 1) /* neither so +1, 0, or -1 */ ? (rn2(3) - 1) /* neither so +1, 0, or -1 */
: -rn2(2)) /* 0, or -1 */ : -rn2(2)) /* 0, or -1 */
: rn2(2)); /* 0, or 1 */ : rn2(2)); /* 0, or 1 */
*ny += *ny += (*nx == x /* same kind of thing with y */
(*nx == x ? /* same kind of thing with y */ ? (y > 1 ? (y < ROWNO ? (rn2(2) ? 1 : -1) : -1) : 1)
(y > 1 ? (y < ROWNO ? (rn2(2) ? 1 : -1) : -1) : 1) : (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2)));
: (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2)));
} }
/* count_wsegs() /* count_wsegs()
* * returns the number of visible segments that a worm has.
* returns
* the number of visible segments that a worm has.
*/ */
int int
count_wsegs(mtmp) count_wsegs(mtmp)
struct monst *mtmp; struct monst *mtmp;
@@ -708,9 +703,7 @@ struct monst *mtmp;
} }
/* create_worm_tail() /* create_worm_tail()
* * will create a worm tail chain of (num_segs + 1) and return pointer to it.
* will create a worm tail chain of (num_segs + 1) and return a pointer to
* it.
*/ */
STATIC_OVL STATIC_OVL
struct wseg * struct wseg *
@@ -737,11 +730,10 @@ int num_segs;
i++; i++;
} }
return (new_tail); return new_tail;
} }
/* worm_known() /* worm_known()
*
* Is any segment of this worm in viewing range? Note: caller must check * Is any segment of this worm in viewing range? Note: caller must check
* invisibility and telepathy (which should only show the head anyway). * invisibility and telepathy (which should only show the head anyway).
* Mostly used in the canseemon() macro. * Mostly used in the canseemon() macro.
@@ -773,10 +765,10 @@ int x1, y1, x2, y2;
* With digits representing relative sequence number of the segments, * With digits representing relative sequence number of the segments,
* returns true when testing between @ and ? (passes through worm's * returns true when testing between @ and ? (passes through worm's
* body), false between @ and ! (stays on same side of worm). * body), false between @ and ! (stays on same side of worm).
* .w1?.. * .w1?..
* ..@2.. * ..@2..
* .65!3. * .65!3.
* ...4.. * ...4..
*/ */
if (distmin(x1, y1, x2, y2) != 1) { if (distmin(x1, y1, x2, y2) != 1) {
@@ -802,9 +794,9 @@ int x1, y1, x2, y2;
/* we don't know which of <x1,y2> or <x2,y1> we'll hit first, but /* we don't know which of <x1,y2> or <x2,y1> we'll hit first, but
whichever it is, they're consecutive iff next seg is the other */ whichever it is, they're consecutive iff next seg is the other */
if (curr->wx == x1 && curr->wy == y2) if (curr->wx == x1 && curr->wy == y2)
return (boolean)(wnxt->wx == x2 && wnxt->wy == y1); return (boolean) (wnxt->wx == x2 && wnxt->wy == y1);
if (curr->wx == x2 && curr->wy == y1) if (curr->wx == x2 && curr->wy == y1)
return (boolean)(wnxt->wx == x1 && wnxt->wy == y2); return (boolean) (wnxt->wx == x1 && wnxt->wy == y2);
} }
/* should never reach here... */ /* should never reach here... */
return FALSE; return FALSE;
+8 -8
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 worn.c $NHDT-Date: 1445214551 2015/10/19 00:29:11 $ $NHDT-Branch: master $:$NHDT-Revision: 1.45 $ */ /* NetHack 3.6 worn.c $NHDT-Date: 1446078770 2015/10/29 00:32:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.46 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -658,7 +658,7 @@ long flag;
for (obj = mon->minvent; obj; obj = obj->nobj) for (obj = mon->minvent; obj; obj = obj->nobj)
if (obj->owornmask & flag) if (obj->owornmask & flag)
return obj; return obj;
return ((struct obj *) 0); return (struct obj *) 0;
} }
} }
@@ -871,9 +871,9 @@ boolean polyspot;
} }
} }
if (handless_or_tiny || has_horns(mdat)) { if (handless_or_tiny || has_horns(mdat)) {
if ((otmp = which_armor(mon, W_ARMH)) != 0 && if ((otmp = which_armor(mon, W_ARMH)) != 0
/* flimsy test for horns matches polyself handling */ /* flimsy test for horns matches polyself handling */
(handless_or_tiny || !is_flimsy(otmp))) { && (handless_or_tiny || !is_flimsy(otmp))) {
if (vis) if (vis)
pline("%s helmet falls to the %s!", s_suffix(Monnam(mon)), pline("%s helmet falls to the %s!", s_suffix(Monnam(mon)),
surface(mon->mx, mon->my)); surface(mon->mx, mon->my));
@@ -942,9 +942,9 @@ struct obj *obj;
* Exceptions to things based on race. Correctly checks polymorphed player * Exceptions to things based on race. Correctly checks polymorphed player
*race. *race.
* Returns: * Returns:
* 0 No exception, normal rules apply. * 0 No exception, normal rules apply.
* 1 If the race/object combination is acceptable. * 1 If the race/object combination is acceptable.
* -1 If the race/object combination is unacceptable. * -1 If the race/object combination is unacceptable.
*/ */
int int
racial_exception(mon, obj) racial_exception(mon, obj)
@@ -959,7 +959,7 @@ struct obj *obj;
return 1; return 1;
/* Unacceptable Exceptions: */ /* Unacceptable Exceptions: */
/* Checks for object that certain races should never use go here */ /* Checks for object that certain races should never use go here */
/* return -1; */ /* return -1; */
return 0; return 0;
} }
+37 -39
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 write.c $NHDT-Date: 1442276267 2015/09/15 00:17:47 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */ /* NetHack 3.6 write.c $NHDT-Date: 1446078770 2015/10/29 00:32:50 $ $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #include "hack.h"
@@ -20,8 +20,7 @@ register struct obj *otmp;
switch (otmp->otyp) { switch (otmp->otyp) {
#ifdef MAIL #ifdef MAIL
case SCR_MAIL: case SCR_MAIL:
return (2); return 2;
/* break; */
#endif #endif
case SCR_LIGHT: case SCR_LIGHT:
case SCR_GOLD_DETECTION: case SCR_GOLD_DETECTION:
@@ -30,39 +29,32 @@ register struct obj *otmp;
case SCR_AMNESIA: case SCR_AMNESIA:
case SCR_FIRE: case SCR_FIRE:
case SCR_EARTH: case SCR_EARTH:
return (8); return 8;
/* break; */
case SCR_DESTROY_ARMOR: case SCR_DESTROY_ARMOR:
case SCR_CREATE_MONSTER: case SCR_CREATE_MONSTER:
case SCR_PUNISHMENT: case SCR_PUNISHMENT:
return (10); return 10;
/* break; */
case SCR_CONFUSE_MONSTER: case SCR_CONFUSE_MONSTER:
return (12); return 12;
/* break; */
case SCR_IDENTIFY: case SCR_IDENTIFY:
return (14); return 14;
/* break; */
case SCR_ENCHANT_ARMOR: case SCR_ENCHANT_ARMOR:
case SCR_REMOVE_CURSE: case SCR_REMOVE_CURSE:
case SCR_ENCHANT_WEAPON: case SCR_ENCHANT_WEAPON:
case SCR_CHARGING: case SCR_CHARGING:
return (16); return 16;
/* break; */
case SCR_SCARE_MONSTER: case SCR_SCARE_MONSTER:
case SCR_STINKING_CLOUD: case SCR_STINKING_CLOUD:
case SCR_TAMING: case SCR_TAMING:
case SCR_TELEPORTATION: case SCR_TELEPORTATION:
return (20); return 20;
/* break; */
case SCR_GENOCIDE: case SCR_GENOCIDE:
return (30); return 30;
/* break; */
case SCR_BLANK_PAPER: case SCR_BLANK_PAPER:
default: default:
impossible("You can't write such a weird scroll!"); impossible("You can't write such a weird scroll!");
} }
return (1000); return 1000;
} }
/* decide whether the hero knowns a particular scroll's label; /* decide whether the hero knowns a particular scroll's label;
@@ -97,6 +89,7 @@ struct obj *objlist;
static NEARDATA const char write_on[] = { SCROLL_CLASS, SPBOOK_CLASS, 0 }; static NEARDATA const char write_on[] = { SCROLL_CLASS, SPBOOK_CLASS, 0 };
/* write -- applying a magic marker */
int int
dowrite(pen) dowrite(pen)
register struct obj *pen; register struct obj *pen;
@@ -127,8 +120,11 @@ register struct obj *pen;
return 0; return 0;
/* can't write on a novel (unless/until it's been converted into a blank /* can't write on a novel (unless/until it's been converted into a blank
spellbook), but we want messages saying so to avoid "spellbook" */ spellbook), but we want messages saying so to avoid "spellbook" */
typeword = (paper->otyp == SPE_NOVEL) ? "book" typeword = (paper->otyp == SPE_NOVEL)
: (paper->oclass == SPBOOK_CLASS) ? "spellbook" : "scroll"; ? "book"
: (paper->oclass == SPBOOK_CLASS)
? "spellbook"
: "scroll";
if (Blind) { if (Blind) {
if (!paper->dknown) { if (!paper->dknown) {
You("don't know if that %s is blank or not.", typeword); You("don't know if that %s is blank or not.", typeword);
@@ -185,16 +181,18 @@ register struct obj *pen;
entry, so we don't simply use first match with it; entry, so we don't simply use first match with it;
also, player might assign same name multiple times also, player might assign same name multiple times
and if so, we choose one of those matches randomly */ and if so, we choose one of those matches randomly */
if (objects[i].oc_uname && !strcmpi(objects[i].oc_uname, nm) && if (objects[i].oc_uname && !strcmpi(objects[i].oc_uname, nm)
/* first match: chance incremented to 1, /*
!rn2(1) is 1, we remember i; * First match: chance incremented to 1,
second match: chance incremented to 2, * !rn2(1) is 1, we remember i;
!rn2(2) has 1/2 chance to replace i; * second match: chance incremented to 2,
third match: chance incremented to 3, * !rn2(2) has 1/2 chance to replace i;
!rn2(3) has 1/3 chance to replace i * third match: chance incremented to 3,
and 2/3 chance to keep previous 50:50 * !rn2(3) has 1/3 chance to replace i
choice; so on for higher match counts */ * and 2/3 chance to keep previous 50:50
!rn2(++deferralchance)) * choice; so on for higher match counts.
*/
&& !rn2(++deferralchance))
deferred = i; deferred = i;
} }
/* writing by user-assigned name is same as by description: /* writing by user-assigned name is same as by description:
@@ -238,7 +236,7 @@ found:
if (pen->spe < basecost / 2) { if (pen->spe < basecost / 2) {
Your("marker is too dry to write that!"); Your("marker is too dry to write that!");
obfree(new_obj, (struct obj *) 0); obfree(new_obj, (struct obj *) 0);
return (1); return 1;
} }
/* we're really going to write now, so calculate cost /* we're really going to write now, so calculate cost
@@ -259,7 +257,7 @@ found:
useup(paper); useup(paper);
} }
obfree(new_obj, (struct obj *) 0); obfree(new_obj, (struct obj *) 0);
return (1); return 1;
} }
pen->spe -= actualcost; pen->spe -= actualcost;
@@ -287,11 +285,11 @@ found:
*/ */
/* if known, then either by-name or by-descr works */ /* if known, then either by-name or by-descr works */
if (!objects[new_obj->otyp].oc_name_known && if (!objects[new_obj->otyp].oc_name_known
/* else if named, then only by-descr works */ /* else if named, then only by-descr works */
!(by_descr && label_known(new_obj->otyp, invent)) && && !(by_descr && label_known(new_obj->otyp, invent))
/* and Luck might override after both checks have failed */ /* and Luck might override after both checks have failed */
rnl(Role_if(PM_WIZARD) ? 5 : 15)) { && rnl(Role_if(PM_WIZARD) ? 5 : 15)) {
You("%s to write that.", by_descr ? "fail" : "don't know how"); You("%s to write that.", by_descr ? "fail" : "don't know how");
/* scrolls disappear, spellbooks don't */ /* scrolls disappear, spellbooks don't */
if (paper->oclass == SPBOOK_CLASS) { if (paper->oclass == SPBOOK_CLASS) {
@@ -308,7 +306,7 @@ found:
useup(paper); useup(paper);
} }
obfree(new_obj, (struct obj *) 0); obfree(new_obj, (struct obj *) 0);
return (1); return 1;
} }
/* can write scrolls when blind, but requires luck too; /* can write scrolls when blind, but requires luck too;
attempts to write books when blind are caught above */ attempts to write books when blind are caught above */
@@ -342,7 +340,7 @@ found:
new_obj = new_obj =
hold_another_object(new_obj, "Oops! %s out of your grasp!", hold_another_object(new_obj, "Oops! %s out of your grasp!",
The(aobjnam(new_obj, "slip")), (const char *) 0); The(aobjnam(new_obj, "slip")), (const char *) 0);
return (1); return 1;
} }
/* most book descriptions refer to cover appearance, so we can issue a /* most book descriptions refer to cover appearance, so we can issue a
@@ -364,8 +362,8 @@ char *outbuf;
"vellum", "vellum",
"cloth", "cloth",
#if 0 #if 0
"canvas", "hardcover", /* not used */ "canvas", "hardcover", /* not used */
"papyrus", /* not applicable--can't be produced via writing */ "papyrus", /* not applicable--can't be produced via writing */
#endif /*0*/ #endif /*0*/
0 0
}; };
+111 -111
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 zap.c $NHDT-Date: 1431998738 2015/05/19 01:25:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.223 $ */ /* NetHack 3.6 zap.c $NHDT-Date: 1446078771 2015/10/29 00:32:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.230 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -110,16 +110,14 @@ struct obj *obj;
so that casting a spell won't re-discover its forgotten book. */ so that casting a spell won't re-discover its forgotten book. */
if (obj->oclass != SPBOOK_CLASS) { if (obj->oclass != SPBOOK_CLASS) {
/* if type already discovered, treat this item has having been seen /* if type already discovered, treat this item has having been seen
even if the hero is currently blinded (skips redundant makeknown) even if hero is currently blinded (skips redundant makeknown) */
*/
if (objects[obj->otyp].oc_name_known) { if (objects[obj->otyp].oc_name_known) {
obj->dknown = 1; /* will usually be set already */ obj->dknown = 1; /* will usually be set already */
/* otherwise discover it if this item itself has been or can be
* seen */ /* otherwise discover it if item itself has been or can be seen */
} else { } else {
/* in case it was picked up while blind and then zapped without /* in case it was picked up while blind and then zapped without
examining inventory after regaining sight (bypassing xname()) examining inventory after regaining sight (bypassing xname) */
*/
if (!Blind) if (!Blind)
obj->dknown = 1; obj->dknown = 1;
/* make the discovery iff we know what we're manipulating */ /* make the discovery iff we know what we're manipulating */
@@ -600,10 +598,10 @@ coord *cc;
* get_container_location() returns the following information * get_container_location() returns the following information
* about the outermost container: * about the outermost container:
* loc argument gets set to: * loc argument gets set to:
* OBJ_INVENT if in hero's inventory; return 0. * OBJ_INVENT if in hero's inventory; return 0.
* OBJ_FLOOR if on the floor; return 0. * OBJ_FLOOR if on the floor; return 0.
* OBJ_BURIED if buried; return 0. * OBJ_BURIED if buried; return 0.
* OBJ_MINVENT if in monster's inventory; return monster. * OBJ_MINVENT if in monster's inventory; return monster.
* container_nesting is updated with the nesting depth of the containers * container_nesting is updated with the nesting depth of the containers
* if applicable. * if applicable.
*/ */
@@ -1002,13 +1000,14 @@ register struct obj *obj;
boolean u_ring; boolean u_ring;
/* Is this a charged/enchanted object? */ /* Is this a charged/enchanted object? */
if (!obj || (!objects[obj->otyp].oc_charged && obj->oclass != WEAPON_CLASS if (!obj
&& obj->oclass != ARMOR_CLASS && !is_weptool(obj)) || (!objects[obj->otyp].oc_charged && obj->oclass != WEAPON_CLASS
&& obj->oclass != ARMOR_CLASS && !is_weptool(obj))
|| obj->spe <= 0) || obj->spe <= 0)
return (FALSE); return FALSE;
if (defends(AD_DRLI, obj) || defends_when_carried(AD_DRLI, obj) if (defends(AD_DRLI, obj) || defends_when_carried(AD_DRLI, obj)
|| obj_resists(obj, 10, 90)) || obj_resists(obj, 10, 90))
return (FALSE); return FALSE;
/* Charge for the cost of the object */ /* Charge for the cost of the object */
costly_alteration(obj, COST_DRAIN); costly_alteration(obj, COST_DRAIN);
@@ -1062,7 +1061,7 @@ register struct obj *obj;
} }
if (carried(obj)) if (carried(obj))
update_inventory(); update_inventory();
return (TRUE); return TRUE;
} }
boolean boolean
@@ -1070,7 +1069,8 @@ obj_resists(obj, ochance, achance)
struct obj *obj; struct obj *obj;
int ochance, achance; /* percent chance for ordinary objects, artifacts */ int ochance, achance; /* percent chance for ordinary objects, artifacts */
{ {
if (obj->otyp == AMULET_OF_YENDOR || obj->otyp == SPE_BOOK_OF_THE_DEAD if (obj->otyp == AMULET_OF_YENDOR
|| obj->otyp == SPE_BOOK_OF_THE_DEAD
|| obj->otyp == CANDELABRUM_OF_INVOCATION || obj->otyp == CANDELABRUM_OF_INVOCATION
|| obj->otyp == BELL_OF_OPENING || obj->otyp == BELL_OF_OPENING
|| (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm]))) { || (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm]))) {
@@ -1078,7 +1078,7 @@ int ochance, achance; /* percent chance for ordinary objects, artifacts */
} else { } else {
int chance = rn2(100); int chance = rn2(100);
return ((boolean)(chance < (obj->oartifact ? achance : ochance))); return (boolean) (chance < (obj->oartifact ? achance : ochance));
} }
} }
@@ -1104,7 +1104,7 @@ struct obj *obj;
if (obj->quan > 4L) if (obj->quan > 4L)
zap_odds /= 2; zap_odds /= 2;
return ((boolean)(!rn2(zap_odds))); return (boolean) !rn2(zap_odds);
} }
/* Use up at least minwt number of things made of material mat. /* Use up at least minwt number of things made of material mat.
@@ -1723,16 +1723,16 @@ struct obj *obj, *otmp;
* monster's inventory. They are not polymorphed * monster's inventory. They are not polymorphed
* either. * either.
* UNDEAD_TURNING - When an undead creature gets killed via * UNDEAD_TURNING - When an undead creature gets killed via
* undead turning, prevent its corpse from being * undead turning, prevent its corpse from being
* immediately revived by the same effect. * immediately revived by the same effect.
* STONE_TO_FLESH - If a statue can't be revived, its * STONE_TO_FLESH - If a statue can't be revived, its
* contents get dropped before turning it into * contents get dropped before turning it into
* meat; prevent those contents from being hit. * meat; prevent those contents from being hit.
* retouch_equipment() - bypass flag is used to track which * retouch_equipment() - bypass flag is used to track which
* items have been handled (bhito isn't involved). * items have been handled (bhito isn't involved).
* menu_drop(), askchain() - inventory traversal where multiple * menu_drop(), askchain() - inventory traversal where multiple
* Drop can alter the invent chain while traversal * Drop can alter the invent chain while traversal
* is in progress (bhito isn't involved). * is in progress (bhito isn't involved).
* *
* The bypass bit on all objects is reset each turn, whenever * The bypass bit on all objects is reset each turn, whenever
* context.bypasses is set. * context.bypasses is set.
@@ -1969,7 +1969,7 @@ schar zz;
/* /*
* zappable - returns 1 if zap is available, 0 otherwise. * zappable - returns 1 if zap is available, 0 otherwise.
* it removes a charge from the wand if zappable. * it removes a charge from the wand if zappable.
* added by GAN 11/03/86 * added by GAN 11/03/86
*/ */
int int
@@ -2054,6 +2054,7 @@ struct obj *otmp;
static NEARDATA const char zap_syms[] = { WAND_CLASS, 0 }; static NEARDATA const char zap_syms[] = { WAND_CLASS, 0 };
/* 'z' command (or 'y' if numbed_pad==-1) */
int int
dozap() dozap()
{ {
@@ -2061,10 +2062,10 @@ dozap()
int damage; int damage;
if (check_capacity((char *) 0)) if (check_capacity((char *) 0))
return (0); return 0;
obj = getobj(zap_syms, "zap"); obj = getobj(zap_syms, "zap");
if (!obj) if (!obj)
return (0); return 0;
check_unpaid(obj); check_unpaid(obj);
@@ -2074,7 +2075,7 @@ dozap()
else if (obj->cursed && !rn2(WAND_BACKFIRE_CHANCE)) { else if (obj->cursed && !rn2(WAND_BACKFIRE_CHANCE)) {
backfire(obj); /* the wand blows up in your face! */ backfire(obj); /* the wand blows up in your face! */
exercise(A_STR, FALSE); exercise(A_STR, FALSE);
return (1); return 1;
} else if (!(objects[obj->otyp].oc_dir == NODIR) && !getdir((char *) 0)) { } else if (!(objects[obj->otyp].oc_dir == NODIR) && !getdir((char *) 0)) {
if (!Blind) if (!Blind)
pline("%s glows and fades.", The(xname(obj))); pline("%s glows and fades.", The(xname(obj)));
@@ -2087,7 +2088,7 @@ dozap()
losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX); losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX);
} }
} else { } else {
/* Are we having fun yet? /* Are we having fun yet?
* weffects -> buzz(obj->otyp) -> zhitm (temple priest) -> * weffects -> buzz(obj->otyp) -> zhitm (temple priest) ->
* attack -> hitum -> known_hitum -> ghod_hitsu -> * attack -> hitum -> known_hitum -> ghod_hitsu ->
* buzz(AD_ELEC) -> destroy_item(WAND_CLASS) -> * buzz(AD_ELEC) -> destroy_item(WAND_CLASS) ->
@@ -2103,7 +2104,7 @@ dozap()
useup(obj); useup(obj);
} }
update_inventory(); /* maybe used a charge */ update_inventory(); /* maybe used a charge */
return (1); return 1;
} }
int int
@@ -2409,7 +2410,7 @@ boolean ordinary;
that the wand itself has been seen */ that the wand itself has been seen */
if (learn_it) if (learn_it)
learnwand(obj); learnwand(obj);
return (damage); return damage;
} }
/* called when poly'd hero uses breath attack against self */ /* called when poly'd hero uses breath attack against self */
@@ -2938,7 +2939,7 @@ int skill;
const char * const char *
exclam(force) exclam(force)
register int force; int force;
{ {
/* force == 0 occurs e.g. with sleep ray */ /* force == 0 occurs e.g. with sleep ray */
/* note that large force is usual with wands so that !! would /* note that large force is usual with wands so that !! would
@@ -2948,16 +2949,16 @@ register int force;
void void
hit(str, mtmp, force) hit(str, mtmp, force)
register const char *str; const char *str;
register struct monst *mtmp; struct monst *mtmp;
register const char *force; /* usually either "." or "!" */ const char *force; /* usually either "." or "!" */
{ {
if ((!cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp) if ((!cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp)
&& !(u.uswallow && mtmp == u.ustuck)) || !flags.verbose) && !(u.uswallow && mtmp == u.ustuck)) || !flags.verbose)
pline("%s %s it.", The(str), vtense(str, "hit")); pline("%s %s it.", The(str), vtense(str, "hit"));
else else
pline("%s %s %s%s", The(str), vtense(str, "hit"), mon_nam(mtmp), pline("%s %s %s%s", The(str), vtense(str, "hit"),
force); mon_nam(mtmp), force);
} }
void void
@@ -2985,13 +2986,12 @@ int range, *skipstart, *skipend;
/* /*
* Called for the following distance effects: * Called for the following distance effects:
* when a weapon is thrown (weapon == THROWN_WEAPON) * when a weapon is thrown (weapon == THROWN_WEAPON)
* when an object is kicked (KICKED_WEAPON) * when an object is kicked (KICKED_WEAPON)
* when an IMMEDIATE wand is zapped (ZAPPED_WAND) * when an IMMEDIATE wand is zapped (ZAPPED_WAND)
* when a light beam is flashed (FLASHED_LIGHT) * when a light beam is flashed (FLASHED_LIGHT)
* when a mirror is applied (INVIS_BEAM) * when a mirror is applied (INVIS_BEAM)
* A thrown/kicked object falls down at the end of its range or when a * A thrown/kicked object falls down at end of its range or when a monster
*monster
* is hit. The variable 'bhitpos' is set to the final position of the weapon * is hit. The variable 'bhitpos' is set to the final position of the weapon
* thrown/zapped. The ray of a wand may affect (by calling a provided * thrown/zapped. The ray of a wand may affect (by calling a provided
* function) several objects and monsters on its path. The return value * function) several objects and monsters on its path. The return value
@@ -3058,7 +3058,7 @@ struct obj **pobj; /* object tossed/used, set to NULL
if (is_pick(obj) && inside_shop(x, y) if (is_pick(obj) && inside_shop(x, y)
&& (mtmp = shkcatch(obj, x, y))) { && (mtmp = shkcatch(obj, x, y))) {
tmp_at(DISP_END, 0); tmp_at(DISP_END, 0);
return (mtmp); return mtmp;
} }
typ = levl[bhitpos.x][bhitpos.y].typ; typ = levl[bhitpos.x][bhitpos.y].typ;
@@ -3323,7 +3323,7 @@ int dx, dy;
mtmp = m_at(bhitpos.x, bhitpos.y); mtmp = m_at(bhitpos.x, bhitpos.y);
m_respond(mtmp); m_respond(mtmp);
tmp_at(DISP_END, 0); tmp_at(DISP_END, 0);
return (mtmp); return mtmp;
} }
if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ) if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)
|| closed_door(bhitpos.x, bhitpos.y)) { || closed_door(bhitpos.x, bhitpos.y)) {
@@ -3341,7 +3341,7 @@ int dx, dy;
} else { /* we catch it */ } else { /* we catch it */
tmp_at(DISP_END, 0); tmp_at(DISP_END, 0);
You("skillfully catch the boomerang."); You("skillfully catch the boomerang.");
return (&youmonst); return &youmonst;
} }
} }
tmp_at(bhitpos.x, bhitpos.y); tmp_at(bhitpos.x, bhitpos.y);
@@ -3360,8 +3360,9 @@ int dx, dy;
return (struct monst *) 0; return (struct monst *) 0;
} }
/* used by buzz(); also used by munslime(muse.c) */ /* used by buzz(); also used by munslime(muse.c); returns damage to mon */
int zhitm(mon, type, nd, ootmp) /* returns damage to mon */ int
zhitm(mon, type, nd, ootmp)
register struct monst *mon; register struct monst *mon;
register int type, nd; register int type, nd;
struct obj **ootmp; /* to return worn armor for caller to disintegrate */ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
@@ -3519,7 +3520,7 @@ struct obj **ootmp; /* to return worn armor for caller to disintegrate */
debugpline3("zapped monster hp = %d (= %d - %d)", mon->mhp - tmp, debugpline3("zapped monster hp = %d (= %d - %d)", mon->mhp - tmp,
mon->mhp, tmp); mon->mhp, tmp);
mon->mhp -= tmp; mon->mhp -= tmp;
return (tmp); return tmp;
} }
STATIC_OVL void STATIC_OVL void
@@ -3736,7 +3737,7 @@ int type; /* either hero cast spell type or 0 */
/* very high armor protection does not achieve invulnerability */ /* very high armor protection does not achieve invulnerability */
ac = AC_VALUE(ac); ac = AC_VALUE(ac);
return (3 - chance) < ac + spell_bonus; return (3 - chance < ac + spell_bonus);
} }
STATIC_OVL void STATIC_OVL void
@@ -4023,17 +4024,17 @@ register int dx, dy;
explode(sx, sy, type, d(12, 6), 0, EXPL_FIERY); explode(sx, sy, type, d(12, 6), 0, EXPL_FIERY);
get_out_buzz: get_out_buzz:
if (shopdamage) if (shopdamage)
pay_for_damage( pay_for_damage(abstype == ZT_FIRE
abstype == ZT_FIRE ? "burn away"
? "burn away" : abstype == ZT_COLD
: abstype == ZT_COLD ? "shatter"
? "shatter" /* "damage" indicates wall rather than door */
: : abstype == ZT_ACID
/* "damage" indicates wall rather than door */ ? "damage"
abstype == ZT_ACID ? "damage" : abstype == ZT_DEATH : abstype == ZT_DEATH
? "disintegrate" ? "disintegrate"
: "destroy", : "destroy",
FALSE); FALSE);
bhitpos = save_bhitpos; bhitpos = save_bhitpos;
} }
@@ -4426,7 +4427,9 @@ short exploding_wand_typ;
return rangemod; return rangemod;
} }
void fracture_rock(obj) /* fractured by pick-axe or wand of striking */ /* fractured by pick-axe or wand of striking */
void
fracture_rock(obj)
register struct obj *obj; /* no texts here! */ register struct obj *obj; /* no texts here! */
{ {
xchar x, y; xchar x, y;
@@ -4494,13 +4497,13 @@ register struct obj *obj;
/* /*
* destroy_strings[dindx][0:singular,1:plural,2:killer_reason] * destroy_strings[dindx][0:singular,1:plural,2:killer_reason]
* [0] freezing potion * [0] freezing potion
* [1] boiling potion other than oil * [1] boiling potion other than oil
* [2] boiling potion of oil * [2] boiling potion of oil
* [3] burning scroll * [3] burning scroll
* [4] burning spellbook * [4] burning spellbook
* [5] shocked ring * [5] shocked ring
* [6] shocked wand * [6] shocked wand
* (books, rings, and wands don't stack so don't need plural form; * (books, rings, and wands don't stack so don't need plural form;
* crumbling ring doesn't do damage so doesn't need killer reason) * crumbling ring doesn't do damage so doesn't need killer reason)
*/ */
@@ -4606,7 +4609,7 @@ register int osym, dmgtyp;
break; break;
} }
#if 0 #if 0
if (obj == current_wand) { skip++; break; } if (obj == current_wand) { skip++; break; }
#endif #endif
dindx = 6; dindx = 6;
dmg = rnd(10); dmg = rnd(10);
@@ -4781,7 +4784,7 @@ int osym, dmgtyp;
m_useup(mtmp, obj); m_useup(mtmp, obj);
} }
} }
return (tmp); return tmp;
} }
int int
@@ -4842,7 +4845,7 @@ int damage, tell;
killed(mtmp); killed(mtmp);
} }
} }
return (resisted); return resisted;
} }
#define MAXWISHTRY 5 #define MAXWISHTRY 5
@@ -4851,38 +4854,33 @@ STATIC_OVL void
wishcmdassist(triesleft) wishcmdassist(triesleft)
int triesleft; int triesleft;
{ {
static NEARDATA const char *wishinfo[] = static NEARDATA const char *
{ wishinfo[] = {
"Wish details:", "", "Enter the name of an object, such as " "Wish details:",
"\"potion of monster detection\",", "",
"\"scroll labeled README\", \"elven mithril-coat\", or " "Enter the name of an object, such as \"potion of monster detection\",",
"\"Grimtooth\"", "\"scroll labeled README\", \"elven mithril-coat\", or \"Grimtooth\"",
"(without the quotes).", "", "For object types which come in " "(without the quotes).",
"stacks, you may specify a plural " "",
"name", "For object types which come in stacks, you may specify a plural name",
"such as \"potions of healing\", or specify a count, such as " "such as \"potions of healing\", or specify a count, such as \"1000 gold",
"\"1000 gold", "pieces\", although that aspect of your wish might not be granted.",
"pieces\", although that aspect of your wish might not be granted.", "",
"", "You may also specify various prefix values which might be used to",
"You may also specify various prefix values which might be used to", "modify the item, such as \"uncursed\" or \"rustproof\" or \"+1\".",
"modify the item, such as \"uncursed\" or \"rustproof\" or \"+1\".", "Most modifiers shown when viewing your inventory can be specified.",
"Most modifiers shown when viewing your inventory can be " "",
"specified.", "You may specify 'nothing' to explicitly decline this wish.",
"", "You may specify 'nothing' to explicitly decline this wish.", 0, 0,
}, },
preserve_wishless[] = "Doing so will preserve " preserve_wishless[] = "Doing so will preserve 'wishless' conduct.",
"'wishless' conduct.", retry_info[] =
retry_info[] = "If you specify an " "If you specify an unrecognized object name %s%s time%s,",
"unrecognized object name %s%s " retry_too[] = "a randomly chosen item will be granted.",
"time%s,", suppress_cmdassist[] =
retry_too[] = "(Suppress this assistance with !cmdassist in your config file.)",
"a randomly chosen item will be granted.", *cardinals[] = { "zero", "one", "two", "three", "four", "five" },
suppress_cmdassist[] = too_many[] = "too many";
"(Suppress this assistance with "
"!cmdassist in your config file.)",
*cardinals[] = { "zero", "one", "two",
"three", "four", "five" },
too_many[] = "too many";
int i; int i;
winid win; winid win;
char buf[BUFSZ]; char buf[BUFSZ];
@@ -4895,10 +4893,12 @@ int triesleft;
if (!u.uconduct.wishes) if (!u.uconduct.wishes)
putstr(win, 0, preserve_wishless); putstr(win, 0, preserve_wishless);
putstr(win, 0, ""); putstr(win, 0, "");
Sprintf(buf, retry_info, (triesleft >= 0 && triesleft < SIZE(cardinals)) Sprintf(buf, retry_info,
? cardinals[triesleft] (triesleft >= 0 && triesleft < SIZE(cardinals))
: too_many, ? cardinals[triesleft]
(triesleft < MAXWISHTRY) ? " more" : "", plur(triesleft)); : too_many,
(triesleft < MAXWISHTRY) ? " more" : "",
plur(triesleft));
putstr(win, 0, buf); putstr(win, 0, buf);
putstr(win, 0, retry_too); putstr(win, 0, retry_too);
putstr(win, 0, ""); putstr(win, 0, "");