another batch of formatting

Same sort of stuff as before:  some continuation lines with operator
followed by end of line comment (only a few files with those still to
go...), plus tab replaced by spaces in comments, excess parenthesis
removal for return statements, and force function name to be in column
one in function definitions:
  type name(args) /* comment */
  argtype args;
  {
to
  /* comment */
  type
  name(args)
  argtype args;
  {
I've been spotting those by eye rather than rexexp, so probably missed
some.
This commit is contained in:
PatR
2015-11-03 18:28:53 -08:00
parent 37771f779e
commit 2ddc361adf
10 changed files with 522 additions and 479 deletions
+37 -40
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -10,13 +10,10 @@ extern boolean notonhead;
STATIC_DCL boolean FDECL(dog_hunger, (struct monst *, struct edog *)); 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_invent, (struct monst *, struct edog *, int));
STATIC_DCL int FDECL(dog_goal, STATIC_DCL int FDECL(dog_goal, (struct monst *, struct edog *, int, int, int));
(struct monst *, struct edog *, int, int, int));
STATIC_DCL boolean FDECL(can_reach_location, (struct monst *, XCHAR_P, STATIC_DCL boolean FDECL(can_reach_location, (struct monst *, XCHAR_P,
XCHAR_P, XCHAR_P, XCHAR_P)); XCHAR_P, XCHAR_P, XCHAR_P));
STATIC_DCL boolean STATIC_DCL boolean FDECL(could_reach_item, (struct monst *, XCHAR_P, XCHAR_P));
FDECL(could_reach_item, (struct monst *, XCHAR_P, XCHAR_P));
STATIC_DCL void FDECL(quickmimic, (struct monst *)); STATIC_DCL void FDECL(quickmimic, (struct monst *));
/* pick a carried item for pet to drop */ /* pick a carried item for pet to drop */
@@ -320,12 +317,13 @@ boolean devour;
} }
#if 0 /* pet is eating, so slime recovery is not feasible... */ #if 0 /* pet is eating, so slime recovery is not feasible... */
/* turning into slime might be cureable */ /* turning into slime might be cureable */
if (slimer && munslime(mtmp, FALSE)) { if (slimer && munslime(mtmp, FALSE)) {
/* but the cure (fire directed at self) might be fatal */ /* but the cure (fire directed at self) might be fatal */
if (mtmp->mhp < 1) return 2; if (mtmp->mhp < 1)
slimer = FALSE; /* sliming is avoided, skip polymorph */ return 2;
} slimer = FALSE; /* sliming is avoided, skip polymorph */
}
#endif #endif
if (poly || slimer) { if (poly || slimer) {
@@ -383,10 +381,10 @@ register struct edog *edog;
You_feel("%s for a moment.", You_feel("%s for a moment.",
Hallucination ? "bummed" : "sad"); Hallucination ? "bummed" : "sad");
mondied(mtmp); mondied(mtmp);
return (TRUE); return TRUE;
} }
} }
return (FALSE); return FALSE;
} }
/* do something with object (drop, pick up, eat) at current position /* do something with object (drop, pick up, eat) at current position
@@ -402,7 +400,7 @@ int udist;
struct obj *obj, *otmp; struct obj *obj, *otmp;
if (mtmp->msleeping || !mtmp->mcanmove) if (mtmp->msleeping || !mtmp->mcanmove)
return (0); return 0;
omx = mtmp->mx; omx = mtmp->mx;
omy = mtmp->my; omy = mtmp->my;
@@ -462,8 +460,7 @@ int udist;
} }
/* set dog's goal -- gtyp, gx, gy /* 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 STATIC_OVL int
dog_goal(mtmp, edog, after, udist, whappr) dog_goal(mtmp, edog, after, udist, whappr)
register struct monst *mtmp; register struct monst *mtmp;
@@ -478,7 +475,7 @@ int after, udist, whappr;
/* Steeds don't move on their own will */ /* Steeds don't move on their own will */
if (mtmp == u.usteed) if (mtmp == u.usteed)
return (-2); return -2;
omx = mtmp->mx; omx = mtmp->mx;
omy = mtmp->my; omy = mtmp->my;
@@ -535,7 +532,8 @@ int after, udist, whappr;
&& !dog_has_minvent && !dog_has_minvent
&& (!levl[omx][omy].lit || levl[u.ux][u.uy].lit) && (!levl[omx][omy].lit || levl[u.ux][u.uy].lit)
&& (otyp == MANFOOD || m_cansee(mtmp, nx, ny)) && (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; gx = nx;
gy = ny; gy = ny;
gtyp = APPORT; gtyp = APPORT;
@@ -550,7 +548,7 @@ int after, udist, whappr;
gx = u.ux; gx = u.ux;
gy = u.uy; gy = u.uy;
if (after && udist <= 4 && 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; appr = (udist >= 9) ? 1 : (mtmp->mflee) ? -1 : 0;
if (udist > 1) { if (udist > 1) {
if (!IS_ROOM(levl[u.ux][u.uy].typ) || !rn2(4) || whappr if (!IS_ROOM(levl[u.ux][u.uy].typ) || !rn2(4) || whappr
@@ -645,19 +643,19 @@ register int after; /* this is extra fast monster movement */
omx = mtmp->mx; omx = mtmp->mx;
omy = mtmp->my; omy = mtmp->my;
if (has_edog && dog_hunger(mtmp, edog)) if (has_edog && dog_hunger(mtmp, edog))
return (2); /* starved */ return 2; /* starved */
udist = distu(omx, omy); udist = distu(omx, omy);
/* Let steeds eat and maybe throw rider during Conflict */ /* Let steeds eat and maybe throw rider during Conflict */
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
if (Conflict && !resist(mtmp, RING_CLASS, 0, 0)) { if (Conflict && !resist(mtmp, RING_CLASS, 0, 0)) {
dismount_steed(DISMOUNT_THROWN); dismount_steed(DISMOUNT_THROWN);
return (1); return 1;
} }
udist = 1; udist = 1;
} else if (!udist) } else if (!udist)
/* maybe we tamed him while being swallowed --jgm */ /* maybe we tamed him while being swallowed --jgm */
return (0); return 0;
nix = omx; /* set before newdogpos */ nix = omx; /* set before newdogpos */
niy = omy; niy = omy;
@@ -678,7 +676,7 @@ register int after; /* this is extra fast monster movement */
appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist, appr = dog_goal(mtmp, has_edog ? edog : (struct edog *) 0, after, udist,
whappr); whappr);
if (appr == -2) if (appr == -2)
return (0); return 0;
allowflags = ALLOW_M | ALLOW_TRAPS | ALLOW_SSM | ALLOW_SANCT; allowflags = ALLOW_M | ALLOW_TRAPS | ALLOW_SSM | ALLOW_SANCT;
if (passes_walls(mtmp->data)) if (passes_walls(mtmp->data))
@@ -716,8 +714,7 @@ register int after; /* this is extra fast monster movement */
if (is_giant(mtmp->data)) if (is_giant(mtmp->data))
allowflags |= BUSTDOOR; allowflags |= BUSTDOOR;
if (tunnels(mtmp->data) 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; allowflags |= ALLOW_DIG;
cnt = mfndpos(mtmp, poss, info, allowflags); cnt = mfndpos(mtmp, poss, info, allowflags);
@@ -773,7 +770,7 @@ register int after; /* this is extra fast monster movement */
continue; continue;
if (after) if (after)
return (0); /* hit only once each move */ return 0; /* hit only once each move */
notonhead = 0; notonhead = 0;
mstatus = mattackm(mtmp, mtmp2); mstatus = mattackm(mtmp, mtmp2);
@@ -803,13 +800,14 @@ register int after; /* this is extra fast monster movement */
return 0; return 0;
} }
{ /* Dog avoids harmful traps, but perhaps it has to pass one {
* in order to follow player. (Non-harmful traps do not /* Dog avoids harmful traps, but perhaps it has to pass one
* have ALLOW_TRAPS in info[].) The dog only avoids the * in order to follow player. (Non-harmful traps do not
* trap if you've seen it, unlike enemies who avoid traps * have ALLOW_TRAPS in info[].) The dog only avoids the
* if they've seen some trap of that type sometime in the * trap if you've seen it, unlike enemies who avoid traps
* past. (Neither behavior is really realistic.) * if they've seen some trap of that type sometime in the
*/ * past. (Neither behavior is really realistic.)
*/
struct trap *trap; struct trap *trap;
if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) { if ((info[i] & ALLOW_TRAPS) && (trap = t_at(nx, ny))) {
@@ -883,7 +881,7 @@ newdogpos:
m_unleash(mtmp, FALSE); m_unleash(mtmp, FALSE);
} }
(void) mattacku(mtmp); (void) mattacku(mtmp);
return (0); return 0;
} }
if (!m_in_out_region(mtmp, nix, niy)) if (!m_in_out_region(mtmp, nix, niy))
return 1; return 1;
@@ -956,7 +954,7 @@ newdogpos:
newsym(cc.x, cc.y); newsym(cc.x, cc.y);
set_apparxy(mtmp); set_apparxy(mtmp);
} }
return (1); return 1;
} }
/* check if a monster could pick up objects from a location */ /* check if a monster could pick up objects from a location */
@@ -974,11 +972,10 @@ xchar nx, ny;
/* Hack to prevent a dog from being endlessly stuck near an object that /* 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 * 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 * checks to see if the squares in between are good. The checking could be
* little smarter; a full check would probably be useful in m_move() too. * 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 * Since the maximum food distance is 5, this should never be more than 5
* calls * calls deep.
* deep.
*/ */
STATIC_OVL boolean STATIC_OVL boolean
can_reach_location(mon, mx, my, fx, fy) can_reach_location(mon, mx, my, fx, fy)
+37 -37
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -91,7 +91,7 @@ const char *msg;
/* else impossible? */ /* else impossible? */
} }
return (revived); return revived;
} }
STATIC_OVL int STATIC_OVL int
@@ -141,7 +141,7 @@ moverock()
} }
if (revive_nasty(rx, ry, "You sense movement on the other side.")) if (revive_nasty(rx, ry, "You sense movement on the other side."))
return (-1); return -1;
if (mtmp && !noncorporeal(mtmp->data) if (mtmp && !noncorporeal(mtmp->data)
&& (!mtmp->mtrapped && (!mtmp->mtrapped
@@ -334,10 +334,10 @@ moverock()
sokoban_guilt(); sokoban_guilt();
break; break;
} else } else
return (-1); return -1;
} }
} }
return (0); return 0;
} }
/* /*
@@ -421,8 +421,8 @@ xchar x, y;
/* /*
* The location could still block because of * The location could still block because of
* 1. More than one boulder * 1. More than one boulder
* 2. Boulder stuck in a wall/stone/door. * 2. Boulder stuck in a wall/stone/door.
* *
* [perhaps use does_block() below (from vision.c)] * [perhaps use does_block() below (from vision.c)]
*/ */
@@ -594,16 +594,16 @@ register xchar x, y;
{ {
struct rm *lev = &levl[x][y]; struct rm *lev = &levl[x][y];
return (boolean)(!((IS_STWALL(lev->typ) || IS_TREE(lev->typ)) return (boolean) !((IS_STWALL(lev->typ) || IS_TREE(lev->typ))
&& (lev->wall_info & W_NONDIGGABLE))); && (lev->wall_info & W_NONDIGGABLE));
} }
boolean boolean
may_passwall(x, y) may_passwall(x, y)
register xchar x, y; register xchar x, y;
{ {
return (boolean)(!(IS_STWALL(levl[x][y].typ) return (boolean) !(IS_STWALL(levl[x][y].typ)
&& (levl[x][y].wall_info & W_NONPASSWALL))); && (levl[x][y].wall_info & W_NONPASSWALL));
} }
boolean boolean
@@ -611,11 +611,11 @@ bad_rock(mdat, x, y)
struct permonst *mdat; struct permonst *mdat;
register xchar x, y; register xchar x, y;
{ {
return ( return (boolean) ((Sokoban && sobj_at(BOULDER, x, y))
(boolean)((Sokoban && sobj_at(BOULDER, x, y)) || (IS_ROCK(levl[x][y].typ)
|| (IS_ROCK(levl[x][y].typ) && (!tunnels(mdat) || needspick(mdat)
&& (!tunnels(mdat) || needspick(mdat) || !may_dig(x, y)) || !may_dig(x, y))
&& !(passes_walls(mdat) && may_passwall(x, y))))); && !(passes_walls(mdat) && may_passwall(x, y))));
} }
/* caller has already decided that it's a tight diagonal; check whether a /* caller has already decided that it's a tight diagonal; check whether a
@@ -652,8 +652,8 @@ boolean
invocation_pos(x, y) invocation_pos(x, y)
xchar x, y; xchar x, y;
{ {
return ( return (boolean) (Invocation_lev(&u.uz)
(boolean)(Invocation_lev(&u.uz) && x == inv_pos.x && y == inv_pos.y)); && x == inv_pos.x && y == inv_pos.y);
} }
/* return TRUE if (dx,dy) is an OK place to move /* return TRUE if (dx,dy) is an OK place to move
@@ -1326,10 +1326,10 @@ domove()
u.ustuck = 0; u.ustuck = 0;
} else { } else {
/* If holder is asleep or paralyzed: /* If holder is asleep or paralyzed:
* 37.5% chance of getting away, * 37.5% chance of getting away,
* 12.5% chance of waking/releasing it; * 12.5% chance of waking/releasing it;
* otherwise: * otherwise:
* 7.5% chance of getting away. * 7.5% chance of getting away.
* [strength ought to be a factor] * [strength ought to be a factor]
* If holder is tame and there is no conflict, * If holder is tame and there is no conflict,
* guaranteed escape. * guaranteed escape.
@@ -1729,7 +1729,7 @@ overexertion()
fall_asleep(-10, FALSE); 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 void
@@ -2047,7 +2047,7 @@ register int typewanted;
switch (rno = levl[x][y].roomno) { switch (rno = levl[x][y].roomno) {
case NO_ROOM: case NO_ROOM:
return (ptr); return ptr;
case SHARED: case SHARED:
step = 2; step = 2;
break; break;
@@ -2057,7 +2057,7 @@ register int typewanted;
default: /* i.e. a regular room # */ default: /* i.e. a regular room # */
if (goodtype(rno)) if (goodtype(rno))
*(--ptr) = rno; *(--ptr) = rno;
return (ptr); return ptr;
} }
min_x = x - 1; min_x = x - 1;
@@ -2094,7 +2094,7 @@ register int typewanted;
&& goodtype(rno)) && goodtype(rno))
*(--ptr) = rno; *(--ptr) = rno;
} }
return (ptr); return ptr;
} }
/* is (x,y) in a town? */ /* is (x,y) in a town? */
@@ -2311,7 +2311,7 @@ dopickup()
} else } else
You("don't %s anything in here to pick up.", You("don't %s anything in here to pick up.",
Blind ? "feel" : "see"); Blind ? "feel" : "see");
return (1); return 1;
} else { } else {
int tmpcount = -count; int tmpcount = -count;
return loot_mon(u.ustuck, &tmpcount, (boolean *) 0); return loot_mon(u.ustuck, &tmpcount, (boolean *) 0);
@@ -2321,20 +2321,20 @@ dopickup()
if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data) if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data)
|| (Flying && !Breathless)) { || (Flying && !Breathless)) {
You("cannot dive into the water to pick things up."); You("cannot dive into the water to pick things up.");
return (0); return 0;
} else if (!Underwater) { } else if (!Underwater) {
You_cant("even see the bottom, let alone pick up %s.", something); You_cant("even see the bottom, let alone pick up %s.", something);
return (0); return 0;
} }
} }
if (is_lava(u.ux, u.uy)) { if (is_lava(u.ux, u.uy)) {
if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data) if (Wwalking || is_floater(youmonst.data) || is_clinger(youmonst.data)
|| (Flying && !Breathless)) { || (Flying && !Breathless)) {
You_cant("reach the bottom to pick things up."); You_cant("reach the bottom to pick things up.");
return (0); return 0;
} else if (!likes_lava(youmonst.data)) { } else if (!likes_lava(youmonst.data)) {
You("would burn to a crisp trying to pick things up."); You("would burn to a crisp trying to pick things up.");
return (0); return 0;
} }
} }
if (!OBJ_AT(u.ux, u.uy)) { if (!OBJ_AT(u.ux, u.uy)) {
@@ -2365,7 +2365,7 @@ dopickup()
return 0; return 0;
} }
return (pickup(-count)); return pickup(-count);
} }
/* stop running if we see something interesting */ /* stop running if we see something interesting */
@@ -2570,11 +2570,11 @@ monster_nearby()
&& (!mtmp->mpeaceful || Hallucination) && (!mtmp->mpeaceful || Hallucination)
&& (!is_hider(mtmp->data) || !mtmp->mundetected) && (!is_hider(mtmp->data) || !mtmp->mundetected)
&& !noattacks(mtmp->data) && mtmp->mcanmove && !noattacks(mtmp->data) && mtmp->mcanmove
&& !mtmp->msleeping && /* aplvax!jcn */ && !mtmp->msleeping /* aplvax!jcn */
!onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp)) && !onscary(u.ux, u.uy, mtmp) && canspotmon(mtmp))
return (1); return 1;
} }
return (0); return 0;
} }
void void
@@ -2711,7 +2711,7 @@ weight_cap()
if (carrcap < 0) if (carrcap < 0)
carrcap = 0; carrcap = 0;
} }
return ((int) carrcap); return (int) carrcap;
} }
static int wc; /* current weight_cap(); valid after call to inv_weight() */ static int wc; /* current weight_cap(); valid after call to inv_weight() */
@@ -2793,7 +2793,7 @@ boolean incl_gold;
ct++; ct++;
otmp = otmp->nobj; otmp = otmp->nobj;
} }
return (ct); return ct;
} }
/* Counts the money in an object chain. */ /* Counts the money in an object chain. */
+58 -44
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -37,7 +37,7 @@ boolean
picking_at(x, y) picking_at(x, y)
int 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 */ /* produce an occupation string appropriate for the current activity */
@@ -66,8 +66,9 @@ lock_action()
return xlock.box->otyp == CHEST ? actions[1] : actions[2]; return xlock.box->otyp == CHEST ? actions[1] : actions[2];
} }
STATIC_PTR /* try to open/close a lock */
int picklock(VOID_ARGS) /* try to open/close a lock */ STATIC_PTR int
picklock(VOID_ARGS)
{ {
if (xlock.box) { if (xlock.box) {
if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) { if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) {
@@ -97,7 +98,7 @@ int picklock(VOID_ARGS) /* try to open/close a lock */
} }
if (rn2(100) >= xlock.chance) if (rn2(100) >= xlock.chance)
return (1); /* still busy */ return 1; /* still busy */
You("succeed in %s.", lock_action()); You("succeed in %s.", lock_action());
if (xlock.door) { if (xlock.door) {
@@ -175,8 +176,9 @@ boolean destroyit;
} }
} }
STATIC_PTR /* try to force a locked chest */
int forcelock(VOID_ARGS) /* try to force a locked chest */ STATIC_PTR int
forcelock(VOID_ARGS)
{ {
if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy)) if ((xlock.box->ox != u.ux) || (xlock.box->oy != u.uy))
return ((xlock.usedtime = 0)); /* you or it moved */ return ((xlock.usedtime = 0)); /* you or it moved */
@@ -206,7 +208,7 @@ int forcelock(VOID_ARGS) /* try to force a locked chest */
wake_nearby(); /* due to hammering on the container */ wake_nearby(); /* due to hammering on the container */
if (rn2(100) >= xlock.chance) if (rn2(100) >= xlock.chance)
return (1); /* still busy */ return 1; /* still busy */
You("succeed in forcing the lock."); You("succeed in forcing the lock.");
breakchestlock(xlock.box, (boolean)(!xlock.picktyp && !rn2(3))); breakchestlock(xlock.box, (boolean)(!xlock.picktyp && !rn2(3)));
@@ -234,7 +236,7 @@ reset_pick()
/* player is applying a key, lock pick, or credit card */ /* player is applying a key, lock pick, or credit card */
int int
pick_lock(pick) pick_lock(pick)
register struct obj *pick; struct obj *pick;
{ {
int picktyp, c, ch; int picktyp, c, ch;
coord cc; coord cc;
@@ -261,6 +263,7 @@ register struct obj *pick;
return PICKLOCK_LEARNED_SOMETHING; return PICKLOCK_LEARNED_SOMETHING;
} else { } else {
const char *action = lock_action(); const char *action = lock_action();
You("resume your attempt at %s.", action); You("resume your attempt at %s.", action);
set_occupation(picklock, action, 0); set_occupation(picklock, action, 0);
return PICKLOCK_DID_SOMETHING; return PICKLOCK_DID_SOMETHING;
@@ -331,7 +334,7 @@ register struct obj *pick;
c = ynq(qbuf); c = ynq(qbuf);
if (c == 'q') if (c == 'q')
return (0); return 0;
if (c == 'n') if (c == 'n')
continue; continue;
@@ -425,7 +428,7 @@ register struct obj *pick;
c = yn(qbuf); c = yn(qbuf);
if (c == 'n') if (c == 'n')
return (0); return 0;
switch (picktyp) { switch (picktyp) {
case CREDIT_CARD: case CREDIT_CARD:
@@ -452,7 +455,9 @@ register struct obj *pick;
return PICKLOCK_DID_SOMETHING; 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 struct obj *otmp;
register int c, picktyp; register int c, picktyp;
@@ -462,18 +467,18 @@ int doforce() /* try to force a chest with your weapon */
You_cant("force anything from inside here."); You_cant("force anything from inside here.");
return 0; return 0;
} }
if (!uwep || /* proper type test */ if (!uwep /* proper type test */
((uwep->oclass == WEAPON_CLASS || is_weptool(uwep)) || ((uwep->oclass == WEAPON_CLASS || is_weptool(uwep))
? (objects[uwep->otyp].oc_skill < P_DAGGER ? (objects[uwep->otyp].oc_skill < P_DAGGER
|| objects[uwep->otyp].oc_skill == P_FLAIL || objects[uwep->otyp].oc_skill == P_FLAIL
|| objects[uwep->otyp].oc_skill > P_LANCE) || objects[uwep->otyp].oc_skill > P_LANCE)
: uwep->oclass != ROCK_CLASS)) { : uwep->oclass != ROCK_CLASS)) {
You_cant("force anything %s weapon.", You_cant("force anything %s weapon.",
!uwep ? "when not wielding a" !uwep ? "when not wielding a"
: (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep)) : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))
? "without a proper" ? "without a proper"
: "with that"); : "with that");
return (0); return 0;
} }
if (!can_reach_floor(TRUE)) { if (!can_reach_floor(TRUE)) {
cant_reach_floor(u.ux, u.uy, FALSE, TRUE); cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
@@ -484,7 +489,7 @@ int doforce() /* try to force a chest with your weapon */
if (xlock.usedtime && xlock.box && picktyp == xlock.picktyp) { if (xlock.usedtime && xlock.box && picktyp == xlock.picktyp) {
You("resume your attempt to force the lock."); You("resume your attempt to force the lock.");
set_occupation(forcelock, "forcing the lock", 0); 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. */ /* A lock is made only for the honest man, the thief will break it. */
@@ -503,7 +508,7 @@ int doforce() /* try to force a chest with your weapon */
c = ynq(qbuf); c = ynq(qbuf);
if (c == 'q') if (c == 'q')
return (0); return 0;
if (c == 'n') if (c == 'n')
continue; continue;
@@ -522,10 +527,12 @@ int doforce() /* try to force a chest with your weapon */
set_occupation(forcelock, "forcing the lock", 0); set_occupation(forcelock, "forcing the lock", 0);
else else
You("decide not to force the issue."); 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); return doopen_indir(0, 0);
} }
@@ -535,6 +542,7 @@ stumble_on_door_mimic(x, y)
int x, y; int x, y;
{ {
struct monst *mtmp; struct monst *mtmp;
if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp) if ((mtmp = m_at(x, y)) && is_door_mappear(mtmp)
&& !Protection_from_shape_changers) { && !Protection_from_shape_changers) {
stumble_onto_mimic(mtmp); stumble_onto_mimic(mtmp);
@@ -543,7 +551,9 @@ int x, y;
return FALSE; 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; int x, y;
{ {
coord cc; coord cc;
@@ -565,10 +575,10 @@ int x, y;
cc.x = x; cc.x = x;
cc.y = y; cc.y = y;
} else if (!get_adjacent_loc((char *) 0, (char *) 0, u.ux, u.uy, &cc)) } 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)) if ((cc.x == u.ux) && (cc.y == u.uy))
return (0); return 0;
if (stumble_on_door_mimic(cc.x, cc.y)) if (stumble_on_door_mimic(cc.x, cc.y))
return 1; return 1;
@@ -647,11 +657,10 @@ int x, y;
pline_The("door resists!"); pline_The("door resists!");
} }
return (1); return 1;
} }
STATIC_OVL STATIC_OVL boolean
boolean
obstructed(x, y, quietly) obstructed(x, y, quietly)
register int x, y; register int x, y;
boolean quietly; boolean quietly;
@@ -674,22 +683,23 @@ boolean quietly;
} }
if (!canspotmon(mtmp)) if (!canspotmon(mtmp))
map_invisible(x, y); map_invisible(x, y);
return (TRUE); return TRUE;
} }
if (OBJ_AT(x, y)) { if (OBJ_AT(x, y)) {
objhere: objhere:
if (!quietly) if (!quietly)
pline("%s's in the way.", Something); 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 int x, y;
register struct rm *door; register struct rm *door;
struct monst *mtmp;
boolean portcullis; boolean portcullis;
int res = 0; int res = 0;
@@ -704,20 +714,20 @@ int doclose() /* try to close a door */
} }
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
x = u.ux + u.dx; x = u.ux + u.dx;
y = u.uy + u.dy; y = u.uy + u.dy;
if ((x == u.ux) && (y == u.uy)) { if ((x == u.ux) && (y == u.uy)) {
You("are in the way!"); You("are in the way!");
return (1); return 1;
} }
if (!isok(x, y)) if (!isok(x, y))
goto nodoor; goto nodoor;
if (stumble_on_door_mimic(x, y)) if (stumble_on_door_mimic(x, y))
return (1); return 1;
/* when choosing a direction is impaired, use a turn /* when choosing a direction is impaired, use a turn
regardless of whether a door is successfully targetted */ regardless of whether a door is successfully targetted */
@@ -781,14 +791,16 @@ int doclose() /* try to close a door */
} }
} }
return (1); return 1;
} }
boolean /* box obj was hit with spell effect otmp */ /* box obj was hit with spell or wand effect otmp;
boxlock(obj, otmp) /* returns true if something happened */ returns true if something happened */
register struct obj *obj, *otmp; /* obj *is* a box */ boolean
boxlock(obj, otmp)
struct obj *obj, *otmp; /* obj *is* a box */
{ {
register boolean res = 0; boolean res = 0;
switch (otmp->otyp) { switch (otmp->otyp) {
case WAN_LOCKING: case WAN_LOCKING:
@@ -828,8 +840,10 @@ register struct obj *obj, *otmp; /* obj *is* a box */
return res; return res;
} }
boolean /* Door/secret door was hit with spell effect otmp */ /* Door/secret door was hit with spell or wand effect otmp;
doorlock(otmp, x, y) /* returns true if something happened */ returns true if something happened */
boolean
doorlock(otmp, x, y)
struct obj *otmp; struct obj *otmp;
int x, y; int x, y;
{ {
+70 -69
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -15,23 +15,23 @@ static const char brief_feeling[] =
"have a %s feeling for a moment, then it passes."; "have a %s feeling for a moment, then it passes.";
STATIC_DCL char *FDECL(mon_nam_too, (char *, struct monst *, struct monst *)); STATIC_DCL char *FDECL(mon_nam_too, (char *, struct monst *, struct monst *));
STATIC_DCL int FDECL(hitmm, STATIC_DCL int FDECL(hitmm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL int FDECL(gazemm, STATIC_DCL int FDECL(gazemm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL int FDECL(gulpmm, STATIC_DCL int FDECL(gulpmm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL int FDECL(explmm, STATIC_DCL int FDECL(explmm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL int FDECL(mdamagem, STATIC_DCL int FDECL(mdamagem, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL void FDECL(mswingsm, STATIC_DCL void FDECL(mswingsm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct obj *)); struct obj *));
STATIC_DCL void FDECL(noises, (struct monst *, struct attack *)); STATIC_DCL void FDECL(noises, (struct monst *, struct attack *));
STATIC_DCL void FDECL(missmm, STATIC_DCL void FDECL(missmm, (struct monst *, struct monst *,
(struct monst *, struct monst *, struct attack *)); struct attack *));
STATIC_DCL int FDECL(passivemm, STATIC_DCL int FDECL(passivemm, (struct monst *, struct monst *,
(struct monst *, struct monst *, BOOLEAN_P, int)); BOOLEAN_P, int));
/* Needed for the special case of monsters wielding vorpal blades (rare). /* 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() * If we use this a lot it should probably be a parameter to mdamagem()
@@ -109,8 +109,8 @@ struct attack *mattk;
* fightm() -- fight some other monster * fightm() -- fight some other monster
* *
* Returns: * Returns:
* 0 - Monster did nothing. * 0 - Monster did nothing.
* 1 - If the monster made an attack. The monster might have died. * 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, * 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 * then we report that the monster did nothing so it will continue to
@@ -126,12 +126,12 @@ register struct monst *mtmp;
#endif #endif
/* perhaps the monster will resist Conflict */ /* perhaps the monster will resist Conflict */
if (resist(mtmp, RING_CLASS, 0, 0)) if (resist(mtmp, RING_CLASS, 0, 0))
return (0); return 0;
if (u.ustuck == mtmp) { if (u.ustuck == mtmp) {
/* perhaps we're holding it... */ /* perhaps we're holding it... */
if (itsstuck(mtmp)) if (itsstuck(mtmp))
return (0); return 0;
} }
has_u_swallowed = (u.uswallow && (mtmp == u.ustuck)); has_u_swallowed = (u.uswallow && (mtmp == u.ustuck));
@@ -162,10 +162,10 @@ register struct monst *mtmp;
if (result & MM_AGR_DIED) if (result & MM_AGR_DIED)
return 1; /* mtmp died */ return 1; /* mtmp died */
/* /*
* If mtmp has the hero swallowed, lie and say there * If mtmp has the hero swallowed, lie and say there
* was no attack (this allows mtmp to digest the hero). * was no attack (this allows mtmp to digest the hero).
*/ */
if (has_u_swallowed) if (has_u_swallowed)
return 0; return 0;
@@ -179,7 +179,7 @@ register struct monst *mtmp;
(void) mattackm(mon, mtmp); /* return attack */ (void) mattackm(mon, mtmp); /* return attack */
} }
return ((result & MM_HIT) ? 1 : 0); return (result & MM_HIT) ? 1 : 0;
} }
} }
} }
@@ -188,7 +188,7 @@ register struct monst *mtmp;
/* /*
* mdisplacem() -- attacker moves defender out of the way; * mdisplacem() -- attacker moves defender out of the way;
* returns same results as mattackm(). * returns same results as mattackm().
*/ */
int int
mdisplacem(magr, mdef, quietly) mdisplacem(magr, mdef, quietly)
@@ -211,12 +211,12 @@ boolean quietly;
* for pet displacement. * for pet displacement.
*/ */
if (!rn2(7)) if (!rn2(7))
return (MM_MISS); return MM_MISS;
/* Grid bugs cannot displace at an angle. */ /* Grid bugs cannot displace at an angle. */
if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
&& magr->my != mdef->my) && magr->my != mdef->my)
return (MM_MISS); return MM_MISS;
/* undetected monster becomes un-hidden if it is displaced */ /* undetected monster becomes un-hidden if it is displaced */
if (mdef->mundetected) if (mdef->mundetected)
@@ -269,19 +269,18 @@ boolean quietly;
/* /*
* mattackm() -- a monster attacks another monster. * mattackm() -- a monster attacks another monster.
* *
* --------- aggressor died * --------- aggressor died
* / ------- defender died * / ------- defender died
* / / ----- defender was hit * / / ----- defender was hit
* / / / * / / /
* x x x * x x x
* *
* 0x4 MM_AGR_DIED * 0x4 MM_AGR_DIED
* 0x2 MM_DEF_DIED * 0x2 MM_DEF_DIED
* 0x1 MM_HIT * 0x1 MM_HIT
* 0x0 MM_MISS * 0x0 MM_MISS
* *
* Each successive attack has a lower probability of hitting. Some rely on * 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 ** * success of previous attacks. ** this doen't seem to be implemented -dl **
* *
* In the case of exploding monsters, the monster dies as well. * In the case of exploding monsters, the monster dies as well.
@@ -300,16 +299,16 @@ register struct monst *magr, *mdef;
struct permonst *pa, *pd; struct permonst *pa, *pd;
if (!magr || !mdef) if (!magr || !mdef)
return (MM_MISS); /* mike@genat */ return MM_MISS; /* mike@genat */
if (!magr->mcanmove || magr->msleeping) if (!magr->mcanmove || magr->msleeping)
return (MM_MISS); return MM_MISS;
pa = magr->data; pa = magr->data;
pd = mdef->data; pd = mdef->data;
/* Grid bugs cannot attack at an angle. */ /* Grid bugs cannot attack at an angle. */
if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx if (pa == &mons[PM_GRID_BUG] && magr->mx != mdef->mx
&& magr->my != mdef->my) && magr->my != mdef->my)
return (MM_MISS); return MM_MISS;
/* Calculate the armour class differential. */ /* Calculate the armour class differential. */
tmp = find_mac(mdef) + magr->m_lev; tmp = find_mac(mdef) + magr->m_lev;
@@ -340,10 +339,10 @@ register struct monst *magr, *mdef;
vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my) vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)
&& (canspotmon(magr) || canspotmon(mdef))); && (canspotmon(magr) || canspotmon(mdef)));
/* Set flag indicating monster has moved this turn. Necessary since a /* 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 * 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 * some cases, in which case this still counts as its move for the round
* and it shouldn't move again. * and it shouldn't move again.
*/ */
magr->mlstmv = monstermoves; magr->mlstmv = monstermoves;
@@ -368,7 +367,7 @@ register struct monst *magr, *mdef;
mswingsm(magr, mdef, otmp); mswingsm(magr, mdef, otmp);
tmp += hitval(otmp, mdef); tmp += hitval(otmp, mdef);
} }
/* fall through */ /*FALLTHRU*/
case AT_CLAW: case AT_CLAW:
case AT_KICK: case AT_KICK:
case AT_BITE: case AT_BITE:
@@ -532,7 +531,8 @@ struct attack *mattk;
} }
} else } else
noises(magr, mattk); noises(magr, mattk);
return (mdamagem(magr, mdef, mattk));
return mdamagem(magr, mdef, mattk);
} }
/* Returns the same values as mdamagem(). */ /* Returns the same values as mdamagem(). */
@@ -553,7 +553,7 @@ struct attack *mattk;
|| mdef->msleeping) { || mdef->msleeping) {
if (vis) if (vis)
pline("but nothing happens."); pline("but nothing happens.");
return (MM_MISS); return MM_MISS;
} }
/* call mon_reflects 2x, first test, then, if visible, print message */ /* call mon_reflects 2x, first test, then, if visible, print message */
if (magr->data == &mons[PM_MEDUSA] && mon_reflects(mdef, (char *) 0)) { if (magr->data == &mons[PM_MEDUSA] && mon_reflects(mdef, (char *) 0)) {
@@ -564,7 +564,7 @@ struct attack *mattk;
if (canseemon(magr)) if (canseemon(magr))
(void) mon_reflects( (void) mon_reflects(
magr, "The gaze is reflected away by %s %s."); magr, "The gaze is reflected away by %s %s.");
return (MM_MISS); return MM_MISS;
} }
if (mdef->minvis && !perceives(magr->data)) { if (mdef->minvis && !perceives(magr->data)) {
if (canseemon(magr)) { if (canseemon(magr)) {
@@ -572,18 +572,18 @@ struct attack *mattk;
"reflected.", "reflected.",
Monnam(magr), mhis(magr)); Monnam(magr), mhis(magr));
} }
return (MM_MISS); return MM_MISS;
} }
if (canseemon(magr)) if (canseemon(magr))
pline("%s is turned to stone!", Monnam(magr)); pline("%s is turned to stone!", Monnam(magr));
monstone(magr); monstone(magr);
if (magr->mhp > 0) if (magr->mhp > 0)
return (MM_MISS); return MM_MISS;
return (MM_AGR_DIED); 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 */ /* return True if magr is allowed to swallow mdef, False otherwise */
@@ -663,11 +663,11 @@ register struct attack *mattk;
== (MM_AGR_DIED | MM_DEF_DIED)) { == (MM_AGR_DIED | MM_DEF_DIED)) {
; /* both died -- do nothing */ ; /* both died -- do nothing */
} else if (status & MM_DEF_DIED) { /* defender died */ } else if (status & MM_DEF_DIED) { /* defender died */
/* /*
* Note: remove_monster() was called in relmon(), wiping out * Note: remove_monster() was called in relmon(), wiping out
* magr from level.monsters[mdef->mx][mdef->my]. We need to * magr from level.monsters[mdef->mx][mdef->my]. We need to
* put it back and display it. -kd * put it back and display it. -kd
*/ */
place_monster(magr, dx, dy); place_monster(magr, dx, dy);
newsym(dx, dy); newsym(dx, dy);
/* aggressor moves to <dx,dy> and might encounter trouble there */ /* aggressor moves to <dx,dy> and might encounter trouble there */
@@ -691,8 +691,8 @@ register struct attack *mattk;
STATIC_OVL int STATIC_OVL int
explmm(magr, mdef, mattk) explmm(magr, mdef, mattk)
register struct monst *magr, *mdef; struct monst *magr, *mdef;
register struct attack *mattk; struct attack *mattk;
{ {
int result; int result;
@@ -734,8 +734,8 @@ register struct attack *mattk;
res = MM_MISS; res = MM_MISS;
boolean cancelled; boolean cancelled;
if ((touch_petrifies(pd) || /* or flesh_petrifies() */ if ((touch_petrifies(pd) /* or flesh_petrifies() */
(mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA])) || (mattk->adtyp == AD_DGST && pd == &mons[PM_MEDUSA]))
&& !resists_ston(magr)) { && !resists_ston(magr)) {
long protector = attk_protection((int) mattk->aatyp), long protector = attk_protection((int) mattk->aatyp),
wornitems = magr->misc_worn_check; wornitems = magr->misc_worn_check;
@@ -771,9 +771,9 @@ register struct attack *mattk;
if (is_rider(pd)) { if (is_rider(pd)) {
if (vis) if (vis)
pline("%s %s!", Monnam(magr), pline("%s %s!", Monnam(magr),
pd == &mons[PM_FAMINE] (pd == &mons[PM_FAMINE])
? "belches feebly, shrivels up and dies" ? "belches feebly, shrivels up and dies"
: pd == &mons[PM_PESTILENCE] : (pd == &mons[PM_PESTILENCE])
? "coughs spasmodically and collapses" ? "coughs spasmodically and collapses"
: "vomits violently and drops dead"); : "vomits violently and drops dead");
mondied(magr); mondied(magr);
@@ -1377,8 +1377,8 @@ struct monst *mon;
void void
rustm(mdef, obj) rustm(mdef, obj)
register struct monst *mdef; struct monst *mdef;
register struct obj *obj; struct obj *obj;
{ {
int dmgtyp; int dmgtyp;
@@ -1571,8 +1571,9 @@ xdrainenergym(mon, givemsg)
struct monst *mon; struct monst *mon;
boolean givemsg; boolean givemsg;
{ {
if (mon->mspec_used < 20 && /* limit draining */ if (mon->mspec_used < 20 /* limit draining */
(attacktype(mon->data, AT_MAGC) || attacktype(mon->data, AT_BREA))) { && (attacktype(mon->data, AT_MAGC)
|| attacktype(mon->data, AT_BREA))) {
mon->mspec_used += d(2, 2); mon->mspec_used += d(2, 2);
if (givemsg) if (givemsg)
pline("%s seems lethargic.", Monnam(mon)); pline("%s seems lethargic.", Monnam(mon));
+59 -54
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -33,8 +33,8 @@ int x, y;
if (!isok(x, y)) if (!isok(x, y))
return FALSE; return FALSE;
type = levl[x][y].typ; type = levl[x][y].typ;
return (IS_WALL(type) || IS_DOOR(type) || type == SDOOR return (boolean) (IS_WALL(type) || IS_DOOR(type)
|| type == IRONBARS); || type == SDOOR || type == IRONBARS);
} }
STATIC_OVL boolean STATIC_OVL boolean
@@ -48,8 +48,9 @@ int x, y;
return TRUE; return TRUE;
type = levl[x][y].typ; type = levl[x][y].typ;
return (type == STONE || IS_WALL(type) || IS_DOOR(type) || type == SDOOR return (boolean) (type == STONE
|| type == IRONBARS); || IS_WALL(type) || IS_DOOR(type)
|| type == SDOOR || type == IRONBARS);
} }
/* return TRUE if out of bounds, wall or rock */ /* return TRUE if out of bounds, wall or rock */
@@ -57,7 +58,7 @@ STATIC_OVL boolean
is_solid(x, y) is_solid(x, y)
int 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));
} }
/* /*
@@ -70,13 +71,13 @@ int x, y;
* a wall, '.' a room, 'a' anything (we don't care), and our direction is * a wall, '.' a room, 'a' anything (we don't care), and our direction is
* (0,1) - South or down - then: * (0,1) - South or down - then:
* *
* a a a * a a a
* W x W This would not extend a spine from x down * W x W This would not extend a spine from x down
* W W W (a corridor of walls is formed). * W W W (a corridor of walls is formed).
* *
* a a a * a a a
* W x W This would extend a spine from x down. * W x W This would extend a spine from x down.
* . W W * . W W
*/ */
STATIC_OVL int STATIC_OVL int
extend_spine(locale, wall_there, dx, dy) extend_spine(locale, wall_there, dx, dy)
@@ -90,15 +91,15 @@ int wall_there, dx, dy;
if (wall_there) { /* wall in that direction */ if (wall_there) { /* wall in that direction */
if (dx) { if (dx) {
if (locale[1][0] && locale[1][2] && /* EW are wall/stone */ if (locale[1][0] && locale[1][2] /* EW are wall/stone */
locale[nx][0] && locale[nx][2]) { /* diag are wall/stone */ && locale[nx][0] && locale[nx][2]) { /* diag are wall/stone */
spine = 0; spine = 0;
} else { } else {
spine = 1; spine = 1;
} }
} else { /* dy */ } else { /* dy */
if (locale[0][1] && locale[2][1] && /* NS are wall/stone */ if (locale[0][1] && locale[2][1] /* NS are wall/stone */
locale[0][ny] && locale[2][ny]) { /* diag are wall/stone */ && locale[0][ny] && locale[2][ny]) { /* diag are wall/stone */
spine = 0; spine = 0;
} else { } else {
spine = 1; spine = 1;
@@ -125,11 +126,11 @@ int x1, y1, x2, y2;
struct rm *lev; struct rm *lev;
int bits; int bits;
int locale[3][3]; /* rock or wall status surrounding positions */ int locale[3][3]; /* rock or wall status surrounding positions */
/* /*
* Value 0 represents a free-standing wall. It could be anything, * Value 0 represents a free-standing wall. It could be anything,
* so even though this table says VWALL, we actually leave whatever * so even though this table says VWALL, we actually leave whatever
* typ was there alone. * typ was there alone.
*/ */
static xchar spine_array[16] = { VWALL, HWALL, HWALL, HWALL, static xchar spine_array[16] = { VWALL, HWALL, HWALL, HWALL,
VWALL, TRCORNER, TLCORNER, TDWALL, VWALL, TRCORNER, TLCORNER, TDWALL,
VWALL, BRCORNER, BLCORNER, TUWALL, VWALL, BRCORNER, BLCORNER, TUWALL,
@@ -198,12 +199,13 @@ register int dir;
move(&x, &y, dir); move(&x, &y, dir);
if (x < 3 || y < 3 || x > x_maze_max || y > y_maze_max if (x < 3 || y < 3 || x > x_maze_max || y > y_maze_max
|| levl[x][y].typ != 0) || levl[x][y].typ != 0)
return (FALSE); return FALSE;
return (TRUE); return TRUE;
} }
/* find random starting point for maze generation */
STATIC_OVL void STATIC_OVL void
maze0xy(cc) /* find random starting point for maze generation */ maze0xy(cc)
coord *cc; coord *cc;
{ {
cc->x = 3 + 2 * rn2((x_maze_max >> 1) - 1); cc->x = 3 + 2 * rn2((x_maze_max >> 1) - 1);
@@ -213,23 +215,24 @@ coord *cc;
/* /*
* Bad if: * Bad if:
* pos is occupied OR * pos is occupied OR
* pos is inside restricted region (lx,ly,hx,hy) 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) * NOT (pos is corridor and a maze level OR pos is a room OR pos is air)
*/ */
boolean boolean
bad_location(x, y, lx, ly, hx, hy) bad_location(x, y, lx, ly, hx, hy)
xchar x, y; xchar x, y;
xchar lx, ly, hx, hy; xchar lx, ly, hx, hy;
{ {
return ( return (boolean) (occupied(x, y)
(boolean)(occupied(x, y) || within_bounded_area(x, y, lx, ly, hx, hy) || within_bounded_area(x, y, lx, ly, hx, hy)
|| !((levl[x][y].typ == CORR && level.flags.is_maze_lev) || !((levl[x][y].typ == CORR && level.flags.is_maze_lev)
|| levl[x][y].typ == ROOM || levl[x][y].typ == AIR))); || 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) */ /* 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 */ and place something (based on rtype) in that region */
void void
place_lregion(lx, ly, hx, hy, nlx, nly, nhx, nhy, rtype, lev) place_lregion(lx, ly, hx, hy, nlx, nly, nhx, nhy, rtype, lev)
xchar lx, ly, hx, hy; xchar lx, ly, hx, hy;
@@ -242,10 +245,10 @@ d_level *lev;
xchar x, y; xchar x, y;
if (!lx) { /* default to whole level */ if (!lx) { /* default to whole level */
/* /*
* if there are rooms and this a branch, let place_branch choose * if there are rooms and this a branch, let place_branch choose
* the branch location (to avoid putting branches in corridors). * the branch location (to avoid putting branches in corridors).
*/ */
if (rtype == LR_BRANCH && nroom) { if (rtype == LR_BRANCH && nroom) {
place_branch(Is_branchlev(&u.uz), 0, 0); place_branch(Is_branchlev(&u.uz), 0, 0);
return; return;
@@ -312,7 +315,7 @@ d_level *lev;
if (oneshot) if (oneshot)
(void) rloc(m_at(x, y), FALSE); (void) rloc(m_at(x, y), FALSE);
else else
return (FALSE); return FALSE;
} }
u_on_newpos(x, y); u_on_newpos(x, y);
break; break;
@@ -327,7 +330,7 @@ d_level *lev;
place_branch(Is_branchlev(&u.uz), x, y); place_branch(Is_branchlev(&u.uz), x, y);
break; break;
} }
return (TRUE); return TRUE;
} }
static boolean was_waterlevel; /* ugh... this shouldn't be needed */ static boolean was_waterlevel; /* ugh... this shouldn't be needed */
@@ -611,8 +614,8 @@ register const char *s;
y = rn1(y_range, y_maze_min + INVPOS_Y_MARGIN + 1); y = rn1(y_range, y_maze_min + INVPOS_Y_MARGIN + 1);
/* we don't want it to be too near the stairs, nor /* we don't want it to be too near the stairs, nor
to be on a spot that's already in use (wall|trap) */ to be on a spot that's already in use (wall|trap) */
} while (x == xupstair || y == yupstair || /*(direct line)*/ } while (x == xupstair || y == yupstair /*(direct line)*/
abs(x - xupstair) == abs(y - yupstair) || abs(x - xupstair) == abs(y - yupstair)
|| distmin(x, y, xupstair, yupstair) <= INVPOS_DISTANCE || distmin(x, y, xupstair, yupstair) <= INVPOS_DISTANCE
|| !SPACE_POS(levl[x][y].typ) || occupied(x, y)); || !SPACE_POS(levl[x][y].typ) || occupied(x, y));
inv_pos.x = x; inv_pos.x = x;
@@ -767,8 +770,10 @@ register int dir;
} }
} }
void mazexy(cc) /* find random point in generated corridors, /* find random point in generated corridors,
so we don't create items in moats, bunkers, or walls */ so we don't create items in moats, bunkers, or walls */
void
mazexy(cc)
coord *cc; coord *cc;
{ {
int cpt = 0; int cpt = 0;
@@ -796,8 +801,6 @@ coord *cc;
return; return;
} }
void
bound_digging()
/* put a non-diggable boundary around the initial portion of a level map. /* 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. * assumes that no level will initially put things beyond the isok() range.
* *
@@ -808,6 +811,8 @@ bound_digging()
* we can't bound unconditionally on one beyond the last line, because * we can't bound unconditionally on one beyond the last line, because
* that provides a window of abuse for wallified special levels * that provides a window of abuse for wallified special levels
*/ */
void
bound_digging()
{ {
register int x, y; register int x, y;
register unsigned typ; register unsigned typ;
@@ -892,11 +897,11 @@ bound_digging()
void void
mkportal(x, y, todnum, todlevel) mkportal(x, y, todnum, todlevel)
register xchar x, y, todnum, todlevel; xchar x, y, todnum, todlevel;
{ {
/* a portal "trap" must be matched by a */ /* a portal "trap" must be matched by a
/* portal in the destination dungeon/dlevel */ portal in the destination dungeon/dlevel */
register struct trap *ttmp = maketrap(x, y, MAGIC_PORTAL); struct trap *ttmp = maketrap(x, y, MAGIC_PORTAL);
if (!ttmp) { if (!ttmp) {
impossible("portal on top of portal??"); impossible("portal on top of portal??");
@@ -914,6 +919,7 @@ fumaroles()
{ {
xchar n; xchar n;
boolean snd = FALSE, loud = FALSE; boolean snd = FALSE, loud = FALSE;
for (n = rn2(3) + 2; n; n--) { for (n = rn2(3) + 2; n; n--) {
xchar x = rn1(COLNO - 4, 3); xchar x = rn1(COLNO - 4, 3);
xchar y = rn1(ROWNO - 4, 3); xchar y = rn1(ROWNO - 4, 3);
@@ -936,8 +942,10 @@ fumaroles()
* other source files, but they are all so nicely encapsulated here. * other source files, but they are all so nicely encapsulated here.
*/ */
#ifdef DEBUG
/* to ease the work of debuggers at this stage */ /* to ease the work of debuggers at this stage */
#define register #define register
#endif
#define CONS_OBJ 0 #define CONS_OBJ 0
#define CONS_MON 1 #define CONS_MON 1
@@ -985,7 +993,6 @@ movebubbles()
* Pick up everything inside of a bubble then fill all bubble * Pick up everything inside of a bubble then fill all bubble
* locations. * locations.
*/ */
for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) { for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) {
if (b->cons) if (b->cons)
panic("movebubbles: cons != null"); panic("movebubbles: cons != null");
@@ -1084,7 +1091,6 @@ movebubbles()
* all the junk that changes owners when bubbles overlap * all the junk that changes owners when bubbles overlap
* would eventually end up in the last bubble in the chain. * would eventually end up in the last bubble in the chain.
*/ */
up = !up; up = !up;
for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) { for (b = up ? bbubbles : ebubbles; b; b = up ? b->next : b->prev) {
register int rx = rn2(3), ry = rn2(3); register int rx = rn2(3), ry = rn2(3);
@@ -1302,7 +1308,6 @@ register int x, y, n;
bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e }, bm7[] = { 7, 4, 0x3e, 0x7f, 0x7f, 0x3e },
bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e }, bm8[] = { 8, 4, 0x7e, 0xff, 0xff, 0x7e },
*bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 }; *bmask[] = { bm2, bm3, bm4, bm5, bm6, bm7, bm8 };
register struct bubble *b; register struct bubble *b;
if (x >= bxmax || y >= bymax) if (x >= bxmax || y >= bymax)
@@ -1367,7 +1372,7 @@ register boolean ini;
/* /*
* collision with level borders? * collision with level borders?
* 1 = horizontal border, 2 = vertical, 3 = corner * 1 = horizontal border, 2 = vertical, 3 = corner
*/ */
if (b->x <= bxmin) if (b->x <= bxmin)
colli |= 2; colli |= 2;
+12 -12
View File
@@ -1,10 +1,10 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
#include "hack.h" #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) */ /* set up an individual monster's base type (initial creation, shapechange) */
void void
@@ -116,8 +116,8 @@ struct monst *mon;
/* check for magic resistance granted by worn or carried items */ /* check for magic resistance granted by worn or carried items */
o = is_you ? invent : mon->minvent; o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY; slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */ if (!is_you /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP; slotmask |= W_WEP;
if (is_you && u.twoweap) if (is_you && u.twoweap)
slotmask |= W_SWAPWEP; slotmask |= W_SWAPWEP;
@@ -154,8 +154,8 @@ struct monst *mon;
return TRUE; return TRUE;
o = is_you ? invent : mon->minvent; o = is_you ? invent : mon->minvent;
slotmask = W_ARMOR | W_ACCESSORY; slotmask = W_ARMOR | W_ACCESSORY;
if (!is_you || /* assumes monsters don't wield non-weapons */ if (!is_you /* assumes monsters don't wield non-weapons */
(uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))) || (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep))))
slotmask |= W_WEP; slotmask |= W_WEP;
if (is_you && u.twoweap) if (is_you && u.twoweap)
slotmask |= W_SWAPWEP; slotmask |= W_SWAPWEP;
@@ -937,7 +937,7 @@ static const short grownups[][2] = {
{ PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON }, { PM_BABY_GRAY_DRAGON, PM_GRAY_DRAGON },
{ PM_BABY_SILVER_DRAGON, PM_SILVER_DRAGON }, { PM_BABY_SILVER_DRAGON, PM_SILVER_DRAGON },
#if 0 /* DEFERRED */ #if 0 /* DEFERRED */
{PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON}, {PM_BABY_SHIMMERING_DRAGON, PM_SHIMMERING_DRAGON},
#endif #endif
{ PM_BABY_RED_DRAGON, PM_RED_DRAGON }, { PM_BABY_RED_DRAGON, PM_RED_DRAGON },
{ PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON }, { PM_BABY_WHITE_DRAGON, PM_WHITE_DRAGON },
@@ -1099,12 +1099,12 @@ struct attack *mattk;
/* /*
* Returns: * Returns:
* True if monster is presumed to 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. * False if monster definitely does not have a sense of smell.
* *
* Do not base this on presence of a head or nose, since many * Do not base this on presence of a head or nose, since many
* creatures sense smells other ways (feelers, forked-tongues, etc.) * creatures sense smells other ways (feelers, forked-tongues, etc.)
* We're assuming all insects can smell at a distance too. * We're assuming all insects can smell at a distance too.
*/ */
boolean boolean
olfaction(mdat) olfaction(mdat)
+45 -45
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -16,9 +16,10 @@ STATIC_DCL int FDECL(m_arrival, (struct monst *));
STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *)); STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *));
STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *)); STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *));
boolean /* TRUE : mtmp died */ /* True if mtmp died */
mb_trapped(mtmp) boolean
register struct monst *mtmp; mb_trapped(mtmp)
struct monst *mtmp;
{ {
if (flags.verbose) { if (flags.verbose) {
if (cansee(mtmp->mx, mtmp->my) && !Unaware) if (cansee(mtmp->mx, mtmp->my) && !Unaware)
@@ -68,8 +69,8 @@ register struct monst *mtmp;
{ {
int x, y; int x, y;
if (mtmp->mpeaceful && in_town(u.ux + u.dx, u.uy + u.dy) && mtmp->mcansee if (mtmp->mpeaceful && in_town(u.ux + u.dx, u.uy + u.dy)
&& m_canseeu(mtmp) && !rn2(3)) { && mtmp->mcansee && m_canseeu(mtmp) && !rn2(3)) {
if (picking_lock(&x, &y) && IS_DOOR(levl[x][y].typ) if (picking_lock(&x, &y) && IS_DOOR(levl[x][y].typ)
&& (levl[x][y].doormask & D_LOCKED)) { && (levl[x][y].doormask & D_LOCKED)) {
if (couldsee(mtmp->mx, mtmp->my)) { if (couldsee(mtmp->mx, mtmp->my)) {
@@ -94,7 +95,7 @@ int
dochugw(mtmp) dochugw(mtmp)
register struct monst *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); boolean already_saw_mon = !occupation ? 0 : canspotmon(mtmp);
int rd = dochug(mtmp); int rd = dochug(mtmp);
@@ -102,13 +103,12 @@ register struct monst *mtmp;
/* check whether hero notices monster and stops current activity */ /* check whether hero notices monster and stops current activity */
if (occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination) if (occupation && !rd && !Confusion && (!mtmp->mpeaceful || Hallucination)
/* it's close enough to be a threat */ /* 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 */ /* and either couldn't see it before, or it was too far away */
&& (!already_saw_mon || !couldsee(x, y) && (!already_saw_mon || !couldsee(x, y)
|| distu(x, y) > (BOLT_LIM + 1) * (BOLT_LIM + 1)) || distu(x, y) > (BOLT_LIM + 1) * (BOLT_LIM + 1))
/* can see it now, or sense it and would normally see it */ /* can see it now, or sense it and would normally see it */
&& (canseemon(mtmp) && (canseemon(mtmp) || (sensemon(mtmp) && couldsee(x, y)))
|| (sensemon(mtmp) && couldsee(mtmp->mx, mtmp->my)))
&& mtmp->mcanmove && !noattacks(mtmp->data) && mtmp->mcanmove && !noattacks(mtmp->data)
&& !onscary(u.ux, u.uy, mtmp)) && !onscary(u.ux, u.uy, mtmp))
stop_occupation(); stop_occupation();
@@ -190,12 +190,12 @@ register struct monst *mtmp;
* + Nymphs, jabberwocks, and leprechauns do not easily wake up. * + Nymphs, jabberwocks, and leprechauns do not easily wake up.
* *
* Wake up if: * Wake up if:
* in direct LOS AND * in direct LOS AND
* within 10 squares AND * within 10 squares AND
* not stealthy or (mon is an ettin and 9/10) AND * not stealthy or (mon is an ettin and 9/10) AND
* (mon is not a nymph, jabberwock, or leprechaun) or 1/50 AND * (mon is not a nymph, jabberwock, or leprechaun) or 1/50 AND
* Aggravate or mon is (dog or human) or * Aggravate or mon is (dog or human) or
* (1/7 and mon is not mimicing furniture or object) * (1/7 and mon is not mimicing furniture or object)
*/ */
if (couldsee(mtmp->mx, mtmp->my) && distu(mtmp->mx, mtmp->my) <= 100 if (couldsee(mtmp->mx, mtmp->my) && distu(mtmp->mx, mtmp->my) <= 100
&& (!Stealth || (mtmp->data == &mons[PM_ETTIN] && rn2(10))) && (!Stealth || (mtmp->data == &mons[PM_ETTIN] && rn2(10)))
@@ -338,7 +338,8 @@ register struct monst *mtmp;
register int tmp = 0; register int tmp = 0;
int inrange, nearby, scared; int inrange, nearby, scared;
/* Pre-movement adjustments */ /* Pre-movement adjustments
*/
mdat = mtmp->data; mdat = mtmp->data;
@@ -453,10 +454,10 @@ register struct monst *mtmp;
} }
/* the watch will look around and see if you are up to no good :-) */ /* 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); 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; struct monst *m2, *nmon = (struct monst *) 0;
if (canseemon(mtmp)) if (canseemon(mtmp))
@@ -532,7 +533,8 @@ toofar:
} }
} }
/* Now the actual movement phase */ /* Now the actual movement phase
*/
if (!nearby || mtmp->mflee || scared || mtmp->mconf || mtmp->mstun if (!nearby || mtmp->mflee || scared || mtmp->mconf || mtmp->mstun
|| (mtmp->minvis && !rn2(3)) || (mtmp->minvis && !rn2(3))
@@ -604,7 +606,8 @@ toofar:
} }
} }
/* 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 (!mtmp->mpeaceful || (Conflict && !resist(mtmp, RING_CLASS, 0, 0))) {
if (inrange && !noattacks(mdat) && u.uhp > 0 && !scared && tmp != 3) if (inrange && !noattacks(mdat) && u.uhp > 0 && !scared && tmp != 3)
@@ -629,8 +632,7 @@ static NEARDATA const char practical[] = { WEAPON_CLASS, ARMOR_CLASS,
GEM_CLASS, FOOD_CLASS, 0 }; GEM_CLASS, FOOD_CLASS, 0 };
static NEARDATA const char magical[] = { AMULET_CLASS, POTION_CLASS, static NEARDATA const char magical[] = { AMULET_CLASS, POTION_CLASS,
SCROLL_CLASS, WAND_CLASS, SCROLL_CLASS, WAND_CLASS,
RING_CLASS, SPBOOK_CLASS, RING_CLASS, SPBOOK_CLASS, 0 };
0 };
static NEARDATA const char indigestion[] = { BALL_CLASS, ROCK_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 boulder_class[] = { ROCK_CLASS, 0 };
static NEARDATA const char gem_class[] = { GEM_CLASS, 0 }; static NEARDATA const char gem_class[] = { GEM_CLASS, 0 };
@@ -835,21 +837,21 @@ not_special:
gx = mtmp->mux; gx = mtmp->mux;
gy = mtmp->muy; gy = mtmp->muy;
appr = mtmp->mflee ? -1 : 1; appr = mtmp->mflee ? -1 : 1;
if (mtmp->mconf || (u.uswallow && mtmp == u.ustuck)) if (mtmp->mconf || (u.uswallow && mtmp == u.ustuck)) {
appr = 0; appr = 0;
else { } else {
struct obj *lepgold, *ygold; struct obj *lepgold, *ygold;
boolean should_see = boolean should_see = (couldsee(omx, omy)
(couldsee(omx, omy) && (levl[gx][gy].lit || !levl[omx][omy].lit) && (levl[gx][gy].lit || !levl[omx][omy].lit)
&& (dist2(omx, omy, gx, gy) <= 36)); && (dist2(omx, omy, gx, gy) <= 36));
if (!mtmp->mcansee if (!mtmp->mcansee
|| (should_see && Invis && !perceives(ptr) && rn2(11)) || (should_see && Invis && !perceives(ptr) && rn2(11))
|| is_obj_mappear(&youmonst,STRANGE_OBJECT) || u.uundetected || is_obj_mappear(&youmonst,STRANGE_OBJECT) || u.uundetected
|| (is_obj_mappear(&youmonst,GOLD_PIECE) && !likes_gold(ptr)) || (is_obj_mappear(&youmonst,GOLD_PIECE) && !likes_gold(ptr))
|| (mtmp->mpeaceful && !mtmp->isshk) || /* allow shks to follow */ || (mtmp->mpeaceful && !mtmp->isshk) /* allow shks to follow */
((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT || ((monsndx(ptr) == PM_STALKER || ptr->mlet == S_BAT
|| ptr->mlet == S_LIGHT) && !rn2(3))) || ptr->mlet == S_LIGHT) && !rn2(3)))
appr = 0; appr = 0;
if (monsndx(ptr) == PM_LEPRECHAUN && (appr == 1) if (monsndx(ptr) == PM_LEPRECHAUN && (appr == 1)
@@ -870,10 +872,9 @@ not_special:
} }
if ((!mtmp->mpeaceful || !rn2(10)) && (!Is_rogue_level(&u.uz))) { if ((!mtmp->mpeaceful || !rn2(10)) && (!Is_rogue_level(&u.uz))) {
boolean in_line = boolean in_line = (lined_up(mtmp)
lined_up(mtmp) && (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy)
&& (distmin(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= (throws_rocks(youmonst.data) ? 20 : ACURRSTR / 2 + 1)));
<= (throws_rocks(youmonst.data) ? 20 : ACURRSTR / 2 + 1));
if (appr != 1 || !in_line) { if (appr != 1 || !in_line) {
/* Monsters in combat won't pick stuff up, avoiding the /* Monsters in combat won't pick stuff up, avoiding the
@@ -964,7 +965,7 @@ not_special:
&& (!is_unicorn(ptr) && (!is_unicorn(ptr)
|| objects[otmp->otyp].oc_material == GEMSTONE) || objects[otmp->otyp].oc_material == GEMSTONE)
/* Don't get stuck circling an Elbereth */ /* Don't get stuck circling an Elbereth */
&& !(onscary(xx, yy, mtmp))) { && !onscary(xx, yy, mtmp)) {
minr = distmin(omx, omy, xx, yy); minr = distmin(omx, omy, xx, yy);
oomx = min(COLNO - 1, omx + minr); oomx = min(COLNO - 1, omx + minr);
oomy = min(ROWNO - 1, omy + minr); oomy = min(ROWNO - 1, omy + minr);
@@ -1122,8 +1123,7 @@ not_special:
* nearby is set, we never call m_move unless it is a special case * 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 * (confused, stun, etc.) The effect is that this ALLOW_U (and
* mfndpos) has no effect for normal attacks, though it lets a * mfndpos) has no effect for normal attacks, though it lets a
* confused * confused monster attack you by accident.
* monster attack you by accident.
*/ */
if (info[chi] & ALLOW_U) { if (info[chi] & ALLOW_U) {
nix = mtmp->mux; nix = mtmp->mux;
@@ -1210,8 +1210,7 @@ postmov:
/* open a door, or crash through it, if you can */ /* open a door, or crash through it, if you can */
if (IS_DOOR(levl[mtmp->mx][mtmp->my].typ) if (IS_DOOR(levl[mtmp->mx][mtmp->my].typ)
&& !passes_walls(ptr) /* doesn't need to open doors */ && !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]; struct rm *here = &levl[mtmp->mx][mtmp->my];
boolean btrapped = (here->doormask & D_TRAPPED), boolean btrapped = (here->doormask & D_TRAPPED),
observeit = canseeit && canspotmon(mtmp); observeit = canseeit && canspotmon(mtmp);
@@ -1330,8 +1329,7 @@ postmov:
/* recompute the likes tests, in case we polymorphed /* recompute the likes tests, in case we polymorphed
* or if the "likegold" case got taken above */ * or if the "likegold" case got taken above */
if (setlikes) { if (setlikes) {
register int pctload = int pctload = (curr_mon_load(mtmp) * 100) / max_mon_load(mtmp);
(curr_mon_load(mtmp) * 100) / max_mon_load(mtmp);
/* look for gold or jewels nearby */ /* look for gold or jewels nearby */
likegold = (likes_gold(ptr) && pctload < 95); likegold = (likes_gold(ptr) && pctload < 95);
@@ -1517,11 +1515,12 @@ xchar x, y;
/* Pets avoid cursed locations */ /* Pets avoid cursed locations */
if (cursed_object_at(x, y)) if (cursed_object_at(x, y))
return TRUE; return TRUE;
}
/* Monsters avoid a trap if they've seen that type before */ /* Monsters avoid a trap if they've seen that type before */
else if (trap && rn2(40) } else if (trap && rn2(40)
&& (mtmp->mtrapseen & (1 << (trap->ttyp - 1))) != 0) && (mtmp->mtrapseen & (1 << (trap->ttyp - 1))) != 0) {
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
@@ -1594,6 +1593,7 @@ struct monst *mon;
struct permonst *ptr; struct permonst *ptr;
{ {
int reslt = 0; int reslt = 0;
if (mon->cham >= LOW_PM) { if (mon->cham >= LOW_PM) {
if (ptr == &mons[mon->cham]) if (ptr == &mons[mon->cham])
mon->cham = NON_PM; mon->cham = NON_PM;
+22 -19
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -58,7 +58,7 @@ const char *name; /* if null, then format `obj' */
pline("It misses."); pline("It misses.");
else else
You("are almost hit by %s.", onm); You("are almost hit by %s.", onm);
return (0); return 0;
} else { } else {
if (Blind || !flags.verbose) if (Blind || !flags.verbose)
You("are hit%s", exclam(dam)); You("are hit%s", exclam(dam));
@@ -78,7 +78,7 @@ const char *name; /* if null, then format `obj' */
losehp(dam, knm, kprefix); /* acid damage */ losehp(dam, knm, kprefix); /* acid damage */
exercise(A_STR, FALSE); exercise(A_STR, FALSE);
} }
return (1); return 1;
} }
} }
@@ -138,7 +138,7 @@ struct obj *otmp; /* missile; might be destroyed by drop_throw */
int range; /* how much farther will object travel if it misses */ int range; /* how much farther will object travel if it misses */
/* Use -1 to signify to keep going even after hit, */ /* Use -1 to signify to keep going even after hit, */
/* unless its gone (used for rolling_boulder_traps) */ /* 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; int damage, tmp;
boolean vis, ismimic; boolean vis, ismimic;
@@ -577,11 +577,13 @@ struct monst *mtmp;
/* Multishot calculations */ /* Multishot calculations */
multishot = 1; 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 */ /* ammo requires corresponding launcher be wielded */
(is_ammo(otmp) ? matching_launcher(otmp, mwep) && (is_ammo(otmp)
/* otherwise any stackable (non-ammo) weapon */ ? matching_launcher(otmp, mwep)
: otmp->oclass == WEAPON_CLASS) && !mtmp->mconf) { /* otherwise any stackable (non-ammo) weapon */
: otmp->oclass == WEAPON_CLASS)
&& !mtmp->mconf) {
int skill = (int) objects[otmp->otyp].oc_skill; int skill = (int) objects[otmp->otyp].oc_skill;
/* Assumes lords are skilled, princes are expert */ /* Assumes lords are skilled, princes are expert */
@@ -673,10 +675,10 @@ struct monst *mtmp;
/* monster spits substance at you */ /* monster spits substance at you */
int int
spitmu(mtmp, mattk) spitmu(mtmp, mattk)
register struct monst *mtmp; struct monst *mtmp;
register struct attack *mattk; struct attack *mattk;
{ {
register struct obj *otmp; struct obj *otmp;
if (mtmp->mcan) { if (mtmp->mcan) {
if (!Deaf) if (!Deaf)
@@ -716,8 +718,8 @@ register struct attack *mattk;
/* monster breathes at you (ranged) */ /* monster breathes at you (ranged) */
int int
breamu(mtmp, mattk) breamu(mtmp, mattk)
register struct monst *mtmp; struct monst *mtmp;
register struct attack *mattk; struct attack *mattk;
{ {
/* if new breath types are added, change AD_ACID to max type */ /* if new breath types are added, change AD_ACID to max type */
int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp; int typ = (mattk->adtyp == AD_RBRE) ? rnd(AD_ACID) : mattk->adtyp;
@@ -730,7 +732,7 @@ register struct attack *mattk;
else else
You_hear("a cough."); You_hear("a cough.");
} }
return (0); return 0;
} }
if (!mtmp->mspec_used && rn2(3)) { if (!mtmp->mspec_used && rn2(3)) {
if ((typ >= AD_MAGM) && (typ <= AD_ACID)) { if ((typ >= AD_MAGM) && (typ <= AD_ACID)) {
@@ -751,7 +753,7 @@ register struct attack *mattk;
impossible("Breath weapon %d used", typ - 1); impossible("Breath weapon %d used", typ - 1);
} }
} }
return (1); return 1;
} }
boolean boolean
@@ -761,8 +763,9 @@ int boulderhandling; /* 0=block, 1=ignore, 2=conditionally block */
{ {
int dx, dy, boulderspots; int dx, dy, boulderspots;
tbx = ax - bx; /* These two values are set for use */ /* These two values are set for use after successful return. */
tby = ay - by; /* after successful return. */ tbx = ax - bx;
tby = ay - by;
/* sometimes displacement makes a monster think that you're at its /* sometimes displacement makes a monster think that you're at its
own location; prevent it from throwing and zapping in that case */ own location; prevent it from throwing and zapping in that case */
@@ -824,8 +827,8 @@ int type;
for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj) for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
if (otmp->otyp == type) if (otmp->otyp == type)
return (otmp); return otmp;
return ((struct obj *) 0); return (struct obj *) 0;
} }
/* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */ /* TRUE iff thrown/kicked/rolled object doesn't pass through iron bars */
+83 -70
View File
@@ -1,5 +1,5 @@
/* NetHack 3.6 polyself.c $NHDT-Date: 1432512772 2015/05/25 00:12:52 $ $NHDT-Branch: master $:$NHDT-Revision: 1.100 $ */ /* 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 */ /* Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* /*
@@ -10,13 +10,13 @@
* player polymorphed into a light-emitting monster. * player polymorphed into a light-emitting monster.
* *
* Transformation sequences: * Transformation sequences:
* /-> polymon poly into monster form * /-> polymon poly into monster form
* polyself = * 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" #include "hack.h"
@@ -71,9 +71,9 @@ set_uasmon()
} }
/* resists_magm() takes wielded, worn, and carried equipment into /* resists_magm() takes wielded, worn, and carried equipment into
into account; cheat and duplicate its monster-specific part */ into account; cheat and duplicate its monster-specific part */
PROPSET(ANTIMAGIC, PROPSET(ANTIMAGIC, (dmgtype(mdat, AD_MAGM)
(dmgtype(mdat, AD_MAGM) || mdat == &mons[PM_BABY_GRAY_DRAGON] || mdat == &mons[PM_BABY_GRAY_DRAGON]
|| dmgtype(mdat, AD_RBRE))); || dmgtype(mdat, AD_RBRE)));
PROPSET(SICK_RES, (mdat->mlet == S_FUNGUS || mdat == &mons[PM_GHOUL])); PROPSET(SICK_RES, (mdat->mlet == S_FUNGUS || mdat == &mons[PM_GHOUL]));
PROPSET(STUNNED, (mdat == &mons[PM_STALKER] || is_bat(mdat))); PROPSET(STUNNED, (mdat == &mons[PM_STALKER] || is_bat(mdat)));
@@ -119,9 +119,10 @@ STATIC_OVL void
check_strangling(on) check_strangling(on)
boolean on; boolean on;
{ {
if (on) { /* on -- maybe resume strangling */ /* on -- maybe resume strangling */
/* when Strangled is already set, polymorphing from one if (on) {
vulnerable form into another causes the counter to be reset */ /* 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 if (uamul && uamul->otyp == AMULET_OF_STRANGULATION
&& can_be_strangled(&youmonst)) { && can_be_strangled(&youmonst)) {
Your("%s %s your %s!", simpleonames(uamul), Your("%s %s your %s!", simpleonames(uamul),
@@ -130,7 +131,9 @@ boolean on;
Strangled = 6L; Strangled = 6L;
makeknown(AMULET_OF_STRANGULATION); makeknown(AMULET_OF_STRANGULATION);
} }
} else { /* off -- maybe block strangling */
/* off -- maybe block strangling */
} else {
if (Strangled && !can_be_strangled(&youmonst)) { if (Strangled && !can_be_strangled(&youmonst)) {
Strangled = 0L; Strangled = 0L;
You("are no longer being strangled."); You("are no longer being strangled.");
@@ -143,7 +146,7 @@ STATIC_OVL void
polyman(fmt, arg) polyman(fmt, arg)
const char *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); was_mimicking = (youmonst.m_ap_type == M_AP_OBJECT);
boolean was_blind = !!Blind; boolean was_blind = !!Blind;
@@ -218,10 +221,12 @@ change_sex()
swap unintentionally makes `Upolyd' appear to be true */ swap unintentionally makes `Upolyd' appear to be true */
boolean already_polyd = (boolean) Upolyd; boolean already_polyd = (boolean) Upolyd;
/* Some monsters are always of one sex and their sex can't be changed */ /* Some monsters are always of one sex and their sex can't be changed;
/* succubi/incubi can change, but are handled below */ * 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 */ * !already_polyd check necessary because is_male() and is_female()
* are true if the player is a priest/priestess.
*/
if (!already_polyd if (!already_polyd
|| (!is_male(youmonst.data) && !is_female(youmonst.data) || (!is_male(youmonst.data) && !is_female(youmonst.data)
&& !is_neuter(youmonst.data))) && !is_neuter(youmonst.data)))
@@ -285,10 +290,11 @@ newman()
/* /*
* New hit points: * New hit points:
* remove level-gain based HP from any extra HP accumulated * remove level-gain based HP from any extra HP accumulated
* (the "extra" might actually be negative); * (the "extra" might actually be negative);
* modify the extra, retaining {80%, 90%, 100%, or 110%}; * modify the extra, retaining {80%, 90%, 100%, or 110%};
* add in newly generated set of level-gain HP. * add in newly generated set of level-gain HP.
*
* (This used to calculate new HP in direct proportion to old HP, * (This used to calculate new HP in direct proportion to old HP,
* but that was subject to abuse: accumulate a large amount of * 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 * extra HP, drain level down to 1, then polyself to level 2 or 3
@@ -569,8 +575,10 @@ made_change:
} }
} }
/* (try to) make a mntmp monster out of the player */ /* (try to) make a mntmp monster out of the player;
int polymon(mntmp) /* returns 1 if polymorph successful */ returns 1 if polymorph successful */
int
polymon(mntmp)
int mntmp; int mntmp;
{ {
boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow, boolean sticky = sticks(youmonst.data) && u.ustuck && !u.uswallow,
@@ -580,7 +588,7 @@ int mntmp;
if (mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */ if (mvitals[mntmp].mvflags & G_GENOD) { /* allow G_EXTINCT */
You_feel("rather %s-ish.", mons[mntmp].mname); You_feel("rather %s-ish.", mons[mntmp].mname);
exercise(A_WIS, TRUE); exercise(A_WIS, TRUE);
return (0); return 0;
} }
/* KMH, conduct */ /* KMH, conduct */
@@ -695,7 +703,7 @@ int mntmp;
u.mh = u.mhmax; u.mh = u.mhmax;
if (u.ulevel < mlvl) { 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 #ifdef DUMB
/* DRS/NS 2.2.6 messes up -- Peter Kendell */ /* DRS/NS 2.2.6 messes up -- Peter Kendell */
int mtd = u.mtimedone, ulv = u.ulevel; int mtd = u.mtimedone, ulv = u.ulevel;
@@ -770,6 +778,7 @@ int mntmp;
if (lays_eggs(youmonst.data) && flags.female) if (lays_eggs(youmonst.data) && flags.female)
pline(use_thec, "sit", "lay an egg"); pline(use_thec, "sit", "lay an egg");
} }
/* you now know what an egg of your type looks like */ /* you now know what an egg of your type looks like */
if (lays_eggs(youmonst.data)) { if (lays_eggs(youmonst.data)) {
learn_egg_type(u.umonnum); learn_egg_type(u.umonnum);
@@ -831,7 +840,7 @@ int mntmp;
flesh golem above, now gets transformed back into stone golem] */ flesh golem above, now gets transformed back into stone golem] */
if (!uarmg) if (!uarmg)
selftouch(no_longer_petrify_resistant); selftouch(no_longer_petrify_resistant);
return (1); return 1;
} }
STATIC_OVL void STATIC_OVL void
@@ -1035,17 +1044,17 @@ dobreathe()
if (Strangled) { if (Strangled) {
You_cant("breathe. Sorry."); You_cant("breathe. Sorry.");
return (0); return 0;
} }
if (u.uen < 15) { if (u.uen < 15) {
You("don't have enough energy to breathe!"); You("don't have enough energy to breathe!");
return (0); return 0;
} }
u.uen -= 15; u.uen -= 15;
context.botl = 1; context.botl = 1;
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
mattk = attacktype_fordmg(youmonst.data, AT_BREA, AD_ANY); mattk = attacktype_fordmg(youmonst.data, AT_BREA, AD_ANY);
if (!mattk) if (!mattk)
@@ -1055,7 +1064,7 @@ dobreathe()
else else
buzz((int) (20 + mattk->adtyp - 1), (int) mattk->damn, u.ux, u.uy, buzz((int) (20 + mattk->adtyp - 1), (int) mattk->damn, u.ux, u.uy,
u.dx, u.dy); u.dx, u.dy);
return (1); return 1;
} }
int int
@@ -1065,7 +1074,7 @@ dospit()
struct attack *mattk; struct attack *mattk;
if (!getdir((char *) 0)) if (!getdir((char *) 0))
return (0); return 0;
mattk = attacktype_fordmg(youmonst.data, AT_SPIT, AD_ANY); mattk = attacktype_fordmg(youmonst.data, AT_SPIT, AD_ANY);
if (!mattk) { if (!mattk) {
impossible("bad spit attack?"); impossible("bad spit attack?");
@@ -1085,7 +1094,7 @@ dospit()
otmp->spe = 1; /* to indicate it's yours */ otmp->spe = 1; /* to indicate it's yours */
throwit(otmp, 0L, FALSE); throwit(otmp, 0L, FALSE);
} }
return (1); return 1;
} }
int int
@@ -1095,13 +1104,13 @@ doremove()
if (u.utrap && u.utraptype == TT_BURIEDBALL) { if (u.utrap && u.utraptype == TT_BURIEDBALL) {
pline_The("ball and chain are buried firmly in the %s.", pline_The("ball and chain are buried firmly in the %s.",
surface(u.ux, u.uy)); surface(u.ux, u.uy));
return (0); return 0;
} }
You("are not chained to anything!"); You("are not chained to anything!");
return (0); return 0;
} }
unpunish(); unpunish();
return (1); return 1;
} }
int int
@@ -1112,13 +1121,13 @@ dospinweb()
if (Levitation || Is_airlevel(&u.uz) || Underwater if (Levitation || Is_airlevel(&u.uz) || Underwater
|| Is_waterlevel(&u.uz)) { || Is_waterlevel(&u.uz)) {
You("must be on the ground to spin a web."); You("must be on the ground to spin a web.");
return (0); return 0;
} }
if (u.uswallow) { if (u.uswallow) {
You("release web fluid inside %s.", mon_nam(u.ustuck)); You("release web fluid inside %s.", mon_nam(u.ustuck));
if (is_animal(u.ustuck->data)) { if (is_animal(u.ustuck->data)) {
expels(u.ustuck, u.ustuck->data, TRUE); expels(u.ustuck, u.ustuck->data, TRUE);
return (0); return 0;
} }
if (is_whirly(u.ustuck->data)) { if (is_whirly(u.ustuck->data)) {
int i; int i;
@@ -1145,17 +1154,17 @@ dospinweb()
} }
pline_The("web %sis swept away!", sweep); pline_The("web %sis swept away!", sweep);
} }
return (0); return 0;
} /* default: a nasty jelly-like creature */ } /* default: a nasty jelly-like creature */
pline_The("web dissolves into %s.", mon_nam(u.ustuck)); pline_The("web dissolves into %s.", mon_nam(u.ustuck));
return (0); return 0;
} }
if (u.utrap) { if (u.utrap) {
You("cannot spin webs while stuck in a trap."); You("cannot spin webs while stuck in a trap.");
return (0); return 0;
} }
exercise(A_DEX, TRUE); exercise(A_DEX, TRUE);
if (ttmp) if (ttmp) {
switch (ttmp->ttyp) { switch (ttmp->ttyp) {
case PIT: case PIT:
case SPIKED_PIT: case SPIKED_PIT:
@@ -1163,21 +1172,21 @@ dospinweb()
deltrap(ttmp); deltrap(ttmp);
bury_objs(u.ux, u.uy); bury_objs(u.ux, u.uy);
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
return (1); return 1;
case SQKY_BOARD: case SQKY_BOARD:
pline_The("squeaky board is muffled."); pline_The("squeaky board is muffled.");
deltrap(ttmp); deltrap(ttmp);
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
return (1); return 1;
case TELEP_TRAP: case TELEP_TRAP:
case LEVEL_TELEP: case LEVEL_TELEP:
case MAGIC_PORTAL: case MAGIC_PORTAL:
case VIBRATING_SQUARE: case VIBRATING_SQUARE:
Your("webbing vanishes!"); Your("webbing vanishes!");
return (0); return 0;
case WEB: case WEB:
You("make the web thicker."); You("make the web thicker.");
return (1); return 1;
case HOLE: case HOLE:
case TRAPDOOR: case TRAPDOOR:
You("web over the %s.", You("web over the %s.",
@@ -1189,7 +1198,7 @@ dospinweb()
You("spin a web, jamming the trigger."); You("spin a web, jamming the trigger.");
deltrap(ttmp); deltrap(ttmp);
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
return (1); return 1;
case ARROW_TRAP: case ARROW_TRAP:
case DART_TRAP: case DART_TRAP:
case BEAR_TRAP: case BEAR_TRAP:
@@ -1203,23 +1212,23 @@ dospinweb()
case POLY_TRAP: case POLY_TRAP:
You("have triggered a trap!"); You("have triggered a trap!");
dotrap(ttmp, 0); dotrap(ttmp, 0);
return (1); return 1;
default: default:
impossible("Webbing over trap type %d?", ttmp->ttyp); 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 */ /* cop out: don't let them hide the stairs */
Your("web fails to impede access to the %s.", Your("web fails to impede access to the %s.",
(levl[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder"); (levl[u.ux][u.uy].typ == STAIRS) ? "stairs" : "ladder");
return (1); return 1;
} }
ttmp = maketrap(u.ux, u.uy, WEB); ttmp = maketrap(u.ux, u.uy, WEB);
if (ttmp) { if (ttmp) {
ttmp->madeby_u = 1; ttmp->madeby_u = 1;
feeltrap(ttmp); feeltrap(ttmp);
} }
return (1); return 1;
} }
int int
@@ -1228,7 +1237,7 @@ dosummon()
int placeholder; int placeholder;
if (u.uen < 10) { if (u.uen < 10) {
You("lack the energy to send forth a call for help!"); You("lack the energy to send forth a call for help!");
return (0); return 0;
} }
u.uen -= 10; u.uen -= 10;
context.botl = 1; context.botl = 1;
@@ -1237,7 +1246,7 @@ dosummon()
exercise(A_WIS, TRUE); exercise(A_WIS, TRUE);
if (!were_summon(youmonst.data, TRUE, &placeholder, (char *) 0)) if (!were_summon(youmonst.data, TRUE, &placeholder, (char *) 0))
pline("But none arrive."); pline("But none arrive.");
return (1); return 1;
} }
int int
@@ -1269,7 +1278,7 @@ dogaze()
} }
if (u.uen < 15) { if (u.uen < 15) {
You("lack the energy to use your special gaze!"); You("lack the energy to use your special gaze!");
return (0); return 0;
} }
u.uen -= 15; u.uen -= 15;
context.botl = 1; context.botl = 1;
@@ -1279,12 +1288,12 @@ dogaze()
continue; continue;
if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) { if (canseemon(mtmp) && couldsee(mtmp->mx, mtmp->my)) {
looked++; looked++;
if (Invis && !perceives(mtmp->data)) if (Invis && !perceives(mtmp->data)) {
pline("%s seems not to notice your gaze.", Monnam(mtmp)); 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)); You_cant("see where to gaze at %s.", Monnam(mtmp));
else if (mtmp->m_ap_type == M_AP_FURNITURE } else if (mtmp->m_ap_type == M_AP_FURNITURE
|| mtmp->m_ap_type == M_AP_OBJECT) { || mtmp->m_ap_type == M_AP_OBJECT) {
looked--; looked--;
continue; continue;
} else if (flags.safe_dog && mtmp->mtame && !Confusion) { } else if (flags.safe_dog && mtmp->mtame && !Confusion) {
@@ -1419,14 +1428,15 @@ dohide()
u.uundetected = 0; u.uundetected = 0;
return 0; return 0;
} }
if ((is_hider(youmonst.data) && !Flying) && /* floor hider */ if ((is_hider(youmonst.data) && !Flying) /* floor hider */
(Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) { && (Is_airlevel(&u.uz) || Is_waterlevel(&u.uz))) {
There("is nowhere to hide beneath you."); There("is nowhere to hide beneath you.");
u.uundetected = 0; u.uundetected = 0;
return 0; return 0;
} }
/* TODO? inhibit floor hiding at furniture locations, or /* 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)) { if (u.uundetected || (ismimic && youmonst.m_ap_type != M_AP_NOTHING)) {
youhiding(FALSE, 1); /* "you are already hiding" */ youhiding(FALSE, 1); /* "you are already hiding" */
@@ -1448,6 +1458,7 @@ int
dopoly() dopoly()
{ {
struct permonst *savedat = youmonst.data; struct permonst *savedat = youmonst.data;
if (is_vampire(youmonst.data)) { if (is_vampire(youmonst.data)) {
polyself(2); polyself(2);
if (savedat != youmonst.data) { if (savedat != youmonst.data) {
@@ -1455,7 +1466,7 @@ dopoly()
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
} }
} }
return (1); return 1;
} }
int int
@@ -1465,7 +1476,7 @@ domindblast()
if (u.uen < 10) { if (u.uen < 10) {
You("concentrate but lack the energy to maintain doing so."); You("concentrate but lack the energy to maintain doing so.");
return (0); return 0;
} }
u.uen -= 10; u.uen -= 10;
context.botl = 1; context.botl = 1;
@@ -1668,8 +1679,8 @@ int part;
int int
poly_gender() poly_gender()
{ {
/* Returns gender of polymorphed player; 0/1=same meaning as flags.female, /* Returns gender of polymorphed player;
* 2=none. * 0/1=same meaning as flags.female, 2=none.
*/ */
if (is_neuter(youmonst.data) || !humanoid(youmonst.data)) if (is_neuter(youmonst.data) || !humanoid(youmonst.data))
return 2; return 2;
@@ -1681,6 +1692,7 @@ ugolemeffects(damtype, dam)
int damtype, dam; int damtype, dam;
{ {
int heal = 0; int heal = 0;
/* We won't bother with "slow"/"haste" since players do not /* We won't bother with "slow"/"haste" since players do not
* have a monster-specific slow/haste so there is no way to * have a monster-specific slow/haste so there is no way to
* restore the old velocity once they are back to human. * restore the old velocity once they are back to human.
@@ -1690,7 +1702,7 @@ int damtype, dam;
switch (damtype) { switch (damtype) {
case AD_ELEC: case AD_ELEC:
if (u.umonnum == PM_FLESH_GOLEM) if (u.umonnum == PM_FLESH_GOLEM)
heal = dam / 6; /* Approx 1 per die */ heal = (dam + 5) / 6; /* Approx 1 per die */
break; break;
case AD_FIRE: case AD_FIRE:
if (u.umonnum == PM_IRON_GOLEM) if (u.umonnum == PM_IRON_GOLEM)
@@ -1719,9 +1731,9 @@ int atyp;
case SILVER_DRAGON_SCALES: case SILVER_DRAGON_SCALES:
return PM_SILVER_DRAGON; return PM_SILVER_DRAGON;
#if 0 /* DEFERRED */ #if 0 /* DEFERRED */
case SHIMMERING_DRAGON_SCALE_MAIL: case SHIMMERING_DRAGON_SCALE_MAIL:
case SHIMMERING_DRAGON_SCALES: case SHIMMERING_DRAGON_SCALES:
return PM_SHIMMERING_DRAGON; return PM_SHIMMERING_DRAGON;
#endif #endif
case RED_DRAGON_SCALE_MAIL: case RED_DRAGON_SCALE_MAIL:
case RED_DRAGON_SCALES: case RED_DRAGON_SCALES:
@@ -1757,6 +1769,7 @@ polysense(mptr)
struct permonst *mptr; struct permonst *mptr;
{ {
short warnidx = 0; short warnidx = 0;
context.warntype.speciesidx = 0; context.warntype.speciesidx = 0;
context.warntype.species = 0; context.warntype.species = 0;
context.warntype.polyd = 0; context.warntype.polyd = 0;
+99 -89
View File
@@ -1,4 +1,4 @@
/* 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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -17,14 +17,14 @@ STATIC_DCL int FDECL(disarm_holdingtrap, (struct trap *));
STATIC_DCL int FDECL(disarm_landmine, (struct trap *)); STATIC_DCL int FDECL(disarm_landmine, (struct trap *));
STATIC_DCL int FDECL(disarm_squeaky_board, (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(disarm_shooting_trap, (struct trap *, int));
STATIC_DCL int FDECL(try_lift, STATIC_DCL int FDECL(try_lift, (struct monst *, struct trap *, int,
(struct monst *, struct trap *, int, BOOLEAN_P)); BOOLEAN_P));
STATIC_DCL int FDECL(help_monster_out, (struct monst *, struct trap *)); STATIC_DCL int FDECL(help_monster_out, (struct monst *, struct trap *));
STATIC_DCL boolean STATIC_DCL boolean FDECL(thitm, (int, struct monst *, struct obj *, int,
FDECL(thitm, (int, struct monst *, struct obj *, int, BOOLEAN_P)); BOOLEAN_P));
STATIC_DCL void FDECL(launch_drop_spot, (struct obj *, XCHAR_P, XCHAR_P)); STATIC_DCL void FDECL(launch_drop_spot, (struct obj *, XCHAR_P, XCHAR_P));
STATIC_DCL int FDECL(mkroll_launch, STATIC_DCL int FDECL(mkroll_launch, (struct trap *, XCHAR_P, XCHAR_P,
(struct trap *, XCHAR_P, XCHAR_P, SHORT_P, long)); SHORT_P, long));
STATIC_DCL boolean FDECL(isclearpath, (coord *, int, SCHAR_P, SCHAR_P)); STATIC_DCL boolean FDECL(isclearpath, (coord *, int, SCHAR_P, SCHAR_P));
STATIC_DCL char *FDECL(trapnote, (struct trap *, BOOLEAN_P)); STATIC_DCL char *FDECL(trapnote, (struct trap *, BOOLEAN_P));
#if 0 #if 0
@@ -32,8 +32,9 @@ STATIC_DCL void FDECL(join_adjacent_pits, (struct trap *));
#endif #endif
STATIC_DCL void FDECL(clear_conjoined_pits, (struct trap *)); STATIC_DCL void FDECL(clear_conjoined_pits, (struct trap *));
STATIC_DCL int FDECL(steedintrap, (struct trap *, struct obj *)); STATIC_DCL int FDECL(steedintrap, (struct trap *, struct obj *));
STATIC_DCL boolean STATIC_DCL boolean FDECL(keep_saddle_with_steedcorpse, (unsigned,
FDECL(keep_saddle_with_steedcorpse, (unsigned, struct obj *, struct obj *)); struct obj *,
struct obj *));
STATIC_DCL void NDECL(maybe_finish_sokoban); STATIC_DCL void NDECL(maybe_finish_sokoban);
/* mintrap() should take a flags argument, but for time being we use this */ /* mintrap() should take a flags argument, but for time being we use this */
@@ -136,7 +137,7 @@ struct monst *victim;
int int
erode_obj(otmp, ostr, type, ef_flags) erode_obj(otmp, ostr, type, ef_flags)
register struct obj *otmp; register struct obj *otmp;
register const char *ostr; const char *ostr;
int type; int type;
int ef_flags; int ef_flags;
{ {
@@ -289,7 +290,7 @@ int ef_flags;
boolean boolean
grease_protect(otmp, ostr, victim) grease_protect(otmp, ostr, victim)
register struct obj *otmp; register struct obj *otmp;
register const char *ostr; const char *ostr;
struct monst *victim; struct monst *victim;
{ {
static const char txt[] = "protected by the layer of grease!"; static const char txt[] = "protected by the layer of grease!";
@@ -299,9 +300,9 @@ struct monst *victim;
if (victim == &youmonst) if (victim == &youmonst)
Your("%s %s %s", ostr, vtense(ostr, "are"), txt); Your("%s %s %s", ostr, vtense(ostr, "are"), txt);
else if (vismon) else if (vismon)
pline("%s's %s %s %s", Monnam(victim), ostr, vtense(ostr, "are"), pline("%s's %s %s %s", Monnam(victim),
txt); ostr, vtense(ostr, "are"), txt);
} else if ((victim == &youmonst) || vismon) { } else if (victim == &youmonst || vismon) {
pline("%s %s", Yobjnam2(otmp, "are"), txt); pline("%s %s", Yobjnam2(otmp, "are"), txt);
} }
if (!rn2(2)) { if (!rn2(2)) {
@@ -321,13 +322,13 @@ register int x, y, typ;
{ {
register struct trap *ttmp; register struct trap *ttmp;
register struct rm *lev; register struct rm *lev;
register boolean oldplace; boolean oldplace;
if ((ttmp = t_at(x, y)) != 0) { if ((ttmp = t_at(x, y)) != 0) {
if (ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE) if (ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE)
return (struct trap *) 0; return (struct trap *) 0;
oldplace = TRUE; 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_BEARTRAP && typ != BEAR_TRAP)
|| (u.utraptype == TT_WEB && typ != WEB) || (u.utraptype == TT_WEB && typ != WEB)
|| (u.utraptype == TT_PIT && typ != PIT || (u.utraptype == TT_PIT && typ != PIT
@@ -364,8 +365,7 @@ register int x, y, typ;
ttmp->tnote = (short) rn2(12); /* all in use anyway */ ttmp->tnote = (short) rn2(12); /* all in use anyway */
break; break;
} }
case STATUE_TRAP: /* create a "living" statue */ case STATUE_TRAP: { /* create a "living" statue */
{
struct monst *mtmp; struct monst *mtmp;
struct obj *otmp, *statue; struct obj *otmp, *statue;
struct permonst *mptr; struct permonst *mptr;
@@ -396,13 +396,13 @@ register int x, y, typ;
case PIT: case PIT:
case SPIKED_PIT: case SPIKED_PIT:
ttmp->conjoined = 0; ttmp->conjoined = 0;
/* fall through */ /*FALLTHRU*/
case HOLE: case HOLE:
case TRAPDOOR: case TRAPDOOR:
lev = &levl[x][y]; lev = &levl[x][y];
if (*in_rooms(x, y, SHOPBASE) if (*in_rooms(x, y, SHOPBASE)
&& ((typ == HOLE || typ == TRAPDOOR) || IS_DOOR(lev->typ) && (typ == HOLE || typ == TRAPDOOR
|| IS_WALL(lev->typ))) || IS_DOOR(lev->typ) || IS_WALL(lev->typ)))
add_damage(x, y, /* schedule repair */ add_damage(x, y, /* schedule repair */
((IS_DOOR(lev->typ) || IS_WALL(lev->typ)) ((IS_DOOR(lev->typ) || IS_WALL(lev->typ))
&& !context.mon_moving) && !context.mon_moving)
@@ -411,7 +411,6 @@ register int x, y, typ;
lev->doormask = 0; /* subsumes altarmask, icedpool... */ lev->doormask = 0; /* subsumes altarmask, icedpool... */
if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */ if (IS_ROOM(lev->typ)) /* && !IS_AIR(lev->typ) */
lev->typ = ROOM; lev->typ = ROOM;
/* /*
* some cases which can happen when digging * some cases which can happen when digging
* down while phazing thru solid areas * down while phazing thru solid areas
@@ -536,24 +535,24 @@ boolean td; /* td == TRUE : trap door or hole */
* *
* The cause of animation is: * The cause of animation is:
* *
* ANIMATE_NORMAL - hero "finds" the monster * ANIMATE_NORMAL - hero "finds" the monster
* ANIMATE_SHATTER - hero tries to destroy the statue * ANIMATE_SHATTER - hero tries to destroy the statue
* ANIMATE_SPELL - stone to flesh spell hits 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 * Perhaps x, y is not needed if we can use get_obj_location() to find
* the statue's location... ??? * the statue's location... ???
* *
* Sequencing matters: * Sequencing matters:
* create monster; if it fails, give up with statue intact; * create monster; if it fails, give up with statue intact;
* give "statue comes to life" message; * give "statue comes to life" message;
* if statue belongs to shop, have shk give "you owe" message; * if statue belongs to shop, have shk give "you owe" message;
* transfer statue contents to monster (after stolen_value()); * transfer statue contents to monster (after stolen_value());
* delete statue. * delete statue.
* [This ordering means that if the statue ends up wearing a cloak of * [This ordering means that if the statue ends up wearing a cloak of
* invisibility or a mummy wrapping, the visibility checks might be * invisibility or a mummy wrapping, the visibility checks might be
* wrong, but to avoid that we'd have to clone the statue contents * 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 * first in order to give them to the monster before checking their
* shop status--it's not worth the hassle.] * shop status--it's not worth the hassle.]
*/ */
struct monst * struct monst *
animate_statue(statue, x, y, cause, fail_reason) animate_statue(statue, x, y, cause, fail_reason)
@@ -883,6 +882,7 @@ unsigned trflags;
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
} }
break; break;
case DART_TRAP: case DART_TRAP:
if (trap->once && trap->tseen && !rn2(15)) { if (trap->once && trap->tseen && !rn2(15)) {
You_hear("a soft click."); You_hear("a soft click.");
@@ -916,6 +916,7 @@ unsigned trflags;
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
} }
break; break;
case ROCKTRAP: case ROCKTRAP:
if (trap->once && trap->tseen && !rn2(15)) { if (trap->once && trap->tseen && !rn2(15)) {
pline("A trap door in %s opens, but nothing falls out!", pline("A trap door in %s opens, but nothing falls out!",
@@ -1172,6 +1173,7 @@ unsigned trflags;
exercise(A_DEX, FALSE); exercise(A_DEX, FALSE);
} }
break; break;
case HOLE: case HOLE:
case TRAPDOOR: case TRAPDOOR:
if (!Can_fall_thru(&u.uz)) { if (!Can_fall_thru(&u.uz)) {
@@ -1187,6 +1189,7 @@ unsigned trflags;
seetrap(trap); seetrap(trap);
tele_trap(trap); tele_trap(trap);
break; break;
case LEVEL_TELEP: case LEVEL_TELEP:
seetrap(trap); seetrap(trap);
level_tele_trap(trap); level_tele_trap(trap);
@@ -1419,6 +1422,7 @@ unsigned trflags;
fill_pit(u.ux, u.uy); fill_pit(u.ux, u.uy);
break; break;
} }
case ROLLING_BOULDER_TRAP: { case ROLLING_BOULDER_TRAP: {
int style = ROLL | (trap->tseen ? LAUNCH_KNOWN : 0); int style = ROLL | (trap->tseen ? LAUNCH_KNOWN : 0);
@@ -1432,10 +1436,12 @@ unsigned trflags;
} }
break; break;
} }
case MAGIC_PORTAL: case MAGIC_PORTAL:
feeltrap(trap); feeltrap(trap);
domagicportal(trap); domagicportal(trap);
break; break;
case VIBRATING_SQUARE: case VIBRATING_SQUARE:
seetrap(trap); seetrap(trap);
/* messages handled elsewhere; the trap symbol is merely to mark the /* messages handled elsewhere; the trap symbol is merely to mark the
@@ -2706,6 +2712,7 @@ boolean byplayer;
} }
} }
/* start levitating */
void void
float_up() float_up()
{ {
@@ -2721,29 +2728,29 @@ float_up()
} else { } else {
You("float up, only your %s is still stuck.", body_part(LEG)); You("float up, only your %s is still stuck.", body_part(LEG));
} }
}
#if 0 #if 0
else if(Is_waterlevel(&u.uz)) } else if(Is_waterlevel(&u.uz)) {
pline("It feels as though you've lost some weight."); pline("It feels as though you've lost some weight.");
#endif #endif
else if (u.uinwater) } else if (u.uinwater) {
spoteffects(TRUE); spoteffects(TRUE);
else if (u.uswallow) } else if (u.uswallow) {
You(is_animal(u.ustuck->data) ? "float away from the %s." You(is_animal(u.ustuck->data) ? "float away from the %s."
: "spiral up into %s.", : "spiral up into %s.",
is_animal(u.ustuck->data) ? surface(u.ux, u.uy) is_animal(u.ustuck->data) ? surface(u.ux, u.uy)
: mon_nam(u.ustuck)); : mon_nam(u.ustuck));
else if (Hallucination) } else if (Hallucination) {
pline("Up, up, and awaaaay! You're walking on air!"); 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."); You("gain control over your movements.");
else } else {
You("start to float in the air!"); You("start to float in the air!");
}
if (u.usteed && !is_floater(u.usteed->data) if (u.usteed && !is_floater(u.usteed->data)
&& !is_flyer(u.usteed->data)) { && !is_flyer(u.usteed->data)) {
if (Lev_at_will) if (Lev_at_will) {
pline("%s magically floats up!", Monnam(u.usteed)); pline("%s magically floats up!", Monnam(u.usteed));
else { } else {
You("cannot stay on %s.", mon_nam(u.usteed)); You("cannot stay on %s.", mon_nam(u.usteed));
dismount_steed(DISMOUNT_GENERIC); dismount_steed(DISMOUNT_GENERIC);
} }
@@ -2768,6 +2775,7 @@ int x, y;
} }
} }
/* stop levitating */
int int
float_down(hmask, emask) float_down(hmask, emask)
long hmask, emask; /* might cancel timeout */ long hmask, emask; /* might cancel timeout */
@@ -2843,20 +2851,18 @@ long hmask, emask; /* might cancel timeout */
} }
if (!trap) { if (!trap) {
trap = t_at(u.ux, u.uy); trap = t_at(u.ux, u.uy);
if (Is_airlevel(&u.uz)) if (Is_airlevel(&u.uz)) {
You("begin to tumble in place."); 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."); You_feel("heavier.");
/* u.uinwater msgs already in spoteffects()/drown() */ /* u.uinwater msgs already in spoteffects()/drown() */
else if (!u.uinwater && !no_msg) { } else if (!u.uinwater && !no_msg) {
if (!(emask & W_SADDLE)) { if (!(emask & W_SADDLE)) {
if (Sokoban && trap) { if (Sokoban && trap) {
/* Justification elsewhere for Sokoban traps /* Justification elsewhere for Sokoban traps is based
* is based on air currents. This is * on air currents. This is consistent with that.
* consistent with that. * The unexpected additional force of the air currents
* The unexpected additional force of the * once levitation ceases knocks you off your feet.
* air currents once levitation
* ceases knocks you off your feet.
*/ */
if (Hallucination) if (Hallucination)
pline("Bummer! You've crashed."); pline("Bummer! You've crashed.");
@@ -2869,12 +2875,14 @@ long hmask, emask; /* might cancel timeout */
} else if (u.usteed && (is_floater(u.usteed->data) } else if (u.usteed && (is_floater(u.usteed->data)
|| is_flyer(u.usteed->data))) { || is_flyer(u.usteed->data))) {
You("settle more firmly in the saddle."); You("settle more firmly in the saddle.");
} else if (Hallucination) } else if (Hallucination) {
pline("Bummer! You've %s.", is_pool(u.ux, u.uy) pline("Bummer! You've %s.",
? "splashed down" is_pool(u.ux, u.uy)
: "hit the ground"); ? "splashed down"
else : "hit the ground");
} else {
You("float gently to the %s.", surface(u.ux, u.uy)); You("float gently to the %s.", surface(u.ux, u.uy));
}
} }
} }
} }
@@ -2882,8 +2890,7 @@ long hmask, emask; /* might cancel timeout */
/* can't rely on u.uz0 for detecting trap door-induced level change; /* 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 */ it gets changed to reflect the new level before we can check it */
assign_level(&current_dungeon_level, &u.uz); assign_level(&current_dungeon_level, &u.uz);
if (trap) {
if (trap)
switch (trap->ttyp) { switch (trap->ttyp) {
case STATUE_TRAP: case STATUE_TRAP:
break; break;
@@ -2896,7 +2903,7 @@ long hmask, emask; /* might cancel timeout */
if (!u.utrap) /* not already in the trap */ if (!u.utrap) /* not already in the trap */
dotrap(trap, 0); dotrap(trap, 0);
} }
}
if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow
/* falling through trap door calls goto_level, /* falling through trap door calls goto_level,
and goto_level does its own pickup() call */ and goto_level does its own pickup() call */
@@ -3174,9 +3181,9 @@ xchar x, y;
return TRUE; return TRUE;
} else if (!force && (Luck + 5) > rn2(20)) { } else if (!force && (Luck + 5) > rn2(20)) {
/* chance per item of sustaining damage: /* chance per item of sustaining damage:
* max luck (Luck==13): 10% * max luck (Luck==13): 10%
* avg luck (Luck==0): 75% * avg luck (Luck==0): 75%
* awful luck (Luck<-4): 100% * awful luck (Luck<-4): 100%
*/ */
return FALSE; return FALSE;
} else if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) { } else if (obj->oclass == SCROLL_CLASS || obj->oclass == SPBOOK_CLASS) {
@@ -3318,9 +3325,9 @@ boolean force;
return ER_NOTHING; return ER_NOTHING;
} else if (!force && (Luck + 5) > rn2(20)) { } else if (!force && (Luck + 5) > rn2(20)) {
/* chance per item of sustaining damage: /* chance per item of sustaining damage:
* max luck: 10% * max luck: 10%
* avg luck (Luck==0): 75% * avg luck (Luck==0): 75%
* awful luck (Luck<-4): 100% * awful luck (Luck<-4): 100%
*/ */
return ER_NOTHING; return ER_NOTHING;
} else if (obj->oclass == SCROLL_CLASS) { } else if (obj->oclass == SCROLL_CLASS) {
@@ -3492,9 +3499,8 @@ boolean *lostsome;
return TRUE; return TRUE;
} }
/*
* return(TRUE) == player relocated /* return TRUE iff player relocated */
*/
boolean boolean
drown() drown()
{ {
@@ -3577,9 +3583,9 @@ drown()
} }
crawl_ok = FALSE; crawl_ok = FALSE;
x = y = 0; /* lint suppression */ x = y = 0; /* lint suppression */
/* if sleeping, wake up now so that we don't crawl out of water /* 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 while still asleep; we can't do that the same way that waking
due to combat is handled; note unmul() clears u.usleep */ due to combat is handled; note unmul() clears u.usleep */
if (u.usleep) if (u.usleep)
unmul("Suddenly you wake up!"); unmul("Suddenly you wake up!");
/* being doused will revive from fainting */ /* being doused will revive from fainting */
@@ -3649,7 +3655,7 @@ crawl:
void void
drain_en(n) drain_en(n)
register int n; int n;
{ {
if (!u.uenmax) { if (!u.uenmax) {
/* energy is completely gone */ /* energy is completely gone */
@@ -3671,7 +3677,9 @@ register int n;
} }
} }
int dountrap() /* disarm a trap */ /* disarm a trap */
int
dountrap()
{ {
if (near_capacity() >= HVY_ENCUMBER) { if (near_capacity() >= HVY_ENCUMBER) {
pline("You're too strained to do that."); pline("You're too strained to do that.");
@@ -3843,6 +3851,7 @@ boolean force_failure;
} else if (ttype == WEB) { } else if (ttype == WEB) {
if (!webmaker(youmonst.data)) { if (!webmaker(youmonst.data)) {
struct trap *ttmp2 = maketrap(u.ux, u.uy, WEB); struct trap *ttmp2 = maketrap(u.ux, u.uy, WEB);
if (ttmp2) { if (ttmp2) {
pline_The( pline_The(
"webbing sticks to you. You're caught too!"); "webbing sticks to you. You're caught too!");
@@ -3893,7 +3902,8 @@ struct monst *mtmp;
} }
} }
STATIC_OVL int disarm_holdingtrap(ttmp) /* Helge Hafting */ STATIC_OVL int
disarm_holdingtrap(ttmp) /* Helge Hafting */
struct trap *ttmp; struct trap *ttmp;
{ {
struct monst *mtmp; struct monst *mtmp;
@@ -3925,7 +3935,8 @@ struct trap *ttmp;
return 1; return 1;
} }
STATIC_OVL int disarm_landmine(ttmp) /* Helge Hafting */ STATIC_OVL int
disarm_landmine(ttmp) /* Helge Hafting */
struct trap *ttmp; struct trap *ttmp;
{ {
int fails = try_disarm(ttmp, FALSE); int fails = try_disarm(ttmp, FALSE);
@@ -3954,10 +3965,9 @@ struct trap *ttmp;
if (!obj) if (!obj)
return 0; return 0;
bad_tool = bad_tool = (obj->cursed
(obj->cursed || ((obj->otyp != POT_OIL || obj->lamplit) || ((obj->otyp != POT_OIL || obj->lamplit)
&& (obj->otyp != CAN_OF_GREASE || !obj->spe))); && (obj->otyp != CAN_OF_GREASE || !obj->spe)));
fails = try_disarm(ttmp, bad_tool); fails = try_disarm(ttmp, bad_tool);
if (fails < 2) if (fails < 2)
return fails; return fails;
@@ -4814,11 +4824,11 @@ struct trap *trap;
return FALSE; return FALSE;
} }
/* Destroy a trap that emanates from the floor. */
boolean boolean
delfloortrap(ttmp) delfloortrap(ttmp)
register struct trap *ttmp; register struct trap *ttmp;
{ {
/* Destroy a trap that emanates from the floor. */
/* some of these are arbitrary -dlc */ /* some of these are arbitrary -dlc */
if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP) if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP)
|| (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP) || (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP)
@@ -4837,18 +4847,18 @@ register struct trap *ttmp;
} }
deltrap(ttmp); deltrap(ttmp);
return TRUE; return TRUE;
} else }
return FALSE; return FALSE;
} }
/* used for doors (also tins). can be used for anything else that opens. */ /* used for doors (also tins). can be used for anything else that opens. */
void void
b_trapped(item, bodypart) b_trapped(item, bodypart)
register const char *item; const char *item;
register int bodypart; int bodypart;
{ {
register int lvl = level_difficulty(); int lvl = level_difficulty(),
int dmg = rnd(5 + (lvl < 5 ? lvl : 2 + lvl / 2)); dmg = rnd(5 + (lvl < 5 ? lvl : 2 + lvl / 2));
pline("KABOOM!! %s was booby-trapped!", The(item)); pline("KABOOM!! %s was booby-trapped!", The(item));
wake_nearby(); wake_nearby();