[comp.sources.games] v12i079: cdungeon - C language port of DECUS dungeon, Part12/12

billr@saab.CNA.TEK.COM (Bill Randle) (05/15/91)

Submitted-by: ian@airs.COM
Posting-number: Volume 12, Issue 79
Archive-name: cdungeon/Part12
Environment: Unix, MS-DOS



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 12 (of 12)."
# Contents:  Makefile.MSC ballop.c dso1.c dso4.c dso5.c dso6.c lightp.c
#   local.c
# Wrapped by billr@saab on Tue May 14 16:27:45 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile.MSC' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile.MSC'\"
else
echo shar: Extracting \"'Makefile.MSC'\" \(4550 characters\)
sed "s/^X//" >'Makefile.MSC' <<'END_OF_FILE'
X# Makefile for dungeon
X# By Jonathan Mark <uunet!microsoft!jonm>
X
XMSC	= 1		# this is the Microsoft C version (for DOS)
X
X!if $(MSC)
XO = obj                 # suffix for object files
XBINDIR = .		# Where to install the program
XLIBDIR = .		# Where to install the data file
XTARGET = dungeon.exe
X!else
XO = o			# suffix for object files
XBINDIR = /usr/games	# Where to install the program
XLIBDIR = /usr/games/lib # Where to install the data file
XTARGET = dungeon
X!endif
X
X# The dungeon program provides a ``more'' facility which tries to
X# figure out how many rows the terminal has.  Several mechanisms are
X# supported for determining this; the most common one has been left
X# uncommented.  If you have trouble, especially when linking, you may
X# have to select a different option.
X
X# more option 1: use the termcap routines.  On some systems the LIBS
X# variable may need to be set to -lcurses.  On some it may need to
X# be /usr/lib/termcap.o.  These options are commented out below.
X# LIBS = -ltermcap
X# TERMFLAG =
X# LIBS = -lcurses
X# LIBS = /usr/lib/termcap.o
X
X# more option 2: use the terminfo routines.  On some systems the LIBS
X# variable needs to be -lcursesX, but probably all such systems support
X# the termcap routines (option 1) anyhow.
X# LIBS = -lcurses
X# TERMFLAG = -DMORE_TERMINFO
X
X# more option 3: assume all terminals have 24 rows
X!if $(MSC)
XLIBS =
XTERMFLAG = -DMORE_24
X!endif
X
X# more option 4: don't use the more facility at all
X# LIBS =
X# TERMFLAG = -DMORE_NONE
X
X# End of more options
X
X# Uncomment the following line if you want to have access to the game
X# debugging tool.  This is invoked by typing "gdt".  It is not much
X# use except for debugging.
X# GDTFLAG = -DALLOW_GDT
X
X# Compilation flags
X!if $(MSC)
X# MSC-specific compile options:
X#	-AM	"medium" memory model (code > 64k, data < 64k)
X#	-Za	disables Microsoft C extensions.  This causes the compiler to
X#		  define __STDC__, which in turn causes BINREAD to be defined
X#		  as "rb", etc.  (This seems odd -- is the "b" suffix in
X#		  ANSI C?) [Yes, it is]
XCFLAGS = -O -AM -Za
X!else
XCFLAGS = -O
X!endif
X
X##################################################################
X
X# Source files
XCSRC =	actors.c ballop.c clockr.c demons.c dgame.c dinit.c dmain.c\
X	dso1.c dso2.c dso3.c dso4.c dso5.c dso6.c dso7.c dsub.c dverb1.c\
X	dverb2.c gdt.c lightp.c local.c nobjs.c np.c np1.c np2.c np3.c\
X	nrooms.c objcts.c rooms.c sobjs.c supp.c sverbs.c verbs.c villns.c
X
X# Object files
XOBJS1 =	actors.$O ballop.$O clockr.$O demons.$O dgame.$O dinit.$O dmain.$O
XOBJS2 =	dso1.$O dso2.$O dso3.$O dso4.$O dso5.$O dso6.$O dso7.$O dsub.$O
XOBJS3 = dverb1.$O dverb2.$O gdt.$O lightp.$O local.$O nobjs.$O np.$O np1.$O
XOBJS4 = np2.$O np3.$O nrooms.$O objcts.$O rooms.$O sobjs.$O supp.$O sverbs.$O
XOBJS5 = verbs.$O villns.$O
XOBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5)
X
X!if $(MSC)
X# If we try to link as one $(CC) command, the command line is too long for
X# DOS to accept.  We therefore have to use the ugly "response file" syntax.
X#
X$(TARGET): $(OBJS) dtextc.dat
X	link @<<
X$(OBJS1)+
X$(OBJS2)+
X$(OBJS3)+
X$(OBJS4)+
X$(OBJS5)
X$(TARGET)
X/map /codeview
X$(LIBS)
X
X<<
X!else
X$(TARGET): $(OBJS) dtextc.dat
X	$(CC) $(CFLAGS) -o $(TARGET) $(OBJS) $(LIBS)
X!endif
X
Xinstall: $(TARGET) dtextc.dat
X	cp $(TARGET) $(BINDIR)
X	cp dtextc.dat $(LIBDIR)
X
Xclean:
X	rm -f $(OBJS) $(TARGET) core dsave.dat *~
X
Xdtextc.dat:
X	cat dtextc.uu1 dtextc.uu2 dtextc.uu3 dtextc.uu4 >dtextc.uu
X	uudecode dtextc.uu
X	rm -f dtextc.uu
X
Xdinit.$O: dinit.c funcs.h vars.h
X	$(CC) $(CFLAGS) $(GDTFLAG) -DTEXTFILE=\"$(LIBDIR)/dtextc.dat\" -c dinit.c
X
Xdgame.$O: dgame.c funcs.h vars.h
X	$(CC) $(CFLAGS) $(GDTFLAG) -c dgame.c
X
Xgdt.$O: gdt.c funcs.h vars.h
X	$(CC) $(CFLAGS) $(GDTFLAG) -c gdt.c
X
Xlocal.$O: local.c funcs.h vars.h
X	$(CC) $(CFLAGS) $(GDTFLAG) -c local.c
X
Xsupp.$O: supp.c funcs.h vars.h
X	$(CC) $(CFLAGS) $(TERMFLAG) -c supp.c	
X
Xactors.$O: funcs.h vars.h
Xballop.$O: funcs.h vars.h
Xclockr.$O: funcs.h vars.h
Xdemons.$O: funcs.h vars.h
Xdmain.$O: funcs.h vars.h
Xdso1.$O: funcs.h vars.h
Xdso2.$O: funcs.h vars.h
Xdso3.$O: funcs.h vars.h
Xdso4.$O: funcs.h vars.h
Xdso5.$O: funcs.h vars.h
Xdso6.$O: funcs.h vars.h
Xdso7.$O: funcs.h vars.h
Xdsub.$O: funcs.h vars.h
Xdverb1.$O: funcs.h vars.h
Xdverb2.$O: funcs.h vars.h
Xlightp.$O: funcs.h vars.h
Xnobjs.$O: funcs.h vars.h
Xnp.$O: funcs.h vars.h
Xnp1.$O: funcs.h vars.h parse.h
Xnp2.$O: funcs.h vars.h parse.h
Xnp3.$O: funcs.h vars.h parse.h
Xnrooms.$O: funcs.h vars.h
Xobjcts.$O: funcs.h vars.h
Xrooms.$O: funcs.h vars.h
Xsobjs.$O: funcs.h vars.h
Xsverbs.$O: funcs.h vars.h
Xverbs.$O: funcs.h vars.h
Xvillns.$O: funcs.h vars.h
X
X
END_OF_FILE
if test 4550 -ne `wc -c <'Makefile.MSC'`; then
    echo shar: \"'Makefile.MSC'\" unpacked with wrong size!
