games-request@tekred.UUCP (06/10/87)
Submitted by: Larry Wall <lwall%sdcrdcf.UUCP@jove.cam.unisys.com> Comp.sources.games: Volume 1, Issue 47 Archive-name: warp7/Part03 #! /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 3 (of 7). If kit 3 is complete, the line" echo '"'"End of kit 3 (of 7)"'" will echo at the end.' echo "" export PATH || (echo "You didn't use sh, you clunch." ; kill $$) echo Extracting move.c sed >move.c <<'!STUFFY!FUNK!' -e 's/X//' X/* $Header: move.c,v 7.0.1.2 86/10/20 14:37:06 lwall Exp $ */ X X/* $Log: move.c,v $ X * Revision 7.0.1.2 86/10/20 14:37:06 lwall X * Picked some lint. X * X * Revision 7.0.1.1 86/10/16 10:52:09 lwall X * Added Damage. Fixed random bugs. X * X * Revision 7.0 86/10/08 15:12:40 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 "play.h" X#include "score.h" X#include "term.h" X#include "them.h" X#include "us.h" X#include "util.h" X#include "weapon.h" X#include "INTERN.h" X#include "move.h" X Xvoid Xmove_init() X{ X ; X} X Xvoid Xbounce(obj) XReg4 OBJECT *obj; X{ X Reg1 int x; X Reg2 int y; X Reg3 int count=0; X X y = (obj->posy - sgn(obj->vely) + YSIZE00) % YSIZE; X x = (obj->posx - sgn(obj->velx) + XSIZE00) % XSIZE; X while (occupant[y][x]) { X y = (y + rand_mod(3) - 1 + YSIZE00) % YSIZE; X x = (x + rand_mod(3) - 1 + XSIZE00) % XSIZE; X if (++count > 10000) { /* if universe full, get out of it fast */ X unmake_object(obj); X if (ent) unmake_object(ent); X if (base) unmake_object(base); X finish = 1; X return; X } X } X obj->posy = y; X obj->posx = x; X obj->vely = 0; X obj->velx = 0; X occupant[y][x] = obj; X if (numamoebas && obj->image == ' ') X mvaddc(y+1, x*2, amb[y][x]); X else X mvaddc(y+1, x*2, obj->image); X} X Xvoid Xmove_universe() X{ X Reg1 OBJECT *curobj; X Reg2 int x; X Reg3 int y; X Reg4 OBJECT *temp; X OBJECT *thenext; X X for (curobj = movers; curobj != &root; curobj = curobj->next) { X x = curobj->posx; X y = curobj->posy; X if (curobj == occupant[y][x]) { X occupant[y][x] = 0; X } X else if (curobj->type != Torp && curobj->type != Web) { X resetty(); X abort(); X } X } X for (curobj = movers; curobj != &root; curobj = thenext) { X thenext = curobj->next; X if (curobj->vely || curobj->velx) { X y = curobj->posy; X x = curobj->posx; X if (curobj->image != ' ' && X (!(temp=occupant[y][x]) || temp->image==' ') ) { X move(y+1, x*2, numamoebas ? amb[y][x] : ' '); X } X y = (y + curobj->vely + YSIZE00) % YSIZE; X x = (x + curobj->velx + XSIZE00) % XSIZE; X if (!(temp=occupant[y][x]) || temp->type != Star || X curobj->type != Torp || curobj->image == '+' || X curobj->image == 'x') { X curobj->posy = y; X curobj->posx = x; X } X else { X if (curobj->image == '0') { X curobj->vely = rand_mod(3)-1; X curobj->velx = rand_mod(3)-1; X } X else X curobj->vely = curobj->velx = 0; X y = curobj->posy; X x = curobj->posx; X } X } X else { /* not moving */ X y = curobj->posy; X x = curobj->posx; X if (curobj->type == Torp || X curobj->type == Star || X curobj->type == Web) { X curobj->flags |= STATIC; X curobj->next->prev = curobj->prev; X curobj->prev->next = curobj->next; X curobj->prev = movers->prev; X curobj->next = movers; X movers->prev->next = curobj; X movers->prev = curobj; X } X } X if (temp = occupant[y][x]) { /* already occupied? */ X if (!temp->contend) { X if (temp->type == Torp) { X if (temp->image == '+') X blast[y][x] += 1250; X else if (temp->image == 'o' && (base||ent)) X blast[y][x] += 500+super*20; X else if (temp->image == 'O' && (base||ent)) X blast[y][x] += 5000+super*100; X } X } X yblasted[y] |= 1; X xblasted[x] |= 1; X blasted = TRUE; X curobj->contend = temp; X occupant[y][x] = curobj; X switch (curobj->type) { X case Enemy: X if (numamoebas && curobj == nuke && temp->image == '+') X blast[y][x] += 80000; X else if (temp->type == Enemy) X blast[y][x] += 10; X else X goto defblast; X break; X case Crusher: X if (curobj->velx) X blast[y][x] += 100000; X else X goto defblast; X break; X case Torp: X if (curobj->image == '+') X blast[y][x] += (temp==nuke ? 80000 : 1250); X else if (curobj->image == 'o') X blast[y][x] += 500+super*20; X else if (curobj->image == 'O') X blast[y][x] += 5000+super*100; X goto defblast; X case Star: X if (temp == ent) X goto damshield; X goto defblast; X case Enterprise: X if (temp->type == Star) { X damshield: X if (!rand_mod(10)) { X if (!damflag[NOSHIELDS]) X damage++; X if (damflag[NOSHIELDS] < 100) X damflag[NOSHIELDS] += rand_mod(smarts)/5+2; X } X } X goto defblast; X default: X defblast: X blast[y][x] += rand_mod(751)+1; X break; X } X } X else { X occupant[y][x] = curobj; X if (curobj->image != ' ' && X (curobj->velx || curobj->vely || X curobj->type == Torp || curobj->type == Web) ) { X mvaddc(y+1, x*2, curobj->image); X } X if (curobj->type == Crusher && curobj->velx) { X blast[y][x] += 100000; X yblasted[y] |= 1; X xblasted[x] |= 1; X blasted = TRUE; X } X } X } X if (blasted) { X Reg7 int minxblast = -1; X Reg8 int maxxblast = -2; X Reg5 long tmpblast; X X blasted = numamoebas; X for (x=0; x<XSIZE; x++) { X if (xblasted[x]) { X xblasted[x] = 0; X maxxblast = x; X if (minxblast < 0) X minxblast = x; X } X } X for (y=0; y<YSIZE; y++) { X if (yblasted[y]) { X yblasted[y] = 0; X for (x=minxblast; x<=maxxblast; x++) { X tmpblast = blast[y][x]; X if (numamoebas && amb[y][x] == '~') { X if (temp = occupant[y][x]) { X if (temp->image == '&') X tmpblast >>= 1; X else if (temp->type == Web) X tmpblast = 100000; X else X tmpblast += 50 + temp->energy/100; X if (tmpblast > 250 && !rand_mod(5+(inumstars>>4))) X modify_amoeba(y,x,1,'~',5); X } X xblasted[x] = 2; X yblasted[y] = 2; X } X if (tmpblast) { X Reg6 OBJECT *biggie = 0; X X blast[y][x] = 0; X temp = occupant[y][x]; X if (tmpblast < 0) { X if (numamoebas && tmpblast < -1000000 && X amb[y][x] == '~' && temp != nuke) { X amb[y][x] = ' '; X if (!temp) X make_plink(y,x); X ambsize--; X } X tmpblast = 0; X } X if (temp) { X if ((!numamoebas || amb[y][x]==' ') && X tmpblast < 100000) X make_plink(y,x); X for ( ;temp; X temp = curobj->contend,curobj->contend = 0){ X curobj = temp; X switch (curobj->type) { X case Enterprise: { X long tmp = curobj->energy; X X if (ent->energy>500 || apolloflag & 1) X curobj->energy -= tmpblast / X ((apolloflag & 1) X ? 20 X : (5+abs(ent->velx)+abs(ent->vely)) X / ((damflag[NOSHIELDS]>>3)+1)+1); X else X curobj->energy -= tmpblast; X if (rand_mod(1 + tmp - curobj->energy) > 100 X || ent->energy < (entmax>>1)) { X if (debug & 128 || X (damage <= smarts/10 && X !rand_mod(6-smarts/20-massacre) )) { X tmp = rand_mod(MAXDAMAGE); X if (damflag[tmp]) { X if (damflag[tmp] < 60) X damflag[tmp] += rand_mod(60); X } X else { X damflag[tmp] = X rand_mod(smarts+10)+2; X damage++; X } X } X } X break; X } X case Base: X if (base->energy > 1000 || apolloflag & 2) X curobj->energy -= tmpblast / X ((apolloflag & 2)?20:5); X else X curobj->energy -= tmpblast; X break; X case Crusher: X if (tmpblast > 132767) X curobj->energy -= (tmpblast - 100000); X else if (tmpblast >= 100000) { X curobj->energy += (tmpblast - 100000); X if (curobj->energy > 32767) X curobj->energy = 32767; X } X else /* vulnerable while feeding */ X curobj->energy -= tmpblast; X break; X case Enemy: X curobj->energy -= tmpblast*10/enemshields; X break; X default: X curobj->energy -= tmpblast; X break; X } X if (curobj->energy < 0) { /* killed it? */ X switch (curobj->image) { X case 'A': X tmpblast = 100000; X make_blast(y,x,8192L,1); X numapollos = apolloflag = 0; X numstars--; X numenemies--; X curscore += 5000; X deados = 0; X break; X case 'E': case 'e': case 'C': case 'c': X ent = 0; X numents--; X if (base) X status = 2; X else X status = 3; X deados = 0; X break; X case 'B': case 'b': X base = 0; X numbases--; X if (ent) X status = entmode; X else X status = 3; X deados = 0; X break; X case '&': { X int i, xxx, yyy; X X for (i = 0; i < YSIZE; i++) X yblasted[i] &= 1; X for (i = 0; i < XSIZE; i++) X xblasted[i] &= 1; X numamoebas = 0; /* ignore amb[][] now */ X for (yyy = 0; yyy < YSIZE; yyy++) { X for (xxx = 0; xxx < XSIZE; xxx++) { X if (amb[yyy][xxx] == '~' && X !occupant[yyy][xxx]) { X mvaddch(yyy+1,xxx*2,' '); X } X } X } X numenemies--; X curscore += 10000; X if (curobj == enemies) X enemies = curobj->next; X deados = 0; X break; X } X case '<': case '>': { X int i; X X numenemies--; X numcrushes = 0; X curscore += 10000; X if (curobj == movers) X movers = curobj->next; X if (curobj == enemies) X enemies = curobj->next; X deados = 0; X X tmpblast = 100000; X make_blast(y,(x+XSIZE00)%XSIZE,10000L,0); X if (curobj->image == '<') { X for (i=XSIZE00; i<=XSIZE01; i++) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X for (i=XSIZE00; i<=XSIZE02; i++) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X make_blast(y,(x+XSIZE03)%XSIZE, X 10000L,1); X for (i=XSIZE00; i<=XSIZE08; i++) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X } X else { X for (i=XSIZE00; i>=XSIZE99; i--) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X for (i=XSIZE00; i>=XSIZE98; i--) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X make_blast(y,(x+XSIZE97)%XSIZE, X 10000L,1); X for (i=XSIZE00; i>=XSIZE92; i--) X make_blast(y,(x+i)%XSIZE, X 10000L,0); X } X } X break; X case 'K': X numenemies--; X curscore += curobj->mass; X if (curobj == enemies) X enemies = curobj->next; X deados = 0; X break; X case 'T': X numenemies--; X curscore += curobj->mass*3/2; X if (curobj == enemies) X enemies = curobj->next; X deados = 0; X break; X case 'R': case ' ': case 'P': X numenemies--; X if (curobj->flags & PIRATE) X curscore += curobj->mass; X else X curscore += curobj->mass*3; X if (curobj == enemies) X enemies = curobj->next; X deados = 0; X break; X case 'G': X numenemies--; X numgorns--; X tmpblast = 100000; X if (madgorns) X curscore += curobj->mass/2; X else X curscore += curobj->mass*2; X if (curobj == enemies) X enemies = curobj->next; X { X int xxx,yyy; X X for (xxx = -1; xxx<=1; xxx++) X for (yyy = -1; yyy<=1; yyy++) X if (rand_mod(2+massacre)) X fire_torp(curobj, X yyy,xxx); X } X deados = 0; X break; X case '@': X numinhab--; X /* FALL THROUGH */ X case '*': X banging = TRUE; X numstars--; X break; X case '|': case '-': case '/': case '\\': X tmpblast = 100000; X make_blast(y,x,curobj->mass,1); X banging = TRUE; X deados = 0; X break; X case 'x': X curscore += 10; X deados = 0; X break; X case 'X': X curscore += 100; X numxes--; X deados = 0; X break; X case '0': X curscore += 35; X numos--; X deados += 3; X break; X case 'o': X curscore += 100; X numos--; X deados++; X break; X case 'O': X curscore += 200; X numos--; X deados += 2; X break; X case 'M': X deadmudds++; X inumfriends--; X numfriends--; X if (curobj == enemies) X enemies = curobj->next; X break; X case 'Q': case 'W': case 'Y': case 'U': X case 'I': case 'S': case 'D': case 'H': X case 'J': case 'L': case 'Z': case 'V': X case 'F': X numfriends--; X if (curobj == enemies) X enemies = curobj->next; X if (inumfriends < 10) X madfriends += 500; X else X madfriends += 10000/inumfriends; X break; X } X if (tmpblast < 100000) X make_blast(y,x,curobj->mass,1); X unmake_object(curobj); X } X else { /* didn't kill anything */ X if (!biggie) X biggie = curobj; X else { X if (biggie->mass > curobj->mass) X bounce(curobj); X else { X bounce(biggie); X biggie = curobj; X } X } X } X } X if (biggie) { X occupant[y][x] = biggie; X if (numamoebas && biggie->image == ' ') X mvaddch(y+1,x*2, amb[y][x]); X else X mvaddch(y+1,x*2, biggie->image); X } X else { X occupant[y][x] = 0; X mvaddch(y+1, x*2, numamoebas ? amb[y][x] : ' '); X } X } X } X } X } X } X } X do_bangs(); X if (numcrushes && movers->type == Crusher) X movers->vely = 0; X if (curobj = base) { X char ch; X X curobj->velx = 0; X curobj->vely = 0; X curobj->energy += 25*lookaround(curobj->posy,curobj->posx,Star); X if (curobj->energy > basemax) X curobj->energy = basemax; X if (curobj->energy >= 1000) X ch = 'B'; X else X ch = 'b'; X if (ch != curobj->image) { X setimage(curobj, ch); X } X } X if (curobj = ent) { X char ch; X X if (entmode == 0) { X curobj->velx = 0; X curobj->vely = 0; X } X if (base && !cloaking && !curobj->velx && !curobj->vely && X lookfor(curobj->posy,curobj->posx,Base)) { X int tmp; X X#ifdef lint X tmp = 0; X#else X tmp = (int) (base->energy - 1000 < entmax - curobj->energy ? X base->energy - 1000 : entmax - curobj->energy); X#endif X if (tmp < 0) X tmp = 0; X curobj->energy += tmp; X base->energy -= tmp; X tmp = (btorp < 50 - etorp ? X btorp : 50 - etorp); X etorp += tmp; X btorp -= tmp; X if (damage) { X tmp = rand_mod(MAXDAMAGE); X if (damflag[tmp] > 5) { X damflag[tmp] = rand_mod(5)+1; X } X } X } X if (curobj->energy >= 500 && (!damage || !damflag[NOSHIELDS])) X ch = cloaked?'C':'E'; X else X ch = cloaked?'c':'e'; X if (ch != curobj->image) { X setimage(curobj, ch); X } X } X} X Xint Xlookaround(y, x, what) XReg1 int y; XReg2 int x; XReg4 char what; X{ X Reg3 OBJECT *obj; X Reg5 int count=0; X Reg6 int xp; X Reg7 int xm; X X if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what) /* 0, 1 */ X count++; X if ((obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what) /* 0, -1 */ X count++; X if ((obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what) /* -1, 1 */ X count++; X if ((obj=occupant[y][x])&&obj->type == what) /* -1, 0 */ X count++; X if ((obj=occupant[y][xm])&&obj->type == what) /* -1, -1 */ X count++; X if ((obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what) /* 1, 1 */ X count++; X if ((obj=occupant[y][x])&&obj->type == what) /* 1, 0 */ X count++; X if ((obj=occupant[y][xm])&&obj->type == what) /* 1, -1 */ X count++; X return (count); X} X Xint Xlookfor(y, x, what) XReg1 int y; XReg2 int x; XReg4 char what; X{ X Reg3 OBJECT *obj; X Reg5 int xp; X Reg6 int xm; X X if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->type == what ||/* 0, 1 */ X (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->type == what ||/* 0, -1 */ X (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->type == what ||/* -1, 1 */ X (obj=occupant[y][x])&&obj->type == what ||/* -1, 0 */ X (obj=occupant[y][xm])&&obj->type == what ||/* -1,-1 */ X (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->type == what ||/* 1, 1 */ X (obj=occupant[y][x])&&obj->type == what ||/* 1, 0 */ X (obj=occupant[y][xm])&&obj->type == what) /* 1, -1 */ X return(1); X return (0); X} X XOBJECT* Xlookimg(y, x, what) XReg1 int y; XReg2 int x; XReg4 char what; X{ X Reg3 OBJECT *obj; X Reg5 int xp; X Reg6 int xm; X X if ((obj=occupant[y][xp=(x+XSIZE01)%XSIZE])&&obj->image==what ||/* 0, 1 */ X (obj=occupant[y][xm=(x+XSIZE99)%XSIZE])&&obj->image==what ||/* 0, -1 */ X (obj=occupant[y=(y+YSIZE99)%YSIZE][xp])&&obj->image==what ||/* -1, 1 */ X (obj=occupant[y][x])&&obj->image==what ||/* -1, 0 */ X (obj=occupant[y][xm])&&obj->image==what ||/* -1,-1 */ X (obj=occupant[y=(y+2)%YSIZE][xp])&&obj->image==what ||/* 1, 1 */ X (obj=occupant[y][x])&&obj->image==what ||/* 1, 0 */ X (obj=occupant[y][xm])&&obj->image==what) /* 1, -1 */ X return obj; X return Null(OBJECT*); X} !STUFFY!FUNK! echo Extracting weapon.c sed >weapon.c <<'!STUFFY!FUNK!' -e 's/X//' X/* $Header: weapon.c,v 7.0.1.2 86/10/20 14:36:33 lwall Exp $ */ X X/* $Log: weapon.c,v $ X * Revision 7.0.1.2 86/10/20 14:36:33 lwall X * Picked some lint. X * X * Revision 7.0.1.1 86/10/16 10:54:42 lwall X * Added Damage. Fixed random bugs. X * X * Revision 7.0 86/10/08 15:18:08 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 "sig.h" X#include "term.h" X#include "them.h" X#include "us.h" X#include "util.h" X#include "INTERN.h" X#include "weapon.h" X Xvoid Xweapon_init() X{ X ; X} X Xvoid Xfire_torp(from, ydir, xdir) XReg1 OBJECT *from; XReg3 int ydir; XReg4 int xdir; X{ X Reg2 OBJECT *to; X X if (from->type == Enemy || X (from == ent && etorp > 0) || X (from == base && btorp > 0)) { X to = occupant[(from->posy+from->vely+ydir+YSIZE00)%YSIZE] X [(from->posx+from->velx+xdir+XSIZE00)%XSIZE]; X if (from->type != Enemy || !to || to->vely || to->velx) { X if (from->type != Enemy && X (to = isatorp[from==base][ydir+1][xdir+1])) { X to->vely += ydir; X to->velx += xdir; X } X else { X if (from == ent) { X to = make_object(Torp, '+', from->posy,from->posx, X from->vely+ydir,from->velx+xdir, 0L, 1L,&root); X aretorps++; X isatorp[0][ydir+1][xdir+1] = to; X etorp--; X } X else if (from == base) { X to = make_object(Torp, '+', from->posy,from->posx, X from->vely+ydir,from->velx+xdir, 0L, 1L,&root); X aretorps++; X isatorp[1][ydir+1][xdir+1] = to; X btorp--; X } X else if (from->image == 'G') { X numos++; X to = make_object(Torp, 'o', from->posy,from->posx, X from->vely+ydir,from->velx+xdir, 100L, 1L,&root); X if (madgorns) { X possiblescore += 35; X to->image = '0'; X to->mass = 2000; X to->energy = 2000; X } X else if (rand_mod(120)+10 > smarts) X possiblescore += 100; X else { X possiblescore += 200; X to->image = 'O'; X } X } X else { X to = make_object(Torp, 'x', from->posy,from->posx, X from->vely+ydir,from->velx+xdir, 0L, 1L,&root); X if (rand_mod(160)+10 > smarts) X possiblescore += 10; X else { X possiblescore += 100; X to->image = 'X'; X to->mass = 1000+super*20; X numxes++; X } X } X } X } X } X} X Xvoid Xattack(attackee) XReg7 OBJECT *attackee; X{ X Reg1 int dx; X Reg2 int dy; X Reg3 int curx; X Reg4 int cury; X Reg5 int prob; X Reg6 OBJECT *obj; X Reg8 bool torps; X Reg9 bool webnear = FALSE; X Reg10 bool thru_stars; X int nukey; X int nukex; X int nukedist; X X if (attackee) { X if (attackee == nuke) { X if (amb[attackee->posy][attackee->posx] != '~') X return; X nukey = nukex = 0; X nukedist = 100; X } X for (dx= -1; dx<=1 ; dx++) { X for (dy= -1; dy<=1; dy++) { X if (dx||dy) { X cury = attackee->posy; X curx = attackee->posx; X torps = thru_stars = FALSE; X if (massacre || madgorns || !rand_mod(53-super) ) X webnear += rand_mod(2); X else X webnear = FALSE; X for (prob = scandist;prob;prob--) { X cury = (cury + dy + YSIZE00) % YSIZE; X curx = (curx + dx + XSIZE00) % XSIZE; X if (obj = occupant[cury][curx]) { X switch (obj->image) { X case 'P': case 'K': case 'R': case ' ': X pot_shot: X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/40+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X if (rand_mod(51 - sm50) <= prob) { X switch (obj->strategy||thru_stars?0: X rand_mod(ent?4:2)) { X case 1: case 2: X if (-dy + attackee->vely == obj->vely X && -dx + attackee->velx == obj->velx) X fire_torp(obj, X -dy + attackee->vely, X -dx + attackee->velx); X else X fire_torp(obj, X -dy + attackee->vely - obj->vely, X -dx + attackee->velx - obj->velx); X if (obj->image == ' ') X setimage(obj, X obj->flags & PIRATE ? 'P' : 'R'); X break; X case 3: { X int newspeed = X rand_mod(prob<5&&smarts>70?4:3)-1; X X obj->vely = -dy * newspeed; X obj->velx = -dx * newspeed; X if (newspeed >= 0 && X !rand_mod(82-sm80)) { X obj->vely += attackee->vely; X obj->velx += attackee->velx; X } X break; X } X case 0: X if (!torps && obj->energy > 1000) { X fire_phaser(obj, -dy, -dx); X if (smarts > 40 && X (scandist-prob > 5 X || attackee==base) && X (massacre || obj->strategy || X rand_mod(2))) X while (rand_mod(2)) X fire_phaser(obj, -dy, -dx); X if (obj->image == ' ') X setimage(obj, X obj->flags&PIRATE ? 'P':'R'); X } X if (obj->strategy) { X obj->velx = obj->vely = 0; X if (obj->energy < 1000 || X bvely || bvelx) X obj->strategy = 0; X } X else if ((attackee==base || X (cloaking && attackee==ent) X ) && X scandist-prob > 5 && X !(rand_mod( X ent?antibase*2:antibase)) ) X obj->strategy = 1; X break; X } X } X goto bombout; X case 'G': X if (thru_stars && obj->strategy < 7) X goto bombout; X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/40+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X goto bombout; X } X if (obj->strategy) { X if (madgorns || !rand_mod(4)) { X obj->vely = attackee->vely; X obj->velx = attackee->velx; X } X obj->strategy += (!torps && deados > 10); X if (obj->strategy > 4) X madgorns = TRUE; X if (!torps && obj->strategy > 5) { X do { X fire_phaser(obj, -dy, -dx); X } while (rand_mod(2)); X } X } X else if (numgorns >= numenemies-1 && X deados > 15+numgorns*5) X obj->strategy = 1; X if (madgorns || rand_mod(51 - sm50) <= prob) { X if (-dy + attackee->vely == obj->vely X && -dx + attackee->velx == obj->velx) X fire_torp(obj, X -dy + attackee->vely, X -dx + attackee->velx); X else X fire_torp(obj, X -dy + attackee->vely - obj->vely, X -dx + attackee->velx - obj->velx); X } X goto bombout; X case 'T': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/40+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X if (thru_stars) X goto bombout; X if (webnear && scandist-prob > 5) { X if (massacre || rand_mod(50) < super) { X if (!torps && obj->energy > 1000) { X fire_phaser(obj, -dy, -dx); X while (!rand_mod(57-sm55)) X fire_phaser(obj, -dy, -dx); X } X } X } X goto bombout; X case 'C': case 'c': X if (thru_stars) X goto bombout; X break; X case 'Q': case 'W': case 'Y': case 'U': X case 'I': case 'S': case 'D': case 'H': case 'J': X case 'L': case 'Z': case 'V': case 'M': case 'F': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/40+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X if (rand_mod(2)) X goto pot_shot; X } X if (madfriends > 1000) { X madfriends -= 200; X goto pot_shot; X } X /* FALL THROUGH */ X case '+': X if (attackee == nuke) { X if (smarts > 70) { X if ( X (obj->posx + obj->velx + XSIZE00)%XSIZE X == attackee->posx && X (obj->posy + obj->vely + YSIZE00)%YSIZE X == attackee->posy ) { X Tract(nuke,dy,dx,-1); X } X else X while (!rand_mod(82-sm80)) X Tract(nuke,dy,dx,-1); X } X else if (smarts > 60 || X rand_mod(2+scandist-prob) < X rand_mod(smarts/20+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X torps = FALSE; X thru_stars = FALSE; X break; X case '|': case '-': case '/': case '\\': X if (thru_stars) X goto bombout; X webnear = (scandist-prob < 3); X torps = FALSE; X break; X case 'x': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/20+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X if (thru_stars) X goto bombout; X torps = TRUE; X break; X case 'o': case 'O': case '0': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/20+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X if (thru_stars) X goto bombout; X torps = TRUE; X if (rand_mod(99+3*scandist) < smarts+3*prob) { X obj->vely = -dy + attackee->vely; X obj->velx = -dx + attackee->velx; X if (obj->flags & STATIC) {/* not a mover? */ X obj->flags &= ~STATIC; X obj->prev->next = obj->next; X obj->next->prev = obj->prev; X root.prev->next = obj; X obj->prev = root.prev; X root.prev = obj; X obj->next = &root; X } X } X if (obj->image != '0') X break; X /* DROP THROUGH! */ X case 'X': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/20+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X torps = TRUE; X if (thru_stars) X goto bombout; X if (prob == scandist) { X int y, x; X X blast[y=(obj->posy+obj->vely+YSIZE00)%YSIZE] X [x=(obj->posx+obj->velx+XSIZE00)%XSIZE] X += (obj->image == '0' ? 2000 : 200); X yblasted[y] |= 1; X xblasted[x] |= 1; X blasted = TRUE; X } X break; X case 'A': X if (attackee != nuke) { X if (scandist-prob>1 && !rand_mod(51-super)) X Tract(obj,-dy,-dx,1); X } X /* FALL THROUGH */ X case '*': case '@': X if (attackee == nuke) { X if (amb[cury][curx] != '~') { X if (scandist-prob < nukedist) { X nukedist = scandist-prob; X nukey = dy; /* nearest food in */ X nukex = dx; /* this direction */ X } X if (smarts > 55 && scandist-prob > 8) { X if (rand_mod(30+scandist-prob) < X rand_mod(smarts/20+1)) X Tract(nuke,dy,dx,1); X } X } X else if (obj->vely || obj->velx) { X Tract(nuke,dy,dx,1); /* for looks */ X obj->vely = obj->velx = 0; X } X } X if (!thru_stars) X if (rand_mod(97-sm95)) X goto bombout; X else X thru_stars = TRUE; X break; X case '<': case '>': X if (attackee == nuke) { X if ((!dy && scandist-prob < 8) || X rand_mod(2+scandist-prob) < X rand_mod(smarts/20+1) ) { X nuke->mass += 10000; X Tract(nuke,dy,dx,-1); X nuke->mass -= 10000; X } X } X goto bombout; X case 'E': case 'B': X if (attackee == nuke) { X if (rand_mod(2+scandist-prob) < X rand_mod(smarts/40+1)) X Tract(nuke,dy,dx,rand_mod(3)?1:-1); X } X goto bombout; X default: X goto bombout; X } X } X else { X if (thru_stars) X goto bombout; X } X } Xbombout: ; /* end of loop */ X } X } X } X if (attackee == nuke && nukedist < 100) {/* aim amoeba at nearest */ X if (nukey < 0) /* free star */ X nukey = 2; X if (nukex < 0) X nukex = 2; X nuke->strategy = nukey + (nukex << 2); X } X } X} X Xvoid Xfire_phaser(obj, dy, dx) XReg7 OBJECT *obj; XReg5 int dy; XReg6 int dx; X{ X Reg1 int y; X Reg2 int x; X Reg3 int skipping; X Reg4 int size=5000; X int decr = 50, oldy, oldx; X static char curchar[] = "@* "; X X if (obj == ent) X decr = 100; X else if (obj == base) { X decr = 1000; X size = 200; X } X if (!dy) X curchar[2] = '-'; X else if (!dx) X curchar[2] = '!'; X else if (dy == dx) X curchar[2] = '\\'; X else X curchar[2] = '/'; X if (obj->energy >= decr) { X obj->energy -= decr; X for ( X /* initialize */ X skipping = (obj != base), X y = (obj->posy+(obj==base?dy*2:dy)+YSIZE00)%YSIZE, X x = (obj->posx+(obj==base?dx*2:dx)+XSIZE00)%XSIZE; X /* while */ X size && (!occupant[y][x]||(skipping && occupant[y][x]->type==Star)); X /* at end of loop */ X y = (y+dy+YSIZE00) % YSIZE, X x = (x+dx+XSIZE00) % XSIZE, X size = size * 3 / 4 ) { X move(y+1,x*2,0); X beg_qwrite(); X if (obj == base || obj->image == 'T') { X *filler = '@'; X qwrite(); X *filler = '#'; X qwrite(); X *filler = '~'; X qwrite(); X *filler = '%'; X qwrite(); X *filler = ':'; X qwrite(); X *filler = '@'; X } X else { X *filler = size >= 500 ? X *curchar : (size >= 50 ? X curchar[1] : X curchar[2]); X } X qwrite(); X if (occupant[y][x]) X qaddc(occupant[y][x]->image); X else { X if (numamoebas) X qaddc(amb[y][x]); X else X qaddspace(); X if (skipping) X skipping = 0; X } X end_qwrite(); X } X if (size) { X char img; X X assert(occupant[y][x]); X img = occupant[y][x]->image; X if (occupant[y][x]->type == Crusher) { X if (dy) X return; X if (dx==(img == '<' ? 1 : -1) ) { X occupant[y][x]->image = X (occupant[y][x]->velx *= -1) < 0 ? '>' : '<'; X return; X } X } X else if (occupant[y][x]->flags & FRIENDLY) X madfriends += 200; X if (numamoebas && amb[y][x] == '~' && smarts % 3 && X (smarts > 70 || rand_mod(smarts) > rand_mod(20)) ) { X if (size > 10000) X modify_amoeba(y,x,1,'~',10); X else if (size > 1000) X modify_amoeba(y,x,1,'~',7); X else if (size > 50) X modify_amoeba(y,x,1,'~',5); X else X modify_amoeba(y,x,1,'~',2); X if (occupant[y][x] == nuke) { X nuke->strategy = rand_mod(30); X nuke->flags |= COUNTDOWN; X } X return; X } X else { X move(y+1,x*2,0); X beg_qwrite(); X if (img == ' ') { X *filler = occupant[y][x]->flags & PIRATE ? 'P' : 'R'; X occupant[y][x]->image = *filler; X occupant[y][x]->strategy = 0; X qwrite(); X qwrite(); X } X else if (img == 'C' || img == 'c') { X cloaked = 0; X img += 2; X occupant[y][x]->image = img; X *filler = img; X qwrite(); X qwrite(); X } X else if (img == 'K' && size > 50) X occupant[y][x]->strategy = 0; X *filler = '@'; X qwrite(); X *filler = '#'; X qwrite(); X *filler = '@'; X qwrite(); X *filler = '#'; X qwrite(); X *filler = '@'; X qwrite(); X qaddc(img); X end_qwrite(); X oldy = y; X oldx = x; X y = (occupant[oldy][oldx]->posy + occupant[oldy][oldx]->vely + X YSIZE00) % YSIZE; X x = (occupant[oldy][oldx]->posx + occupant[oldy][oldx]->velx + X XSIZE00) % XSIZE; X if (occupant[y][x] && occupant[y][x]->type == Star) { X y = occupant[oldy][oldx]->posy; X x = occupant[oldy][oldx]->posx; X } X if (obj==base) X blast[y][x] += size>50 ? 15000 : (size>15 ? 1500 : 150); X else if (obj==ent) X blast[y][x] += size*4; X else if (obj->image=='T') X blast[y][x] += 15000; X else X blast[y][x] += size*smarts/25; X yblasted[y] |= 1; X xblasted[x] |= 1; X blasted = TRUE; X } X } X } X} X Xint Xtract(obj, dy, dx, to_or_fro) XReg7 OBJECT *obj; XReg4 int dy; XReg5 int dx; Xint to_or_fro; X{ X Reg1 int y; X Reg2 int x; X Reg3 int size=10; X static char ch; X Reg6 OBJECT *tractee; X X if (!dy) X ch = '|'; X else if (!dx) X ch = '-'; X else if (dy == dx) X ch = '/'; X else X ch = '\\'; X { X for ( X y = (obj->posy+dy+YSIZE00)%YSIZE, X x = (obj->posx+dx+XSIZE00)%XSIZE; X size && (!occupant[y][x]); X y = (y+dy+YSIZE00) % YSIZE, x = (x+dx+XSIZE00) % XSIZE, size--) { X move(y+1,x*2,0); X beg_qwrite(); X *filler = ch; X qwrite(); X qwrite(); X if (numamoebas) X qaddch(amb[y][x]); X else X qaddspace(); X end_qwrite(); X } X tractee = occupant[y][x]; X if (size) { X assert(tractee); X if (numamoebas && obj != nuke && amb[y][x] == '~') { X if (to_or_fro > 0) X modify_amoeba(y,x,2,'~',size); X else X modify_amoeba(y,x,1,' ',size); X } X if (tractee->type != Web && X (tractee->mass < obj->mass * 5 || X (tractee->type == Crusher && !dx) ) ) { X if (tractee == ent) { X evely -= dy * to_or_fro; X evelx -= dx * to_or_fro; X } X else if (tractee == base) { X bvely -= dy * to_or_fro; X bvelx -= dx * to_or_fro; X } X else { X tractee->vely -= dy * to_or_fro; X tractee->velx -= dx * to_or_fro; X } X if (tractee->type == Torp || X tractee->type == Star) { X if (tractee->flags & STATIC) { /* not a mover? */ X tractee->flags &= ~STATIC; X tractee->prev->next = tractee->next; X tractee->next->prev = tractee->prev; X root.prev->next = tractee; X tractee->prev = root.prev; X root.prev = tractee; X tractee->next = &root; X } X } X } X else if (tractee->type == Crusher && !dy && X dx==(tractee->image == '<' ? 1 : -1) ) { X setimage(tractee, (tractee->velx *= -1) < 0 ? '>' : '<'); X } X if (tractee->mass * 5 > obj->mass) X return(1); X } X } X return(0); X} !STUFFY!FUNK! echo Extracting init.c sed >init.c <<'!STUFFY!FUNK!' -e 's/X//' X/* $Header: init.c,v 7.0.1.4 86/12/12 16:58:03 lwall Exp $ */ X X/* $Log: init.c,v $ X * Revision 7.0.1.4 86/12/12 16:58:03 lwall X * Baseline for net release. X * X * Revision 7.0.1.3 86/10/20 14:35:31 lwall X * Picked some lint. X * X * Revision 7.0.1.2 86/10/17 15:53:30 lwall X * Added random walk star fields. X * X * Revision 7.0.1.1 86/10/16 10:51:19 lwall X * Added Damage. Fixed random bugs. X * X * Revision 7.0 86/10/08 15:12:10 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 "play.h" X#include "score.h" X#include "term.h" X#include "them.h" X#include "us.h" X#include "util.h" X#include "weapon.h" X#include "INTERN.h" X#include "init.h" X Xvoid Xinitialize() X{ X Reg1 int i; X Reg2 int x; X Reg3 int y; X Reg4 int dist; X Reg5 int ydist; X Reg6 int xdist; X long e; X int yoff, xoff, ypred, xpred; X Reg7 OBJECT *obj; X char ch; X FILE *mapfp = NULL; X bool tmptholspec; X int inhabjackpot; X long inhenergy; X int walksplit = 200; X static char *distname[] = X {" #"," -"," \\"," /", X " |"," *"," `"," '"}; X X cloaking = madgorns = FALSE; X deados = madfriends = 0; X curscore = possiblescore = 0L; X yamblast = xamblast = ambsize = 0; X if (smarts > 90) X massacre = TRUE; X scandist = (massacre?20:15); X antibase = (smarts>60?1:(smarts>40?2:(smarts>25?4:100))); X sm35 = (smarts>35?35:smarts); X sm45 = (smarts>45?45:smarts); X sm50 = (smarts>50?50:smarts); X sm55 = (smarts>55?55:smarts); X sm80 = (smarts>80?80:smarts); X sm95 = (smarts>95?95:smarts); X super = (smarts>50?smarts-50:0); X enemshields = 10 + super/2; /* (scaled by 10) 1 @ 50 .. 3 @ 90 */ X if (smarts>90) X enemshields += (smarts-90)*10; /* lay it on thick: ~13 @ 99 */ X entmax = (smarts>=75?5000:(smarts>=50?4000:(smarts>=40?3000:2000))); X basemax = (smarts>=75?20000:(smarts>=50?15000:(smarts>=40?12500:10000))); X X clear(); X while (root.next != &root) { X root.next = root.next->next; X free_object(root.next->prev); X } X root.prev = &root; X enemies = movers = NULL; X numos = numxes = 0; X#if defined(vax) && XYSIZEx4 == 3680 X asm("movc5 $0,_occupant,$0,$3680,_occupant"); X asm("movc5 $0,_blast,$0,$3680,_blast"); /* 3680 = XYSIZEx4 */ X asm("movc5 $0,_amb,$32,$920,_amb"); X#else X for (y=0;y<YSIZE;y++) X for (x=0;x<XSIZE;x++) { X occupant[y][x] = 0; X blast[y][x] = 0; X amb[y][x] = ' '; X } X#endif X for (y=0; y<YSIZE; y++) X yblasted[y] = 0; X for (x=0; x<XSIZE; x++) X xblasted[x] = 0; X blasted = FALSE; X if (!starspec) X if (smarts < 15) X inumstars = 50 + rand_mod(50); X else if (smarts < 50 || smarts > 85) X inumstars = exdis(800) + rand_mod(100) + 1; X else /* too few stars makes 50..85 too hard */ X inumstars = exdis(700) + rand_mod(150-super*2) + 50+super*2; X tmptholspec = (smarts > 15 && inumstars < 450 && ! rand_mod(90-sm80)); X if (!klingspec) { X inumenemies = rand_mod((smarts+1)/2) + 1; X if (massacre || tmptholspec) X inumenemies += 10; X } X if (!friendspec) X inumfriends = rand_mod(smarts/8+1); X if (!piratespec) X inumpirates = rand_mod(inumfriends/2+1); X if (inumfriends+inumenemies+inumstars > YSIZE*XSIZE-20) X inumstars = YSIZE*XSIZE-20 - inumenemies - inumfriends; X if (inumstars < 0) { X inumfriends += inumstars; X inumstars = 0; X } X if (inumfriends < 0) { X inumenemies += inumfriends; X inumfriends = 0; X } X if (inumenemies < 0) X inumenemies = 0; X numstars = inumstars; X inuminhab = numinhab = 0; X inumroms = inumthols = inumgorns = 0; X numapollos = apolspec || massacre ? 1 : X ((!numstars || rand_mod(2) || smarts < 10) ? 0 : 1); X inumapollos = apolloflag = 0; X realapollo = NULL; X inumcrushes = numcrushes = X crushspec||massacre?1:(rand_mod(2000) < inumstars); X inumenemies += inumcrushes; X inumamoebas = numamoebas = (amoebaspec ? 1 : X !rand_mod(inumcrushes?3-massacre:8) ); /* < and & are fun together */ X inumenemies += inumamoebas; X if (!rand_mod(40)) { X inhabjackpot = 32767; X inumfriends += rand_mod(10); X inumpirates += rand_mod(10); X } X else X inhabjackpot = inumpirates; X inhenergy = 30000-super*150; X if (!rand_mod(10)) X inhenergy = 50000; X if (!rand_mod(4)) X inhenergy += rand_mod(3500+super*150); X numfriends = inumfriends; X numpirates = inumpirates; X numenemies = inumenemies; X deadmudds = 0; X X /* do stars */ X Xstars_again: X if (prespec) X dist = 4; X else if (numstars > 750) X dist = 0; X else X dist = rand_mod(starspec||smarts<=5?3:5); X if (debugging) { X real_y = real_x = -100; X printf("\r\n"); X } X switch (dist) { X case 0: /* uniform random */ X ydist = xdist = 0; X if (inumstars < 700 && !rand_mod(3-(inumstars<50))) { X ydist = xdist = 6; /* well, maybe not so random */ X y = rand_mod(YSIZE); X x = rand_mod(XSIZE); X if (rand_mod(2)) X walksplit = inumstars/(exdis(40)+1); X } X if (debugging) X printf(" R\r\n"); X break; X case 1: case 2: /* clumped, maybe skewed, maybe superposed */ X ydist = rand_mod(4); X xdist = rand_mod(2); X if (debugging) X printf("%s\r\n",distname[ydist+4*xdist]); X yoff = rand_mod(YSIZE); X xoff = rand_mod(XSIZE); X if (dist == 2) X dist = numstars/2 + exdis(numstars/2) - exdis(numstars/2); X else X dist = 0; X break; X case 3: case 4: /* predefined or residual */ X scenario_again: X if (debugging) X printf(" P\r\n"); X dist = 0; X Sprintf(spbuf,"smap.%d", X (prescene>=0?prescene:rand_mod(MAPS)) ); X if ((mapfp = fopen(spbuf,"r")) != NULL && X fgets(spbuf,10,mapfp) != NULL ) { X inumstars = numstars = atoi(spbuf); X if (inumenemies+inumstars > YSIZE*XSIZE-20) X inumstars = numstars = YSIZE*XSIZE-20 - inumenemies; X ydist = rand_mod(2) + 4; /* flip y axis? */ X xdist = rand_mod(2) + 4; /* flip x axis? */ X yoff = rand_mod(YSIZE); /* how much to shift y */ X xoff = rand_mod(XSIZE); /* how much to shift x */ X } X else { X prespec = FALSE; X prescene = -1; X if (rand_mod(2)) X goto scenario_again; X goto stars_again; X } X break; X } X for (i = 1; i <= numstars; i++) { X if (dist && i == dist) { /* flip to another skewing? */ X ydist = rand_mod(4); X xdist = rand_mod(2); X if (!rand_mod(4)) { X ydist = xdist = 6; X if (debugging) X printf("&\r\n"); X } X else if (debugging) X printf("%s\r\n",distname[ydist+4*xdist]); X yoff = rand_mod(YSIZE); X xoff = rand_mod(XSIZE); X dist = 0; X } X do { /* until an open spot found */ X switch (xdist) { X case 0: X x = rand_mod(XSIZE); /* pick from 0..39, uniform */ X break; X case 1: case 2: case 3: X#ifndef lint X x = (int)((((double)(myrand()-HALFRAND)) * X ((double)(myrand()-HALFRAND))/RANDRAND) X * 20.0) + xoff; /* pick from -20..20, clumped */ X#endif X break; X case 4: X if (fscanf(mapfp,"%d %d\n",&ypred,&xpred) == EOF) X ydist = xdist = 0; X x = xpred + xoff; X break; X case 5: X if (fscanf(mapfp,"%d %d\n",&ypred,&xpred) == EOF) X ydist = xdist = 0; X x = -xpred + xoff; X break; X case 6: X x += rand_mod(3) - 1; X break; X } X switch (ydist) { X case 0: X y = rand_mod(YSIZE); X break; X case 1: X#ifndef lint X y = (int)((((double)(myrand()-HALFRAND)) * X ((double)(myrand()-HALFRAND))/RANDRAND) X * 12.0) + yoff; /* pick from -12..12, clumped */ X#endif X break; X case 2: X#ifndef lint X y = (int)((((double)(myrand()-HALFRAND)) * X ((double)(myrand()-HALFRAND))/RANDRAND) X * 12.0) + yoff + x*YSIZE/XSIZE; X /* clumped & skewed */ X#endif X break; X case 3: X#ifndef lint X y = (int)((((double)(myrand()-HALFRAND)) * X ((double)(myrand()-HALFRAND))/RANDRAND) X * 12.0) + yoff - x*YSIZE/XSIZE; X /* clumped & skewed */ X#endif X break; X case 4: X y = ypred + yoff; X break; X case 5: X y = -ypred + yoff; X break; X case 6: X y += rand_mod(3) - 1; X#ifdef lint X walksplit = walksplit; X#endif X if (!rand_mod(walksplit)) { X y = rand_mod(YSIZE); X x = rand_mod(XSIZE); X } X break; X } X while (x<0) x += XSIZE00; X while (y<0) y += YSIZE00; X x %= XSIZE; X y %= YSIZE; X } while (occupant[y][x]); X e = rand_mod(32768); X if (--inhabjackpot > 0 || e >= inhenergy) { X ch = '@'; X if (inhabjackpot && e < 10000) X e += 10000; X inuminhab = ++numinhab; X } X else { X ch = '*'; X } X obj = make_object(Star,ch,y,x,0,0,e+rand_mod(super*100+1),e/4,&root); X obj->flags |= STATIC; X } X if (inumstars > 30 && inhabjackpot <= 0 && X !rand_mod(3 - (inumstars > 400) - (inhenergy > 32768)) ) { X int initx; X int inity; X X x = initx = obj->posx; X y = inity = obj->posy; X while (rand_mod(2) && inuminhab < inumstars/2) { X for (i=rand_mod(smarts)*2+20; i; i--) { X if ((obj = occupant[y][x]) && obj->image == '*') { X setimage(obj,'@'); X if (obj->energy < 10000) X obj->energy += 20000; /* the benefits of civilization */ X inuminhab = ++numinhab; X } X if (i&15) { X y = (y + rand_mod(3) + YSIZE99) % YSIZE; X x = (x + rand_mod(3) + XSIZE99) % XSIZE; X } X else { /* don't wander too far */ X y = inity; X x = initx; X } X } X x = initx = rand_mod(XSIZE); X y = inity = rand_mod(YSIZE); X } X } X if (mapfp != NULL) X Fclose(mapfp); X if (numcrushes) { X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x]); X movers = make_object(Crusher,'<',y,x,0,1,32767L,32768L,&root); X possiblescore += 10000; X } X ient = (numents != 0); X if (ient) { X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x]); X e = entmax; X ent = make_object(Enterprise,'E',y,x,0,0,e,e/2,&root); X if (!movers) X movers = ent; X } X ibase = (numbases != 0); X if (ibase) { X e = 52-super; X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x] || lookaround(y,x,Star) * 7 < e--); X e = basemax; X base = make_object(Base, 'B',y,x,0,0,e,e/4,&root); X if (!movers) X movers = base; X } X if (numamoebas) { X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x]); X nuke = make_object(Enemy,'&',y,x,0,0,32767L, X (long)entmax+entmax+rand_mod(entmax),&root); X possiblescore += 10000; X amb[y][x] = '~'; X if (rand_mod(2)) X modify_amoeba(y,x,2,'~',(int)rand_mod(smarts<<1));/* just make blob */ X else { X for (i=smarts/10+1; i; i--) { X nuke->strategy = rand_mod(256); /* random direction */ X modify_amoeba(y,x,2,'~',(int)rand_mod(5)); X modify_amoeba(y,x,2,'~',(int)rand_mod(5)); X modify_amoeba(y,x,2,'~',(int)rand_mod(5)); X modify_amoeba(y,x,2,'~',(int)rand_mod(5)); /* extend pseudopod */ X } X } X if (!enemies) X enemies = nuke; X if (!movers) X movers = nuke; X } X if (rand_mod(27-sm50/2) && !romspec && !gornspec) X dist = 27-sm50/2; X else X dist = rand_mod(4) + 1; X for (i = 1+inumcrushes+inumamoebas; i <= numenemies; i++) { X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x]); X if (rand_mod(dist)) { X if (!tholspec && !tmptholspec && rand_mod((inumstars*3)/sm50+2)) X ch = 'K'; X else { X ch = 'T'; X inumthols++; X } X } X else { X if (romspec == gornspec) X e = 50; X else if (gornspec) X e = 10; X else X e = 90; X if (rand_mod(100) < e) { X ch = 'R'; X inumroms++; X } X else { X ch = 'G'; X inumgorns++; X } X } X if (possiblescore > ENTBOUNDARY - 10000) X e = (ENTBOUNDARY - possiblescore) / 5; X else X e = 250 + (sm50-1) * 30 * 20 / numenemies+1; X#ifndef lint X e = exdis((int)e) + e - exdis((int)e); X obj = make_object(Enemy,ch,y,x,0,0, X e + rand_mod(super*200+2) + 10000*massacre,e/4,&root); X#endif X e /= 4; X switch (ch) { X case 'K': X possiblescore += e; X break; X case 'T': X possiblescore += e*3/2; X break; X case 'G': X possiblescore += e*2; X break; X case 'R': X possiblescore += e*3; X obj->flags |= CLOAKS; X break; X } X if (!enemies) X enemies = obj; X if (!movers) X movers = obj; X } X numgorns = inumgorns; X for (i=0; i<numfriends; i++) { X do { X x = rand_mod(XSIZE); X y = rand_mod(YSIZE); X } while (occupant[y][x]); X e = 250 + (sm50-1) * 30 * 20 / numenemies+1; X#ifndef lint X e = exdis((int)e) + e - exdis((int)e); X#endif X { X static char let[] = "QWYUISDHJLZVMFFFFFFFFF"; X X dist = rand_mod(20); X ch = let[dist]; X } /* grr, venix doesn't like indexing into string */ X obj = make_object(Enemy,ch,y,x,0,0, X e + rand_mod(super*200+2),e/4,&root); X if (numpirates-- > 0) { X obj->flags |= PIRATE; X if (smarts >= 20 && !rand_mod(10-smarts/10)) X obj->flags |= CLOAKS; X } X obj->flags |= FRIENDLY; X if (!enemies) X enemies = obj; X if (!movers) X movers = obj; X } X if (!movers) X movers = &root; X if (!enemies) X enemies = &root; X if (ent) X mvaddch(ent->posy+1, ent->posx*2, ent->image); X if (base) X mvaddch(base->posy+1, base->posx*2, base->image); X sleep(2); X { X Reg7 OBJECT *curobj; X X for (curobj = root.next; curobj != &root; curobj = curobj->next) { X mvaddch(curobj->posy+1, curobj->posx*2, curobj->image); X } X } X X for (i=0;i<2;i++) for (y=0;y<3;y++) for (x=0;x<3;x++) X isatorp[i][y][x]=0; X X whenok = 0; X timer = 0; X finish = 0; X bombed_out = FALSE; X if (ent) X entmode = status = 0; X else X if (base) X status = 2; X else X status = 3; X X Sprintf(spbuf, X "%-4s E: %4d %2d B: %5d %3d Enemies: %-3d Stars: %-3d Stardate%5d.%1d %9ld", X " ", 0, 0, 0, 0, 0, 0, smarts * 100, 0, 0L); X mvaddstr(0,0,spbuf); X oldeenergy = oldbenergy = oldcurscore = X oldstatus = oldetorp = oldbtorp = oldstrs = oldenemies = -1; X /* force everything to fill in */ X damage = olddamage = 0; X for (i=0; i<MAXDAMAGE; i++) X damflag[i] = 0; X btorp = 500; X etorp = 50; X} !STUFFY!FUNK! echo "" echo "End of kit 3 (of 7)" cat /dev/null >kit3isdone 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