X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/e0360616809f0f00834009161e54df0d39ef831c..bcbc46f191b73fe1b817d448571b248466e49272:/hack/hack.fight.c diff --git a/hack/hack.fight.c b/hack/hack.fight.c index 86dd2f6b..dc5074cc 100644 --- a/hack/hack.fight.c +++ b/hack/hack.fight.c @@ -1,4 +1,4 @@ -/* $NetBSD: hack.fight.c,v 1.7 2006/03/29 01:18:39 jnemeth Exp $ */ +/* $NetBSD: hack.fight.c,v 1.12 2009/08/12 07:28:40 dholland Exp $ */ /* * Copyright (c) 1985, Stichting Centrum voor Wiskunde en Informatica, @@ -63,7 +63,7 @@ #include #ifndef lint -__RCSID("$NetBSD: hack.fight.c,v 1.7 2006/03/29 01:18:39 jnemeth Exp $"); +__RCSID("$NetBSD: hack.fight.c,v 1.12 2009/08/12 07:28:40 dholland Exp $"); #endif /* not lint */ #include "hack.h" @@ -72,15 +72,17 @@ __RCSID("$NetBSD: hack.fight.c,v 1.7 2006/03/29 01:18:39 jnemeth Exp $"); static boolean far_noise; static long noisetime; +static void monstone(struct monst *); + /* hitmm returns 0 (miss), 1 (hit), or 2 (kill) */ int -hitmm(magr, mdef) - struct monst *magr, *mdef; +hitmm(struct monst *magr, struct monst *mdef) { const struct permonst *pa = magr->data, *pd = mdef->data; - int hit; + int didhit; schar tmp; boolean vis; + if (strchr("Eauy", pa->mlet)) return (0); if (magr->mfroz) @@ -91,8 +93,8 @@ hitmm(magr, mdef) if (mdef->msleep) mdef->msleep = 0; } - hit = (tmp > rnd(20)); - if (hit) + didhit = (tmp > rnd(20)); + if (didhit) mdef->msleep = 0; vis = (cansee(magr->mx, magr->my) && cansee(mdef->mx, mdef->my)); if (vis) { @@ -101,8 +103,8 @@ hitmm(magr, mdef) seemimic(mdef); if (magr->mimic) seemimic(magr); - (void) sprintf(buf, "%s %s", Monnam(magr), - hit ? "hits" : "misses"); + (void) snprintf(buf, sizeof(buf), "%s %s", Monnam(magr), + didhit ? "hits" : "misses"); pline("%s %s.", buf, monnam(mdef)); } else { boolean far = (dist(magr->mx, magr->my) > 15); @@ -113,7 +115,7 @@ hitmm(magr, mdef) far ? " in the distance" : ""); } } - if (hit) { + if (didhit) { if (magr->data->mlet == 'c' && !magr->cham) { magr->mhpmax += 3; if (vis) @@ -121,7 +123,7 @@ hitmm(magr, mdef) else if (mdef->mtame) pline("You have a peculiarly sad feeling for a moment, then it passes."); monstone(mdef); - hit = 2; + didhit = 2; } else if ((mdef->mhp -= d(pa->damn, pa->damd)) < 1) { magr->mhpmax += 1 + rn2(pd->mlevel + 1); if (magr->mtame && magr->mhpmax > 8 * pa->mlevel) { @@ -135,16 +137,15 @@ hitmm(magr, mdef) else if (mdef->mtame) pline("You have a sad feeling for a moment, then it passes."); mondied(mdef); - hit = 2; + didhit = 2; } } - return (hit); + return (didhit); } /* drop (perhaps) a cadaver and remove monster */ void -mondied(mdef) - struct monst *mdef; +mondied(struct monst *mdef) { const struct permonst *pd = mdef->data; if (letter(pd->mlet) && rn2(3)) { @@ -159,9 +160,8 @@ mondied(mdef) } /* drop a rock and remove monster */ -void -monstone(mdef) - struct monst *mdef; +static void +monstone(struct monst *mdef) { if (strchr(mlarge, mdef->data->mlet)) mksobj_at(ENORMOUS_ROCK, mdef->mx, mdef->my); @@ -176,8 +176,7 @@ monstone(mdef) int -fightm(mtmp) - struct monst *mtmp; +fightm(struct monst *mtmp) { struct monst *mon; for (mon = fmon; mon; mon = mon->nmon) @@ -191,12 +190,11 @@ fightm(mtmp) /* u is hit by sth, but not a monster */ int -thitu(tlev, dam, name) - int tlev, dam; - const char *name; +thitu(int tlev, int dam, const char *name) { char buf[BUFSZ]; - setan(name, buf); + + setan(name, buf, sizeof(buf)); if (u.uac + tlev <= rnd(20)) { if (Blind) pline("It misses."); @@ -213,13 +211,11 @@ thitu(tlev, dam, name) } } -char mlarge[] = "bCDdegIlmnoPSsTUwY',&"; +const char mlarge[] = "bCDdegIlmnoPSsTUwY',&"; +/* return TRUE if mon still alive */ boolean -hmon(mon, obj, thrown) /* return TRUE if mon still alive */ - struct monst *mon; - struct obj *obj; - int thrown; +hmon(struct monst *mon, struct obj *obj, int thrown) { int tmp; boolean hittxt = FALSE; @@ -347,8 +343,7 @@ hmon(mon, obj, thrown) /* return TRUE if mon still alive */ /* try to attack; return FALSE if monster evaded */ /* u.dx and u.dy must be set */ int -attack(mtmp) - struct monst *mtmp; +attack(struct monst *mtmp) { schar tmp; boolean malive = TRUE;