fi
# end of 'Makefile.MSC'
fi
if test -f 'ballop.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'ballop.c'\"
else
echo shar: Extracting \"'ballop.c'\" \(3038 characters\)
sed "s/^X//" >'ballop.c' <<'END_OF_FILE'
X/* BALLOP-	BALLOON FUNCTION */
X
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
Xlogical ballop_(arg)
Xinteger arg;
X{
X    /* System generated locals */
X    logical ret_val;
X
X    ret_val = TRUE_;
X/* 						!ASSUME WINS. */
X    if (arg != 2) {
X	goto L200;
X    }
X/* 						!READOUT? */
X    if (prsvec_1.prsa != vindex_1.lookw) {
X	goto L10;
X    }
X/* 						!ONLY PROCESS LOOK. */
X    if (findex_1.binff != 0) {
X	goto L50;
X    }
X/* 						!INFLATED? */
X    rspeak_(543);
X/* 						!NO. */
X    goto L100;
XL50:
X    rspsub_(544, objcts_1.odesc2[findex_1.binff - 1]);
X/* 						!YES. */
XL100:
X    if (findex_1.btief != 0) {
X	rspeak_(545);
X    }
X/* 						!HOOKED? */
X    return ret_val;
X
XL200:
X    if (arg != 1) {
X	goto L500;
X    }
X/* 						!READIN? */
X    if (prsvec_1.prsa != vindex_1.walkw) {
X	goto L300;
X    }
X/* 						!WALK? */
X    if (findxt_(prsvec_1.prso, play_1.here)) {
X	goto L250;
X    }
X/* 						!VALID EXIT? */
X    rspeak_(546);
X/* 						!NO, JOKE. */
X    return ret_val;
X
XL250:
X    if (findex_1.btief == 0) {
X	goto L275;
X    }
X/* 						!TIED UP? */
X    rspeak_(547);
X/* 						!YES, JOKE. */
X    return ret_val;
X
XL275:
X    if (curxt_1.xtype != xpars_1.xnorm) {
X	goto L10;
X    }
X/* 						!NORMAL EXIT? */
X    if ((rooms_1.rflag[curxt_1.xroom1 - 1] & RMUNG) == 0) {
X	state_1.bloc = curxt_1.xroom1;
X    }
XL10:
X    ret_val = FALSE_;
X    return ret_val;
X
XL300:
X    if (prsvec_1.prsa != vindex_1.takew || prsvec_1.prso != findex_1.binff) {
X	goto L350;
X    }
X    rspsub_(548, objcts_1.odesc2[findex_1.binff - 1]);
X/* 						!RECEP CONT TOO HOT. */
X    return ret_val;
X
XL350:
X    if (prsvec_1.prsa != vindex_1.putw || prsvec_1.prsi != oindex_1.recep || 
X	    qempty_(oindex_1.recep)) {
X	goto L10;
X    }
X    rspeak_(549);
X    return ret_val;
X
XL500:
X    if (prsvec_1.prsa != vindex_1.unboaw || (rooms_1.rflag[play_1.here - 1] & 
X	    RLAND) == 0) {
X	goto L600;
X    }
X    if (findex_1.binff != 0) {
X	cevent_1.ctick[cindex_1.cevbal - 1] = 3;
X    }
X/* 						!HE GOT OUT, START BALLOON. */
X    goto L10;
X
XL600:
X    if (prsvec_1.prsa != vindex_1.burnw || objcts_1.ocan[prsvec_1.prso - 1] !=
X	     oindex_1.recep) {
X	goto L700;
X    }
X    rspsub_(550, objcts_1.odesc2[prsvec_1.prso - 1]);
X/* 						!LIGHT FIRE IN RECEP. */
X    cevent_1.ctick[cindex_1.cevbrn - 1] = objcts_1.osize[prsvec_1.prso - 1] * 
X	    20;
X    objcts_1.oflag1[prsvec_1.prso - 1] |= ONBT + FLAMBT + 
X	    LITEBT & ~ (TAKEBT + READBT);
X    if (findex_1.binff != 0) {
X	return ret_val;
X    }
X    if (! findex_1.blabf) {
X	newsta_(oindex_1.blabe, 0, 0, oindex_1.ballo, 0);
X    }
X    findex_1.blabf = TRUE_;
X    findex_1.binff = prsvec_1.prso;
X    cevent_1.ctick[cindex_1.cevbal - 1] = 3;
X    rspeak_(551);
X    return ret_val;
X
XL700:
X    if (prsvec_1.prsa == vindex_1.unboaw && findex_1.binff != 0 && (
X	    rooms_1.rflag[play_1.here - 1] & RLAND) != 0) {
X	cevent_1.ctick[cindex_1.cevbal - 1] = 3;
X    }
X    goto L10;
X
X} /* ballop_ */
END_OF_FILE
if test 3038 -ne `wc -c <'ballop.c'`; then
    echo shar: \"'ballop.c'\" unpacked with wrong size!
