Tons of changes; re-indent, use termios, fix warnings, add prototypes...
Games is almost clean; only hack is left...
This commit is contained in:
parent
75e554c27d
commit
a8fba37dbd
@ -1,10 +1,13 @@
|
||||
# $NetBSD: Makefile,v 1.11 1997/10/12 14:21:47 lukem Exp $
|
||||
# $NetBSD: Makefile,v 1.12 1997/10/18 20:03:05 christos Exp $
|
||||
# @(#)Makefile 5.12 (Berkeley) 5/30/93
|
||||
|
||||
# EXTRA
|
||||
# Incorporates code to gather additional performance statistics
|
||||
# SYSV
|
||||
# Use system III/V (instead of V7) type ioctl calls
|
||||
#
|
||||
# TERMIO
|
||||
# Use sysv termio
|
||||
# TERMIOS
|
||||
# Use posix termios
|
||||
# BSD
|
||||
# Use BSD specific features (mostly timer and signal stuff)
|
||||
# BSD4.1
|
||||
@ -52,15 +55,14 @@
|
||||
# NOLOG
|
||||
# Turn off logging.
|
||||
|
||||
WARNS= 0
|
||||
PROG= larn
|
||||
MAN= larn.6
|
||||
CFLAGS+=-DBSD -DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE
|
||||
CFLAGS+=-DBSD -DVER=12 -DSUBVER=0 -DNONAP -DUIDSCORE -DTERMIOS
|
||||
SRCS= main.c object.c create.c tok.c display.c global.c data.c io.c \
|
||||
monster.c store.c diag.c help.c config.c nap.c bill.c scores.c \
|
||||
signal.c moreobj.c movem.c regen.c fortune.c savelev.c
|
||||
DPADD= ${LIBTERM} ${LIBCOMPAT}
|
||||
LDADD= -ltermcap -lcompat
|
||||
DPADD= ${LIBTERM}
|
||||
LDADD= -ltermcap
|
||||
HIDEGAME=hidegame
|
||||
DAT=larnmaze larnopts larn.help
|
||||
FILES=${DAT:S@^@${.CURDIR}/datfiles/@g}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: bill.c,v 1.4 1996/05/22 00:34:35 mrg Exp $ */
|
||||
/* $NetBSD: bill.c,v 1.5 1997/10/18 20:03:06 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
@ -33,11 +33,12 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)bill.c 5.2 (Berkeley) 5/28/91";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: bill.c,v 1.4 1996/05/22 00:34:35 mrg Exp $";
|
||||
__RCSID("$NetBSD: bill.c,v 1.5 1997/10/18 20:03:06 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -48,6 +49,7 @@ static char rcsid[] = "$NetBSD: bill.c,v 1.4 1996/05/22 00:34:35 mrg Exp $";
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
/* bill.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
|
||||
@ -116,17 +118,17 @@ char *mail[] = {
|
||||
};
|
||||
|
||||
/*
|
||||
* function to mail the letters to the player if a winner
|
||||
* function to mail the letters to the player if a winner
|
||||
*/
|
||||
|
||||
void
|
||||
mailbill()
|
||||
{
|
||||
register int i;
|
||||
char fname[32];
|
||||
char buf[128];
|
||||
int i;
|
||||
char fname[32];
|
||||
char buf[128];
|
||||
char **cp;
|
||||
int fd;
|
||||
int fd;
|
||||
|
||||
wait(0);
|
||||
if (fork() == 0) {
|
||||
@ -135,15 +137,15 @@ mailbill()
|
||||
sprintf(fname, "/tmp/#%dlarnmail", getpid());
|
||||
for (i = 0; i < 6; i++) {
|
||||
if ((fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT,
|
||||
0666)) == -1)
|
||||
0666)) == -1)
|
||||
exit(0);
|
||||
while (*cp != NULL) {
|
||||
if (*cp[0] == '1') {
|
||||
sprintf(buf, "\n%d gold pieces back with you from your journey. As the",
|
||||
(long)c[GOLD]);
|
||||
sprintf(buf, "\n%ld gold pieces back with you from your journey. As the",
|
||||
(long) c[GOLD]);
|
||||
write(fd, buf, strlen(buf));
|
||||
} else if (*cp[0] == '2') {
|
||||
sprintf(buf, "\nin preparing your tax bill. You owe %d gold pieces as", (long)c[GOLD]*TAXRATE);
|
||||
sprintf(buf, "\nin preparing your tax bill. You owe %ld gold pieces as", (long) c[GOLD] * TAXRATE);
|
||||
write(fd, buf, strlen(buf));
|
||||
} else
|
||||
write(fd, *cp, strlen(*cp));
|
||||
@ -153,7 +155,7 @@ mailbill()
|
||||
|
||||
close(fd);
|
||||
sprintf(buf, "mail -I %s < %s > /dev/null",
|
||||
loginname, fname);
|
||||
loginname, fname);
|
||||
system(buf);
|
||||
unlink(fname);
|
||||
}
|
||||
|
@ -1,48 +1,50 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: config.c,v 1.4 1995/04/22 07:34:04 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: config.c,v 1.5 1997/10/18 20:03:08 christos Exp $ */
|
||||
|
||||
/*
|
||||
* config.c -- This defines the installation dependent variables.
|
||||
* Some strings are modified later. ANSI C would
|
||||
* allow compile time string concatenation, we must
|
||||
* do runtime concatenation, in main.
|
||||
* config.c -- This defines the installation dependent variables.
|
||||
* Some strings are modified later. ANSI C would
|
||||
* allow compile time string concatenation, we must
|
||||
* do runtime concatenation, in main.
|
||||
*
|
||||
* Larn is copyrighted 1986 by Noah Morgan.
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: config.c,v 1.5 1997/10/18 20:03:08 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "header.h"
|
||||
#include "pathnames.h"
|
||||
|
||||
/*
|
||||
* All these strings will be appended to in main() to be complete filenames
|
||||
* All these strings will be appended to in main() to be complete filenames
|
||||
*/
|
||||
|
||||
/* the game save filename */
|
||||
char savefilename[1024];
|
||||
char savefilename[1024];
|
||||
|
||||
/* the logging file */
|
||||
char logfile[] = _PATH_LOG;
|
||||
char logfile[] = _PATH_LOG;
|
||||
|
||||
/* the help text file */
|
||||
char helpfile[] = _PATH_HELP;
|
||||
char helpfile[] = _PATH_HELP;
|
||||
|
||||
/* the score file */
|
||||
char scorefile[] = _PATH_SCORE;
|
||||
char scorefile[] = _PATH_SCORE;
|
||||
|
||||
/* the maze data file */
|
||||
char larnlevels[] = _PATH_LEVELS;
|
||||
char larnlevels[] = _PATH_LEVELS;
|
||||
|
||||
/* the .larnopts filename */
|
||||
char optsfile[1024] ="/.larnopts";
|
||||
char optsfile[1024] = "/.larnopts";
|
||||
|
||||
/* the player id datafile name */
|
||||
char playerids[] = _PATH_PLAYERIDS;
|
||||
char playerids[] = _PATH_PLAYERIDS;
|
||||
|
||||
char diagfile[] ="Diagfile"; /* the diagnostic filename */
|
||||
char ckpfile[] ="Larn12.0.ckp"; /* the checkpoint filename */
|
||||
char *password ="pvnert(x)"; /* the wizards password <=32 */
|
||||
char psname[PSNAMESIZE]="larn"; /* the process name */
|
||||
char diagfile[] = "Diagfile"; /* the diagnostic filename */
|
||||
char ckpfile[] = "Larn12.0.ckp"; /* the checkpoint filename */
|
||||
char *password = "pvnert(x)"; /* the wizards password <=32 */
|
||||
char psname[PSNAMESIZE] = "larn"; /* the process name */
|
||||
|
||||
#define WIZID 1
|
||||
int wisid=0; /* the user id of the only person who can be wizard */
|
||||
|
||||
int wisid = 0; /* the user id of the only person who can be wizard */
|
||||
|
@ -1,43 +1,56 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: create.c,v 1.5 1997/07/13 20:21:32 christos Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: create.c,v 1.6 1997/10/18 20:03:09 christos Exp $ */
|
||||
|
||||
/* create.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: create.c,v 1.6 1997/10/18 20:03:09 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/* create.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include "header.h"
|
||||
extern char spelknow[],larnlevels[];
|
||||
extern char beenhere[],wizard;
|
||||
extern short level;
|
||||
extern short oldx,oldy;
|
||||
#include "extern.h"
|
||||
#include <unistd.h>
|
||||
static void fillroom __P((int, int));
|
||||
|
||||
/*
|
||||
makeplayer()
|
||||
|
||||
subroutine to create the player and the players attributes
|
||||
this is called at the beginning of a game and at no other time
|
||||
*/
|
||||
void
|
||||
makeplayer()
|
||||
{
|
||||
register int i;
|
||||
scbr(); clear();
|
||||
c[HPMAX]=c[HP]=10; /* start player off with 15 hit points */
|
||||
c[LEVEL]=1; /* player starts at level one */
|
||||
c[SPELLMAX]=c[SPELLS]=1; /* total # spells starts off as 3 */
|
||||
c[REGENCOUNTER]=16; c[ECOUNTER]=96; /*start regeneration correctly*/
|
||||
{
|
||||
int i;
|
||||
scbr();
|
||||
clear();
|
||||
c[HPMAX] = c[HP] = 10; /* start player off with 15 hit points */
|
||||
c[LEVEL] = 1; /* player starts at level one */
|
||||
c[SPELLMAX] = c[SPELLS] = 1; /* total # spells starts off as 3 */
|
||||
c[REGENCOUNTER] = 16;
|
||||
c[ECOUNTER] = 96; /* start regeneration correctly */
|
||||
c[SHIELD] = c[WEAR] = c[WIELD] = -1;
|
||||
for (i=0; i<26; i++) iven[i]=0;
|
||||
spelknow[0]=spelknow[1]=1; /*he knows protection, magic missile*/
|
||||
if (c[HARDGAME]<=0)
|
||||
{
|
||||
iven[0]=OLEATHER; iven[1]=ODAGGER;
|
||||
ivenarg[1]=ivenarg[0]=c[WEAR]=0; c[WIELD]=1;
|
||||
}
|
||||
playerx=rnd(MAXX-2); playery=rnd(MAXY-2);
|
||||
oldx=0; oldy=25;
|
||||
gltime=0; /* time clock starts at zero */
|
||||
cbak[SPELLS] = -50;
|
||||
for (i=0; i<6; i++) c[i]=12; /* make the attributes, ie str, int, etc. */
|
||||
recalc();
|
||||
for (i = 0; i < 26; i++)
|
||||
iven[i] = 0;
|
||||
spelknow[0] = spelknow[1] = 1; /* he knows protection, magic missile */
|
||||
if (c[HARDGAME] <= 0) {
|
||||
iven[0] = OLEATHER;
|
||||
iven[1] = ODAGGER;
|
||||
ivenarg[1] = ivenarg[0] = c[WEAR] = 0;
|
||||
c[WIELD] = 1;
|
||||
}
|
||||
|
||||
playerx = rnd(MAXX - 2);
|
||||
playery = rnd(MAXY - 2);
|
||||
oldx = 0;
|
||||
oldy = 25;
|
||||
gltime = 0; /* time clock starts at zero */
|
||||
cbak[SPELLS] = -50;
|
||||
for (i = 0; i < 6; i++)
|
||||
c[i] = 12; /* make the attributes, ie str, int, etc. */
|
||||
recalc();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
newcavelevel(level)
|
||||
int level;
|
||||
@ -48,27 +61,40 @@ makeplayer()
|
||||
levels will get a few more monsters.
|
||||
Note that it is here we remove genocided monsters from the present level.
|
||||
*/
|
||||
void
|
||||
newcavelevel(x)
|
||||
register int x;
|
||||
{
|
||||
register int i,j;
|
||||
if (beenhere[level]) savelevel(); /* put the level back into storage */
|
||||
level = x; /* get the new level and put in working storage */
|
||||
if (beenhere[x]==0) for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=mitem[j][i]=0;
|
||||
else { getlevel(); sethp(0); goto chgn; }
|
||||
makemaze(x); makeobject(x); beenhere[x]=1; sethp(1);
|
||||
int x;
|
||||
{
|
||||
int i, j;
|
||||
if (beenhere[level])
|
||||
savelevel(); /* put the level back into storage */
|
||||
level = x; /* get the new level and put in working
|
||||
* storage */
|
||||
if (beenhere[x] == 0)
|
||||
for (i = 0; i < MAXY; i++)
|
||||
for (j = 0; j < MAXX; j++)
|
||||
know[j][i] = mitem[j][i] = 0;
|
||||
else {
|
||||
getlevel();
|
||||
sethp(0);
|
||||
goto chgn;
|
||||
}
|
||||
makemaze(x);
|
||||
makeobject(x);
|
||||
beenhere[x] = 1;
|
||||
sethp(1);
|
||||
|
||||
#if WIZID
|
||||
if (wizard || x==0)
|
||||
if (wizard || x == 0)
|
||||
#else
|
||||
if (x==0)
|
||||
if (x == 0)
|
||||
#endif
|
||||
|
||||
for (j=0; j<MAXY; j++)
|
||||
for (i=0; i<MAXX; i++)
|
||||
know[i][j]=1;
|
||||
chgn: checkgen(); /* wipe out any genocided monsters */
|
||||
}
|
||||
for (j = 0; j < MAXY; j++)
|
||||
for (i = 0; i < MAXX; i++)
|
||||
know[i][j] = 1;
|
||||
chgn: checkgen(); /* wipe out any genocided monsters */
|
||||
}
|
||||
|
||||
/*
|
||||
makemaze(level)
|
||||
@ -76,83 +102,119 @@ chgn: checkgen(); /* wipe out any genocided monsters */
|
||||
|
||||
subroutine to make the caverns for a given level. only walls are made.
|
||||
*/
|
||||
static int mx,mxl,mxh,my,myl,myh,tmp2;
|
||||
makemaze(k)
|
||||
int k;
|
||||
{
|
||||
register int i,j,tmp;
|
||||
int z;
|
||||
if (k > 1 && (rnd(17)<=4 || k==MAXLEVEL-1 || k==MAXLEVEL+MAXVLEVEL-1))
|
||||
{
|
||||
if (cannedlevel(k)); return; /* read maze from data file */
|
||||
}
|
||||
if (k==0) tmp=0; else tmp=OWALL;
|
||||
for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) item[j][i]=tmp;
|
||||
if (k==0) return; eat(1,1);
|
||||
if (k==1) item[33][MAXY-1]=0; /* exit from dungeon */
|
||||
|
||||
/* now for open spaces -- not on level 10 */
|
||||
if (k != MAXLEVEL-1)
|
||||
{
|
||||
tmp2 = rnd(3)+3;
|
||||
for (tmp=0; tmp<tmp2; tmp++)
|
||||
{
|
||||
my = rnd(11)+2; myl = my - rnd(2); myh = my + rnd(2);
|
||||
if (k < MAXLEVEL)
|
||||
{
|
||||
mx = rnd(44)+5; mxl = mx - rnd(4); mxh = mx + rnd(12)+3;
|
||||
z=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
mx = rnd(60)+3; mxl = mx - rnd(2); mxh = mx + rnd(2);
|
||||
z = makemonst(k);
|
||||
}
|
||||
for (i=mxl; i<mxh; i++) for (j=myl; j<myh; j++)
|
||||
{ item[i][j]=0;
|
||||
if ((mitem[i][j]=z)) hitp[i][j]=monster[z].hitpoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k!=MAXLEVEL-1) { my=rnd(MAXY-2); for (i=1; i<MAXX-1; i++) item[i][my] = 0; }
|
||||
if (k>1) treasureroom(k);
|
||||
static int mx, mxl, mxh, my, myl, myh, tmp2;
|
||||
void
|
||||
makemaze(k)
|
||||
int k;
|
||||
{
|
||||
int i, j, tmp;
|
||||
int z;
|
||||
if (k > 1 && (rnd(17) <= 4 || k == MAXLEVEL - 1 || k == MAXLEVEL + MAXVLEVEL - 1)) {
|
||||
if (cannedlevel(k));
|
||||
return; /* read maze from data file */
|
||||
}
|
||||
if (k == 0)
|
||||
tmp = 0;
|
||||
else
|
||||
tmp = OWALL;
|
||||
for (i = 0; i < MAXY; i++)
|
||||
for (j = 0; j < MAXX; j++)
|
||||
item[j][i] = tmp;
|
||||
if (k == 0)
|
||||
return;
|
||||
eat(1, 1);
|
||||
if (k == 1)
|
||||
item[33][MAXY - 1] = 0; /* exit from dungeon */
|
||||
|
||||
/* now for open spaces -- not on level 10 */
|
||||
if (k != MAXLEVEL - 1) {
|
||||
tmp2 = rnd(3) + 3;
|
||||
for (tmp = 0; tmp < tmp2; tmp++) {
|
||||
my = rnd(11) + 2;
|
||||
myl = my - rnd(2);
|
||||
myh = my + rnd(2);
|
||||
if (k < MAXLEVEL) {
|
||||
mx = rnd(44) + 5;
|
||||
mxl = mx - rnd(4);
|
||||
mxh = mx + rnd(12) + 3;
|
||||
z = 0;
|
||||
} else {
|
||||
mx = rnd(60) + 3;
|
||||
mxl = mx - rnd(2);
|
||||
mxh = mx + rnd(2);
|
||||
z = makemonst(k);
|
||||
}
|
||||
for (i = mxl; i < mxh; i++)
|
||||
for (j = myl; j < myh; j++) {
|
||||
item[i][j] = 0;
|
||||
if ((mitem[i][j] = z))
|
||||
hitp[i][j] = monster[z].hitpoints;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (k != MAXLEVEL - 1) {
|
||||
my = rnd(MAXY - 2);
|
||||
for (i = 1; i < MAXX - 1; i++)
|
||||
item[i][my] = 0;
|
||||
}
|
||||
if (k > 1)
|
||||
treasureroom(k);
|
||||
}
|
||||
|
||||
/*
|
||||
function to eat away a filled in maze
|
||||
*/
|
||||
eat(xx,yy)
|
||||
register int xx,yy;
|
||||
{
|
||||
register int dir,try;
|
||||
dir = rnd(4); try=2;
|
||||
while (try)
|
||||
{
|
||||
switch(dir)
|
||||
{
|
||||
case 1: if (xx <= 2) break; /* west */
|
||||
if ((item[xx-1][yy]!=OWALL) || (item[xx-2][yy]!=OWALL)) break;
|
||||
item[xx-1][yy] = item[xx-2][yy] = 0;
|
||||
eat(xx-2,yy); break;
|
||||
void
|
||||
eat(xx, yy)
|
||||
int xx, yy;
|
||||
{
|
||||
int dir, try;
|
||||
dir = rnd(4);
|
||||
try = 2;
|
||||
while (try) {
|
||||
switch (dir) {
|
||||
case 1:
|
||||
if (xx <= 2)
|
||||
break; /* west */
|
||||
if ((item[xx - 1][yy] != OWALL) || (item[xx - 2][yy] != OWALL))
|
||||
break;
|
||||
item[xx - 1][yy] = item[xx - 2][yy] = 0;
|
||||
eat(xx - 2, yy);
|
||||
break;
|
||||
|
||||
case 2: if (xx >= MAXX-3) break; /* east */
|
||||
if ((item[xx+1][yy]!=OWALL) || (item[xx+2][yy]!=OWALL)) break;
|
||||
item[xx+1][yy] = item[xx+2][yy] = 0;
|
||||
eat(xx+2,yy); break;
|
||||
case 2:
|
||||
if (xx >= MAXX - 3)
|
||||
break; /* east */
|
||||
if ((item[xx + 1][yy] != OWALL) || (item[xx + 2][yy] != OWALL))
|
||||
break;
|
||||
item[xx + 1][yy] = item[xx + 2][yy] = 0;
|
||||
eat(xx + 2, yy);
|
||||
break;
|
||||
|
||||
case 3: if (yy <= 2) break; /* south */
|
||||
if ((item[xx][yy-1]!=OWALL) || (item[xx][yy-2]!=OWALL)) break;
|
||||
item[xx][yy-1] = item[xx][yy-2] = 0;
|
||||
eat(xx,yy-2); break;
|
||||
case 3:
|
||||
if (yy <= 2)
|
||||
break; /* south */
|
||||
if ((item[xx][yy - 1] != OWALL) || (item[xx][yy - 2] != OWALL))
|
||||
break;
|
||||
item[xx][yy - 1] = item[xx][yy - 2] = 0;
|
||||
eat(xx, yy - 2);
|
||||
break;
|
||||
|
||||
case 4: if (yy >= MAXY-3 ) break; /* north */
|
||||
if ((item[xx][yy+1]!=OWALL) || (item[xx][yy+2]!=OWALL)) break;
|
||||
item[xx][yy+1] = item[xx][yy+2] = 0;
|
||||
eat(xx,yy+2); break;
|
||||
};
|
||||
if (++dir > 4) { dir=1; --try; }
|
||||
case 4:
|
||||
if (yy >= MAXY - 3)
|
||||
break; /* north */
|
||||
if ((item[xx][yy + 1] != OWALL) || (item[xx][yy + 2] != OWALL))
|
||||
break;
|
||||
item[xx][yy + 1] = item[xx][yy + 2] = 0;
|
||||
eat(xx, yy + 2);
|
||||
break;
|
||||
};
|
||||
if (++dir > 4) {
|
||||
dir = 1;
|
||||
--try;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* function to read in a maze from a data file
|
||||
@ -166,122 +228,157 @@ eat(xx,yy)
|
||||
* ~ eye of larn ! cure dianthroritis
|
||||
* - random object
|
||||
*/
|
||||
int
|
||||
cannedlevel(k)
|
||||
int k;
|
||||
{
|
||||
char *row,*lgetl();
|
||||
register int i,j;
|
||||
int it,arg,mit,marg;
|
||||
if (lopen(larnlevels)<0)
|
||||
{
|
||||
write(1,"Can't open the maze data file\n",30); died(-282); return(0);
|
||||
}
|
||||
i=lgetc(); if (i<='0') { died(-282); return(0); }
|
||||
for (i=18*rund(i-'0'); i>0; i--) lgetl(); /* advance to desired maze */
|
||||
for (i=0; i<MAXY; i++)
|
||||
{
|
||||
int k;
|
||||
{
|
||||
char *row;
|
||||
int i, j;
|
||||
int it, arg, mit, marg;
|
||||
if (lopen(larnlevels) < 0) {
|
||||
write(1, "Can't open the maze data file\n", 30);
|
||||
died(-282);
|
||||
return (0);
|
||||
}
|
||||
i = lgetc();
|
||||
if (i <= '0') {
|
||||
died(-282);
|
||||
return (0);
|
||||
}
|
||||
for (i = 18 * rund(i - '0'); i > 0; i--)
|
||||
lgetl(); /* advance to desired maze */
|
||||
for (i = 0; i < MAXY; i++) {
|
||||
row = lgetl();
|
||||
for (j=0; j<MAXX; j++)
|
||||
{
|
||||
for (j = 0; j < MAXX; j++) {
|
||||
it = mit = arg = marg = 0;
|
||||
switch(*row++)
|
||||
{
|
||||
case '#': it = OWALL; break;
|
||||
case 'D': it = OCLOSEDDOOR; arg = rnd(30); break;
|
||||
case '~': if (k!=MAXLEVEL-1) break;
|
||||
it = OLARNEYE;
|
||||
mit = rund(8)+DEMONLORD;
|
||||
marg = monster[mit].hitpoints; break;
|
||||
case '!': if (k!=MAXLEVEL+MAXVLEVEL-1) break;
|
||||
it = OPOTION; arg = 21;
|
||||
mit = DEMONLORD+7;
|
||||
marg = monster[mit].hitpoints; break;
|
||||
case '.': if (k<MAXLEVEL) break;
|
||||
mit = makemonst(k+1);
|
||||
marg = monster[mit].hitpoints; break;
|
||||
case '-': it = newobject(k+1,&arg); break;
|
||||
};
|
||||
item[j][i] = it; iarg[j][i] = arg;
|
||||
mitem[j][i] = mit; hitp[j][i] = marg;
|
||||
switch (*row++) {
|
||||
case '#':
|
||||
it = OWALL;
|
||||
break;
|
||||
case 'D':
|
||||
it = OCLOSEDDOOR;
|
||||
arg = rnd(30);
|
||||
break;
|
||||
case '~':
|
||||
if (k != MAXLEVEL - 1)
|
||||
break;
|
||||
it = OLARNEYE;
|
||||
mit = rund(8) + DEMONLORD;
|
||||
marg = monster[mit].hitpoints;
|
||||
break;
|
||||
case '!':
|
||||
if (k != MAXLEVEL + MAXVLEVEL - 1)
|
||||
break;
|
||||
it = OPOTION;
|
||||
arg = 21;
|
||||
mit = DEMONLORD + 7;
|
||||
marg = monster[mit].hitpoints;
|
||||
break;
|
||||
case '.':
|
||||
if (k < MAXLEVEL)
|
||||
break;
|
||||
mit = makemonst(k + 1);
|
||||
marg = monster[mit].hitpoints;
|
||||
break;
|
||||
case '-':
|
||||
it = newobject(k + 1, &arg);
|
||||
break;
|
||||
};
|
||||
item[j][i] = it;
|
||||
iarg[j][i] = arg;
|
||||
mitem[j][i] = mit;
|
||||
hitp[j][i] = marg;
|
||||
|
||||
#if WIZID
|
||||
know[j][i] = (wizard) ? 1 : 0;
|
||||
#else
|
||||
know[j][i] = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
lrclose();
|
||||
return(1);
|
||||
}
|
||||
lrclose();
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
function to make a treasure room on a level
|
||||
level 10's treasure room has the eye in it and demon lords
|
||||
level V3 has potion of cure dianthroritis and demon prince
|
||||
*/
|
||||
void
|
||||
treasureroom(lv)
|
||||
register int lv;
|
||||
{
|
||||
register int tx,ty,xsize,ysize;
|
||||
int lv;
|
||||
{
|
||||
int tx, ty, xsize, ysize;
|
||||
|
||||
for (tx=1+rnd(10); tx<MAXX-10; tx+=10)
|
||||
if ( (lv==MAXLEVEL-1) || (lv==MAXLEVEL+MAXVLEVEL-1) || rnd(13)==2)
|
||||
{
|
||||
xsize = rnd(6)+3; ysize = rnd(3)+3;
|
||||
ty = rnd(MAXY-9)+1; /* upper left corner of room */
|
||||
if (lv==MAXLEVEL-1 || lv==MAXLEVEL+MAXVLEVEL-1)
|
||||
troom(lv,xsize,ysize,tx=tx+rnd(MAXX-24),ty,rnd(3)+6);
|
||||
else troom(lv,xsize,ysize,tx,ty,rnd(9));
|
||||
for (tx = 1 + rnd(10); tx < MAXX - 10; tx += 10)
|
||||
if ((lv == MAXLEVEL - 1) || (lv == MAXLEVEL + MAXVLEVEL - 1) || rnd(13) == 2) {
|
||||
xsize = rnd(6) + 3;
|
||||
ysize = rnd(3) + 3;
|
||||
ty = rnd(MAXY - 9) + 1; /* upper left corner of room */
|
||||
if (lv == MAXLEVEL - 1 || lv == MAXLEVEL + MAXVLEVEL - 1)
|
||||
troom(lv, xsize, ysize, tx = tx + rnd(MAXX - 24), ty, rnd(3) + 6);
|
||||
else
|
||||
troom(lv, xsize, ysize, tx, ty, rnd(9));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* subroutine to create a treasure room of any size at a given location
|
||||
* room is filled with objects and monsters
|
||||
* subroutine to create a treasure room of any size at a given location
|
||||
* room is filled with objects and monsters
|
||||
* the coordinate given is that of the upper left corner of the room
|
||||
*/
|
||||
troom(lv,xsize,ysize,tx,ty,glyph)
|
||||
int lv,xsize,ysize,tx,ty,glyph;
|
||||
{
|
||||
register int i,j;
|
||||
int tp1,tp2;
|
||||
for (j=ty-1; j<=ty+ysize; j++)
|
||||
for (i=tx-1; i<=tx+xsize; i++) /* clear out space for room */
|
||||
item[i][j]=0;
|
||||
for (j=ty; j<ty+ysize; j++)
|
||||
for (i=tx; i<tx+xsize; i++) /* now put in the walls */
|
||||
{
|
||||
item[i][j]=OWALL; mitem[i][j]=0;
|
||||
void
|
||||
troom(lv, xsize, ysize, tx, ty, glyph)
|
||||
int lv, xsize, ysize, tx, ty, glyph;
|
||||
{
|
||||
int i, j;
|
||||
int tp1, tp2;
|
||||
for (j = ty - 1; j <= ty + ysize; j++)
|
||||
for (i = tx - 1; i <= tx + xsize; i++) /* clear out space for
|
||||
* room */
|
||||
item[i][j] = 0;
|
||||
for (j = ty; j < ty + ysize; j++)
|
||||
for (i = tx; i < tx + xsize; i++) { /* now put in the walls */
|
||||
item[i][j] = OWALL;
|
||||
mitem[i][j] = 0;
|
||||
}
|
||||
for (j = ty + 1; j < ty + ysize - 1; j++)
|
||||
for (i = tx + 1; i < tx + xsize - 1; i++) /* now clear out
|
||||
* interior */
|
||||
item[i][j] = 0;
|
||||
|
||||
switch (rnd(2)) { /* locate the door on the treasure room */
|
||||
case 1:
|
||||
item[i = tx + rund(xsize)][j = ty + (ysize - 1) * rund(2)] = OCLOSEDDOOR;
|
||||
iarg[i][j] = glyph; /* on horizontal walls */
|
||||
break;
|
||||
case 2:
|
||||
item[i = tx + (xsize - 1) * rund(2)][j = ty + rund(ysize)] = OCLOSEDDOOR;
|
||||
iarg[i][j] = glyph; /* on vertical walls */
|
||||
break;
|
||||
};
|
||||
|
||||
tp1 = playerx;
|
||||
tp2 = playery;
|
||||
playery = ty + (ysize >> 1);
|
||||
if (c[HARDGAME] < 2)
|
||||
for (playerx = tx + 1; playerx <= tx + xsize - 2; playerx += 2)
|
||||
for (i = 0, j = rnd(6); i <= j; i++) {
|
||||
something(lv + 2);
|
||||
createmonster(makemonst(lv + 1));
|
||||
}
|
||||
for (j=ty+1; j<ty+ysize-1; j++)
|
||||
for (i=tx+1; i<tx+xsize-1; i++) /* now clear out interior */
|
||||
item[i][j]=0;
|
||||
|
||||
switch(rnd(2)) /* locate the door on the treasure room */
|
||||
{
|
||||
case 1: item[i=tx+rund(xsize)][j=ty+(ysize-1)*rund(2)]=OCLOSEDDOOR;
|
||||
iarg[i][j] = glyph; /* on horizontal walls */
|
||||
break;
|
||||
case 2: item[i=tx+(xsize-1)*rund(2)][j=ty+rund(ysize)]=OCLOSEDDOOR;
|
||||
iarg[i][j] = glyph; /* on vertical walls */
|
||||
break;
|
||||
};
|
||||
|
||||
tp1=playerx; tp2=playery; playery=ty+(ysize>>1);
|
||||
if (c[HARDGAME]<2)
|
||||
for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
|
||||
for (i=0, j=rnd(6); i<=j; i++)
|
||||
{ something(lv+2); createmonster(makemonst(lv+1)); }
|
||||
else
|
||||
for (playerx=tx+1; playerx<=tx+xsize-2; playerx+=2)
|
||||
for (i=0, j=rnd(4); i<=j; i++)
|
||||
{ something(lv+2); createmonster(makemonst(lv+3)); }
|
||||
for (playerx = tx + 1; playerx <= tx + xsize - 2; playerx += 2)
|
||||
for (i = 0, j = rnd(4); i <= j; i++) {
|
||||
something(lv + 2);
|
||||
createmonster(makemonst(lv + 3));
|
||||
}
|
||||
|
||||
playerx = tp1;
|
||||
playery = tp2;
|
||||
}
|
||||
|
||||
playerx=tp1; playery=tp2;
|
||||
}
|
||||
|
||||
static void fillroom();
|
||||
|
||||
/*
|
||||
***********
|
||||
@ -289,180 +386,215 @@ static void fillroom();
|
||||
***********
|
||||
subroutine to create the objects in the maze for the given level
|
||||
*/
|
||||
void
|
||||
makeobject(j)
|
||||
register int j;
|
||||
{
|
||||
register int i;
|
||||
if (j==0)
|
||||
{
|
||||
fillroom(OENTRANCE,0); /* entrance to dungeon */
|
||||
fillroom(ODNDSTORE,0); /* the DND STORE */
|
||||
fillroom(OSCHOOL,0); /* college of Larn */
|
||||
fillroom(OBANK,0); /* 1st national bank of larn */
|
||||
fillroom(OVOLDOWN,0); /* volcano shaft to temple */
|
||||
fillroom(OHOME,0); /* the players home & family */
|
||||
fillroom(OTRADEPOST,0); /* the trading post */
|
||||
fillroom(OLRS,0); /* the larn revenue service */
|
||||
int j;
|
||||
{
|
||||
int i;
|
||||
if (j == 0) {
|
||||
fillroom(OENTRANCE, 0); /* entrance to dungeon */
|
||||
fillroom(ODNDSTORE, 0); /* the DND STORE */
|
||||
fillroom(OSCHOOL, 0); /* college of Larn */
|
||||
fillroom(OBANK, 0); /* 1st national bank of larn */
|
||||
fillroom(OVOLDOWN, 0); /* volcano shaft to temple */
|
||||
fillroom(OHOME, 0); /* the players home & family */
|
||||
fillroom(OTRADEPOST, 0); /* the trading post */
|
||||
fillroom(OLRS, 0); /* the larn revenue service */
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (j == MAXLEVEL)
|
||||
fillroom(OVOLUP, 0); /* volcano shaft up from the temple */
|
||||
|
||||
if (j==MAXLEVEL) fillroom(OVOLUP,0); /* volcano shaft up from the temple */
|
||||
/* make the fixed objects in the maze STAIRS */
|
||||
if ((j > 0) && (j != MAXLEVEL - 1) && (j != MAXLEVEL + MAXVLEVEL - 1))
|
||||
fillroom(OSTAIRSDOWN, 0);
|
||||
if ((j > 1) && (j != MAXLEVEL))
|
||||
fillroom(OSTAIRSUP, 0);
|
||||
|
||||
/* make the fixed objects in the maze STAIRS */
|
||||
if ((j>0) && (j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
|
||||
fillroom(OSTAIRSDOWN,0);
|
||||
if ((j > 1) && (j != MAXLEVEL)) fillroom(OSTAIRSUP,0);
|
||||
/* make the random objects in the maze */
|
||||
|
||||
/* make the random objects in the maze */
|
||||
|
||||
fillmroom(rund(3),OBOOK,j); fillmroom(rund(3),OALTAR,0);
|
||||
fillmroom(rund(3),OSTATUE,0); fillmroom(rund(3),OPIT,0);
|
||||
fillmroom(rund(3),OFOUNTAIN,0); fillmroom( rnd(3)-2,OIVTELETRAP,0);
|
||||
fillmroom(rund(2),OTHRONE,0); fillmroom(rund(2),OMIRROR,0);
|
||||
fillmroom(rund(2),OTRAPARROWIV,0); fillmroom( rnd(3)-2,OIVDARTRAP,0);
|
||||
fillmroom(rund(3),OCOOKIE,0);
|
||||
if (j==1) fillmroom(1,OCHEST,j);
|
||||
else fillmroom(rund(2),OCHEST,j);
|
||||
if ((j != MAXLEVEL-1) && (j != MAXLEVEL+MAXVLEVEL-1))
|
||||
fillmroom(rund(2),OIVTRAPDOOR,0);
|
||||
if (j<=10)
|
||||
{
|
||||
fillmroom((rund(2)),ODIAMOND,rnd(10*j+1)+10);
|
||||
fillmroom(rund(2),ORUBY,rnd(6*j+1)+6);
|
||||
fillmroom(rund(2),OEMERALD,rnd(4*j+1)+4);
|
||||
fillmroom(rund(2),OSAPPHIRE,rnd(3*j+1)+2);
|
||||
}
|
||||
for (i=0; i<rnd(4)+3; i++)
|
||||
fillroom(OPOTION,newpotion()); /* make a POTION */
|
||||
for (i=0; i<rnd(5)+3; i++)
|
||||
fillroom(OSCROLL,newscroll()); /* make a SCROLL */
|
||||
for (i=0; i<rnd(12)+11; i++)
|
||||
fillroom(OGOLDPILE,12*rnd(j+1)+(j<<3)+10); /* make GOLD */
|
||||
if (j==5) fillroom(OBANK2,0); /* branch office of the bank */
|
||||
froom(2,ORING,0); /* a ring mail */
|
||||
froom(1,OSTUDLEATHER,0); /* a studded leather */
|
||||
froom(3,OSPLINT,0); /* a splint mail */
|
||||
froom(5,OSHIELD,rund(3)); /* a shield */
|
||||
froom(2,OBATTLEAXE,rund(3)); /* a battle axe */
|
||||
froom(5,OLONGSWORD,rund(3)); /* a long sword */
|
||||
froom(5,OFLAIL,rund(3)); /* a flail */
|
||||
froom(4,OREGENRING,rund(3)); /* ring of regeneration */
|
||||
froom(1,OPROTRING,rund(3)); /* ring of protection */
|
||||
froom(2,OSTRRING,4); /* ring of strength + 4 */
|
||||
froom(7,OSPEAR,rnd(5)); /* a spear */
|
||||
froom(3,OORBOFDRAGON,0); /* orb of dragon slaying*/
|
||||
froom(4,OSPIRITSCARAB,0); /*scarab of negate spirit*/
|
||||
froom(4,OCUBEofUNDEAD,0); /* cube of undead control */
|
||||
froom(2,ORINGOFEXTRA,0); /* ring of extra regen */
|
||||
froom(3,ONOTHEFT,0); /* device of antitheft */
|
||||
froom(2,OSWORDofSLASHING,0); /* sword of slashing */
|
||||
if (c[BESSMANN]==0)
|
||||
{
|
||||
froom(4,OHAMMER,0);/*Bessman's flailing hammer*/ c[BESSMANN]=1;
|
||||
}
|
||||
if (c[HARDGAME]<3 || (rnd(4)==3))
|
||||
{
|
||||
if (j>3)
|
||||
{
|
||||
froom(3,OSWORD,3); /* sunsword + 3 */
|
||||
froom(5,O2SWORD,rnd(4)); /* a two handed sword */
|
||||
froom(3,OBELT,4); /* belt of striking */
|
||||
froom(3,OENERGYRING,3); /* energy ring */
|
||||
froom(4,OPLATE,5); /* platemail + 5 */
|
||||
}
|
||||
fillmroom(rund(3), OBOOK, j);
|
||||
fillmroom(rund(3), OALTAR, 0);
|
||||
fillmroom(rund(3), OSTATUE, 0);
|
||||
fillmroom(rund(3), OPIT, 0);
|
||||
fillmroom(rund(3), OFOUNTAIN, 0);
|
||||
fillmroom(rnd(3) - 2, OIVTELETRAP, 0);
|
||||
fillmroom(rund(2), OTHRONE, 0);
|
||||
fillmroom(rund(2), OMIRROR, 0);
|
||||
fillmroom(rund(2), OTRAPARROWIV, 0);
|
||||
fillmroom(rnd(3) - 2, OIVDARTRAP, 0);
|
||||
fillmroom(rund(3), OCOOKIE, 0);
|
||||
if (j == 1)
|
||||
fillmroom(1, OCHEST, j);
|
||||
else
|
||||
fillmroom(rund(2), OCHEST, j);
|
||||
if ((j != MAXLEVEL - 1) && (j != MAXLEVEL + MAXVLEVEL - 1))
|
||||
fillmroom(rund(2), OIVTRAPDOOR, 0);
|
||||
if (j <= 10) {
|
||||
fillmroom((rund(2)), ODIAMOND, rnd(10 * j + 1) + 10);
|
||||
fillmroom(rund(2), ORUBY, rnd(6 * j + 1) + 6);
|
||||
fillmroom(rund(2), OEMERALD, rnd(4 * j + 1) + 4);
|
||||
fillmroom(rund(2), OSAPPHIRE, rnd(3 * j + 1) + 2);
|
||||
}
|
||||
for (i = 0; i < rnd(4) + 3; i++)
|
||||
fillroom(OPOTION, newpotion()); /* make a POTION */
|
||||
for (i = 0; i < rnd(5) + 3; i++)
|
||||
fillroom(OSCROLL, newscroll()); /* make a SCROLL */
|
||||
for (i = 0; i < rnd(12) + 11; i++)
|
||||
fillroom(OGOLDPILE, 12 * rnd(j + 1) + (j << 3) + 10); /* make GOLD */
|
||||
if (j == 5)
|
||||
fillroom(OBANK2, 0); /* branch office of the bank */
|
||||
froom(2, ORING, 0); /* a ring mail */
|
||||
froom(1, OSTUDLEATHER, 0); /* a studded leather */
|
||||
froom(3, OSPLINT, 0); /* a splint mail */
|
||||
froom(5, OSHIELD, rund(3)); /* a shield */
|
||||
froom(2, OBATTLEAXE, rund(3)); /* a battle axe */
|
||||
froom(5, OLONGSWORD, rund(3)); /* a long sword */
|
||||
froom(5, OFLAIL, rund(3)); /* a flail */
|
||||
froom(4, OREGENRING, rund(3)); /* ring of regeneration */
|
||||
froom(1, OPROTRING, rund(3)); /* ring of protection */
|
||||
froom(2, OSTRRING, 4); /* ring of strength + 4 */
|
||||
froom(7, OSPEAR, rnd(5)); /* a spear */
|
||||
froom(3, OORBOFDRAGON, 0); /* orb of dragon slaying */
|
||||
froom(4, OSPIRITSCARAB, 0); /* scarab of negate spirit */
|
||||
froom(4, OCUBEofUNDEAD, 0); /* cube of undead control */
|
||||
froom(2, ORINGOFEXTRA, 0); /* ring of extra regen */
|
||||
froom(3, ONOTHEFT, 0); /* device of antitheft */
|
||||
froom(2, OSWORDofSLASHING, 0); /* sword of slashing */
|
||||
if (c[BESSMANN] == 0) {
|
||||
froom(4, OHAMMER, 0); /* Bessman's flailing hammer */
|
||||
c[BESSMANN] = 1;
|
||||
}
|
||||
if (c[HARDGAME] < 3 || (rnd(4) == 3)) {
|
||||
if (j > 3) {
|
||||
froom(3, OSWORD, 3); /* sunsword + 3 */
|
||||
froom(5, O2SWORD, rnd(4)); /* a two handed sword */
|
||||
froom(3, OBELT, 4); /* belt of striking */
|
||||
froom(3, OENERGYRING, 3); /* energy ring */
|
||||
froom(4, OPLATE, 5); /* platemail + 5 */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to fill in a number of objects of the same kind
|
||||
*/
|
||||
|
||||
fillmroom(n,what,arg)
|
||||
int n,arg;
|
||||
char what;
|
||||
{
|
||||
register int i;
|
||||
for (i=0; i<n; i++) fillroom(what,arg);
|
||||
}
|
||||
froom(n,itm,arg)
|
||||
int n,arg;
|
||||
char itm;
|
||||
{ if (rnd(151) < n) fillroom(itm,arg); }
|
||||
void
|
||||
fillmroom(n, what, arg)
|
||||
int n, arg;
|
||||
char what;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
fillroom(what, arg);
|
||||
}
|
||||
void
|
||||
froom(n, itm, arg)
|
||||
int n, arg;
|
||||
char itm;
|
||||
{
|
||||
if (rnd(151) < n)
|
||||
fillroom(itm, arg);
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to put an object into an empty room
|
||||
* uses a random walk
|
||||
*/
|
||||
static void
|
||||
fillroom(what,arg)
|
||||
int arg;
|
||||
char what;
|
||||
{
|
||||
register int x,y;
|
||||
fillroom(what, arg)
|
||||
int arg;
|
||||
char what;
|
||||
{
|
||||
int x, y;
|
||||
|
||||
#ifdef EXTRA
|
||||
c[FILLROOM]++;
|
||||
#endif
|
||||
|
||||
x=rnd(MAXX-2); y=rnd(MAXY-2);
|
||||
while (item[x][y])
|
||||
{
|
||||
x = rnd(MAXX - 2);
|
||||
y = rnd(MAXY - 2);
|
||||
while (item[x][y]) {
|
||||
|
||||
#ifdef EXTRA
|
||||
c[RANDOMWALK]++; /* count up these random walks */
|
||||
c[RANDOMWALK]++;/* count up these random walks */
|
||||
#endif
|
||||
|
||||
x += rnd(3)-2; y += rnd(3)-2;
|
||||
if (x > MAXX-2) x=1; if (x < 1) x=MAXX-2;
|
||||
if (y > MAXY-2) y=1; if (y < 1) y=MAXY-2;
|
||||
}
|
||||
item[x][y]=what; iarg[x][y]=arg;
|
||||
x += rnd(3) - 2;
|
||||
y += rnd(3) - 2;
|
||||
if (x > MAXX - 2)
|
||||
x = 1;
|
||||
if (x < 1)
|
||||
x = MAXX - 2;
|
||||
if (y > MAXY - 2)
|
||||
y = 1;
|
||||
if (y < 1)
|
||||
y = MAXY - 2;
|
||||
}
|
||||
item[x][y] = what;
|
||||
iarg[x][y] = arg;
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to put monsters into an empty room without walls or other
|
||||
monsters
|
||||
*/
|
||||
int
|
||||
fillmonst(what)
|
||||
char what;
|
||||
{
|
||||
register int x,y,trys;
|
||||
for (trys=5; trys>0; --trys) /* max # of creation attempts */
|
||||
{
|
||||
x=rnd(MAXX-2); y=rnd(MAXY-2);
|
||||
if ((item[x][y]==0) && (mitem[x][y]==0) && ((playerx!=x) || (playery!=y)))
|
||||
{
|
||||
mitem[x][y] = what; know[x][y]=0;
|
||||
hitp[x][y] = monster[what].hitpoints; return(0);
|
||||
int what;
|
||||
{
|
||||
int x, y, trys;
|
||||
for (trys = 5; trys > 0; --trys) { /* max # of creation attempts */
|
||||
x = rnd(MAXX - 2);
|
||||
y = rnd(MAXY - 2);
|
||||
if ((item[x][y] == 0) && (mitem[x][y] == 0) && ((playerx != x) || (playery != y))) {
|
||||
mitem[x][y] = what;
|
||||
know[x][y] = 0;
|
||||
hitp[x][y] = monster[what].hitpoints;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
return(-1); /* creation failure */
|
||||
}
|
||||
return (-1); /* creation failure */
|
||||
}
|
||||
|
||||
/*
|
||||
creates an entire set of monsters for a level
|
||||
must be done when entering a new level
|
||||
if sethp(1) then wipe out old monsters else leave them there
|
||||
*/
|
||||
void
|
||||
sethp(flg)
|
||||
int flg;
|
||||
{
|
||||
register int i,j;
|
||||
if (flg) for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) stealth[j][i]=0;
|
||||
if (level==0) { c[TELEFLAG]=0; return; } /* if teleported and found level 1 then know level we are on */
|
||||
if (flg) j = rnd(12) + 2 + (level>>1); else j = (level>>1) + 1;
|
||||
for (i=0; i<j; i++) fillmonst(makemonst(level));
|
||||
int flg;
|
||||
{
|
||||
int i, j;
|
||||
if (flg)
|
||||
for (i = 0; i < MAXY; i++)
|
||||
for (j = 0; j < MAXX; j++)
|
||||
stealth[j][i] = 0;
|
||||
if (level == 0) {
|
||||
c[TELEFLAG] = 0;
|
||||
return;
|
||||
} /* if teleported and found level 1 then know
|
||||
* level we are on */
|
||||
if (flg)
|
||||
j = rnd(12) + 2 + (level >> 1);
|
||||
else
|
||||
j = (level >> 1) + 1;
|
||||
for (i = 0; i < j; i++)
|
||||
fillmonst(makemonst(level));
|
||||
positionplayer();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function to destroy all genocided monsters on the present level
|
||||
*/
|
||||
void
|
||||
checkgen()
|
||||
{
|
||||
register int x,y;
|
||||
for (y=0; y<MAXY; y++)
|
||||
for (x=0; x<MAXX; x++)
|
||||
{
|
||||
int x, y;
|
||||
for (y = 0; y < MAXY; y++)
|
||||
for (x = 0; x < MAXX; x++)
|
||||
if (monster[mitem[x][y]].genocided)
|
||||
mitem[x][y]=0; /* no more monster */
|
||||
}
|
||||
mitem[x][y] = 0; /* no more monster */
|
||||
}
|
||||
|
1003
games/larn/data.c
1003
games/larn/data.c
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,18 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: diag.c,v 1.7 1997/07/13 20:21:34 christos Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: diag.c,v 1.8 1997/10/18 20:03:12 christos Exp $ */
|
||||
|
||||
/* diag.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: diag.c,v 1.8 1997/10/18 20:03:12 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/* diag.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/types.h>
|
||||
#include <sys/times.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "header.h"
|
||||
extern long int initialtime;
|
||||
extern int rmst,maxitm,lasttime;
|
||||
extern char nosignal;
|
||||
#include "extern.h"
|
||||
static struct tms cputime;
|
||||
/*
|
||||
***************************
|
||||
@ -19,47 +22,47 @@ static struct tms cputime;
|
||||
subroutine to print out data for debugging
|
||||
*/
|
||||
#ifdef EXTRA
|
||||
static int rndcount[16];
|
||||
static int rndcount[16];
|
||||
void
|
||||
diag()
|
||||
{
|
||||
register int i,j;
|
||||
int hit,dam;
|
||||
cursors(); lwclose();
|
||||
if (lcreat(diagfile) < 0) /* open the diagnostic file */
|
||||
{
|
||||
lcreat((char*)0); lprcat("\ndiagnostic failure\n"); return(-1);
|
||||
}
|
||||
|
||||
write(1,"\nDiagnosing . . .\n",18);
|
||||
{
|
||||
int i, j;
|
||||
int hit, dam;
|
||||
cursors();
|
||||
lwclose();
|
||||
if (lcreat(diagfile) < 0) { /* open the diagnostic file */
|
||||
lcreat((char *) 0);
|
||||
lprcat("\ndiagnostic failure\n");
|
||||
return (-1);
|
||||
}
|
||||
write(1, "\nDiagnosing . . .\n", 18);
|
||||
lprcat("\n\nBeginning of DIAG diagnostics ----------\n");
|
||||
|
||||
/* for the character attributes */
|
||||
/* for the character attributes */
|
||||
|
||||
lprintf("\n\nPlayer attributes:\n\nHit points: %2d(%2d)",(long)c[HP],(long)c[HPMAX]);
|
||||
lprintf("\n\nPlayer attributes:\n\nHit points: %2d(%2d)", (long) c[HP], (long) c[HPMAX]);
|
||||
lprintf("\ngold: %d Experience: %d Character level: %d Level in caverns: %d",
|
||||
(long)c[GOLD],(long)c[EXPERIENCE],(long)c[LEVEL],(long)level);
|
||||
lprintf("\nTotal types of monsters: %d",(long)MAXMONST+8);
|
||||
(long) c[GOLD], (long) c[EXPERIENCE], (long) c[LEVEL], (long) level);
|
||||
lprintf("\nTotal types of monsters: %d", (long) MAXMONST + 8);
|
||||
|
||||
lprcat("\f\nHere's the dungeon:\n\n");
|
||||
|
||||
i=level;
|
||||
for (j=0; j<MAXLEVEL+MAXVLEVEL; j++)
|
||||
{
|
||||
i = level;
|
||||
for (j = 0; j < MAXLEVEL + MAXVLEVEL; j++) {
|
||||
newcavelevel(j);
|
||||
lprintf("\nMaze for level %s:\n",levelname[level]);
|
||||
lprintf("\nMaze for level %s:\n", levelname[level]);
|
||||
diagdrawscreen();
|
||||
}
|
||||
}
|
||||
newcavelevel(i);
|
||||
|
||||
lprcat("\f\nNow for the monster data:\n\n");
|
||||
lprcat(" Monster Name LEV AC DAM ATT DEF GOLD HP EXP \n");
|
||||
lprcat("--------------------------------------------------------------------------\n");
|
||||
for (i=0; i<=MAXMONST+8; i++)
|
||||
{
|
||||
lprintf("%19s %2d %3d ",monster[i].name,(long)monster[i].level,(long)monster[i].armorclass);
|
||||
lprintf(" %3d %3d %3d ",(long)monster[i].damage,(long)monster[i].attack,(long)monster[i].defense);
|
||||
lprintf("%6d %3d %6d\n",(long)monster[i].gold,(long)monster[i].hitpoints,(long)monster[i].experience);
|
||||
}
|
||||
for (i = 0; i <= MAXMONST + 8; i++) {
|
||||
lprintf("%19s %2d %3d ", monster[i].name, (long) monster[i].level, (long) monster[i].armorclass);
|
||||
lprintf(" %3d %3d %3d ", (long) monster[i].damage, (long) monster[i].attack, (long) monster[i].defense);
|
||||
lprintf("%6d %3d %6d\n", (long) monster[i].gold, (long) monster[i].hitpoints, (long) monster[i].experience);
|
||||
}
|
||||
|
||||
lprcat("\n\nHere's a Table for the to hit percentages\n");
|
||||
lprcat("\n We will be assuming that players level = 2 * monster level");
|
||||
@ -70,249 +73,333 @@ diag()
|
||||
lprcat("\n Each entry is as follows: to hit / damage / number hits to kill\n");
|
||||
lprcat("\n monster WC = 4 WC = 20 WC = 40");
|
||||
lprcat("\n---------------------------------------------------------------");
|
||||
for (i=0; i<=MAXMONST+8; i++)
|
||||
{
|
||||
hit = 2*monster[i].armorclass+2*monster[i].level+16;
|
||||
for (i = 0; i <= MAXMONST + 8; i++) {
|
||||
hit = 2 * monster[i].armorclass + 2 * monster[i].level + 16;
|
||||
dam = 16 - c[HARDGAME];
|
||||
lprintf("\n%20s %2d/%2d/%2d %2d/%2d/%2d %2d/%2d/%2d",
|
||||
monster[i].name,
|
||||
(long)(hit/2),(long)max(0,dam+2),(long)(monster[i].hitpoints/(dam+2)+1),
|
||||
(long)((hit+2)/2),(long)max(0,dam+10),(long)(monster[i].hitpoints/(dam+10)+1),
|
||||
(long)((hit+5)/2),(long)max(0,dam+20),(long)(monster[i].hitpoints/(dam+20)+1));
|
||||
}
|
||||
monster[i].name,
|
||||
(long) (hit / 2), (long) max(0, dam + 2), (long) (monster[i].hitpoints / (dam + 2) + 1),
|
||||
(long) ((hit + 2) / 2), (long) max(0, dam + 10), (long) (monster[i].hitpoints / (dam + 10) + 1),
|
||||
(long) ((hit + 5) / 2), (long) max(0, dam + 20), (long) (monster[i].hitpoints / (dam + 20) + 1));
|
||||
}
|
||||
|
||||
lprcat("\n\nHere's the list of available potions:\n\n");
|
||||
for (i=0; i<MAXPOTION; i++) lprintf("%20s\n",&potionhide[i][1]);
|
||||
for (i = 0; i < MAXPOTION; i++)
|
||||
lprintf("%20s\n", &potionhide[i][1]);
|
||||
lprcat("\n\nHere's the list of available scrolls:\n\n");
|
||||
for (i=0; i<MAXSCROLL; i++) lprintf("%20s\n",&scrollhide[i][1]);
|
||||
for (i = 0; i < MAXSCROLL; i++)
|
||||
lprintf("%20s\n", &scrollhide[i][1]);
|
||||
lprcat("\n\nHere's the spell list:\n\n");
|
||||
lprcat("spell name description\n");
|
||||
lprcat("-------------------------------------------------------------------------------------------\n\n");
|
||||
for (j=0; j<SPNUM; j++)
|
||||
{
|
||||
lprc(' '); lprcat(spelcode[j]);
|
||||
lprintf(" %21s %s\n",spelname[j],speldescript[j]);
|
||||
}
|
||||
for (j = 0; j < SPNUM; j++) {
|
||||
lprc(' ');
|
||||
lprcat(spelcode[j]);
|
||||
lprintf(" %21s %s\n", spelname[j], speldescript[j]);
|
||||
}
|
||||
|
||||
lprcat("\n\nFor the c[] array:\n");
|
||||
for (j=0; j<100; j+=10)
|
||||
{
|
||||
lprintf("\nc[%2d] = ",(long)j); for (i=0; i<9; i++) lprintf("%5d ",(long)c[i+j]);
|
||||
}
|
||||
for (j = 0; j < 100; j += 10) {
|
||||
lprintf("\nc[%2d] = ", (long) j);
|
||||
for (i = 0; i < 9; i++)
|
||||
lprintf("%5d ", (long) c[i + j]);
|
||||
}
|
||||
|
||||
lprcat("\n\nTest of random number generator ----------------");
|
||||
lprcat("\n for 25,000 calls divided into 16 slots\n\n");
|
||||
|
||||
for (i=0; i<16; i++) rndcount[i]=0;
|
||||
for (i=0; i<25000; i++) rndcount[rund(16)]++;
|
||||
for (i=0; i<16; i++) { lprintf(" %5d",(long)rndcount[i]); if (i==7) lprc('\n'); }
|
||||
|
||||
lprcat("\n\n"); lwclose();
|
||||
lcreat((char*)0); lprcat("Done Diagnosing . . .");
|
||||
return(0);
|
||||
for (i = 0; i < 16; i++)
|
||||
rndcount[i] = 0;
|
||||
for (i = 0; i < 25000; i++)
|
||||
rndcount[rund(16)]++;
|
||||
for (i = 0; i < 16; i++) {
|
||||
lprintf(" %5d", (long) rndcount[i]);
|
||||
if (i == 7)
|
||||
lprc('\n');
|
||||
}
|
||||
|
||||
lprcat("\n\n");
|
||||
lwclose();
|
||||
lcreat((char *) 0);
|
||||
lprcat("Done Diagnosing . . .");
|
||||
return (0);
|
||||
}
|
||||
/*
|
||||
subroutine to count the number of occurrences of an object
|
||||
*/
|
||||
int
|
||||
dcount(l)
|
||||
int l;
|
||||
{
|
||||
register int i,j,p;
|
||||
{
|
||||
int i, j, p;
|
||||
int k;
|
||||
k=0;
|
||||
for (i=0; i<MAXX; i++)
|
||||
for (j=0; j<MAXY; j++)
|
||||
for (p=0; p<MAXLEVEL; p++)
|
||||
if (cell[p*MAXX*MAXY+i*MAXY+j].item == l) k++;
|
||||
return(k);
|
||||
}
|
||||
k = 0;
|
||||
for (i = 0; i < MAXX; i++)
|
||||
for (j = 0; j < MAXY; j++)
|
||||
for (p = 0; p < MAXLEVEL; p++)
|
||||
if (cell[p * MAXX * MAXY + i * MAXY + j].item == l)
|
||||
k++;
|
||||
return (k);
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to draw the whole screen as the player knows it
|
||||
*/
|
||||
void
|
||||
diagdrawscreen()
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (i = 0; i < MAXY; i++)
|
||||
/* for the east west walls of this line */
|
||||
{
|
||||
register int i,j,k;
|
||||
|
||||
for (i=0; i<MAXY; i++)
|
||||
|
||||
/* for the east west walls of this line */
|
||||
{
|
||||
for (j=0; j<MAXX; j++) if (k=mitem[j][i]) lprc(monstnamelist[k]); else
|
||||
lprc(objnamelist[item[j][i]]);
|
||||
for (j = 0; j < MAXX; j++)
|
||||
if (k = mitem[j][i])
|
||||
lprc(monstnamelist[k]);
|
||||
else
|
||||
lprc(objnamelist[item[j][i]]);
|
||||
lprc('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
to save the game in a file
|
||||
*/
|
||||
static time_t zzz=0;
|
||||
static time_t zzz = 0;
|
||||
int
|
||||
savegame(fname)
|
||||
char *fname;
|
||||
{
|
||||
register int i,k;
|
||||
register struct sphere *sp;
|
||||
struct stat statbuf;
|
||||
nosignal=1; lflush(); savelevel();
|
||||
ointerest();
|
||||
if (lcreat(fname) < 0)
|
||||
{
|
||||
lcreat((char*)0); lprintf("\nCan't open file <%s> to save game\n",fname);
|
||||
nosignal=0; return(-1);
|
||||
}
|
||||
{
|
||||
int i, k;
|
||||
struct sphere *sp;
|
||||
struct stat statbuf;
|
||||
|
||||
nosignal = 1;
|
||||
lflush();
|
||||
savelevel();
|
||||
ointerest();
|
||||
if (lcreat(fname) < 0) {
|
||||
lcreat((char *) 0);
|
||||
lprintf("\nCan't open file <%s> to save game\n", fname);
|
||||
nosignal = 0;
|
||||
return (-1);
|
||||
}
|
||||
set_score_output();
|
||||
lwrite((char*)beenhere,MAXLEVEL+MAXVLEVEL);
|
||||
for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
|
||||
lwrite((char *) beenhere, MAXLEVEL + MAXVLEVEL);
|
||||
for (k = 0; k < MAXLEVEL + MAXVLEVEL; k++)
|
||||
if (beenhere[k])
|
||||
lwrite((char*)&cell[k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
|
||||
lwrite((char *) &cell[k * MAXX * MAXY], sizeof(struct cel) * MAXY * MAXX);
|
||||
times(&cputime); /* get cpu time */
|
||||
c[CPUTIME] += (cputime.tms_utime+cputime.tms_stime)/60;
|
||||
lwrite((char*)&c[0],100*sizeof(long));
|
||||
lprint((long)gltime); lprc(level);
|
||||
lprc(playerx); lprc(playery);
|
||||
lwrite((char*)iven,26); lwrite((char*)ivenarg,26*sizeof(short));
|
||||
for (k=0; k<MAXSCROLL; k++) lprc(scrollname[k][0]);
|
||||
for (k=0; k<MAXPOTION; k++) lprc(potionname[k][0]);
|
||||
lwrite((char*)spelknow,SPNUM); lprc(wizard);
|
||||
lprc(rmst); /* random monster generation counter */
|
||||
for (i=0; i<90; i++) lprc(itm[i].qty);
|
||||
lwrite((char*)course,25); lprc(cheat); lprc(VERSION);
|
||||
for (i=0; i<MAXMONST; i++) lprc(monster[i].genocided); /* genocide info */
|
||||
for (sp=spheres; sp; sp=sp->p)
|
||||
lwrite((char*)sp,sizeof(struct sphere)); /* save spheres of annihilation */
|
||||
time(&zzz); lprint((long)(zzz-initialtime));
|
||||
lwrite((char*)&zzz,sizeof(long));
|
||||
if (fstat(lfd,&statbuf)< 0) lprint(0L);
|
||||
else lprint((long)statbuf.st_ino); /* inode # */
|
||||
lwclose(); lastmonst[0] = 0;
|
||||
c[CPUTIME] += (cputime.tms_utime + cputime.tms_stime) / 60;
|
||||
lwrite((char *) &c[0], 100 * sizeof(long));
|
||||
lprint((long) gltime);
|
||||
lprc(level);
|
||||
lprc(playerx);
|
||||
lprc(playery);
|
||||
lwrite((char *) iven, 26);
|
||||
lwrite((char *) ivenarg, 26 * sizeof(short));
|
||||
for (k = 0; k < MAXSCROLL; k++)
|
||||
lprc(scrollname[k][0]);
|
||||
for (k = 0; k < MAXPOTION; k++)
|
||||
lprc(potionname[k][0]);
|
||||
lwrite((char *) spelknow, SPNUM);
|
||||
lprc(wizard);
|
||||
lprc(rmst); /* random monster generation counter */
|
||||
for (i = 0; i < 90; i++)
|
||||
lprc(itm[i].qty);
|
||||
lwrite((char *) course, 25);
|
||||
lprc(cheat);
|
||||
lprc(VERSION);
|
||||
for (i = 0; i < MAXMONST; i++)
|
||||
lprc(monster[i].genocided); /* genocide info */
|
||||
for (sp = spheres; sp; sp = sp->p)
|
||||
lwrite((char *) sp, sizeof(struct sphere)); /* save spheres of
|
||||
* annihilation */
|
||||
time(&zzz);
|
||||
lprint((long) (zzz - initialtime));
|
||||
lwrite((char *) &zzz, sizeof(long));
|
||||
if (fstat(lfd, &statbuf) < 0)
|
||||
lprint(0L);
|
||||
else
|
||||
lprint((long) statbuf.st_ino); /* inode # */
|
||||
lwclose();
|
||||
lastmonst[0] = 0;
|
||||
#ifndef VT100
|
||||
setscroll();
|
||||
#endif VT100
|
||||
lcreat((char*)0); nosignal=0;
|
||||
return(0);
|
||||
}
|
||||
#endif /* VT100 */
|
||||
lcreat((char *) 0);
|
||||
nosignal = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
restoregame(fname)
|
||||
char *fname;
|
||||
{
|
||||
register int i,k;
|
||||
register struct sphere *sp,*sp2;
|
||||
struct stat filetimes;
|
||||
cursors(); lprcat("\nRestoring . . ."); lflush();
|
||||
if (lopen(fname) <= 0)
|
||||
{
|
||||
lcreat((char*)0); lprintf("\nCan't open file <%s>to restore game\n",fname);
|
||||
nap(2000); c[GOLD]=c[BANKACCOUNT]=0; died(-265); return;
|
||||
}
|
||||
|
||||
lrfill((char*)beenhere,MAXLEVEL+MAXVLEVEL);
|
||||
for (k=0; k<MAXLEVEL+MAXVLEVEL; k++)
|
||||
char *fname;
|
||||
{
|
||||
int i, k;
|
||||
struct sphere *sp, *sp2;
|
||||
struct stat filetimes;
|
||||
cursors();
|
||||
lprcat("\nRestoring . . .");
|
||||
lflush();
|
||||
if (lopen(fname) <= 0) {
|
||||
lcreat((char *) 0);
|
||||
lprintf("\nCan't open file <%s>to restore game\n", fname);
|
||||
nap(2000);
|
||||
c[GOLD] = c[BANKACCOUNT] = 0;
|
||||
died(-265);
|
||||
return;
|
||||
}
|
||||
lrfill((char *) beenhere, MAXLEVEL + MAXVLEVEL);
|
||||
for (k = 0; k < MAXLEVEL + MAXVLEVEL; k++)
|
||||
if (beenhere[k])
|
||||
lrfill((char*)&cell[k*MAXX*MAXY],sizeof(struct cel)*MAXY*MAXX);
|
||||
lrfill((char *) &cell[k * MAXX * MAXY], sizeof(struct cel) * MAXY * MAXX);
|
||||
|
||||
lrfill((char*)&c[0],100*sizeof(long)); gltime = lrint();
|
||||
lrfill((char *) &c[0], 100 * sizeof(long));
|
||||
gltime = lrint();
|
||||
level = c[CAVELEVEL] = lgetc();
|
||||
playerx = lgetc(); playery = lgetc();
|
||||
lrfill((char*)iven,26); lrfill((char*)ivenarg,26*sizeof(short));
|
||||
for (k=0; k<MAXSCROLL; k++) scrollname[k] = lgetc() ? scrollhide[k] : "";
|
||||
for (k=0; k<MAXPOTION; k++) potionname[k] = lgetc() ? potionhide[k] : "";
|
||||
lrfill((char*)spelknow,SPNUM); wizard = lgetc();
|
||||
rmst = lgetc(); /* random monster creation flag */
|
||||
playerx = lgetc();
|
||||
playery = lgetc();
|
||||
lrfill((char *) iven, 26);
|
||||
lrfill((char *) ivenarg, 26 * sizeof(short));
|
||||
for (k = 0; k < MAXSCROLL; k++)
|
||||
scrollname[k] = lgetc() ? scrollhide[k] : "";
|
||||
for (k = 0; k < MAXPOTION; k++)
|
||||
potionname[k] = lgetc() ? potionhide[k] : "";
|
||||
lrfill((char *) spelknow, SPNUM);
|
||||
wizard = lgetc();
|
||||
rmst = lgetc(); /* random monster creation flag */
|
||||
|
||||
for (i=0; i<90; i++) itm[i].qty = lgetc();
|
||||
lrfill((char*)course,25); cheat = lgetc();
|
||||
if (VERSION != lgetc()) /* version number */
|
||||
{
|
||||
cheat=1;
|
||||
for (i = 0; i < 90; i++)
|
||||
itm[i].qty = lgetc();
|
||||
lrfill((char *) course, 25);
|
||||
cheat = lgetc();
|
||||
if (VERSION != lgetc()) { /* version number */
|
||||
cheat = 1;
|
||||
lprcat("Sorry, But your save file is for an older version of larn\n");
|
||||
nap(2000); c[GOLD]=c[BANKACCOUNT]=0; died(-266); return;
|
||||
}
|
||||
|
||||
for (i=0; i<MAXMONST; i++) monster[i].genocided=lgetc(); /* genocide info */
|
||||
for (sp=0,i=0; i<c[SPHCAST]; i++)
|
||||
{
|
||||
nap(2000);
|
||||
c[GOLD] = c[BANKACCOUNT] = 0;
|
||||
died(-266);
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < MAXMONST; i++)
|
||||
monster[i].genocided = lgetc(); /* genocide info */
|
||||
for (sp = 0, i = 0; i < c[SPHCAST]; i++) {
|
||||
sp2 = sp;
|
||||
sp = (struct sphere *)malloc(sizeof(struct sphere));
|
||||
if (sp==0) { write(2,"Can't malloc() for sphere space\n",32); break; }
|
||||
lrfill((char*)sp,sizeof(struct sphere)); /* get spheres of annihilation */
|
||||
sp->p=0; /* null out pointer */
|
||||
if (i==0) spheres=sp; /* beginning of list */
|
||||
else sp2->p = sp;
|
||||
sp = (struct sphere *) malloc(sizeof(struct sphere));
|
||||
if (sp == 0) {
|
||||
write(2, "Can't malloc() for sphere space\n", 32);
|
||||
break;
|
||||
}
|
||||
lrfill((char *) sp, sizeof(struct sphere)); /* get spheres of
|
||||
* annihilation */
|
||||
sp->p = 0; /* null out pointer */
|
||||
if (i == 0)
|
||||
spheres = sp; /* beginning of list */
|
||||
else
|
||||
sp2->p = sp;
|
||||
}
|
||||
|
||||
time(&zzz);
|
||||
initialtime = zzz-lrint();
|
||||
fstat(fd,&filetimes); /* get the creation and modification time of file */
|
||||
lrfill((char*)&zzz,sizeof(long)); zzz += 6;
|
||||
if (filetimes.st_ctime > zzz) fsorry(); /* file create time */
|
||||
else if (filetimes.st_mtime > zzz) fsorry(); /* file modify time */
|
||||
if (c[HP]<0) { died(284); return; } /* died a post mortem death */
|
||||
|
||||
initialtime = zzz - lrint();
|
||||
fstat(fd, &filetimes); /* get the creation and modification time of
|
||||
* file */
|
||||
lrfill((char *) &zzz, sizeof(long));
|
||||
zzz += 6;
|
||||
if (filetimes.st_ctime > zzz)
|
||||
fsorry(); /* file create time */
|
||||
else if (filetimes.st_mtime > zzz)
|
||||
fsorry(); /* file modify time */
|
||||
if (c[HP] < 0) {
|
||||
died(284);
|
||||
return;
|
||||
} /* died a post mortem death */
|
||||
oldx = oldy = 0;
|
||||
i = lrint(); /* inode # */
|
||||
if (i && (filetimes.st_ino!=i)) fsorry();
|
||||
i = lrint(); /* inode # */
|
||||
if (i && (filetimes.st_ino != i))
|
||||
fsorry();
|
||||
lrclose();
|
||||
if (strcmp(fname,ckpfile) == 0)
|
||||
{
|
||||
if (lappend(fname) < 0) fcheat(); else { lprc(' '); lwclose(); }
|
||||
lcreat((char*)0);
|
||||
if (strcmp(fname, ckpfile) == 0) {
|
||||
if (lappend(fname) < 0)
|
||||
fcheat();
|
||||
else {
|
||||
lprc(' ');
|
||||
lwclose();
|
||||
}
|
||||
else if (unlink(fname) < 0) fcheat(); /* can't unlink save file */
|
||||
/* for the greedy cheater checker */
|
||||
for (k=0; k<6; k++) if (c[k]>99) greedy();
|
||||
if (c[HPMAX]>999 || c[SPELLMAX]>125) greedy();
|
||||
if (c[LEVEL]==25 && c[EXPERIENCE]>skill[24]) /* if patch up lev 25 player */
|
||||
{
|
||||
long tmp;
|
||||
tmp = c[EXPERIENCE]-skill[24]; /* amount to go up */
|
||||
lcreat((char *) 0);
|
||||
} else if (unlink(fname) < 0)
|
||||
fcheat(); /* can't unlink save file */
|
||||
/* for the greedy cheater checker */
|
||||
for (k = 0; k < 6; k++)
|
||||
if (c[k] > 99)
|
||||
greedy();
|
||||
if (c[HPMAX] > 999 || c[SPELLMAX] > 125)
|
||||
greedy();
|
||||
if (c[LEVEL] == 25 && c[EXPERIENCE] > skill[24]) { /* if patch up lev 25
|
||||
* player */
|
||||
long tmp;
|
||||
tmp = c[EXPERIENCE] - skill[24]; /* amount to go up */
|
||||
c[EXPERIENCE] = skill[24];
|
||||
raiseexperience((long)tmp);
|
||||
}
|
||||
getlevel(); lasttime=gltime;
|
||||
raiseexperience((long) tmp);
|
||||
}
|
||||
getlevel();
|
||||
lasttime = gltime;
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to not allow greedy cheaters
|
||||
*/
|
||||
void
|
||||
greedy()
|
||||
{
|
||||
{
|
||||
#if WIZID
|
||||
if (wizard) return;
|
||||
if (wizard)
|
||||
return;
|
||||
#endif
|
||||
|
||||
lprcat("\n\nI am so sorry, but your character is a little TOO good! Since this\n");
|
||||
lprcat("cannot normally happen from an honest game, I must assume that you cheated.\n");
|
||||
lprcat("In that you are GREEDY as well as a CHEATER, I cannot allow this game\n");
|
||||
lprcat("to continue.\n"); nap(5000); c[GOLD]=c[BANKACCOUNT]=0; died(-267); return;
|
||||
}
|
||||
lprcat("to continue.\n");
|
||||
nap(5000);
|
||||
c[GOLD] = c[BANKACCOUNT] = 0;
|
||||
died(-267);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to not allow altered save files and terminate the attempted
|
||||
restart
|
||||
*/
|
||||
void
|
||||
fsorry()
|
||||
{
|
||||
{
|
||||
lprcat("\nSorry, but your savefile has been altered.\n");
|
||||
lprcat("However, seeing as I am a good sport, I will let you play.\n");
|
||||
lprcat("Be advised though, you won't be placed on the normal scoreboard.");
|
||||
cheat = 1; nap(4000);
|
||||
}
|
||||
cheat = 1;
|
||||
nap(4000);
|
||||
}
|
||||
|
||||
/*
|
||||
subroutine to not allow game if save file can't be deleted
|
||||
*/
|
||||
void
|
||||
fcheat()
|
||||
{
|
||||
{
|
||||
#if WIZID
|
||||
if (wizard) return;
|
||||
if (wizard)
|
||||
return;
|
||||
#endif
|
||||
|
||||
lprcat("\nSorry, but your savefile can't be deleted. This can only mean\n");
|
||||
lprcat("that you tried to CHEAT by protecting the directory the savefile\n");
|
||||
lprcat("is in. Since this is unfair to the rest of the larn community, I\n");
|
||||
lprcat("cannot let you play this game.\n");
|
||||
nap(5000); c[GOLD]=c[BANKACCOUNT]=0; died(-268); return;
|
||||
}
|
||||
nap(5000);
|
||||
c[GOLD] = c[BANKACCOUNT] = 0;
|
||||
died(-268);
|
||||
return;
|
||||
}
|
||||
|
@ -1,328 +1,468 @@
|
||||
/* $NetBSD: display.c,v 1.4 1997/10/18 20:03:15 christos Exp $ */
|
||||
|
||||
/* display.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: display.c,v 1.3 1995/03/23 08:33:21 cgd Exp $";
|
||||
__RCSID("$NetBSD: display.c,v 1.4 1997/10/18 20:03:15 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/* display.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
#define makecode(_a,_b,_c) (((_a)<<16) + ((_b)<<8) + (_c))
|
||||
|
||||
static int minx,maxx,miny,maxy,k,m;
|
||||
static char bot1f=0,bot2f=0,bot3f=0;
|
||||
char always=0;
|
||||
static void botsub __P((int, char *));
|
||||
|
||||
static int minx, maxx, miny, maxy, k, m;
|
||||
static char bot1f = 0, bot2f = 0, bot3f = 0;
|
||||
char always = 0;
|
||||
/*
|
||||
bottomline()
|
||||
|
||||
now for the bottom line of the display
|
||||
*/
|
||||
void
|
||||
bottomline()
|
||||
{ recalc(); bot1f=1; }
|
||||
{
|
||||
recalc();
|
||||
bot1f = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bottomhp()
|
||||
{ bot2f=1; }
|
||||
{
|
||||
bot2f = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bottomspell()
|
||||
{ bot3f=1; }
|
||||
{
|
||||
bot3f = 1;
|
||||
}
|
||||
|
||||
void
|
||||
bottomdo()
|
||||
{
|
||||
if (bot1f) { bot3f=bot1f=bot2f=0; bot_linex(); return; }
|
||||
if (bot2f) { bot2f=0; bot_hpx(); }
|
||||
if (bot3f) { bot3f=0; bot_spellx(); }
|
||||
}
|
||||
|
||||
static void botsub();
|
||||
|
||||
bot_linex()
|
||||
{
|
||||
register int i;
|
||||
if (cbak[SPELLS] <= -50 || (always))
|
||||
{
|
||||
cursor( 1,18);
|
||||
if (c[SPELLMAX]>99) lprintf("Spells:%3d(%3d)",(long)c[SPELLS],(long)c[SPELLMAX]);
|
||||
else lprintf("Spells:%3d(%2d) ",(long)c[SPELLS],(long)c[SPELLMAX]);
|
||||
lprintf(" AC: %-3d WC: %-3d Level",(long)c[AC],(long)c[WCLASS]);
|
||||
if (c[LEVEL]>99) lprintf("%3d",(long)c[LEVEL]);
|
||||
else lprintf(" %-2d",(long)c[LEVEL]);
|
||||
lprintf(" Exp: %-9d %s\n",(long)c[EXPERIENCE],class[c[LEVEL]-1]);
|
||||
lprintf("HP: %3d(%3d) STR=%-2d INT=%-2d ",
|
||||
(long)c[HP],(long)c[HPMAX],(long)(c[STRENGTH]+c[STREXTRA]),(long)c[INTELLIGENCE]);
|
||||
lprintf("WIS=%-2d CON=%-2d DEX=%-2d CHA=%-2d LV:",
|
||||
(long)c[WISDOM],(long)c[CONSTITUTION],(long)c[DEXTERITY],(long)c[CHARISMA]);
|
||||
|
||||
if ((level==0) || (wizard)) c[TELEFLAG]=0;
|
||||
if (c[TELEFLAG]) lprcat(" ?"); else lprcat(levelname[level]);
|
||||
lprintf(" Gold: %-6d",(long)c[GOLD]);
|
||||
always=1; botside();
|
||||
c[TMP] = c[STRENGTH]+c[STREXTRA];
|
||||
for (i=0; i<100; i++) cbak[i]=c[i];
|
||||
{
|
||||
if (bot1f) {
|
||||
bot3f = bot1f = bot2f = 0;
|
||||
bot_linex();
|
||||
return;
|
||||
}
|
||||
|
||||
botsub(makecode(SPELLS,8,18),"%3d");
|
||||
if (c[SPELLMAX]>99) botsub(makecode(SPELLMAX,12,18),"%3d)");
|
||||
else botsub(makecode(SPELLMAX,12,18),"%2d) ");
|
||||
botsub(makecode(HP,5,19),"%3d");
|
||||
botsub(makecode(HPMAX,9,19),"%3d");
|
||||
botsub(makecode(AC,21,18),"%-3d");
|
||||
botsub(makecode(WCLASS,30,18),"%-3d");
|
||||
botsub(makecode(EXPERIENCE,49,18),"%-9d");
|
||||
if (c[LEVEL] != cbak[LEVEL])
|
||||
{ cursor(59,18); lprcat(class[c[LEVEL]-1]); }
|
||||
if (c[LEVEL]>99) botsub(makecode(LEVEL,40,18),"%3d");
|
||||
else botsub(makecode(LEVEL,40,18)," %-2d");
|
||||
c[TMP] = c[STRENGTH]+c[STREXTRA]; botsub(makecode(TMP,18,19),"%-2d");
|
||||
botsub(makecode(INTELLIGENCE,25,19),"%-2d");
|
||||
botsub(makecode(WISDOM,32,19),"%-2d");
|
||||
botsub(makecode(CONSTITUTION,39,19),"%-2d");
|
||||
botsub(makecode(DEXTERITY,46,19),"%-2d");
|
||||
botsub(makecode(CHARISMA,53,19),"%-2d");
|
||||
if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG]))
|
||||
{
|
||||
if ((level==0) || (wizard)) c[TELEFLAG]=0;
|
||||
cbak[TELEFLAG] = c[TELEFLAG];
|
||||
cbak[CAVELEVEL] = level; cursor(59,19);
|
||||
if (c[TELEFLAG]) lprcat(" ?"); else lprcat(levelname[level]);
|
||||
}
|
||||
botsub(makecode(GOLD,69,19),"%-6d");
|
||||
botside();
|
||||
}
|
||||
if (bot2f) {
|
||||
bot2f = 0;
|
||||
bot_hpx();
|
||||
}
|
||||
if (bot3f) {
|
||||
bot3f = 0;
|
||||
bot_spellx();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bot_linex()
|
||||
{
|
||||
int i;
|
||||
if (cbak[SPELLS] <= -50 || (always)) {
|
||||
cursor(1, 18);
|
||||
if (c[SPELLMAX] > 99)
|
||||
lprintf("Spells:%3d(%3d)", (long) c[SPELLS], (long) c[SPELLMAX]);
|
||||
else
|
||||
lprintf("Spells:%3d(%2d) ", (long) c[SPELLS], (long) c[SPELLMAX]);
|
||||
lprintf(" AC: %-3d WC: %-3d Level", (long) c[AC], (long) c[WCLASS]);
|
||||
if (c[LEVEL] > 99)
|
||||
lprintf("%3d", (long) c[LEVEL]);
|
||||
else
|
||||
lprintf(" %-2d", (long) c[LEVEL]);
|
||||
lprintf(" Exp: %-9d %s\n", (long) c[EXPERIENCE], class[c[LEVEL] - 1]);
|
||||
lprintf("HP: %3d(%3d) STR=%-2d INT=%-2d ",
|
||||
(long) c[HP], (long) c[HPMAX], (long) (c[STRENGTH] + c[STREXTRA]), (long) c[INTELLIGENCE]);
|
||||
lprintf("WIS=%-2d CON=%-2d DEX=%-2d CHA=%-2d LV:",
|
||||
(long) c[WISDOM], (long) c[CONSTITUTION], (long) c[DEXTERITY], (long) c[CHARISMA]);
|
||||
|
||||
if ((level == 0) || (wizard))
|
||||
c[TELEFLAG] = 0;
|
||||
if (c[TELEFLAG])
|
||||
lprcat(" ?");
|
||||
else
|
||||
lprcat(levelname[level]);
|
||||
lprintf(" Gold: %-6d", (long) c[GOLD]);
|
||||
always = 1;
|
||||
botside();
|
||||
c[TMP] = c[STRENGTH] + c[STREXTRA];
|
||||
for (i = 0; i < 100; i++)
|
||||
cbak[i] = c[i];
|
||||
return;
|
||||
}
|
||||
botsub(makecode(SPELLS, 8, 18), "%3d");
|
||||
if (c[SPELLMAX] > 99)
|
||||
botsub(makecode(SPELLMAX, 12, 18), "%3d)");
|
||||
else
|
||||
botsub(makecode(SPELLMAX, 12, 18), "%2d) ");
|
||||
botsub(makecode(HP, 5, 19), "%3d");
|
||||
botsub(makecode(HPMAX, 9, 19), "%3d");
|
||||
botsub(makecode(AC, 21, 18), "%-3d");
|
||||
botsub(makecode(WCLASS, 30, 18), "%-3d");
|
||||
botsub(makecode(EXPERIENCE, 49, 18), "%-9d");
|
||||
if (c[LEVEL] != cbak[LEVEL]) {
|
||||
cursor(59, 18);
|
||||
lprcat(class[c[LEVEL] - 1]);
|
||||
}
|
||||
if (c[LEVEL] > 99)
|
||||
botsub(makecode(LEVEL, 40, 18), "%3d");
|
||||
else
|
||||
botsub(makecode(LEVEL, 40, 18), " %-2d");
|
||||
c[TMP] = c[STRENGTH] + c[STREXTRA];
|
||||
botsub(makecode(TMP, 18, 19), "%-2d");
|
||||
botsub(makecode(INTELLIGENCE, 25, 19), "%-2d");
|
||||
botsub(makecode(WISDOM, 32, 19), "%-2d");
|
||||
botsub(makecode(CONSTITUTION, 39, 19), "%-2d");
|
||||
botsub(makecode(DEXTERITY, 46, 19), "%-2d");
|
||||
botsub(makecode(CHARISMA, 53, 19), "%-2d");
|
||||
if ((level != cbak[CAVELEVEL]) || (c[TELEFLAG] != cbak[TELEFLAG])) {
|
||||
if ((level == 0) || (wizard))
|
||||
c[TELEFLAG] = 0;
|
||||
cbak[TELEFLAG] = c[TELEFLAG];
|
||||
cbak[CAVELEVEL] = level;
|
||||
cursor(59, 19);
|
||||
if (c[TELEFLAG])
|
||||
lprcat(" ?");
|
||||
else
|
||||
lprcat(levelname[level]);
|
||||
}
|
||||
botsub(makecode(GOLD, 69, 19), "%-6d");
|
||||
botside();
|
||||
}
|
||||
|
||||
/*
|
||||
special subroutine to update only the gold number on the bottomlines
|
||||
called from ogold()
|
||||
*/
|
||||
void
|
||||
bottomgold()
|
||||
{
|
||||
botsub(makecode(GOLD,69,19),"%-6d");
|
||||
/* botsub(GOLD,"%-6d",69,19); */
|
||||
}
|
||||
{
|
||||
botsub(makecode(GOLD, 69, 19), "%-6d");
|
||||
/* botsub(GOLD,"%-6d",69,19); */
|
||||
}
|
||||
|
||||
/*
|
||||
special routine to update hp and level fields on bottom lines
|
||||
called in monster.c hitplayer() and spattack()
|
||||
*/
|
||||
void
|
||||
bot_hpx()
|
||||
{
|
||||
if (c[EXPERIENCE] != cbak[EXPERIENCE])
|
||||
{
|
||||
recalc(); bot_linex();
|
||||
}
|
||||
else botsub(makecode(HP,5,19),"%3d");
|
||||
}
|
||||
{
|
||||
if (c[EXPERIENCE] != cbak[EXPERIENCE]) {
|
||||
recalc();
|
||||
bot_linex();
|
||||
} else
|
||||
botsub(makecode(HP, 5, 19), "%3d");
|
||||
}
|
||||
|
||||
/*
|
||||
special routine to update number of spells called from regen()
|
||||
*/
|
||||
void
|
||||
bot_spellx()
|
||||
{
|
||||
botsub(makecode(SPELLS,9,18),"%2d");
|
||||
}
|
||||
{
|
||||
botsub(makecode(SPELLS, 9, 18), "%2d");
|
||||
}
|
||||
|
||||
/*
|
||||
common subroutine for a more economical bottomline()
|
||||
*/
|
||||
static struct bot_side_def
|
||||
{
|
||||
int typ;
|
||||
char *string;
|
||||
}
|
||||
bot_data[] =
|
||||
{
|
||||
STEALTH,"stealth", UNDEADPRO,"undead pro", SPIRITPRO,"spirit pro",
|
||||
CHARMCOUNT,"Charm", TIMESTOP,"Time Stop", HOLDMONST,"Hold Monst",
|
||||
GIANTSTR,"Giant Str", FIRERESISTANCE,"Fire Resit", DEXCOUNT,"Dexterity",
|
||||
STRCOUNT,"Strength", SCAREMONST,"Scare", HASTESELF,"Haste Self",
|
||||
CANCELLATION,"Cancel", INVISIBILITY,"Invisible", ALTPRO,"Protect 3",
|
||||
PROTECTIONTIME,"Protect 2", WTW,"Wall-Walk"
|
||||
};
|
||||
static struct bot_side_def {
|
||||
int typ;
|
||||
char *string;
|
||||
}
|
||||
bot_data[] =
|
||||
{
|
||||
{ STEALTH, "stealth"},
|
||||
{ UNDEADPRO, "undead pro" },
|
||||
{ SPIRITPRO, "spirit pro" },
|
||||
{ CHARMCOUNT, "Charm"},
|
||||
{ TIMESTOP, "Time Stop" },
|
||||
{ HOLDMONST, "Hold Monst" },
|
||||
{ GIANTSTR, "Giant Str"},
|
||||
{ FIRERESISTANCE, "Fire Resit" },
|
||||
{ DEXCOUNT, "Dexterity" },
|
||||
{ STRCOUNT, "Strength"},
|
||||
{ SCAREMONST, "Scare" },
|
||||
{ HASTESELF, "Haste Self" },
|
||||
{ CANCELLATION, "Cancel"},
|
||||
{ INVISIBILITY, "Invisible" },
|
||||
{ ALTPRO, "Protect 3" },
|
||||
{ PROTECTIONTIME, "Protect 2"},
|
||||
{ WTW, "Wall-Walk" }
|
||||
};
|
||||
|
||||
void
|
||||
botside()
|
||||
{
|
||||
register int i,idx;
|
||||
for (i=0; i<17; i++)
|
||||
{
|
||||
{
|
||||
int i, idx;
|
||||
for (i = 0; i < 17; i++) {
|
||||
idx = bot_data[i].typ;
|
||||
if ((always) || (c[idx] != cbak[idx]))
|
||||
{
|
||||
if ((always) || (cbak[idx] == 0))
|
||||
{ if (c[idx]) { cursor(70,i+1); lprcat(bot_data[i].string); } } else
|
||||
if (c[idx]==0) { cursor(70,i+1); lprcat(" "); }
|
||||
cbak[idx]=c[idx];
|
||||
}
|
||||
if ((always) || (c[idx] != cbak[idx])) {
|
||||
if ((always) || (cbak[idx] == 0)) {
|
||||
if (c[idx]) {
|
||||
cursor(70, i + 1);
|
||||
lprcat(bot_data[i].string);
|
||||
}
|
||||
} else if (c[idx] == 0) {
|
||||
cursor(70, i + 1);
|
||||
lprcat(" ");
|
||||
}
|
||||
cbak[idx] = c[idx];
|
||||
}
|
||||
always=0;
|
||||
}
|
||||
always = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
botsub(idx,str)
|
||||
register int idx;
|
||||
char *str;
|
||||
{
|
||||
register int x,y;
|
||||
y = idx & 0xff; x = (idx>>8) & 0xff; idx >>= 16;
|
||||
if (c[idx] != cbak[idx])
|
||||
{ cbak[idx]=c[idx]; cursor(x,y); lprintf(str,(long)c[idx]); }
|
||||
botsub(idx, str)
|
||||
int idx;
|
||||
char *str;
|
||||
{
|
||||
int x, y;
|
||||
y = idx & 0xff;
|
||||
x = (idx >> 8) & 0xff;
|
||||
idx >>= 16;
|
||||
if (c[idx] != cbak[idx]) {
|
||||
cbak[idx] = c[idx];
|
||||
cursor(x, y);
|
||||
lprintf(str, (long) c[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* subroutine to draw only a section of the screen
|
||||
* only the top section of the screen is updated. If entire lines are being
|
||||
* drawn, then they will be cleared first.
|
||||
* only the top section of the screen is updated.
|
||||
* If entire lines are being drawn, then they will be cleared first.
|
||||
*/
|
||||
int d_xmin=0,d_xmax=MAXX,d_ymin=0,d_ymax=MAXY; /* for limited screen drawing */
|
||||
draws(xmin,xmax,ymin,ymax)
|
||||
int xmin,xmax,ymin,ymax;
|
||||
{
|
||||
register int i,idx;
|
||||
if (xmin==0 && xmax==MAXX) /* clear section of screen as needed */
|
||||
{
|
||||
if (ymin==0) cl_up(79,ymax);
|
||||
else for (i=ymin; i<ymin; i++) cl_line(1,i+1);
|
||||
/* for limited screen drawing */
|
||||
int d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY;
|
||||
|
||||
void
|
||||
draws(xmin, xmax, ymin, ymax)
|
||||
int xmin, xmax, ymin, ymax;
|
||||
{
|
||||
int i, idx;
|
||||
if (xmin == 0 && xmax == MAXX) { /* clear section of screen as
|
||||
* needed */
|
||||
if (ymin == 0)
|
||||
cl_up(79, ymax);
|
||||
else
|
||||
for (i = ymin; i < ymin; i++)
|
||||
cl_line(1, i + 1);
|
||||
xmin = -1;
|
||||
}
|
||||
d_xmin=xmin; d_xmax=xmax; d_ymin=ymin; d_ymax=ymax; /* for limited screen drawing */
|
||||
}
|
||||
d_xmin = xmin;
|
||||
d_xmax = xmax;
|
||||
d_ymin = ymin;
|
||||
d_ymax = ymax; /* for limited screen drawing */
|
||||
drawscreen();
|
||||
if (xmin<=0 && xmax==MAXX) /* draw stuff on right side of screen as needed*/
|
||||
{
|
||||
for (i=ymin; i<ymax; i++)
|
||||
{
|
||||
if (xmin <= 0 && xmax == MAXX) { /* draw stuff on right side
|
||||
* of screen as needed */
|
||||
for (i = ymin; i < ymax; i++) {
|
||||
idx = bot_data[i].typ;
|
||||
if (c[idx])
|
||||
{
|
||||
cursor(70,i+1); lprcat(bot_data[i].string);
|
||||
}
|
||||
cbak[idx]=c[idx];
|
||||
if (c[idx]) {
|
||||
cursor(70, i + 1);
|
||||
lprcat(bot_data[i].string);
|
||||
}
|
||||
cbak[idx] = c[idx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
drawscreen()
|
||||
|
||||
subroutine to redraw the whole screen as the player knows it
|
||||
*/
|
||||
char screen[MAXX][MAXY],d_flag; /* template for the screen */
|
||||
u_char screen[MAXX][MAXY], d_flag; /* template for the screen */
|
||||
void
|
||||
drawscreen()
|
||||
{
|
||||
register int i,j,k;
|
||||
int lastx,lasty; /* variables used to optimize the object printing */
|
||||
if (d_xmin==0 && d_xmax==MAXX && d_ymin==0 && d_ymax==MAXY)
|
||||
{
|
||||
d_flag=1; clear(); /* clear the screen */
|
||||
}
|
||||
else
|
||||
{
|
||||
d_flag=0; cursor(1,1);
|
||||
}
|
||||
if (d_xmin<0)
|
||||
d_xmin=0; /* d_xmin=-1 means display all without bottomline */
|
||||
{
|
||||
int i, j, k;
|
||||
int lastx, lasty; /* variables used to optimize the
|
||||
* object printing */
|
||||
if (d_xmin == 0 && d_xmax == MAXX && d_ymin == 0 && d_ymax == MAXY) {
|
||||
d_flag = 1;
|
||||
clear(); /* clear the screen */
|
||||
} else {
|
||||
d_flag = 0;
|
||||
cursor(1, 1);
|
||||
}
|
||||
if (d_xmin < 0)
|
||||
d_xmin = 0; /* d_xmin=-1 means display all without
|
||||
* bottomline */
|
||||
|
||||
for (i=d_ymin; i<d_ymax; i++)
|
||||
for (j=d_xmin; j<d_xmax; j++)
|
||||
if (know[j][i]==0) screen[j][i] = ' '; else
|
||||
if (k=mitem[j][i]) screen[j][i] = monstnamelist[k]; else
|
||||
if ((k=item[j][i])==OWALL) screen[j][i] = '#';
|
||||
else screen[j][i] = ' ';
|
||||
for (i = d_ymin; i < d_ymax; i++)
|
||||
for (j = d_xmin; j < d_xmax; j++)
|
||||
if (know[j][i] == 0)
|
||||
screen[j][i] = ' ';
|
||||
else if ((k = mitem[j][i]) != 0)
|
||||
screen[j][i] = monstnamelist[k];
|
||||
else if ((k = item[j][i]) == OWALL)
|
||||
screen[j][i] = '#';
|
||||
else
|
||||
screen[j][i] = ' ';
|
||||
|
||||
for (i=d_ymin; i<d_ymax; i++)
|
||||
{
|
||||
j=d_xmin; while ((screen[j][i]==' ') && (j<d_xmax)) j++;
|
||||
for (i = d_ymin; i < d_ymax; i++) {
|
||||
j = d_xmin;
|
||||
while ((screen[j][i] == ' ') && (j < d_xmax))
|
||||
j++;
|
||||
/* was m=0 */
|
||||
if (j >= d_xmax) m=d_xmin; /* don't search backwards if blank line */
|
||||
else
|
||||
{ /* search backwards for end of line */
|
||||
m=d_xmax-1; while ((screen[m][i]==' ') && (m>d_xmin)) --m;
|
||||
if (j<=m) cursor(j+1,i+1); else continue;
|
||||
}
|
||||
while (j <= m)
|
||||
{
|
||||
if (j <= m-3)
|
||||
{
|
||||
for (k=j; k<=j+3; k++) if (screen[k][i] != ' ') k=1000;
|
||||
if (k < 1000)
|
||||
{ while(screen[j][i]==' ' && j<=m) j++; cursor(j+1,i+1); }
|
||||
}
|
||||
lprc(screen[j++][i]);
|
||||
}
|
||||
if (j >= d_xmax)
|
||||
m = d_xmin; /* don't search backwards if blank
|
||||
* line */
|
||||
else { /* search backwards for end of line */
|
||||
m = d_xmax - 1;
|
||||
while ((screen[m][i] == ' ') && (m > d_xmin))
|
||||
--m;
|
||||
if (j <= m)
|
||||
cursor(j + 1, i + 1);
|
||||
else
|
||||
continue;
|
||||
}
|
||||
while (j <= m) {
|
||||
if (j <= m - 3) {
|
||||
for (k = j; k <= j + 3; k++)
|
||||
if (screen[k][i] != ' ')
|
||||
k = 1000;
|
||||
if (k < 1000) {
|
||||
while (screen[j][i] == ' ' && j <= m)
|
||||
j++;
|
||||
cursor(j + 1, i + 1);
|
||||
}
|
||||
}
|
||||
lprc(screen[j++][i]);
|
||||
}
|
||||
}
|
||||
setbold(); /* print out only bold objects now */
|
||||
|
||||
for (lastx=lasty=127, i=d_ymin; i<d_ymax; i++)
|
||||
for (j=d_xmin; j<d_xmax; j++)
|
||||
{
|
||||
if (k=item[j][i])
|
||||
for (lastx = lasty = 127, i = d_ymin; i < d_ymax; i++)
|
||||
for (j = d_xmin; j < d_xmax; j++) {
|
||||
if ((k = item[j][i]) != 0)
|
||||
if (k != OWALL)
|
||||
if ((know[j][i]) && (mitem[j][i]==0))
|
||||
if (objnamelist[k]!=' ')
|
||||
{
|
||||
if (lasty!=i+1 || lastx!=j)
|
||||
cursor(lastx=j+1,lasty=i+1); else lastx++;
|
||||
if ((know[j][i]) && (mitem[j][i] == 0))
|
||||
if (objnamelist[k] != ' ') {
|
||||
if (lasty != i + 1 || lastx != j)
|
||||
cursor(lastx = j + 1, lasty = i + 1);
|
||||
else
|
||||
lastx++;
|
||||
lprc(objnamelist[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resetbold(); if (d_flag) { always=1; botside(); always=1; bot_linex(); }
|
||||
oldx=99;
|
||||
d_xmin = 0 , d_xmax = MAXX , d_ymin = 0 , d_ymax = MAXY; /* for limited screen drawing */
|
||||
resetbold();
|
||||
if (d_flag) {
|
||||
always = 1;
|
||||
botside();
|
||||
always = 1;
|
||||
bot_linex();
|
||||
}
|
||||
|
||||
oldx = 99;
|
||||
d_xmin = 0, d_xmax = MAXX, d_ymin = 0, d_ymax = MAXY; /* for limited screen
|
||||
* drawing */
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
showcell(x,y)
|
||||
|
||||
subroutine to display a cell location on the screen
|
||||
*/
|
||||
showcell(x,y)
|
||||
int x,y;
|
||||
{
|
||||
register int i,j,k,m;
|
||||
if (c[BLINDCOUNT]) return; /* see nothing if blind */
|
||||
if (c[AWARENESS]) { minx = x-3; maxx = x+3; miny = y-3; maxy = y+3; }
|
||||
else { minx = x-1; maxx = x+1; miny = y-1; maxy = y+1; }
|
||||
|
||||
if (minx < 0) minx=0; if (maxx > MAXX-1) maxx = MAXX-1;
|
||||
if (miny < 0) miny=0; if (maxy > MAXY-1) maxy = MAXY-1;
|
||||
|
||||
for (j=miny; j<=maxy; j++)
|
||||
for (m=minx; m<=maxx; m++)
|
||||
if (know[m][j]==0)
|
||||
{
|
||||
cursor(m+1,j+1);
|
||||
x=maxx; while (know[x][j]) --x;
|
||||
for (i=m; i<=x; i++)
|
||||
{
|
||||
if ((k=mitem[i][j]) != 0) lprc(monstnamelist[k]);
|
||||
else switch(k=item[i][j])
|
||||
{
|
||||
case OWALL: case 0: case OIVTELETRAP: case OTRAPARROWIV:
|
||||
case OIVDARTRAP: case OIVTRAPDOOR:
|
||||
lprc(objnamelist[k]); break;
|
||||
|
||||
default: setbold(); lprc(objnamelist[k]); resetbold();
|
||||
};
|
||||
know[i][j]=1;
|
||||
}
|
||||
m = maxx;
|
||||
}
|
||||
void
|
||||
showcell(x, y)
|
||||
int x, y;
|
||||
{
|
||||
int i, j, k, m;
|
||||
if (c[BLINDCOUNT])
|
||||
return; /* see nothing if blind */
|
||||
if (c[AWARENESS]) {
|
||||
minx = x - 3;
|
||||
maxx = x + 3;
|
||||
miny = y - 3;
|
||||
maxy = y + 3;
|
||||
} else {
|
||||
minx = x - 1;
|
||||
maxx = x + 1;
|
||||
miny = y - 1;
|
||||
maxy = y + 1;
|
||||
}
|
||||
|
||||
if (minx < 0)
|
||||
minx = 0;
|
||||
if (maxx > MAXX - 1)
|
||||
maxx = MAXX - 1;
|
||||
if (miny < 0)
|
||||
miny = 0;
|
||||
if (maxy > MAXY - 1)
|
||||
maxy = MAXY - 1;
|
||||
|
||||
for (j = miny; j <= maxy; j++)
|
||||
for (m = minx; m <= maxx; m++)
|
||||
if (know[m][j] == 0) {
|
||||
cursor(m + 1, j + 1);
|
||||
x = maxx;
|
||||
while (know[x][j])
|
||||
--x;
|
||||
for (i = m; i <= x; i++) {
|
||||
if ((k = mitem[i][j]) != 0)
|
||||
lprc(monstnamelist[k]);
|
||||
else
|
||||
switch (k = item[i][j]) {
|
||||
case OWALL:
|
||||
case 0:
|
||||
case OIVTELETRAP:
|
||||
case OTRAPARROWIV:
|
||||
case OIVDARTRAP:
|
||||
case OIVTRAPDOOR:
|
||||
lprc(objnamelist[k]);
|
||||
break;
|
||||
|
||||
default:
|
||||
setbold();
|
||||
lprc(objnamelist[k]);
|
||||
resetbold();
|
||||
};
|
||||
know[i][j] = 1;
|
||||
}
|
||||
m = maxx;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
this routine shows only the spot that is given it. the spaces around
|
||||
these coordinated are not shown
|
||||
used in godirect() in monster.c for missile weapons display
|
||||
*/
|
||||
show1cell(x,y)
|
||||
int x,y;
|
||||
{
|
||||
if (c[BLINDCOUNT]) return; /* see nothing if blind */
|
||||
cursor(x+1,y+1);
|
||||
if ((k=mitem[x][y]) != 0) lprc(monstnamelist[k]);
|
||||
else switch(k=item[x][y])
|
||||
{
|
||||
case OWALL: case 0: case OIVTELETRAP: case OTRAPARROWIV:
|
||||
case OIVDARTRAP: case OIVTRAPDOOR:
|
||||
lprc(objnamelist[k]); break;
|
||||
void
|
||||
show1cell(x, y)
|
||||
int x, y;
|
||||
{
|
||||
if (c[BLINDCOUNT])
|
||||
return; /* see nothing if blind */
|
||||
cursor(x + 1, y + 1);
|
||||
if ((k = mitem[x][y]) != 0)
|
||||
lprc(monstnamelist[k]);
|
||||
else
|
||||
switch (k = item[x][y]) {
|
||||
case OWALL:
|
||||
case 0:
|
||||
case OIVTELETRAP:
|
||||
case OTRAPARROWIV:
|
||||
case OIVDARTRAP:
|
||||
case OIVTRAPDOOR:
|
||||
lprc(objnamelist[k]);
|
||||
break;
|
||||
|
||||
default: setbold(); lprc(objnamelist[k]); resetbold();
|
||||
};
|
||||
know[x][y]|=1; /* we end up knowing about it */
|
||||
}
|
||||
default:
|
||||
setbold();
|
||||
lprc(objnamelist[k]);
|
||||
resetbold();
|
||||
};
|
||||
know[x][y] |= 1; /* we end up knowing about it */
|
||||
}
|
||||
|
||||
/*
|
||||
showplayer()
|
||||
@ -330,11 +470,13 @@ show1cell(x,y)
|
||||
subroutine to show where the player is on the screen
|
||||
cursor values start from 1 up
|
||||
*/
|
||||
void
|
||||
showplayer()
|
||||
{
|
||||
cursor(playerx+1,playery+1);
|
||||
oldx=playerx; oldy=playery;
|
||||
}
|
||||
{
|
||||
cursor(playerx + 1, playery + 1);
|
||||
oldx = playerx;
|
||||
oldy = playery;
|
||||
}
|
||||
|
||||
/*
|
||||
moveplayer(dir)
|
||||
@ -345,94 +487,144 @@ showplayer()
|
||||
nomove is set to 1 to stop the next move (inadvertent monsters hitting
|
||||
players when walking into walls) if player walks off screen or into wall
|
||||
*/
|
||||
short diroffx[] = { 0, 0, 1, 0, -1, 1, -1, 1, -1 };
|
||||
short diroffy[] = { 0, 1, 0, -1, 0, -1, -1, 1, 1 };
|
||||
short diroffx[] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
|
||||
short diroffy[] = {0, 1, 0, -1, 0, -1, -1, 1, 1};
|
||||
int
|
||||
moveplayer(dir)
|
||||
int dir; /* from = present room # direction = [1-north]
|
||||
[2-east] [3-south] [4-west] [5-northeast]
|
||||
[6-northwest] [7-southeast] [8-southwest]
|
||||
if direction=0, don't move--just show where he is */
|
||||
{
|
||||
register int k,m,i,j;
|
||||
if (c[CONFUSE]) if (c[LEVEL]<rnd(30)) dir=rund(9); /*if confused any dir*/
|
||||
k = playerx + diroffx[dir]; m = playery + diroffy[dir];
|
||||
if (k<0 || k>=MAXX || m<0 || m>=MAXY) { nomove=1; return(yrepcount = 0); }
|
||||
i = item[k][m]; j = mitem[k][m];
|
||||
if (i==OWALL && c[WTW]==0) { nomove=1; return(yrepcount = 0); } /* hit a wall */
|
||||
if (k==33 && m==MAXY-1 && level==1)
|
||||
{
|
||||
newcavelevel(0); for (k=0; k<MAXX; k++) for (m=0; m<MAXY; m++)
|
||||
if (item[k][m]==OENTRANCE)
|
||||
{ playerx=k; playery=m; positionplayer(); drawscreen(); return(0); }
|
||||
}
|
||||
if (j>0) { hitmonster(k,m); return(yrepcount = 0); } /* hit a monster*/
|
||||
lastpx = playerx; lastpy = playery;
|
||||
playerx = k; playery = m;
|
||||
if (i && i!=OTRAPARROWIV && i!=OIVTELETRAP && i!=OIVDARTRAP && i!=OIVTRAPDOOR) return(yrepcount = 0); else return(1);
|
||||
int dir; /* from = present room # direction =
|
||||
* [1-north] [2-east] [3-south] [4-west]
|
||||
* [5-northeast] [6-northwest] [7-southeast]
|
||||
* [8-southwest] if direction=0, don't
|
||||
* move--just show where he is */
|
||||
{
|
||||
int k, m, i, j;
|
||||
if (c[CONFUSE])
|
||||
if (c[LEVEL] < rnd(30))
|
||||
dir = rund(9); /* if confused any dir */
|
||||
k = playerx + diroffx[dir];
|
||||
m = playery + diroffy[dir];
|
||||
if (k < 0 || k >= MAXX || m < 0 || m >= MAXY) {
|
||||
nomove = 1;
|
||||
return (yrepcount = 0);
|
||||
}
|
||||
|
||||
i = item[k][m];
|
||||
j = mitem[k][m];
|
||||
if (i == OWALL && c[WTW] == 0) {
|
||||
nomove = 1;
|
||||
return (yrepcount = 0);
|
||||
} /* hit a wall */
|
||||
if (k == 33 && m == MAXY - 1 && level == 1) {
|
||||
newcavelevel(0);
|
||||
for (k = 0; k < MAXX; k++)
|
||||
for (m = 0; m < MAXY; m++)
|
||||
if (item[k][m] == OENTRANCE) {
|
||||
playerx = k;
|
||||
playery = m;
|
||||
positionplayer();
|
||||
drawscreen();
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
if (j > 0) {
|
||||
hitmonster(k, m);
|
||||
return (yrepcount = 0);
|
||||
} /* hit a monster */
|
||||
lastpx = playerx;
|
||||
lastpy = playery;
|
||||
playerx = k;
|
||||
playery = m;
|
||||
if (i && i != OTRAPARROWIV && i != OIVTELETRAP && i != OIVDARTRAP && i != OIVTRAPDOOR)
|
||||
return (yrepcount = 0);
|
||||
else
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* function to show what magic items have been discovered thus far
|
||||
* enter with -1 for just spells, anything else will give scrolls & potions
|
||||
*/
|
||||
static int lincount,count;
|
||||
static int lincount, count;
|
||||
void
|
||||
seemagic(arg)
|
||||
int arg;
|
||||
{
|
||||
register int i,number;
|
||||
count = lincount = 0; nosignal=1;
|
||||
int arg;
|
||||
{
|
||||
int i, number = 0;
|
||||
count = lincount = 0;
|
||||
nosignal = 1;
|
||||
|
||||
if (arg== -1) /* if display spells while casting one */
|
||||
{
|
||||
for (number=i=0; i<SPNUM; i++) if (spelknow[i]) number++;
|
||||
number = (number+2)/3 + 4; /* # lines needed to display */
|
||||
cl_up(79,number); cursor(1,1);
|
||||
}
|
||||
else
|
||||
{
|
||||
resetscroll(); clear();
|
||||
}
|
||||
if (arg == -1) { /* if display spells while casting one */
|
||||
for (number = i = 0; i < SPNUM; i++)
|
||||
if (spelknow[i])
|
||||
number++;
|
||||
number = (number + 2) / 3 + 4; /* # lines needed to display */
|
||||
cl_up(79, number);
|
||||
cursor(1, 1);
|
||||
} else {
|
||||
resetscroll();
|
||||
clear();
|
||||
}
|
||||
|
||||
lprcat("The magic spells you have discovered thus far:\n\n");
|
||||
for (i=0; i<SPNUM; i++)
|
||||
if (spelknow[i])
|
||||
{ lprintf("%s %-20s ",spelcode[i],spelname[i]); seepage(); }
|
||||
|
||||
if (arg== -1)
|
||||
{
|
||||
seepage(); more(); nosignal=0;
|
||||
draws(0,MAXX,0,number); return;
|
||||
for (i = 0; i < SPNUM; i++)
|
||||
if (spelknow[i]) {
|
||||
lprintf("%s %-20s ", spelcode[i], spelname[i]);
|
||||
seepage();
|
||||
}
|
||||
|
||||
lincount += 3; if (count!=0) { count=2; seepage(); }
|
||||
|
||||
lprcat("\nThe magic scrolls you have found to date are:\n\n");
|
||||
count=0;
|
||||
for (i=0; i<MAXSCROLL; i++)
|
||||
if (scrollname[i][0])
|
||||
if (scrollname[i][1]!=' ')
|
||||
{ lprintf("%-26s",&scrollname[i][1]); seepage(); }
|
||||
|
||||
lincount += 3; if (count!=0) { count=2; seepage(); }
|
||||
|
||||
lprcat("\nThe magic potions you have found to date are:\n\n");
|
||||
count=0;
|
||||
for (i=0; i<MAXPOTION; i++)
|
||||
if (potionname[i][0])
|
||||
if (potionname[i][1]!=' ')
|
||||
{ lprintf("%-26s",&potionname[i][1]); seepage(); }
|
||||
|
||||
if (lincount!=0) more(); nosignal=0; setscroll(); drawscreen();
|
||||
if (arg == -1) {
|
||||
seepage();
|
||||
more();
|
||||
nosignal = 0;
|
||||
draws(0, MAXX, 0, number);
|
||||
return;
|
||||
}
|
||||
lincount += 3;
|
||||
if (count != 0) {
|
||||
count = 2;
|
||||
seepage();
|
||||
}
|
||||
lprcat("\nThe magic scrolls you have found to date are:\n\n");
|
||||
count = 0;
|
||||
for (i = 0; i < MAXSCROLL; i++)
|
||||
if (scrollname[i][0])
|
||||
if (scrollname[i][1] != ' ') {
|
||||
lprintf("%-26s", &scrollname[i][1]);
|
||||
seepage();
|
||||
}
|
||||
lincount += 3;
|
||||
if (count != 0) {
|
||||
count = 2;
|
||||
seepage();
|
||||
}
|
||||
lprcat("\nThe magic potions you have found to date are:\n\n");
|
||||
count = 0;
|
||||
for (i = 0; i < MAXPOTION; i++)
|
||||
if (potionname[i][0])
|
||||
if (potionname[i][1] != ' ') {
|
||||
lprintf("%-26s", &potionname[i][1]);
|
||||
seepage();
|
||||
}
|
||||
if (lincount != 0)
|
||||
more();
|
||||
nosignal = 0;
|
||||
setscroll();
|
||||
drawscreen();
|
||||
}
|
||||
|
||||
/*
|
||||
* subroutine to paginate the seemagic function
|
||||
*/
|
||||
void
|
||||
seepage()
|
||||
{
|
||||
if (++count==3)
|
||||
{
|
||||
lincount++; count=0; lprc('\n');
|
||||
if (lincount>17) { lincount=0; more(); clear(); }
|
||||
{
|
||||
if (++count == 3) {
|
||||
lincount++;
|
||||
count = 0;
|
||||
lprc('\n');
|
||||
if (lincount > 17) {
|
||||
lincount = 0;
|
||||
more();
|
||||
clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
312
games/larn/extern.h
Normal file
312
games/larn/extern.h
Normal file
@ -0,0 +1,312 @@
|
||||
/* $NetBSD: extern.h,v 1.1 1997/10/18 20:03:17 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Christos Zoulas.
|
||||
* 4. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* bill.c */
|
||||
void mailbill __P((void));
|
||||
|
||||
/* config.c */
|
||||
|
||||
/* create.c */
|
||||
void makeplayer __P((void));
|
||||
void newcavelevel __P((int));
|
||||
void makemaze __P((int));
|
||||
void eat __P((int, int));
|
||||
int cannedlevel __P((int));
|
||||
void treasureroom __P((int));
|
||||
void troom __P((int, int, int, int, int, int));
|
||||
void makeobject __P((int));
|
||||
void fillmroom __P((int, int, int));
|
||||
void froom __P((int, int, int));
|
||||
int fillmonst __P((int));
|
||||
void sethp __P((int));
|
||||
void checkgen __P((void));
|
||||
|
||||
/* data.c */
|
||||
|
||||
/* diag.c */
|
||||
void diag __P((void));
|
||||
int dcount __P((int));
|
||||
void diagdrawscreen __P((void));
|
||||
int savegame __P((char *));
|
||||
void restoregame __P((char *));
|
||||
void greedy __P((void));
|
||||
void fsorry __P((void));
|
||||
void fcheat __P((void));
|
||||
|
||||
/* display.c */
|
||||
void bottomline __P((void));
|
||||
void bottomhp __P((void));
|
||||
void bottomspell __P((void));
|
||||
void bottomdo __P((void));
|
||||
void bot_linex __P((void));
|
||||
void bottomgold __P((void));
|
||||
void bot_hpx __P((void));
|
||||
void bot_spellx __P((void));
|
||||
void botside __P((void));
|
||||
void draws __P((int, int, int, int));
|
||||
void drawscreen __P((void));
|
||||
void showcell __P((int, int));
|
||||
void show1cell __P((int, int));
|
||||
void showplayer __P((void));
|
||||
int moveplayer __P((int));
|
||||
void seemagic __P((int));
|
||||
void seepage __P((void));
|
||||
|
||||
/* fortune.c */
|
||||
char *fortune __P((void));
|
||||
|
||||
/* global.c */
|
||||
void raiselevel __P((void));
|
||||
void loselevel __P((void));
|
||||
void raiseexperience __P((long));
|
||||
void loseexperience __P((long));
|
||||
void losehp __P((int));
|
||||
void losemhp __P((int));
|
||||
void raisehp __P((int));
|
||||
void raisemhp __P((int));
|
||||
void raisespells __P((int));
|
||||
void raisemspells __P((int));
|
||||
void losespells __P((int));
|
||||
void losemspells __P((int));
|
||||
int makemonst __P((int));
|
||||
void positionplayer __P((void));
|
||||
void recalc __P((void));
|
||||
void quit __P((void));
|
||||
void more __P((void));
|
||||
int take __P((int, int));
|
||||
int drop_object __P((int));
|
||||
void enchantarmor __P((void));
|
||||
void enchweapon __P((void));
|
||||
int pocketfull __P((void));
|
||||
int nearbymonst __P((void));
|
||||
int stealsomething __P((void));
|
||||
int emptyhanded __P((void));
|
||||
void creategem __P((void));
|
||||
void adjustcvalues __P((int, int));
|
||||
void gettokstr __P((char *));
|
||||
int getpassword __P((void));
|
||||
int getyn __P((void));
|
||||
int packweight __P((void));
|
||||
int rnd __P((int));
|
||||
int rund __P((int));
|
||||
|
||||
/* help.c */
|
||||
void help __P((void));
|
||||
void welcome __P((void));
|
||||
void retcont __P((void));
|
||||
int openhelp __P((void));
|
||||
|
||||
/* io.c */
|
||||
void setupvt100 __P((void));
|
||||
void clearvt100 __P((void));
|
||||
int getchar __P((void));
|
||||
void scbr __P((void));
|
||||
void sncbr __P((void));
|
||||
void newgame __P((void));
|
||||
void lprintf __P((const char *, ...));
|
||||
void lprint __P((long));
|
||||
void lwrite __P((char *, int));
|
||||
long lgetc __P((void));
|
||||
long lrint __P((void));
|
||||
void lrfill __P((char *, int));
|
||||
char *lgetw __P((void));
|
||||
char *lgetl __P((void));
|
||||
int lcreat __P((char *));
|
||||
int lopen __P((char *));
|
||||
int lappend __P((char *));
|
||||
void lrclose __P((void));
|
||||
void lwclose __P((void));
|
||||
void lprcat __P((char *));
|
||||
void cursor __P((int, int));
|
||||
void cursors __P((void));
|
||||
void init_term __P((void));
|
||||
void cl_line __P((int, int));
|
||||
void cl_up __P((int, int));
|
||||
void cl_dn __P((int, int));
|
||||
void standout __P((char *));
|
||||
void set_score_output __P((void));
|
||||
void lflush __P((void));
|
||||
void xputchar __P((int));
|
||||
void flush_buf __P((void));
|
||||
char *tmcapcnv __P((char *, char *));
|
||||
void beep __P((void));
|
||||
|
||||
/* main.c */
|
||||
int main __P((int, char **));
|
||||
void showstr __P((void));
|
||||
void qshowstr __P((void));
|
||||
void t_setup __P((int));
|
||||
void t_endup __P((int));
|
||||
void showwear __P((void));
|
||||
void showwield __P((void));
|
||||
void showread __P((void));
|
||||
void showeat __P((void));
|
||||
void showquaff __P((void));
|
||||
void show1 __P((int, char *[]));
|
||||
void show3 __P((int));
|
||||
void randmonst __P((void));
|
||||
void parse __P((void));
|
||||
void parse2 __P((void));
|
||||
void run __P((int));
|
||||
void wield __P((void));
|
||||
void ydhi __P((int));
|
||||
void ycwi __P((int));
|
||||
void wear __P((void));
|
||||
void dropobj __P((void));
|
||||
void readscr __P((void));
|
||||
void eatcookie __P((void));
|
||||
void quaff __P((void));
|
||||
int whatitem __P((char *));
|
||||
unsigned long readnum __P((long));
|
||||
void szero __P((char *));
|
||||
|
||||
/* monster.c */
|
||||
void createmonster __P((int));
|
||||
int cgood __P((int, int, int, int));
|
||||
void createitem __P((int, int));
|
||||
void cast __P((void));
|
||||
void speldamage __P((int));
|
||||
void loseint __P((void));
|
||||
int isconfuse __P((void));
|
||||
int nospell __P((int, int));
|
||||
int fullhit __P((int));
|
||||
void direct __P((int, int, char *, int));
|
||||
void godirect __P((int, int, char *, int, int));
|
||||
void ifblind __P((int, int));
|
||||
void tdirect __P((int));
|
||||
void omnidirect __P((int, int, char *));
|
||||
int vxy __P((int *, int *));
|
||||
void dirpoly __P((int));
|
||||
void hitmonster __P((int, int));
|
||||
int hitm __P((int, int, int));
|
||||
void hitplayer __P((int, int));
|
||||
void dropsomething __P((int));
|
||||
void dropgold __P((int));
|
||||
void something __P((int));
|
||||
int newobject __P((int, int *));
|
||||
int spattack __P((int, int, int));
|
||||
void checkloss __P((int));
|
||||
int annihilate __P((void));
|
||||
int newsphere __P((int, int, int, int));
|
||||
int rmsphere __P((int, int));
|
||||
void sphboom __P((int, int));
|
||||
void genmonst __P((void));
|
||||
|
||||
/* moreobj.c */
|
||||
void oaltar __P((void));
|
||||
void othrone __P((int));
|
||||
void odeadthrone __P((void));
|
||||
void ochest __P((void));
|
||||
void ofountain __P((void));
|
||||
void fntchange __P((int));
|
||||
|
||||
/* movem.c */
|
||||
void movemonst __P((void));
|
||||
void movemt __P((int, int));
|
||||
void mmove __P((int, int, int, int));
|
||||
void movsphere __P((void));
|
||||
|
||||
/* nap.c */
|
||||
void nap __P((int));
|
||||
|
||||
/* object.c */
|
||||
void lookforobject __P((void));
|
||||
void finditem __P((int));
|
||||
void ostairs __P((int));
|
||||
void oteleport __P((int));
|
||||
void opotion __P((int));
|
||||
void quaffpotion __P((int));
|
||||
void oscroll __P((int));
|
||||
void adjusttime __P((long));
|
||||
void read_scroll __P((int));
|
||||
void oorb __P((void));
|
||||
void opit __P((void));
|
||||
void obottomless __P((void));
|
||||
void oelevator __P((int));
|
||||
void ostatue __P((void));
|
||||
void omirror __P((void));
|
||||
void obook __P((void));
|
||||
void readbook __P((int));
|
||||
void ocookie __P((void));
|
||||
void ogold __P((int));
|
||||
void ohome __P((void));
|
||||
void iopts __P((void));
|
||||
void ignore __P((void));
|
||||
|
||||
/* regen.c */
|
||||
void regen __P((void));
|
||||
|
||||
/* savelev.c */
|
||||
void savelevel __P((void));
|
||||
void getlevel __P((void));
|
||||
|
||||
/* scores.c */
|
||||
int readboard __P((void));
|
||||
int writeboard __P((void));
|
||||
int makeboard __P((void));
|
||||
int hashewon __P((void));
|
||||
long paytaxes __P((long));
|
||||
int winshou __P((void));
|
||||
int shou __P((int));
|
||||
void showscores __P((void));
|
||||
void showallscores __P((void));
|
||||
int sortboard __P((void));
|
||||
void newscore __P((long, char *, int, int));
|
||||
void new1sub __P((long, int, char *, long));
|
||||
void new2sub __P((long, int, char *, int));
|
||||
void died __P((int));
|
||||
void diedsub __P((int));
|
||||
void diedlog __P((void));
|
||||
int getplid __P((char *));
|
||||
|
||||
/* signal.c */
|
||||
void sigsetup __P((void));
|
||||
|
||||
/* store.c */
|
||||
void dnd_2hed __P((void));
|
||||
void dnd_hed __P((void));
|
||||
void dndstore __P((void));
|
||||
void sch_hed __P((void));
|
||||
void oschool __P((void));
|
||||
void obank __P((void));
|
||||
void obank2 __P((void));
|
||||
void ointerest __P((void));
|
||||
void obanksub __P((void));
|
||||
void appraise __P((int));
|
||||
void otradepost __P((void));
|
||||
void cnsitm __P((void));
|
||||
void olrs __P((void));
|
||||
|
||||
/* tok.c */
|
||||
int yylex __P((void));
|
||||
void flushall __P((void));
|
||||
void sethard __P((int));
|
||||
void readopts __P((void));
|
@ -1,3 +1,5 @@
|
||||
/* $NetBSD: fortune.c,v 1.4 1997/10/18 20:03:18 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
@ -31,21 +33,26 @@
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91";
|
||||
static char sccsid[] = "@(#)fortune.c 5.5 (Berkeley) 6/10/91";
|
||||
#else
|
||||
static char rcsid[] = "$NetBSD: fortune.c,v 1.3 1995/03/23 08:33:23 cgd Exp $";
|
||||
__RCSID("$NetBSD: fortune.c,v 1.4 1997/10/18 20:03:18 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
/* fortune.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
|
||||
/*
|
||||
* function to return a random fortune from the fortune file
|
||||
*/
|
||||
|
||||
char *flines[] = {
|
||||
char *flines[] = {
|
||||
"gem value = gem * 2 ^ perfection",
|
||||
"sitting down can have unexpected results",
|
||||
"don't pry into the affairs of others",
|
||||
|
1098
games/larn/global.c
1098
games/larn/global.c
File diff suppressed because it is too large
Load Diff
@ -1,81 +1,79 @@
|
||||
/* $NetBSD: header.h,v 1.10 1997/07/13 20:21:35 christos Exp $ */
|
||||
/* $NetBSD: header.h,v 1.11 1997/10/18 20:03:22 christos Exp $ */
|
||||
|
||||
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
|
||||
/* header.h Larn is copyrighted 1986 by Noah Morgan. */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#define MAXLEVEL 11
|
||||
/* max # levels in the dungeon */
|
||||
/* max # levels in the dungeon */
|
||||
#define MAXVLEVEL 3
|
||||
/* max # of levels in the temple of the luran */
|
||||
/* max # of levels in the temple of the luran */
|
||||
#define MAXX 67
|
||||
#define MAXY 17
|
||||
|
||||
#define SCORESIZE 10
|
||||
/* this is the number of people on a scoreboard max */
|
||||
/* this is the number of people on a scoreboard max */
|
||||
#define MAXPLEVEL 100
|
||||
/* maximum player level allowed */
|
||||
/* maximum player level allowed */
|
||||
#define MAXMONST 56
|
||||
/* maximum # monsters in the dungeon */
|
||||
/* maximum # monsters in the dungeon */
|
||||
#define SPNUM 38
|
||||
/* maximum number of spells in existance */
|
||||
/* maximum number of spells in existance */
|
||||
#define MAXSCROLL 28
|
||||
/* maximum number of scrolls that are possible */
|
||||
/* maximum number of scrolls that are possible */
|
||||
#define MAXPOTION 35
|
||||
/* maximum number of potions that are possible */
|
||||
/* maximum number of potions that are possible */
|
||||
#define TIMELIMIT 30000
|
||||
/* the maximum number of moves before the game is called */
|
||||
/* the maximum number of moves before the game is called */
|
||||
#define TAXRATE 1/20
|
||||
/* the tax rate for the LRS */
|
||||
/* the tax rate for the LRS */
|
||||
#define MAXOBJ 93
|
||||
/* the maximum number of objects n < MAXOBJ */
|
||||
/* the maximum number of objects n < MAXOBJ */
|
||||
|
||||
/* this is the structure definition of the monster data */
|
||||
struct monst
|
||||
{
|
||||
char *name;
|
||||
char level;
|
||||
short armorclass;
|
||||
char damage;
|
||||
char attack;
|
||||
char defense;
|
||||
char genocided;
|
||||
char intelligence; /* monsters intelligence -- used to choose movement */
|
||||
short gold;
|
||||
short hitpoints;
|
||||
unsigned long experience;
|
||||
};
|
||||
/* this is the structure definition of the monster data */
|
||||
struct monst {
|
||||
char *name;
|
||||
char level;
|
||||
short armorclass;
|
||||
char damage;
|
||||
char attack;
|
||||
char defense;
|
||||
char genocided;
|
||||
char intelligence; /* monsters intelligence -- used to
|
||||
* choose movement */
|
||||
short gold;
|
||||
short hitpoints;
|
||||
unsigned long experience;
|
||||
};
|
||||
|
||||
/* this is the structure definition for the items in the dnd store */
|
||||
struct _itm
|
||||
{
|
||||
short price;
|
||||
char obj;
|
||||
char arg;
|
||||
char qty;
|
||||
};
|
||||
/* this is the structure definition for the items in the dnd store */
|
||||
struct _itm {
|
||||
short price;
|
||||
u_char obj;
|
||||
u_char arg;
|
||||
char qty;
|
||||
};
|
||||
|
||||
/* this is the structure that holds the entire dungeon specifications */
|
||||
struct cel
|
||||
{
|
||||
short hitp; /* monster's hit points */
|
||||
char mitem; /* the monster ID */
|
||||
char item; /* the object's ID */
|
||||
short iarg; /* the object's argument */
|
||||
char know; /* have we been here before*/
|
||||
};
|
||||
/* this is the structure that holds the entire dungeon specifications */
|
||||
struct cel {
|
||||
short hitp; /* monster's hit points */
|
||||
char mitem; /* the monster ID */
|
||||
char item; /* the object's ID */
|
||||
short iarg; /* the object's argument */
|
||||
char know; /* have we been here before */
|
||||
};
|
||||
|
||||
/* this is the structure for maintaining & moving the spheres of annihilation */
|
||||
struct sphere
|
||||
{
|
||||
struct sphere *p; /* pointer to next structure */
|
||||
char x,y,lev; /* location of the sphere */
|
||||
char dir; /* direction sphere is going in */
|
||||
short lifetime; /* duration of the sphere */
|
||||
};
|
||||
struct sphere {
|
||||
struct sphere *p; /* pointer to next structure */
|
||||
char x, y, lev; /* location of the sphere */
|
||||
char dir; /* direction sphere is going in */
|
||||
short lifetime; /* duration of the sphere */
|
||||
};
|
||||
|
||||
/* defines for the character attribute array c[] */
|
||||
#define STRENGTH 0 /* characters physical strength not due to objects */
|
||||
/* defines for the character attribute array c[] */
|
||||
#define STRENGTH 0 /* characters physical strength not due to
|
||||
* objects */
|
||||
#define INTELLIGENCE 1
|
||||
#define WISDOM 2
|
||||
#define CONSTITUTION 3
|
||||
@ -149,13 +147,14 @@ struct sphere
|
||||
#define SEEINVISIBLE 71
|
||||
#define FILLROOM 72
|
||||
#define RANDOMWALK 73
|
||||
#define SPHCAST 74 /* nz if an active sphere of annihilation */
|
||||
#define WTW 75 /* walk through walls */
|
||||
#define STREXTRA 76 /* character strength due to objects or enchantments */
|
||||
#define TMP 77 /* misc scratch space */
|
||||
#define LIFEPROT 78 /* life protection counter */
|
||||
#define SPHCAST 74 /* nz if an active sphere of annihilation */
|
||||
#define WTW 75 /* walk through walls */
|
||||
#define STREXTRA 76 /* character strength due to objects or
|
||||
* enchantments */
|
||||
#define TMP 77 /* misc scratch space */
|
||||
#define LIFEPROT 78 /* life protection counter */
|
||||
|
||||
/* defines for the objects in the game */
|
||||
/* defines for the objects in the game */
|
||||
|
||||
#define OALTAR 1
|
||||
#define OTHRONE 2
|
||||
@ -222,7 +221,7 @@ struct sphere
|
||||
#define OSCROLL 41
|
||||
#define OPOTION 42
|
||||
#define OBOOK 43
|
||||
#define OCHEST 44
|
||||
#define OCHEST 44
|
||||
#define OAMULET 45
|
||||
|
||||
#define OORBOFDRAGON 46
|
||||
@ -249,62 +248,62 @@ struct sphere
|
||||
#define OTRADEPOST 77
|
||||
#define OIVTELETRAP 78
|
||||
#define ODEADTHRONE 79
|
||||
#define OANNIHILATION 80 /* sphere of annihilation */
|
||||
#define OANNIHILATION 80 /* sphere of annihilation */
|
||||
#define OTHRONE2 81
|
||||
#define OLRS 82 /* Larn Revenue Service */
|
||||
#define OLRS 82 /* Larn Revenue Service */
|
||||
#define OCOOKIE 83
|
||||
#define OURN 84
|
||||
#define OBRASSLAMP 85
|
||||
#define OHANDofFEAR 86 /* hand of fear */
|
||||
#define OSPHTAILSMAN 87 /* tailsman of the sphere */
|
||||
#define OWWAND 88 /* wand of wonder */
|
||||
#define OPSTAFF 89 /* staff of power */
|
||||
#define OWWAND 88 /* wand of wonder */
|
||||
#define OPSTAFF 89 /* staff of power */
|
||||
/* used up to 92 */
|
||||
|
||||
/* defines for the monsters as objects */
|
||||
/* defines for the monsters as objects */
|
||||
|
||||
#define BAT 1
|
||||
#define GNOME 2
|
||||
#define HOBGOBLIN 3
|
||||
#define JACKAL 4
|
||||
#define KOBOLD 5
|
||||
#define ORC 6
|
||||
#define BAT 1
|
||||
#define GNOME 2
|
||||
#define HOBGOBLIN 3
|
||||
#define JACKAL 4
|
||||
#define KOBOLD 5
|
||||
#define ORC 6
|
||||
#define SNAKE 7
|
||||
#define CENTIPEDE 8
|
||||
#define JACULI 9
|
||||
#define TROGLODYTE 10
|
||||
#define ANT 11
|
||||
#define EYE 12
|
||||
#define JACULI 9
|
||||
#define TROGLODYTE 10
|
||||
#define ANT 11
|
||||
#define EYE 12
|
||||
#define LEPRECHAUN 13
|
||||
#define NYMPH 14
|
||||
#define QUASIT 15
|
||||
#define RUSTMONSTER 16
|
||||
#define ZOMBIE 17
|
||||
#define ASSASSINBUG 18
|
||||
#define BUGBEAR 19
|
||||
#define HELLHOUND 20
|
||||
#define ICELIZARD 21
|
||||
#define CENTAUR 22
|
||||
#define TROLL 23
|
||||
#define YETI 24
|
||||
#define WHITEDRAGON 25
|
||||
#define ELF 26
|
||||
#define CUBE 27
|
||||
#define METAMORPH 28
|
||||
#define VORTEX 29
|
||||
#define ZILLER 30
|
||||
#define VIOLETFUNGI 31
|
||||
#define WRAITH 32
|
||||
#define FORVALAKA 33
|
||||
#define LAMANOBE 34
|
||||
#define OSEQUIP 35
|
||||
#define ROTHE 36
|
||||
#define XORN 37
|
||||
#define VAMPIRE 38
|
||||
#define INVISIBLESTALKER 39
|
||||
#define POLTERGEIST 40
|
||||
#define DISENCHANTRESS 41
|
||||
#define SHAMBLINGMOUND 42
|
||||
#define NYMPH 14
|
||||
#define QUASIT 15
|
||||
#define RUSTMONSTER 16
|
||||
#define ZOMBIE 17
|
||||
#define ASSASSINBUG 18
|
||||
#define BUGBEAR 19
|
||||
#define HELLHOUND 20
|
||||
#define ICELIZARD 21
|
||||
#define CENTAUR 22
|
||||
#define TROLL 23
|
||||
#define YETI 24
|
||||
#define WHITEDRAGON 25
|
||||
#define ELF 26
|
||||
#define CUBE 27
|
||||
#define METAMORPH 28
|
||||
#define VORTEX 29
|
||||
#define ZILLER 30
|
||||
#define VIOLETFUNGI 31
|
||||
#define WRAITH 32
|
||||
#define FORVALAKA 33
|
||||
#define LAMANOBE 34
|
||||
#define OSEQUIP 35
|
||||
#define ROTHE 36
|
||||
#define XORN 37
|
||||
#define VAMPIRE 38
|
||||
#define INVISIBLESTALKER 39
|
||||
#define POLTERGEIST 40
|
||||
#define DISENCHANTRESS 41
|
||||
#define SHAMBLINGMOUND 42
|
||||
#define YELLOWMOLD 43
|
||||
#define UMBERHULK 44
|
||||
#define GNOMEKING 45
|
||||
@ -323,78 +322,85 @@ struct sphere
|
||||
#define DEMONPRINCE 64
|
||||
|
||||
#define NULL 0
|
||||
#define BUFBIG 4096 /* size of the output buffer */
|
||||
#define MAXIBUF 4096 /* size of the input buffer */
|
||||
#define LOGNAMESIZE 40 /* max size of the players name */
|
||||
#define PSNAMESIZE 40 /* max size of the process name */
|
||||
#define BUFBIG 4096 /* size of the output buffer */
|
||||
#define MAXIBUF 4096 /* size of the input buffer */
|
||||
#define LOGNAMESIZE 40 /* max size of the players name */
|
||||
#define PSNAMESIZE 40 /* max size of the process name */
|
||||
|
||||
#ifndef NODEFS
|
||||
extern char VERSION,SUBVERSION;
|
||||
extern char aborted[],alpha[],beenhere[],boldon,cheat,ckpfile[],ckpflag;
|
||||
extern char *class[],course[],diagfile[],helpfile[];
|
||||
extern char *inbuffer,is_alpha[],is_digit[];
|
||||
extern char item[MAXX][MAXY],iven[],know[MAXX][MAXY],larnlevels[],lastmonst[];
|
||||
extern char *levelname[],logfile[],loginname[],logname[],*lpbuf,*lpend;
|
||||
extern char *lpnt,moved[MAXX][MAXY],mitem[MAXX][MAXY],monstlevel[];
|
||||
extern char monstnamelist[],nch[],ndgg[],nlpts[],nomove,nosignal,nowelcome;
|
||||
extern char nplt[],nsw[],*objectname[],objnamelist[],optsfile[];
|
||||
extern char *potionhide[],*potionname[],playerids[],potprob[];
|
||||
extern char predostuff,psname[],restorflag,savefilename[],scorefile[],scprob[];
|
||||
extern char screen[MAXX][MAXY],*scrollhide[],*scrollname[],sex,*spelcode[];
|
||||
extern char *speldescript[];
|
||||
extern char spelknow[],*spelname[],*spelmes[],spelweird[MAXMONST+8][SPNUM];
|
||||
extern char splev[],stealth[MAXX][MAXY],to_lower[],to_upper[],wizard;
|
||||
extern short diroffx[],diroffy[],hitflag,hit2flag,hit3flag,hitp[MAXX][MAXY];
|
||||
extern short iarg[MAXX][MAXY],ivenarg[],lasthx,lasthy,lastnum,lastpx,lastpy;
|
||||
extern short nobeep,oldx,oldy,playerx,playery,level;
|
||||
extern int dayplay,enable_scroll,srcount,yrepcount,userid,wisid,lfd,fd;
|
||||
extern uid_t uid, euid;
|
||||
extern long initialtime,outstanding_taxes,skill[],gltime,c[],cbak[];
|
||||
extern char VERSION, SUBVERSION;
|
||||
extern u_char alpha[], beenhere[], boldon, cheat, ckpflag;
|
||||
extern u_char *class[], course[];
|
||||
extern char diagfile[], helpfile[], ckpfile[], larnlevels[],
|
||||
playerids[], optsfile[], psname[], savefilename[],
|
||||
scorefile[];
|
||||
extern u_char *inbuffer, is_alpha[], is_digit[];
|
||||
extern u_char item[MAXX][MAXY], iven[], know[MAXX][MAXY];
|
||||
extern char *levelname[], logfile[], loginname[], logname[],
|
||||
lastmonst[];
|
||||
extern u_char *lpbuf, *lpend;
|
||||
extern u_char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[];
|
||||
extern char monstnamelist[], objnamelist[];
|
||||
extern u_char nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome;
|
||||
extern u_char nplt[], nsw[];
|
||||
extern char *objectname[], *potionhide[], *potionname[],
|
||||
*spelcode[], *spelname[], *spelmes[], aborted[],
|
||||
spelweird[MAXMONST + 8][SPNUM];
|
||||
extern u_char potprob[];
|
||||
extern u_char predostuff, restorflag, scprob[];
|
||||
extern u_char screen[MAXX][MAXY], sex;
|
||||
extern char *speldescript[], *scrollhide[], *scrollname[];
|
||||
extern u_char spelknow[];
|
||||
extern u_char splev[], stealth[MAXX][MAXY], to_lower[], to_upper[], wizard;
|
||||
extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY];
|
||||
extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx,
|
||||
lastpy;
|
||||
extern short nobeep, oldx, oldy, playerx, playery, level;
|
||||
extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
|
||||
lfd, fd;
|
||||
extern uid_t uid, euid;
|
||||
extern long initialtime, outstanding_taxes, skill[], gltime, c[], cbak[];
|
||||
extern unsigned long randx;
|
||||
extern struct cel *cell;
|
||||
extern struct monst monster[];
|
||||
extern struct sphere *spheres;
|
||||
extern struct _itm itm[];
|
||||
extern long initialtime;
|
||||
extern int rmst, maxitm, lasttime;
|
||||
|
||||
char *fortune(),*getenv(),*getlogin(),*lgetw(),*lgetl(),*ctime();
|
||||
char *tmcapcnv(),*tgetstr(),*tgoto();
|
||||
long paytaxes(),lgetc(),lrint();
|
||||
unsigned long readnum();
|
||||
void *malloc();
|
||||
|
||||
/* macro to create scroll #'s with probability of occurrence */
|
||||
/* macro to create scroll #'s with probability of occurrence */
|
||||
#define newscroll() (scprob[rund(81)])
|
||||
/* macro to return a potion # created with probability of occurrence */
|
||||
/* macro to return a potion # created with probability of occurrence */
|
||||
#define newpotion() (potprob[rund(41)])
|
||||
/* macro to return the + points on created leather armor */
|
||||
/* macro to return the + points on created leather armor */
|
||||
#define newleather() (nlpts[rund(c[HARDGAME]?13:15)])
|
||||
/* macro to return the + points on chain armor */
|
||||
/* macro to return the + points on chain armor */
|
||||
#define newchain() (nch[rund(10)])
|
||||
/* macro to return + points on plate armor */
|
||||
/* macro to return + points on plate armor */
|
||||
#define newplate() (nplt[rund(c[HARDGAME]?4:12)])
|
||||
/* macro to return + points on new daggers */
|
||||
/* macro to return + points on new daggers */
|
||||
#define newdagger() (ndgg[rund(13)])
|
||||
/* macro to return + points on new swords */
|
||||
/* macro to return + points on new swords */
|
||||
#define newsword() (nsw[rund(c[HARDGAME]?6:13)])
|
||||
/* macro to destroy object at present location */
|
||||
/* macro to destroy object at present location */
|
||||
#define forget() (item[playerx][playery]=know[playerx][playery]=0)
|
||||
/* macro to wipe out a monster at a location */
|
||||
/* macro to wipe out a monster at a location */
|
||||
#define disappear(x,y) (mitem[x][y]=know[x][y]=0)
|
||||
|
||||
#ifdef VT100
|
||||
/* macro to turn on bold display for the terminal */
|
||||
/* macro to turn on bold display for the terminal */
|
||||
#define setbold() (lprcat(boldon?"\33[1m":"\33[7m"))
|
||||
/* macro to turn off bold display for the terminal */
|
||||
/* macro to turn off bold display for the terminal */
|
||||
#define resetbold() (lprcat("\33[m"))
|
||||
/* macro to setup the scrolling region for the terminal */
|
||||
/* macro to setup the scrolling region for the terminal */
|
||||
#define setscroll() (lprcat("\33[20;24r"))
|
||||
/* macro to clear the scrolling region for the terminal */
|
||||
/* macro to clear the scrolling region for the terminal */
|
||||
#define resetscroll() (lprcat("\33[;24r"))
|
||||
/* macro to clear the screen and home the cursor */
|
||||
/* macro to clear the screen and home the cursor */
|
||||
#define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50)
|
||||
#define cltoeoln() lprcat("\33[K")
|
||||
#else VT100
|
||||
/* defines below are for use in the termcap mode only */
|
||||
#else /* VT100 */
|
||||
/* defines below are for use in the termcap mode only */
|
||||
#define ST_START 1
|
||||
#define ST_END 2
|
||||
#define BOLD 3
|
||||
@ -403,31 +409,31 @@ void *malloc();
|
||||
#define CL_LINE 6
|
||||
#define CL_DOWN 14
|
||||
#define CURSOR 15
|
||||
/* macro to turn on bold display for the terminal */
|
||||
/* macro to turn on bold display for the terminal */
|
||||
#define setbold() (*lpnt++ = ST_START)
|
||||
/* macro to turn off bold display for the terminal */
|
||||
/* macro to turn off bold display for the terminal */
|
||||
#define resetbold() (*lpnt++ = ST_END)
|
||||
/* macro to setup the scrolling region for the terminal */
|
||||
/* macro to setup the scrolling region for the terminal */
|
||||
#define setscroll() enable_scroll=1
|
||||
/* macro to clear the scrolling region for the terminal */
|
||||
/* macro to clear the scrolling region for the terminal */
|
||||
#define resetscroll() enable_scroll=0
|
||||
/* macro to clear the screen and home the cursor */
|
||||
/* macro to clear the screen and home the cursor */
|
||||
#define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
|
||||
/* macro to clear to end of line */
|
||||
/* macro to clear to end of line */
|
||||
#define cltoeoln() (*lpnt++ = CL_LINE)
|
||||
#endif VT100
|
||||
#endif /* VT100 */
|
||||
|
||||
/* macro to output one byte to the output buffer */
|
||||
/* macro to output one byte to the output buffer */
|
||||
#define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ =(ch)))
|
||||
|
||||
/* macro to seed the random number generator */
|
||||
/* macro to seed the random number generator */
|
||||
#define srand(x) (randx=x)
|
||||
#ifdef MACRORND
|
||||
/* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
|
||||
/* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
|
||||
#define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
|
||||
#define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) )
|
||||
#endif MACRORND
|
||||
/* macros for miscellaneous data conversion */
|
||||
#endif /* MACRORND */
|
||||
/* macros for miscellaneous data conversion */
|
||||
#define min(x,y) (((x)>(y))?(y):(x))
|
||||
#define max(x,y) (((x)>(y))?(x):(y))
|
||||
#define isalpha(x) (is_alpha[x])
|
||||
@ -436,5 +442,4 @@ void *malloc();
|
||||
#define toupper(x) (to_upper[x])
|
||||
#define lcc(x) (to_lower[x])
|
||||
#define ucc(x) (to_upper[x])
|
||||
#endif NODEFS
|
||||
|
||||
#endif /* NODEFS */
|
||||
|
@ -1,11 +1,17 @@
|
||||
/* $NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $ */
|
||||
|
||||
/* help.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/03/23 08:33:33 cgd Exp $";
|
||||
__RCSID("$NetBSD: help.c,v 1.4 1997/10/18 20:03:24 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/* help.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <unistd.h>
|
||||
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
/*
|
||||
* help function to display the help info
|
||||
* help function to display the help info
|
||||
*
|
||||
* format of the .larn.help file
|
||||
*
|
||||
@ -13,79 +19,107 @@ static char rcsid[] = "$NetBSD: help.c,v 1.3 1995/03/23 08:33:33 cgd Exp $";
|
||||
* page (23 lines) for the introductory message (not counted in above)
|
||||
* pages of help text (23 lines per page)
|
||||
*/
|
||||
extern char helpfile[];
|
||||
void
|
||||
help()
|
||||
{
|
||||
register int i,j;
|
||||
{
|
||||
int i, j;
|
||||
#ifndef VT100
|
||||
char tmbuf[128]; /* intermediate translation buffer when not a VT100 */
|
||||
#endif VT100
|
||||
if ((j=openhelp()) < 0) return; /* open the help file and get # pages */
|
||||
for (i=0; i<23; i++) lgetl(); /* skip over intro message */
|
||||
for (; j>0; j--)
|
||||
{
|
||||
char tmbuf[128]; /* intermediate translation buffer
|
||||
* when not a VT100 */
|
||||
#endif /* VT100 */
|
||||
if ((j = openhelp()) < 0)
|
||||
return; /* open the help file and get # pages */
|
||||
for (i = 0; i < 23; i++)
|
||||
lgetl(); /* skip over intro message */
|
||||
for (; j > 0; j--) {
|
||||
clear();
|
||||
for (i=0; i<23; i++)
|
||||
for (i = 0; i < 23; i++)
|
||||
#ifdef VT100
|
||||
lprcat(lgetl()); /* print out each line that we read in */
|
||||
#else VT100
|
||||
{ tmcapcnv(tmbuf,lgetl()); lprcat(tmbuf); } /* intercept \33's */
|
||||
#endif VT100
|
||||
if (j>1)
|
||||
{
|
||||
lprcat(" ---- Press "); standout("return");
|
||||
lprcat(" to exit, "); standout("space");
|
||||
lprcat(lgetl()); /* print out each line that
|
||||
* we read in */
|
||||
#else /* VT100 */
|
||||
{
|
||||
tmcapcnv(tmbuf, lgetl());
|
||||
lprcat(tmbuf);
|
||||
} /* intercept \33's */
|
||||
#endif /* VT100 */
|
||||
if (j > 1) {
|
||||
lprcat(" ---- Press ");
|
||||
standout("return");
|
||||
lprcat(" to exit, ");
|
||||
standout("space");
|
||||
lprcat(" for more help ---- ");
|
||||
i=0; while ((i!=' ') && (i!='\n') && (i!='\33')) i=getchar();
|
||||
if ((i=='\n') || (i=='\33'))
|
||||
{
|
||||
lrclose(); setscroll(); drawscreen(); return;
|
||||
}
|
||||
i = 0;
|
||||
while ((i != ' ') && (i != '\n') && (i != '\33'))
|
||||
i = getchar();
|
||||
if ((i == '\n') || (i == '\33')) {
|
||||
lrclose();
|
||||
setscroll();
|
||||
drawscreen();
|
||||
return;
|
||||
}
|
||||
}
|
||||
lrclose(); retcont(); drawscreen();
|
||||
}
|
||||
lrclose();
|
||||
retcont();
|
||||
drawscreen();
|
||||
}
|
||||
|
||||
/*
|
||||
* function to display the welcome message and background
|
||||
*/
|
||||
void
|
||||
welcome()
|
||||
{
|
||||
register int i;
|
||||
{
|
||||
int i;
|
||||
#ifndef VT100
|
||||
char tmbuf[128]; /* intermediate translation buffer when not a VT100 */
|
||||
#endif VT100
|
||||
if (openhelp() < 0) return; /* open the help file */
|
||||
char tmbuf[128]; /* intermediate translation buffer
|
||||
* when not a VT100 */
|
||||
#endif /* VT100 */
|
||||
if (openhelp() < 0)
|
||||
return; /* open the help file */
|
||||
clear();
|
||||
for(i=0; i<23; i++)
|
||||
for (i = 0; i < 23; i++)
|
||||
#ifdef VT100
|
||||
lprcat(lgetl()); /* print out each line that we read in */
|
||||
#else VT100
|
||||
{ tmcapcnv(tmbuf,lgetl()); lprcat(tmbuf); } /* intercept \33's */
|
||||
#endif VT100
|
||||
lrclose(); retcont(); /* press return to continue */
|
||||
}
|
||||
lprcat(lgetl());/* print out each line that we read in */
|
||||
#else /* VT100 */
|
||||
{
|
||||
tmcapcnv(tmbuf, lgetl());
|
||||
lprcat(tmbuf);
|
||||
} /* intercept \33's */
|
||||
#endif /* VT100 */
|
||||
lrclose();
|
||||
retcont(); /* press return to continue */
|
||||
}
|
||||
|
||||
/*
|
||||
* function to say press return to continue and reset scroll when done
|
||||
*/
|
||||
void
|
||||
retcont()
|
||||
{
|
||||
cursor(1,24); lprcat("Press "); standout("return");
|
||||
lprcat(" to continue: "); while (getchar() != '\n');
|
||||
{
|
||||
cursor(1, 24);
|
||||
lprcat("Press ");
|
||||
standout("return");
|
||||
lprcat(" to continue: ");
|
||||
while (getchar() != '\n');
|
||||
setscroll();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* routine to open the help file and return the first character - '0'
|
||||
*/
|
||||
int
|
||||
openhelp()
|
||||
{
|
||||
if (lopen(helpfile)<0)
|
||||
{
|
||||
lprintf("Can't open help file \"%s\" ",helpfile);
|
||||
lflush(); sleep(4); drawscreen(); setscroll(); return(-1);
|
||||
}
|
||||
resetscroll(); return(lgetc() - '0');
|
||||
{
|
||||
if (lopen(helpfile) < 0) {
|
||||
lprintf("Can't open help file \"%s\" ", helpfile);
|
||||
lflush();
|
||||
sleep(4);
|
||||
drawscreen();
|
||||
setscroll();
|
||||
return (-1);
|
||||
}
|
||||
|
||||
resetscroll();
|
||||
return (lgetc() - '0');
|
||||
}
|
||||
|
1362
games/larn/io.c
1362
games/larn/io.c
File diff suppressed because it is too large
Load Diff
1671
games/larn/main.c
1671
games/larn/main.c
File diff suppressed because it is too large
Load Diff
2914
games/larn/monster.c
2914
games/larn/monster.c
File diff suppressed because it is too large
Load Diff
@ -1,19 +1,24 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: moreobj.c,v 1.3 1995/03/23 08:33:54 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: moreobj.c,v 1.4 1997/10/18 20:03:32 christos Exp $ */
|
||||
|
||||
/* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
|
||||
*
|
||||
* Routines in this file:
|
||||
*
|
||||
* oaltar()
|
||||
* othrone()
|
||||
* ochest()
|
||||
* ofountain()
|
||||
/*
|
||||
* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
|
||||
*
|
||||
* Routines in this file:
|
||||
*
|
||||
* oaltar() othrone() ochest() ofountain()
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: moreobj.c,v 1.4 1997/10/18 20:03:32 christos Exp $");
|
||||
#endif /* not lint */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
static void ohear();
|
||||
static void ohear __P((void));
|
||||
static void fch __P((int, long *));
|
||||
|
||||
/*
|
||||
* ******
|
||||
@ -22,96 +27,115 @@ static void ohear();
|
||||
*
|
||||
* subroutine to process an altar object
|
||||
*/
|
||||
void
|
||||
oaltar()
|
||||
{
|
||||
unsigned long k;
|
||||
{
|
||||
unsigned long k;
|
||||
|
||||
lprcat("\nDo you (p) pray (d) desecrate"); iopts();
|
||||
while (1)
|
||||
{
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 'p': lprcat(" pray\nDo you (m) give money or (j) just pray? ");
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 'j': if (rnd(100)<75)
|
||||
lprcat("\nnothing happens");
|
||||
else if (rnd(13)<4) ohear();
|
||||
else if (rnd(43) == 10)
|
||||
{
|
||||
if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
|
||||
enchantarmor(); return;
|
||||
}
|
||||
else if (rnd(43) == 10)
|
||||
{
|
||||
if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
|
||||
enchweapon(); return;
|
||||
}
|
||||
else createmonster(makemonst(level+1));
|
||||
return;
|
||||
lprcat("\nDo you (p) pray (d) desecrate");
|
||||
iopts();
|
||||
while (1) {
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 'p':
|
||||
lprcat(" pray\nDo you (m) give money or (j) just pray? ");
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 'j':
|
||||
if (rnd(100) < 75)
|
||||
lprcat("\nnothing happens");
|
||||
else if (rnd(13) < 4)
|
||||
ohear();
|
||||
else if (rnd(43) == 10) {
|
||||
if (c[WEAR])
|
||||
lprcat("\nYou feel your armor vibrate for a moment");
|
||||
enchantarmor();
|
||||
return;
|
||||
} else if (rnd(43) == 10) {
|
||||
if (c[WIELD])
|
||||
lprcat("\nYou feel your weapon vibrate for a moment");
|
||||
enchweapon();
|
||||
return;
|
||||
} else
|
||||
createmonster(makemonst(level + 1));
|
||||
return;
|
||||
|
||||
case 'm': lprcat("\n\n"); cursor(1,24); cltoeoln();
|
||||
cursor(1,23); cltoeoln();
|
||||
lprcat("how much do you donate? ");
|
||||
k = readnum((long)c[GOLD]);
|
||||
if (c[GOLD]<k)
|
||||
{
|
||||
lprcat("\nYou don't have that much!");
|
||||
return;
|
||||
}
|
||||
c[GOLD] -= k;
|
||||
if (k < c[GOLD]/10 || k<rnd(50))
|
||||
{ createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
|
||||
else if (rnd(101) > 50) { ohear(); return; }
|
||||
else if (rnd(43) == 5)
|
||||
{
|
||||
if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
|
||||
enchantarmor(); return;
|
||||
}
|
||||
else if (rnd(43) == 8)
|
||||
{
|
||||
if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
|
||||
enchweapon(); return;
|
||||
}
|
||||
else lprcat("\nThank You.");
|
||||
bottomline(); return;
|
||||
|
||||
case '\33': return;
|
||||
};
|
||||
|
||||
case 'd': lprcat(" desecrate");
|
||||
if (rnd(100)<60)
|
||||
{ createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
|
||||
else
|
||||
if (rnd(101)<30)
|
||||
{
|
||||
lprcat("\nThe altar crumbles into a pile of dust before your eyes");
|
||||
forget(); /* remember to destroy the altar */
|
||||
case 'm':
|
||||
lprcat("\n\n");
|
||||
cursor(1, 24);
|
||||
cltoeoln();
|
||||
cursor(1, 23);
|
||||
cltoeoln();
|
||||
lprcat("how much do you donate? ");
|
||||
k = readnum((long) c[GOLD]);
|
||||
if (c[GOLD] < k) {
|
||||
lprcat("\nYou don't have that much!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
c[GOLD] -= k;
|
||||
if (k < c[GOLD] / 10 || k < rnd(50)) {
|
||||
createmonster(makemonst(level + 1));
|
||||
c[AGGRAVATE] += 200;
|
||||
} else if (rnd(101) > 50) {
|
||||
ohear();
|
||||
return;
|
||||
} else if (rnd(43) == 5) {
|
||||
if (c[WEAR])
|
||||
lprcat("\nYou feel your armor vibrate for a moment");
|
||||
enchantarmor();
|
||||
return;
|
||||
} else if (rnd(43) == 8) {
|
||||
if (c[WIELD])
|
||||
lprcat("\nYou feel your weapon vibrate for a moment");
|
||||
enchweapon();
|
||||
return;
|
||||
} else
|
||||
lprcat("\nThank You.");
|
||||
bottomline();
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33': ignore();
|
||||
if (rnd(100)<30) { createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
|
||||
else lprcat("\nnothing happens");
|
||||
return;
|
||||
};
|
||||
}
|
||||
case '\33':
|
||||
return;
|
||||
};
|
||||
|
||||
case 'd':
|
||||
lprcat(" desecrate");
|
||||
if (rnd(100) < 60) {
|
||||
createmonster(makemonst(level + 2) + 8);
|
||||
c[AGGRAVATE] += 2500;
|
||||
} else if (rnd(101) < 30) {
|
||||
lprcat("\nThe altar crumbles into a pile of dust before your eyes");
|
||||
forget(); /* remember to destroy
|
||||
* the altar */
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33':
|
||||
ignore();
|
||||
if (rnd(100) < 30) {
|
||||
createmonster(makemonst(level + 1));
|
||||
c[AGGRAVATE] += rnd(450);
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function to cast a +3 protection on the player
|
||||
*/
|
||||
static void
|
||||
ohear()
|
||||
{
|
||||
{
|
||||
lprcat("\nYou have been heard!");
|
||||
if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
|
||||
if (c[ALTPRO] == 0)
|
||||
c[MOREDEFENSES] += 3;
|
||||
c[ALTPRO] += 500; /* protection field */
|
||||
bottomline();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*******
|
||||
@ -120,68 +144,85 @@ ohear()
|
||||
|
||||
subroutine to process a throne object
|
||||
*/
|
||||
void
|
||||
othrone(arg)
|
||||
int arg;
|
||||
{
|
||||
register int i,k;
|
||||
int arg;
|
||||
{
|
||||
int i, k;
|
||||
|
||||
lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
|
||||
while (1)
|
||||
{
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 'p': lprcat(" pry off"); k=rnd(101);
|
||||
if (k<25)
|
||||
{
|
||||
for (i=0; i<rnd(4); i++) creategem(); /* gems pop off the throne */
|
||||
item[playerx][playery]=ODEADTHRONE;
|
||||
know[playerx][playery]=0;
|
||||
}
|
||||
else if (k<40 && arg==0)
|
||||
{
|
||||
createmonster(GNOMEKING);
|
||||
item[playerx][playery]=OTHRONE2;
|
||||
know[playerx][playery]=0;
|
||||
}
|
||||
else lprcat("\nnothing happens");
|
||||
return;
|
||||
lprcat("\nDo you (p) pry off jewels, (s) sit down");
|
||||
iopts();
|
||||
while (1) {
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 'p':
|
||||
lprcat(" pry off");
|
||||
k = rnd(101);
|
||||
if (k < 25) {
|
||||
for (i = 0; i < rnd(4); i++)
|
||||
creategem(); /* gems pop off the
|
||||
* throne */
|
||||
item[playerx][playery] = ODEADTHRONE;
|
||||
know[playerx][playery] = 0;
|
||||
} else if (k < 40 && arg == 0) {
|
||||
createmonster(GNOMEKING);
|
||||
item[playerx][playery] = OTHRONE2;
|
||||
know[playerx][playery] = 0;
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
|
||||
case 's': lprcat(" sit down"); k=rnd(101);
|
||||
if (k<30 && arg==0)
|
||||
{
|
||||
createmonster(GNOMEKING);
|
||||
item[playerx][playery]=OTHRONE2;
|
||||
know[playerx][playery]=0;
|
||||
}
|
||||
else if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
|
||||
else lprcat("\nnothing happens");
|
||||
return;
|
||||
case 's':
|
||||
lprcat(" sit down");
|
||||
k = rnd(101);
|
||||
if (k < 30 && arg == 0) {
|
||||
createmonster(GNOMEKING);
|
||||
item[playerx][playery] = OTHRONE2;
|
||||
know[playerx][playery] = 0;
|
||||
} else if (k < 35) {
|
||||
lprcat("\nZaaaappp! You've been teleported!\n");
|
||||
beep();
|
||||
oteleport(0);
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33': ignore(); return;
|
||||
};
|
||||
}
|
||||
case 'i':
|
||||
case '\33':
|
||||
ignore();
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
odeadthrone()
|
||||
{
|
||||
register int k;
|
||||
{
|
||||
int k;
|
||||
|
||||
lprcat("\nDo you (s) sit down"); iopts();
|
||||
while (1)
|
||||
{
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 's': lprcat(" sit down"); k=rnd(101);
|
||||
if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
|
||||
else lprcat("\nnothing happens");
|
||||
return;
|
||||
lprcat("\nDo you (s) sit down");
|
||||
iopts();
|
||||
while (1) {
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 's':
|
||||
lprcat(" sit down");
|
||||
k = rnd(101);
|
||||
if (k < 35) {
|
||||
lprcat("\nZaaaappp! You've been teleported!\n");
|
||||
beep();
|
||||
oteleport(0);
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33': ignore(); return;
|
||||
};
|
||||
}
|
||||
case 'i':
|
||||
case '\33':
|
||||
ignore();
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
******
|
||||
@ -190,55 +231,68 @@ odeadthrone()
|
||||
|
||||
subroutine to process a throne object
|
||||
*/
|
||||
void
|
||||
ochest()
|
||||
{
|
||||
register int i,k;
|
||||
lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
|
||||
while (1)
|
||||
{
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 'o': lprcat(" open it"); k=rnd(101);
|
||||
if (k<40)
|
||||
{
|
||||
lprcat("\nThe chest explodes as you open it"); beep();
|
||||
i = rnd(10); lastnum=281; /* in case he dies */
|
||||
lprintf("\nYou suffer %d hit points damage!",(long)i);
|
||||
checkloss(i);
|
||||
switch(rnd(10)) /* see if he gets a curse */
|
||||
{
|
||||
case 1: c[ITCHING]+= rnd(1000)+100;
|
||||
lprcat("\nYou feel an irritation spread over your skin!");
|
||||
beep();
|
||||
break;
|
||||
{
|
||||
int i, k;
|
||||
lprcat("\nDo you (t) take it, (o) try to open it");
|
||||
iopts();
|
||||
while (1) {
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 'o':
|
||||
lprcat(" open it");
|
||||
k = rnd(101);
|
||||
if (k < 40) {
|
||||
lprcat("\nThe chest explodes as you open it");
|
||||
beep();
|
||||
i = rnd(10);
|
||||
lastnum = 281; /* in case he dies */
|
||||
lprintf("\nYou suffer %d hit points damage!", (long) i);
|
||||
checkloss(i);
|
||||
switch (rnd(10)) { /* see if he gets a
|
||||
* curse */
|
||||
case 1:
|
||||
c[ITCHING] += rnd(1000) + 100;
|
||||
lprcat("\nYou feel an irritation spread over your skin!");
|
||||
beep();
|
||||
break;
|
||||
|
||||
case 2: c[CLUMSINESS]+= rnd(1600)+200;
|
||||
lprcat("\nYou begin to lose hand to eye coordination!");
|
||||
beep();
|
||||
break;
|
||||
|
||||
case 3: c[HALFDAM]+= rnd(1600)+200;
|
||||
beep();
|
||||
lprcat("\nA sickness engulfs you!"); break;
|
||||
};
|
||||
item[playerx][playery]=know[playerx][playery]=0;
|
||||
if (rnd(100)<69) creategem(); /* gems from the chest */
|
||||
dropgold(rnd(110*iarg[playerx][playery]+200));
|
||||
for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
|
||||
}
|
||||
else lprcat("\nnothing happens");
|
||||
return;
|
||||
case 2:
|
||||
c[CLUMSINESS] += rnd(1600) + 200;
|
||||
lprcat("\nYou begin to lose hand to eye coordination!");
|
||||
beep();
|
||||
break;
|
||||
|
||||
case 't': lprcat(" take");
|
||||
if (take(OCHEST,iarg[playerx][playery])==0)
|
||||
item[playerx][playery]=know[playerx][playery]=0;
|
||||
return;
|
||||
case 3:
|
||||
c[HALFDAM] += rnd(1600) + 200;
|
||||
beep();
|
||||
lprcat("\nA sickness engulfs you!");
|
||||
break;
|
||||
};
|
||||
item[playerx][playery] = know[playerx][playery] = 0;
|
||||
if (rnd(100) < 69)
|
||||
creategem(); /* gems from the chest */
|
||||
dropgold(rnd(110 * iarg[playerx][playery] + 200));
|
||||
for (i = 0; i < rnd(4); i++)
|
||||
something(iarg[playerx][playery] + 2);
|
||||
} else
|
||||
lprcat("\nnothing happens");
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33': ignore(); return;
|
||||
};
|
||||
}
|
||||
case 't':
|
||||
lprcat(" take");
|
||||
if (take(OCHEST, iarg[playerx][playery]) == 0)
|
||||
item[playerx][playery] = know[playerx][playery] = 0;
|
||||
return;
|
||||
|
||||
case 'i':
|
||||
case '\33':
|
||||
ignore();
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*********
|
||||
@ -246,64 +300,70 @@ ochest()
|
||||
*********
|
||||
*/
|
||||
|
||||
void
|
||||
ofountain()
|
||||
{
|
||||
register int x;
|
||||
{
|
||||
int x;
|
||||
cursors();
|
||||
lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
|
||||
while (1) switch(getchar())
|
||||
{
|
||||
case 'd': lprcat("drink");
|
||||
if (rnd(1501)<2)
|
||||
{
|
||||
lprcat("\nOops! You seem to have caught the dreadful sleep!");
|
||||
beep(); lflush(); sleep(3); died(280); return;
|
||||
}
|
||||
x = rnd(100);
|
||||
if (x<7)
|
||||
{
|
||||
c[HALFDAM] += 200+rnd(200);
|
||||
lprcat("\nYou feel a sickness coming on");
|
||||
}
|
||||
else if (x<13) quaffpotion(23); /* see invisible */
|
||||
else if (x < 45)
|
||||
lprcat("\nnothing seems to have happened");
|
||||
else if (rnd(3) != 2)
|
||||
fntchange(1); /* change char levels upward */
|
||||
else
|
||||
fntchange(-1); /* change char levels downward */
|
||||
if (rnd(12)<3)
|
||||
{
|
||||
lprcat("\nThe fountains bubbling slowly quiets");
|
||||
item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
|
||||
know[playerx][playery]=0;
|
||||
}
|
||||
return;
|
||||
lprcat("\nDo you (d) drink, (w) wash yourself");
|
||||
iopts();
|
||||
while (1)
|
||||
switch (getchar()) {
|
||||
case 'd':
|
||||
lprcat("drink");
|
||||
if (rnd(1501) < 2) {
|
||||
lprcat("\nOops! You seem to have caught the dreadful sleep!");
|
||||
beep();
|
||||
lflush();
|
||||
sleep(3);
|
||||
died(280);
|
||||
return;
|
||||
}
|
||||
x = rnd(100);
|
||||
if (x < 7) {
|
||||
c[HALFDAM] += 200 + rnd(200);
|
||||
lprcat("\nYou feel a sickness coming on");
|
||||
} else if (x < 13)
|
||||
quaffpotion(23); /* see invisible */
|
||||
else if (x < 45)
|
||||
lprcat("\nnothing seems to have happened");
|
||||
else if (rnd(3) != 2)
|
||||
fntchange(1); /* change char levels upward */
|
||||
else
|
||||
fntchange(-1); /* change char levels
|
||||
* downward */
|
||||
if (rnd(12) < 3) {
|
||||
lprcat("\nThe fountains bubbling slowly quiets");
|
||||
item[playerx][playery] = ODEADFOUNTAIN; /* dead fountain */
|
||||
know[playerx][playery] = 0;
|
||||
}
|
||||
return;
|
||||
|
||||
case '\33':
|
||||
case 'i': ignore(); return;
|
||||
case 'i':
|
||||
ignore();
|
||||
return;
|
||||
|
||||
case 'w': lprcat("wash yourself");
|
||||
if (rnd(100) < 11)
|
||||
{
|
||||
x=rnd((level<<2)+2);
|
||||
lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x);
|
||||
lastnum=273; losehp(x); bottomline(); cursors();
|
||||
}
|
||||
else
|
||||
if (rnd(100) < 29)
|
||||
lprcat("\nYou got the dirt off!");
|
||||
else
|
||||
if (rnd(100) < 31)
|
||||
lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
|
||||
else
|
||||
if (rnd(100) < 34)
|
||||
createmonster(WATERLORD); /* make water lord */
|
||||
else
|
||||
lprcat("\nnothing seems to have happened");
|
||||
return;
|
||||
case 'w':
|
||||
lprcat("wash yourself");
|
||||
if (rnd(100) < 11) {
|
||||
x = rnd((level << 2) + 2);
|
||||
lprintf("\nOh no! The water was foul! You suffer %d hit points!", (long) x);
|
||||
lastnum = 273;
|
||||
losehp(x);
|
||||
bottomline();
|
||||
cursors();
|
||||
} else if (rnd(100) < 29)
|
||||
lprcat("\nYou got the dirt off!");
|
||||
else if (rnd(100) < 31)
|
||||
lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
|
||||
else if (rnd(100) < 34)
|
||||
createmonster(WATERLORD); /* make water lord */
|
||||
else
|
||||
lprcat("\nnothing seems to have happened");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
***
|
||||
@ -313,64 +373,113 @@ ofountain()
|
||||
subroutine to process an up/down of a character attribute for ofountain
|
||||
*/
|
||||
static void
|
||||
fch(how,x)
|
||||
int how;
|
||||
long *x;
|
||||
{
|
||||
if (how < 0) { lprcat(" went down by one!"); --(*x); }
|
||||
else { lprcat(" went up by one!"); (*x)++; }
|
||||
bottomline();
|
||||
fch(how, x)
|
||||
int how;
|
||||
long *x;
|
||||
{
|
||||
if (how < 0) {
|
||||
lprcat(" went down by one!");
|
||||
--(*x);
|
||||
} else {
|
||||
lprcat(" went up by one!");
|
||||
(*x)++;
|
||||
}
|
||||
bottomline();
|
||||
}
|
||||
|
||||
/*
|
||||
a subroutine to raise or lower character levels
|
||||
if x > 0 they are raised if x < 0 they are lowered
|
||||
*/
|
||||
void
|
||||
fntchange(how)
|
||||
int how;
|
||||
{
|
||||
register long j;
|
||||
int how;
|
||||
{
|
||||
long j;
|
||||
lprc('\n');
|
||||
switch(rnd(9))
|
||||
{
|
||||
case 1: lprcat("Your strength"); fch(how,&c[0]); break;
|
||||
case 2: lprcat("Your intelligence"); fch(how,&c[1]); break;
|
||||
case 3: lprcat("Your wisdom"); fch(how,&c[2]); break;
|
||||
case 4: lprcat("Your constitution"); fch(how,&c[3]); break;
|
||||
case 5: lprcat("Your dexterity"); fch(how,&c[4]); break;
|
||||
case 6: lprcat("Your charm"); fch(how,&c[5]); break;
|
||||
case 7: j=rnd(level+1);
|
||||
if (how < 0)
|
||||
{ lprintf("You lose %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); losemhp((int)j); }
|
||||
else
|
||||
{ lprintf("You gain %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); }
|
||||
bottomline(); break;
|
||||
|
||||
case 8: j=rnd(level+1);
|
||||
if (how > 0)
|
||||
{
|
||||
lprintf("You just gained %d spell",(long)j); raisemspells((int)j);
|
||||
if (j>1) lprcat("s!"); else lprc('!');
|
||||
}
|
||||
else
|
||||
{
|
||||
lprintf("You just lost %d spell",(long)j); losemspells((int)j);
|
||||
if (j>1) lprcat("s!"); else lprc('!');
|
||||
}
|
||||
bottomline(); break;
|
||||
|
||||
case 9: j = 5*rnd((level+1)*(level+1));
|
||||
if (how < 0)
|
||||
{
|
||||
lprintf("You just lost %d experience point",(long)j);
|
||||
if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j);
|
||||
}
|
||||
else
|
||||
{
|
||||
lprintf("You just gained %d experience point",(long)j);
|
||||
if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j);
|
||||
}
|
||||
break;
|
||||
switch (rnd(9)) {
|
||||
case 1:
|
||||
lprcat("Your strength");
|
||||
fch(how, &c[0]);
|
||||
break;
|
||||
case 2:
|
||||
lprcat("Your intelligence");
|
||||
fch(how, &c[1]);
|
||||
break;
|
||||
case 3:
|
||||
lprcat("Your wisdom");
|
||||
fch(how, &c[2]);
|
||||
break;
|
||||
case 4:
|
||||
lprcat("Your constitution");
|
||||
fch(how, &c[3]);
|
||||
break;
|
||||
case 5:
|
||||
lprcat("Your dexterity");
|
||||
fch(how, &c[4]);
|
||||
break;
|
||||
case 6:
|
||||
lprcat("Your charm");
|
||||
fch(how, &c[5]);
|
||||
break;
|
||||
case 7:
|
||||
j = rnd(level + 1);
|
||||
if (how < 0) {
|
||||
lprintf("You lose %d hit point", (long) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
losemhp((int) j);
|
||||
} else {
|
||||
lprintf("You gain %d hit point", (long) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
raisemhp((int) j);
|
||||
}
|
||||
cursors();
|
||||
bottomline();
|
||||
break;
|
||||
|
||||
case 8:
|
||||
j = rnd(level + 1);
|
||||
if (how > 0) {
|
||||
lprintf("You just gained %d spell", (long) j);
|
||||
raisemspells((int) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
} else {
|
||||
lprintf("You just lost %d spell", (long) j);
|
||||
losemspells((int) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
}
|
||||
bottomline();
|
||||
break;
|
||||
|
||||
case 9:
|
||||
j = 5 * rnd((level + 1) * (level + 1));
|
||||
if (how < 0) {
|
||||
lprintf("You just lost %d experience point", (long) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
loseexperience((long) j);
|
||||
} else {
|
||||
lprintf("You just gained %d experience point", (long) j);
|
||||
if (j > 1)
|
||||
lprcat("s!");
|
||||
else
|
||||
lprc('!');
|
||||
raiseexperience((long) j);
|
||||
}
|
||||
break;
|
||||
}
|
||||
cursors();
|
||||
}
|
||||
|
@ -1,316 +1,446 @@
|
||||
/* $NetBSD: movem.c,v 1.5 1997/10/18 20:03:34 christos Exp $ */
|
||||
|
||||
/*
|
||||
* movem.c (move monster) Larn is copyrighted 1986 by Noah Morgan.
|
||||
*
|
||||
* Here are the functions in this file:
|
||||
*
|
||||
* movemonst() Routine to move the monsters toward the player
|
||||
* movemt(x,y) Function to move a monster at (x,y) -- must determine where
|
||||
* mmove(x,y,xd,yd) Function to actually perform the monster movement
|
||||
* movsphere() Function to look for and move spheres of annihilation
|
||||
*/
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: movem.c,v 1.4 1997/07/13 20:21:37 christos Exp $";
|
||||
#endif /* not lint */
|
||||
__RCSID("$NetBSD: movem.c,v 1.5 1997/10/18 20:03:34 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
/*
|
||||
* movem.c (move monster) Larn is copyrighted 1986 by Noah Morgan.
|
||||
*
|
||||
* Here are the functions in this file:
|
||||
*
|
||||
* movemonst() Routine to move the monsters toward the player
|
||||
* movemt(x,y) Function to move a monster at (x,y) -- must determine where
|
||||
* mmove(x,y,xd,yd) Function to actually perform the monster movement
|
||||
* movsphere() Function to look for and move spheres of annihilation
|
||||
*/
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
* movemonst() Routine to move the monsters toward the player
|
||||
* movemonst() Routine to move the monsters toward the player
|
||||
*
|
||||
* This routine has the responsibility to determine which monsters are to
|
||||
* move, and call movemt() to do the move.
|
||||
* Returns no value.
|
||||
* This routine has the responsibility to determine which monsters are to
|
||||
* move, and call movemt() to do the move.
|
||||
* Returns no value.
|
||||
*/
|
||||
static short w1[9],w1x[9],w1y[9];
|
||||
static int tmp1,tmp2,tmp3,tmp4,distance;
|
||||
static short w1[9], w1x[9], w1y[9];
|
||||
static int tmp1, tmp2, tmp3, tmp4, distance;
|
||||
void
|
||||
movemonst()
|
||||
{
|
||||
register int i,j;
|
||||
if (c[TIMESTOP]) return; /* no action if time is stopped */
|
||||
if (c[HASTESELF]) if ((c[HASTESELF]&1)==0) return;
|
||||
if (spheres) movsphere(); /* move the spheres of annihilation if any */
|
||||
if (c[HOLDMONST]) return; /* no action if monsters are held */
|
||||
{
|
||||
int i, j;
|
||||
if (c[TIMESTOP])
|
||||
return; /* no action if time is stopped */
|
||||
if (c[HASTESELF])
|
||||
if ((c[HASTESELF] & 1) == 0)
|
||||
return;
|
||||
if (spheres)
|
||||
movsphere(); /* move the spheres of annihilation if any */
|
||||
if (c[HOLDMONST])
|
||||
return; /* no action if monsters are held */
|
||||
|
||||
if (c[AGGRAVATE]) /* determine window of monsters to move */
|
||||
{
|
||||
tmp1=playery-5; tmp2=playery+6; tmp3=playerx-10; tmp4=playerx+11;
|
||||
distance=40; /* depth of intelligent monster movement */
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp1=playery-3; tmp2=playery+4; tmp3=playerx-5; tmp4=playerx+6;
|
||||
distance=17; /* depth of intelligent monster movement */
|
||||
}
|
||||
|
||||
if (level == 0) /* if on outside level monsters can move in perimeter */
|
||||
{
|
||||
if (tmp1 < 0) tmp1=0; if (tmp2 > MAXY) tmp2=MAXY;
|
||||
if (tmp3 < 0) tmp3=0; if (tmp4 > MAXX) tmp4=MAXX;
|
||||
}
|
||||
else /* if in a dungeon monsters can't be on the perimeter (wall there) */
|
||||
{
|
||||
if (tmp1 < 1) tmp1=1; if (tmp2 > MAXY-1) tmp2=MAXY-1;
|
||||
if (tmp3 < 1) tmp3=1; if (tmp4 > MAXX-1) tmp4=MAXX-1;
|
||||
}
|
||||
|
||||
for (j=tmp1; j<tmp2; j++) /* now reset monster moved flags */
|
||||
for (i=tmp3; i<tmp4; i++)
|
||||
moved[i][j] = 0;
|
||||
moved[lasthx][lasthy]=0;
|
||||
|
||||
if (c[AGGRAVATE] || !c[STEALTH]) /* who gets moved? split for efficiency */
|
||||
{
|
||||
for (j=tmp1; j<tmp2; j++) /* look thru all locations in window */
|
||||
for (i=tmp3; i<tmp4; i++)
|
||||
if (mitem[i][j]) /* if there is a monster to move */
|
||||
if (moved[i][j]==0) /* if it has not already been moved */
|
||||
movemt(i,j); /* go and move the monster */
|
||||
}
|
||||
else /* not aggravated and not stealth */
|
||||
{
|
||||
for (j=tmp1; j<tmp2; j++) /* look thru all locations in window */
|
||||
for (i=tmp3; i<tmp4; i++)
|
||||
if (mitem[i][j]) /* if there is a monster to move */
|
||||
if (moved[i][j]==0) /* if it has not already been moved */
|
||||
if (stealth[i][j]) /* if it is asleep due to stealth */
|
||||
movemt(i,j); /* go and move the monster */
|
||||
}
|
||||
|
||||
if (mitem[lasthx][lasthy]) /* now move monster last hit by player if not already moved */
|
||||
{
|
||||
if (moved[lasthx][lasthy]==0) /* if it has not already been moved */
|
||||
{
|
||||
movemt(lasthx,lasthy);
|
||||
lasthx = w1x[0]; lasthy = w1y[0];
|
||||
}
|
||||
}
|
||||
if (c[AGGRAVATE]) { /* determine window of monsters to move */
|
||||
tmp1 = playery - 5;
|
||||
tmp2 = playery + 6;
|
||||
tmp3 = playerx - 10;
|
||||
tmp4 = playerx + 11;
|
||||
distance = 40; /* depth of intelligent monster movement */
|
||||
} else {
|
||||
tmp1 = playery - 3;
|
||||
tmp2 = playery + 4;
|
||||
tmp3 = playerx - 5;
|
||||
tmp4 = playerx + 6;
|
||||
distance = 17; /* depth of intelligent monster movement */
|
||||
}
|
||||
|
||||
/*
|
||||
* movemt(x,y) Function to move a monster at (x,y) -- must determine where
|
||||
* int x,y;
|
||||
*
|
||||
* This routine is responsible for determining where one monster at (x,y) will
|
||||
* move to. Enter with the monsters coordinates in (x,y).
|
||||
* Returns no value.
|
||||
*/
|
||||
static int tmpitem,xl,xh,yl,yh;
|
||||
movemt(i,j)
|
||||
int i,j;
|
||||
{
|
||||
register int k,m,z,tmp,xtmp,ytmp,monst;
|
||||
switch(monst=mitem[i][j]) /* for half speed monsters */
|
||||
{
|
||||
case TROGLODYTE: case HOBGOBLIN: case METAMORPH: case XVART:
|
||||
case INVISIBLESTALKER: case ICELIZARD: if ((gltime & 1) == 1) return;
|
||||
};
|
||||
if (level == 0) { /* if on outside level monsters can move in
|
||||
* perimeter */
|
||||
if (tmp1 < 0)
|
||||
tmp1 = 0;
|
||||
if (tmp2 > MAXY)
|
||||
tmp2 = MAXY;
|
||||
if (tmp3 < 0)
|
||||
tmp3 = 0;
|
||||
if (tmp4 > MAXX)
|
||||
tmp4 = MAXX;
|
||||
} else { /* if in a dungeon monsters can't be on the
|
||||
* perimeter (wall there) */
|
||||
if (tmp1 < 1)
|
||||
tmp1 = 1;
|
||||
if (tmp2 > MAXY - 1)
|
||||
tmp2 = MAXY - 1;
|
||||
if (tmp3 < 1)
|
||||
tmp3 = 1;
|
||||
if (tmp4 > MAXX - 1)
|
||||
tmp4 = MAXX - 1;
|
||||
}
|
||||
|
||||
if (c[SCAREMONST]) /* choose destination randomly if scared */
|
||||
{
|
||||
if ((xl = i+rnd(3)-2) < 0) xl=0; if (xl >= MAXX) xl=MAXX-1;
|
||||
if ((yl = j+rnd(3)-2) < 0) yl=0; if (yl >= MAXY) yl=MAXY-1;
|
||||
if ((tmp=item[xl][yl]) != OWALL)
|
||||
if (mitem[xl][yl] == 0)
|
||||
if ((mitem[i][j] != VAMPIRE) || (tmpitem != OMIRROR))
|
||||
if (tmp != OCLOSEDDOOR) mmove(i,j,xl,yl);
|
||||
return;
|
||||
for (j = tmp1; j < tmp2; j++) /* now reset monster moved flags */
|
||||
for (i = tmp3; i < tmp4; i++)
|
||||
moved[i][j] = 0;
|
||||
moved[lasthx][lasthy] = 0;
|
||||
|
||||
if (c[AGGRAVATE] || !c[STEALTH]) { /* who gets moved? split for
|
||||
* efficiency */
|
||||
for (j = tmp1; j < tmp2; j++) /* look thru all locations in
|
||||
* window */
|
||||
for (i = tmp3; i < tmp4; i++)
|
||||
if (mitem[i][j]) /* if there is a monster
|
||||
* to move */
|
||||
if (moved[i][j] == 0) /* if it has not already
|
||||
* been moved */
|
||||
movemt(i, j); /* go and move the
|
||||
* monster */
|
||||
} else { /* not aggravated and not stealth */
|
||||
for (j = tmp1; j < tmp2; j++) /* look thru all locations in
|
||||
* window */
|
||||
for (i = tmp3; i < tmp4; i++)
|
||||
if (mitem[i][j]) /* if there is a monster
|
||||
* to move */
|
||||
if (moved[i][j] == 0) /* if it has not already
|
||||
* been moved */
|
||||
if (stealth[i][j]) /* if it is asleep due
|
||||
* to stealth */
|
||||
movemt(i, j); /* go and move the
|
||||
* monster */
|
||||
}
|
||||
|
||||
if (mitem[lasthx][lasthy]) { /* now move monster last hit by
|
||||
* player if not already moved */
|
||||
if (moved[lasthx][lasthy] == 0) { /* if it has not already
|
||||
* been moved */
|
||||
movemt(lasthx, lasthy);
|
||||
lasthx = w1x[0];
|
||||
lasthy = w1y[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (monster[monst].intelligence > 10-c[HARDGAME]) /* if smart monster */
|
||||
/* intelligent movement here -- first setup screen array */
|
||||
{
|
||||
xl=tmp3-2; yl=tmp1-2; xh=tmp4+2; yh=tmp2+2;
|
||||
vxy(&xl,&yl); vxy(&xh,&yh);
|
||||
for (k=yl; k<yh; k++)
|
||||
for (m=xl; m<xh; m++)
|
||||
{
|
||||
switch(item[m][k])
|
||||
{
|
||||
case OWALL: case OPIT: case OTRAPARROW: case ODARTRAP:
|
||||
case OCLOSEDDOOR: case OTRAPDOOR: case OTELEPORTER:
|
||||
smm: screen[m][k]=127; break;
|
||||
case OMIRROR: if (mitem[m][k]==VAMPIRE) goto smm;
|
||||
default: screen[m][k]= 0; break;
|
||||
};
|
||||
}
|
||||
screen[playerx][playery]=1;
|
||||
/*
|
||||
* movemt(x,y) Function to move a monster at (x,y) -- must determine where
|
||||
* int x,y;
|
||||
*
|
||||
* This routine is responsible for determining where one monster at (x,y) will
|
||||
* move to. Enter with the monsters coordinates in (x,y).
|
||||
* Returns no value.
|
||||
*/
|
||||
static int tmpitem, xl, xh, yl, yh;
|
||||
void
|
||||
movemt(i, j)
|
||||
int i, j;
|
||||
{
|
||||
int k, m, z, tmp, xtmp, ytmp, monst;
|
||||
switch (monst = mitem[i][j]) { /* for half speed monsters */
|
||||
case TROGLODYTE:
|
||||
case HOBGOBLIN:
|
||||
case METAMORPH:
|
||||
case XVART:
|
||||
case INVISIBLESTALKER:
|
||||
case ICELIZARD:
|
||||
if ((gltime & 1) == 1)
|
||||
return;
|
||||
};
|
||||
|
||||
/* now perform proximity ripple from playerx,playery to monster */
|
||||
xl=tmp3-1; yl=tmp1-1; xh=tmp4+1; yh=tmp2+1;
|
||||
vxy(&xl,&yl); vxy(&xh,&yh);
|
||||
for (tmp=1; tmp<distance; tmp++) /* only up to 20 squares away */
|
||||
for (k=yl; k<yh; k++)
|
||||
for (m=xl; m<xh; m++)
|
||||
if (screen[m][k]==tmp) /* if find proximity n advance it */
|
||||
for (z=1; z<9; z++) /* go around in a circle */
|
||||
{
|
||||
if (screen[xtmp=m+diroffx[z]][ytmp=k+diroffy[z]]==0)
|
||||
screen[xtmp][ytmp]=tmp+1;
|
||||
if (xtmp==i && ytmp==j) goto out;
|
||||
}
|
||||
|
||||
out: if (tmp<distance) /* did find connectivity */
|
||||
/* now select lowest value around playerx,playery */
|
||||
for (z=1; z<9; z++) /* go around in a circle */
|
||||
if (screen[xl=i+diroffx[z]][yl=j+diroffy[z]]==tmp)
|
||||
if (!mitem[xl][yl]) { mmove(i,j,w1x[0]=xl,w1y[0]=yl); return; }
|
||||
}
|
||||
|
||||
/* dumb monsters move here */
|
||||
xl=i-1; yl=j-1; xh=i+2; yh=j+2;
|
||||
if (i<playerx) xl++; else if (i>playerx) --xh;
|
||||
if (j<playery) yl++; else if (j>playery) --yh;
|
||||
for (k=0; k<9; k++) w1[k] = 10000;
|
||||
|
||||
for (k=xl; k<xh; k++)
|
||||
for (m=yl; m<yh; m++) /* for each square compute distance to player */
|
||||
{
|
||||
tmp = k-i+4+3*(m-j);
|
||||
tmpitem = item[k][m];
|
||||
if (tmpitem!=OWALL || (k==playerx && m==playery))
|
||||
if (mitem[k][m]==0)
|
||||
if ((mitem[i][j] != VAMPIRE) || (tmpitem != OMIRROR))
|
||||
if (tmpitem!=OCLOSEDDOOR)
|
||||
{
|
||||
w1[tmp] = (playerx-k)*(playerx-k)+(playery-m)*(playery-m);
|
||||
w1x[tmp] = k; w1y[tmp] = m;
|
||||
}
|
||||
if (c[SCAREMONST]) { /* choose destination randomly if scared */
|
||||
if ((xl = i + rnd(3) - 2) < 0)
|
||||
xl = 0;
|
||||
if (xl >= MAXX)
|
||||
xl = MAXX - 1;
|
||||
if ((yl = j + rnd(3) - 2) < 0)
|
||||
yl = 0;
|
||||
if (yl >= MAXY)
|
||||
yl = MAXY - 1;
|
||||
if ((tmp = item[xl][yl]) != OWALL)
|
||||
if (mitem[xl][yl] == 0)
|
||||
if ((mitem[i][j] != VAMPIRE) || (tmpitem != OMIRROR))
|
||||
if (tmp != OCLOSEDDOOR)
|
||||
mmove(i, j, xl, yl);
|
||||
return;
|
||||
}
|
||||
if (monster[monst].intelligence > 10 - c[HARDGAME]) { /* if smart monster */
|
||||
/* intelligent movement here -- first setup screen array */
|
||||
xl = tmp3 - 2;
|
||||
yl = tmp1 - 2;
|
||||
xh = tmp4 + 2;
|
||||
yh = tmp2 + 2;
|
||||
vxy(&xl, &yl);
|
||||
vxy(&xh, &yh);
|
||||
for (k = yl; k < yh; k++)
|
||||
for (m = xl; m < xh; m++) {
|
||||
switch (item[m][k]) {
|
||||
case OWALL:
|
||||
case OPIT:
|
||||
case OTRAPARROW:
|
||||
case ODARTRAP:
|
||||
case OCLOSEDDOOR:
|
||||
case OTRAPDOOR:
|
||||
case OTELEPORTER:
|
||||
smm: screen[m][k] = 127;
|
||||
break;
|
||||
case OMIRROR:
|
||||
if (mitem[m][k] == VAMPIRE)
|
||||
goto smm;
|
||||
default:
|
||||
screen[m][k] = 0;
|
||||
break;
|
||||
};
|
||||
}
|
||||
screen[playerx][playery] = 1;
|
||||
|
||||
/*
|
||||
* now perform proximity ripple from playerx,playery to
|
||||
* monster
|
||||
*/
|
||||
xl = tmp3 - 1;
|
||||
yl = tmp1 - 1;
|
||||
xh = tmp4 + 1;
|
||||
yh = tmp2 + 1;
|
||||
vxy(&xl, &yl);
|
||||
vxy(&xh, &yh);
|
||||
for (tmp = 1; tmp < distance; tmp++) /* only up to 20 squares
|
||||
* away */
|
||||
for (k = yl; k < yh; k++)
|
||||
for (m = xl; m < xh; m++)
|
||||
if (screen[m][k] == tmp) /* if find proximity n
|
||||
* advance it */
|
||||
for (z = 1; z < 9; z++) { /* go around in a circle */
|
||||
if (screen[xtmp = m + diroffx[z]][ytmp = k + diroffy[z]] == 0)
|
||||
screen[xtmp][ytmp] = tmp + 1;
|
||||
if (xtmp == i && ytmp == j)
|
||||
goto out;
|
||||
}
|
||||
|
||||
out: if (tmp < distance) /* did find connectivity */
|
||||
/* now select lowest value around playerx,playery */
|
||||
for (z = 1; z < 9; z++) /* go around in a circle */
|
||||
if (screen[xl = i + diroffx[z]][yl = j + diroffy[z]] == tmp)
|
||||
if (!mitem[xl][yl]) {
|
||||
mmove(i, j, w1x[0] = xl, w1y[0] = yl);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* dumb monsters move here */
|
||||
xl = i - 1;
|
||||
yl = j - 1;
|
||||
xh = i + 2;
|
||||
yh = j + 2;
|
||||
if (i < playerx)
|
||||
xl++;
|
||||
else if (i > playerx)
|
||||
--xh;
|
||||
if (j < playery)
|
||||
yl++;
|
||||
else if (j > playery)
|
||||
--yh;
|
||||
for (k = 0; k < 9; k++)
|
||||
w1[k] = 10000;
|
||||
|
||||
for (k = xl; k < xh; k++)
|
||||
for (m = yl; m < yh; m++) { /* for each square compute
|
||||
* distance to player */
|
||||
tmp = k - i + 4 + 3 * (m - j);
|
||||
tmpitem = item[k][m];
|
||||
if (tmpitem != OWALL || (k == playerx && m == playery))
|
||||
if (mitem[k][m] == 0)
|
||||
if ((mitem[i][j] != VAMPIRE) || (tmpitem != OMIRROR))
|
||||
if (tmpitem != OCLOSEDDOOR) {
|
||||
w1[tmp] = (playerx - k) * (playerx - k) + (playery - m) * (playery - m);
|
||||
w1x[tmp] = k;
|
||||
w1y[tmp] = m;
|
||||
}
|
||||
}
|
||||
|
||||
tmp = 0;
|
||||
for (k=1; k<9; k++) if (w1[tmp] > w1[k]) tmp=k;
|
||||
for (k = 1; k < 9; k++)
|
||||
if (w1[tmp] > w1[k])
|
||||
tmp = k;
|
||||
|
||||
if (w1[tmp] < 10000)
|
||||
if ((i!=w1x[tmp]) || (j!=w1y[tmp]))
|
||||
mmove(i,j,w1x[tmp],w1y[tmp]);
|
||||
}
|
||||
if ((i != w1x[tmp]) || (j != w1y[tmp]))
|
||||
mmove(i, j, w1x[tmp], w1y[tmp]);
|
||||
}
|
||||
|
||||
/*
|
||||
* mmove(x,y,xd,yd) Function to actually perform the monster movement
|
||||
* int x,y,xd,yd;
|
||||
* mmove(x,y,xd,yd) Function to actually perform the monster movement
|
||||
* int x,y,xd,yd;
|
||||
*
|
||||
* Enter with the from coordinates in (x,y) and the destination coordinates
|
||||
* in (xd,yd).
|
||||
* Enter with the from coordinates in (x,y) and the destination coordinates
|
||||
* in (xd,yd).
|
||||
*/
|
||||
mmove(aa,bb,cc,dd)
|
||||
int aa,bb,cc,dd;
|
||||
{
|
||||
register int tmp,i,flag;
|
||||
char *who,*p;
|
||||
flag=0; /* set to 1 if monster hit by arrow trap */
|
||||
if ((cc==playerx) && (dd==playery))
|
||||
{
|
||||
hitplayer(aa,bb); moved[aa][bb] = 1; return;
|
||||
}
|
||||
i=item[cc][dd];
|
||||
if ((i==OPIT) || (i==OTRAPDOOR))
|
||||
switch(mitem[aa][bb])
|
||||
{
|
||||
case SPIRITNAGA: case PLATINUMDRAGON: case WRAITH:
|
||||
case VAMPIRE: case SILVERDRAGON: case POLTERGEIST:
|
||||
case DEMONLORD: case DEMONLORD+1: case DEMONLORD+2:
|
||||
case DEMONLORD+3: case DEMONLORD+4: case DEMONLORD+5:
|
||||
case DEMONLORD+6: case DEMONPRINCE: break;
|
||||
void
|
||||
mmove(aa, bb, cc, dd)
|
||||
int aa, bb, cc, dd;
|
||||
{
|
||||
int tmp, i, flag;
|
||||
char *who = NULL, *p;
|
||||
flag = 0; /* set to 1 if monster hit by arrow trap */
|
||||
if ((cc == playerx) && (dd == playery)) {
|
||||
hitplayer(aa, bb);
|
||||
moved[aa][bb] = 1;
|
||||
return;
|
||||
}
|
||||
i = item[cc][dd];
|
||||
if ((i == OPIT) || (i == OTRAPDOOR))
|
||||
switch (mitem[aa][bb]) {
|
||||
case SPIRITNAGA:
|
||||
case PLATINUMDRAGON:
|
||||
case WRAITH:
|
||||
case VAMPIRE:
|
||||
case SILVERDRAGON:
|
||||
case POLTERGEIST:
|
||||
case DEMONLORD:
|
||||
case DEMONLORD + 1:
|
||||
case DEMONLORD + 2:
|
||||
case DEMONLORD + 3:
|
||||
case DEMONLORD + 4:
|
||||
case DEMONLORD + 5:
|
||||
case DEMONLORD + 6:
|
||||
case DEMONPRINCE:
|
||||
break;
|
||||
|
||||
default: mitem[aa][bb]=0; /* fell in a pit or trapdoor */
|
||||
default:
|
||||
mitem[aa][bb] = 0; /* fell in a pit or trapdoor */
|
||||
};
|
||||
tmp = mitem[cc][dd] = mitem[aa][bb];
|
||||
if (i==OANNIHILATION)
|
||||
{
|
||||
if (tmp>=DEMONLORD+3) /* demons dispel spheres */
|
||||
{
|
||||
if (i == OANNIHILATION) {
|
||||
if (tmp >= DEMONLORD + 3) { /* demons dispel spheres */
|
||||
cursors();
|
||||
lprintf("\nThe %s dispels the sphere!",monster[tmp].name);
|
||||
rmsphere(cc,dd); /* delete the sphere */
|
||||
}
|
||||
else i=tmp=mitem[cc][dd]=0;
|
||||
}
|
||||
stealth[cc][dd]=1;
|
||||
if ((hitp[cc][dd] = hitp[aa][bb]) < 0) hitp[cc][dd]=1;
|
||||
mitem[aa][bb] = 0; moved[cc][dd] = 1;
|
||||
if (tmp == LEPRECHAUN)
|
||||
switch(i)
|
||||
{
|
||||
case OGOLDPILE: case OMAXGOLD: case OKGOLD: case ODGOLD:
|
||||
case ODIAMOND: case ORUBY: case OEMERALD: case OSAPPHIRE:
|
||||
item[cc][dd] = 0; /* leprechaun takes gold */
|
||||
};
|
||||
|
||||
if (tmp == TROLL) /* if a troll regenerate him */
|
||||
if ((gltime & 1) == 0)
|
||||
if (monster[tmp].hitpoints > hitp[cc][dd]) hitp[cc][dd]++;
|
||||
|
||||
if (i==OTRAPARROW) /* arrow hits monster */
|
||||
{ who = "An arrow"; if ((hitp[cc][dd] -= rnd(10)+level) <= 0)
|
||||
{ mitem[cc][dd]=0; flag=2; } else flag=1; }
|
||||
if (i==ODARTRAP) /* dart hits monster */
|
||||
{ who = "A dart"; if ((hitp[cc][dd] -= rnd(6)) <= 0)
|
||||
{ mitem[cc][dd]=0; flag=2; } else flag=1; }
|
||||
if (i==OTELEPORTER) /* monster hits teleport trap */
|
||||
{ flag=3; fillmonst(mitem[cc][dd]); mitem[cc][dd]=0; }
|
||||
if (c[BLINDCOUNT]) return; /* if blind don't show where monsters are */
|
||||
if (know[cc][dd] & 1)
|
||||
{
|
||||
p=0;
|
||||
if (flag) cursors();
|
||||
switch(flag)
|
||||
{
|
||||
case 1: p="\n%s hits the %s"; break;
|
||||
case 2: p="\n%s hits and kills the %s"; break;
|
||||
case 3: p="\nThe %s%s gets teleported"; who=""; break;
|
||||
};
|
||||
if (p) { lprintf(p,who,monster[tmp].name); beep(); }
|
||||
}
|
||||
/* if (yrepcount>1) { know[aa][bb] &= 2; know[cc][dd] &= 2; return; } */
|
||||
if (know[aa][bb] & 1) show1cell(aa,bb);
|
||||
if (know[cc][dd] & 1) show1cell(cc,dd);
|
||||
lprintf("\nThe %s dispels the sphere!", monster[tmp].name);
|
||||
rmsphere(cc, dd); /* delete the sphere */
|
||||
} else
|
||||
i = tmp = mitem[cc][dd] = 0;
|
||||
}
|
||||
stealth[cc][dd] = 1;
|
||||
if ((hitp[cc][dd] = hitp[aa][bb]) < 0)
|
||||
hitp[cc][dd] = 1;
|
||||
mitem[aa][bb] = 0;
|
||||
moved[cc][dd] = 1;
|
||||
if (tmp == LEPRECHAUN)
|
||||
switch (i) {
|
||||
case OGOLDPILE:
|
||||
case OMAXGOLD:
|
||||
case OKGOLD:
|
||||
case ODGOLD:
|
||||
case ODIAMOND:
|
||||
case ORUBY:
|
||||
case OEMERALD:
|
||||
case OSAPPHIRE:
|
||||
item[cc][dd] = 0; /* leprechaun takes gold */
|
||||
};
|
||||
|
||||
if (tmp == TROLL) /* if a troll regenerate him */
|
||||
if ((gltime & 1) == 0)
|
||||
if (monster[tmp].hitpoints > hitp[cc][dd])
|
||||
hitp[cc][dd]++;
|
||||
|
||||
if (i == OTRAPARROW) { /* arrow hits monster */
|
||||
who = "An arrow";
|
||||
if ((hitp[cc][dd] -= rnd(10) + level) <= 0) {
|
||||
mitem[cc][dd] = 0;
|
||||
flag = 2;
|
||||
} else
|
||||
flag = 1;
|
||||
}
|
||||
if (i == ODARTRAP) { /* dart hits monster */
|
||||
who = "A dart";
|
||||
if ((hitp[cc][dd] -= rnd(6)) <= 0) {
|
||||
mitem[cc][dd] = 0;
|
||||
flag = 2;
|
||||
} else
|
||||
flag = 1;
|
||||
}
|
||||
if (i == OTELEPORTER) { /* monster hits teleport trap */
|
||||
flag = 3;
|
||||
fillmonst(mitem[cc][dd]);
|
||||
mitem[cc][dd] = 0;
|
||||
}
|
||||
if (c[BLINDCOUNT])
|
||||
return; /* if blind don't show where monsters are */
|
||||
if (know[cc][dd] & 1) {
|
||||
p = 0;
|
||||
if (flag)
|
||||
cursors();
|
||||
switch (flag) {
|
||||
case 1:
|
||||
p = "\n%s hits the %s";
|
||||
break;
|
||||
case 2:
|
||||
p = "\n%s hits and kills the %s";
|
||||
break;
|
||||
case 3:
|
||||
p = "\nThe %s%s gets teleported";
|
||||
who = "";
|
||||
break;
|
||||
};
|
||||
if (p) {
|
||||
lprintf(p, who, monster[tmp].name);
|
||||
beep();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if (yrepcount>1) { know[aa][bb] &= 2; know[cc][dd] &= 2; return;
|
||||
* }
|
||||
*/
|
||||
if (know[aa][bb] & 1)
|
||||
show1cell(aa, bb);
|
||||
if (know[cc][dd] & 1)
|
||||
show1cell(cc, dd);
|
||||
}
|
||||
|
||||
/*
|
||||
* movsphere() Function to look for and move spheres of annihilation
|
||||
* movsphere() Function to look for and move spheres of annihilation
|
||||
*
|
||||
* This function works on the sphere linked list, first duplicating the list
|
||||
* (the act of moving changes the list), then processing each sphere in order
|
||||
* to move it. They eat anything in their way, including stairs, volcanic
|
||||
* shafts, potions, etc, except for upper level demons, who can dispel
|
||||
* spheres.
|
||||
* No value is returned.
|
||||
* This function works on the sphere linked list, first duplicating the list
|
||||
* (the act of moving changes the list), then processing each sphere in order
|
||||
* to move it. They eat anything in their way, including stairs, volcanic
|
||||
* shafts, potions, etc, except for upper level demons, who can dispel
|
||||
* spheres.
|
||||
* No value is returned.
|
||||
*/
|
||||
#define SPHMAX 20 /* maximum number of spheres movsphere can handle */
|
||||
#define SPHMAX 20 /* maximum number of spheres movsphere can
|
||||
* handle */
|
||||
void
|
||||
movsphere()
|
||||
{
|
||||
register int x,y,dir,len;
|
||||
register struct sphere *sp,*sp2;
|
||||
struct sphere sph[SPHMAX];
|
||||
{
|
||||
int x, y, dir, len;
|
||||
struct sphere *sp, *sp2;
|
||||
struct sphere sph[SPHMAX];
|
||||
|
||||
/* first duplicate sphere list */
|
||||
for (sp=0,x=0,sp2=spheres; sp2; sp2=sp2->p) /* look through sphere list */
|
||||
if (sp2->lev == level) /* only if this level */
|
||||
{
|
||||
sph[x] = *sp2; sph[x++].p = 0; /* copy the struct */
|
||||
if (x>1) sph[x-2].p = &sph[x-1]; /* link pointers */
|
||||
for (sp = 0, x = 0, sp2 = spheres; sp2; sp2 = sp2->p) /* look through sphere
|
||||
* list */
|
||||
if (sp2->lev == level) { /* only if this level */
|
||||
sph[x] = *sp2;
|
||||
sph[x++].p = 0; /* copy the struct */
|
||||
if (x > 1)
|
||||
sph[x - 2].p = &sph[x - 1]; /* link pointers */
|
||||
}
|
||||
if (x) sp= sph; /* if any spheres, point to them */
|
||||
else return; /* no spheres */
|
||||
if (x)
|
||||
sp = sph; /* if any spheres, point to them */
|
||||
else
|
||||
return; /* no spheres */
|
||||
|
||||
for (sp=sph; sp; sp=sp->p) /* look through sphere list */
|
||||
{
|
||||
x = sp->x; y = sp->y;
|
||||
if (item[x][y]!=OANNIHILATION) continue; /* not really there */
|
||||
if (--(sp->lifetime) < 0) /* has sphere run out of gas? */
|
||||
{
|
||||
rmsphere(x,y); /* delete sphere */
|
||||
for (sp = sph; sp; sp = sp->p) { /* look through sphere list */
|
||||
x = sp->x;
|
||||
y = sp->y;
|
||||
if (item[x][y] != OANNIHILATION)
|
||||
continue; /* not really there */
|
||||
if (--(sp->lifetime) < 0) { /* has sphere run out of gas? */
|
||||
rmsphere(x, y); /* delete sphere */
|
||||
continue;
|
||||
}
|
||||
switch(rnd((int)max(7,c[INTELLIGENCE]>>1))) /* time to move the sphere */
|
||||
{
|
||||
case 1:
|
||||
case 2: /* change direction to a random one */
|
||||
sp->dir = rnd(8);
|
||||
default: /* move in normal direction */
|
||||
dir = sp->dir; len = sp->lifetime;
|
||||
rmsphere(x,y);
|
||||
newsphere(x+diroffx[dir],y+diroffy[dir],dir,len);
|
||||
};
|
||||
}
|
||||
switch (rnd((int) max(7, c[INTELLIGENCE] >> 1))) { /* time to move the
|
||||
* sphere */
|
||||
case 1:
|
||||
case 2: /* change direction to a random one */
|
||||
sp->dir = rnd(8);
|
||||
default: /* move in normal direction */
|
||||
dir = sp->dir;
|
||||
len = sp->lifetime;
|
||||
rmsphere(x, y);
|
||||
newsphere(x + diroffx[dir], y + diroffy[dir], dir, len);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,24 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: nap.c,v 1.4 1995/04/27 22:15:28 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: nap.c,v 1.5 1997/10/18 20:03:36 christos Exp $ */
|
||||
|
||||
/* nap.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: nap.c,v 1.5 1997/10/18 20:03:36 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <unistd.h>
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
* routine to take a nap for n milliseconds
|
||||
*/
|
||||
void
|
||||
nap(x)
|
||||
register int x;
|
||||
{
|
||||
if (x<=0) return; /* eliminate chance for infinite loop */
|
||||
int x;
|
||||
{
|
||||
if (x <= 0)
|
||||
return; /* eliminate chance for infinite loop */
|
||||
lflush();
|
||||
usleep(x*1000);
|
||||
}
|
||||
usleep(x * 1000);
|
||||
}
|
||||
|
1732
games/larn/object.c
1732
games/larn/object.c
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pathnames.h,v 1.6 1997/01/07 12:12:22 tls Exp $ */
|
||||
/* $NetBSD: pathnames.h,v 1.7 1997/10/18 20:03:41 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -1,9 +1,13 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: regen.c,v 1.4 1997/07/13 20:21:39 christos Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: regen.c,v 1.5 1997/10/18 20:03:43 christos Exp $ */
|
||||
|
||||
/* regen.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: regen.c,v 1.5 1997/10/18 20:03:43 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
/*
|
||||
*******
|
||||
REGEN()
|
||||
@ -12,85 +16,172 @@ static char rcsid[] = "$NetBSD: regen.c,v 1.4 1997/07/13 20:21:39 christos Exp $
|
||||
|
||||
subroutine to regenerate player hp and spells
|
||||
*/
|
||||
void
|
||||
regen()
|
||||
{
|
||||
register int i,flag;
|
||||
register long *d;
|
||||
{
|
||||
int i, flag;
|
||||
long *d;
|
||||
d = c;
|
||||
#ifdef EXTRA
|
||||
d[MOVESMADE]++;
|
||||
#endif
|
||||
if (d[TIMESTOP]) { if(--d[TIMESTOP]<=0) bottomline(); return; } /* for stop time spell */
|
||||
flag=0;
|
||||
if (d[TIMESTOP]) {
|
||||
if (--d[TIMESTOP] <= 0)
|
||||
bottomline();
|
||||
return;
|
||||
} /* for stop time spell */
|
||||
flag = 0;
|
||||
|
||||
if (d[STRENGTH]<3) { d[STRENGTH]=3; flag=1; }
|
||||
if ((d[HASTESELF]==0) || ((d[HASTESELF] & 1) == 0))
|
||||
if (d[STRENGTH] < 3) {
|
||||
d[STRENGTH] = 3;
|
||||
flag = 1;
|
||||
}
|
||||
if ((d[HASTESELF] == 0) || ((d[HASTESELF] & 1) == 0))
|
||||
gltime++;
|
||||
|
||||
if (d[HP] != d[HPMAX])
|
||||
if (d[REGENCOUNTER]-- <= 0) /* regenerate hit points */
|
||||
{
|
||||
d[REGENCOUNTER] = 22 + (d[HARDGAME]<<1) - d[LEVEL];
|
||||
if ((d[HP] += d[REGEN]) > d[HPMAX]) d[HP] = d[HPMAX];
|
||||
if (d[REGENCOUNTER]-- <= 0) { /* regenerate hit points */
|
||||
d[REGENCOUNTER] = 22 + (d[HARDGAME] << 1) - d[LEVEL];
|
||||
if ((d[HP] += d[REGEN]) > d[HPMAX])
|
||||
d[HP] = d[HPMAX];
|
||||
bottomhp();
|
||||
}
|
||||
|
||||
if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */
|
||||
if (d[ECOUNTER]-- <= 0)
|
||||
{
|
||||
d[ECOUNTER] = 100+4*(d[HARDGAME]-d[LEVEL]-d[ENERGY]);
|
||||
d[SPELLS]++; bottomspell();
|
||||
}
|
||||
|
||||
if (d[HERO]) if (--d[HERO]<=0) { for (i=0; i<6; i++) d[i] -= 10; flag=1; }
|
||||
if (d[ALTPRO]) if (--d[ALTPRO]<=0) { d[MOREDEFENSES]-=3; flag=1; }
|
||||
if (d[PROTECTIONTIME]) if (--d[PROTECTIONTIME]<=0) { d[MOREDEFENSES]-=2; flag=1; }
|
||||
if (d[DEXCOUNT]) if (--d[DEXCOUNT]<=0) { d[DEXTERITY]-=3; flag=1; }
|
||||
if (d[STRCOUNT]) if (--d[STRCOUNT]<=0) { d[STREXTRA]-=3; flag=1; }
|
||||
if (d[BLINDCOUNT]) if (--d[BLINDCOUNT]<=0) { cursors(); lprcat("\nThe blindness lifts "); beep(); }
|
||||
if (d[CONFUSE]) if (--d[CONFUSE]<=0) { cursors(); lprcat("\nYou regain your senses"); beep(); }
|
||||
if (d[GIANTSTR]) if (--d[GIANTSTR]<=0) { d[STREXTRA] -= 20; flag=1; }
|
||||
if (d[CHARMCOUNT]) if ((--d[CHARMCOUNT]) <= 0) flag=1;
|
||||
if (d[INVISIBILITY]) if ((--d[INVISIBILITY]) <= 0) flag=1;
|
||||
if (d[CANCELLATION]) if ((--d[CANCELLATION]) <= 0) flag=1;
|
||||
if (d[WTW]) if ((--d[WTW]) <= 0) flag=1;
|
||||
if (d[HASTESELF]) if ((--d[HASTESELF]) <= 0) flag=1;
|
||||
if (d[AGGRAVATE]) --d[AGGRAVATE];
|
||||
if (d[SCAREMONST]) if ((--d[SCAREMONST]) <= 0) flag=1;
|
||||
if (d[STEALTH]) if ((--d[STEALTH]) <= 0) flag=1;
|
||||
if (d[AWARENESS]) --d[AWARENESS];
|
||||
if (d[HOLDMONST]) if ((--d[HOLDMONST]) <= 0) flag=1;
|
||||
if (d[HASTEMONST]) --d[HASTEMONST];
|
||||
if (d[FIRERESISTANCE]) if ((--d[FIRERESISTANCE]) <= 0) flag=1;
|
||||
if (d[GLOBE]) if (--d[GLOBE]<=0) { d[MOREDEFENSES]-=10; flag=1; }
|
||||
if (d[SPIRITPRO]) if (--d[SPIRITPRO] <= 0) flag=1;
|
||||
if (d[UNDEADPRO]) if (--d[UNDEADPRO] <= 0) flag=1;
|
||||
if (d[HALFDAM]) if (--d[HALFDAM]<=0) { cursors(); lprcat("\nYou now feel better "); beep(); }
|
||||
}
|
||||
if (d[SPELLS] < d[SPELLMAX]) /* regenerate spells */
|
||||
if (d[ECOUNTER]-- <= 0) {
|
||||
d[ECOUNTER] = 100 + 4 * (d[HARDGAME] - d[LEVEL] - d[ENERGY]);
|
||||
d[SPELLS]++;
|
||||
bottomspell();
|
||||
}
|
||||
if (d[HERO])
|
||||
if (--d[HERO] <= 0) {
|
||||
for (i = 0; i < 6; i++)
|
||||
d[i] -= 10;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[ALTPRO])
|
||||
if (--d[ALTPRO] <= 0) {
|
||||
d[MOREDEFENSES] -= 3;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[PROTECTIONTIME])
|
||||
if (--d[PROTECTIONTIME] <= 0) {
|
||||
d[MOREDEFENSES] -= 2;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[DEXCOUNT])
|
||||
if (--d[DEXCOUNT] <= 0) {
|
||||
d[DEXTERITY] -= 3;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[STRCOUNT])
|
||||
if (--d[STRCOUNT] <= 0) {
|
||||
d[STREXTRA] -= 3;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[BLINDCOUNT])
|
||||
if (--d[BLINDCOUNT] <= 0) {
|
||||
cursors();
|
||||
lprcat("\nThe blindness lifts ");
|
||||
beep();
|
||||
}
|
||||
if (d[CONFUSE])
|
||||
if (--d[CONFUSE] <= 0) {
|
||||
cursors();
|
||||
lprcat("\nYou regain your senses");
|
||||
beep();
|
||||
}
|
||||
if (d[GIANTSTR])
|
||||
if (--d[GIANTSTR] <= 0) {
|
||||
d[STREXTRA] -= 20;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[CHARMCOUNT])
|
||||
if ((--d[CHARMCOUNT]) <= 0)
|
||||
flag = 1;
|
||||
if (d[INVISIBILITY])
|
||||
if ((--d[INVISIBILITY]) <= 0)
|
||||
flag = 1;
|
||||
if (d[CANCELLATION])
|
||||
if ((--d[CANCELLATION]) <= 0)
|
||||
flag = 1;
|
||||
if (d[WTW])
|
||||
if ((--d[WTW]) <= 0)
|
||||
flag = 1;
|
||||
if (d[HASTESELF])
|
||||
if ((--d[HASTESELF]) <= 0)
|
||||
flag = 1;
|
||||
if (d[AGGRAVATE])
|
||||
--d[AGGRAVATE];
|
||||
if (d[SCAREMONST])
|
||||
if ((--d[SCAREMONST]) <= 0)
|
||||
flag = 1;
|
||||
if (d[STEALTH])
|
||||
if ((--d[STEALTH]) <= 0)
|
||||
flag = 1;
|
||||
if (d[AWARENESS])
|
||||
--d[AWARENESS];
|
||||
if (d[HOLDMONST])
|
||||
if ((--d[HOLDMONST]) <= 0)
|
||||
flag = 1;
|
||||
if (d[HASTEMONST])
|
||||
--d[HASTEMONST];
|
||||
if (d[FIRERESISTANCE])
|
||||
if ((--d[FIRERESISTANCE]) <= 0)
|
||||
flag = 1;
|
||||
if (d[GLOBE])
|
||||
if (--d[GLOBE] <= 0) {
|
||||
d[MOREDEFENSES] -= 10;
|
||||
flag = 1;
|
||||
}
|
||||
if (d[SPIRITPRO])
|
||||
if (--d[SPIRITPRO] <= 0)
|
||||
flag = 1;
|
||||
if (d[UNDEADPRO])
|
||||
if (--d[UNDEADPRO] <= 0)
|
||||
flag = 1;
|
||||
if (d[HALFDAM])
|
||||
if (--d[HALFDAM] <= 0) {
|
||||
cursors();
|
||||
lprcat("\nYou now feel better ");
|
||||
beep();
|
||||
}
|
||||
if (d[SEEINVISIBLE])
|
||||
if (--d[SEEINVISIBLE]<=0)
|
||||
{ monstnamelist[INVISIBLESTALKER] = ' ';
|
||||
cursors(); lprcat("\nYou feel your vision return to normal"); beep(); }
|
||||
if (d[ITCHING])
|
||||
{
|
||||
if (d[ITCHING]>1)
|
||||
if ((d[WEAR]!= -1) || (d[SHIELD]!= -1))
|
||||
if (rnd(100)<50)
|
||||
{
|
||||
d[WEAR]=d[SHIELD]= -1; cursors();
|
||||
lprcat("\nThe hysteria of itching forces you to remove your armor!");
|
||||
beep(); recalc(); bottomline();
|
||||
}
|
||||
if (--d[ITCHING]<=0) { cursors(); lprcat("\nYou now feel the irritation subside!"); beep(); }
|
||||
if (--d[SEEINVISIBLE] <= 0) {
|
||||
monstnamelist[INVISIBLESTALKER] = ' ';
|
||||
cursors();
|
||||
lprcat("\nYou feel your vision return to normal");
|
||||
beep();
|
||||
}
|
||||
if (d[CLUMSINESS])
|
||||
{
|
||||
if (d[WIELD] != -1)
|
||||
if (d[CLUMSINESS]>1)
|
||||
if (item[playerx][playery]==0) /* only if nothing there */
|
||||
if (rnd(100)<33) /* drop your weapon due to clumsiness */
|
||||
drop_object((int)d[WIELD]);
|
||||
if (--d[CLUMSINESS]<=0) { cursors(); lprcat("\nYou now feel less awkward!"); beep(); }
|
||||
if (d[ITCHING]) {
|
||||
if (d[ITCHING] > 1)
|
||||
if ((d[WEAR] != -1) || (d[SHIELD] != -1))
|
||||
if (rnd(100) < 50) {
|
||||
d[WEAR] = d[SHIELD] = -1;
|
||||
cursors();
|
||||
lprcat("\nThe hysteria of itching forces you to remove your armor!");
|
||||
beep();
|
||||
recalc();
|
||||
bottomline();
|
||||
}
|
||||
if (--d[ITCHING] <= 0) {
|
||||
cursors();
|
||||
lprcat("\nYou now feel the irritation subside!");
|
||||
beep();
|
||||
}
|
||||
if (flag) bottomline();
|
||||
}
|
||||
|
||||
if (d[CLUMSINESS]) {
|
||||
if (d[WIELD] != -1)
|
||||
if (d[CLUMSINESS] > 1)
|
||||
if (item[playerx][playery] == 0) /* only if nothing there */
|
||||
if (rnd(100) < 33) /* drop your weapon due
|
||||
* to clumsiness */
|
||||
drop_object((int) d[WIELD]);
|
||||
if (--d[CLUMSINESS] <= 0) {
|
||||
cursors();
|
||||
lprcat("\nYou now feel less awkward!");
|
||||
beep();
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
bottomline();
|
||||
}
|
||||
|
@ -1,51 +1,65 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: savelev.c,v 1.3 1995/03/23 08:34:13 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: savelev.c,v 1.4 1997/10/18 20:03:45 christos Exp $ */
|
||||
|
||||
/* savelev.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: savelev.c,v 1.4 1997/10/18 20:03:45 christos Exp $");
|
||||
#endif /* not lint */
|
||||
#include "header.h"
|
||||
extern struct cel *cell;
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
* routine to save the present level into storage
|
||||
*/
|
||||
void
|
||||
savelevel()
|
||||
{
|
||||
register struct cel *pcel;
|
||||
register char *pitem,*pknow,*pmitem;
|
||||
register short *phitp,*piarg;
|
||||
register struct cel *pecel;
|
||||
pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
|
||||
pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells */
|
||||
pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
|
||||
while (pcel < pecel)
|
||||
{
|
||||
pcel->mitem = *pmitem++;
|
||||
pcel->hitp = *phitp++;
|
||||
pcel->item = *pitem++;
|
||||
pcel->know = *pknow++;
|
||||
{
|
||||
struct cel *pcel;
|
||||
char *pitem, *pknow, *pmitem;
|
||||
short *phitp, *piarg;
|
||||
struct cel *pecel;
|
||||
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
|
||||
* cells */
|
||||
pecel = pcel + MAXX * MAXY; /* pointer to past end of this
|
||||
* level's cells */
|
||||
pitem = item[0];
|
||||
piarg = iarg[0];
|
||||
pknow = know[0];
|
||||
pmitem = mitem[0];
|
||||
phitp = hitp[0];
|
||||
while (pcel < pecel) {
|
||||
pcel->mitem = *pmitem++;
|
||||
pcel->hitp = *phitp++;
|
||||
pcel->item = *pitem++;
|
||||
pcel->know = *pknow++;
|
||||
pcel++->iarg = *piarg++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* routine to restore a level from storage
|
||||
*/
|
||||
void
|
||||
getlevel()
|
||||
{
|
||||
register struct cel *pcel;
|
||||
register char *pitem,*pknow,*pmitem;
|
||||
register short *phitp,*piarg;
|
||||
register struct cel *pecel;
|
||||
pcel = &cell[level*MAXX*MAXY]; /* pointer to this level's cells */
|
||||
pecel = pcel + MAXX*MAXY; /* pointer to past end of this level's cells */
|
||||
pitem=item[0]; piarg=iarg[0]; pknow=know[0]; pmitem=mitem[0]; phitp=hitp[0];
|
||||
while (pcel < pecel)
|
||||
{
|
||||
{
|
||||
struct cel *pcel;
|
||||
char *pitem, *pknow, *pmitem;
|
||||
short *phitp, *piarg;
|
||||
struct cel *pecel;
|
||||
pcel = &cell[level * MAXX * MAXY]; /* pointer to this level's
|
||||
* cells */
|
||||
pecel = pcel + MAXX * MAXY; /* pointer to past end of this
|
||||
* level's cells */
|
||||
pitem = item[0];
|
||||
piarg = iarg[0];
|
||||
pknow = know[0];
|
||||
pmitem = mitem[0];
|
||||
phitp = hitp[0];
|
||||
while (pcel < pecel) {
|
||||
*pmitem++ = pcel->mitem;
|
||||
*phitp++ = pcel->hitp;
|
||||
*pitem++ = pcel->item;
|
||||
*pknow++ = pcel->know;
|
||||
*piarg++ = pcel++->iarg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1158
games/larn/scores.c
1158
games/larn/scores.c
File diff suppressed because it is too large
Load Diff
@ -1,86 +1,140 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: signal.c,v 1.5 1995/12/21 11:27:51 mycroft Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: signal.c,v 1.6 1997/10/18 20:03:50 christos Exp $ */
|
||||
|
||||
/* "Larn is copyrighted 1986 by Noah Morgan.\n" */
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: signal.c,v 1.6 1997/10/18 20:03:50 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include "header.h" /* "Larn is copyrighted 1986 by Noah Morgan.\n" */
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
static void s2choose __P((void));
|
||||
static void cntlc __P((int));
|
||||
static void sgam __P((int));
|
||||
static void tstop __P((int));
|
||||
static void sigpanic __P((int));
|
||||
|
||||
#define BIT(a) (1<<((a)-1))
|
||||
extern char savefilename[],wizard,predostuff,nosignal;
|
||||
static s2choose() /* text to be displayed if ^C during intro screen */
|
||||
{
|
||||
cursor(1,24); lprcat("Press "); setbold(); lprcat("return"); resetbold();
|
||||
lprcat(" to continue: "); lflush();
|
||||
}
|
||||
|
||||
static void
|
||||
cntlc() /* what to do for a ^C */
|
||||
{
|
||||
if (nosignal) return; /* don't do anything if inhibited */
|
||||
signal(SIGQUIT,SIG_IGN); signal(SIGINT,SIG_IGN);
|
||||
quit(); if (predostuff==1) s2choose(); else showplayer();
|
||||
s2choose()
|
||||
{ /* text to be displayed if ^C during intro
|
||||
* screen */
|
||||
cursor(1, 24);
|
||||
lprcat("Press ");
|
||||
setbold();
|
||||
lprcat("return");
|
||||
resetbold();
|
||||
lprcat(" to continue: ");
|
||||
lflush();
|
||||
signal(SIGQUIT,cntlc); signal(SIGINT,cntlc);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cntlc(n)
|
||||
int n;
|
||||
{ /* what to do for a ^C */
|
||||
if (nosignal)
|
||||
return; /* don't do anything if inhibited */
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
quit();
|
||||
if (predostuff == 1)
|
||||
s2choose();
|
||||
else
|
||||
showplayer();
|
||||
lflush();
|
||||
signal(SIGQUIT, cntlc);
|
||||
signal(SIGINT, cntlc);
|
||||
}
|
||||
|
||||
/*
|
||||
* subroutine to save the game if a hangup signal
|
||||
*/
|
||||
static void
|
||||
sgam()
|
||||
{
|
||||
savegame(savefilename); wizard=1; died(-257); /* hangup signal */
|
||||
}
|
||||
sgam(n)
|
||||
int n;
|
||||
{
|
||||
savegame(savefilename);
|
||||
wizard = 1;
|
||||
died(-257); /* hangup signal */
|
||||
}
|
||||
|
||||
#ifdef SIGTSTP
|
||||
static void
|
||||
tstop() /* control Y */
|
||||
{
|
||||
if (nosignal) return; /* nothing if inhibited */
|
||||
lcreat((char*)0); clearvt100(); lflush(); signal(SIGTSTP,SIG_DFL);
|
||||
tstop(n)
|
||||
int n;
|
||||
{ /* control Y */
|
||||
if (nosignal)
|
||||
return; /* nothing if inhibited */
|
||||
lcreat((char *) 0);
|
||||
clearvt100();
|
||||
lflush();
|
||||
signal(SIGTSTP, SIG_DFL);
|
||||
#ifdef SIGVTALRM
|
||||
/* looks like BSD4.2 or higher - must clr mask for signal to take effect*/
|
||||
sigsetmask(sigblock(0)& ~BIT(SIGTSTP));
|
||||
/*
|
||||
* looks like BSD4.2 or higher - must clr mask for signal to take
|
||||
* effect
|
||||
*/
|
||||
sigsetmask(sigblock(0) & ~BIT(SIGTSTP));
|
||||
#endif
|
||||
kill(getpid(),SIGTSTP);
|
||||
kill(getpid(), SIGTSTP);
|
||||
|
||||
setupvt100(); signal(SIGTSTP,tstop);
|
||||
if (predostuff==1) s2choose(); else drawscreen();
|
||||
showplayer(); lflush();
|
||||
}
|
||||
#endif SIGTSTP
|
||||
setupvt100();
|
||||
signal(SIGTSTP, tstop);
|
||||
if (predostuff == 1)
|
||||
s2choose();
|
||||
else
|
||||
drawscreen();
|
||||
showplayer();
|
||||
lflush();
|
||||
}
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
/*
|
||||
* subroutine to issue the needed signal traps called from main()
|
||||
*/
|
||||
static void sigpanic();
|
||||
void
|
||||
sigsetup()
|
||||
{
|
||||
signal(SIGQUIT, cntlc); signal(SIGINT, cntlc);
|
||||
signal(SIGKILL, SIG_IGN); signal(SIGHUP, sgam);
|
||||
signal(SIGILL, sigpanic); signal(SIGTRAP, sigpanic);
|
||||
signal(SIGIOT, sigpanic); signal(SIGEMT, sigpanic);
|
||||
signal(SIGFPE, sigpanic); signal(SIGBUS, sigpanic);
|
||||
signal(SIGSEGV, sigpanic); signal(SIGSYS, sigpanic);
|
||||
signal(SIGPIPE, sigpanic); signal(SIGTERM, sigpanic);
|
||||
{
|
||||
signal(SIGQUIT, cntlc);
|
||||
signal(SIGINT, cntlc);
|
||||
signal(SIGKILL, SIG_IGN);
|
||||
signal(SIGHUP, sgam);
|
||||
signal(SIGILL, sigpanic);
|
||||
signal(SIGTRAP, sigpanic);
|
||||
signal(SIGIOT, sigpanic);
|
||||
signal(SIGEMT, sigpanic);
|
||||
signal(SIGFPE, sigpanic);
|
||||
signal(SIGBUS, sigpanic);
|
||||
signal(SIGSEGV, sigpanic);
|
||||
signal(SIGSYS, sigpanic);
|
||||
signal(SIGPIPE, sigpanic);
|
||||
signal(SIGTERM, sigpanic);
|
||||
#ifdef SIGTSTP
|
||||
signal(SIGTSTP,tstop); signal(SIGSTOP,tstop);
|
||||
#endif SIGTSTP
|
||||
}
|
||||
signal(SIGTSTP, tstop);
|
||||
signal(SIGSTOP, tstop);
|
||||
#endif /* SIGTSTP */
|
||||
}
|
||||
|
||||
/*
|
||||
* routine to process a fatal error signal
|
||||
*/
|
||||
static void
|
||||
sigpanic(sig)
|
||||
int sig;
|
||||
{
|
||||
char buf[128];
|
||||
signal(sig,SIG_DFL);
|
||||
sprintf(buf,"\nLarn - Panic! Signal %d received [SIG%s]",sig,sys_signame[sig]);
|
||||
write(2,buf,strlen(buf)); sleep(2);
|
||||
int sig;
|
||||
{
|
||||
char buf[128];
|
||||
signal(sig, SIG_DFL);
|
||||
sprintf(buf, "\nLarn - Panic! Signal %d received [SIG%s]", sig, sys_signame[sig]);
|
||||
write(2, buf, strlen(buf));
|
||||
sleep(2);
|
||||
sncbr();
|
||||
savegame(savefilename);
|
||||
kill(getpid(),sig); /* this will terminate us */
|
||||
}
|
||||
savegame(savefilename);
|
||||
kill(getpid(), sig); /* this will terminate us */
|
||||
}
|
||||
|
1208
games/larn/store.c
1208
games/larn/store.c
File diff suppressed because it is too large
Load Diff
407
games/larn/tok.c
407
games/larn/tok.c
@ -1,223 +1,274 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$NetBSD: tok.c,v 1.4 1995/04/24 12:24:14 cgd Exp $";
|
||||
#endif /* not lint */
|
||||
/* $NetBSD: tok.c,v 1.5 1997/10/18 20:03:54 christos Exp $ */
|
||||
|
||||
/* tok.c Larn is copyrighted 1986 by Noah Morgan. */
|
||||
#include <sys/types.h>
|
||||
#ifdef SYSV
|
||||
#include <fcntl.h>
|
||||
#include <termio.h>
|
||||
#else SYSV
|
||||
#include <sys/ioctl.h>
|
||||
#endif SYSV
|
||||
#include "header.h"
|
||||
#include <string.h>
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: tok.c,v 1.5 1997/10/18 20:03:54 christos Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
static char lastok=0;
|
||||
int yrepcount=0,dayplay=0;
|
||||
#include <sys/types.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/wait.h>
|
||||
#include "header.h"
|
||||
#include "extern.h"
|
||||
|
||||
static char lastok = 0;
|
||||
int yrepcount = 0, dayplay = 0;
|
||||
#ifndef FLUSHNO
|
||||
#define FLUSHNO 5
|
||||
#endif FLUSHNO
|
||||
static int flushno=FLUSHNO; /* input queue flushing threshold */
|
||||
#define MAXUM 52 /* maximum number of user re-named monsters */
|
||||
#define MAXMNAME 40 /* max length of a monster re-name */
|
||||
static char usermonster[MAXUM][MAXMNAME]; /* the user named monster name goes here */
|
||||
static char usermpoint=0; /* the user monster pointer */
|
||||
#endif /* FLUSHNO */
|
||||
static int flushno = FLUSHNO; /* input queue flushing threshold */
|
||||
#define MAXUM 52 /* maximum number of user re-named monsters */
|
||||
#define MAXMNAME 40 /* max length of a monster re-name */
|
||||
static char usermonster[MAXUM][MAXMNAME]; /* the user named monster
|
||||
* name goes here */
|
||||
static u_char usermpoint = 0; /* the user monster pointer */
|
||||
|
||||
/*
|
||||
lexical analyzer for larn
|
||||
*/
|
||||
int
|
||||
yylex()
|
||||
{
|
||||
char cc;
|
||||
int ic;
|
||||
if (hit2flag) { hit2flag=0; yrepcount=0; return(' '); }
|
||||
if (yrepcount>0) { --yrepcount; return(lastok); } else yrepcount=0;
|
||||
if (yrepcount==0) { bottomdo(); showplayer(); } /* show where the player is */
|
||||
lflush();
|
||||
while (1)
|
||||
{
|
||||
{
|
||||
char cc;
|
||||
int ic;
|
||||
if (hit2flag) {
|
||||
hit2flag = 0;
|
||||
yrepcount = 0;
|
||||
return (' ');
|
||||
}
|
||||
if (yrepcount > 0) {
|
||||
--yrepcount;
|
||||
return (lastok);
|
||||
} else
|
||||
yrepcount = 0;
|
||||
if (yrepcount == 0) {
|
||||
bottomdo();
|
||||
showplayer();
|
||||
} /* show where the player is */
|
||||
lflush();
|
||||
while (1) {
|
||||
c[BYTESIN]++;
|
||||
if (ckpflag)
|
||||
if ((c[BYTESIN] % 400) == 0) /* check for periodic checkpointing */
|
||||
{
|
||||
if ((c[BYTESIN] % 400) == 0) { /* check for periodic
|
||||
* checkpointing */
|
||||
#ifndef DOCHECKPOINTS
|
||||
savegame(ckpfile);
|
||||
savegame(ckpfile);
|
||||
#else
|
||||
wait(0); /* wait for other forks to finish */
|
||||
if (fork() == 0) { savegame(ckpfile); exit(); }
|
||||
wait(0); /* wait for other forks to
|
||||
* finish */
|
||||
if (fork() == 0) {
|
||||
savegame(ckpfile);
|
||||
exit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef TIMECHECK
|
||||
if (dayplay==0)
|
||||
if (playable())
|
||||
{
|
||||
cursor(1,19);
|
||||
lprcat("\nSorry, but it is now time for work. Your game has been saved.\n"); beep();
|
||||
lflush(); savegame(savefilename); wizard=nomove=1; sleep(4);
|
||||
died(-257);
|
||||
}
|
||||
#endif TIMECHECK
|
||||
if (dayplay == 0)
|
||||
if (playable()) {
|
||||
cursor(1, 19);
|
||||
lprcat("\nSorry, but it is now time for work. Your game has been saved.\n");
|
||||
beep();
|
||||
lflush();
|
||||
savegame(savefilename);
|
||||
wizard = nomove = 1;
|
||||
sleep(4);
|
||||
died(-257);
|
||||
}
|
||||
#endif /* TIMECHECK */
|
||||
|
||||
}
|
||||
do { /* if keyboard input buffer is too big, flush
|
||||
* some of it */
|
||||
ioctl(0, FIONREAD, &ic);
|
||||
if (ic > flushno)
|
||||
read(0, &cc, 1);
|
||||
}
|
||||
while (ic > flushno);
|
||||
|
||||
do /* if keyboard input buffer is too big, flush some of it */
|
||||
{
|
||||
ioctl(0,FIONREAD,&ic);
|
||||
if (ic>flushno) read(0,&cc,1);
|
||||
if (read(0, &cc, 1) != 1)
|
||||
return (lastok = -1);
|
||||
|
||||
if (cc == 'Y' - 64) { /* control Y -- shell escape */
|
||||
resetscroll();
|
||||
clear();/* scrolling region, home, clear, no
|
||||
* attributes */
|
||||
if ((ic = fork()) == 0) { /* child */
|
||||
execl("/bin/csh", 0);
|
||||
exit(1);
|
||||
}
|
||||
while (ic>flushno);
|
||||
|
||||
if (read(0,&cc,1) != 1) return(lastok = -1);
|
||||
|
||||
if (cc == 'Y'-64) /* control Y -- shell escape */
|
||||
{
|
||||
resetscroll(); clear(); /* scrolling region, home, clear, no attributes */
|
||||
if ((ic=fork())==0) /* child */
|
||||
{
|
||||
execl("/bin/csh",0); exit();
|
||||
}
|
||||
wait(0);
|
||||
if (ic<0) /* error */
|
||||
{
|
||||
write(2,"Can't fork off a shell!\n",25); sleep(2);
|
||||
}
|
||||
|
||||
setscroll();
|
||||
return(lastok = 'L'-64); /* redisplay screen */
|
||||
if (ic < 0) { /* error */
|
||||
write(2, "Can't fork off a shell!\n", 25);
|
||||
sleep(2);
|
||||
}
|
||||
|
||||
if ((cc <= '9') && (cc >= '0'))
|
||||
{ yrepcount = yrepcount*10 + cc - '0'; }
|
||||
else { if (yrepcount>0) --yrepcount; return(lastok = cc); }
|
||||
setscroll();
|
||||
return (lastok = 'L' - 64); /* redisplay screen */
|
||||
}
|
||||
if ((cc <= '9') && (cc >= '0')) {
|
||||
yrepcount = yrepcount * 10 + cc - '0';
|
||||
} else {
|
||||
if (yrepcount > 0)
|
||||
--yrepcount;
|
||||
return (lastok = cc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* flushall() Function to flush all type-ahead in the input buffer
|
||||
*/
|
||||
void
|
||||
flushall()
|
||||
{
|
||||
char cc;
|
||||
int ic;
|
||||
for (;;) /* if keyboard input buffer is too big, flush some of it */
|
||||
{
|
||||
ioctl(0,FIONREAD,&ic);
|
||||
if (ic<=0) return;
|
||||
while (ic>0) { read(0,&cc,1); --ic; } /* gobble up the byte */
|
||||
}
|
||||
{
|
||||
char cc;
|
||||
int ic;
|
||||
for (;;) { /* if keyboard input buffer is too big, flush
|
||||
* some of it */
|
||||
ioctl(0, FIONREAD, &ic);
|
||||
if (ic <= 0)
|
||||
return;
|
||||
while (ic > 0) {
|
||||
read(0, &cc, 1);
|
||||
--ic;
|
||||
} /* gobble up the byte */
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function to set the desired hardness
|
||||
function to set the desired hardness
|
||||
enter with hard= -1 for default hardness, else any desired hardness
|
||||
*/
|
||||
void
|
||||
sethard(hard)
|
||||
int hard;
|
||||
{
|
||||
register int j,k,i;
|
||||
j=c[HARDGAME]; hashewon();
|
||||
if (restorflag==0) /* don't set c[HARDGAME] if restoring game */
|
||||
{
|
||||
if (hard >= 0) c[HARDGAME]= hard;
|
||||
}
|
||||
else c[HARDGAME]=j; /* set c[HARDGAME] to proper value if restoring game */
|
||||
int hard;
|
||||
{
|
||||
int j, k, i;
|
||||
j = c[HARDGAME];
|
||||
hashewon();
|
||||
if (restorflag == 0) { /* don't set c[HARDGAME] if restoring game */
|
||||
if (hard >= 0)
|
||||
c[HARDGAME] = hard;
|
||||
} else
|
||||
c[HARDGAME] = j;/* set c[HARDGAME] to proper value if
|
||||
* restoring game */
|
||||
|
||||
if (k=c[HARDGAME])
|
||||
for (j=0; j<=MAXMONST+8; j++)
|
||||
{
|
||||
i = ((6+k)*monster[j].hitpoints+1)/6;
|
||||
monster[j].hitpoints = (i<0) ? 32767 : i;
|
||||
i = ((6+k)*monster[j].damage+1)/5;
|
||||
monster[j].damage = (i>127) ? 127 : i;
|
||||
i = (10*monster[j].gold)/(10+k);
|
||||
monster[j].gold = (i>32767) ? 32767 : i;
|
||||
i = monster[j].armorclass - k;
|
||||
monster[j].armorclass = (i< -127) ? -127 : i;
|
||||
i = (7*monster[j].experience)/(7+k) + 1;
|
||||
monster[j].experience = (i<=0) ? 1 : i;
|
||||
}
|
||||
}
|
||||
if ((k = c[HARDGAME]) != 0)
|
||||
for (j = 0; j <= MAXMONST + 8; j++) {
|
||||
i = ((6 + k) * monster[j].hitpoints + 1) / 6;
|
||||
monster[j].hitpoints = (i < 0) ? 32767 : i;
|
||||
i = ((6 + k) * monster[j].damage + 1) / 5;
|
||||
monster[j].damage = (i > 127) ? 127 : i;
|
||||
i = (10 * monster[j].gold) / (10 + k);
|
||||
monster[j].gold = (i > 32767) ? 32767 : i;
|
||||
i = monster[j].armorclass - k;
|
||||
monster[j].armorclass = (i < -127) ? -127 : i;
|
||||
i = (7 * monster[j].experience) / (7 + k) + 1;
|
||||
monster[j].experience = (i <= 0) ? 1 : i;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
function to read and process the larn options file
|
||||
*/
|
||||
void
|
||||
readopts()
|
||||
{
|
||||
register char *i;
|
||||
register int j,k;
|
||||
int flag;
|
||||
flag=1; /* set to 0 if he specifies a name for his character */
|
||||
if (lopen(optsfile) < 0)
|
||||
{
|
||||
strcpy(logname,loginname); return; /* user name if no character name */
|
||||
}
|
||||
i = " ";
|
||||
while (*i)
|
||||
{
|
||||
if ((i=(char *)lgetw()) == 0) break; /* check for EOF */
|
||||
while ((*i==' ') || (*i=='\t')) i++; /* eat leading whitespace */
|
||||
switch(*i)
|
||||
{
|
||||
case 'b': if (strcmp(i,"bold-objects") == 0) boldon=1;
|
||||
break;
|
||||
|
||||
case 'e': if (strcmp(i,"enable-checkpointing") == 0) ckpflag=1;
|
||||
break;
|
||||
|
||||
case 'i': if (strcmp(i,"inverse-objects") == 0) boldon=0;
|
||||
break;
|
||||
|
||||
case 'f': if (strcmp(i,"female") == 0) sex=0; /* male or female */
|
||||
break;
|
||||
|
||||
case 'm': if (strcmp(i,"monster:")== 0) /* name favorite monster */
|
||||
{
|
||||
if ((i=lgetw())==0) break;
|
||||
if (strlen(i)>=MAXMNAME) i[MAXMNAME-1]=0;
|
||||
strcpy(usermonster[usermpoint],i);
|
||||
if (usermpoint >= MAXUM) break; /* defined all of em */
|
||||
if (isalpha(j=usermonster[usermpoint][0]))
|
||||
{
|
||||
for (k=1; k<MAXMONST+8; k++) /* find monster */
|
||||
if (monstnamelist[k] == j)
|
||||
{
|
||||
monster[k].name = &usermonster[usermpoint++][0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (strcmp(i,"male") == 0) sex=1;
|
||||
break;
|
||||
|
||||
case 'n': if (strcmp(i,"name:") == 0) /* defining players name */
|
||||
{
|
||||
if ((i=lgetw())==0) break;
|
||||
if (strlen(i)>=LOGNAMESIZE) i[LOGNAMESIZE-1]=0;
|
||||
strcpy(logname,i); flag=0;
|
||||
}
|
||||
else if (strcmp(i,"no-introduction") == 0) nowelcome=1;
|
||||
else if (strcmp(i,"no-beep") == 0) nobeep=1;
|
||||
break;
|
||||
|
||||
case 'p': if (strcmp(i,"process-name:")== 0)
|
||||
{
|
||||
if ((i=lgetw())==0) break;
|
||||
if (strlen(i)>=PSNAMESIZE) i[PSNAMESIZE-1]=0;
|
||||
strcpy(psname,i);
|
||||
}
|
||||
else if (strcmp(i,"play-day-play") == 0) dayplay=1;
|
||||
break;
|
||||
|
||||
case 's': if (strcmp(i,"savefile:") == 0) /* defining savefilename */
|
||||
{
|
||||
if ((i=lgetw())==0) break;
|
||||
strcpy(savefilename,i); flag=0;
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
if (flag) strcpy(logname,loginname);
|
||||
{
|
||||
char *i;
|
||||
int j, k;
|
||||
int flag;
|
||||
flag = 1; /* set to 0 if he specifies a name for his
|
||||
* character */
|
||||
if (lopen(optsfile) < 0) {
|
||||
strcpy(logname, loginname);
|
||||
return; /* user name if no character name */
|
||||
}
|
||||
i = " ";
|
||||
while (*i) {
|
||||
if ((i = (char *) lgetw()) == 0)
|
||||
break; /* check for EOF */
|
||||
while ((*i == ' ') || (*i == '\t'))
|
||||
i++; /* eat leading whitespace */
|
||||
switch (*i) {
|
||||
case 'b':
|
||||
if (strcmp(i, "bold-objects") == 0)
|
||||
boldon = 1;
|
||||
break;
|
||||
|
||||
case 'e':
|
||||
if (strcmp(i, "enable-checkpointing") == 0)
|
||||
ckpflag = 1;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
if (strcmp(i, "inverse-objects") == 0)
|
||||
boldon = 0;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
if (strcmp(i, "female") == 0)
|
||||
sex = 0; /* male or female */
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
if (strcmp(i, "monster:") == 0) { /* name favorite monster */
|
||||
if ((i = lgetw()) == 0)
|
||||
break;
|
||||
if (strlen(i) >= MAXMNAME)
|
||||
i[MAXMNAME - 1] = 0;
|
||||
strcpy(usermonster[usermpoint], i);
|
||||
if (usermpoint >= MAXUM)
|
||||
break; /* defined all of em */
|
||||
if (isalpha(j = usermonster[usermpoint][0])) {
|
||||
for (k = 1; k < MAXMONST + 8; k++) /* find monster */
|
||||
if (monstnamelist[k] == j) {
|
||||
monster[k].name = &usermonster[usermpoint++][0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (strcmp(i, "male") == 0)
|
||||
sex = 1;
|
||||
break;
|
||||
|
||||
case 'n':
|
||||
if (strcmp(i, "name:") == 0) { /* defining players name */
|
||||
if ((i = lgetw()) == 0)
|
||||
break;
|
||||
if (strlen(i) >= LOGNAMESIZE)
|
||||
i[LOGNAMESIZE - 1] = 0;
|
||||
strcpy(logname, i);
|
||||
flag = 0;
|
||||
} else if (strcmp(i, "no-introduction") == 0)
|
||||
nowelcome = 1;
|
||||
else if (strcmp(i, "no-beep") == 0)
|
||||
nobeep = 1;
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
if (strcmp(i, "process-name:") == 0) {
|
||||
if ((i = lgetw()) == 0)
|
||||
break;
|
||||
if (strlen(i) >= PSNAMESIZE)
|
||||
i[PSNAMESIZE - 1] = 0;
|
||||
strcpy(psname, i);
|
||||
} else if (strcmp(i, "play-day-play") == 0)
|
||||
dayplay = 1;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
if (strcmp(i, "savefile:") == 0) { /* defining savefilename */
|
||||
if ((i = lgetw()) == 0)
|
||||
break;
|
||||
strcpy(savefilename, i);
|
||||
flag = 0;
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
if (flag)
|
||||
strcpy(logname, loginname);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user