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