fi
# end of 'ballop.c'
fi
if test -f 'dso1.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dso1.c'\"
else
echo shar: Extracting \"'dso1.c'\" \(3600 characters\)
sed "s/^X//" >'dso1.c' <<'END_OF_FILE'
X/* PRINCR- PRINT CONTENTS OF ROOM */
X
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
Xvoid princr_(full, rm)
Xlogical full;
Xinteger rm;
X{
X    /* System generated locals */
X    integer i__1, i__2;
X
X    /* Local variables */
X    integer i, j, k;
X
X    j = 329;
X/* 						!ASSUME SUPERBRIEF FORMAT. */
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!LOOP ON OBJECTS */
X	if (! qhere_(i, rm) || (objcts_1.oflag1[i - 1] & VISIBT + 
X		NDSCBT) != VISIBT || i == advs_1.avehic[
X		play_1.winner - 1]) {
X	    goto L500;
X	}
X	if (! (full) && (findex_1.superf || findex_1.brieff && (
X		rooms_1.rflag[play_1.here - 1] & RSEEN) != 0)) {
X	    goto L200;
X	}
X
X/* DO LONG DESCRIPTION OF OBJECT. */
X
X	k = objcts_1.odesco[i - 1];
X/* 						!GET UNTOUCHED. */
X	if (k == 0 || (objcts_1.oflag2[i - 1] & TCHBT) != 0) {
X	    k = objcts_1.odesc1[i - 1];
X	}
X	rspeak_(k);
X/* 						!DESCRIBE. */
X	goto L500;
X/* DO SHORT DESCRIPTION OF OBJECT. */
X
XL200:
X	rspsub_(j, objcts_1.odesc2[i - 1]);
X/* 						!YOU CAN SEE IT. */
X	j = 502;
X
XL500:
X	;
X    }
X
X/* NOW LOOP TO PRINT CONTENTS OF OBJECTS IN ROOM. */
X
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!LOOP ON OBJECTS. */
X	if (! qhere_(i, rm) || (objcts_1.oflag1[i - 1] & VISIBT + 
X		NDSCBT) != VISIBT) {
X	    goto L1000;
X	}
X	if ((objcts_1.oflag2[i - 1] & ACTRBT) != 0) {
X	    i__2 = oactor_(i);
X	    invent_(i__2);
X	}
X	if ((objcts_1.oflag1[i - 1] & TRANBT) == 0 && (
X		objcts_1.oflag2[i - 1] & OPENBT) == 0 || qempty_(i))
X		 {
X	    goto L1000;
X	}
X
X/* OBJECT IS NOT EMPTY AND IS OPEN OR TRANSPARENT. */
X
X	j = 573;
X	if (i != oindex_1.tcase) {
X	    goto L600;
X	}
X/* 						!TROPHY CASE? */
X	j = 574;
X	if ((findex_1.brieff || findex_1.superf) && ! (full)) {
X	    goto L1000;
X	}
XL600:
X	princo_(i, j);
X/* 						!PRINT CONTENTS. */
X
XL1000:
X	;
X    }
X} /* princr_ */
X
X/* INVENT- PRINT CONTENTS OF ADVENTURER */
X
X/* DECLARATIONS */
X
Xvoid invent_(adv)
Xinteger adv;
X{
X    /* System generated locals */
X    integer i__1;
X
X    /* Local variables */
X    integer i, j;
X
X    i = 575;
X/* 						!FIRST LINE. */
X    if (adv != aindex_1.player) {
X	i = 576;
X    }
X/* 						!IF NOT ME. */
X    i__1 = objcts_1.olnt;
X    for (j = 1; j <= i__1; ++j) {
X/* 						!LOOP */
X	if (objcts_1.oadv[j - 1] != adv || (objcts_1.oflag1[j - 1] & 
X		VISIBT) == 0) {
X	    goto L10;
X	}
X	rspsub_(i, objcts_1.odesc2[advs_1.aobj[adv - 1] - 1]);
X	i = 0;
X	rspsub_(502, objcts_1.odesc2[j - 1]);
XL10:
X	;
X    }
X
X    if (i == 0) {
X	goto L25;
X    }
X/* 						!ANY OBJECTS? */
X    if (adv == aindex_1.player) {
X	rspeak_(578);
X    }
X/* 						!NO, TELL HIM. */
X    return;
X
XL25:
X    i__1 = objcts_1.olnt;
X    for (j = 1; j <= i__1; ++j) {
X/* 						!LOOP. */
X	if (objcts_1.oadv[j - 1] != adv || (objcts_1.oflag1[j - 1] & 
X		VISIBT) == 0 || (objcts_1.oflag1[j - 1] & 
X		TRANBT) == 0 && (objcts_1.oflag2[j - 1] & 
X		OPENBT) == 0) {
X	    goto L100;
X	}
X	if (! qempty_(j)) {
X	    princo_(j, 573);
X	}
X/* 						!IF NOT EMPTY, LIST. */
XL100:
X	;
X    }
X} /* invent_ */
X
X/* PRINCO-	PRINT CONTENTS OF OBJECT */
X
X/* DECLARATIONS */
X
Xvoid princo_(obj, desc)
Xinteger obj;
Xinteger desc;
X{
X    /* System generated locals */
X    integer i__1;
X
X    /* Local variables */
X    integer i;
X
X    rspsub_(desc, objcts_1.odesc2[obj - 1]);
X/* 						!PRINT HEADER. */
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!LOOP THRU. */
X	if (objcts_1.ocan[i - 1] == obj) {
X	    rspsub_(502, objcts_1.odesc2[i - 1]);
X	}
X/* L100: */
X    }
X} /* princo_ */
END_OF_FILE
if test 3600 -ne `wc -c <'dso1.c'`; then
    echo shar: \"'dso1.c'\" unpacked with wrong size!
