-/* $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,
#include <sys/cdefs.h>
#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"
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)
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) {
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);
far ? " in the distance" : "");
}
}
- if (hit) {
+ if (didhit) {
if (magr->data->mlet == 'c' && !magr->cham) {
magr->mhpmax += 3;
if (vis)
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) {
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)) {
}
/* 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);
int
-fightm(mtmp)
- struct monst *mtmp;
+fightm(struct monst *mtmp)
{
struct monst *mon;
for (mon = fmon; mon; mon = mon->nmon)
/* 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.");
}
}
-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;
/* 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;