-/* $NetBSD: monster.c,v 1.16 2008/02/03 21:24:58 dholland Exp $ */
+/* $NetBSD: monster.c,v 1.20 2021/05/02 12:50:45 rillig Exp $ */
/*
* monster.c Larn is copyrighted 1986 by Noah Morgan.
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: monster.c,v 1.16 2008/02/03 21:24:58 dholland Exp $");
+__RCSID("$NetBSD: monster.c,v 1.20 2021/05/02 12:50:45 rillig Exp $");
#endif /* not lint */
#include <string.h>
};
static int cgood(int, int, int, int);
+static void speldamage(int);
+static void loseint(void);
+static int isconfuse(void);
+static int nospell(int, int);
+static int fullhit(int);
+static void direct(int, int, const char *, int);
+static void ifblind(int, int);
+static void tdirect(int);
+static void omnidirect(int, int, const char *);
static int dirsub(int *, int *);
+static void dirpoly(int);
+static int hitm(int, int, int);
static void dropsomething(int);
static int spattack(int, int, int);
+static void sphboom(int, int);
+static void genmonst(void);
/*
* createmonster(monstno) Function to create a monster next to the player
* Returns no value.
*/
void
-createmonster(mon)
- int mon;
+createmonster(int mon)
{
int x, y, k, i;
if (mon < 1 || mon > MAXMONST + 8) { /* check for monster number
* if monst==TRUE check for no monster at this location
* This routine will return FALSE if at a wall or the dungeon exit on level 1
*/
-static int
+static int
cgood(int x, int y, int theitem, int monst)
{
#define itm __lose
* Returns no value, thus we don't know about createitem() failures.
*/
void
-createitem(it, arg)
- int it, arg;
+createitem(int it, int arg)
{
int x, y, k, i;
if (it >= MAXOBJ)
*/
static char eys[] = "\nEnter your spell: ";
void
-cast()
+cast(void)
{
int i, j, a, b, d;
cursors();
* Enter with the spell number, returns no value.
* Please insure that there are 2 spaces before all messages here
*/
-void
+static void
speldamage(int x)
{
int i, j, clev;
*
* No arguments and no return value
*/
-void
-loseint()
+static void
+loseint(void)
{
if (--c[INTELLIGENCE] < 3)
c[INTELLIGENCE] = 3;
* This routine prints out a message saying "You can't aim your magic!"
* returns 0 if not confused, non-zero (time remaining confused) if confused
*/
-int
-isconfuse()
+static int
+isconfuse(void)
{
if (c[CONFUSE]) {
lprcat(" You can't aim your magic!");
* otherwise returns 0
* Enter with the spell number in x, and the monster number in monst.
*/
-int
-nospell(x, monst)
- int x, monst;
+static int
+nospell(int x, int monst)
{
int tmp;
if (x >= SPNUM || monst >= MAXMONST + 8 || monst < 0 || x < 0)
* Function to return hp damage to monster due to a number of full hits
* Enter with the number of full hits being done
*/
-int
-fullhit(xx)
- int xx;
+static int
+fullhit(int xx)
{
int i;
if (xx < 0 || xx > 20)
* lprintf format string in str, and lprintf's argument in arg.
* Returns no value.
*/
-void
-direct(spnum, dam, str, arg)
- int spnum, dam, arg;
- const char *str;
+static void
+direct(int spnum, int dam, const char *str, int arg)
{
int x, y;
int m;
* Returns no value.
*/
void
-godirect(spnum, dam, str, delay, cshow)
- int spnum, dam, delay;
- const char *str, cshow;
+godirect(int spnum, int dam, const char *str, int delay, int cshow_i)
{
u_char *p;
int x, y, m;
int dx, dy;
+ char cshow;
+
+ /* truncate to char width in case it matters */
+ cshow = (char)cshow_i;
+
if (spnum < 0 || spnum >= SPNUM || str == 0 || delay < 0)
return; /* bad args */
if (isconfuse())
* Enter with the coordinates (x,y) of the monster
* Returns no value.
*/
-void
+static void
ifblind(int x, int y)
{
const char *p;
* Enter with the spell number that wants to teleport away
* Returns no value.
*/
-void
-tdirect(spnum)
- int spnum;
+static void
+tdirect(int spnum)
{
int x, y;
int m;
* and the lprintf string to identify the spell in str.
* Returns no value.
*/
-void
+static void
omnidirect(int spnum, int dam, const char *str)
{
int x, y, m;
* Returns index into diroffx[] (0-8).
*/
static int
-dirsub(x, y)
- int *x, *y;
+dirsub(int *x, int *y)
{
int i;
lprcat("\nIn What Direction? ");
switch (ttgetch()) {
case 'b':
i++;
+ /* FALLTHROUGH */
case 'n':
i++;
+ /* FALLTHROUGH */
case 'y':
i++;
+ /* FALLTHROUGH */
case 'u':
i++;
+ /* FALLTHROUGH */
case 'h':
i++;
+ /* FALLTHROUGH */
case 'k':
i++;
+ /* FALLTHROUGH */
case 'l':
i++;
+ /* FALLTHROUGH */
case 'j':
i++;
+ /* FALLTHROUGH */
goto out;
};
out:
* routine are affected.
*/
int
-vxy(x, y)
- int *x, *y;
+vxy(int *x, int *y)
{
int flag = 0;
if (*x < 0) {
* Enter with the spell number in spmun.
* Returns no value.
*/
-void
-dirpoly(spnum)
- int spnum;
+static void
+dirpoly(int spnum)
{
int x, y, m;
if (spnum < 0 || spnum >= SPNUM)
* Returns no value.
*/
void
-hitmonster(x, y)
- int x, y;
+hitmonster(int x, int y)
{
int tmp, monst, damag = 0, flag;
if (c[TIMESTOP])
* This routine is used to specifically damage a monster at a location (x,y)
* Called by hitmonster(x,y)
*/
-int
-hitm(x, y, amt)
- int x, y;
- int amt;
+static int
+hitm(int x, int y, int amt)
{
int monst;
int hpoints, amt2;
* Returns nothing of value.
*/
void
-hitplayer(x, y)
- int x, y;
+hitplayer(int x, int y)
{
int dam, tmp, mster, bias;
vxy(&x, &y); /* verify coordinates are within range */
* Returns nothing of value.
*/
static void
-dropsomething(monst)
- int monst;
+dropsomething(int monst)
{
switch (monst) {
case ORC:
* Returns nothing of value.
*/
void
-dropgold(amount)
- int amount;
+dropgold(int amount)
{
if (amount > 250)
createitem(OMAXGOLD, amount / 100);
OLONGSWORD};
int
-newobject(lev, i)
- int lev, *i;
+newobject(int lev, int *i)
{
int tmp = 32, j;
if (level < 0 || level > MAXLEVEL + MAXVLEVEL)
};
static char spsel[] = {1, 2, 3, 5, 6, 8, 9, 11, 13, 14};
static int
-spattack(x, xx, yy)
- int x, xx, yy;
+spattack(int x, int xx, int yy)
{
int i, j = 0, k, m;
const char *p = NULL;
* Note: if x > c[HP] this routine could kill the player!
*/
void
-checkloss(x)
- int x;
+checkloss(int x)
{
if (x > 0) {
losehp(x);
* Returns the experience gained from all monsters killed
*/
int
-annihilate()
+annihilate(void)
{
int i, j;
long k;
* Returns the number of spheres currently in existence
*/
int
-newsphere(x, y, dir, life)
- int x, y, dir, life;
+newsphere(int x, int y, int dir, int life)
{
int m;
struct sphere *sp;
* Returns the number of spheres currently in existence
*/
int
-rmsphere(x, y)
- int x, y;
+rmsphere(int x, int y)
{
struct sphere *sp, *sp2 = 0;
for (sp = spheres; sp; sp2 = sp, sp = sp->p)
*
* Enter with the coordinates of the blast, Returns no value
*/
-void
-sphboom(x, y)
- int x, y;
+static void
+sphboom(int x, int y)
{
int i, j;
if (c[HOLDMONST])
*
* This is done by setting a flag in the monster[] structure
*/
-void
-genmonst()
+static void
+genmonst(void)
{
int i, j;
cursors();