fi
# end of 'dso1.c'
fi
if test -f 'dso4.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dso4.c'\"
else
echo shar: Extracting \"'dso4.c'\" \(3760 characters\)
sed "s/^X//" >'dso4.c' <<'END_OF_FILE'
X/* ROBADV-- STEAL WINNER'S VALUABLES */
X
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
Xinteger robadv_(adv, nr, nc, na)
Xinteger adv;
Xinteger nr;
Xinteger nc;
Xinteger na;
X{
X    /* System generated locals */
X    integer ret_val, i__1;
X
X    /* Local variables */
X    integer i;
X
X    ret_val = 0;
X/* 						!COUNT OBJECTS */
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X	if (objcts_1.oadv[i - 1] != adv || objcts_1.otval[i - 1] <= 0 || (
X		objcts_1.oflag2[i - 1] & SCRDBT) != 0) {
X	    goto L100;
X	}
X	newsta_(i, 0, nr, nc, na);
X/* 						!STEAL OBJECT */
X	++ret_val;
XL100:
X	;
X    }
X    return ret_val;
X} /* robadv_ */
X
X/* ROBRM-- STEAL ROOM VALUABLES */
X
X/* DECLARATIONS */
X
Xinteger robrm_(rm, pr, nr, nc, na)
Xinteger rm;
Xinteger pr;
Xinteger nr;
Xinteger nc;
Xinteger na;
X{
X    /* System generated locals */
X    integer ret_val, i__1, i__2;
X
X    /* Local variables */
X    integer i;
X
X
X/* OBJECTS */
X
X
X
X
X    ret_val = 0;
X/* 						!COUNT OBJECTS */
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!LOOP ON OBJECTS. */
X	if (! qhere_(i, rm)) {
X	    goto L100;
X	}
X	if (objcts_1.otval[i - 1] <= 0 || (objcts_1.oflag2[i - 1] & 
X		SCRDBT) != 0 || (objcts_1.oflag1[i - 1] & 
X		VISIBT) == 0 || ! prob_(pr, pr)) {
X	    goto L50;
X	}
X	newsta_(i, 0, nr, nc, na);
X	++ret_val;
X	objcts_1.oflag2[i - 1] |= TCHBT;
X	goto L100;
XL50:
X	if ((objcts_1.oflag2[i - 1] & ACTRBT) != 0) {
X	    i__2 = oactor_(i);
X	    ret_val += robadv_(i__2, nr, nc, na);
X	}
XL100:
X	;
X    }
X    return ret_val;
X} /* robrm_ */
X
X/* WINNIN-- SEE IF VILLAIN IS WINNING */
X
X/* DECLARATIONS */
X
Xlogical winnin_(vl, hr)
Xinteger vl;
Xinteger hr;
X{
X    /* System generated locals */
X    logical ret_val;
X
X    /* Local variables */
X    integer ps, vs;
X
X
X/* OBJECTS */
X
X
X
X    vs = objcts_1.ocapac[vl - 1];
X/* 						!VILLAIN STRENGTH */
X    ps = vs - fights_(hr, 1);
X/* 						!HIS MARGIN OVER HERO */
X    ret_val = prob_(90, 100);
X    if (ps > 3) {
X	return ret_val;
X    }
X/* 						!+3... 90% WINNING */
X    ret_val = prob_(75, 85);
X    if (ps > 0) {
X	return ret_val;
X    }
X/* 						!>0... 75% WINNING */
X    ret_val = prob_(50, 30);
X    if (ps == 0) {
X	return ret_val;
X    }
X/* 						!=0... 50% WINNING */
X    ret_val = prob_(25, 25);
X    if (vs > 1) {
X	return ret_val;
X    }
X/* 						!ANY VILLAIN STRENGTH. */
X    ret_val = prob_(10, 0);
X    return ret_val;
X} /* winnin_ */
X
X/* FIGHTS-- COMPUTE FIGHT STRENGTH */
X
X/* DECLARATIONS */
X
Xinteger fights_(h, flg)
Xinteger h;
Xlogical flg;
X{
X    /* Initialized data */
X
X    const integer smin = 2;
X    const integer smax = 7;
X
X    /* System generated locals */
X    integer ret_val;
X
X    ret_val = smin + ((smax - smin) * advs_1.ascore[h - 1] + state_1.mxscor /
X	     2) / state_1.mxscor;
X    if (flg) {
X	ret_val += advs_1.astren[h - 1];
X    }
X    return ret_val;
X} /* fights_ */
X
X/* VILSTR-	COMPUTE VILLAIN STRENGTH */
X
X/* DECLARATIONS */
X
Xinteger vilstr_(v)
Xinteger v;
X{
X    /* System generated locals */
X    integer ret_val, i__1, i__2, i__3;
X
X    /* Local variables */
X    integer i;
X
X    ret_val = objcts_1.ocapac[v - 1];
X    if (ret_val <= 0) {
X	return ret_val;
X    }
X    if (v != oindex_1.thief || ! findex_1.thfenf) {
X	goto L100;
X    }
X    findex_1.thfenf = FALSE_;
X/* 						!THIEF UNENGROSSED. */
X    ret_val = min(ret_val,2);
X/* 						!NO BETTER THAN 2. */
X
XL100:
X    i__1 = vill_1.vlnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!SEE IF  BEST WEAPON. */
X	if (vill_1.villns[i - 1] == v && prsvec_1.prsi == vill_1.vbest[i - 1]
X		) {
X/* Computing MAX */
X	    i__2 = 1, i__3 = ret_val - 1;
X	    ret_val = max(i__2,i__3);
X	}
X/* L200: */
X    }
X    return ret_val;
X} /* vilstr_ */
END_OF_FILE
if test 3760 -ne `wc -c <'dso4.c'`; then
    echo shar: \"'dso4.c'\" unpacked with wrong size!
