-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
register struct obj *otmp;
if (mtmp == u.usteed)
- return (FALSE);
+ return FALSE;
if (mtmp->mleashed) {
otmp = get_mleash(mtmp);
You("don't know that spell.");
else
You("are not able to teleport at will.");
- return (0);
+ return 0;
}
}
}
if (castit) {
exercise(A_WIS, TRUE);
if (spelleffects(sp_no, TRUE))
- return (1);
+ return 1;
else if (!wizard)
- return (0);
+ return 0;
} else {
u.uen -= energy;
context.botl = 1;
(void) next_to_u();
} else {
You1(shudder_for_moment);
- return (0);
+ return 0;
}
if (!trap)
morehungry(100);
- return (1);
+ return 1;
}
void
if (!xx) {
/* no current location (migrating monster arrival) */
if (dndest.nlx && On_W_tower_level(&u.uz))
- return ((yy & 2) != 0)
- ^ /* inside xor not within */
- !within_bounded_area(x, y, dndest.nlx, dndest.nly,
- dndest.nhx, dndest.nhy);
+ return (((yy & 2) != 0)
+ /* inside xor not within */
+ ^ !within_bounded_area(x, y, dndest.nlx, dndest.nly,
+ dndest.nhx, dndest.nhy));
if (updest.lx && (yy & 1) != 0) /* moving up */
- return (within_bounded_area(x, y, updest.lx, updest.ly, updest.hx,
- updest.hy)
+ return (within_bounded_area(x, y, updest.lx, updest.ly,
+ updest.hx, updest.hy)
&& (!updest.nlx
|| !within_bounded_area(x, y, updest.nlx, updest.nly,
updest.nhx, updest.nhy)));
if (dndest.lx && (yy & 1) == 0) /* moving down */
- return (within_bounded_area(x, y, dndest.lx, dndest.ly, dndest.hx,
- dndest.hy)
+ return (within_bounded_area(x, y, dndest.lx, dndest.ly,
+ dndest.hx, dndest.hy)
&& (!dndest.nlx
|| !within_bounded_area(x, y, dndest.nlx, dndest.nly,
dndest.nhx, dndest.nhy)));
|| (restricted_fall
&& (!within_bounded_area(tx, ty, dndest.lx, dndest.ly,
dndest.hx, dndest.hy)
- || (dndest.nlx && within_bounded_area(
- tx, ty, dndest.nlx, dndest.nly,
- dndest.nhx, dndest.nhy)))) ||
+ || (dndest.nlx
+ && within_bounded_area(tx, ty,
+ dndest.nlx, dndest.nly,
+ dndest.nhx, dndest.nhy))))
/* on the Wizard Tower levels, objects inside should
stay inside and objects outside should stay outside */
- (dndest.nlx && On_W_tower_level(&u.uz)
- && within_bounded_area(tx, ty, dndest.nlx, dndest.nly,
- dndest.nhx, dndest.nhy)
- != within_bounded_area(otx, oty, dndest.nlx, dndest.nly,
- dndest.nhx, dndest.nhy)));
+ || (dndest.nlx && On_W_tower_level(&u.uz)
+ && within_bounded_area(tx, ty, dndest.nlx, dndest.nly,
+ dndest.nhx, dndest.nhy)
+ != within_bounded_area(otx, oty, dndest.nlx, dndest.nly,
+ dndest.nhx, dndest.nhy)));
if (flooreffects(obj, tx, ty, "fall")) {
return FALSE;
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
if (Sokoban)
maybe_finish_sokoban();
}
- return (ttmp);
+ return ttmp;
}
void
/* statues of unique monsters from bones or wishing end
up here (cant_revive() sets mnum to be doppelganger;
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 */
- (mptr->msound == MS_GUARDIAN
- && quest_info(MS_GUARDIAN) != mnum)) {
+ || (mptr->msound == MS_GUARDIAN
+ && quest_info(MS_GUARDIAN) != mnum)) {
mon = makemon(&mons[PM_DOPPELGANGER], x, y,
NO_MINVENT | MM_NOCOUNTBIRTH | MM_ADJACENTOK);
/* if hero has protection from shape changers, cham field will
/* "the|your|Manlobbi's statue [of a wombat]" */
shkp = shop_keeper(*in_rooms(mon->mx, mon->my, SHOPBASE));
Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
- (cause == ANIMATE_SPELL &&
+ (cause == ANIMATE_SPELL
/* avoid "of a shopkeeper" if it's Manlobbi himself
(if carried, it can't be unpaid--hence won't be
described as "Manlobbi's statue"--because there
wasn't any living shk when statue was picked up) */
- (mon != shkp || carried(statue)))
- ? xname(statue)
- : "statue");
+ && (mon != shkp || carried(statue)))
+ ? xname(statue)
+ : "statue");
pline("%s %s!", upstart(statuename), comes_to_life);
} 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) {
if (cansee(x, y))
Sprintf(statuename, "%s%s", shk_your(tmpbuf, statue),
which refers to "it" so needs to follow a message describing
the object ("the statue comes to life" one above) */
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
if stone-to-flesh is used on petrified shopkeep */
- mon != shkp)
+ && mon != shkp)
(void) stolen_value(statue, x, y, (boolean) shkp->mpeaceful,
FALSE);
|| (tt == HOLE && !mindless(mptr)))) {
/* it has been in such a trap - perhaps it escapes */
if (rn2(4))
- return (0);
+ return 0;
} else {
mtmp->mtrapseen |= (1 << (tt - 1));
}
if (thitm(0, mtmp, otmp, d(2, 6), FALSE))
trapkilled = TRUE;
break;
-
case SQKY_BOARD:
if (is_flyer(mptr))
break;
/* wake up nearby monsters */
wake_nearto(mtmp->mx, mtmp->my, 40);
break;
-
case BEAR_TRAP:
if (mptr->msize > MZ_SMALL && !amorphous(mptr) && !is_flyer(mptr)
&& !is_whirly(mptr) && !unsolid(mptr)) {
if (mtmp->mtrapped)
trapkilled = thitm(0, mtmp, (struct obj *) 0, d(2, 4), FALSE);
break;
-
case SLP_GAS_TRAP:
if (!resists_sleep(mtmp) && !breathless(mptr) && !mtmp->msleeping
&& mtmp->mcanmove) {
}
}
break;
-
case RUST_TRAP: {
struct obj *target;
(void) split_mon(mtmp, (struct monst *) 0);
}
break;
- }
+ } /* RUST_TRAP */
case FIRE_TRAP:
mfiretrap:
if (in_sight)
if (see_it)
seetrap(trap);
break;
-
case PIT:
case SPIKED_PIT:
fallverb = "falls";
} else
break;
}
- /* Fall through */
+ /*FALLTHRU*/
case LEVEL_TELEP:
case MAGIC_PORTAL: {
int mlev_res;
+
mlev_res = mlevel_tele_trap(mtmp, trap, inescapable, in_sight);
if (mlev_res)
- return (mlev_res);
- } break;
-
+ return mlev_res;
+ break;
+ }
case TELEP_TRAP:
mtele_trap(mtmp, trap, in_sight);
break;
-
case WEB:
/* Monster in a web. */
if (webmaker(mptr))
}
}
break;
-
case STATUE_TRAP:
break;
-
case MAGIC_TRAP:
/* A magic trap. Monsters usually immune. */
if (!rn2(21))
newsym(trap->tx, trap->ty);
}
break;
-
case LANDMINE:
if (rn2(3))
break; /* monsters usually don't set it off */
nomovemsg = "The explosion awakens you!";
}
break;
-
case POLY_TRAP:
if (resists_magm(mtmp)) {
shieldeff(mtmp->mx, mtmp->my);
seetrap(trap);
}
break;
-
case ROLLING_BOULDER_TRAP:
if (!is_flyer(mptr)) {
int style = ROLL | (in_sight ? 0 : LAUNCH_UNSEEN);
}
}
break;
-
case VIBRATING_SQUARE:
if (see_it && !Blind) {
if (in_sight)
seetrap(trap);
}
break;
-
default:
impossible("Some monster encountered a strange trap of type %d.",
tt);
if (u.uswallow) {
You("float down, but you are still %s.",
is_animal(u.ustuck->data) ? "swallowed" : "engulfed");
- return (1);
+ return 1;
}
if (Punished && !carried(uball)
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,
and goto_level does its own pickup() call */
- on_level(&u.uz, ¤t_dungeon_level))
+ && on_level(&u.uz, ¤t_dungeon_level))
(void) pickup(1);
return 1;
}
break;
/* very occasionally something nice happens. */
-
- case 19:
- /* tame nearby monsters */
- {
- register int i, j;
- register struct monst *mtmp;
-
- (void) adjattrib(A_CHA, 1, FALSE);
- for (i = -1; i <= 1; i++)
- for (j = -1; j <= 1; j++) {
- if (!isok(u.ux + i, u.uy + j))
- 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;
-
- pseudo = zeroobj; /* neither cursed nor blessed,
- and zero out oextra */
- pseudo.otyp = SCR_REMOVE_CURSE;
- HConfusion = 0L;
- (void) seffects(&pseudo);
- HConfusion = save_conf;
- break;
- }
+ case 19: { /* tame nearby monsters */
+ int i, j;
+ struct monst *mtmp;
+
+ (void) adjattrib(A_CHA, 1, FALSE);
+ for (i = -1; i <= 1; i++)
+ for (j = -1; j <= 1; j++) {
+ if (!isok(u.ux + i, u.uy + j))
+ 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;
+
+ 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:
break;
}
}
}
if (!otmp)
- return (FALSE); /* nothing to drop! */
+ return FALSE; /* nothing to drop! */
if (otmp->owornmask)
remove_worn_item(otmp, FALSE);
*lostsome = TRUE;
dropx(otmp);
invc--;
}
- return (TRUE);
+ return TRUE;
}
/*
if (!rn2(5))
inpool_ok = TRUE;
else
- return (FALSE);
+ return FALSE;
}
if (!u.uinwater) {
losehp(i, "rusting away", KILLED_BY);
}
if (inpool_ok)
- return (FALSE);
+ return FALSE;
if ((i = number_leashed()) > 0) {
pline_The("leash%s slip%s loose.", (i > 1) ? "es" : "",
u.uinwater = 1;
under_water(1);
vision_full_recalc = 1;
- return (FALSE);
+ return FALSE;
}
if ((Teleportation || can_teleport(youmonst.data)) && !Unaware
&& (Teleport_control || rn2(3) < Luck + 2)) {
if (!level.flags.noteleport) {
(void) dotele();
if (!is_pool(u.ux, u.uy))
- return (TRUE);
+ return TRUE;
} else
pline_The("attempted teleport spell fails.");
}
if (u.usteed) {
dismount_steed(DISMOUNT_GENERIC);
if (!is_pool(u.ux, u.uy))
- return (TRUE);
+ return TRUE;
}
crawl_ok = FALSE;
x = y = 0; /* lint suppression */
if (succ) {
pline("Pheew! That was close.");
teleds(x, y, TRUE);
- return (TRUE);
+ return TRUE;
}
/* still too much weight */
pline("But in vain.");
You("find yourself back %s.",
Is_waterlevel(&u.uz) ? "in an air bubble" : "on land");
}
- return (TRUE);
+ return TRUE;
}
void
char the_trap[BUFSZ], qbuf[QBUFSZ];
if (!getdir((char *) 0))
- return (0);
+ return 0;
x = u.ux + u.dx;
y = u.uy + u.dy;
if (!isok(x, y)) {
(ttmp->ttyp == WEB) ? "Remove" : "Disarm", the_trap);
switch (ynq(qbuf)) {
case 'q':
- return (0);
+ return 0;
case 'n':
trap_skipped = TRUE;
deal_with_floor_trap = FALSE;
doname, ansimpleoname, "a box");
switch (ynq(qbuf)) {
case 'q':
- return (0);
+ return 0;
case 'n':
continue;
}
switch (ynq("Disarm it?")) {
case 'q':
- return (1);
+ return 1;
case 'n':
trap_skipped = TRUE;
continue;
}
} else
pline("That %s was not trapped.", xname(otmp));
- return (1);
+ return 1;
} else {
You("find no traps on %s.", the(xname(otmp)));
- return (1);
+ return 1;
}
}
You(trap_skipped ? "find no other traps here."
: "know of no traps here.");
- return (0);
+ return 0;
}
if (stumble_on_door_mimic(x, y))
if (!IS_DOOR(levl[x][y].typ)) {
if (!trap_skipped)
You("know of no traps there.");
- return (0);
+ return 0;
}
switch (levl[x][y].doormask) {
case D_NODOOR:
You("%s no door there.", Blind ? "feel" : "see");
- return (0);
+ return 0;
case D_ISOPEN:
pline("This door is safely open.");
- return (0);
+ return 0;
case D_BROKEN:
pline("This door is broken.");
- return (0);
+ return 0;
}
if ((levl[x][y].doormask & D_TRAPPED
You("find a trap on the door!");
exercise(A_WIS, TRUE);
if (ynq("Disarm it?") != 'y')
- return (1);
+ return 1;
if (levl[x][y].doormask & D_TRAPPED) {
ch = 15 + (Role_if(PM_ROGUE) ? u.ulevel * 3 : u.ulevel);
exercise(A_DEX, TRUE);
}
} else
pline("This door was not trapped.");
- return (1);
+ return 1;
} else {
You("find no traps on the door.");
- return (1);
+ return 1;
}
}
}
}
return TRUE;
- }
+ } /* case 21 */
case 20:
case 19:
case 18:
if (dmg)
losehp(dmg, "electric shock", KILLED_BY_AN);
break;
- }
+ } /* case 6 */
case 5:
case 4:
case 3:
register int x, y;
{
register struct trap *trap = ftrap;
+
while (trap) {
if (trap->tx == x && trap->ty == y)
- return (trap);
+ return trap;
trap = trap->ntrap;
}
- return ((struct trap *) 0);
+ return (struct trap *) 0;
}
void
register struct trap *ttmp;
clear_conjoined_pits(trap);
- if (trap == ftrap)
+ if (trap == ftrap) {
ftrap = ftrap->ntrap;
- else {
- for (ttmp = ftrap; ttmp->ntrap != trap; ttmp = ttmp->ntrap)
- ;
+ } else {
+ for (ttmp = ftrap; ttmp; ttmp = ttmp->ntrap)
+ if (ttmp->ntrap == trap)
+ break;
+ if (!ttmp)
+ panic("deltrap: no preceding trap!");
ttmp->ntrap = trap->ntrap;
}
if (Sokoban && (trap->ttyp == PIT || trap->ttyp == HOLE))
boolean u_entering_trap2;
{
int dx, dy, diridx, adjidx;
+
if (!trap1 || !trap2)
return FALSE;
if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty)
{
int diridx, adjidx, x, y;
struct trap *t;
+
if (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) {
for (diridx = 0; diridx < 8; ++diridx) {
if (trap->conjoined & (1 << diridx)) {
x = trap->tx + xdir[diridx];
y = trap->ty + ydir[diridx];
- t = t_at(x, y);
- if (isok(x, y) && t
+ if (isok(x, y)
+ && (t = t_at(x, y)) != 0
&& (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
adjidx = (diridx + 4) % 8;
t->conjoined &= ~(1 << adjidx);
join_adjacent_pits(trap)
struct trap *trap;
{
- struct trap *t;
- int diridx, x, y;
- if (!trap) return;
- for(diridx = 0; diridx < 8; ++diridx) {
- x = trap->tx + xdir[diridx];
- y = trap->ty + ydir[diridx];
- if (isok(x,y)) {
- if (((t = t_at(x,y)) != 0) &&
- (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
- trap->conjoined |= (1 << diridx);
- join_adjacent_pits(t);
- } else trap->conjoined &= ~(1 << diridx);
- }
- }
+ struct trap *t;
+ int diridx, x, y;
+
+ if (!trap)
+ return;
+ for (diridx = 0; diridx < 8; ++diridx) {
+ x = trap->tx + xdir[diridx];
+ y = trap->ty + ydir[diridx];
+ if (isok(x, y)) {
+ if ((t = t_at(x, y)) != 0
+ && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) {
+ 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.
boolean
unconscious()
{
- return (boolean)(
- multi < 0
- && (u.usleep || (nomovemsg
- && (!strncmp(nomovemsg, "You awake", 9)
- || !strncmp(nomovemsg, "You regain con", 14)
- || !strncmp(nomovemsg, "You are consci", 14)))));
+ if (multi >= 0)
+ return FALSE;
+
+ return (boolean) (u.usleep
+ || (nomovemsg
+ && (!strncmp(nomovemsg, "You awake", 9)
+ || !strncmp(nomovemsg, "You regain con", 14)
+ || !strncmp(nomovemsg, "You are consci", 14))));
}
static const char lava_killer[] = "molten lava";
/* Check whether we should burn away boots *first* so we know whether to
* make the player sink into the lava. Assumption: water walking only
- * comes
- * from boots. */
+ * comes from boots.
+ */
if (Wwalking && uarmf && is_organic(uarmf) && !uarmf->oerodeproof) {
obj = uarmf;
pline("%s into flame!", Yobjnam2(obj, "burst"));
pline("You're still burning.");
}
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)) {
boil_away = !Fire_resistance;
/* if not fire resistant, sink_into_lava() will quickly be fatal;
destroy_item(SCROLL_CLASS, AD_FIRE);
destroy_item(SPBOOK_CLASS, AD_FIRE);
destroy_item(POTION_CLASS, AD_FIRE);
- return (FALSE);
+ return FALSE;
}
/* called each turn when trapped in lava */
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
* If the monster dies immediately from the blow, the 'I' will
* not stay there, so the player will have suddenly forgotten
* the square's contents for no apparent reason.
- if (!canspotmon(mtmp) &&
- !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph))
- map_invisible(bhitpos.x, bhitpos.y);
+ if (!canspotmon(mtmp)
+ && !glyph_is_invisible(levl[bhitpos.x][bhitpos.y].glyph))
+ map_invisible(bhitpos.x, bhitpos.y);
*/
return FALSE;
}
/* if it was an invisible mimic, treat it as if we stumbled
* 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 */
- distu(mtmp->mx, mtmp->my) <= 2) {
+ && distu(mtmp->mx, mtmp->my) <= 2) {
if (!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data, AD_STCK))
u.ustuck = mtmp;
}
*/
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp);
- return (FALSE);
+ return FALSE;
}
stumble_onto_mimic(mtmp);
return TRUE;
newsym(mtmp->mx, mtmp->my);
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp);
- return (FALSE);
+ return FALSE;
}
if (!((Blind ? Blind_telepat : Unblind_telepat) || Detect_monsters)) {
struct obj *obj;
/* Intelligent chaotic weapons (Stormbringer) want blood */
if (wep && wep->oartifact == ART_STORMBRINGER) {
override_confirmation = TRUE;
- return (FALSE);
+ return FALSE;
}
if (canspotmon(mtmp)) {
Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
if (!paranoid_query(ParanoidHit, qbuf)) {
context.move = 0;
- return (TRUE);
+ return TRUE;
}
}
}
- return (FALSE);
+ return FALSE;
}
/*
Strcpy(buf, y_monnam(mtmp));
buf[0] = highc(buf[0]);
You("stop. %s is in the way!", buf);
- return (TRUE);
+ return TRUE;
} else if ((mtmp->mfrozen || (!mtmp->mcanmove)
|| (mtmp->data->mmove == 0)) && rn2(6)) {
pline("%s doesn't seem to move!", Monnam(mtmp));
- return (TRUE);
+ return TRUE;
} else
- return (FALSE);
+ return FALSE;
}
}
bhitpos.x = u.ux + u.dx;
bhitpos.y = u.uy + u.dy;
if (attack_checks(mtmp, uwep))
- return (TRUE);
+ return TRUE;
if (Upolyd && noattacks(youmonst.data)) {
/* certain "pacifist" monsters don't attack */
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 */
- overexertion())
+ || overexertion())
goto atk_done;
if (u.twoweap && !can_twoweapon())
&& (m_move(mtmp, 0) == 2 || /* it died */
mtmp->mx != u.ux + u.dx
|| mtmp->my != u.uy + u.dy)) /* it moved */
- return (FALSE);
+ return FALSE;
if (Upolyd)
(void) hmonas(mtmp);
&& !(u.uswallow && mtmp == u.ustuck))
map_invisible(u.ux + u.dx, u.uy + u.dy);
- return (TRUE);
+ return TRUE;
}
/* really hit target monster; returns TRUE if it still lives */
cutworm(mon, x, y, weapon);
}
}
- return (malive);
+ return malive;
}
/* hit target monster; returns TRUE if it still lives */
if (wepbefore && !uwep)
wep_was_destroyed = TRUE;
(void) passive(mon, mhit, malive, AT_WEAP, wep_was_destroyed);
- return (malive);
+ return malive;
}
boolean /* general "damage monster" routine */
boolean silvermsg = FALSE, silverobj = FALSE;
boolean valid_weapon_attack = FALSE;
boolean unarmed = !uwep && !uarm && !uarms;
- boolean hand_to_hand = (thrown == HMON_MELEE ||
+ boolean hand_to_hand = (thrown == HMON_MELEE
/* not grapnels; applied implies uwep */
- (thrown == HMON_APPLIED && is_pole(uwep)));
+ || (thrown == HMON_APPLIED && is_pole(uwep)));
int jousting = 0;
int wtype;
struct obj *monwep;
|| obj->oclass == GEM_CLASS) {
/* is it not a melee weapon? */
if (/* if you strike with a bow... */
- is_launcher(obj) ||
+ is_launcher(obj)
/* 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... */
- (!thrown && !u.usteed && is_pole(obj)) ||
+ || (!thrown && !u.usteed && is_pole(obj))
/* or throw a missile without the proper bow... */
- (is_ammo(obj) && (thrown != HMON_THROWN
- || !ammo_and_launcher(obj, uwep)))) {
+ || (is_ammo(obj) && (thrown != HMON_THROWN
+ || !ammo_and_launcher(obj, uwep)))) {
/* then do only 1-2 points of damage */
if (mdat == &mons[PM_SHADE] && !shade_glare(obj))
tmp = 0;
valid_weapon_attack = (tmp > 1);
if (!valid_weapon_attack || mon == u.ustuck || u.twoweap) {
; /* 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 */
- hand_to_hand) {
+ && hand_to_hand) {
You("strike %s from behind!", mon_nam(mon));
tmp += rnd(u.ulevel);
hittxt = TRUE;
ysimple_name(obj));
release_camera_demon(obj, u.ux, u.uy);
useup(obj);
- return (TRUE);
- /*NOTREACHED*/
- break;
+ return TRUE;
case CORPSE: /* fixed by polder@cs.vu.nl */
if (touch_petrifies(&mons[obj->corpsenm])) {
tmp = 1;
if (resists_ston(mon))
break;
/* note: hp may be <= 0 even if munstoned==TRUE */
- return (boolean)(mon->mhp > 0);
+ return (boolean) (mon->mhp > 0);
#if 0
- } else if (touch_petrifies(mdat)) {
- /* maybe turn the corpse into a statue? */
+ } else if (touch_petrifies(mdat)) {
+ ; /* maybe turn the corpse into a statue? */
#endif
}
tmp = (obj->corpsenm >= LOW_PM ? mons[obj->corpsenm].msize
minstapetrify(mon, TRUE);
if (resists_ston(mon))
break;
- return (boolean)(mon->mhp > 0);
+ return (boolean) (mon->mhp > 0);
} else { /* ordinary egg(s) */
const char *eggp =
(obj->corpsenm != NON_PM && obj->known)
&& u.umonnum != PM_SUCCUBUS && u.umonnum != PM_INCUBUS
&& u.umonnum != PM_BALROG) {
demonpet();
- return (0);
+ return 0;
}
switch (mattk->adtyp) {
case AD_STUN:
xkilled(mdef, 0);
} else if (tmp)
killed(mdef);
- return (2);
+ return 2;
}
- return (1);
+ return 1;
}
STATIC_OVL int
mdef->mhp -= tmp;
if (mdef->mhp <= 0) {
killed(mdef);
- return (2);
+ return 2;
}
} else {
shieldeff(mdef->mx, mdef->my);
default:
break;
}
- return (1);
+ return 1;
}
STATIC_OVL void
exercise(A_CON, TRUE);
}
end_engulf();
- return (2);
+ return 2;
case AD_PHYS:
if (youmonst.data == &mons[PM_FOG_CLOUD]) {
pline("%s is laden with your moisture.", Monnam(mdef));
if ((mdef->mhp -= dam) <= 0) {
killed(mdef);
if (mdef->mhp <= 0) /* not lifesaved */
- return (2);
+ return 2;
}
You("%s %s!", is_animal(youmonst.data) ? "regurgitate" : "expel",
mon_nam(mdef));
}
}
}
- return (0);
+ return 0;
}
void
sum[i] = dhit;
/* might be a worm that gets cut in half */
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
* already did it.
*/
rehumanize();
}
if (sum[i] == 2)
- return ((boolean) passive(mon, 1, 0, mattk->aatyp, FALSE));
+ return (boolean) passive(mon, 1, 0, mattk->aatyp, FALSE);
/* defender dead */
else {
(void) passive(mon, sum[i], 1, mattk->aatyp, FALSE);
if (multi < 0)
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. */
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_OVL void
restfakecorr(grd)
-register struct monst *grd;
+struct monst *grd;
{
/* it seems you left the corridor - let the guard disappear */
if (clear_fcorr(grd, FALSE)) {
}
}
-boolean grddead(grd) /* called in mon.c */
-register struct monst *grd;
+/* called in mon.c */
+boolean
+grddead(grd)
+struct monst *grd;
{
- register boolean dispose = clear_fcorr(grd, TRUE);
+ boolean dispose = clear_fcorr(grd, TRUE);
if (!dispose) {
/* destroy guard's gold; drop any other inventory */
STATIC_OVL boolean
in_fcorridor(grd, x, y)
-register struct monst *grd;
+struct monst *grd;
int x, y;
{
register int fci;
+ struct egd *egrd = EGD(grd);
- for (fci = EGD(grd)->fcbeg; fci < EGD(grd)->fcend; fci++)
- if (x == EGD(grd)->fakecorr[fci].fx
- && y == EGD(grd)->fakecorr[fci].fy)
- return (TRUE);
- return (FALSE);
+ for (fci = egrd->fcbeg; fci < egrd->fcend; fci++)
+ if (x == egrd->fakecorr[fci].fx && y == egrd->fakecorr[fci].fy)
+ return TRUE;
+ return FALSE;
}
STATIC_OVL
if (DEADMONSTER(mtmp))
continue;
if (mtmp->isgd && on_level(&(EGD(mtmp)->gdlevel), &u.uz))
- return (mtmp);
+ return mtmp;
}
- return ((struct monst *) 0);
+ return (struct monst *) 0;
}
char
for (ptr = array; *ptr; ptr++)
if (rooms[*ptr - ROOMOFFSET].rtype == VAULT)
- return (*ptr);
- return ('\0');
+ return *ptr;
+ return '\0';
}
void
(void) mungspaces(buf);
} while (!letter(buf[0]) && --trycount > 0);
- if (u.ualign.type == A_LAWFUL &&
- /* ignore trailing text, in case player includes character's rank
- */
- strncmpi(buf, plname, (int) strlen(plname)) != 0) {
+ if (u.ualign.type == A_LAWFUL
+ /* ignore trailing text, in case player includes rank */
+ && strncmpi(buf, plname, (int) strlen(plname)) != 0) {
adjalign(-1); /* Liar! */
}
uchar typ;
struct fakecorridor *fcp;
register struct egd *egrd = EGD(grd);
- register struct rm *crm;
- register boolean goldincorridor = FALSE,
- u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE,
- grd_in_vault =
- *in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
+ struct rm *crm;
+ boolean goldincorridor = FALSE,
+ u_in_vault = vault_occupied(u.urooms) ? TRUE : FALSE,
+ grd_in_vault = *in_rooms(grd->mx, grd->my, VAULT) ? TRUE : FALSE;
boolean disappear_msg_seen = FALSE, semi_dead = (grd->mhp <= 0);
long umoney = money_cnt(invent);
register boolean u_carry_gold = ((umoney + hidden_gold()) > 0L);
boolean see_guard, newspot = FALSE;
if (!on_level(&(egrd->gdlevel), &u.uz))
- return (-1);
+ return -1;
nx = ny = m = n = 0;
if (!u_in_vault && !grd_in_vault)
wallify_vault(grd);
}
if (!in_fcorridor(grd, grd->mx, grd->my))
(void) clear_fcorr(grd, TRUE);
- return (-1);
+ return -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) {
verbalize("How dare you %s that gold, scoundrel!",
(egrd->witness & GD_EATGOLD) ? "consume" : "destroy");
egrd->witness = 0;
grd->mpeaceful = 0;
- return (-1);
+ return -1;
}
if (egrd->fcend == 1) {
if (u_in_vault && (u_carry_gold || um_dist(grd->mx, grd->my, 1))) {
levl[m][n].typ = egrd->fakecorr[0].ftyp;
newsym(m, n);
grd->mpeaceful = 0;
- return (-1);
+ return -1;
}
/* not fair to get mad when (s)he's fainted or paralyzed */
if (!is_fainted() && multi >= 0)
egrd->warncnt++;
- return (0);
+ return 0;
}
if (!u_in_vault) {
: "are confronted by %s.",
/* "an angry guard" */
x_monnam(grd, ARTICLE_A, "angry", 0, FALSE));
- return (-1);
+ return -1;
} else {
if (!Deaf)
verbalize("Well, begone.");
disappear_msg_seen = TRUE;
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 */
- (egrd->fcend > 1 && u_in_vault))) {
+ || (egrd->fcend > 1 && u_in_vault))) {
if (!grd->mx) {
restfakecorr(grd);
- return (-2);
+ return -2;
}
if (egrd->warncnt < 6) {
egrd->warncnt = 6;
if (!Deaf)
verbalize("Drop all your gold, scoundrel!");
- return (0);
+ return 0;
} else {
if (!Deaf)
verbalize("So be it, rogue!");
grd->mpeaceful = 0;
- return (-1);
+ return -1;
}
}
}
&& !(u.ustuck && !sticks(youmonst.data)))
verbalize("Move along!");
restfakecorr(grd);
- return (0); /* didn't move */
+ return 0; /* didn't move */
}
x = grd->mx;
y = grd->my;
fcp->ftyp = typ;
newpos:
if (egrd->gddone) {
- /* The following is a kludge. We need to keep */
- /* the guard around in order to be able to make */
- /* the fake corridor disappear as the player */
- /* moves out of it, but we also need the guard */
- /* out of the way. We send the guard to never- */
- /* never land. We set ogx ogy to mx my in order */
- /* to avoid a check at the top of this function. */
- /* At the end of the process, the guard is killed */
- /* in restfakecorr(). */
+ /* The following is a kludge. We need to keep */
+ /* the guard around in order to be able to make */
+ /* the fake corridor disappear as the player */
+ /* moves out of it, but we also need the guard */
+ /* out of the way. We send the guard to never- */
+ /* never land. We set ogx ogy to mx my in order */
+ /* to avoid a check at the top of this function. */
+ /* At the end of the process, the guard is killed */
+ /* in restfakecorr(). */
cleanup:
x = grd->mx;
y = grd->my;
if (!semi_dead && (in_fcorridor(grd, u.ux, u.uy) || cansee(x, y))) {
if (!disappear_msg_seen && see_guard)
pline("Suddenly, %s disappears.", noit_mon_nam(grd));
- return (1);
+ return 1;
}
- return (-2);
+ return -2;
}
egrd->ogx = grd->mx; /* update old positions */
egrd->ogy = grd->my;
} else
newsym(grd->mx, grd->my);
restfakecorr(grd);
- return (1);
+ return 1;
}
/* Routine when dying or quitting with a vault guard around */
long
hidden_gold()
{
- register long value = 0L;
- register struct obj *obj;
+ long value = 0L;
+ struct obj *obj;
for (obj = invent; obj; obj = obj->nobj)
if (Has_contents(obj))
value += contained_gold(obj);
/* 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))
- return (FALSE);
+ return FALSE;
else
- return ((boolean)(grd == (struct monst *) 0));
+ return (boolean) (grd == (struct monst *) 0);
}
void
unsigned int activity;
{
struct monst *guard = findgd();
+
if (guard && guard->mcansee && m_canseeu(guard)) {
if (activity == GD_EATGOLD || activity == GD_DESTROYGOLD)
EGD(guard)->witness = activity;
}
}
+
/*vault.c*/
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
/*
- * This module contains code for calculation of "to hit" and damage
- * bonuses for any given weapon used, as well as weapons selection
- * code for monsters.
+ * This module contains code for calculation of "to hit" and damage
+ * bonuses for any given weapon used, as well as weapons selection
+ * code for monsters.
*/
#include "hack.h"
}
/*
- * hitval returns an integer representing the "to hit" bonuses
- * of "otmp" against the monster.
+ * hitval returns an integer representing the "to hit" bonuses
+ * of "otmp" against the monster.
*/
int
hitval(otmp, mon)
if (Is_weapon)
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;
- /* 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 */
if (Is_weapon && otmp->blessed
*/
/*
- * dmgval returns an integer representing the damage bonuses
- * of "otmp" against the monster.
+ * dmgval returns an integer representing the damage bonuses
+ * of "otmp" against the monster.
*/
int
dmgval(otmp, 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
|| otmp->oclass == CHAIN_CLASS) {
int bonus = 0;
tmp = 1;
}
- return (tmp);
+ return tmp;
}
STATIC_DCL struct obj *FDECL(oselect, (struct monst *, int));
#define Oselect(x) \
if ((otmp = oselect(mtmp, x)) != 0) \
- return (otmp);
+ return otmp;
STATIC_OVL struct obj *
oselect(mtmp, x)
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otmp->otyp == x
- &&
/* never select non-cockatrice corpses */
- !((x == CORPSE || x == EGG)
- && !touch_petrifies(&mons[otmp->corpsenm]))
+ && !((x == CORPSE || x == EGG)
+ && !touch_petrifies(&mons[otmp->corpsenm]))
&& (!otmp->oartifact || touch_artifact(otmp, mtmp)))
return otmp;
}
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 obj *otmp;
/* Don't throw a cursed weapon-in-hand or an artifact */
if ((otmp = oselect(mtmp, rwep[i])) && !otmp->oartifact
&& !(otmp == MON_WEP(mtmp) && mwelded(otmp)))
- return (otmp);
+ return otmp;
} else
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otmp->otyp == LOADSTONE && !otmp->cursed)
SCALPEL, KNIFE, WORM_TOOTH
};
+/* select a hand to hand weapon for the monster */
struct obj *
-select_hwep(mtmp) /* select a hand to hand weapon for the monster */
+select_hwep(mtmp)
register struct monst *mtmp;
{
register struct obj *otmp;
else if (dex < 8)
return (sbon - 1);
else if (dex < 14)
- return (sbon);
+ return sbon;
else
return (sbon + dex - 14);
}
int str = ACURR(A_STR);
if (Upolyd)
- return (0);
+ return 0;
if (str < 6)
- return (-1);
+ return -1;
else if (str < 16)
- return (0);
+ return 0;
else if (str < 18)
- return (1);
+ return 1;
else if (str == 18)
- return (2); /* up to 18 */
+ return 2; /* up to 18 */
else if (str <= STR18(75))
- return (3); /* up to 18/75 */
+ return 3; /* up to 18/75 */
else if (str <= STR18(90))
- return (4); /* up to 18/90 */
+ return 4; /* up to 18/90 */
else if (str < STR18(100))
- return (5); /* up to 18/99 */
+ return 5; /* up to 18/99 */
else
- return (6);
+ return 6;
}
/* increase a towel's wetness */
int tmp = P_SKILL(skill);
/* The more difficult the training, the more slots it takes.
- * unskilled -> basic 1
- * basic -> skilled 2
- * skilled -> expert 3
+ * unskilled -> basic 1
+ * basic -> skilled 2
+ * skilled -> expert 3
*/
if (skill <= P_LAST_WEAPON || skill == P_TWO_WEAPON_COMBAT)
return tmp;
/* Fewer slots used up for unarmed or martial.
- * unskilled -> basic 1
- * basic -> skilled 1
- * skilled -> expert 2
- * expert -> master 2
- * master -> grand master 3
+ * unskilled -> basic 1
+ * basic -> skilled 1
+ * skilled -> expert 2
+ * expert -> master 2
+ * master -> grand master 3
*/
return (tmp + 1) / 2;
}
int skill;
boolean speedy;
{
- return !P_RESTRICTED(skill) && P_SKILL(skill) < P_MAX_SKILL(skill)
- && ((wizard && speedy)
- || (P_ADVANCE(skill) >= (unsigned) practice_needed_to_advance(
- P_SKILL(skill))
- && u.skills_advanced < P_SKILL_LIMIT
- && u.weapon_slots >= slots_required(skill)));
+ if (P_RESTRICTED(skill)
+ || P_SKILL(skill) >= P_MAX_SKILL(skill)
+ || u.skills_advanced >= P_SKILL_LIMIT)
+ return FALSE;
+
+ 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 */
could_advance(skill)
int skill;
{
- return !P_RESTRICTED(skill) && P_SKILL(skill) < P_MAX_SKILL(skill)
- && ((P_ADVANCE(skill)
- >= (unsigned) practice_needed_to_advance(P_SKILL(skill))
- && u.skills_advanced < P_SKILL_LIMIT));
+ if (P_RESTRICTED(skill)
+ || P_SKILL(skill) >= P_MAX_SKILL(skill)
+ || 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
peaked_skill(skill)
int skill;
{
- return !P_RESTRICTED(skill) && P_SKILL(skill) >= P_MAX_SKILL(skill)
- && ((P_ADVANCE(skill)
- >= (unsigned) practice_needed_to_advance(P_SKILL(skill))));
+ if (P_RESTRICTED(skill))
+ return FALSE;
+
+ return (boolean) (P_SKILL(skill) >= P_MAX_SKILL(skill)
+ && ((int) P_ADVANCE(skill)
+ >= practice_needed_to_advance(P_SKILL(skill))));
}
STATIC_OVL void
int skill;
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) {
u.weapon_slots--;
} else if (u.skills_advanced) {
int type;
if (!obj)
- /* Not using a weapon */
- return (P_BARE_HANDED_COMBAT);
+ return P_BARE_HANDED_COMBAT; /* Not using a weapon */
if (obj->oclass != WEAPON_CLASS && obj->oclass != TOOL_CLASS
&& obj->oclass != GEM_CLASS)
- /* Not a weapon, weapon-tool, or ammo */
- return (P_NONE);
+ return P_NONE; /* Not a weapon, weapon-tool, or ammo */
type = objects[obj->otyp].oc_skill;
- return ((type < 0) ? -type : type);
+ return (type < 0) ? -type : type;
}
int
}
} else if (type == P_BARE_HANDED_COMBAT) {
/*
- * b.h. m.a.
- * unskl: +1 n/a
- * basic: +1 +3
- * skild: +2 +4
- * exprt: +2 +5
- * mastr: +3 +6
- * grand: +3 +7
+ * b.h. m.a.
+ * unskl: +1 n/a
+ * basic: +1 +3
+ * skild: +2 +4
+ * exprt: +2 +5
+ * mastr: +3 +6
+ * grand: +3 +7
*/
bonus = P_SKILL(type);
bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */
}
} else if (type == P_BARE_HANDED_COMBAT) {
/*
- * b.h. m.a.
- * unskl: 0 n/a
- * basic: +1 +3
- * skild: +1 +4
- * exprt: +2 +6
- * mastr: +2 +7
- * grand: +3 +9
+ * b.h. m.a.
+ * unskl: 0 n/a
+ * basic: +1 +3
+ * skild: +1 +4
+ * exprt: +2 +6
+ * mastr: +2 +7
+ * grand: +3 +9
*/
bonus = P_SKILL(type);
bonus = max(bonus, P_UNSKILLED) - 1; /* unskilled => 0 */
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
/* wizard code - inspired by rogue code from Merlyn Leroy (digi-g!brian) */
-/* - heavily modified to give the wiz balls. (genat!mike) */
-/* - dewimped and given some maledictions. -3. */
-/* - generalized for 3.1 (mike@bullns.on01.bull.ca) */
+/* - heavily modified to give the wiz balls. (genat!mike) */
+/* - dewimped and given some maledictions. -3. */
+/* - generalized for 3.1 (mike@bullns.on01.bull.ca) */
#include "hack.h"
#include "qtext.h"
struct obj *amu;
#if 0 /* caller takes care of this check */
- if (!u.uhave.amulet)
- return;
+ if (!u.uhave.amulet)
+ return;
#endif
if ((((amu = uamul) != 0 && amu->otyp == AMULET_OF_YENDOR)
|| ((amu = uwep) != 0 && amu->otyp == AMULET_OF_YENDOR))
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->otyp == AMULET_OF_YENDOR)
- return (1);
- return (0);
+ return 1;
+ return 0;
}
int
|| otmp->otyp == BELL_OF_OPENING
|| otmp->otyp == CANDELABRUM_OF_INVOCATION
|| otmp->otyp == SPE_BOOK_OF_THE_DEAD)
- return (1);
- return (0);
+ return 1;
+ return 0;
}
/*
- * New for 3.1 Strategy / Tactics for the wiz, as well as other
- * monsters that are "after" something (defined via mflag3).
+ * New for 3.1 Strategy / Tactics for the wiz, as well as other
+ * monsters that are "after" something (defined via mflag3).
*
- * The strategy section decides *what* the monster is going
- * to attempt, the tactics section implements the decision.
+ * The strategy section decides *what* the monster is going
+ * to attempt, the tactics section implements the decision.
*/
#define STRAT(w, x, y, typ) \
((unsigned long) (w) | ((unsigned long) (x) << 16) \
{
switch (mask) {
case M3_WANTSAMUL:
- return (AMULET_OF_YENDOR);
+ return AMULET_OF_YENDOR;
case M3_WANTSBELL:
- return (BELL_OF_OPENING);
+ return BELL_OF_OPENING;
case M3_WANTSCAND:
- return (CANDELABRUM_OF_INVOCATION);
+ return CANDELABRUM_OF_INVOCATION;
case M3_WANTSBOOK:
- return (SPE_BOOK_OF_THE_DEAD);
+ return SPE_BOOK_OF_THE_DEAD;
default:
break; /* 0 signifies quest artifact */
}
- return (0);
+ return 0;
}
/*
- * If "otyp" is zero, it triggers a check for the quest_artifact,
- * since bell, book, candle, and amulet are all objects, not really
- * artifacts right now. [MRS]
+ * If "otyp" is zero, it triggers a check for the quest_artifact,
+ * since bell, book, candle, and amulet are all objects, not really
+ * artifacts right now. [MRS]
*/
STATIC_OVL boolean
mon_has_arti(mtmp, otyp)
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) {
if (otyp) {
if (otmp->otyp == otyp)
- return (1);
+ return 1;
} else if (is_quest_artifact(otmp))
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
STATIC_OVL struct monst *
/* no need for !DEADMONSTER check here since they have no inventory */
if (mtmp2 != mtmp)
if (mon_has_arti(mtmp2, otyp))
- return (mtmp2);
+ return mtmp2;
- return ((struct monst *) 0);
+ return (struct monst *) 0;
}
STATIC_OVL struct obj *
for (otmp = fobj; otmp; otmp = otmp->nobj)
if (otyp) {
if (otmp->otyp == otyp)
- return (otmp);
+ return otmp;
} else if (is_quest_artifact(otmp))
- return (otmp);
- return ((struct obj *) 0);
+ return otmp;
+ return (struct obj *) 0;
}
STATIC_OVL boolean
{
switch (mask) {
case M3_WANTSAMUL:
- return (boolean)(u.uhave.amulet);
+ return (boolean) u.uhave.amulet;
case M3_WANTSBELL:
- return (boolean)(u.uhave.bell);
+ return (boolean) u.uhave.bell;
case M3_WANTSCAND:
- return (boolean)(u.uhave.menorah);
+ return (boolean) u.uhave.menorah;
case M3_WANTSBOOK:
- return (boolean)(u.uhave.book);
+ return (boolean) u.uhave.book;
case M3_WANTSARTI:
- return (boolean)(u.uhave.questart);
+ return (boolean) u.uhave.questart;
default:
break;
}
- return (0);
+ return 0;
}
STATIC_OVL unsigned long
otyp = which_arti(mask);
if (!mon_has_arti(mtmp, otyp)) {
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)))
- return (STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask));
- else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0 &&
+ return STRAT(STRAT_GROUND, otmp->ox, otmp->oy, mask);
+ else if ((mtmp2 = other_mon_has_arti(mtmp, otyp)) != 0
/* when seeking the Amulet, avoid targetting the Wizard
or temple priests (to protect Moloch's high priest) */
- (otyp != AMULET_OF_YENDOR
- || (!mtmp2->iswiz && !inhistemple(mtmp2))))
- return (STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask));
+ && (otyp != AMULET_OF_YENDOR
+ || (!mtmp2->iswiz && !inhistemple(mtmp2))))
+ return STRAT(STRAT_MONSTR, mtmp2->mx, mtmp2->my, mask);
}
return (unsigned long) STRAT_NONE;
}
{
unsigned long strat, dstrat;
- if (!is_covetous(mtmp->data) ||
+ if (!is_covetous(mtmp->data)
/* perhaps a shopkeeper has been polymorphed into a master
lich; we don't want it teleporting to the stairs to heal
because that will leave its shop untended */
- (mtmp->isshk && inhishop(mtmp)) ||
+ || (mtmp->isshk && inhishop(mtmp))
/* likewise for temple priests */
- (mtmp->ispriest && inhistemple(mtmp)))
+ || (mtmp->ispriest && inhistemple(mtmp)))
return (unsigned long) STRAT_NONE;
switch ((mtmp->mhp * 3) / mtmp->mhpmax) { /* 0-3 */
default:
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 */
if (mtmp->data != &mons[PM_WIZARD_OF_YENDOR])
- return (unsigned long) (STRAT_HEAL);
+ return (unsigned long) STRAT_HEAL;
/* else fall through */
case 2:
if (context.made_amulet)
if ((strat = target_on(M3_WANTSAMUL, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if (u.uevent.invoked) { /* priorities change once gate opened */
-
if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
} else {
if ((strat = target_on(M3_WANTSBOOK, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSBELL, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSCAND, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
if ((strat = target_on(M3_WANTSARTI, mtmp)) != STRAT_NONE)
- return (strat);
+ return strat;
}
- return (dstrat);
+ return dstrat;
}
int
if (distu(mtmp->mx, mtmp->my) > (BOLT_LIM * BOLT_LIM))
if (mtmp->mhp <= mtmp->mhpmax - 8) {
mtmp->mhp += rnd(8);
- return (1);
+ return 1;
}
/* fall through :-) */
case STRAT_NONE: /* harass */
if (!rn2(!mtmp->mflee ? 5 : 33))
mnexto(mtmp);
- return (0);
+ return 0;
default: /* kill, maim, pillage! */
{
struct obj *otmp;
if (!targ) { /* simply wants you to close */
- return (0);
+ return 0;
}
if ((u.ux == tx && u.uy == ty) || where == STRAT_PLAYER) {
/* player is standing on it (or has it) */
mnexto(mtmp);
- return (0);
+ return 0;
}
if (where == STRAT_GROUND) {
if (!MON_AT(tx, ty) || (mtmp->mx == tx && mtmp->my == ty)) {
: distant_name(otmp, doname));
obj_extract_self(otmp);
(void) mpickobj(mtmp, otmp);
- return (1);
+ return 1;
} else
- return (0);
+ return 0;
} else {
/* a monster is standing on it - cause some trouble */
if (!rn2(5))
mnexto(mtmp);
- return (0);
+ return 0;
}
} else { /* a monster has it - 'port beside it. */
(void) mnearto(mtmp, tx, ty, FALSE);
- return (0);
+ return 0;
}
}
}
/*NOTREACHED*/
- return (0);
+ return 0;
}
void
return count;
}
-/* Let's resurrect the wizard, for some unexpected fun. */
+/* Let's resurrect the wizard, for some unexpected fun. */
void
resurrect()
{
verb = "elude";
mmtmp = &migrating_mons;
while ((mtmp = *mmtmp) != 0) {
- if (mtmp->iswiz &&
+ if (mtmp->iswiz
/* 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) {
mon_catchup_elapsed_time(mtmp, elapsed);
if (elapsed >= LARGEST_INT)
}
}
-/* Here, we make trouble for the poor shmuck who actually */
-/* managed to do in the Wizard. */
+/* Here, we make trouble for the poor shmuck who actually
+ managed to do in the Wizard. */
void
intervene()
{
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
/* Description of long worm implementation.
*
* 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,
* it just means that the monster does not have a long worm tail.
*
* singly threaded linked lists. The wormno variable is used as an index
* for these segment arrays.
*
- * wtails: The first (starting struct) of a linked list. This points
- * to the tail (last) segment of the worm.
- *
- * 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 head). Note that the segment that wheads[wormno] points
- * to, is not displayed. It is simply there to keep track of
- * where the head came from, so that worm movement and display
- *are
- * simplified later.
- * 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
- * necessary.
- * From now on, we will use "start" and "end" to refer to the
- * linked list and "head" and "tail" to refer to the worm.
+ * wtails: The first (starting struct) of a linked list. This points
+ * to the tail (last) segment of the worm.
+ *
+ * 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 head). Note that the segment that wheads[wormno] points
+ * to, is not displayed. It is simply there to keep track of
+ * where the head came from, so that worm movement and display
+ * are simplified later.
+ * 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
+ * necessary.
+ * From now on, we will use "start" and "end" to refer to the
+ * linked list and "head" and "tail" to refer to the worm.
*
* 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
* segment at the tail (unless we want it to grow). This new head segment is
new_wormno++;
}
- return (0); /* level infested with worms */
+ return 0; /* level infested with worms */
}
/*
/* Normally 17-20 does */
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)
return; /* not good enough */
*nx = x;
*ny = y;
- *nx += (x > 1 ? /* extreme left ? */
- (x < COLNO ? /* extreme right ? */
- (rn2(3) - 1) /* neither so +1, 0, or -1 */
- : -rn2(2)) /* 0, or -1 */
- : rn2(2)); /* 0, or 1 */
+ *nx += (x > 1 /* extreme left ? */
+ ? (x < COLNO /* extreme right ? */
+ ? (rn2(3) - 1) /* neither so +1, 0, or -1 */
+ : -rn2(2)) /* 0, or -1 */
+ : rn2(2)); /* 0, or 1 */
- *ny +=
- (*nx == x ? /* same kind of thing with y */
- (y > 1 ? (y < ROWNO ? (rn2(2) ? 1 : -1) : -1) : 1)
- : (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2)));
+ *ny += (*nx == x /* same kind of thing with y */
+ ? (y > 1 ? (y < ROWNO ? (rn2(2) ? 1 : -1) : -1) : 1)
+ : (y > 1 ? (y < ROWNO ? (rn2(3) - 1) : -rn2(2)) : rn2(2)));
}
/* count_wsegs()
- *
- * returns
- * the number of visible segments that a worm has.
+ * returns the number of visible segments that a worm has.
*/
-
int
count_wsegs(mtmp)
struct monst *mtmp;
}
/* create_worm_tail()
- *
- * will create a worm tail chain of (num_segs + 1) and return a pointer to
- * it.
+ * will create a worm tail chain of (num_segs + 1) and return pointer to it.
*/
STATIC_OVL
struct wseg *
i++;
}
- return (new_tail);
+ return new_tail;
}
/* worm_known()
- *
* Is any segment of this worm in viewing range? Note: caller must check
* invisibility and telepathy (which should only show the head anyway).
* Mostly used in the canseemon() macro.
* With digits representing relative sequence number of the segments,
* returns true when testing between @ and ? (passes through worm's
* body), false between @ and ! (stays on same side of worm).
- * .w1?..
- * ..@2..
- * .65!3.
- * ...4..
+ * .w1?..
+ * ..@2..
+ * .65!3.
+ * ...4..
*/
if (distmin(x1, y1, x2, y2) != 1) {
/* 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 */
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)
- return (boolean)(wnxt->wx == x1 && wnxt->wy == y2);
+ return (boolean) (wnxt->wx == x1 && wnxt->wy == y2);
}
/* should never reach here... */
return FALSE;
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
for (obj = mon->minvent; obj; obj = obj->nobj)
if (obj->owornmask & flag)
return obj;
- return ((struct obj *) 0);
+ return (struct obj *) 0;
}
}
}
}
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 */
- (handless_or_tiny || !is_flimsy(otmp))) {
+ && (handless_or_tiny || !is_flimsy(otmp))) {
if (vis)
pline("%s helmet falls to the %s!", s_suffix(Monnam(mon)),
surface(mon->mx, mon->my));
* Exceptions to things based on race. Correctly checks polymorphed player
*race.
* Returns:
- * 0 No exception, normal rules apply.
- * 1 If the race/object combination is acceptable.
- * -1 If the race/object combination is unacceptable.
+ * 0 No exception, normal rules apply.
+ * 1 If the race/object combination is acceptable.
+ * -1 If the race/object combination is unacceptable.
*/
int
racial_exception(mon, obj)
return 1;
/* Unacceptable Exceptions: */
/* Checks for object that certain races should never use go here */
- /* return -1; */
+ /* return -1; */
return 0;
}
-/* 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. */
#include "hack.h"
switch (otmp->otyp) {
#ifdef MAIL
case SCR_MAIL:
- return (2);
-/* break; */
+ return 2;
#endif
case SCR_LIGHT:
case SCR_GOLD_DETECTION:
case SCR_AMNESIA:
case SCR_FIRE:
case SCR_EARTH:
- return (8);
- /* break; */
+ return 8;
case SCR_DESTROY_ARMOR:
case SCR_CREATE_MONSTER:
case SCR_PUNISHMENT:
- return (10);
- /* break; */
+ return 10;
case SCR_CONFUSE_MONSTER:
- return (12);
- /* break; */
+ return 12;
case SCR_IDENTIFY:
- return (14);
- /* break; */
+ return 14;
case SCR_ENCHANT_ARMOR:
case SCR_REMOVE_CURSE:
case SCR_ENCHANT_WEAPON:
case SCR_CHARGING:
- return (16);
- /* break; */
+ return 16;
case SCR_SCARE_MONSTER:
case SCR_STINKING_CLOUD:
case SCR_TAMING:
case SCR_TELEPORTATION:
- return (20);
- /* break; */
+ return 20;
case SCR_GENOCIDE:
- return (30);
- /* break; */
+ return 30;
case SCR_BLANK_PAPER:
default:
impossible("You can't write such a weird scroll!");
}
- return (1000);
+ return 1000;
}
/* decide whether the hero knowns a particular scroll's label;
static NEARDATA const char write_on[] = { SCROLL_CLASS, SPBOOK_CLASS, 0 };
+/* write -- applying a magic marker */
int
dowrite(pen)
register struct obj *pen;
return 0;
/* 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" */
- typeword = (paper->otyp == SPE_NOVEL) ? "book"
- : (paper->oclass == SPBOOK_CLASS) ? "spellbook" : "scroll";
+ typeword = (paper->otyp == SPE_NOVEL)
+ ? "book"
+ : (paper->oclass == SPBOOK_CLASS)
+ ? "spellbook"
+ : "scroll";
if (Blind) {
if (!paper->dknown) {
You("don't know if that %s is blank or not.", typeword);
entry, so we don't simply use first match with it;
also, player might assign same name multiple times
and if so, we choose one of those matches randomly */
- if (objects[i].oc_uname && !strcmpi(objects[i].oc_uname, nm) &&
- /* first match: chance incremented to 1,
- !rn2(1) is 1, we remember i;
- second match: chance incremented to 2,
- !rn2(2) has 1/2 chance to replace i;
- third match: chance incremented to 3,
- !rn2(3) has 1/3 chance to replace i
- and 2/3 chance to keep previous 50:50
- choice; so on for higher match counts */
- !rn2(++deferralchance))
+ if (objects[i].oc_uname && !strcmpi(objects[i].oc_uname, nm)
+ /*
+ * First match: chance incremented to 1,
+ * !rn2(1) is 1, we remember i;
+ * second match: chance incremented to 2,
+ * !rn2(2) has 1/2 chance to replace i;
+ * third match: chance incremented to 3,
+ * !rn2(3) has 1/3 chance to replace i
+ * and 2/3 chance to keep previous 50:50
+ * choice; so on for higher match counts.
+ */
+ && !rn2(++deferralchance))
deferred = i;
}
/* writing by user-assigned name is same as by description:
if (pen->spe < basecost / 2) {
Your("marker is too dry to write that!");
obfree(new_obj, (struct obj *) 0);
- return (1);
+ return 1;
}
/* we're really going to write now, so calculate cost
useup(paper);
}
obfree(new_obj, (struct obj *) 0);
- return (1);
+ return 1;
}
pen->spe -= actualcost;
*/
/* 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 */
- !(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 */
- 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");
/* scrolls disappear, spellbooks don't */
if (paper->oclass == SPBOOK_CLASS) {
useup(paper);
}
obfree(new_obj, (struct obj *) 0);
- return (1);
+ return 1;
}
/* can write scrolls when blind, but requires luck too;
attempts to write books when blind are caught above */
new_obj =
hold_another_object(new_obj, "Oops! %s out of your grasp!",
The(aobjnam(new_obj, "slip")), (const char *) 0);
- return (1);
+ return 1;
}
/* most book descriptions refer to cover appearance, so we can issue a
"vellum",
"cloth",
#if 0
- "canvas", "hardcover", /* not used */
- "papyrus", /* not applicable--can't be produced via writing */
+ "canvas", "hardcover", /* not used */
+ "papyrus", /* not applicable--can't be produced via writing */
#endif /*0*/
0
};
-/* 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. */
/* NetHack may be freely redistributed. See license for details. */
so that casting a spell won't re-discover its forgotten book. */
if (obj->oclass != SPBOOK_CLASS) {
/* 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) {
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 {
/* 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)
obj->dknown = 1;
/* make the discovery iff we know what we're manipulating */
* get_container_location() returns the following information
* about the outermost container:
* loc argument gets set to:
- * OBJ_INVENT if in hero's inventory; return 0.
- * OBJ_FLOOR if on the floor; return 0.
- * OBJ_BURIED if buried; return 0.
- * OBJ_MINVENT if in monster's inventory; return monster.
+ * OBJ_INVENT if in hero's inventory; return 0.
+ * OBJ_FLOOR if on the floor; return 0.
+ * OBJ_BURIED if buried; return 0.
+ * OBJ_MINVENT if in monster's inventory; return monster.
* container_nesting is updated with the nesting depth of the containers
* if applicable.
*/
boolean u_ring;
/* Is this a charged/enchanted object? */
- if (!obj || (!objects[obj->otyp].oc_charged && obj->oclass != WEAPON_CLASS
- && obj->oclass != ARMOR_CLASS && !is_weptool(obj))
+ if (!obj
+ || (!objects[obj->otyp].oc_charged && obj->oclass != WEAPON_CLASS
+ && obj->oclass != ARMOR_CLASS && !is_weptool(obj))
|| obj->spe <= 0)
- return (FALSE);
+ return FALSE;
if (defends(AD_DRLI, obj) || defends_when_carried(AD_DRLI, obj)
|| obj_resists(obj, 10, 90))
- return (FALSE);
+ return FALSE;
/* Charge for the cost of the object */
costly_alteration(obj, COST_DRAIN);
}
if (carried(obj))
update_inventory();
- return (TRUE);
+ return TRUE;
}
boolean
struct obj *obj;
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 == BELL_OF_OPENING
|| (obj->otyp == CORPSE && is_rider(&mons[obj->corpsenm]))) {
} else {
int chance = rn2(100);
- return ((boolean)(chance < (obj->oartifact ? achance : ochance)));
+ return (boolean) (chance < (obj->oartifact ? achance : ochance));
}
}
if (obj->quan > 4L)
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.
* monster's inventory. They are not polymorphed
* either.
* UNDEAD_TURNING - When an undead creature gets killed via
- * undead turning, prevent its corpse from being
- * immediately revived by the same effect.
+ * undead turning, prevent its corpse from being
+ * immediately revived by the same effect.
* STONE_TO_FLESH - If a statue can't be revived, its
- * contents get dropped before turning it into
- * meat; prevent those contents from being hit.
+ * contents get dropped before turning it into
+ * meat; prevent those contents from being hit.
* 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
- * Drop can alter the invent chain while traversal
- * is in progress (bhito isn't involved).
+ * Drop can alter the invent chain while traversal
+ * is in progress (bhito isn't involved).
*
* The bypass bit on all objects is reset each turn, whenever
* context.bypasses is set.
/*
* 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
*/
int
static NEARDATA const char zap_syms[] = { WAND_CLASS, 0 };
+/* 'z' command (or 'y' if numbed_pad==-1) */
int
dozap()
{
int damage;
if (check_capacity((char *) 0))
- return (0);
+ return 0;
obj = getobj(zap_syms, "zap");
if (!obj)
- return (0);
+ return 0;
check_unpaid(obj);
else if (obj->cursed && !rn2(WAND_BACKFIRE_CHANCE)) {
backfire(obj); /* the wand blows up in your face! */
exercise(A_STR, FALSE);
- return (1);
+ return 1;
} else if (!(objects[obj->otyp].oc_dir == NODIR) && !getdir((char *) 0)) {
if (!Blind)
pline("%s glows and fades.", The(xname(obj)));
losehp(Maybe_Half_Phys(damage), buf, NO_KILLER_PREFIX);
}
} else {
- /* Are we having fun yet?
+ /* Are we having fun yet?
* weffects -> buzz(obj->otyp) -> zhitm (temple priest) ->
* attack -> hitum -> known_hitum -> ghod_hitsu ->
* buzz(AD_ELEC) -> destroy_item(WAND_CLASS) ->
useup(obj);
}
update_inventory(); /* maybe used a charge */
- return (1);
+ return 1;
}
int
that the wand itself has been seen */
if (learn_it)
learnwand(obj);
- return (damage);
+ return damage;
}
/* called when poly'd hero uses breath attack against self */
const char *
exclam(force)
-register int force;
+int force;
{
/* force == 0 occurs e.g. with sleep ray */
/* note that large force is usual with wands so that !! would
void
hit(str, mtmp, force)
-register const char *str;
-register struct monst *mtmp;
-register const char *force; /* usually either "." or "!" */
+const char *str;
+struct monst *mtmp;
+const char *force; /* usually either "." or "!" */
{
if ((!cansee(bhitpos.x, bhitpos.y) && !canspotmon(mtmp)
&& !(u.uswallow && mtmp == u.ustuck)) || !flags.verbose)
pline("%s %s it.", The(str), vtense(str, "hit"));
else
- pline("%s %s %s%s", The(str), vtense(str, "hit"), mon_nam(mtmp),
- force);
+ pline("%s %s %s%s", The(str), vtense(str, "hit"),
+ mon_nam(mtmp), force);
}
void
/*
* Called for the following distance effects:
- * when a weapon is thrown (weapon == THROWN_WEAPON)
- * when an object is kicked (KICKED_WEAPON)
- * when an IMMEDIATE wand is zapped (ZAPPED_WAND)
- * when a light beam is flashed (FLASHED_LIGHT)
- * when a mirror is applied (INVIS_BEAM)
- * A thrown/kicked object falls down at the end of its range or when a
- *monster
+ * when a weapon is thrown (weapon == THROWN_WEAPON)
+ * when an object is kicked (KICKED_WEAPON)
+ * when an IMMEDIATE wand is zapped (ZAPPED_WAND)
+ * when a light beam is flashed (FLASHED_LIGHT)
+ * when a mirror is applied (INVIS_BEAM)
+ * A thrown/kicked object falls down at end of its range or when a monster
* 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
* function) several objects and monsters on its path. The return value
if (is_pick(obj) && inside_shop(x, y)
&& (mtmp = shkcatch(obj, x, y))) {
tmp_at(DISP_END, 0);
- return (mtmp);
+ return mtmp;
}
typ = levl[bhitpos.x][bhitpos.y].typ;
mtmp = m_at(bhitpos.x, bhitpos.y);
m_respond(mtmp);
tmp_at(DISP_END, 0);
- return (mtmp);
+ return mtmp;
}
if (!ZAP_POS(levl[bhitpos.x][bhitpos.y].typ)
|| closed_door(bhitpos.x, bhitpos.y)) {
} else { /* we catch it */
tmp_at(DISP_END, 0);
You("skillfully catch the boomerang.");
- return (&youmonst);
+ return &youmonst;
}
}
tmp_at(bhitpos.x, bhitpos.y);
return (struct monst *) 0;
}
-/* used by buzz(); also used by munslime(muse.c) */
-int zhitm(mon, type, nd, ootmp) /* returns damage to mon */
+/* used by buzz(); also used by munslime(muse.c); returns damage to mon */
+int
+zhitm(mon, type, nd, ootmp)
register struct monst *mon;
register int type, nd;
struct obj **ootmp; /* to return worn armor for caller to disintegrate */
debugpline3("zapped monster hp = %d (= %d - %d)", mon->mhp - tmp,
mon->mhp, tmp);
mon->mhp -= tmp;
- return (tmp);
+ return tmp;
}
STATIC_OVL void
/* very high armor protection does not achieve invulnerability */
ac = AC_VALUE(ac);
- return (3 - chance) < ac + spell_bonus;
+ return (3 - chance < ac + spell_bonus);
}
STATIC_OVL void
explode(sx, sy, type, d(12, 6), 0, EXPL_FIERY);
get_out_buzz:
if (shopdamage)
- pay_for_damage(
- abstype == ZT_FIRE
- ? "burn away"
- : abstype == ZT_COLD
- ? "shatter"
- :
- /* "damage" indicates wall rather than door */
- abstype == ZT_ACID ? "damage" : abstype == ZT_DEATH
- ? "disintegrate"
- : "destroy",
- FALSE);
+ pay_for_damage(abstype == ZT_FIRE
+ ? "burn away"
+ : abstype == ZT_COLD
+ ? "shatter"
+ /* "damage" indicates wall rather than door */
+ : abstype == ZT_ACID
+ ? "damage"
+ : abstype == ZT_DEATH
+ ? "disintegrate"
+ : "destroy",
+ FALSE);
bhitpos = save_bhitpos;
}
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! */
{
xchar x, y;
/*
* destroy_strings[dindx][0:singular,1:plural,2:killer_reason]
- * [0] freezing potion
- * [1] boiling potion other than oil
- * [2] boiling potion of oil
- * [3] burning scroll
- * [4] burning spellbook
- * [5] shocked ring
- * [6] shocked wand
+ * [0] freezing potion
+ * [1] boiling potion other than oil
+ * [2] boiling potion of oil
+ * [3] burning scroll
+ * [4] burning spellbook
+ * [5] shocked ring
+ * [6] shocked wand
* (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)
*/
break;
}
#if 0
- if (obj == current_wand) { skip++; break; }
+ if (obj == current_wand) { skip++; break; }
#endif
dindx = 6;
dmg = rnd(10);
m_useup(mtmp, obj);
}
}
- return (tmp);
+ return tmp;
}
int
killed(mtmp);
}
}
- return (resisted);
+ return resisted;
}
#define MAXWISHTRY 5
wishcmdassist(triesleft)
int triesleft;
{
- static NEARDATA const char *wishinfo[] =
- {
- "Wish details:", "", "Enter the name of an object, such as "
- "\"potion of monster detection\",",
- "\"scroll labeled README\", \"elven mithril-coat\", or "
- "\"Grimtooth\"",
- "(without the quotes).", "", "For object types which come in "
- "stacks, you may specify a plural "
- "name",
- "such as \"potions of healing\", or specify a count, such as "
- "\"1000 gold",
- "pieces\", although that aspect of your wish might not be granted.",
- "",
- "You may also specify various prefix values which might be used to",
- "modify the item, such as \"uncursed\" or \"rustproof\" or \"+1\".",
- "Most modifiers shown when viewing your inventory can be "
- "specified.",
- "", "You may specify 'nothing' to explicitly decline this wish.", 0,
- },
- preserve_wishless[] = "Doing so will preserve "
- "'wishless' conduct.",
- retry_info[] = "If you specify an "
- "unrecognized object name %s%s "
- "time%s,",
- retry_too[] =
- "a randomly chosen item will be granted.",
- suppress_cmdassist[] =
- "(Suppress this assistance with "
- "!cmdassist in your config file.)",
- *cardinals[] = { "zero", "one", "two",
- "three", "four", "five" },
- too_many[] = "too many";
+ static NEARDATA const char *
+ wishinfo[] = {
+ "Wish details:",
+ "",
+ "Enter the name of an object, such as \"potion of monster detection\",",
+ "\"scroll labeled README\", \"elven mithril-coat\", or \"Grimtooth\"",
+ "(without the quotes).",
+ "",
+ "For object types which come in stacks, you may specify a plural name",
+ "such as \"potions of healing\", or specify a count, such as \"1000 gold",
+ "pieces\", although that aspect of your wish might not be granted.",
+ "",
+ "You may also specify various prefix values which might be used to",
+ "modify the item, such as \"uncursed\" or \"rustproof\" or \"+1\".",
+ "Most modifiers shown when viewing your inventory can be specified.",
+ "",
+ "You may specify 'nothing' to explicitly decline this wish.",
+ 0,
+ },
+ preserve_wishless[] = "Doing so will preserve 'wishless' conduct.",
+ retry_info[] =
+ "If you specify an unrecognized object name %s%s time%s,",
+ retry_too[] = "a randomly chosen item will be granted.",
+ suppress_cmdassist[] =
+ "(Suppress this assistance with !cmdassist in your config file.)",
+ *cardinals[] = { "zero", "one", "two", "three", "four", "five" },
+ too_many[] = "too many";
int i;
winid win;
char buf[BUFSZ];
if (!u.uconduct.wishes)
putstr(win, 0, preserve_wishless);
putstr(win, 0, "");
- Sprintf(buf, retry_info, (triesleft >= 0 && triesleft < SIZE(cardinals))
- ? cardinals[triesleft]
- : too_many,
- (triesleft < MAXWISHTRY) ? " more" : "", plur(triesleft));
+ Sprintf(buf, retry_info,
+ (triesleft >= 0 && triesleft < SIZE(cardinals))
+ ? cardinals[triesleft]
+ : too_many,
+ (triesleft < MAXWISHTRY) ? " more" : "",
+ plur(triesleft));
putstr(win, 0, buf);
putstr(win, 0, retry_too);
putstr(win, 0, "");