[comp.sources.games] v01i049: warp7 - space war game, Part05/07

games-request@tekred.UUCP (06/10/87)

Submitted by: Larry Wall <lwall%sdcrdcf.UUCP@jove.cam.unisys.com>
Comp.sources.games: Volume 1, Issue 49
Archive-name: warp7/Part05



#! /bin/sh

# Make a new directory for the warp sources, cd to it, and run kits 1
# thru 7 through sh.  When all 7 kits have been run, read README.

echo "This is warp 7.0 kit 5 (of 7).  If kit 5 is complete, the line"
echo '"'"End of kit 5 (of 7)"'" will echo at the end.'
echo ""
export PATH || (echo "You didn't use sh, you clunch." ; kill $$)
echo Extracting warp.c
sed >warp.c <<'!STUFFY!FUNK!' -e 's/X//'
Xchar rcsid[] = "@(#)$Header: warp.c,v 7.0.1.3 86/12/12 17:07:44 lwall Exp $";
X
X/*	warp -- a real-time space war program
X *	author: Larry Wall
X *	helpers: Jonathan and Mark Biggar, and Dan Faigin
X *	special thanks to my sweetie Gloria who suggested the Planet Crusher
X *
X *	Copyright (C) 1986, Larry Wall
X *
X *	This program may be copied as long as this copyright notice is
X *	included, and as long as it is not being copied for purposes
X *	of profit.  If you want to modify this program in any way other
X *	than normal configuration changes, common decency would suggest
X *	that you also modify the name of the program so that my good name
X *	(what there is of it) is not impugned.  (Calling it something like
X *	"warpx" or "superwarp" would be fine.)  Also, give it another
X *	WARPDIR so that the scoreboards don't get confused.
X *
X * version 5.0  04/20/83
X *         5.1  05/05/83	various tidbits
X *	   5.2  05/12/83	VAX -> vax, ifdef'ed a SIGCONT
X *	   5.3  05/24/83	RCS
X *
X * $Log:	warp.c,v $
X * Revision 7.0.1.3  86/12/12  17:07:44  lwall
X * Baseline for net release.
X * 
X * Revision 7.0.1.2  86/10/20  12:08:00  lwall
X * Made all exits reset tty.
X * 
X * Revision 7.0.1.1  86/10/16  10:54:13  lwall
X * Added Damage.  Fixed random bugs.
X * 
X * Revision 7.0  86/10/08  15:14:47  lwall
X * Split into separate files.  Added amoebas and pirates.
X * 
X * Revision 6.4  83/12/16  13:11:45  lwall
X * Handled 15 bit random number generators.
X * 
X * Fixed array overflow bug on multiple zaps.
X * 
X * Multiple zaps now consolidated to minimize output.
X * 
X * Tholian jackpot games outlawed under difficulty 15.
X * 
X * Revision 6.3  83/08/24  11:17:49  lwall
X * Fixed array overflow bug on multiple zap.
X * 
X * Revision 6.2  83/08/23  18:06:37  lwall
X * Added zap command.
X * Warp -s should now work on dumb terminals
X * Specifying difficulty >= 40 now just makes it a special game.
X * SIGTTOU #ifdef'ed.
X * No-delay read provided as alternative to FIONREAD.
X * Warp won't report "-1 obsolete" when there are no Enterprises left.
X * Some high-difficulty tuning.
X * 
X * Revision 6.1  83/08/17  08:49:03  lwall
X * Fixed obscure bug in storing UP that caused a %. in CM to occasionally
X * foist garbage onto the screen.
X * 
X * Revision 6.0  83/08/08  17:09:26  lwall
X * New baseline version for net release.
X * 
X * Revision 5.5  83/08/01  10:59:56  lwall
X * Cloaking for the Enterprise.
X * Difficulty now goes to 99, and many activities depending on difficulty
X *     have been adjusted in frequency.
X * Simplified exit sequence, and reduced dependencies on control
X *     characters.  You needn't see the scoreboard if you don't want to.
X * Hitting i,w,c, or v switches to Enterprise.  Hitting p switches to Base.
X * Excessive use of q is not allowed.
X * Excessive use of D is not allowed.
X * Scoreboard may depend on either full name or login name.
X * Integrated scoreboard lister.  Login name now shows up on scoreboard.
X * "Hidden" startup options are now upper case.
X * Checks upon startup for no cursor movement, or screen too small.
X * Checks upon startup that WARPDIR is correctly protected, and that warp
X *     is running setuid.  As an additional bonus this prevents root from
X *     running warp, which mucks things up, UN*X be blessed.
X * All gets's turned into fgets's for safety.
X * Bonus Enterprises and Bases.
X * Escalating bonuses for saving Base and Enterprise.
X * Escalating Enterprise energy.
X * Turbolasers decrease with distance.
X * Really smart enemies can see through stars occasionally.
X * Occasional Tholian jackpot waves.  Tholians are a trifle nastier.
X * Choleric Gorns.
X * An O or o can miss seeing you.  Enemies can avoid a stationary O, o, or X.
X * Warp 3 enemies and other nastinesses are possible in massacre mode.
X * Enemies that decide to navigate when they see you can do other things than
X *     just come toward you.
X * Gorns occasionally launch a salvo for the fun of it.
X * Only star and enemy explosions can keep the round going now.
X * Bounces don't always go back to starting spot now.
X * Better full name processing.  USG quirks handled.  & substitution also
X *     handled now (whoever dreamed up that one must have been in the middle
X *     of the night before the morning after).
X * Catch ^D on fgets.
X * Version number printer.
X * Less signal catching during debugging.
X * 
X * Revision 5.4  83/06/24  09:28:38  lwall
X * 16 bit random number generators are now supported.
X * Made warp not blow up on a null save file.
X * Warp now prints E and B before the stars.
X * Fixed bug which caused torp count to get decremented even when no torp
X *     was launched because of an obstacle.
X * Put %<n>ld formats where appropriate.
X * Fixed E: 0  0 bug on refresh.
X * 
X * Revision 5.3  83/05/24  14:03:10  lwall
X * Starting RCS
X * 
X */
X
X#include "INTERN.h"
X#include "warp.h"
X#include "EXTERN.h"
X#include "bang.h"
X#include "init.h"
X#include "intrp.h"
X#include "object.h"
X#include "move.h"
X#include "play.h"
X#include "score.h"
X#include "sig.h"
X#include "term.h"
X#include "them.h"
X#include "us.h"
X#include "util.h"
X#include "version.h"
X#include "weapon.h"
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X    char tmp, *s, *tcbuf;
X
X    int i;
X
X    FILE *savfil;
X
X#if RANDBITS > 16
X    for (i=100; i; i--)
X	if (rand() >= 65536)
X	    goto rand_ok;
X    printf("Recompile with RANDBITS = 15 or 16.\n");
X    exit(1);
X#else
X#if RANDBITS > 15
X    for (i=100; i; i--) {
X	if (rand() >= 32768)
X	    goto rand_ok;
X    }
X    printf("Recompile with RANDBITS = 15.\n");
X    exit(1);
X#endif
X#endif
Xrand_ok:
X
X#ifdef lint  /* to suppress "defined but never used" */
X# ifdef SIGTSTP
X    (void)stop_catcher();
X# endif
X# ifdef SIGCONT
X    (void)cont_catcher();
X# endif
X#endif
X
X    while (--argc > 0 && (*++argv)[0] == '-')
X	for (s = argv[0]+1; *s != '\0'; s++)
X	    switch (*s) {
X	    case '&':
X		amoebaspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case 'A':
X		apolspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case 'b':
X		beginner = TRUE;
X		break;
X	    case 'C':
X		crushspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case 'D':
X		debugging = TRUE;
X#ifdef DEBUGGING
X		debug = atoi(++s);
X#endif
X		s += strlen(s)-1;
X		break;
X	    case 'd':
X		s++;
X		if (*s == '=') s++;
X		ismarts = atoi(s);
X		if (ismarts <= 0)
X		    ismarts = 1;
X		if (ismarts > 99)
X		    ismarts = 99;
X		if (ismarts > 40)
X		    beginner = TRUE;
X		s += strlen(s)-1;
X		break;
X	    case 'E':
X		klingspec = TRUE;
X		beginner = TRUE;
X		s++;
X		if (*s == '=') s++;
X		inumenemies = atoi(s);
X		s += strlen(s)-1;
X		break;
X	    case 'F':
X		friendspec = TRUE;
X		beginner = TRUE;
X		s++;
X		if (*s == '=') s++;
X		inumfriends = atoi(s);
X		s += strlen(s)-1;
X		break;
X	    case 'G':
X		gornspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case 'l':
X		lowspeed = TRUE;
X		break;
X	    case 'm':
X		metakey = TRUE;
X		break;
X	    case 'M':
X		massacre = TRUE;
X		break;
X	    case 'P':
X		piratespec = TRUE;
X		beginner = TRUE;
X		s++;
X		if (*s == '=') s++;
X		inumpirates = atoi(s);
X		s += strlen(s)-1;
X		break;
X	    case 'S':
X		prespec = TRUE;
X		beginner = TRUE;
X		s++;
X		if (*s == '=') s++;
X		if (*s)
X		    prescene = atoi(s);
X		else
X		    prescene = -1;
X		s += strlen(s)-1;
X		break;
X	    case 'R':
X		romspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case '*':
X		starspec = TRUE;
X		beginner = TRUE;
X		s++;
X		if (*s == '=') s++;
X		inumstars = atoi(s);
X		s += strlen(s)-1;
X		break;
X	    case 's':
X		scorespec = TRUE;
X		break;
X	    case 'T':
X		tholspec = TRUE;
X		beginner = TRUE;
X		break;
X	    case 'x':
X		experimenting = TRUE;
X		break;
X	    case 'v':
X		version();
X		exit(0);
X		break;
X	    default:
X		fprintf(stderr,"warp: illegal option %c\n", *s);
X		fprintf(stderr, "Usage: warp -dn -b -x -v -s\n");
X		exit(1);
X	    }
X    if (argc != 0) {
X	fprintf(stderr, "Usage: warp -dn -b -x -v -s\n");
X	exit(1);
X    }
X    bang_init();
X    move_init();
X    object_init();
X    play_init();
X    them_init();
X    us_init();
X    util_init();
X    weapon_init();
X
X    tcbuf = malloc(1024);
X    intrp_init(tcbuf);
X
X    if (chdir(warplib) < 0)
X	fprintf(stderr,nocd,warplib);
X
X    term_init();
X
X    term_set(tcbuf);
X    free(tcbuf);
X
X    umask(022);     /* mustn't rely on incoming umask--could be 033 which */
X		    /* would disable people from running wscore */
X
X    score_init();
X
X    sig_init();
X
X    if (totalscore) {
X	clear();
X	mvaddstr(12,25,"*** restoring saved game ***");
X	roundsleep(1);
X    }
X
X    srand(getpid());
X
X    do {
X	for (keepgoing = TRUE;;) {
X	    if (!experimenting) {
X		if ((savfil = fopen(savefilename,"w")) == NULL) {
X		    resetty();
X		    printf("Can't open savefile\r\n");
X		    finalize(1);
X		}
X		fprintf(savfil,
X		    "%-8s %10ld, %2d,%5d,%2d,%2d,%3d %c%c%c%c%c%c%c%c%c\n",
X		    logname, totalscore, smarts, cumsmarts,
X		    numents, numbases, wave,
X		    apolspec ? 'a' : ' ',
X		    beginner   ? 'b' : ' ',
X		    crushspec  ? 'c' : ' ',
X		    gornspec   ? 'g' : ' ',
X		    massacre   ? 'm' : ' ',
X		    romspec    ? 'r' : ' ',
X		    tholspec   ? 't' : ' ',
X		    lowspeed   ? 'l' : ' ',
X		    amoebaspec ? '&' : ' '
X		);
X		fprintf(savfil,"         running on %s, process #%d\n",
X		    term+5,getpid());
X		Fclose(savfil);
X	    }
X
X	    lastscore = totalscore;
X	    initialize();
X	    play();
X	    cumsmarts += smarts;
X	    wavescore();
X	    if (numents<=0 && numbases<=0)
X		keepgoing = FALSE;
X	  if (!keepgoing) break;
X	    do {
X		if (experimenting) {
X		    mvaddstr(23,15,
X		      "      [Hit space to continue, 'q' to quit]       ");
X		}
X		else {
X		    mvaddstr(23,15,
X		      "[Hit space to continue, 's' to save, 'q' to quit]");
X		}
X		sleep(1);
X		Fflush(stdout);
X		eat_typeahead();
X		getcmd(&tmp);
X		if (tmp == BREAKCH || tmp == INTRCH) {
X		    mvaddstr(23,15,
X		      "                                                 ");
X		    mvaddstr(23,33,
X		      "Really quit? ");
X		    getcmd(&tmp);
X		    if (tmp == 'y' || tmp == 'Y')
X			tmp = 'q';
X		    else
X			tmp = 1;
X		}
X	    } while (tmp != INTRCH && tmp != BREAKCH && !index(" qQs",tmp));
X	  if (tmp != ' ' && tmp != 's') break;
X	    if (!beginner && smarts < 20)
X		smarts += 4;
X	    else if (!beginner && smarts < 35)
X		smarts += 2;
X	    else if (smarts < 99)
X		smarts++;
X	  if (tmp == 's') save_game();
X	}
X	score();
X
X    } while (justonemoretime);
X
X    if (!experimenting)
X	unlink(savefilename);
X
X    clear();
X    resetty();
X    exit(0);
X}
!STUFFY!FUNK!
echo Extracting us.c
sed >us.c <<'!STUFFY!FUNK!' -e 's/X//'
X/* $Header: us.c,v 7.0.1.3 87/01/13 17:13:21 lwall Exp $ */
X
X/* $Log:	us.c,v $
X * Revision 7.0.1.3  87/01/13  17:13:21  lwall
X * Partially fixed ^S behavior.  It now just ignores ^S.
X * 
X * Revision 7.0.1.2  86/12/12  17:06:09  lwall
X * Baseline for net release.
X * 
X * Revision 7.0.1.1  86/10/16  10:53:50  lwall
X * Added Damage.  Fixed random bugs.
X * 
X * Revision 7.0  86/10/08  15:14:21  lwall
X * Split into separate files.  Added amoebas and pirates.
X * 
X */
X
X#include "EXTERN.h"
X#include "warp.h"
X#include "bang.h"
X#include "object.h"
X#include "play.h"
X#include "sig.h"
X#include "term.h"
X#include "util.h"
X#include "weapon.h"
X#include "INTERN.h"
X#include "us.h"
X
Xvoid
Xus_init()
X{
X    ;
X}
X
Xvoid
Xdo_direction(dy,dx)
Xint dy, dx;
X{
X    Reg1 int decr;
X    Reg2 OBJECT *obj;
X
X    if (status < 2) {
X	if (cloaking) {
X	    char ch;
X	    
X	    cloaked = FALSE;
X	    ch = (ent->energy >= 500?'E':'e');
X	    if (ch != ent->image) {
X		setimage(ent, ch);
X	    }
X	}
X	decr = 5+abs(evely)+abs(evelx)+tractor*tractor;
X	if (ent->energy >= decr) {
X	    ent->energy -= decr;
X	    if (tractor) {
X		if (!damage || !damflag[NOTRACTORS]) {
X		    if (!rand_mod(50)) {
X			damage++;
X			damflag[NOTRACTORS] = rand_mod(smarts+10)+2;
X		    }
X		    if (tract(ent,dy,dx,tractor)) {
X			evely += tractor*dy;
X			evelx += tractor*dx;
X		    }
X		}
X	    }
X	    else if (!damage ||
X	      (!entmode && !damflag[NOIMPULSE]) ||
X	      (entmode && !damflag[NOWARP]) ) {
X		if (!rand_mod(30+500/(abs(evely)+abs(evelx)+1))) {
X		    damage++;
X		    damflag[entmode?NOWARP:NOIMPULSE] = rand_mod(smarts+10)+2;
X		}
X		evely += dy;
X		evelx += dx;
X	    }
X	    if (inumthols &&
X	      (obj=occupant[(ent->posy+evely+YSIZE00)%YSIZE]
X			   [(ent->posx+evelx+XSIZE00)%XSIZE] ) &&
X	      obj->type == Web)
X		evely = evelx = 0;
X	}
X    }
X    else if (status == 2) {
X	decr = 500+abs(bvely)*5+abs(bvelx)*5+tractor*tractor*100;
X	if (base->energy >= decr) {
X	    base->energy -= decr;
X	    if (tractor) {
X		if (tract(base,dy,dx,tractor)) {
X		    bvely += tractor*dy;
X		    bvelx += tractor*dx;
X		}
X	    }
X	    else {
X		bvely += dy;
X		bvelx += dx;
X	    }
X	    if (inumthols &&
X	      (obj=occupant[(base->posy+bvely+YSIZE00)%YSIZE]
X			   [(base->posx+bvelx+XSIZE00)%XSIZE] ) &&
X	      obj->type == Web)
X		bvely = bvelx = 0;
X	}
X    }
X    tractor = 0;
X}
X
Xvoid
Xctrl_direction(dy,dx)
Xint dy, dx;
X{
X    if (status < 2) {
X	if (cloaking) {
X	    char ch;
X	    
X	    cloaked = FALSE;
X	    ch = (ent->energy >= 500?'E':'e');
X	    if (ch != ent->image) {
X		setimage(ent, ch);
X	    }
X	}
X	if (!damage || !damflag[NOPHASERS]) {
X	    if (!rand_mod(200)) {
X		damage++;
X		damflag[NOPHASERS] = rand_mod(smarts+10)+2;
X	    }
X	    fire_phaser(ent, dy, dx);
X	}
X    }
X    else if (status == 2)
X	fire_phaser(base, dy, dx);
X}
X
Xvoid
Xshift_direction(dy,dx)
Xint dy, dx;
X{
X    if (status < 2) {
X	if (cloaking) {
X	    char ch;
X	    
X	    cloaked = FALSE;
X	    ch = (ent->energy >= 500?'E':'e');
X	    if (ch != ent->image) {
X		setimage(ent, ch);
X	    }
X	}
X	if (!damage || !damflag[NOTORPS]) {
X	    if (!rand_mod(300)) {
X		damage++;
X		damflag[NOTORPS] = rand_mod(smarts+10)+2;
X	    }
X	    fire_torp(ent, dy, dx);
X	}
X    }
X    else if (status == 2)
X	fire_torp(base, dy, dx);
X}
X
Xvoid
Xget_commands(done)
Xbool *done;
X{
X    static char ch[80];
X    Reg1 int i;
X    Reg2 int count;
X    Reg3 bool ctrla = FALSE;
X    char numdestructs = 0, numzaps = 0;
X
Xtop:
X    while (count = read_nd(ch,(sizeof ch))) {
X	for (i=0; i<count; i++) {
X	    if (ch[i] == 'Q') {
X		bombed_out = TRUE;
X		*done = TRUE;
X		keepgoing = FALSE;
X		return;
X	    }
X	    if (ch[i] == 'q' || ch[i] == BREAKCH || ch[i] == INTRCH) {
X		int x;
X		static char quest[] = "Do you wish to escape from reality? ";
X
X		if (timer >= whenok) {
X		    mvaddstr(12,22,quest);
X		    do {
X			getcmd(&ch[i]);
X		    } while (ch[i] != 'y' && ch[i] != 'n');
X		    if (ch[i] == 'y') {
X			bombed_out = TRUE;
X			*done = TRUE;
X			return;
X		    }
X		    else {
X			for (x=11; x<=28; x++) {
X			    mvaddch(12,x*2,
X				occupant[11][x]
X				   ? occupant[11][x]->image
X				   : numamoebas
X				      ? amb[11][x]
X				      : ' ');
X			    addspace();
X			}
X			roundsleep(2);
X			whenok = timer + 10;
X			goto top;
X		    }
X		}
X		else {
X		    write(1,"\07",1);
X		    goto top;
X		}
X	    }
X	}
X	for (i=0; i<count; i++) {
X	    if (ctrla) {
X		switch (ch[i]) {
X		case '1': case 'b':
X		    ctrl_direction(1, -1);
X		    break;
X		case '2': case 'j':
X		    ctrl_direction(1, 0);
X		    break;
X		case '3': case 'n':
X		    ctrl_direction(1, 1);
X		    break;
X		case '4': case 'h':
X		    ctrl_direction(0, -1);
X		    break;
X		case '6': case 'l':
X		    ctrl_direction(0, 1);
X		    break;
X		case '7': case 'y':
X		    ctrl_direction(-1, -1);
X		    break;
X		case '8': case 'k':
X		    ctrl_direction(-1, 0);
X		    break;
X		case '9': case 'u':
X		    ctrl_direction(-1, 1);
X		    break;
X		case 'r':
X		    rewrite();
X		    roundsleep(3);
X		    ctrla = FALSE;
X		    goto top;
X		case 'w':
X		    clear();
X		    while (!input_pending())
X			sleep(1);
X		    rewrite();
X		    roundsleep(3);
X		    ctrla = FALSE;
X		    goto top;
X#ifdef SIGTSTP
X		case 'z':
X		    clear();
X		    mytstp();
X		    sleep(4);
X		    ctrla = FALSE;
X		    goto top;
X#endif
X		default:
X		    break;
X		}
X		ctrla = FALSE;
X	    }
X	    else {
X		switch (ch[i]) {
X		case 'Z':
X		    clear();
X		    mytstp();
X		    sleep(4);
X		    goto top;
X		case 'i':
X		    if (ent && (!damage || !damflag[NOIMPULSE])) {
X			entmode = 0;
X			status = 0;
X		    }
X		    break;
X		case 'w':
X		    if (ent && (!damage || !damflag[NOWARP])) {
X			entmode = 1;
X			status = 1;
X		    }
X		    break;
X		case 'p':
X		    if (base) {
X			status = 2;
X		    }
X		    break;
X		case 'o':
X		    if (status < 2) {
X			if (base)
X			    status = 2;
X		    }
X		    else if (status == 2) {
X			if (ent)
X			    status = entmode;
X		    }
X		    break;
X		case 'v':
X		    if (ent) {
X			status = entmode;
X		    }
X		    cloaking=FALSE;
X		    cloaked=FALSE;
X		    break;
X		case 'c':
X		    if (ent) {
X			status = entmode;
X			if (ent->energy >= 250)
X			    cloaking = TRUE;
X		    }
X		    break;
X		case 'z':
X		    if (ent && (!damage || !damflag[NOZAPPER])) {
X			++numzaps;
X			if (!rand_mod(100/numzaps)) {
X			    damage++;
X			    damflag[NOZAPPER] = rand_mod(smarts+10)+2;
X			}
X			if (nxtbang && bangm[nxtbang-1] < 0)
X			    --nxtbang;	/* consolidate zaps */
X			make_blast(evely*2+ent->posy,evelx*2+ent->posx,
X			    -5000000L, 3*numzaps);
X			ent->energy /= 2;
X		    }
X		    break;
X		case 'D':
X		    if (status < 2 && (!damage || !damflag[NODESTRUCT])) {
X			if (ent && !rand_mod(10)) {
X			    damage++;
X			    damflag[NODESTRUCT] = rand_mod(smarts+10)+2;
X			}
X			if (++numdestructs <= 2)
X			    make_blast(evely*2+ent->posy,evelx*2+ent->posx,
X				15000L, 3);
X			ent->energy /= 4;
X		    }
X		    else if (status == 2) {
X			if (numdestructs)
X			    base->energy = base->energy / 2;
X			if (++numdestructs <= 2)
X			    make_blast(base->posy, base->posx, 15000L, 5);
X		    }
X		    break;
X		case 'd':
X		    if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) {
X			Reg4 OBJECT *obj;
X			int x, y;
X
X			if (ent && !rand_mod(200)) {
X			    damage++;
X			    damflag[NODESTRUCT] = rand_mod(smarts+10)+2;
X			}
X			for (obj = root.prev;
X			  obj != &root;
X			  obj = obj->prev) {
X			    if (obj->image == '+') {
X				blast[y=(obj->posy+obj->vely+YSIZE00)%YSIZE]
X				     [x=(obj->posx+obj->velx+XSIZE00)%XSIZE]
X				     += 1;
X				yblasted[y] |= 1;
X				xblasted[x] |= 1;
X				blasted = TRUE;
X				obj->mass = (massacre?3000:4000);
X			    }
X			}
X		    }
X		    break;
X		case 's':
X		    if ((!damage || !damflag[NODESTRUCT]) && (base||ent)) {
X			Reg4 OBJECT *obj;
X			if (ent && !rand_mod(200)) {
X			    damage++;
X			    damflag[NODESTRUCT] = rand_mod(smarts+10)+2;
X			}
X			for (obj = root.prev;
X			  obj->type == Torp || obj->type == Web ||
X			  obj->type == Star;
X			  obj = obj->prev) {
X			    if (obj->image == '+')
X				obj->vely = obj->velx = 0;
X			}
X		    }
X		    break;
X		case '\001':
X		    ctrla = TRUE;
X		    break;
X		case '\002':
X		case '\003':
X		case '\004':
X		case '\005':
X		case '\006':
X		case '\007':
X		case '\010':
X		case '\011':
X		case '\012':
X		case '\013':
X		case '\014':
X		case '\015':
X		case '\016':
X		case '\017':
X		case '\020':
X		case '\021':
X		case '\022':
X		case '\023':
X		case '\024':
X		case '\025':
X		case '\026':
X		case '\027':
X		case '\030':
X		case '\031':
X		case '\032':
X		    ch[i] += 96;
X		    i--;
X		    ctrla = TRUE;
X		    break;
X		case '\033':
X		    tractor = 0;
X		    break;
X		case 'a':
X		    tractor++;
X		    break;
X		case 'r':
X		    tractor--;
X		    break;
X		case '1': case 'b':
X		    do_direction(1,-1);
X		    break;
X		case '2': case 'j':
X		    do_direction(1,0);
X		    break;
X		case '3': case 'n':
X		    do_direction(1,1);
X		    break;
X		case '4': case 'h':
X		    do_direction(0,-1);
X		    break;
X		case '6': case 'l':
X		    do_direction(0,1);
X		    break;
X		case '7': case 'y':
X		    do_direction(-1,-1);
X		    break;
X		case '8': case 'k':
X		    do_direction(-1,0);
X		    break;
X		case '9': case 'u':
X		    do_direction(-1,1);
X		    break;
X		case '0': case 'S':
X		    if (status < 2) {
X			evely = 0;
X			evelx = 0;
X		    }
X		    break;
X		case '-':
X		    if (status < 2 && ent->energy >= 10) {
X			evely *= -1;
X			evelx *= -1;
X			ent->energy -= 10;
X		    }
X		    break;
X		case '%': case '\177': case '_':
X		    shift_direction(0, -1);
X		    shift_direction(0, 1);
X		    shift_direction(-1, 0);
X		    shift_direction(1, 0);
X		    shift_direction(-1, -1);
X		    shift_direction(-1, 1);
X		    shift_direction(1, -1);
X		    shift_direction(1, 1);
X		    break;
X		case '!': case 'B':
X		    shift_direction(1, -1);
X		    break;
X		case '@': case 'J':
X		    shift_direction(1, 0);
X		    break;
X		case '#': case 'N':
X		    shift_direction(1, 1);
X		    break;
X		case '$': case 'H':
X		    shift_direction(0, -1);
X		    break;
X		case '^': case 'L':
X		    shift_direction(0, 1);
X		    break;
X		case '&': case 'Y':
X		    shift_direction(-1, -1);
X		    break;
X		case '*': case 'K':
X		    shift_direction(-1, 0);
X		    break;
X		case '(': case 'U':
X		    shift_direction(-1, 1);
X		    break;
X		case '?':
X		    helper();
X		    roundsleep(3);
X		    goto top;
X		default:
X		    break;
X		}
X	    }
X	}
X    }
X}
!STUFFY!FUNK!
echo Extracting them.c
sed >them.c <<'!STUFFY!FUNK!' -e 's/X//'
X/* $Header: them.c,v 7.0.1.5 86/12/12 17:05:41 lwall Exp $ */
X
X/* $Log:	them.c,v $
X * Revision 7.0.1.5  86/12/12  17:05:41  lwall
X * Baseline for net release.
X * 
X * Revision 7.0.1.4  86/10/20  12:32:38  lwall
X * Wasn't clearing FRIENDLY flag on pirate creation.
X * 
X * Revision 7.0.1.3  86/10/20  12:15:33  lwall
X * Was trying to create pirates from cloaked pirates.
X * 
X * Revision 7.0.1.2  86/10/17  10:03:44  lwall
X * Fixed Romulan writing spaces while cloaked.
X * 
X * Revision 7.0.1.1  86/10/16  10:53:39  lwall
X * Added Damage.  Fixed random bugs.
X * 
X * Revision 7.0  86/10/08  15:14:15  lwall
X * Split into separate files.  Added amoebas and pirates.
X * 
X */
X
X#include "EXTERN.h"
X#include "warp.h"
X#include "bang.h"
X#include "object.h"
X#include "move.h"
X#include "score.h"
X#include "term.h"
X#include "us.h"
X#include "util.h"
X#include "weapon.h"
X#include "INTERN.h"
X#include "them.h"
X
Xvoid
Xthem_init()
X{
X    ;
X}
X
Xvoid
Xtheir_smarts()
X{
X    Reg1 OBJECT *curkl;
X    Reg2 OBJECT *obj;
X    Reg3 int prob;
X    Reg4 int count;
X    Reg5 int y;
X    Reg6 int x;
X
X    if (numcrushes && (obj=movers)->type == Crusher) {
X	if (numamoebas) {
X	    y = obj->posy;
X	    x = (obj->posx+(obj->image=='<'?1:-1)+XSIZE00)%XSIZE;
X	    if (amb[y][x] == '~') {
X		obj->velx = 0;		/* stop and munch amoeba */
X		modify_amoeba(y,x,1,' ',(int)rand_mod(5+ambsize/10)+1);
X		if (occupant[y][x] == nuke)	/* except go for nucleus */
X		    obj->velx = (obj->image=='<' ? 1 : -1);
X	    }
X	    else if (!obj->velx) {
X		if (!rand_mod(4))
X		    obj->image = rand_mod(2) ? '<' : '>';
X		obj->velx = obj->image == '<' ? 1 : -1;
X	    }
X	}
X	obj->vely += (rand_mod(222) - 111) / 100;
X	if (!(rand_mod(100))) {
X	    setimage(obj, (obj->velx *= -1) < 0 ? '>' : '<');
X	}
X    }
X    if (numamoebas) {
X	if (!rand_mod(3))
X	    nuke->velx = nuke->vely = 0;
X	if (nuke->strategy && ambsize < 90 && !rand_mod(200-smarts))
X	    modify_amoeba(0,0,0,'~',(int)rand_mod(10));
X	if (ambsize > 200 || (ambsize > 100 && !rand_mod(15)))
X	    modify_amoeba(yamblast,xamblast,2,' ',(ambsize-100)/5);
X    }
X    for (curkl = enemies; curkl->type == Enemy; curkl = curkl->next) {
X	if ((curkl->flags & (CLOAKS|FRIENDLY)) == CLOAKS &&
X	    (curkl->image != ' ') &&
X	    (curkl->energy > 300 || massacre) ) {
X	    setimage(curkl, ' ');
X	}
X	if (madgorns)
X	    prob = 3;
X	else if (curkl->vely || curkl->velx)
X	    prob = massacre?10:20;
X	else if ((curkl->flags & (PIRATE|FRIENDLY)) == PIRATE) {
X				/* pirates want to sit sometimes */
X	    if (curkl->strategy) {
X		if ((obj = lookimg(curkl->posy, curkl->posx, '@')) ||
X		    (obj = lookimg(curkl->posy, curkl->posx, 'B')) ) {
X		    make_plink(obj->posy, obj->posx);
X		    if (!--curkl->strategy) {	/* clock ran down */
X			if (obj->image == '@') {
X			    obj->image = '*';
X			    numinhab--;
X			    if (obj->flags & STATIC)
X				mvaddch(obj->posy+1,obj->posx*2,obj->image);
X			    if (curkl->energy < 20000)
X				curkl->energy += 5000;
X			}
X			prob = 2;	/* our work here is done */
X		    }
X		    else if (obj->image == 'B') {
X			btorp -= rand_mod(50);
X			if (btorp < 0)
X			    btorp = 0;
X			obj->energy -= rand_mod(500);
X			if (obj->energy < 0)
X			    obj->energy = 0;
X			prob = 10000;		/* stay here */
X		    }
X		    else
X			prob = 10000;
X		}
X		else {		/* it went away--go elsewhere */
X		    prob = 4;
X		    curkl->strategy = 0;
X		}
X	    }
X	    else if (lookimg(curkl->posy, curkl->posx, '@') ||
X		     lookimg(curkl->posy, curkl->posx, 'B')) {
X		curkl->strategy = rand_mod(15)+5;
X		prob = 10000;
X	    }
X	    else
X		prob = 4;
X	}
X	else if (curkl->image == 'M') {	/* Mudd wants to sit sometimes */
X	    if ((obj = lookimg(curkl->posy, curkl->posx, 'E')) ||
X		(obj = lookimg(curkl->posy, curkl->posx, 'B')) ) {
X		if (obj->image == 'B') {
X		    btorp -= rand_mod(40);
X		    if (btorp < 0)
X			btorp = 0;
X		    obj->energy -= rand_mod(100);
X		    if (obj->energy < 0)
X			obj->energy = 0;
X		}
X		else if (!obj->vely && !obj->velx) {
X		    etorp -= rand_mod(10);
X		    if (etorp < 0)
X			etorp = 0;
X		    obj->energy -= rand_mod(20);
X		    if (obj->energy < 0)
X			obj->energy = 0;
X		}
X		prob = 10000;		/* stay here */
X	    }
X	    else		/* it went away--go elsewhere */
X		prob = 4;
X	}
X	else if (curkl->flags & FRIENDLY) {
X	    if (curkl->energy < 10000 &&
X	      lookimg(curkl->posy, curkl->posx, '@') ) {
X		curkl->energy += 100;
X		prob = 20;	/* do some loading */
X	    }
X	    else
X		prob = 4;
X	}
X	else if (curkl->image == '&') {
X	    if (curkl->flags & COUNTDOWN) {
X		if (curkl->strategy)
X		    curkl->strategy--;
X		else
X		    curkl->flags &= ~COUNTDOWN;
X		prob = 100;	/* someone's feeding us, so sit still */
X	    }
X	    else
X		prob = 4;
X	}
X	else
X	    prob = 4;			/* don't sit still too long */
X	count = 11;
X	for (;;) {
X	    if (--count <= 0)		/* no opening, just ram something */
X		break;
X
X#ifdef lint
X	    prob = prob;
X#endif
X	    if (!(rand_mod(prob)))	/* turn randomly occasionally */
X		goto accell;
X
X	    y=(curkl->posy+curkl->vely+YSIZE00)%YSIZE;	/* find prospective */
X	    x=(curkl->posx+curkl->velx+XSIZE00)%XSIZE;	/*   new position */
X
X	    if (numamoebas) {
X		if (curkl == nuke) {
X		    if (amb[y][x] != '~')
X			goto accell;	/* never move nucleus from protoplasm */
X		}
X		else {
X		    if (amb[y][x] == '~' && rand_mod(2)) {
X			yamblast = y;
X			xamblast = x;
X			goto accell;
X		    }
X		}
X	    }
X
X	    obj = occupant[y][x];
X	    if (!obj) break;		/* is anyone there? */
X
X	    switch (obj->type) {
X	    case Star:
X		if (obj->image == '@' && (curkl->flags & PIRATE)) {
X		    if (curkl->image != 'P' && curkl->image != ' ') {
X			if (curkl->flags & FRIENDLY) {
X			    curkl->flags &= ~FRIENDLY;
X			    curkl->energy += 1000;
X			    possiblescore += curkl->mass;
X			    inumfriends--;
X			    numfriends--;
X			    inumenemies++;
X			    numenemies++;
X			}
X			curkl->image = 'P';
X		    }
X		    break;		/* go ahead and ram the star */
X		}
X		goto accell;		/* try not to ram stars */
X	    case Torp:
X		if (!obj->vely && !obj->velx && (rand_mod(100) <= smarts) &&
X		  (obj->image == 'o' || obj->image == 'O' || obj->image == 'X'))
X		    goto accell;	/* try not to ram "friendly" torps */
X		break;
X	    case Web:
X		if (curkl->image != 'T')
X		    goto accell;	/* non-Tholians shouldn't ram web */
X		if (count <= 5)
X		    break;		/* Tholians retrace web if desperate */
X		if (obj->image ==
X		    (curkl->vely?
X		     (curkl->velx?
X		      (curkl->velx==curkl->vely?
X		       '\\'
X		      :
X		       '/'
X		      )
X		     :
X		      '|'
X		     )
X		    :
X		     '-'
X		    )
X		   ) goto accell;	/* Tholians try not to retrace web */
X		break;			/* No problem with crossing web */
X	    }
X	    break;			/* okay to move over object */
X
X	accell:
X	    /* determine maximum velocity */
X	    if (massacre && curkl->image != 'T') {
X		curkl->vely = rand_mod(7) - 3;
X		curkl->velx = rand_mod(7) - 3;
X	    }
X	    else if (curkl->image == '&') {
X		if (rand_mod(2)) {
X		    curkl->vely = rand_mod(3) - 1;
X		    curkl->velx = rand_mod(3) - 1;
X		}
X		else {
X		    curkl->vely = curkl->strategy & 3;
X		    if (curkl->vely & 2)
X			curkl->vely = -1;
X		    curkl->velx = (curkl->strategy >> 2) & 3;
X		    if (curkl->velx & 2)
X			curkl->velx = -1;
X		}
X	    }
X	    else if (curkl->energy >= 2500 && curkl->image != 'T') {
X		curkl->vely = rand_mod(5) - 2;
X		curkl->velx = rand_mod(5) - 2;
X	    }
X	    else {
X		curkl->vely = rand_mod(3) - 1;
X		curkl->velx = rand_mod(3) - 1;
X	    }
X	}
X	if (count != 10) {
X	    if (curkl->image == ' ') {
X		setimage(curkl, curkl->flags & PIRATE ? 'P' : 'R');
X	    }
X	    if (!count) {
X		curkl->vely = 0;
X		curkl->velx = 0;
X	    }
X	}
X	if (curkl->image == 'G' && (base||ent) &&
X	    !rand_mod((103-smarts)*10) ) {
X	    int xxx,yyy;
X
X	    for (xxx = -1; xxx<=1; xxx++)
X		for (yyy = -1; yyy<=1; yyy++)
X		    if ((xxx||yyy) && rand_mod(2))
X			fire_torp(curkl,yyy,xxx);
X	}
X	else if (curkl->image == 'T' && (curkl->velx || curkl->vely)) {
X	    Make_object(Web,
X            curkl->vely?
X	     (curkl->velx?
X	      (curkl->velx==curkl->vely?
X	       '\\'
X	      :
X	       '/'
X	      )
X	     :
X	      '|'
X	     )
X	    :
X	     '-',
X	    curkl->posy,curkl->posx,0,0,32767L,32767L,&root);
X	    if (obj && obj->type == Web) {
X		unmake_object(obj);
X		occupant[y][x] = Null(OBJECT*);
X	    }
X	}
X    }
X    /* klingon-style fighting */
X    if (numamoebas)
X	attack(nuke);
X    attack(base);
X    if (ent && (!cloaked || ent->image=='E' || ent->image=='e'))
X	attack(ent);
X}
X
Xvoid
Xmodify_amoeba(y,x,where,ch,quant)
XReg1 int y;
XReg2 int x;
Xint where;
XReg6 int ch;
XReg7 int quant;
X{
X    Reg3 int dy;
X    Reg4 int dx;
X    Reg5 int count = 15;
X
X    if (!numamoebas)
X	return;
X    if (!where || (where==1 && rand_mod(2))) {
X	y = nuke->posy;
X	x = nuke->posx;
X    }
X    if (nuke->strategy && rand_mod(3)) {
X	dy = nuke->strategy & 3;
X	if (dy & 2)
X	    dy = -1;
X	dx = (nuke->strategy >> 2) & 3;
X	if (dx & 2)
X	    dx = -1;
X	if (ch == ' ') {		/* take from the tail */
X	    dy = -dy;
X	    dx = -dx;
X	}
X	if (!rand_mod(100))
X	    nuke->strategy = rand_mod(256);
X    }
X    else {
X	dy = rand_mod(3) - 1;
X	dx = rand_mod(3) - 1;
X    }
X    if (!dy && !dx)
X	return;
X    do {
X	if (--count < 0)
X	    return;
X	y = (y + dy + YSIZE00) % YSIZE;
X	x = (x + dx + XSIZE00) % XSIZE;
X    } while (amb[y][x] != ' ');
X    if (ch == ' ') {
X	y = (y - dy + YSIZE00) % YSIZE;
X	x = (x - dx + XSIZE00) % XSIZE;
X    }
X    if (ambsize > 100 && quant > 2) {
X	quant >>= (ambsize/100);
X    }
X    if ((nuke->energy += quant << 6) > 32767)
X	nuke->energy = 32767;
X    count = quant << 3;		/* endless loop catcher */
X    while (count-- > 0 && quant > 0) {
X	if (amb[y][x] != ch) {
X	    quant--;
X	    amb[y][x] = ch;
X	    if (ch == '~') {
X		ambsize++;
X		yblasted[y] |= 2;
X		xblasted[x] |= 2;
X		blasted = TRUE;
X	    }
X	    else
X		ambsize--;
X	    if (!occupant[y][x])
X		mvaddch(y+1,x*2,ch);
X	}
X	y = (y + rand_mod(3) + YSIZE99) % YSIZE;
X	x = (x + rand_mod(3) + XSIZE99) % XSIZE;
X    }
X}
!STUFFY!FUNK!
echo Extracting config.h.SH
sed >config.h.SH <<'!STUFFY!FUNK!' -e 's/X//'
Xcase $CONFIG in
X'')
X    if test ! -f config.sh; then
X	ln ../config.sh . || \
X	ln ../../config.sh . || \
X	ln ../../../config.sh . || \
X	(echo "Can't find config.sh."; exit 1)
X	echo "Using config.sh from above..."
X    fi
X    . config.sh
X    ;;
Xesac
Xecho "Extracting config.h (with variable substitutions)"
Xcat <<!GROK!THIS! >config.h
X/* config.h
X * This file was produced by running the config.h.SH script, which
X * gets its values from config.sh, which is generally produced by
X * running Configure.
X *
X * Feel free to modify any of this as the need arises.  Note, however,
X * that running config.h.SH again will wipe out any changes you've made.
X * For a more permanent change edit config.sh and rerun config.h.SH.
X */
X
X
X/* EUNICE:
X *	This symbol, if defined, indicates that the program is being compiled
X *	under the EUNICE package under VMS.  The program will need to handle
X *	things like files that don't go away the first time you unlink them,
X *	due to version numbering.  It will also need to compensate for lack
X *	of a respectable link() command.
X */
X/* VMX:
X *	This symbol, if defined, indicates that the program is running under
X *	VMS.  It is currently only set in conjunction with the EUNICE symbol.
X */
X#$d_eunice	EUNICE		/**/
X#$d_eunice	VMS		/**/
X
X/* CHARSPRINTF:
X *	This symbol is defined if this system declares "char *sprintf()" in
X *	stdio.h.  The trend seems to be to declare it as "int sprintf()".  It
X *	is up to the package author to declare sprintf correctly based on the
X *	symbol.
X */
X#$d_charsprf	CHARSPRINTF 	/**/
X
X/* FCNTL:
X *	This symbol, if defined, indicates to the C program that it should
X *	include fcntl.h.
X */
X#$d_fcntl	FCNTL		/**/
X
X/* FTIMER:
X *	This symbol, if defined, indicates that the ftime() routine exists.
X */
X#$d_ftime	FTIMER		/**/
X
X/* GETHOSTNAME:
X *	This symbol, if defined, indicates that the C program may use the
X *	gethostname() routine to derive the host name.  See also DOUNAME
X *	and PHOSTNAME.
X */
X/* DOUNAME:
X *	This symbol, if defined, indicates that the C program may use the
X *	uname() routine to derive the host name.  See also GETHOSTNAME and
X *	PHOSTNAME.
X */
X/* PHOSTNAME:
X *	This symbol, if defined, indicates that the C program may use the
X *	contents of PHOSTNAME as a command to feed to the popen() routine
X *	to derive the host name.  See also GETHOSTNAME and DOUNAME.
X */
X#$d_gethname	GETHOSTNAME	/**/
X#$d_douname	DOUNAME		/**/
X#$d_phostname	PHOSTNAME "$phostname"	/**/
X
X/* GETPWENT:
X *	This symbol, if defined, indicates that the getpwent() routine
X *	should be used instead of the getpw() routine.
X */
X#$d_getpwent	GETPWENT	/**/
X
X/* HAVETERMLIB:
X *	This symbol, when defined, indicates that termlib-style routines
X *	are available.  There is nothing to include.
X */
X#$d_havetlib	HAVETERMLIB	/**/
X
X/* index:
X *	This preprocessor symbol is defined, along with rindex, if the system
X *	uses the strchr and strrchr routines instead.
X */
X/* rindex:
X *	This preprocessor symbol is defined, along with index, if the system
X *	uses the strchr and strrchr routines instead.
X */
X#$d_index	index strchr	/* cultural */
X#$d_index	rindex strrchr	/*  differences? */
X
X/* IOCTL:
X *	This symbol, if defined, indicates that sys/ioctl.h exists and should
X *	be included.
X */
X#$d_ioctl	IOCTL		/**/
X
X/* NORMSIG:
X *	This symbol, if defined, indicates that normal signal handling routines
X *	should be used, as opposed to the ones in 4.1bsd (sigset, etc.).
X */
X#$d_normsig	NORMSIG		/**/
X
X/* PORTABLE:
X *	This symbol, if defined, indicates to the C program that it should
X *	not assume that it is running on the machine it was compiled on.
X *	The program should be prepared to look up the host name, translate
X *	generic filenames, use PATH, etc.
X */
X#$d_portable	PORTABLE	/**/
X
X/* RDCHK:
X *	This symbol, if defined, indicates that the rdchk routine is available
X *	to find out if there is input pending on an IO channel.  Generally
X *	the routine is used only if FIONREAD and O_NDELAY aren't available.
X */
X#$d_rdchk	RDCHK		/**/
X
X/* SCOREFULL:
X *	This symbol, if defined, indicates that any scoreboard kept by the
X *	program should be kept on the basis of the user's full name as opposed
X *	to the user's login name.  If the user can change his full name he
X *	can enter multiple scores if this is defined.
X */
X#$d_scorfl	SCOREFULL	/**/
X
X/* SIGNEDCHAR:
X *	This symbol, if defined, indicates that characters are a signed type.
X *	If not defined, things declared as signed characters (and that make
X *	use of negative values) should probably be declared as shorts instead.
X */
X#$d_sgndchr	SIGNEDCHAR	/**/
X
X/* TERMIO:
X *	This symbol, if defined, indicates that the program should include
X *	termio.h rather than sgtty.h.  There are also differences in the
X *	ioctl() calls that depend on the value of this symbol.
X */
X#$d_termio	TERMIO		/**/
X
X/* USENDIR:
X *	This symbol, if defined, indicates that the program should compile
X *	the ndir.c code provided with the package.
X */
X/* LIBNDIR:
X *	This symbol, if defined, indicates that the program should include the
X *	system's version of ndir.h, rather than the one with this package.
X */
X#$d_usendir	USENDIR		/**/
X#$d_libndir	LIBNDIR		/**/
X
X/* WHOAMI:
X *	This symbol, if defined, indicates that the program may include
X *	whoami.h.
X */
X#$d_whoami	WHOAMI		/**/
X
X/* HOSTNAME:
X *	This symbol contains name of the host the program is going to run on.
X *	The domain is not kept with hostname, but must be gotten from MYDOMAIN.
X *	The dot comes with MYDOMAIN, and need not be supplied by the program.
X *	If gethostname() or uname() exist, HOSTNAME may be ignored.
X */
X/* MYDOMAIN:
X *	This symbol contains the domain of the host the program is going to
X *	run on.  The domain must be appended to HOSTNAME to form a complete
X *	host name.  The dot comes with MYDOMAIN, and need not be supplied by
X *	the program.  If the host name is derived from PHOSTNAME, the domain
X *	may or may not already be there, and the program should check.
X */
X#define HOSTNAME "$hostname"		/**/
X#define MYDOMAIN "$mydomain"		/**/
X
X/* PASSNAMES:
X *	This symbol, if defined, indicates that full names are stored in
X *	the /etc/passwd file.
X */
X/* BERKNAMES:
X *	This symbol, if defined, indicates that full names are stored in
X *	the /etc/passwd file in Berkeley format (name first thing, everything
X *	up to first comma, with & replaced by capitalized login id, yuck).
X */
X/* USGNAMES:
X *	This symbol, if defined, indicates that full names are stored in
X *	the /etc/passwd file in USG format (everything after - and before ( is
X *	the name).
X */
X#$d_passnames	PASSNAMES /*  (undef to take name from ~/.fullname) */
X#$d_berknames	BERKNAMES /* (that is, ":name,stuff:") */
X#$d_usgnames	USGNAMES  /* (that is, ":stuff-name(stuff):") */
X
X/* PREFSHELL:
X *	This symbol contains the full name of the preferred user shell on this
X *	system.  Usual values are /bin/csh, /bin/ksh, /bin/sh.
X */
X#define PREFSHELL "$prefshell"		/**/
X
X/* RANDBITS:
X *	This symbol contains the number of bits of random number the rand()
X *	function produces.  Usual values are 15, 16, and 31.
X */
X#define RANDBITS $randbits		/**/
X
X/* Reg1:
X *	This symbol, along with Reg2, Reg3, etc. is either the word "register"
X *	or null, depending on whether the C compiler pays attention to this
X *	many register declarations.  The intent is that you don't have to
X *	order your register declarations in the order of importance, so you
X *	can freely declare register variables in sub-blocks of code and as
X *	function parameters.  Do not use Reg<n> more than once per routine.
X */
X
X#define Reg1 $reg1		/**/
X#define Reg2 $reg2		/**/
X#define Reg3 $reg3		/**/
X#define Reg4 $reg4		/**/
X#define Reg5 $reg5		/**/
X#define Reg6 $reg6		/**/
X#define Reg7 $reg7		/**/
X#define Reg8 $reg8		/**/
X#define Reg9 $reg9		/**/
X#define Reg10 $reg10		/**/
X#define Reg11 $reg11		/**/
X#define Reg12 $reg12		/**/
X#define Reg13 $reg13		/**/
X#define Reg14 $reg14		/**/
X#define Reg15 $reg15		/**/
X#define Reg16 $reg16		/**/
X
X/* ROOTID:
X *	This symbol contains the uid of root, normally 0.
X */
X#define ROOTID $rootid		/**/
X
X/* VOIDFLAGS:
X *	This symbol indicates how much support of the void type is given by this
X *	compiler.  What various bits mean:
X *
X *	    1 = supports declaration of void
X *	    2 = supports arrays of pointers to functions returning void
X *	    4 = supports comparisons between pointers to void functions and
X *		    addresses of void functions
X *
X *	The package designer should define VOIDUSED to indicate the requirements
X *	of the package.  This can be done either by #defining VOIDUSED before
X *	including config.h, or by defining defvoidused in Myinit.U.
X */
X#ifndef VOIDUSED
X#define VOIDUSED $defvoidused
X#endif
X#define VOIDFLAGS $voidflags
X#if (VOIDFLAGS & VOIDUSED) != VOIDUSED
X#$define void int		/* is void to be avoided? */
X#$define M_VOID		/* Xenix strikes again */
X#endif
X
X/* $package private library, may use ~ expansion, %x and %l */
X#define PRIVLIB "$privlib"		/**/
X
X!GROK!THIS!
!STUFFY!FUNK!
echo Extracting warp.man
sed >warp.man <<'!STUFFY!FUNK!' -e 's/X//'
X.TH WARP 6
X.SH NAME
Xwarp - a real-time space war game
X.SH SYNOPSIS
X.B warp [options]
X.SH DESCRIPTION
X.I Warp
Xis a real-time space war game that requires skill and quick thinking.
X"Real-time" in this context means that the enemies keep moving (and shooting)
Xeven if you don't.
XA unique feature of
X.I warp
Xis that blast propagates; it is unhealthy to remain near things that are
Xin the process of blowing up.
XIf a given universe is above a critical density it may chain react.
XScoring is like many popular arcade games--there are multiple waves which
Xget harder and harder as you go along.
XNobody has ever maxed out the scoreboard without cheating.
X.PP
XUnlike many space-war games,
X.I warp
Xis not simply a shooting gallery.
XAlong with phasers and photon torpedoes, you have tractor beams and a cloaking
Xdevice.
XSkill in navigation is important.
XIt helps to be schizophrenic, because you must manage an Enterprise and a Base
Xsimultaneously.
XAnd enemies do not simply shoot back.
XYou can get tailed, absorbed, snuck up upon, hemmed in, rammed, loved to death,
Xreprimanded for destroying civilized life, dragged around, robbed, damaged
Xand eaten.
XAnd if you should happen to get bored by the enemies (a trifle unlikely),
Xyou can always watch the interesting star patterns.
XIn fact, you'll have to, since your tactics will depend upon what kind of
Xuniverse you find yourself in.
X.PP
X.I Warp
Xis played in a double wraparound universe, i.e. the bottom is connected to the
Xtop, and the right is connected to the left.
XYou need a crt with random cursor addressing and at least 24 lines by 80
Xcolumns.
XFor more information about about how to play, simply run
X.I warp
Xand say "y" when it asks if you want to see the instructions.
XThere is also a single-page command summary that you can get while playing
Xby typing a "?".
X.PP
XCommand line options include:
X.TP 5
X.B -b
XPut
X.I warp
Xinto beginner mode.
XMakes the difficulty increase more slowly, but penalizes you for it.
X.TP 5
X.B -d<n>
XSets the initial difficulty to
X.BR n .
X.TP 5
X.B -l
XPlay a low-speed game.
XChanges the basic cycle time from 1 second to 2 seconds.
XThis switch is automatically set at baud rates below 2400.
XYou may want to set it at higher speeds if your terminal cannot keep up
Xwith the output.
X(This should never happen on BSD systems, which have an IOCTL call to
Xdetermine output queue length.)
XBecause this makes the game easier, a separate scoreboard is kept for
Xlow-speed games.
X.TP 5
X.B -m
XTerminal has a meta key which turns on the eighth bit.  Ordinarily the
Xeighth bit is stripped in order to ignore parity.
XMetacharacters will appear to the keymap as prefixed with a ^A, and will
Xsubsequently have the same effect as a control character, unless otherwise
Xmapped.
X.TP 5
X.B -s
XJust prints out the scoreboards and saved games and then exits.
X.TP 5
X.B -v
XPrints out the version number.
X.TP 5
X.B -x
XPlay an experimental game.
XThis causes
X.I warp
Xto ignore any saved game, and disables the ability to save
Xthe current game.
XThus you can play around with something or show
X.I warp
Xto someone without jeopardizing a currently saved game.
X.SH ENVIRONMENT
X.TP 5
X.B WARPMACRO
XIf defined, names a file containing keyboard mappings and macros.
XIf not defined, the value %X/Kbmap.%{TERM} is assumed.
XThe macro file contains lines of the following form:
X.sp
X<keystroke-sequence> <whitespace> <canonical-keystroke-sequence>
X.sp
XYou may use certain % interpolations and ^<letter> control characters.
XFor possible % interpolations see warp.h.
XSequences in the canonical-keystroke-sequence bounded by ^(...^) are
Xsubject to reinterpretation via the keymap.
XThis file has two major uses.
XFirst, you can set up your commands to use any kind of prefix key your terminal
Xmight have, or change the key bindings in any other way you choose.
XSecond, you can define arbitrary macros, such as this:
X.sp
X# define Corbamite maneuver
X=	DDllllll
X.SH AUTHOR
XLarry Wall <lwall@sdcrdcf.UUCP>
X.SH FILES
X~/.fullname, if full names aren't in /etc/passwd
X.SH DIAGNOSTICS
XGenerally self-documenting, as they say.
X.SH BUGS
XAddicting.
XAt the end of a wave, all you have to do to keep going is hit a space.
XYou see the message "Hit space to continue" and automatically hit space.
XAbout 2 seconds later you remember you wanted to go home, but by then
Xit's too late to escape without penalty.
X.PP
XYou can't kill a backgrounded
X.I warp
Xprocess directly, because it is running setuid.
XYou have to use the killer built in to
X.IR warp .
X.PP
XNow that there is a space amoeba, there ought to be tribbles.
XBut it might be too much trouble...
!STUFFY!FUNK!
echo Extracting MANIFEST
sed >MANIFEST <<'!STUFFY!FUNK!' -e 's/X//'
XAfter all the warp kits are run you should have the following files:
X
XFilename		Kit Description
X--------		--- -----------
XConfigure                1  An entertaining little shell script
XEXTERN.h                 6  Set up for external .h files
XINTERN.h                 6  Set up for internal .h files
XMANIFEST                 1  This file
XMakefile.SH              5  Makefile for warp
XREADME                   5  Instructions--please read
Xbang.c                   5  Routines having to do with blast propagation
Xbang.h                   6  Visible declarations for above
Xconfig.H                 4  Sample config.h for if you can't Configure
Xinit.c                   3  Initialization for a wave.
Xinit.h                   2  Visible declarations for above
Xintrp.c                  4  Code to interpret % substitutions
Xintrp.h                  6  Visible declarations for above
Xmakedepend.SH            6  Generates makefile dependencies
Xmakedir.SH               6  Makes multilevel directories
Xmove.c                   3  Object movement and display
Xmove.h                   6  Visible declarations for above
Xndir.c                   5  Directory manipulation routines
Xndir.h                   5  Visible declarations for above
Xobject.c                 6  Object management
Xobject.h                 6  Visible declarations for above
Xpatchlevel.h             4  How patched the kit is
Xplay.c                   5  What to do each second
Xplay.h                   6  Visible declarations for above
Xscore.c                  2  Scoring and saving
Xscore.h                  6  Visible declarations for above
Xsig.c                    5  Signal handling
Xsig.h                    6  Visible declarations for above
Xsm.c                     6  Starmap translator
Xsmp.0                    3  "Straight Grid" scenario
Xsmp.1                    6  "Offset Grid" scenario
Xsmp.2                    6  "Shooting Gallery" scenario
Xsmp.3                    6  "Superfortress" scenario
Xsmp.4                    6  "Blocks" scenario
Xsmp.5                    6  "Microfortress" scenario
Xsmp.6                    6  "Passage" scenario
Xsmp.7                    6  "Wall" scenario
Xterm.c                   2  Terminal handling
Xterm.h                   5  Visible declarations for above
Xthem.c                   5  Smarts for enemies
Xthem.h                   6  Visible declarations for above
Xus.c                     4  Smarts for us
Xus.h                     6  Visible declarations for above
Xutil.c                   1  Utility routines
Xutil.h                   5  Visible declarations for above
Xversion.c                6  Prints version number.
Xversion.h                1  Visible declarations for above
Xwarp.c                   2  Main loop
Xwarp.doc                 4  How to play warp
Xwarp.h                   4  Visible declarations for everyone
Xwarp.man                 5  How to start warp
Xwarp.news                5  Sample startup message
Xweapon.c                 3  Our firepower
Xweapon.h                 6  Visible declarations for above
!STUFFY!FUNK!
echo ""
echo "End of kit 5 (of 7)"
cat /dev/null >kit5isdone
config=true
for iskit in 1 2 3 4 5 6 7; do
    if test -f kit${iskit}isdone; then
	echo "You have run kit ${iskit}."
    else
	echo "You still need to run kit ${iskit}."
	config=false
    fi
done
case $config in
    true)
	echo "You have run all your kits.  Please read README and then type Configure."
	chmod 755 Configure
	;;
esac
: Someone might mail this, so...
exit