fi
# end of 'dso4.c'
fi
if test -f 'dso5.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dso5.c'\"
else
echo shar: Extracting \"'dso5.c'\" \(3494 characters\)
sed "s/^X//" >'dso5.c' <<'END_OF_FILE'
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
X/* GTTIME-- GET TOTAL TIME PLAYED */
X
Xvoid gttime_(t)
Xinteger *t;
X{
X    integer h, m, s;
X
X    itime_(&h, &m, &s);
X    *t = h * 60 + m - (time_1.shour * 60 + time_1.smin);
X    if (*t < 0) {
X	*t += 1440;
X    }
X    *t += time_1.pltime;
X    return;
X} /* gttime_ */
X
X/* OPNCLS-- PROCESS OPEN/CLOSE FOR DOORS */
X
X/* DECLARATIONS */
X
Xlogical opncls_(obj, so, sc)
Xinteger obj;
Xinteger so;
Xinteger sc;
X{
X    /* System generated locals */
X    integer i__1;
X    logical ret_val;
X
X    ret_val = TRUE_;
X/* 						!ASSUME WINS. */
X    if (prsvec_1.prsa == vindex_1.closew) {
X	goto L100;
X    }
X/* 						!CLOSE? */
X    if (prsvec_1.prsa == vindex_1.openw) {
X	goto L50;
X    }
X/* 						!OPEN? */
X    ret_val = FALSE_;
X/* 						!LOSE */
X    return ret_val;
X
XL50:
X    if ((objcts_1.oflag2[obj - 1] & OPENBT) != 0) {
X	goto L200;
X    }
X/* 						!OPEN... IS IT? */
X    rspeak_(so);
X    objcts_1.oflag2[obj - 1] |= OPENBT;
X    return ret_val;
X
XL100:
X    if (! ((objcts_1.oflag2[obj - 1] & OPENBT) != 0)) {
X	goto L200;
X    }
X/* 						!CLOSE... IS IT? */
X    rspeak_(sc);
X    objcts_1.oflag2[obj - 1] &= ~ OPENBT;
X    return ret_val;
X
XL200:
X    i__1 = rnd_(3) + 125;
X    rspeak_(i__1);
X/* 						!DUMMY. */
X    return ret_val;
X} /* opncls_ */
X
X/* LIT-- IS ROOM LIT? */
X
X/* DECLARATIONS */
X
Xlogical lit_(rm)
Xinteger rm;
X{
X    /* System generated locals */
X    integer i__1, i__2;
X    logical ret_val;
X
X    /* Local variables */
X    integer i, j, oa;
X
X    ret_val = TRUE_;
X/* 						!ASSUME WINS */
X    if ((rooms_1.rflag[rm - 1] & RLIGHT) != 0) {
X	return ret_val;
X    }
X
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!LOOK FOR LIT OBJ */
X	if (qhere_(i, rm)) {
X	    goto L100;
X	}
X/* 						!IN ROOM? */
X	oa = objcts_1.oadv[i - 1];
X/* 						!NO */
X	if (oa <= 0) {
X	    goto L1000;
X	}
X/* 						!ON ADV? */
X	if (advs_1.aroom[oa - 1] != rm) {
X	    goto L1000;
X	}
X/* 						!ADV IN ROOM? */
X
X/* OBJ IN ROOM OR ON ADV IN ROOM */
X
XL100:
X	if ((objcts_1.oflag1[i - 1] & ONBT) != 0) {
X	    return ret_val;
X	}
X	if ((objcts_1.oflag1[i - 1] & VISIBT) == 0 || (
X		objcts_1.oflag1[i - 1] & TRANBT) == 0 && (
X		objcts_1.oflag2[i - 1] & OPENBT) == 0) {
X	    goto L1000;
X	}
X
X/* OBJ IS VISIBLE AND OPEN OR TRANSPARENT */
X
X	i__2 = objcts_1.olnt;
X	for (j = 1; j <= i__2; ++j) {
X	    if (objcts_1.ocan[j - 1] == i && (objcts_1.oflag1[j - 1] & 
X		    ONBT) != 0) {
X		return ret_val;
X	    }
X/* L500: */
X	}
XL1000:
X	;
X    }
X    ret_val = FALSE_;
X    return ret_val;
X} /* lit_ */
X
X/* WEIGHT- RETURNS SUM OF WEIGHT OF QUALIFYING OBJECTS */
X
X/* DECLARATIONS */
X
Xinteger weight_(rm, cn, ad)
Xinteger rm;
Xinteger cn;
Xinteger ad;
X{
X    /* System generated locals */
X    integer ret_val, i__1;
X
X    /* Local variables */
X    integer i, j;
X
X    ret_val = 0;
X    i__1 = objcts_1.olnt;
X    for (i = 1; i <= i__1; ++i) {
X/* 						!OMIT BIG FIXED ITEMS. */
X	if (objcts_1.osize[i - 1] >= 10000) {
X	    goto L100;
X	}
X/* 						!IF FIXED, FORGET IT. */
X	if (qhere_(i, rm) && rm != 0 || objcts_1.oadv[i - 1] == ad && ad 
X		!= 0) {
X	    goto L50;
X	}
X	j = i;
X/* 						!SEE IF CONTAINED. */
XL25:
X	j = objcts_1.ocan[j - 1];
X/* 						!GET NEXT LEVEL UP. */
X	if (j == 0) {
X	    goto L100;
X	}
X/* 						!END OF LIST? */
X	if (j != cn) {
X	    goto L25;
X	}
XL50:
X	ret_val += objcts_1.osize[i - 1];
XL100:
X	;
X    }
X    return ret_val;
X} /* weight_ */
END_OF_FILE
if test 3494 -ne `wc -c <'dso5.c'`; then
    echo shar: \"'dso5.c'\" unpacked with wrong size!
