-/* NetHack 3.6 dogmove.c $NHDT-Date: 1445301121 2015/10/20 00:32:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.55 $ */
+/* NetHack 3.6 dogmove.c $NHDT-Date: 1446604109 2015/11/04 02:28:29 $ $NHDT-Branch: master $:$NHDT-Revision: 1.56 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL boolean FDECL(dog_hunger, (struct monst *, struct edog *));
STATIC_DCL int FDECL(dog_invent, (struct monst *, struct edog *, int));
-STATIC_DCL int FDECL(dog_goal,
- (struct monst *, struct edog *, int, int, int));
-
+STATIC_DCL int FDECL(dog_goal, (struct monst *, struct edog *, int, int, int));
STATIC_DCL boolean FDECL(can_reach_location, (struct monst *, XCHAR_P,
XCHAR_P, XCHAR_P, XCHAR_P));
-STATIC_DCL boolean
-FDECL(could_reach_item, (struct monst *, XCHAR_P, XCHAR_P));
+STATIC_DCL boolean FDECL(could_reach_item, (struct monst *, XCHAR_P, XCHAR_P));
STATIC_DCL void FDECL(quickmimic, (struct monst *));
/* pick a carried item for pet to drop */
}
#if 0 /* pet is eating, so slime recovery is not feasible... */
- /* turning into slime might be cureable */
- if (slimer && munslime(mtmp, FALSE)) {
- /* but the cure (fire directed at self) might be fatal */
- if (mtmp->mhp < 1) return 2;
- slimer = FALSE; /* sliming is avoided, skip polymorph */
- }
+ /* turning into slime might be cureable */
+ if (slimer && munslime(mtmp, FALSE)) {
+ /* but the cure (fire directed at self) might be fatal */
+ if (mtmp->mhp < 1)
+ return 2;
+ slimer = FALSE; /* sliming is avoided, skip polymorph */
+ }
#endif
if (poly || slimer) {
You_feel("%s for a moment.",
Hallucination ? "bummed" : "sad");
mondied(mtmp);
- return (TRUE);
+ return TRUE;
}
}
- return (FALSE);
+ return FALSE;
}
/* do something with object (drop, pick up, eat) at current position
struct obj *obj, *otmp;
if (mtmp->msleeping || !mtmp->mcanmove)
- return (0);
+ return 0;
omx = mtmp->mx;
omy = mtmp->my;
}
/* set dog's goal -- gtyp, gx, gy
- * returns -1/0/1 (dog's desire to approach player) or -2 (abort move)
- */
+ returns -1/0/1 (dog's desire to approach player) or -2 (abort move) */
STATIC_OVL int
dog_goal(mtmp, edog, after, udist, whappr)
register struct monst *mtmp;
/* Steeds don't move on their own will */
if (mtmp == u.usteed)
- return (-2);
+ return -2;
omx = mtmp->mx;
omy = mtmp->my;
&& !dog_has_minvent
&& (!levl[omx][omy].lit || levl[u.ux][u.uy].lit)
&& (otyp == MANFOOD || m_cansee(mtmp, nx, ny))
- && edog->apport > rn2(8) && can_carry(mtmp, obj) > 0) {
+ && edog->apport > rn2(8)
+ && can_carry(mtmp, obj) > 0) {
gx = nx;
gy = ny;
gtyp = APPORT;
gx = u.ux;
gy = u.uy;
if (after && udist <= 4 && gx == u.ux && gy == u.uy)
- return (-2);
+ return -2;
appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0;
if (udist > 1) {
if (!IS_ROOM(levl[u.ux][u.uy].typ) || !rn2(4) || whappr
omx = mtmp->mx;
omy = mtmp->my;
if (has_edog && dog_hunger(mtmp, edog))
- return (2); /* starved */
+ return 2; /* starved */
udist = distu(omx, omy);
/* Let steeds eat and maybe throw rider during Conflict */
if (mtmp == u.usteed) {
if (Conflict && !resist(mtmp, RING_CLASS, 0, 0)) {
dismount_steed(DISMOUNT_THROWN);
- return (1);
+ return 1;
}
udist = 1;
} else if (!udist)
/* maybe we tamed him while being swallowed --jgm */
- return (0);
+ return 0;
nix = omx; /* set before newdogpos */
niy = omy;
appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist,
whappr);
if (appr == -2)
- return (0);
+ return 0;
allowflags = ALLOW_M | ALLOW_TRAPS | ALLOW_SSM | ALLOW_SANCT;
if (passes_walls(mtmp->data))
if (is_giant(mtmp->data))
allowflags |= BUSTDOOR;
if (tunnels(mtmp->data)
- && !Is_rogue_level(&u.uz) /* same restriction as m_move() */
- )
+ && !Is_rogue_level(&u.uz)) /* same restriction as m_move() */
allowflags |= ALLOW_DIG;
cnt = mfndpos(mtmp, poss, info, allowflags);
continue;
if (after)
- return (0); /* hit only once each move */
+ return 0; /* hit only once each move */
notonhead = 0;
mstatus = mattackm(mtmp, mtmp2);
return 0;
}
- { /* Dog avoids harmful traps, but perhaps it has to pass one
- * in order to follow player. (Non-harmful traps do not
- * have ALLOW_TRAPS in info[].) The dog only avoids the
- * trap if you've seen it, unlike enemies who avoid traps
- * if they've seen some trap of that type sometime in the
- * past. (Neither behavior is really realistic.)
- */
+ {
+ /* Dog avoids harmful traps, but perhaps it has to pass one
+ * in order to follow player. (Non-harmful traps do not
+ * have ALLOW_TRAPS in info[].) The dog only avoids the
+ * trap if you've seen it, unlike enemies who avoid traps
+ * if they've seen some trap of that type sometime in the
+ * past. (Neither behavior is really realistic.)
+ */
struct trap *trap;
if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) {
m_unleash(mtmp, FALSE);
}
(void) mattacku(mtmp);
- return (0);
+ return 0;
}
if (!m_in_out_region(mtmp, nix, niy))
return 1;
newsym(cc.x, cc.y);
set_apparxy(mtmp);
}
- return (1);
+ return 1;
}
/* check if a monster could pick up objects from a location */
/* Hack to prevent a dog from being endlessly stuck near an object that
* it can't reach, such as caught in a teleport scroll niche. It recursively
- * checks to see if the squares in between are good. The checking could be a
- * little smarter; a full check would probably be useful in m_move() too.
+ * checks to see if the squares in between are good. The checking could be
+ * a little smarter; a full check would probably be useful in m_move() too.
* Since the maximum food distance is 5, this should never be more than 5
- * calls
- * deep.
+ * calls deep.
*/
STATIC_OVL boolean
can_reach_location(mon, mx, my, fx, fy)
-/* NetHack 3.6 hack.c $NHDT-Date: 1445388917 2015/10/21 00:55:17 $ $NHDT-Branch: master $:$NHDT-Revision: 1.154 $ */
+/* NetHack 3.6 hack.c $NHDT-Date: 1446604111 2015/11/04 02:28:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.155 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* else impossible? */
}
- return (revived);
+ return revived;
}
STATIC_OVL int
}
if (revive_nasty(rx, ry, "You sense movement on the other side."))
- return (-1);
+ return -1;
if (mtmp && !noncorporeal(mtmp->data)
&& (!mtmp->mtrapped
sokoban_guilt();
break;
} else
- return (-1);
+ return -1;
}
}
- return (0);
+ return 0;
}
/*
/*
* The location could still block because of
- * 1. More than one boulder
- * 2. Boulder stuck in a wall/stone/door.
+ * 1. More than one boulder
+ * 2. Boulder stuck in a wall/stone/door.
*
* [perhaps use does_block() below (from vision.c)]
*/
{
struct rm *lev = &levl[x][y];
- return (boolean)(!((IS_STWALL(lev->typ) || IS_TREE(lev->typ))
- && (lev->wall_info & W_NONDIGGABLE)));
+ return (boolean) !((IS_STWALL(lev->typ) || IS_TREE(lev->typ))
+ && (lev->wall_info & W_NONDIGGABLE));
}
boolean
may_passwall(x, y)
register xchar x, y;
{
- return (boolean)(!(IS_STWALL(levl[x][y].typ)
- && (levl[x][y].wall_info & W_NONPASSWALL)));
+ return (boolean) !(IS_STWALL(levl[x][y].typ)
+ && (levl[x][y].wall_info & W_NONPASSWALL));
}
boolean
struct permonst *mdat;
register xchar x, y;
{
- return (
- (boolean)((Sokoban && sobj_at(BOULDER, x, y))
- || (IS_ROCK(levl[x][y].typ)
- && (!tunnels(mdat) || needspick(mdat) || !may_dig(x, y))
- && !(passes_walls(mdat) && may_passwall(x, y)))));
+ return (boolean) ((Sokoban && sobj_at(BOULDER, x, y))
+ || (IS_ROCK(levl[x][y].typ)
+ && (!tunnels(mdat) || needspick(mdat)
+ || !may_dig(x, y))
+ && !(passes_walls(mdat) && may_passwall(x, y))));
}
/* caller has already decided that it's a tight diagonal; check whether a
invocation_pos(x, y)
xchar x, y;
{
- return (
- (boolean)(Invocation_lev(&u.uz) && x == inv_pos.x && y == inv_pos.y));
+ return (boolean) (Invocation_lev(&u.uz)
+ && x == inv_pos.x && y == inv_pos.y);
}
/* return TRUE if (dx,dy) is an OK place to move
u.ustuck = 0;
} else {
/* If holder is asleep or paralyzed:
- * 37.5% chance of getting away,
- * 12.5% chance of waking/releasing it;
+ * 37.5% chance of getting away,
+ * 12.5% chance of waking/releasing it;
* otherwise:
- * 7.5% chance of getting away.
+ * 7.5% chance of getting away.
* [strength ought to be a factor]
* If holder is tame and there is no conflict,
* guaranteed escape.
fall_asleep(-10, FALSE);
}
}
- return (multi < 0); /* might have fainted (actually gone to sleep) */
+ return (boolean) (multi < 0); /* might have fainted (forced to sleep) */
}
void
switch (rno = levl[x][y].roomno) {
case NO_ROOM:
- return (ptr);
+ return ptr;
case SHARED:
step = 2;
break;
default: /* i.e. a regular room # */
if (goodtype(rno))
*(--ptr) = rno;
- return (ptr);
+ return ptr;
}
min_x = x - 1;
&& goodtype(rno))
*(--ptr) = rno;
}
- return (ptr);
+ return ptr;
}
/* is (x,y) in a town? */
} else
You("don't %s anything in here to pick up.",
Blind ? "feel" : "see");
- return (1);
+ return 1;
} else {
int tmpcount = -count;
return loot_mon(u.ustuck, &tmpcount, (boolean *) 0);
if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data)
|| (Flying && !Breathless)) {
You("cannot dive into the water to pick things up.");
- return (0);
+ return 0;
} else if (!Underwater) {
You_cant("even see the bottom, let alone pick up %s.", something);
- return (0);
+ return 0;
}
}
if (is_lava(u.ux, u.uy)) {
if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data)
|| (Flying && !Breathless)) {
You_cant("reach the bottom to pick things up.");
- return (0);
+ return 0;
} else if (!likes_lava(youmonst.data)) {
You("would burn to a crisp trying to pick things up.");
- return (0);
+ return 0;
}
}
if (!OBJ_AT(u.ux, u.uy)) {
return 0;
}
- return (pickup(-count));
+ return pickup(-count);
}
/* stop running if we see something interesting */
&& (!mtmp->mpeaceful || Hallucination)
&& (!is_hider(mtmp->data) || !mtmp->mundetected)
&& !noattacks(mtmp->data) && mtmp->mcanmove
- && !mtmp->msleeping && /* aplvax!jcn */
- !onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp))
- return (1);
+ && !mtmp->msleeping /* aplvax!jcn */
+ && !onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp))
+ return 1;
}
- return (0);
+ return 0;
}
void
if (carrcap < 0)
carrcap = 0;
}
- return ((int) carrcap);
+ return (int) carrcap;
}
static int wc; /* current weight_cap(); valid after call to inv_weight() */
ct++;
otmp = otmp->nobj;
}
- return (ct);
+ return ct;
}
/* Counts the money in an object chain. */
-/* NetHack 3.6 lock.c $NHDT-Date: 1436753515 2015/07/13 02:11:55 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
+/* NetHack 3.6 lock.c $NHDT-Date: 1446604112 2015/11/04 02:28:32 $ $NHDT-Branch: master $:$NHDT-Revision: 1.65 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
picking_at(x, y)
int x, y;
{
- return (boolean)(occupation == picklock && xlock.door == &levl[x][y]);
+ return (boolean) (occupation == picklock && xlock.door == &levl[x][y]);
}
/* produce an occupation string appropriate for the current activity */
return xlock.box->otyp == CHEST ? actions[1] : actions[2];
}
-STATIC_PTR
-int picklock(VOID_ARGS) /* try to open/close a lock */
+/* try to open/close a lock */
+STATIC_PTR int
+picklock(VOID_ARGS)
{
if (xlock.box) {
if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) {
}
if (rn2(100) >= xlock.chance)
- return (1); /* still busy */
+ return 1; /* still busy */
You("succeed in %s.", lock_action());
if (xlock.door) {
}
}
-STATIC_PTR
-int forcelock(VOID_ARGS) /* try to force a locked chest */
+/* try to force a locked chest */
+STATIC_PTR int
+forcelock(VOID_ARGS)
{
if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy))
return ((xlock.usedtime = 0)); /* you or it moved */
wake_nearby(); /* due to hammering on the container */
if (rn2(100) >= xlock.chance)
- return (1); /* still busy */
+ return 1; /* still busy */
You("succeed in forcing the lock.");
breakchestlock(xlock.box, (boolean)(!xlock.picktyp && !rn2(3)));
/* player is applying a key, lock pick, or credit card */
int
pick_lock(pick)
-register struct obj *pick;
+struct obj *pick;
{
int picktyp, c, ch;
coord cc;
return PICKLOCK_LEARNED_SOMETHING;
} else {
const char *action = lock_action();
+
You("resume your attempt at %s.", action);
set_occupation(picklock, action, 0);
return PICKLOCK_DID_SOMETHING;
c = ynq(qbuf);
if (c == 'q')
- return (0);
+ return 0;
if (c == 'n')
continue;
c = yn(qbuf);
if (c == 'n')
- return (0);
+ return 0;
switch (picktyp) {
case CREDIT_CARD:
return PICKLOCK_DID_SOMETHING;
}
-int doforce() /* try to force a chest with your weapon */
+/* try to force a chest with your weapon */
+int
+doforce()
{
register struct obj *otmp;
register int c, picktyp;
You_cant("force anything from inside here.");
return 0;
}
- if (!uwep || /* proper type test */
- ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
- ? (objects[uwep->otyp].oc_skill < P_DAGGER
- || objects[uwep->otyp].oc_skill == P_FLAIL
- || objects[uwep->otyp].oc_skill > P_LANCE)
- : uwep->oclass != ROCK_CLASS)) {
+ if (!uwep /* proper type test */
+ || ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
+ ? (objects[uwep->otyp].oc_skill < P_DAGGER
+ || objects[uwep->otyp].oc_skill == P_FLAIL
+ || objects[uwep->otyp].oc_skill > P_LANCE)
+ : uwep->oclass != ROCK_CLASS)) {
You_cant("force anything %s weapon.",
!uwep ? "when not wielding a"
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
? "without a proper"
: "with that");
- return (0);
+ return 0;
}
if (!can_reach_floor(TRUE)) {
cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
if (xlock.usedtime && xlock.box && picktyp == xlock.picktyp) {
You("resume your attempt to force the lock.");
set_occupation(forcelock, "forcing the lock", 0);
- return (1);
+ return 1;
}
/* A lock is made only for the honest man, the thief will break it. */
c = ynq(qbuf);
if (c == 'q')
- return (0);
+ return 0;
if (c == 'n')
continue;
set_occupation(forcelock, "forcing the lock", 0);
else
You("decide not to force the issue.");
- return (1);
+ return 1;
}
-int doopen() /* try to open a door */
+/* try to open a door */
+int
+doopen()
{
return doopen_indir(0, 0);
}
int x, y;
{
struct monst *mtmp;
+
if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp)
&& !Protection_from_shape_changers) {
stumble_onto_mimic(mtmp);
return FALSE;
}
-int doopen_indir(x, y) /* try to open a door in direction u.dx/u.dy */
+/* try to open a door in direction u.dx/u.dy */
+int
+doopen_indir(x, y)
int x, y;
{
coord cc;
cc.x = x;
cc.y = y;
} else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc))
- return (0);
+ return 0;
if ((cc.x == u.ux) && (cc.y == u.uy))
- return (0);
+ return 0;
if (stumble_on_door_mimic(cc.x, cc.y))
return 1;
pline_The("door resists!");
}
- return (1);
+ return 1;
}
-STATIC_OVL
-boolean
+STATIC_OVL boolean
obstructed(x, y, quietly)
register int x, y;
boolean quietly;
}
if (!canspotmon(mtmp))
map_invisible(x, y);
- return (TRUE);
+ return TRUE;
}
if (OBJ_AT(x, y)) {
objhere:
if (!quietly)
pline("%s's in the way.", Something);
- return (TRUE);
+ return TRUE;
}
- return (FALSE);
+ return FALSE;
}
-int doclose() /* try to close a door */
+/* try to close a door */
+int
+doclose()
{
register int x, y;
register struct rm *door;
- struct monst *mtmp;
boolean portcullis;
int res = 0;
}
if (!getdir((char *) 0))
- return (0);
+ return 0;
x = u.ux + u.dx;
y = u.uy + u.dy;
if ((x == u.ux) && (y == u.uy)) {
You("are in the way!");
- return (1);
+ return 1;
}
if (!isok(x, y))
goto nodoor;
if (stumble_on_door_mimic(x, y))
- return (1);
+ return 1;
/* when choosing a direction is impaired, use a turn
regardless of whether a door is successfully targetted */
}
}
- return (1);
+ return 1;
}
-boolean /* box obj was hit with spell effect otmp */
- boxlock(obj, otmp) /* returns true if something happened */
-register struct obj *obj, *otmp; /* obj *is* a box */
+/* box obj was hit with spell or wand effect otmp;
+ returns true if something happened */
+boolean
+boxlock(obj, otmp)
+struct obj *obj, *otmp; /* obj *is* a box */
{
- register boolean res = 0;
+ boolean res = 0;
switch (otmp->otyp) {
case WAN_LOCKING:
return res;
}
-boolean /* Door/secret door was hit with spell effect otmp */
- doorlock(otmp, x, y) /* returns true if something happened */
+/* Door/secret door was hit with spell or wand effect otmp;
+ returns true if something happened */
+boolean
+doorlock(otmp, x, y)
struct obj *otmp;
int x, y;
{
-/* NetHack 3.6 mhitm.c $NHDT-Date: 1445556871 2015/10/22 23:34:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.81 $ */
+/* NetHack 3.6 mhitm.c $NHDT-Date: 1446604113 2015/11/04 02:28:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.82 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
"have a %s feeling for a moment, then it passes.";
STATIC_DCL char *FDECL(mon_nam_too, (char *, struct monst *, struct monst *));
-STATIC_DCL int FDECL(hitmm,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL int FDECL(gazemm,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL int FDECL(gulpmm,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL int FDECL(explmm,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL int FDECL(mdamagem,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL void FDECL(mswingsm,
- (struct monst *, struct monst *, struct obj *));
+STATIC_DCL int FDECL(hitmm, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL int FDECL(gazemm, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL int FDECL(gulpmm, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL int FDECL(explmm, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL int FDECL(mdamagem, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL void FDECL(mswingsm, (struct monst *, struct monst *,
+ struct obj *));
STATIC_DCL void FDECL(noises, (struct monst *, struct attack *));
-STATIC_DCL void FDECL(missmm,
- (struct monst *, struct monst *, struct attack *));
-STATIC_DCL int FDECL(passivemm,
- (struct monst *, struct monst *, BOOLEAN_P, int));
+STATIC_DCL void FDECL(missmm, (struct monst *, struct monst *,
+ struct attack *));
+STATIC_DCL int FDECL(passivemm, (struct monst *, struct monst *,
+ BOOLEAN_P, int));
/* Needed for the special case of monsters wielding vorpal blades (rare).
* If we use this a lot it should probably be a parameter to mdamagem()
* fightm() -- fight some other monster
*
* Returns:
- * 0 - Monster did nothing.
- * 1 - If the monster made an attack. The monster might have died.
+ * 0 - Monster did nothing.
+ * 1 - If the monster made an attack. The monster might have died.
*
* There is an exception to the above. If mtmp has the hero swallowed,
* then we report that the monster did nothing so it will continue to
#endif
/* perhaps the monster will resist Conflict */
if (resist(mtmp, RING_CLASS, 0, 0))
- return (0);
+ return 0;
if (u.ustuck == mtmp) {
/* perhaps we're holding it... */
if (itsstuck(mtmp))
- return (0);
+ return 0;
}
has_u_swallowed = (u.uswallow && (mtmp == u.ustuck));
if (result & MM_AGR_DIED)
return 1; /* mtmp died */
- /*
- * If mtmp has the hero swallowed, lie and say there
- * was no attack (this allows mtmp to digest the hero).
- */
+ /*
+ * If mtmp has the hero swallowed, lie and say there
+ * was no attack (this allows mtmp to digest the hero).
+ */
if (has_u_swallowed)
return 0;
(void) mattackm(mon, mtmp); /* return attack */
}
- return ((result & MM_HIT) ? 1 : 0);
+ return (result & MM_HIT) ? 1 : 0;
}
}
}
/*
* mdisplacem() -- attacker moves defender out of the way;
- * returns same results as mattackm().
+ * returns same results as mattackm().
*/
int
mdisplacem(magr, mdef, quietly)
* for pet displacement.
*/
if (!rn2(7))
- return (MM_MISS);
+ return MM_MISS;
/* Grid bugs cannot displace at an angle. */
if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
&& magr->my != mdef->my)
- return (MM_MISS);
+ return MM_MISS;
/* undetected monster becomes un-hidden if it is displaced */
if (mdef->mundetected)
/*
* mattackm() -- a monster attacks another monster.
*
- * --------- aggressor died
- * / ------- defender died
- * / / ----- defender was hit
- * / / /
- * x x x
+ * --------- aggressor died
+ * / ------- defender died
+ * / / ----- defender was hit
+ * / / /
+ * x x x
*
- * 0x4 MM_AGR_DIED
- * 0x2 MM_DEF_DIED
- * 0x1 MM_HIT
- * 0x0 MM_MISS
+ * 0x4 MM_AGR_DIED
+ * 0x2 MM_DEF_DIED
+ * 0x1 MM_HIT
+ * 0x0 MM_MISS
*
* Each successive attack has a lower probability of hitting. Some rely on
- *the
* success of previous attacks. ** this doen't seem to be implemented -dl **
*
* In the case of exploding monsters, the monster dies as well.
struct permonst *pa, *pd;
if (!magr || !mdef)
- return (MM_MISS); /* mike@genat */
+ return MM_MISS; /* mike@genat */
if (!magr->mcanmove || magr->msleeping)
- return (MM_MISS);
+ return MM_MISS;
pa = magr->data;
pd = mdef->data;
/* Grid bugs cannot attack at an angle. */
if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
&& magr->my != mdef->my)
- return (MM_MISS);
+ return MM_MISS;
/* Calculate the armour class differential. */
tmp = find_mac(mdef) + magr->m_lev;
vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)
&& (canspotmon(magr) || canspotmon(mdef)));
- /* Set flag indicating monster has moved this turn. Necessary since a
- * monster might get an attack out of sequence (i.e. before its move) in
- * some cases, in which case this still counts as its move for the round
- * and it shouldn't move again.
+ /* Set flag indicating monster has moved this turn. Necessary since a
+ * monster might get an attack out of sequence (i.e. before its move) in
+ * some cases, in which case this still counts as its move for the round
+ * and it shouldn't move again.
*/
magr->mlstmv = monstermoves;
mswingsm(magr, mdef, otmp);
tmp += hitval(otmp, mdef);
}
- /* fall through */
+ /*FALLTHRU*/
case AT_CLAW:
case AT_KICK:
case AT_BITE:
}
} else
noises(magr, mattk);
- return (mdamagem(magr, mdef, mattk));
+
+ return mdamagem(magr, mdef, mattk);
}
/* Returns the same values as mdamagem(). */
|| mdef->msleeping) {
if (vis)
pline("but nothing happens.");
- return (MM_MISS);
+ return MM_MISS;
}
/* call mon_reflects 2x, first test, then, if visible, print message */
if (magr->data == &mons[PM_MEDUSA] && mon_reflects(mdef, (char *) 0)) {
if (canseemon(magr))
(void) mon_reflects(
magr, "The gaze is reflected away by %s %s.");
- return (MM_MISS);
+ return MM_MISS;
}
if (mdef->minvis && !perceives(magr->data)) {
if (canseemon(magr)) {
"reflected.",
Monnam(magr), mhis(magr));
}
- return (MM_MISS);
+ return MM_MISS;
}
if (canseemon(magr))
pline("%s is turned to stone!", Monnam(magr));
monstone(magr);
if (magr->mhp > 0)
- return (MM_MISS);
- return (MM_AGR_DIED);
+ return MM_MISS;
+ return MM_AGR_DIED;
}
}
- return (mdamagem(magr, mdef, mattk));
+ return mdamagem(magr, mdef, mattk);
}
/* return True if magr is allowed to swallow mdef, False otherwise */
== (MM_AGR_DIED | MM_DEF_DIED)) {
; /* both died -- do nothing */
} else if (status & MM_DEF_DIED) { /* defender died */
- /*
- * Note: remove_monster() was called in relmon(), wiping out
- * magr from level.monsters[mdef->mx][mdef->my]. We need to
- * put it back and display it. -kd
- */
+ /*
+ * Note: remove_monster() was called in relmon(), wiping out
+ * magr from level.monsters[mdef->mx][mdef->my]. We need to
+ * put it back and display it. -kd
+ */
place_monster(magr, dx, dy);
newsym(dx, dy);
/* aggressor moves to <dx,dy> and might encounter trouble there */
STATIC_OVL int
explmm(magr, mdef, mattk)
-register struct monst *magr, *mdef;
-register struct attack *mattk;
+struct monst *magr, *mdef;
+struct attack *mattk;
{
int result;
res = MM_MISS;
boolean cancelled;
- if ((touch_petrifies(pd) || /* or flesh_petrifies() */
- (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
+ if ((touch_petrifies(pd) /* or flesh_petrifies() */
+ || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
&& !resists_ston(magr)) {
long protector = attk_protection((int) mattk->aatyp),
wornitems = magr->misc_worn_check;
if (is_rider(pd)) {
if (vis)
pline("%s %s!", Monnam(magr),
- pd == &mons[PM_FAMINE]
+ (pd == &mons[PM_FAMINE])
? "belches feebly, shrivels up and dies"
- : pd == &mons[PM_PESTILENCE]
+ : (pd == &mons[PM_PESTILENCE])
? "coughs spasmodically and collapses"
: "vomits violently and drops dead");
mondied(magr);
void
rustm(mdef, obj)
-register struct monst *mdef;
-register struct obj *obj;
+struct monst *mdef;
+struct obj *obj;
{
int dmgtyp;
struct monst *mon;
boolean givemsg;
{
- if (mon->mspec_used < 20 && /* limit draining */
- (attacktype(mon->data, AT_MAGC) || attacktype(mon->data, AT_BREA))) {
+ if (mon->mspec_used < 20 /* limit draining */
+ && (attacktype(mon->data, AT_MAGC)
+ || attacktype(mon->data, AT_BREA))) {
mon->mspec_used += d(2, 2);
if (givemsg)
pline("%s seems lethargic.", Monnam(mon));
-/* NetHack 3.6 mkmaze.c $NHDT-Date: 1432512765 2015/05/25 00:12:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.38 $ */
+/* NetHack 3.6 mkmaze.c $NHDT-Date: 1446604114 2015/11/04 02:28:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.39 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
if (!isok(x, y))
return FALSE;
type = levl[x][y].typ;
- return (IS_WALL(type) || IS_DOOR(type) || type == SDOOR
- || type == IRONBARS);
+ return (boolean) (IS_WALL(type) || IS_DOOR(type)
+ || type == SDOOR || type == IRONBARS);
}
STATIC_OVL boolean
return TRUE;
type = levl[x][y].typ;
- return (type == STONE || IS_WALL(type) || IS_DOOR(type) || type == SDOOR
- || type == IRONBARS);
+ return (boolean) (type == STONE
+ || IS_WALL(type) || IS_DOOR(type)
+ || type == SDOOR || type == IRONBARS);
}
/* return TRUE if out of bounds, wall or rock */
is_solid(x, y)
int x, y;
{
- return (!isok(x, y) || IS_STWALL(levl[x][y].typ));
+ return (boolean) (!isok(x, y) || IS_STWALL(levl[x][y].typ));
}
/*
* a wall, '.' a room, 'a' anything (we don't care), and our direction is
* (0,1) - South or down - then:
*
- * a a a
- * W x W This would not extend a spine from x down
- * W W W (a corridor of walls is formed).
+ * a a a
+ * W x W This would not extend a spine from x down
+ * W W W (a corridor of walls is formed).
*
- * a a a
- * W x W This would extend a spine from x down.
- * . W W
+ * a a a
+ * W x W This would extend a spine from x down.
+ * . W W
*/
STATIC_OVL int
extend_spine(locale, wall_there, dx, dy)
if (wall_there) { /* wall in that direction */
if (dx) {
- if (locale[1][0] && locale[1][2] && /* EW are wall/stone */
- locale[nx][0] && locale[nx][2]) { /* diag are wall/stone */
+ if (locale[1][0] && locale[1][2] /* EW are wall/stone */
+ && locale[nx][0] && locale[nx][2]) { /* diag are wall/stone */
spine = 0;
} else {
spine = 1;
}
- } else { /* dy */
- if (locale[0][1] && locale[2][1] && /* NS are wall/stone */
- locale[0][ny] && locale[2][ny]) { /* diag are wall/stone */
+ } else { /* dy */
+ if (locale[0][1] && locale[2][1] /* NS are wall/stone */
+ && locale[0][ny] && locale[2][ny]) { /* diag are wall/stone */
spine = 0;
} else {
spine = 1;
struct rm *lev;
int bits;
int locale[3][3]; /* rock or wall status surrounding positions */
- /*
- * Value 0 represents a free-standing wall. It could be anything,
- * so even though this table says VWALL, we actually leave whatever
- * typ was there alone.
- */
+ /*
+ * Value 0 represents a free-standing wall. It could be anything,
+ * so even though this table says VWALL, we actually leave whatever
+ * typ was there alone.
+ */
static xchar spine_array[16] = { VWALL, HWALL, HWALL, HWALL,
VWALL, TRCORNER, TLCORNER, TDWALL,
VWALL, BRCORNER, BLCORNER, TUWALL,
move(&x, &y, dir);
if (x < 3 || y < 3 || x > x_maze_max || y > y_maze_max
|| levl[x][y].typ != 0)
- return (FALSE);
- return (TRUE);
+ return FALSE;
+ return TRUE;
}
+/* find random starting point for maze generation */
STATIC_OVL void
-maze0xy(cc) /* find random starting point for maze generation */
+maze0xy(cc)
coord *cc;
{
cc->x = 3 + 2 * rn2((x_maze_max >> 1) - 1);
/*
* Bad if:
- * pos is occupied OR
- * pos is inside restricted region (lx,ly,hx,hy) OR
- * NOT (pos is corridor and a maze level OR pos is a room OR pos is air)
+ * pos is occupied OR
+ * pos is inside restricted region (lx,ly,hx,hy) OR
+ * NOT (pos is corridor and a maze level OR pos is a room OR pos is air)
*/
boolean
bad_location(x, y, lx, ly, hx, hy)
xchar x, y;
xchar lx, ly, hx, hy;
{
- return (
- (boolean)(occupied(x, y) || within_bounded_area(x, y, lx, ly, hx, hy)
- || !((levl[x][y].typ == CORR && level.flags.is_maze_lev)
- || levl[x][y].typ == ROOM || levl[x][y].typ == AIR)));
+ return (boolean) (occupied(x, y)
+ || within_bounded_area(x, y, lx, ly, hx, hy)
+ || !((levl[x][y].typ == CORR && level.flags.is_maze_lev)
+ || levl[x][y].typ == ROOM
+ || levl[x][y].typ == AIR));
}
-/* pick a location in area (lx, ly, hx, hy) but not in (nlx, nly, nhx, nhy) */
-/* and place something (based on rtype) in that region */
+/* pick a location in area (lx, ly, hx, hy) but not in (nlx, nly, nhx, nhy)
+ and place something (based on rtype) in that region */
void
place_lregion(lx, ly, hx, hy, nlx, nly, nhx, nhy, rtype, lev)
xchar lx, ly, hx, hy;
xchar x, y;
if (!lx) { /* default to whole level */
- /*
- * if there are rooms and this a branch, let place_branch choose
- * the branch location (to avoid putting branches in corridors).
- */
+ /*
+ * if there are rooms and this a branch, let place_branch choose
+ * the branch location (to avoid putting branches in corridors).
+ */
if (rtype == LR_BRANCH && nroom) {
place_branch(Is_branchlev(&u.uz), 0, 0);
return;
if (oneshot)
(void) rloc(m_at(x, y), FALSE);
else
- return (FALSE);
+ return FALSE;
}
u_on_newpos(x, y);
break;
place_branch(Is_branchlev(&u.uz), x, y);
break;
}
- return (TRUE);
+ return TRUE;
}
static boolean was_waterlevel; /* ugh... this shouldn't be needed */
y = rn1(y_range, y_maze_min + INVPOS_Y_MARGIN + 1);
/* we don't want it to be too near the stairs, nor
to be on a spot that's already in use (wall|trap) */
- } while (x == xupstair || y == yupstair || /*(direct line)*/
- abs(x - xupstair) == abs(y - yupstair)
+ } while (x == xupstair || y == yupstair /*(direct line)*/
+ || abs(x - xupstair) == abs(y - yupstair)
|| distmin(x, y, xupstair, yupstair) <= INVPOS_DISTANCE
|| !SPACE_POS(levl[x][y].typ) || occupied(x, y));
inv_pos.x = x;
}
}
-void mazexy(cc) /* find random point in generated corridors,
- so we don't create items in moats, bunkers, or walls */
+/* find random point in generated corridors,
+ so we don't create items in moats, bunkers, or walls */
+void
+mazexy(cc)
coord *cc;
{
int cpt = 0;
return;
}
-void
-bound_digging()
/* put a non-diggable boundary around the initial portion of a level map.
* assumes that no level will initially put things beyond the isok() range.
*
* we can't bound unconditionally on one beyond the last line, because
* that provides a window of abuse for wallified special levels
*/
+void
+bound_digging()
{
register int x, y;
register unsigned typ;
void
mkportal(x, y, todnum, todlevel)
-register xchar x, y, todnum, todlevel;
+xchar x, y, todnum, todlevel;
{
- /* a portal "trap" must be matched by a */
- /* portal in the destination dungeon/dlevel */
- register struct trap *ttmp = maketrap(x, y, MAGIC_PORTAL);
+ /* a portal "trap" must be matched by a
+ portal in the destination dungeon/dlevel */
+ struct trap *ttmp = maketrap(x, y, MAGIC_PORTAL);
if (!ttmp) {
impossible("portal on top of portal??");
{
xchar n;
boolean snd = FALSE, loud = FALSE;
+
for (n = rn2(3) + 2; n; n--) {
xchar x = rn1(COLNO - 4, 3);
xchar y = rn1(ROWNO - 4, 3);
* other source files, but they are all so nicely encapsulated here.
*/
+#ifdef DEBUG
/* to ease the work of debuggers at this stage */
#define register
+#endif
#define CONS_OBJ 0
#define CONS_MON 1
* Pick up everything inside of a bubble then fill all bubble
* locations.
*/
-
for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) {
if (b->cons)
panic("movebubbles: cons != null");
* all the junk that changes owners when bubbles overlap
* would eventually end up in the last bubble in the chain.
*/
-
up = !up;
for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) {
register int rx = rn2(3), ry = rn2(3);
bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e },
bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e },
*bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 };
-
register struct bubble *b;
if (x >= bxmax || y >= bymax)
/*
* collision with level borders?
- * 1 = horizontal border, 2 = vertical, 3 = corner
+ * 1 = horizontal border, 2 = vertical, 3 = corner
*/
if (b->x <= bxmin)
colli |= 2;
-/* NetHack 3.6 mondata.c $NHDT-Date: 1445556874 2015/10/22 23:34:34 $ $NHDT-Branch: master $:$NHDT-Revision: 1.57 $ */
+/* NetHack 3.6 mondata.c $NHDT-Date: 1446604115 2015/11/04 02:28:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.58 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
-/* These routines provide basic data for any type of monster. */
+/* These routines provide basic data for any type of monster. */
/* set up an individual monster's base type (initial creation, shapechange) */
void
/* check for magic resistance granted by worn or carried items */
o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY;
- if (!is_you || /* assumes monsters don't wield non-weapons */
- (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
+ if (!is_you /* assumes monsters don't wield non-weapons */
+ || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP;
if (is_you && u.twoweap)
slotmask |= W_SWAPWEP;
return TRUE;
o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY;
- if (!is_you || /* assumes monsters don't wield non-weapons */
- (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
+ if (!is_you /* assumes monsters don't wield non-weapons */
+ || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP;
if (is_you && u.twoweap)
slotmask |= W_SWAPWEP;
{ PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON },
{ PM_BABY_SILVER_DRAGON, PM_SILVER_DRAGON },
#if 0 /* DEFERRED */
- {PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON},
+ {PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON},
#endif
{ PM_BABY_RED_DRAGON, PM_RED_DRAGON },
{ PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON },
/*
* Returns:
- * True if monster is presumed to have a sense of smell.
- * False if monster definitely does not have a sense of smell.
+ * True if monster is presumed to have a sense of smell.
+ * False if monster definitely does not have a sense of smell.
*
- * Do not base this on presence of a head or nose, since many
- * creatures sense smells other ways (feelers, forked-tongues, etc.)
- * We're assuming all insects can smell at a distance too.
+ * Do not base this on presence of a head or nose, since many
+ * creatures sense smells other ways (feelers, forked-tongues, etc.)
+ * We're assuming all insects can smell at a distance too.
*/
boolean
olfaction(mdat)
-/* NetHack 3.6 monmove.c $NHDT-Date: 1445556875 2015/10/22 23:34:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.76 $ */
+/* NetHack 3.6 monmove.c $NHDT-Date: 1446604115 2015/11/04 02:28:35 $ $NHDT-Branch: master $:$NHDT-Revision: 1.77 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *));
STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *));
-boolean /* TRUE : mtmp died */
- mb_trapped(mtmp)
-register struct monst *mtmp;
+/* True if mtmp died */
+boolean
+mb_trapped(mtmp)
+struct monst *mtmp;
{
if (flags.verbose) {
if (cansee(mtmp->mx, mtmp->my) && !Unaware)
{
int x, y;
- if (mtmp->mpeaceful && in_town(u.ux + u.dx, u.uy + u.dy) && mtmp->mcansee
- && m_canseeu(mtmp) && !rn2(3)) {
+ if (mtmp->mpeaceful && in_town(u.ux + u.dx, u.uy + u.dy)
+ && mtmp->mcansee && m_canseeu(mtmp) && !rn2(3)) {
if (picking_lock(&x, &y) && IS_DOOR(levl[x][y].typ)
&& (levl[x][y].doormask & D_LOCKED)) {
if (couldsee(mtmp->mx, mtmp->my)) {
dochugw(mtmp)
register struct monst *mtmp;
{
- register int x = mtmp->mx, y = mtmp->my;
+ int x = mtmp->mx, y = mtmp->my;
boolean already_saw_mon = !occupation ? 0 : canspotmon(mtmp);
int rd = dochug(mtmp);
/* check whether hero notices monster and stops current activity */
if (occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination)
/* it's close enough to be a threat */
- && distu(mtmp->mx, mtmp->my) <= (BOLT_LIM + 1) * (BOLT_LIM + 1)
+ && distu(x, y) <= (BOLT_LIM + 1) * (BOLT_LIM + 1)
/* and either couldn't see it before, or it was too far away */
&& (!already_saw_mon || !couldsee(x, y)
|| distu(x, y) > (BOLT_LIM + 1) * (BOLT_LIM + 1))
/* can see it now, or sense it and would normally see it */
- && (canseemon(mtmp)
- || (sensemon(mtmp) && couldsee(mtmp->mx, mtmp->my)))
+ && (canseemon(mtmp) || (sensemon(mtmp) && couldsee(x, y)))
&& mtmp->mcanmove && !noattacks(mtmp->data)
&& !onscary(u.ux, u.uy, mtmp))
stop_occupation();
* + Nymphs, jabberwocks, and leprechauns do not easily wake up.
*
* Wake up if:
- * in direct LOS AND
- * within 10 squares AND
- * not stealthy or (mon is an ettin and 9/10) AND
- * (mon is not a nymph, jabberwock, or leprechaun) or 1/50 AND
- * Aggravate or mon is (dog or human) or
- * (1/7 and mon is not mimicing furniture or object)
+ * in direct LOS AND
+ * within 10 squares AND
+ * not stealthy or (mon is an ettin and 9/10) AND
+ * (mon is not a nymph, jabberwock, or leprechaun) or 1/50 AND
+ * Aggravate or mon is (dog or human) or
+ * (1/7 and mon is not mimicing furniture or object)
*/
if (couldsee(mtmp->mx, mtmp->my) && distu(mtmp->mx, mtmp->my) <= 100
&& (!Stealth || (mtmp->data == &mons[PM_ETTIN] && rn2(10)))
register int tmp = 0;
int inrange, nearby, scared;
- /* Pre-movement adjustments */
+ /* Pre-movement adjustments
+ */
mdat = mtmp->data;
}
/* the watch will look around and see if you are up to no good :-) */
- if (is_watch(mdat))
+ if (is_watch(mdat)) {
watch_on_duty(mtmp);
- else if (is_mind_flayer(mdat) && !rn2(20)) {
+ } else if (is_mind_flayer(mdat) && !rn2(20)) {
struct monst *m2, *nmon = (struct monst *) 0;
if (canseemon(mtmp))
}
}
- /* Now the actual movement phase */
+ /* Now the actual movement phase
+ */
if (!nearby || mtmp->mflee || scared || mtmp->mconf || mtmp->mstun
|| (mtmp->minvis && !rn2(3))
}
}
- /* Now, attack the player if possible - one attack set per monst */
+ /* Now, attack the player if possible - one attack set per monst
+ */
if (!mtmp->mpeaceful || (Conflict && !resist(mtmp, RING_CLASS, 0, 0))) {
if (inrange && !noattacks(mdat) && u.uhp > 0 && !scared && tmp != 3)
GEM_CLASS, FOOD_CLASS, 0 };
static NEARDATA const char magical[] = { AMULET_CLASS, POTION_CLASS,
SCROLL_CLASS, WAND_CLASS,
- RING_CLASS, SPBOOK_CLASS,
- 0 };
+ RING_CLASS, SPBOOK_CLASS, 0 };
static NEARDATA const char indigestion[] = { BALL_CLASS, ROCK_CLASS, 0 };
static NEARDATA const char boulder_class[] = { ROCK_CLASS, 0 };
static NEARDATA const char gem_class[] = { GEM_CLASS, 0 };
gx = mtmp->mux;
gy = mtmp->muy;
appr = mtmp->mflee ? -1 : 1;
- if (mtmp->mconf || (u.uswallow && mtmp == u.ustuck))
+ if (mtmp->mconf || (u.uswallow && mtmp == u.ustuck)) {
appr = 0;
- else {
+ } else {
struct obj *lepgold, *ygold;
- boolean should_see =
- (couldsee(omx, omy) && (levl[gx][gy].lit || !levl[omx][omy].lit)
- && (dist2(omx, omy, gx, gy) <= 36));
+ boolean should_see = (couldsee(omx, omy)
+ && (levl[gx][gy].lit || !levl[omx][omy].lit)
+ && (dist2(omx, omy, gx, gy) <= 36));
if (!mtmp->mcansee
|| (should_see && Invis && !perceives(ptr) && rn2(11))
|| is_obj_mappear(&youmonst,STRANGE_OBJECT) || u.uundetected
|| (is_obj_mappear(&youmonst,GOLD_PIECE) && !likes_gold(ptr))
- || (mtmp->mpeaceful && !mtmp->isshk) || /* allow shks to follow */
- ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT
- || ptr->mlet == S_LIGHT) && !rn2(3)))
+ || (mtmp->mpeaceful && !mtmp->isshk) /* allow shks to follow */
+ || ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT
+ || ptr->mlet == S_LIGHT) && !rn2(3)))
appr = 0;
if (monsndx(ptr) == PM_LEPRECHAUN && (appr == 1)
}
if ((!mtmp->mpeaceful || !rn2(10)) && (!Is_rogue_level(&u.uz))) {
- boolean in_line =
- lined_up(mtmp)
- && (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy)
- <= (throws_rocks(youmonst.data) ? 20 : ACURRSTR / 2 + 1));
+ boolean in_line = (lined_up(mtmp)
+ && (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy)
+ <= (throws_rocks(youmonst.data) ? 20 : ACURRSTR / 2 + 1)));
if (appr != 1 || !in_line) {
/* Monsters in combat won't pick stuff up, avoiding the
&& (!is_unicorn(ptr)
|| objects[otmp->otyp].oc_material == GEMSTONE)
/* Don't get stuck circling an Elbereth */
- && !(onscary(xx, yy, mtmp))) {
+ && !onscary(xx, yy, mtmp)) {
minr = distmin(omx, omy, xx, yy);
oomx = min(COLNO - 1, omx + minr);
oomy = min(ROWNO - 1, omy + minr);
* nearby is set, we never call m_move unless it is a special case
* (confused, stun, etc.) The effect is that this ALLOW_U (and
* mfndpos) has no effect for normal attacks, though it lets a
- * confused
- * monster attack you by accident.
+ * confused monster attack you by accident.
*/
if (info[chi] & ALLOW_U) {
nix = mtmp->mux;
/* open a door, or crash through it, if you can */
if (IS_DOOR(levl[mtmp->mx][mtmp->my].typ)
&& !passes_walls(ptr) /* doesn't need to open doors */
- && !can_tunnel /* taken care of below */
- ) {
+ && !can_tunnel) { /* taken care of below */
struct rm *here = &levl[mtmp->mx][mtmp->my];
boolean btrapped = (here->doormask & D_TRAPPED),
observeit = canseeit && canspotmon(mtmp);
/* recompute the likes tests, in case we polymorphed
* or if the "likegold" case got taken above */
if (setlikes) {
- register int pctload =
- (curr_mon_load(mtmp) * 100) / max_mon_load(mtmp);
+ int pctload = (curr_mon_load(mtmp) * 100) / max_mon_load(mtmp);
/* look for gold or jewels nearby */
likegold = (likes_gold(ptr) && pctload < 95);
/* Pets avoid cursed locations */
if (cursed_object_at(x, y))
return TRUE;
- }
+
/* Monsters avoid a trap if they've seen that type before */
- else if (trap && rn2(40)
- && (mtmp->mtrapseen & (1 << (trap->ttyp - 1))) != 0)
+ } else if (trap && rn2(40)
+ && (mtmp->mtrapseen & (1 << (trap->ttyp - 1))) != 0) {
return TRUE;
+ }
return FALSE;
}
struct permonst *ptr;
{
int reslt = 0;
+
if (mon->cham >= LOW_PM) {
if (ptr == &mons[mon->cham])
mon->cham = NON_PM;
-/* NetHack 3.6 mthrowu.c $NHDT-Date: 1445556876 2015/10/22 23:34:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
+/* NetHack 3.6 mthrowu.c $NHDT-Date: 1446604116 2015/11/04 02:28:36 $ $NHDT-Branch: master $:$NHDT-Revision: 1.61 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
pline("It misses.");
else
You("are almost hit by %s.", onm);
- return (0);
+ return 0;
} else {
if (Blind || !flags.verbose)
You("are hit%s", exclam(dam));
losehp(dam, knm, kprefix); /* acid damage */
exercise(A_STR, FALSE);
}
- return (1);
+ return 1;
}
}
int range; /* how much farther will object travel if it misses */
/* Use -1 to signify to keep going even after hit, */
/* unless its gone (used for rolling_boulder_traps) */
-boolean verbose; /* give message(s) even when you can't see what happened */
+boolean verbose; /* give message(s) even when you can't see what happened */
{
int damage, tmp;
boolean vis, ismimic;
/* Multishot calculations */
multishot = 1;
- if (otmp->quan > 1L && /* no point checking if there's only 1 */
+ if (otmp->quan > 1L /* no point checking if there's only 1 */
/* ammo requires corresponding launcher be wielded */
- (is_ammo(otmp) ? matching_launcher(otmp, mwep)
- /* otherwise any stackable (non-ammo) weapon */
- : otmp->oclass == WEAPON_CLASS) && !mtmp->mconf) {
+ && (is_ammo(otmp)
+ ? matching_launcher(otmp, mwep)
+ /* otherwise any stackable (non-ammo) weapon */
+ : otmp->oclass == WEAPON_CLASS)
+ && !mtmp->mconf) {
int skill = (int) objects[otmp->otyp].oc_skill;
/* Assumes lords are skilled, princes are expert */
/* monster spits substance at you */
int
spitmu(mtmp, mattk)
-register struct monst *mtmp;
-register struct attack *mattk;
+struct monst *mtmp;
+struct attack *mattk;
{
- register struct obj *otmp;
+ struct obj *otmp;
if (mtmp->mcan) {
if (!Deaf)
/* monster breathes at you (ranged) */
int
breamu(mtmp, mattk)
-register struct monst *mtmp;
-register struct attack *mattk;
+struct monst *mtmp;
+struct attack *mattk;
{
/* if new breath types are added, change AD_ACID to max type */
int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp;
else
You_hear("a cough.");
}
- return (0);
+ return 0;
}
if (!mtmp->mspec_used && rn2(3)) {
if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
impossible("Breath weapon %d used", typ - 1);
}
}
- return (1);
+ return 1;
}
boolean
{
int dx, dy, boulderspots;
- tbx = ax - bx; /* These two values are set for use */
- tby = ay - by; /* after successful return. */
+ /* These two values are set for use after successful return. */
+ tbx = ax - bx;
+ tby = ay - by;
/* sometimes displacement makes a monster think that you're at its
own location; prevent it from throwing and zapping in that case */
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->otyp == type)
- return (otmp);
- return ((struct obj *) 0);
+ return otmp;
+ return (struct obj *) 0;
}
/* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */
-/* NetHack 3.6 polyself.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */
-/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
+/* NetHack 3.6 polyself.c $NHDT-Date: 1446604117 2015/11/04 02:28:37 $ $NHDT-Branch: master $:$NHDT-Revision: 1.102 $ */
+/* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
/*
* player polymorphed into a light-emitting monster.
*
* Transformation sequences:
- * /-> polymon poly into monster form
+ * /-> polymon poly into monster form
* polyself =
- * \-> newman -> polyman fail to poly, get human form
+ * \-> newman -> polyman fail to poly, get human form
*
- * rehumanize -> polyman return to original form
+ * rehumanize -> polyman return to original form
*
- * polymon (called directly) usually golem petrification
+ * polymon (called directly) usually golem petrification
*/
#include "hack.h"
}
/* resists_magm() takes wielded, worn, and carried equipment into
into account; cheat and duplicate its monster-specific part */
- PROPSET(ANTIMAGIC,
- (dmgtype(mdat, AD_MAGM) || mdat == &mons[PM_BABY_GRAY_DRAGON]
- || dmgtype(mdat, AD_RBRE)));
+ PROPSET(ANTIMAGIC, (dmgtype(mdat, AD_MAGM)
+ || mdat == &mons[PM_BABY_GRAY_DRAGON]
+ || dmgtype(mdat, AD_RBRE)));
PROPSET(SICK_RES, (mdat->mlet == S_FUNGUS || mdat == &mons[PM_GHOUL]));
PROPSET(STUNNED, (mdat == &mons[PM_STALKER] || is_bat(mdat)));
check_strangling(on)
boolean on;
{
- if (on) { /* on -- maybe resume strangling */
- /* when Strangled is already set, polymorphing from one
- vulnerable form into another causes the counter to be reset */
+ /* on -- maybe resume strangling */
+ if (on) {
+ /* when Strangled is already set, polymorphing from one
+ vulnerable form into another causes the counter to be reset */
if (uamul && uamul->otyp == AMULET_OF_STRANGULATION
&& can_be_strangled(&youmonst)) {
Your("%s %s your %s!", simpleonames(uamul),
Strangled = 6L;
makeknown(AMULET_OF_STRANGULATION);
}
- } else { /* off -- maybe block strangling */
+
+ /* off -- maybe block strangling */
+ } else {
if (Strangled && !can_be_strangled(&youmonst)) {
Strangled = 0L;
You("are no longer being strangled.");
polyman(fmt, arg)
const char *fmt, *arg;
{
- boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow,
+ boolean sticky = (sticks(youmonst.data) && u.ustuck && !u.uswallow),
was_mimicking = (youmonst.m_ap_type == M_AP_OBJECT);
boolean was_blind = !!Blind;
swap unintentionally makes `Upolyd' appear to be true */
boolean already_polyd = (boolean) Upolyd;
- /* Some monsters are always of one sex and their sex can't be changed */
- /* succubi/incubi can change, but are handled below */
- /* !already_polyd check necessary because is_male() and is_female()
- are true if the player is a priest/priestess */
+ /* Some monsters are always of one sex and their sex can't be changed;
+ * Succubi/incubi can change, but are handled below.
+ *
+ * !already_polyd check necessary because is_male() and is_female()
+ * are true if the player is a priest/priestess.
+ */
if (!already_polyd
|| (!is_male(youmonst.data) && !is_female(youmonst.data)
&& !is_neuter(youmonst.data)))
/*
* New hit points:
- * remove level-gain based HP from any extra HP accumulated
- * (the "extra" might actually be negative);
- * modify the extra, retaining {80%, 90%, 100%, or 110%};
- * add in newly generated set of level-gain HP.
+ * remove level-gain based HP from any extra HP accumulated
+ * (the "extra" might actually be negative);
+ * modify the extra, retaining {80%, 90%, 100%, or 110%};
+ * add in newly generated set of level-gain HP.
+ *
* (This used to calculate new HP in direct proportion to old HP,
* but that was subject to abuse: accumulate a large amount of
* extra HP, drain level down to 1, then polyself to level 2 or 3
}
}
-/* (try to) make a mntmp monster out of the player */
-int polymon(mntmp) /* returns 1 if polymorph successful */
+/* (try to) make a mntmp monster out of the player;
+ returns 1 if polymorph successful */
+int
+polymon(mntmp)
int mntmp;
{
boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow,
if (mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */
You_feel("rather %s-ish.", mons[mntmp].mname);
exercise(A_WIS, TRUE);
- return (0);
+ return 0;
}
/* KMH, conduct */
u.mh = u.mhmax;
if (u.ulevel < mlvl) {
-/* Low level characters can't become high level monsters for long */
+ /* Low level characters can't become high level monsters for long */
#ifdef DUMB
/* DRS/NS 2.2.6 messes up -- Peter Kendell */
int mtd = u.mtimedone, ulv = u.ulevel;
if (lays_eggs(youmonst.data) && flags.female)
pline(use_thec, "sit", "lay an egg");
}
+
/* you now know what an egg of your type looks like */
if (lays_eggs(youmonst.data)) {
learn_egg_type(u.umonnum);
flesh golem above, now gets transformed back into stone golem] */
if (!uarmg)
selftouch(no_longer_petrify_resistant);
- return (1);
+ return 1;
}
STATIC_OVL void
if (Strangled) {
You_cant("breathe. Sorry.");
- return (0);
+ return 0;
}
if (u.uen < 15) {
You("don't have enough energy to breathe!");
- return (0);
+ return 0;
}
u.uen -= 15;
context.botl = 1;
if (!getdir((char *) 0))
- return (0);
+ return 0;
mattk = attacktype_fordmg(youmonst.data, AT_BREA, AD_ANY);
if (!mattk)
else
buzz((int) (20 + mattk->adtyp - 1), (int) mattk->damn, u.ux, u.uy,
u.dx, u.dy);
- return (1);
+ return 1;
}
int
struct attack *mattk;
if (!getdir((char *) 0))
- return (0);
+ return 0;
mattk = attacktype_fordmg(youmonst.data, AT_SPIT, AD_ANY);
if (!mattk) {
impossible("bad spit attack?");
otmp->spe = 1; /* to indicate it's yours */
throwit(otmp, 0L, FALSE);
}
- return (1);
+ return 1;
}
int
if (u.utrap && u.utraptype == TT_BURIEDBALL) {
pline_The("ball and chain are buried firmly in the %s.",
surface(u.ux, u.uy));
- return (0);
+ return 0;
}
You("are not chained to anything!");
- return (0);
+ return 0;
}
unpunish();
- return (1);
+ return 1;
}
int
if (Levitation || Is_airlevel(&u.uz) || Underwater
|| Is_waterlevel(&u.uz)) {
You("must be on the ground to spin a web.");
- return (0);
+ return 0;
}
if (u.uswallow) {
You("release web fluid inside %s.", mon_nam(u.ustuck));
if (is_animal(u.ustuck->data)) {
expels(u.ustuck, u.ustuck->data, TRUE);
- return (0);
+ return 0;
}
if (is_whirly(u.ustuck->data)) {
int i;
}
pline_The("web %sis swept away!", sweep);
}
- return (0);
+ return 0;
} /* default: a nasty jelly-like creature */
pline_The("web dissolves into %s.", mon_nam(u.ustuck));
- return (0);
+ return 0;
}
if (u.utrap) {
You("cannot spin webs while stuck in a trap.");
- return (0);
+ return 0;
}
exercise(A_DEX, TRUE);
- if (ttmp)
+ if (ttmp) {
switch (ttmp->ttyp) {
case PIT:
case SPIKED_PIT:
deltrap(ttmp);
bury_objs(u.ux, u.uy);
newsym(u.ux, u.uy);
- return (1);
+ return 1;
case SQKY_BOARD:
pline_The("squeaky board is muffled.");
deltrap(ttmp);
newsym(u.ux, u.uy);
- return (1);
+ return 1;
case TELEP_TRAP:
case LEVEL_TELEP:
case MAGIC_PORTAL:
case VIBRATING_SQUARE:
Your("webbing vanishes!");
- return (0);
+ return 0;
case WEB:
You("make the web thicker.");
- return (1);
+ return 1;
case HOLE:
case TRAPDOOR:
You("web over the %s.",
You("spin a web, jamming the trigger.");
deltrap(ttmp);
newsym(u.ux, u.uy);
- return (1);
+ return 1;
case ARROW_TRAP:
case DART_TRAP:
case BEAR_TRAP:
case POLY_TRAP:
You("have triggered a trap!");
dotrap(ttmp, 0);
- return (1);
+ return 1;
default:
impossible("Webbing over trap type %d?", ttmp->ttyp);
- return (0);
+ return 0;
}
- else if (On_stairs(u.ux, u.uy)) {
+ } else if (On_stairs(u.ux, u.uy)) {
/* cop out: don't let them hide the stairs */
Your("web fails to impede access to the %s.",
(levl[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder");
- return (1);
+ return 1;
}
ttmp = maketrap(u.ux, u.uy, WEB);
if (ttmp) {
ttmp->madeby_u = 1;
feeltrap(ttmp);
}
- return (1);
+ return 1;
}
int
int placeholder;
if (u.uen < 10) {
You("lack the energy to send forth a call for help!");
- return (0);
+ return 0;
}
u.uen -= 10;
context.botl = 1;
exercise(A_WIS, TRUE);
if (!were_summon(youmonst.data, TRUE, &placeholder, (char *) 0))
pline("But none arrive.");
- return (1);
+ return 1;
}
int
}
if (u.uen < 15) {
You("lack the energy to use your special gaze!");
- return (0);
+ return 0;
}
u.uen -= 15;
context.botl = 1;
continue;
if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) {
looked++;
- if (Invis && !perceives(mtmp->data))
+ if (Invis && !perceives(mtmp->data)) {
pline("%s seems not to notice your gaze.", Monnam(mtmp));
- else if (mtmp->minvis && !See_invisible)
+ } else if (mtmp->minvis && !See_invisible) {
You_cant("see where to gaze at %s.", Monnam(mtmp));
- else if (mtmp->m_ap_type == M_AP_FURNITURE
- || mtmp->m_ap_type == M_AP_OBJECT) {
+ } else if (mtmp->m_ap_type == M_AP_FURNITURE
+ || mtmp->m_ap_type == M_AP_OBJECT) {
looked--;
continue;
} else if (flags.safe_dog && mtmp->mtame && !Confusion) {
u.uundetected = 0;
return 0;
}
- if ((is_hider(youmonst.data) && !Flying) && /* floor hider */
- (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) {
+ if ((is_hider(youmonst.data) && !Flying) /* floor hider */
+ && (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) {
There("is nowhere to hide beneath you.");
u.uundetected = 0;
return 0;
}
/* TODO? inhibit floor hiding at furniture locations, or
- else make youhiding() give smarter messages at such spots */
+ * else make youhiding() give smarter messages at such spots.
+ */
if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
youhiding(FALSE, 1); /* "you are already hiding" */
dopoly()
{
struct permonst *savedat = youmonst.data;
+
if (is_vampire(youmonst.data)) {
polyself(2);
if (savedat != youmonst.data) {
newsym(u.ux, u.uy);
}
}
- return (1);
+ return 1;
}
int
if (u.uen < 10) {
You("concentrate but lack the energy to maintain doing so.");
- return (0);
+ return 0;
}
u.uen -= 10;
context.botl = 1;
int
poly_gender()
{
- /* Returns gender of polymorphed player; 0/1=same meaning as flags.female,
- * 2=none.
+ /* Returns gender of polymorphed player;
+ * 0/1=same meaning as flags.female, 2=none.
*/
if (is_neuter(youmonst.data) || !humanoid(youmonst.data))
return 2;
int damtype, dam;
{
int heal = 0;
+
/* We won't bother with "slow"/"haste" since players do not
* have a monster-specific slow/haste so there is no way to
* restore the old velocity once they are back to human.
switch (damtype) {
case AD_ELEC:
if (u.umonnum == PM_FLESH_GOLEM)
- heal = dam / 6; /* Approx 1 per die */
+ heal = (dam + 5) / 6; /* Approx 1 per die */
break;
case AD_FIRE:
if (u.umonnum == PM_IRON_GOLEM)
case SILVER_DRAGON_SCALES:
return PM_SILVER_DRAGON;
#if 0 /* DEFERRED */
- case SHIMMERING_DRAGON_SCALE_MAIL:
- case SHIMMERING_DRAGON_SCALES:
- return PM_SHIMMERING_DRAGON;
+ case SHIMMERING_DRAGON_SCALE_MAIL:
+ case SHIMMERING_DRAGON_SCALES:
+ return PM_SHIMMERING_DRAGON;
#endif
case RED_DRAGON_SCALE_MAIL:
case RED_DRAGON_SCALES:
struct permonst *mptr;
{
short warnidx = 0;
+
context.warntype.speciesidx = 0;
context.warntype.species = 0;
context.warntype.polyd = 0;
-/* NetHack 3.6 trap.c $NHDT-Date: 1446078765 2015/10/29 00:32:45 $ $NHDT-Branch: master $:$NHDT-Revision: 1.242 $ */
+/* NetHack 3.6 trap.c $NHDT-Date: 1446604119 2015/11/04 02:28:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.243 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
STATIC_DCL int FDECL(disarm_landmine, (struct trap *));
STATIC_DCL int FDECL(disarm_squeaky_board, (struct trap *));
STATIC_DCL int FDECL(disarm_shooting_trap, (struct trap *, int));
-STATIC_DCL int FDECL(try_lift,
- (struct monst *, struct trap *, int, BOOLEAN_P));
+STATIC_DCL int FDECL(try_lift, (struct monst *, struct trap *, int,
+ BOOLEAN_P));
STATIC_DCL int FDECL(help_monster_out, (struct monst *, struct trap *));
-STATIC_DCL boolean
-FDECL(thitm, (int, struct monst *, struct obj *, int, BOOLEAN_P));
+STATIC_DCL boolean FDECL(thitm, (int, struct monst *, struct obj *, int,
+ BOOLEAN_P));
STATIC_DCL void FDECL(launch_drop_spot, (struct obj *, XCHAR_P, XCHAR_P));
-STATIC_DCL int FDECL(mkroll_launch,
- (struct trap *, XCHAR_P, XCHAR_P, SHORT_P, long));
+STATIC_DCL int FDECL(mkroll_launch, (struct trap *, XCHAR_P, XCHAR_P,
+ SHORT_P, long));
STATIC_DCL boolean FDECL(isclearpath, (coord *, int, SCHAR_P, SCHAR_P));
STATIC_DCL char *FDECL(trapnote, (struct trap *, BOOLEAN_P));
#if 0
#endif
STATIC_DCL void FDECL(clear_conjoined_pits, (struct trap *));
STATIC_DCL int FDECL(steedintrap, (struct trap *, struct obj *));
-STATIC_DCL boolean
-FDECL(keep_saddle_with_steedcorpse, (unsigned, struct obj *, struct obj *));
+STATIC_DCL boolean FDECL(keep_saddle_with_steedcorpse, (unsigned,
+ struct obj *,
+ struct obj *));
STATIC_DCL void NDECL(maybe_finish_sokoban);
/* mintrap() should take a flags argument, but for time being we use this */
int
erode_obj(otmp, ostr, type, ef_flags)
register struct obj *otmp;
-register const char *ostr;
+const char *ostr;
int type;
int ef_flags;
{
boolean
grease_protect(otmp, ostr, victim)
register struct obj *otmp;
-register const char *ostr;
+const char *ostr;
struct monst *victim;
{
static const char txt[] = "protected by the layer of grease!";
if (victim == &youmonst)
Your("%s %s %s", ostr, vtense(ostr, "are"), txt);
else if (vismon)
- pline("%s's %s %s %s", Monnam(victim), ostr, vtense(ostr, "are"),
- txt);
- } else if ((victim == &youmonst) || vismon) {
+ pline("%s's %s %s %s", Monnam(victim),
+ ostr, vtense(ostr, "are"), txt);
+ } else if (victim == &youmonst || vismon) {
pline("%s %s", Yobjnam2(otmp, "are"), txt);
}
if (!rn2(2)) {
{
register struct trap *ttmp;
register struct rm *lev;
- register boolean oldplace;
+ boolean oldplace;
if ((ttmp = t_at(x, y)) != 0) {
if (ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE)
return (struct trap *) 0;
oldplace = TRUE;
- if (u.utrap && (x == u.ux) && (y == u.uy)
+ if (u.utrap && x == u.ux && y == u.uy
&& ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP)
|| (u.utraptype == TT_WEB && typ != WEB)
|| (u.utraptype == TT_PIT && typ != PIT
ttmp->tnote = (short) rn2(12); /* all in use anyway */
break;
}
- case STATUE_TRAP: /* create a "living" statue */
- {
+ case STATUE_TRAP: { /* create a "living" statue */
struct monst *mtmp;
struct obj *otmp, *statue;
struct permonst *mptr;
case PIT:
case SPIKED_PIT:
ttmp->conjoined = 0;
- /* fall through */
+ /*FALLTHRU*/
case HOLE:
case TRAPDOOR:
lev = &levl[x][y];
if (*in_rooms(x, y, SHOPBASE)
- && ((typ == HOLE || typ == TRAPDOOR) || IS_DOOR(lev->typ)
- || IS_WALL(lev->typ)))
+ && (typ == HOLE || typ == TRAPDOOR
+ || IS_DOOR(lev->typ) || IS_WALL(lev->typ)))
add_damage(x, y, /* schedule repair */
((IS_DOOR(lev->typ) || IS_WALL(lev->typ))
&& !context.mon_moving)
lev->doormask = 0; /* subsumes altarmask, icedpool... */
if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
lev->typ = ROOM;
-
/*
* some cases which can happen when digging
* down while phazing thru solid areas
*
* The cause of animation is:
*
- * ANIMATE_NORMAL - hero "finds" the monster
- * ANIMATE_SHATTER - hero tries to destroy the statue
- * ANIMATE_SPELL - stone to flesh spell hits the statue
+ * ANIMATE_NORMAL - hero "finds" the monster
+ * ANIMATE_SHATTER - hero tries to destroy the statue
+ * ANIMATE_SPELL - stone to flesh spell hits the statue
*
* Perhaps x, y is not needed if we can use get_obj_location() to find
* the statue's location... ???
*
* Sequencing matters:
- * create monster; if it fails, give up with statue intact;
- * give "statue comes to life" message;
- * if statue belongs to shop, have shk give "you owe" message;
- * transfer statue contents to monster (after stolen_value());
- * delete statue.
- * [This ordering means that if the statue ends up wearing a cloak of
- * invisibility or a mummy wrapping, the visibility checks might be
- * wrong, but to avoid that we'd have to clone the statue contents
- * first in order to give them to the monster before checking their
- * shop status--it's not worth the hassle.]
+ * create monster; if it fails, give up with statue intact;
+ * give "statue comes to life" message;
+ * if statue belongs to shop, have shk give "you owe" message;
+ * transfer statue contents to monster (after stolen_value());
+ * delete statue.
+ * [This ordering means that if the statue ends up wearing a cloak of
+ * invisibility or a mummy wrapping, the visibility checks might be
+ * wrong, but to avoid that we'd have to clone the statue contents
+ * first in order to give them to the monster before checking their
+ * shop status--it's not worth the hassle.]
*/
struct monst *
animate_statue(statue, x, y, cause, fail_reason)
newsym(u.ux, u.uy);
}
break;
+
case DART_TRAP:
if (trap->once && trap->tseen && !rn2(15)) {
You_hear("a soft click.");
newsym(u.ux, u.uy);
}
break;
+
case ROCKTRAP:
if (trap->once && trap->tseen && !rn2(15)) {
pline("A trap door in %s opens, but nothing falls out!",
exercise(A_DEX, FALSE);
}
break;
+
case HOLE:
case TRAPDOOR:
if (!Can_fall_thru(&u.uz)) {
seetrap(trap);
tele_trap(trap);
break;
+
case LEVEL_TELEP:
seetrap(trap);
level_tele_trap(trap);
fill_pit(u.ux, u.uy);
break;
}
+
case ROLLING_BOULDER_TRAP: {
int style = ROLL | (trap->tseen ? LAUNCH_KNOWN : 0);
}
break;
}
+
case MAGIC_PORTAL:
feeltrap(trap);
domagicportal(trap);
break;
+
case VIBRATING_SQUARE:
seetrap(trap);
/* messages handled elsewhere; the trap symbol is merely to mark the
}
}
+/* start levitating */
void
float_up()
{
} else {
You("float up, only your %s is still stuck.", body_part(LEG));
}
- }
#if 0
- else if(Is_waterlevel(&u.uz))
- pline("It feels as though you've lost some weight.");
+ } else if(Is_waterlevel(&u.uz)) {
+ pline("It feels as though you've lost some weight.");
#endif
- else if (u.uinwater)
+ } else if (u.uinwater) {
spoteffects(TRUE);
- else if (u.uswallow)
+ } else if (u.uswallow) {
You(is_animal(u.ustuck->data) ? "float away from the %s."
: "spiral up into %s.",
is_animal(u.ustuck->data) ? surface(u.ux, u.uy)
: mon_nam(u.ustuck));
- else if (Hallucination)
+ } else if (Hallucination) {
pline("Up, up, and awaaaay! You're walking on air!");
- else if (Is_airlevel(&u.uz))
+ } else if (Is_airlevel(&u.uz)) {
You("gain control over your movements.");
- else
+ } else {
You("start to float in the air!");
+ }
if (u.usteed && !is_floater(u.usteed->data)
&& !is_flyer(u.usteed->data)) {
- if (Lev_at_will)
+ if (Lev_at_will) {
pline("%s magically floats up!", Monnam(u.usteed));
- else {
+ } else {
You("cannot stay on %s.", mon_nam(u.usteed));
dismount_steed(DISMOUNT_GENERIC);
}
}
}
+/* stop levitating */
int
float_down(hmask, emask)
long hmask, emask; /* might cancel timeout */
}
if (!trap) {
trap = t_at(u.ux, u.uy);
- if (Is_airlevel(&u.uz))
+ if (Is_airlevel(&u.uz)) {
You("begin to tumble in place.");
- else if (Is_waterlevel(&u.uz) && !no_msg)
+ } else if (Is_waterlevel(&u.uz) && !no_msg) {
You_feel("heavier.");
/* u.uinwater msgs already in spoteffects()/drown() */
- else if (!u.uinwater && !no_msg) {
+ } else if (!u.uinwater && !no_msg) {
if (!(emask & W_SADDLE)) {
if (Sokoban && trap) {
- /* Justification elsewhere for Sokoban traps
- * is based on air currents. This is
- * consistent with that.
- * The unexpected additional force of the
- * air currents once levitation
- * ceases knocks you off your feet.
+ /* Justification elsewhere for Sokoban traps is based
+ * on air currents. This is consistent with that.
+ * The unexpected additional force of the air currents
+ * once levitation ceases knocks you off your feet.
*/
if (Hallucination)
pline("Bummer! You've crashed.");
} else if (u.usteed && (is_floater(u.usteed->data)
|| is_flyer(u.usteed->data))) {
You("settle more firmly in the saddle.");
- } else if (Hallucination)
- pline("Bummer! You've %s.", is_pool(u.ux, u.uy)
- ? "splashed down"
- : "hit the ground");
- else
+ } else if (Hallucination) {
+ pline("Bummer! You've %s.",
+ is_pool(u.ux, u.uy)
+ ? "splashed down"
+ : "hit the ground");
+ } else {
You("float gently to the %s.", surface(u.ux, u.uy));
+ }
}
}
}
/* can't rely on u.uz0 for detecting trap door-induced level change;
it gets changed to reflect the new level before we can check it */
assign_level(¤t_dungeon_level, &u.uz);
-
- if (trap)
+ if (trap) {
switch (trap->ttyp) {
case STATUE_TRAP:
break;
if (!u.utrap) /* not already in the trap */
dotrap(trap, 0);
}
-
+ }
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 */
return TRUE;
} else if (!force && (Luck + 5) > rn2(20)) {
/* chance per item of sustaining damage:
- * max luck (Luck==13): 10%
- * avg luck (Luck==0): 75%
- * awful luck (Luck<-4): 100%
+ * max luck (Luck==13): 10%
+ * avg luck (Luck==0): 75%
+ * awful luck (Luck<-4): 100%
*/
return FALSE;
} else if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) {
return ER_NOTHING;
} else if (!force && (Luck + 5) > rn2(20)) {
/* chance per item of sustaining damage:
- * max luck: 10%
- * avg luck (Luck==0): 75%
- * awful luck (Luck<-4): 100%
+ * max luck: 10%
+ * avg luck (Luck==0): 75%
+ * awful luck (Luck<-4): 100%
*/
return ER_NOTHING;
} else if (obj->oclass == SCROLL_CLASS) {
return TRUE;
}
-/*
- * return(TRUE) == player relocated
- */
+
+/* return TRUE iff player relocated */
boolean
drown()
{
}
crawl_ok = FALSE;
x = y = 0; /* lint suppression */
- /* if sleeping, wake up now so that we don't crawl out of water
- while still asleep; we can't do that the same way that waking
- due to combat is handled; note unmul() clears u.usleep */
+ /* if sleeping, wake up now so that we don't crawl out of water
+ while still asleep; we can't do that the same way that waking
+ due to combat is handled; note unmul() clears u.usleep */
if (u.usleep)
unmul("Suddenly you wake up!");
/* being doused will revive from fainting */
void
drain_en(n)
-register int n;
+int n;
{
if (!u.uenmax) {
/* energy is completely gone */
}
}
-int dountrap() /* disarm a trap */
+/* disarm a trap */
+int
+dountrap()
{
if (near_capacity() >= HVY_ENCUMBER) {
pline("You're too strained to do that.");
} else if (ttype == WEB) {
if (!webmaker(youmonst.data)) {
struct trap *ttmp2 = maketrap(u.ux, u.uy, WEB);
+
if (ttmp2) {
pline_The(
"webbing sticks to you. You're caught too!");
}
}
-STATIC_OVL int disarm_holdingtrap(ttmp) /* Helge Hafting */
+STATIC_OVL int
+disarm_holdingtrap(ttmp) /* Helge Hafting */
struct trap *ttmp;
{
struct monst *mtmp;
return 1;
}
-STATIC_OVL int disarm_landmine(ttmp) /* Helge Hafting */
+STATIC_OVL int
+disarm_landmine(ttmp) /* Helge Hafting */
struct trap *ttmp;
{
int fails = try_disarm(ttmp, FALSE);
if (!obj)
return 0;
- bad_tool =
- (obj->cursed || ((obj->otyp != POT_OIL || obj->lamplit)
- && (obj->otyp != CAN_OF_GREASE || !obj->spe)));
-
+ bad_tool = (obj->cursed
+ || ((obj->otyp != POT_OIL || obj->lamplit)
+ && (obj->otyp != CAN_OF_GREASE || !obj->spe)));
fails = try_disarm(ttmp, bad_tool);
if (fails < 2)
return fails;
return FALSE;
}
+/* Destroy a trap that emanates from the floor. */
boolean
delfloortrap(ttmp)
register struct trap *ttmp;
{
- /* Destroy a trap that emanates from the floor. */
/* some of these are arbitrary -dlc */
if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP)
|| (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP)
}
deltrap(ttmp);
return TRUE;
- } else
- return FALSE;
+ }
+ return FALSE;
}
/* used for doors (also tins). can be used for anything else that opens. */
void
b_trapped(item, bodypart)
-register const char *item;
-register int bodypart;
+const char *item;
+int bodypart;
{
- register int lvl = level_difficulty();
- int dmg = rnd(5 + (lvl < 5 ? lvl : 2 + lvl / 2));
+ int lvl = level_difficulty(),
+ dmg = rnd(5 + (lvl < 5 ? lvl : 2 + lvl / 2));
pline("KABOOM!! %s was booby-trapped!", The(item));
wake_nearby();