-/* $NetBSD: monster.c,v 1.8 2004/01/27 20:30:30 jsm Exp $ */
+/* $NetBSD: monster.c,v 1.13 2008/01/28 05:38:54 dholland Exp $ */
/*
* monster.c Larn is copyrighted 1986 by Noah Morgan.
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: monster.c,v 1.8 2004/01/27 20:30:30 jsm Exp $");
+__RCSID("$NetBSD: monster.c,v 1.13 2008/01/28 05:38:54 dholland Exp $");
#endif /* not lint */
#include <string.h>
if (mon < 1 || mon > MAXMONST + 8) { /* check for monster number
* out of bounds */
beep();
- lprintf("\ncan't createmonst(%d)\n", (long) mon);
+ lprintf("\ncan't createmonst(%ld)\n", (long) mon);
nap(3000);
return;
}
* This routine will return FALSE if at a wall or the dungeon exit on level 1
*/
int
-cgood(x, y, itm, monst)
- int x, y;
- int itm, monst;
+cgood(int x, int y, int theitem, int monst)
{
+#define itm __lose
if ((y >= 0) && (y <= MAXY - 1) && (x >= 0) && (x <= MAXX - 1))
/* within bounds? */
if (item[x][y] != OWALL) /* can't make anything on walls */
/* is it free of items? */
- if (itm == 0 || (item[x][y] == 0))
+ if (theitem == 0 || (item[x][y] == 0))
/* is it free of monsters? */
if (monst == 0 || (mitem[x][y] == 0))
if ((level != 1) || (x != 33) ||
* Please insure that there are 2 spaces before all messages here
*/
void
-speldamage(x)
- int x;
+speldamage(int x)
{
int i, j, clev;
int xl, xh, yl, yh;
- char *p, *kn, *pm;
+ u_char *p, *kn, *pm;
+
if (x >= SPNUM)
return; /* no such spell */
if (c[TIMESTOP]) {
c[DEXCOUNT] += 400;
return;
- case 3:
+ case 3: /* sleep */
i = rnd(3) + 1;
- p = " While the %s slept, you smashed it %d times";
-ws: direct(x, fullhit(i), p, i); /* sleep */
+ direct(x, fullhit(i),
+ " While the %s slept, you smashed it %ld times", i);
return;
case 4: /* charm monster */
/* ----- LEVEL 2 SPELLS ----- */
- case 6:
+ case 6: /* web */
i = rnd(3) + 2;
- p = " While the %s is entangled, you hit %d times";
- goto ws; /* web */
+ direct(x, fullhit(i),
+ " While the %s is entangled, you hit %ld times", i);
+ return;
case 7:
if (c[STRCOUNT] == 0)
return;
default:
- lprintf(" spell %d not available!", (long) x);
+ lprintf(" spell %ld not available!", (long) x);
beep();
return;
};
void
direct(spnum, dam, str, arg)
int spnum, dam, arg;
- char *str;
+ const char *str;
{
int x, y;
int m;
goto fool;
} else {
lastnum = 278;
- lprintf(str, "spell caster (thats you)", (long) arg);
+ lprintf(str, "spell caster (that's you)", (long) arg);
beep();
losehp(dam);
return;
void
godirect(spnum, dam, str, delay, cshow)
int spnum, dam, delay;
- char *str, cshow;
+ const char *str, cshow;
{
- char *p;
+ u_char *p;
int x, y, m;
int dx, dy;
if (spnum < 0 || spnum >= SPNUM || str == 0 || delay < 0)
}
if ((x == playerx) && (y == playery)) { /* if energy hits player */
cursors();
- lprcat("\nYou are hit my your own magic!");
+ lprcat("\nYou are hit by your own magic!");
beep();
lastnum = 278;
losehp(dam);
* Returns no value.
*/
void
-ifblind(x, y)
- int x, y;
+ifblind(int x, int y)
{
- char *p;
+ const char *p;
+
vxy(&x, &y); /* verify correct x,y coordinates */
if (c[BLINDCOUNT]) {
lastnum = 279;
* Returns no value.
*/
void
-omnidirect(spnum, dam, str)
- int spnum, dam;
- char *str;
+omnidirect(int spnum, int dam, const char *str)
{
int x, y, m;
+
if (spnum < 0 || spnum >= SPNUM || str == 0)
return; /* bad args */
for (x = playerx - 1; x < playerx + 2; x++)
vxy(&x, &y); /* verify coordinates are within range */
lastnum = mster = mitem[x][y];
/*
- * spirit naga's and poltergeist's do nothing if scarab of negate
+ * spirit nagas and poltergeists do nothing if scarab of negate
* spirit
*/
if (c[NEGATESPIRIT] || c[SPIRITPRO])
* Returns nothing of value.
*/
void
-something(level)
- int level;
+something(int cavelevel)
{
int j;
int i;
- if (level < 0 || level > MAXLEVEL + MAXVLEVEL)
+ if (cavelevel < 0 || cavelevel > MAXLEVEL + MAXVLEVEL)
return; /* correct level? */
if (rnd(101) < 8)
- something(level); /* possibly more than one item */
- j = newobject(level, &i);
+ something(cavelevel); /* possibly more than one item */
+ j = newobject(cavelevel, &i);
createitem(j, i);
}
int x, xx, yy;
{
int i, j = 0, k, m;
- char *p = 0;
+ const char *p = NULL;
+
if (c[CANCELLATION])
return (0);
vxy(&xx, &yy); /* verify x & y coordinates */
if (j == 0) /* if rusting did not occur */
switch (m) {
case OLEATHER:
- p = "\nThe %s hit you -- Your lucky you have leather on";
+ p = "\nThe %s hit you -- You're lucky you have leather on";
break;
case OSSPLATE:
- p = "\nThe %s hit you -- Your fortunate to have stainless steel armor!";
+ p = "\nThe %s hit you -- You're fortunate to have stainless steel armor!";
break;
}
else {
i = rnd(15) + 8 - c[AC];
spout: p = "\nThe %s breathes fire at you!";
if (c[FIRERESISTANCE])
- p = "\nThe %s's flame doesn't phase you!";
+ p = "\nThe %s's flame doesn't faze you!";
else
spout2: if (p) {
lprintf(p, lastmonst);
lprintf("\nThe %s dispels the sphere!", monster[m].name);
beep();
rmsphere(x, y); /* remove any spheres that are here */
+ free(sp);
return (c[SPHCAST]);
}
if (m == DISENCHANTRESS) { /* disenchantress cancels spheres */
beep();
boom: sphboom(x, y); /* blow up stuff around sphere */
rmsphere(x, y); /* remove any spheres that are here */
+ free(sp);
return (c[SPHCAST]);
}
if (c[CANCELLATION]) { /* cancellation cancels spheres */
spheres = sp->p;
free((char *) sp2);
} else {
- sp2->p = sp->p;
+ if (sp2)
+ sp2->p = sp->p;
free((char *) sp);
}
break;