fi
# end of 'dso5.c'
fi
if test -f 'dso6.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'dso6.c'\"
else
echo shar: Extracting \"'dso6.c'\" \(3549 characters\)
sed "s/^X//" >'dso6.c' <<'END_OF_FILE'
X/* GHERE--	IS GLOBAL ACTUALLY IN THIS ROOM? */
X
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
Xlogical ghere_(obj, rm)
Xinteger obj;
Xinteger rm;
X{
X    /* System generated locals */
X    logical ret_val;
X
X    ret_val = TRUE_;
X/* 						!ASSUME WINS. */
X    switch (obj - star_1.strbit) {
X	case 1:  goto L1000;
X	case 2:  goto L1000;
X	case 3:  goto L1000;
X	case 4:  goto L1000;
X	case 5:  goto L1000;
X	case 6:  goto L1000;
X	case 7:  goto L1000;
X	case 8:  goto L1000;
X	case 9:  goto L1000;
X	case 10:  goto L1000;
X	case 11:  goto L1000;
X	case 12:  goto L2000;
X	case 13:  goto L3000;
X	case 14:  goto L4000;
X	case 15:  goto L5000;
X	case 16:  goto L5000;
X	case 17:  goto L5000;
X	case 18:  goto L6000;
X	case 19:  goto L7000;
X	case 20:  goto L8000;
X	case 21:  goto L9000;
X	case 22:  goto L9100;
X	case 23:  goto L8000;
X	case 24:  goto L10000;
X	case 25:  goto L11000;
X    }
X    bug_(60, obj);
X
X/* 1000--	STARS ARE ALWAYS HERE */
X
XL1000:
X    return ret_val;
X
X/* 2000--	BIRD */
X
XL2000:
X    ret_val = rm >= rindex_1.fore1 && rm < rindex_1.clear || rm == 
X	    rindex_1.mtree;
X    return ret_val;
X
X/* 3000--	TREE */
X
XL3000:
X    ret_val = rm >= rindex_1.fore1 && rm < rindex_1.clear && rm != 
X	    rindex_1.fore3;
X    return ret_val;
X
X/* 4000--	NORTH WALL */
X
XL4000:
X    ret_val = rm >= rindex_1.bkvw && rm <= rindex_1.bkbox || rm == 
X	    rindex_1.cpuzz;
X    return ret_val;
X
X/* 5000--	EAST, SOUTH, WEST WALLS */
X
XL5000:
X    ret_val = rm >= rindex_1.bkvw && rm < rindex_1.bkbox || rm == 
X	    rindex_1.cpuzz;
X    return ret_val;
X
X/* 6000--	GLOBAL WATER */
X
XL6000:
X    ret_val = (rooms_1.rflag[rm - 1] & RWATER + RFILL) != 0;
X    return ret_val;
X
X/* 7000--	GLOBAL GUARDIANS */
X
XL7000:
X    ret_val = rm >= rindex_1.mrc && rm <= rindex_1.mrd || rm >= 
X	    rindex_1.mrce && rm <= rindex_1.mrdw || rm == rindex_1.inmir;
X    return ret_val;
X
X/* 8000--	ROSE/CHANNEL */
X
XL8000:
X    ret_val = rm >= rindex_1.mra && rm <= rindex_1.mrd || rm == 
X	    rindex_1.inmir;
X    return ret_val;
X
X/* 9000--	MIRROR */
X/* 9100		PANEL */
X
XL9100:
X    if (rm == rindex_1.fdoor) {
X	return ret_val;
X    }
X/* 						!PANEL AT FDOOR. */
XL9000:
X    ret_val = rm >= rindex_1.mra && rm <= rindex_1.mrc || rm >= 
X	    rindex_1.mrae && rm <= rindex_1.mrcw;
X    return ret_val;
X
X/* 10000--	MASTER */
X
XL10000:
X    ret_val = rm == rindex_1.fdoor || rm == rindex_1.ncorr || rm == 
X	    rindex_1.parap || rm == rindex_1.cell;
X    return ret_val;
X
X/* 11000--	LADDER */
X
XL11000:
X    ret_val = rm == rindex_1.cpuzz;
X    return ret_val;
X
X} /* ghere_ */
X
X/* MRHERE--	IS MIRROR HERE? */
X
X/* DECLARATIONS */
X
Xinteger mrhere_(rm)
Xinteger rm;
X{
X    /* System generated locals */
X    integer ret_val, i__1;
X
X    if (rm < rindex_1.mrae || rm > rindex_1.mrdw) {
X	goto L100;
X    }
X
X/* RM IS AN E-W ROOM, MIRROR MUST BE N-S (MDIR= 0 OR 180) */
X
X    ret_val = 1;
X/* 						!ASSUME MIRROR 1 HERE. */
X    if ((rm - rindex_1.mrae) % 2 == findex_1.mdir / 180) {
X	ret_val = 2;
X    }
X    return ret_val;
X
X/* RM IS NORTH OR SOUTH OF MIRROR.  IF MIRROR IS N-S OR NOT */
X/* WITHIN ONE ROOM OF RM, LOSE. */
X
XL100:
X    ret_val = 0;
X    if ((i__1 = findex_1.mloc - rm, abs(i__1)) != 1 || findex_1.mdir % 180 ==
X	     0) {
X	return ret_val;
X    }
X
X/* RM IS WITHIN ONE OF MLOC, AND MDIR IS E-W */
X
X    ret_val = 1;
X    if (rm < findex_1.mloc && findex_1.mdir < 180 || rm > findex_1.mloc && 
X	    findex_1.mdir > 180) {
X	ret_val = 2;
X    }
X    return ret_val;
X} /* mrhere_ */
END_OF_FILE
if test 3549 -ne `wc -c <'dso6.c'`; then
    echo shar: \"'dso6.c'\" unpacked with wrong size!
fi
# end of 'dso6.c'
fi
if test -f 'lightp.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lightp.c'\"
else
echo shar: Extracting \"'lightp.c'\" \(3512 characters\)
sed "s/^X//" >'lightp.c' <<'END_OF_FILE'
X/* LIGHTP-	LIGHT PROCESSOR */
X
X/*COPYRIGHT 1980, INFOCOM COMPUTERS AND COMMUNICATIONS, CAMBRIDGE MA. 02142*/
X/* ALL RIGHTS RESERVED, COMMERCIAL USAGE STRICTLY PROHIBITED */
X/* WRITTEN BY R. M. SUPNIK */
X
X#include "funcs.h"
X#include "vars.h"
X
Xlogical lightp_(obj)
Xinteger obj;
X{
X    /* System generated locals */
X    logical ret_val;
X
X    /* Local variables */
X    integer flobts;
X    integer i;
X
X    ret_val = TRUE_;
X/* 						!ASSUME WINS */
X    flobts = FLAMBT + LITEBT + ONBT;
X    if (obj != oindex_1.candl) {
X	goto L20000;
X    }
X/* 						!CANDLE? */
X    if (findex_1.orcand != 0) {
X	goto L19100;
X    }
X/* 						!FIRST REF? */
X    findex_1.orcand = 1;
X/* 						!YES, CANDLES ARE */
X    cevent_1.ctick[cindex_1.cevcnd - 1] = 50;
X/* 						!BURNING WHEN SEEN. */
X
XL19100:
X    if (prsvec_1.prsi == oindex_1.candl) {
X	goto L10;
X    }
X/* 						!IGNORE IND REFS. */
X    if (prsvec_1.prsa != vindex_1.trnofw) {
X	goto L19200;
X    }
X/* 						!TURN OFF? */
X    i = 513;
X/* 						!ASSUME OFF. */
X    if ((objcts_1.oflag1[oindex_1.candl - 1] & ONBT) != 0) {
X	i = 514;
X    }
X/* 						!IF ON, DIFFERENT. */
X    cevent_1.cflag[cindex_1.cevcnd - 1] = FALSE_;
X/* 						!DISABLE COUNTDOWN. */
X    objcts_1.oflag1[oindex_1.candl - 1] &= ~ ONBT;
X    rspeak_(i);
X    return ret_val;
X
XL19200:
X    if (prsvec_1.prsa != vindex_1.burnw && prsvec_1.prsa != vindex_1.trnonw) {
X
X	goto L10;
X    }
X    if ((objcts_1.oflag1[oindex_1.candl - 1] & LITEBT) != 0) {
X	goto L19300;
X    }
X    rspeak_(515);
X/* 						!CANDLES TOO SHORT. */
X    return ret_val;
X
XL19300:
X    if (prsvec_1.prsi != 0) {
X	goto L19400;
X    }
X/* 						!ANY FLAME? */
X    rspeak_(516);
X/* 						!NO, LOSE. */
X    prsvec_1.prswon = FALSE_;
X    return ret_val;
X
XL19400:
X    if (prsvec_1.prsi != oindex_1.match || ! ((objcts_1.oflag1[oindex_1.match 
X	    - 1] & ONBT) != 0)) {
X	goto L19500;
X    }
X    i = 517;
X/* 						!ASSUME OFF. */
X    if ((objcts_1.oflag1[oindex_1.candl - 1] & ONBT) != 0) {
X	i = 518;
X    }
X/* 						!IF ON, JOKE. */
X    objcts_1.oflag1[oindex_1.candl - 1] |= ONBT;
X    cevent_1.cflag[cindex_1.cevcnd - 1] = TRUE_;
X/* 						!RESUME COUNTDOWN. */
X    rspeak_(i);
X    return ret_val;
X
XL19500:
X    if (prsvec_1.prsi != oindex_1.torch || ! ((objcts_1.oflag1[oindex_1.torch 
X	    - 1] & ONBT) != 0)) {
X	goto L19600;
X    }
X    if ((objcts_1.oflag1[oindex_1.candl - 1] & ONBT) != 0) {
X	goto L19700;
X    }
X/* 						!ALREADY ON? */
X    newsta_(oindex_1.candl, 521, 0, 0, 0);
X/* 						!NO, VAPORIZE. */
X    return ret_val;
X
XL19600:
X    rspeak_(519);
X/* 						!CANT LIGHT WITH THAT. */
X    return ret_val;
X
XL19700:
X    rspeak_(520);
X/* 						!ALREADY ON. */
X    return ret_val;
X
XL20000:
X    if (obj != oindex_1.match) {
X	bug_(6, obj);
X    }
X    if (prsvec_1.prsa != vindex_1.trnonw || prsvec_1.prso != oindex_1.match) {
X
X	goto L20500;
X    }
X    if (findex_1.ormtch != 0) {
X	goto L20100;
X    }
X/* 						!ANY MATCHES LEFT? */
X    rspeak_(183);
X/* 						!NO, LOSE. */
X    return ret_val;
X
XL20100:
X    --findex_1.ormtch;
X/* 						!DECREMENT NO MATCHES. */
X    objcts_1.oflag1[oindex_1.match - 1] |= flobts;
X    cevent_1.ctick[cindex_1.cevmat - 1] = 2;
X/* 						!COUNTDOWN. */
X    rspeak_(184);
X    return ret_val;
X
XL20500:
X    if (prsvec_1.prsa != vindex_1.trnofw || (objcts_1.oflag1[oindex_1.match - 
X	    1] & ONBT) == 0) {
X	goto L10;
X    }
X    objcts_1.oflag1[oindex_1.match - 1] &= ~ flobts;
X    cevent_1.ctick[cindex_1.cevmat - 1] = 0;
X    rspeak_(185);
X    return ret_val;
X
X/* HERE FOR FALSE RETURN */
X
XL10:
X    ret_val = FALSE_;
X    return ret_val;
X} /* lightp_ */
END_OF_FILE
if test 3512 -ne `wc -c <'lightp.c'`; then
    echo shar: \"'lightp.c'\" unpacked with wrong size!
fi
# end of 'lightp.c'
fi
if test -f 'local.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'local.c'\"
else
echo shar: Extracting \"'local.c'\" \(1713 characters\)
sed "s/^X//" >'local.c' <<'END_OF_FILE'
X/* local.c -- dungeon functions which need local definition */
X
X#include "funcs.h"
X
X#ifdef __AMOS__
X#include <moncal.h>
X#endif
X
X/* This function should return TRUE_ if it's OK for people to play the
X * game, FALSE_ otherwise.  If you have a working <time.h> library,
X * you can define NONBUSINESS to disallow play Monday to Friday, 9-5
X * (this is only checked at the start of the game, though).  For more
X * complex control you will have to write your own version of this
X * function.
X */
X
X#ifdef NONBUSINESS
X#ifdef BSD4_2
X#include <sys/timeb.h>
X#else /* ! BSD4_2 */
X#include <time.h>
X#endif /* ! BSD4_2 */
X#endif /* NONBUSINESS */
X
Xlogical protected()
X{
X#ifndef NONBUSINESS
X
X    return TRUE_;
X
X#else /* NONBUSINESS */
X
X    time_t t;
X    struct tm *q;
X
X    (void)time(&t);
X    q = localtime(&t);
X
X    /* Return TRUE_ if it's Sunday or Saturday or before 9 or after 5 */
X
X    if (q->tm_wday == 0 || q->tm_wday == 6)
X	return TRUE_;
X    else if (q->tm_hour < 9 || q->tm_hour >= 17)
X	return TRUE_;
X    else
X	return FALSE_;
X
X#endif /* NONBUSINESS */
X
X}
X
X#ifdef ALLOW_GDT
X
X/* This function should return TRUE_ if the user is allowed to invoke the
X * game debugging tool by typing "gdt".  This isn't very useful without
X * the source code, and it's mainly for people trying to debug the game.
X * You can define WIZARDID to specify a user id on a UNIX system.  On a
X * non AMOS, non unix system this function will have to be changed if
X * you want to use gdt.
X */
X
X#ifndef WIZARDID
X#define WIZARDID (0)
X#endif
X
Xlogical wizard()
X{
X#ifdef __AMOS__
X    if (jobidx()->jobusr == 0x102)
X	return TRUE_;
X#else
X#ifdef unix
X    if (getuid() == 0 || getuid() == WIZARDID)
X	return TRUE_;
X#endif
X#endif
X
X    return FALSE_;
X}
X
X#endif
END_OF_FILE
if test 1713 -ne `wc -c <'local.c'`; then
    echo shar: \"'local.c'\" unpacked with wrong size!
fi
# end of 'local.c'
fi
echo shar: End of archive 12 \(of 12\).
cp /dev/null ark12isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 12 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0