From decwrl!shelby!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!zephyr!tektronix!tekgen!tekred!saab!billr Thu Aug 3 07:43:26 PDT 1989 Article 659 of comp.sources.games: Path: decwrl!shelby!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!ginosko!uunet!zephyr!tektronix!tekgen!tekred!saab!billr From: billr@saab.CNA.TEK.COM (Bill Randle) Newsgroups: comp.sources.games Subject: v07i049: GB2 - Galactic Bloodshed, an empire-like war game [Ver. 1.0], Part06/08 Message-ID: <4288@tekred.CNA.TEK.COM> Date: 19 Jul 89 14:41:12 GMT Sender: nobody@tekred.CNA.TEK.COM Lines: 2106 Approved: billr@saab.CNA.TEK.COM Submitted-by: VANCLEEF@mps.ohio-state.edu Posting-number: Volume 7, Issue 49 Archive-name: GB2/Part06 #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Docs/map.doc' <<'END_OF_FILE' XMAP Galactic Bloodshed MAP X X XNAME X [0] map -- Cartesian coordinate map of planet's surface X XSYNOPSIS X map [path] X XDESCRIPTION X The map command gives a sector map of the planet in [path]. If [path] Xis not a planet, map will instead run orbit (see orbit) with lastx,lasty Xboth equal to 0.0 . A player cannot map a planet that has not yet been Xexplored. X X X These are the different types of terrain: X X '*' -- Unexplored wilderness or undeveloped land X '^' -- Mountainous area (more resources, less fertility) X '.' -- Area containing water X '#' -- Area covered with ice X '~' -- Gas (such as might be found on a gas giant planet) X '%' -- Wasteland (uninhabitable) X ' ' -- (Under certain circumstances the sector may be blank) X 'o' -- A steel (or whatever) plated sector, much like the planet X Trantor (from Asimov's _Foundation_) X X X In addition are the designations that map gives the player: X X 'x' -- Area owned by the player X '?' -- Area owned by another player X 'pscbdfgetSDM%#+mACV^ EYBG[' -- a ship of that type is landed on the sector X 'o' -- Area that has been developed to 100% efficiency (steel plated) X X X X--------------- THE PLANETS ----------------- X X There are four basic types of planets. X XEarth-type X X 00000000001111111111222222222233333333 X 01234567890123456789012345678901234567 X 1 ###################################### X 2 ############..*...#***##....#####*#.## X 3 ..#*^*#*.....*.*^^^****#*******#**.*.. X 4 ..*^**.*.......*****.*************.*.. X 5 ..*..*.......**....*..**^^^^******.*.. X 6 ......**......*********..***.***^**.*. X 7 .....^***.....******^**...*....**^^... X 8 .....^**........***^*........*...*..*. X 9 ......^*.........**^*..........**^*... X10 #..#####...####...##....####...##.*##. X11 ###################################### X Sample Earth- type planet X X Continents are generated randomly by the game, and approximate real growth Xof islands by geologic processes. On the average, sectors closer to water Xhave greater fertility than sectors farther away, which have greater Xresource deposits. On the north and south poles of the planet lies ice, Xprime real estate for certain races. X X XGas Giant Type X X This type of planet is mostly a large ball of gas. XThey do not have many resources but they are useful; for instance any ship Xorbiting a gas giant can gain fuel by 'skimming' it's surface of hydrogen X(provided its race has developed hydrogen fusion for fuel.) X X 000000000011111111112222222222333333333344444444444 X 012345678901234567890123456789012345678901234567890 X 1 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.~~~~~ X 2 ~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ X 3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~........~~~~~~~~~~~~ X 4 ................................................... X 5 ~~~~~~~~~~~~~~~~~~~~~~~~~.................~~~~~~~~~ X 6 ~~~~~~.~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ X 7 ~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~.~~~~~~~~ X 8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ X 9 ~~~~~~~~~~~~~~~~~~...............~~~~~~~~~~~~~~~~~~ X10 ................................................... X11 ~~~~~~~~~~~~~~~~~~~~~~~~~~...............~~~~~~~~~~ X12 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~~~~.~~~~~ X Sample gasgiant planet X X Notice the narrow bands streaked across the surface; this represents Xbands of weather across the face of the planet. X X XAirless or Asteroidal Type X X These are planets too small to hold an atmosphere, or have had it Xstripped off by natural or artificial disaster. They consist of land Xand/or mountainous sectors, with high resource deposits and comparatively Xlow fertility. Both types contain large craters in them from Xmeteorite impacts, while asteroidal bodies often appear in unusual shapes X(i.e. not exactly square). If the temperature is sufficiently low, ice Xmay cover the surface. This is an 'iceball' type planet. X X 00000000001111111111222 000000 X 01234567890123456789012 012345 X 1 ^^^^^*^^^^^^^*^^^^^^^^^ 1 *^^^*^ X 2 ^^^*^^^^^^^^***^^*^^^^^ 2 ^^^*^^ X 3 *^^^^*****^^^*^^^^^^^** 3 ^^^^*^ X 4 **^^***^***^^^*^^^*^**^ 4 *^^*^^ X 5 *^^*^******^^^^^^^^^^** 5 *^^^^^ X 6 *^^^^^****^^*^^^^^*^^^* 6 ^*^*^* X 7 ^^*^^^^^^^^^^^^^^^^^^^^ X Sample Airless type Sample Asteroid type X X XSEE ALSO X orbit, cs, scope X X END_OF_FILE if test 4453 -ne `wc -c <'Docs/map.doc'`; then echo shar: \"'Docs/map.doc'\" unpacked with wrong size! fi # end of 'Docs/map.doc' fi if test -f 'Makefile' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Makefile'\" else echo shar: Extracting \"'Makefile'\" \(4467 characters\) sed "s/^X//" >'Makefile' <<'END_OF_FILE' X# Galactic Bloodshed (Robert Chansky, smq@b) X# Makefile (modified by billr@saab.cna.tek.com, 4/26/89) X X# what version of UNIX we are running on. XUV = VER_4_3 X#UV = VER_4_2 X# You might want to get rid of the -pipe -g, since these are for development. XCFLAGS = -D$(UV) -pipe -g X#CFLAGS = -D$(UV) -g X#CFLAGS = -D$(UV) -O X X# destination directories X# GLIB should match the directory in the PATH macro of files.h XGBIN = /usr/games XGLIB = /usr/games/lib/GB X X# objects for shell XSHOBJS = getplace.o \ X read_teleg.o \ X autoreport.o \ X shootblast.o \ X docommand.o \ X explore.o \ X telegram.o \ X mobiliz.o \ X shlmisc.o \ X moveship.o \ X doplanet.o \ X moveplanet.o \ X autoshoot.o \ X dosector.o \ X relation.o \ X enslave.o \ X doturn.o \ X doship.o \ X zoom.o \ X perm.o \ X survey.o \ X enrol.o \ X prof.o \ X GB.o \ X name.o \ X fire.o \ X land.o \ X map.o \ X max.o \ X cs.o \ X fix.o \ X rst.o \ X misc.o \ X help.o \ X rand.o \ X load.o \ X scrap.o \ X build.o \ X order.o \ X orbit.o \ X power.o \ X launch.o \ X declare.o \ X examine.o \ X get4args.o \ X teleg_send.o \ X files_rw.o \ X files_shl.o X X X# depend on vars.h only XVOBJS = getplace.o \ X mobiliz.o \ X shlmisc.o \ X survey.o \ X enrol.o \ X prof.o \ X zoom.o \ X max.o \ X GB.o \ X perm.o \ X telegram.o \ X docommand.o \ X read_teleg.o X X#depend on races.h and vars.h XROBJS = doplanet.o \ X makeplanet.o \ X shootblast.o \ X autoshoot.o \ X moveship.o \ X explore.o \ X relation.o \ X dosector.o \ X declare.o \ X survey.o \ X enrol.o \ X prof.o \ X rst.o \ X GB.o \ X cs.o \ X fix.o \ X max.o \ X map.o \ X name.o \ X fire.o \ X power.o \ X order.o \ X doturn.o \ X doship.o \ X telegram.o \ X makeuniv.o \ X read_teleg.o X X# depend on ships.h and vars.h XSHIPOBJS = autoreport.o \ X shootblast.o \ X makeplanet.o \ X examine.o \ X enslave.o \ X launch.o \ X build.o \ X order.o \ X fire.o \ X land.o \ X map.o \ X max.o \ X cs.o \ X fix.o \ X rst.o \ X load.o \ X name.o \ X prof.o \ X scrap.o \ X orbit.o \ X doturn.o \ X doship.o \ X doplanet.o \ X moveship.o \ X autoshoot.o \ X moveplanet.o \ X files_shl.o X X# depend on files.h XFOBJS = files_shl.o \ X teleg_send.o \ X makeuniv.o \ X shlmisc.o \ X doturn.o \ X enrol.o \ X help.o \ X GB.o \ X build.o \ X power.o \ X examine.o X X X# dont depend on anything XNOOBJS = get4args.o \ X misc.o \ X help.o \ X rand.o \ X daemon.o \ X teleg_send.o \ X files_rw.o X X X# objects for daemon XDOBJS = shootblast.o \ X moveplanet.o \ X autoshoot.o \ X doplanet.o \ X doturn.o \ X daemon.o \ X rand.o \ X max.o \ X perm.o \ X misc.o \ X doship.o \ X dosector.o \ X moveship.o \ X teleg_send.o \ X files_rw.o \ X files_shl.o X X Xall: mor GB makeuniv GB_daemon X X# the shell XGB : ${SHOBJS} X cc -o GB ${SHOBJS} -lcurses -ltermcap -lm X${ROBJS}: races.h X${VOBJS}: vars.h X${SHIPOBJS}: vars.h ships.h X${FOBJS}: files.h X${NOOBJS}: tweakables.h Xmoveship.o : vars.h ships.h shipdata.h Xdoturn.o doplanet.o power.o doship.o files_shl.o makeuniv.o : power.h X#sizes : vars.h ships.h races.h X# sizes.c X X X# make data files program Xmakeuniv : makeuniv.o makeplanet.o rand.o perm.o X cc -o makeuniv makeuniv.o makeplanet.o rand.o perm.o -lm X X X# the daemon XGB_daemon : ${DOBJS} X cc -o GB_daemon ${DOBJS} -lm Xdoturn.o doship.o doplanet.o moveship.o moveplanet.o : doturn.h X X# more clone Xmor : more.c X cc -o mor more.c X Xchmod: X cd $(GLIB) X chmod ag+xs GB X chmod g+rwx Data Data/* Data/Tele/* X chmod a+rx Docs Docs/* X chmod g+r *.dat* X chmod a+x mor X# chmod ga+rwx Data Data/* Data/Tele/* X Xstart: X cd $(GLIB) X /bin/rm -f Data/spitup X GB_daemon \>\& Data/spitup X Xclean: X /bin/rm -rf GB makeuniv GB_daemon mor *.o core a.out X Xclear: X /bin/rm -rf *.o core a.out X X X# shar it up for transport. Xshar: X /bin/cp Docs/* . X uncompress enroll.dat.Z X #*.doc X shar -c README Makefile *.doc *.h *.c planet.list *.dat > /tmp/GB.shar X compress enroll.dat X compress /tmp/GB.shar X mv /tmp/GB.shar.Z . X /bin/rm -f *.doc X X# make the game ftpable by netters. Xpublic: X /bin/cp Docs/* . X uncompress enroll.dat.Z X shar -c README Makefile *.doc *.h *.c planet.list *.dat > /tmp/GB.shar X compress enroll.dat X compress /tmp/GB.shar X /bin/cp /tmp/GB.shar.Z /usr/ftp/pub/games X /bin/rm -f /tmp/GB.shar.Z X chmod a+r /usr/ftp/pub/games/GB.shar.Z X /bin/rm -f *.doc X X# install the game for public use. Xinstall: X make X cp GB $(GBIN) X -mkdir $(GLIB) X cp exam.dat enroll.dat $(GLIB) X -mkdir $(GLIB)/Docs X -cp Docs/* $(GLIB)/Docs X -compress $(GLIB)/Docs/* $(GLIB)/enroll.dat X make clear X makeuniv < planet.list X make chmod X X END_OF_FILE if test 4467 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'autoshoot.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'autoshoot.c'\" else echo shar: Extracting \"'autoshoot.c'\" \(3666 characters\) sed "s/^X//" >'autoshoot.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * autoshoot() -- shoot <-> retaliate routine X * Bombard() -- ship bombards planet X */ X X X#include "vars.h" X#include "ships.h" X#include "races.h" Xextern bool Nuked[MAXPLAYERS]; /* who was nuked on the planet/ship */ Xextern char telegram_buf[]; Xextern racetype *races[]; X X X/* ship #shipno bombards planet, then sends telegrams alerting whom it X * may concern. X */ XBombard(ship,shipno,planet) Xshiptype *ship; Xplanettype *planet; X{ Xint x,y,oldown,numdest,found=0; Xfloat dist; Xchar buf[200]; Xbool whocares; X X /* for telegramming */ X bzero((char *)Nuked, sizeof(Nuked)); X X /* look for someone to bombard-check for war */ X Getxysect(planet,0,0,1); /* reset */ X while (!found && Getxysect(planet,&x,&y,0)) X if (Sector(*planet,x,y).owner && X isset(races[ship->owner]->atwar, Sector(*planet,x,y).owner)) X found=1; X if (!found) { X /* no one we are at war with. find someone neutral X (owner 0 will work, too, but not already bombed)*/ X Getxysect(planet,0,0,1); /* reset */ X while (!found && Getxysect(planet,&x,&y,0)) X if (Sector(*planet,x,y).popn && X Sector(*planet,x,y).owner!=ship->owner && X isclr(races[ship->owner]->allied, Sector(*planet,x,y).owner) ) X found=1; X } X if (found) { X placetype from,to; X int str; X str = MIN(Shipdata[ship->type][ABIL_GUNS], ship->destruct); X /* save owner of destroyed sector */ X if (str) { X oldown = Sector(*planet,x,y).owner; X ship->destruct -= str; X ship->mass -= str * MASS_DESTRUCT; X from.level = LEVEL_SHIP; X from.shipptr = ship; X from.shipno = shipno; X to.level = LEVEL_PLAN; X to.snum = ship->storbits; X to.pnum = ship->pnumorbits; X numdest = shoot(from, &to, (planettype *)NULL,planet, x,y, str, &dist, X &whocares,&whocares,&whocares, 0); /* (0=dont get smap) */ X X /* tell the bombarding player about it.. */ X teleg_add("",telegram_buf); X sprintf(buf,"REPORT: ship #%d\n\n",shipno); X teleg_add(buf,telegram_buf); X sprintf(buf,"%s #%d reports bombing of planet /%s/%s,\n", X Shipnames[ship->type], shipno, X Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X sprintf(buf,"sector %d,%d (owner %d). %d sectors destroyed.\n", X x, y, oldown, numdest); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf); X X /* notify other player. */ X teleg_add("",telegram_buf); X sprintf(buf,"ALERT from planet /%s/%s\n\n", X Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X sprintf(buf,"%s #%d Bombarded sector %d,%d; %d sectors destroyed.\n", X Shipnames[ship->type], shipno, x, y, numdest); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, oldown, telegram_buf); X X } else { X /* no weapons! */ X if (!ship->notified) { X ship->notified = 1; X teleg_add("",telegram_buf); X sprintf(buf, X "Bulletin\n\n Ship #%d has no weapons to bombard with.\n", X shipno); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf); X } X } X X } else { X /* there were no sectors worth bombing. */ X if (!ship->notified) { X ship->notified = 1; X teleg_add("",telegram_buf); X sprintf(buf,"Report from %s #%d\n\n",Shipnames[ship->type],shipno); X teleg_add(buf,telegram_buf); X sprintf(buf,"Planet /%s/%s has been saturation bombed.\n", X Stars[ship->storbits]->name, X Stars[ship->storbits]->pnames[ship->pnumorbits]); X teleg_add(buf,telegram_buf); X teleg_send(TELEG_PLAYER_AUTO, ship->owner, telegram_buf); X } X } X X} END_OF_FILE if test 3666 -ne `wc -c <'autoshoot.c'`; then echo shar: \"'autoshoot.c'\" unpacked with wrong size! fi # end of 'autoshoot.c' fi if test -f 'cs.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'cs.c'\" else echo shar: Extracting \"'cs.c'\" \(4475 characters\) sed "s/^X//" >'cs.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * cs.c -- change scope operand (directory) X */ X X#include "vars.h" X#include "ships.h" X#include "races.h" X Xcs(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ X placetype where; X planettype *planet; X shiptype *s; X int cs_shdata,cs_pdata; X X if (argn==1) { X /* chdir to def scope */ X Dir.level = Race->deflevel; X if ((Dir.snum = Race->defsystem) >= Sdata.numstars) X Dir.snum = Sdata.numstars-1; X if ((Dir.pnum = Race->defplanetnum) >= Stars[Dir.snum]->numplanets) X Dir.pnum = Stars[Dir.snum]->numplanets-1; X Dir.shipno = 0; X Dir.lastx = Dir.lasty = 0.0; X docommand("cs :"); /* trick -- adjust prompt */ X return; X } else if (argn==2) { X /* chdir to specified scope */ X X Locks(1); X where = Getplace(args[1],0); /* do not ignore the fact that you've not X explored the place */ X Locks(0); X if (where.err) { X printf("cs: bad scope.\n"); X Dir.lastx = Dir.lasty = 0.0; X return; X } X X /* fix lastx, lasty coordinates */ X X switch (Dir.level) { X case LEVEL_UNIV: X Dir.lastx = Dir.lasty = 0.0; X break; X case LEVEL_STAR: X if (where.level==LEVEL_UNIV) { X Dir.lastx = Stars[Dir.snum]->xpos; X Dir.lasty = Stars[Dir.snum]->ypos; X } else X Dir.lastx = Dir.lasty = 0.0; X break; X case LEVEL_PLAN: X openpdata(&cs_pdata); X getplanet(cs_pdata,&planet,Stars[Dir.snum]->planetpos[Dir.pnum]); X close(cs_pdata); X if (where.level==LEVEL_STAR && where.snum==Dir.snum) { X Dir.lastx = planet->xpos; X Dir.lasty = planet->ypos; X } else if (where.level==LEVEL_UNIV) { X Dir.lastx = Stars[Dir.snum]->xpos + planet->xpos; X Dir.lasty = Stars[Dir.snum]->ypos + planet->ypos; X } else X Dir.lastx = Dir.lasty = 0.0; X free(planet); X break; X case LEVEL_SHIP: X openshdata(&cs_shdata); X getship(cs_shdata, &s, Dir.shipno); X close(cs_shdata); X if (!s->is_docked) { X switch (where.level) { X case LEVEL_UNIV: X Dir.lastx = s->xpos; X Dir.lasty = s->ypos; X break; X case LEVEL_STAR: X if (s->whatorbits>=LEVEL_STAR && s->storbits==where.snum) { X /* we are going UP from the ship.. change last*/ X Dir.lastx = s->xpos - Stars[s->storbits]->xpos; X Dir.lasty = s->ypos - Stars[s->storbits]->ypos; X } else X Dir.lastx = Dir.lasty = 0.0; X break; X case LEVEL_PLAN: X if (s->whatorbits==LEVEL_PLAN && s->storbits==where.snum X && s->pnumorbits==where.pnum) { X /* same */ X openpdata(&cs_pdata); X getplanet(cs_pdata,&planet,Stars[s->storbits]->planetpos[s->pnumorbits]); X close(cs_pdata); X Dir.lastx = s->xpos - Stars[s->storbits]->xpos - planet->xpos; X Dir.lasty = s->ypos - Stars[s->storbits]->ypos - planet->ypos; X free(planet); X } else X Dir.lastx = Dir.lasty = 0.0; X break; X case LEVEL_SHIP: X Dir.lastx = Dir.lasty = 0.0; X break; X default: X break; X } X } else X Dir.lastx = Dir.lasty = 0.0; X free(s); X break; X default: X break; X } X X Dir.level = where.level; X Dir.snum = where.snum; X Dir.pnum = where.pnum; X Dir.shipno = where.shipno; X X /* fix prompt */ X switch (Dir.level) { X case LEVEL_UNIV: X sprintf(Dir.prompt," [%02d] / >",Sdata.AP[Playernum]); X break; X case LEVEL_STAR: X sprintf(Dir.prompt," / [%02d] %s >", X Stars[Dir.snum]->AP[Playernum], X Stars[Dir.snum]->name); X break; X case LEVEL_SHIP: X switch (where.shipptr->whatorbits) { /* what orbits around */ X case LEVEL_UNIV: X sprintf(Dir.prompt," [%02d] / #%d >", X Stars[Dir.snum]->AP[Playernum], X where.shipno); X break; X case LEVEL_STAR: X sprintf(Dir.prompt," / [%02d] %s / #%d >", X Stars[Dir.snum]->AP[Playernum], X Stars[Dir.snum]->name, X where.shipno); X break; X case LEVEL_PLAN: X sprintf(Dir.prompt," / [%02d] %s / %s / #%d >", X Stars[Dir.snum]->AP[Playernum], X Stars[Dir.snum]->name, X Stars[Dir.snum]->pnames[Dir.pnum], X where.shipno); X break; X } X free(where.shipptr); X break; X case LEVEL_PLAN: X sprintf(Dir.prompt," / [%02d] %s / %s >", X Stars[Dir.snum]->AP[Playernum], X Stars[Dir.snum]->name, X Stars[Dir.snum]->pnames[Dir.pnum]); X break; X default: break; X } X } else if (argn==3 && args[1][1]=='d') { X /* make new def scope */ X where = Getplace(args[2],0); X if (!where.err) { X Race->homelevel = where.level; X Race->homesystem = where.snum; X Race->homeplanetnum = where.pnum; X putrace(Race); X docommand("cs"); /* chdir to home scope */ X printf("New home system is %s\n",Dispplace(&where)); X } else { X printf("cs: bad home system.\n"); X return; X } X } X} END_OF_FILE if test 4475 -ne `wc -c <'cs.c'`; then echo shar: \"'cs.c'\" unpacked with wrong size! fi # end of 'cs.c' fi if test -f 'enslave.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'enslave.c'\" else echo shar: Extracting \"'enslave.c'\" \(4360 characters\) sed "s/^X//" >'enslave.c' <<'END_OF_FILE' X/* X** Galactic Bloodshed (Robert Chansky, smq@b) X** enslave.c -- ENSLAVE the planet below. X*/ X X#include "vars.h" X#include "ships.h" X#include "races.h" X#include X#include Xextern jmp_buf main_jenv; X#include X Xint enslave_shdata,enslave_pdata; Xextern char telegram_buf[AUTO_TELEG_SIZE]; X X Xenslave(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint enslave_handler(); Xshiptype *s, *s2; Xplanettype *p; Xint sh,shipno,i,mask,aliens=0,def=0,attack=0; Xdouble Dist; Xchar buf[200]; X Xenslave_shdata = enslave_pdata = NEUTRAL_FD; Xsignal(SIGINT, enslave_handler); X X X if (argn==1) { X printf("enslave with what ship #"); X scanf("%d",&shipno); X getchr(); X } else X sscanf(args[1]+(args[1][0]=='#'), "%d",&shipno); X X openshdata(&enslave_shdata); X if (!getship(enslave_shdata, &s, shipno)) { X enslave_handler(); X } X close(enslave_shdata); X X if (s->owner!=Playernum) { X DontOwnErr(shipno); X enslave_handler(); X } X X if (testship(s, shipno)) X enslave_handler(); X X if (s->type != STYPE_ASS) { X printf("This ship is not an %s.\n", Shipnames[STYPE_ASS]); X enslave_handler(); X } X if (s->whatorbits!=LEVEL_PLAN) { X printf("%s #%d doesn't orbit a planet.\n", Shipnames[s->type],shipno); X enslave_handler(); X } X X if (!enufAP(Stars[s->storbits]->AP, APcount)) X enslave_handler(); X X X printf("ENSLAVE planet %s (y/n)?", prin_ship_orbits(s)); X tty_on(); X if (getchr() != 'y') { X putchr('\n'); X enslave_handler(); X } X putchr('\n'); X tty_off(); X X openpdata(&enslave_pdata); X getplanet(enslave_pdata,&p,Stars[s->storbits]->planetpos[s->pnumorbits]); X X if (p->info[Playernum-1].numsectsowned==0) { X printf("You don't have a garrison on the planet.\n"); X enslave_handler(); X } X X /* add up forces attacking, defending */ X for (attack=aliens=def=0,i=1; iinfo[i-1].numsectsowned && i!=Playernum) { X aliens = 1; X def += p->info[i-1].destruct; X } X } X X if (!aliens) { X printf("There is no one else on this planet to enslave!\n"); X enslave_handler(); X } X X openshdata(&enslave_shdata); X sh = p->ships; X Locks(1); X while (sh) { X (void)getship(enslave_shdata, &s2, sh); X if (p->info[s2->owner].numsectsowned && s2->owner!=Playernum) X def += s2->destruct; X else if (s2->owner==Playernum) X attack += s2->destruct; X sh = s2->nextship; X free(s2); X } X Locks(0); X close(enslave_shdata); X X deductAPs(APcount, s->storbits, 0); X X printf("\nFor successful enslavement this ship and the other ships here\n"); X printf("that are yours must have a weapons\n"); X printf("capacity greater than twice that the enemy can muster, including\n"); X printf("the planet and all ships orbiting it.\n"); X printf("\nTotal forces bearing on %s: %d\n", prin_ship_orbits(s), attack); X X X teleg_add("",telegram_buf); X sprintf(buf,"ALERT!!!\n\nPlanet /%s/%s ", X Stars[s->storbits]->name, X Stars[s->storbits]->pnames[s->pnumorbits]); X teleg_add(buf,telegram_buf); X X if (def <= 2 * attack) { X X p->slaved_to = Playernum; X putplanet(enslave_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]); X close(enslave_pdata); X X /* send telegs to anyone there */ X sprintf(buf,"ENSLAVED by %s #%d!!\n", X Shipnames[s->type], shipno); X teleg_add(buf,telegram_buf); X sprintf(buf,"All material produced here will be\ndiverted to %s coffers.", X Race->name); X teleg_add(buf,telegram_buf); X X printf("\nEnslavement successful. All material produced here will\n"); X printf("be diverted to %s.\n", Race->name); X printf("You must maintain a garrison of 0.1 the population of the\n"); X printf("planet (at least %.0f); otherwise there is a 50% chance that\n", p->popn * 0.01); X printf("enslaved population will revolt.\n"); X X } else { X close(enslave_pdata); X X sprintf(buf,"repulsed attempt at evslavement by %s #%d!!\n", X Shipnames[s->type], shipno); X teleg_add(buf,telegram_buf); X sprintf(buf,"Enslavement repulsed, defense/attack Ratio : %d to %d.\n", def, attack); X teleg_add(buf,telegram_buf); X X printf("Enslavement repulsed.\n"); X printf("You needed more weapons bearing on the planet...\n"); X } X X X for (i=1; iinfo[i-1].numsectsowned && i!=Playernum) X teleg_send(TELEG_PLAYER_AUTO, i, telegram_buf); X X X free(p); X X} X X X Xenslave_handler() X{ X tty_off(); X close(enslave_pdata); X close(enslave_shdata); X Locks(0); X longjmp(main_jenv,1); X} END_OF_FILE if test 4360 -ne `wc -c <'enslave.c'`; then echo shar: \"'enslave.c'\" unpacked with wrong size! fi # end of 'enslave.c' fi if test -f 'launch.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'launch.c'\" else echo shar: Extracting \"'launch.c'\" \(3825 characters\) sed "s/^X//" >'launch.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * launch.c -- launch or undock a ship (also undock) X */ X X#include "vars.h" X#include "ships.h" X#include Xextern jmp_buf main_jenv; X#include X Xint launch_shdata,launch_pdata; X X Xlaunch(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xint launch_handler(); Xshiptype *s,*s2; Xplanettype *p; Xbool planet=0; Xint shipno; Xfloat fuel; X Xlaunch_shdata = launch_pdata = NEUTRAL_FD; Xsignal(SIGINT, launch_handler); X X if (argn!=2) { X printf("Launch what ship #"); X scanf("%d",&shipno); X getchr(); X } else X sscanf(args[1]+(args[1][0]=='#'),"%d",&shipno); X X openshdata(&launch_shdata); X if (!getship(launch_shdata, &s, shipno)) { X launch_handler(); X } X X if (s->owner!=Playernum) { X DontOwnErr(shipno); X launch_handler(); X } X if (!speed_rating(s)) { X printf("That ship is not designed to be launched.\n"); X launch_handler(); X } X X if (testship(s,shipno)) X launch_handler(); X X if (!s->is_docked) { X printf("Ship #%d is not landed or docked.\n",shipno); X launch_handler(); X } X if (s->whatdest==LEVEL_PLAN && s->resource > Shipdata[s->type][ABIL_CARGO]) { X printf("Ship #%d is too overloaded to launch.\n", shipno); X launch_handler(); X } X X if (s->whatdest==LEVEL_SHIP) { X X if (s->whatorbits==LEVEL_UNIV) { X if (!enufAP(Sdata.AP, APcount)) X launch_handler(); X else X deductAPs(APcount, 0, 1); X } else { X if (!enufAP(Stars[s->storbits]->AP, APcount)) X launch_handler(); X else X deductAPs(APcount, s->storbits, 0); X } X Locks(1); X (void)getship(launch_shdata, &s2, s->destshipno); X Locks(0); X s->is_docked = 0; X s->whatdest = LEVEL_UNIV; /* no destination */ X putship(launch_shdata, s, shipno); X s2->is_docked = 0; X s2->whatdest = LEVEL_UNIV; X putship(launch_shdata, s2, s->destshipno); X close(launch_shdata); X free(s); X free(s2); X printf("%s #%d undocked from ship #%d.\n", X Shipnames[s->type], shipno, s->destshipno); X X } else { X if (!enufAP(Stars[s->storbits]->AP, APcount)) X launch_handler(); X else X deductAPs(APcount, s->storbits, 0); X X s->is_docked = 0; X s->whatdest = LEVEL_UNIV; /* no destination */ X X X /* adjust x,ypos to absolute coords */ X openpdata(&launch_pdata); X getplanet(launch_pdata, &p, Stars[s->storbits]->planetpos[s->pnumorbits]); X if (p->is_explored) /* no alteration of the planet unless this.. */ X close(launch_pdata); X X printf("Planet /%s/%s has gravity field of %.2f\n", Stars[s->storbits]->name, X Stars[s->storbits]->pnames[s->pnumorbits], gravity(p)); X /* alter sector location of ship x,y to stellar coords x,y */ X s->xpos = Stars[s->storbits]->xpos + p->xpos + X (float)int_rand((int)(-DIST_TO_LAND/2),(int)(DIST_TO_LAND/2)); X s->ypos = Stars[s->storbits]->ypos + p->ypos + X (float)int_rand((int)(-DIST_TO_LAND/2),(int)(DIST_TO_LAND/2)); X X /* subtract fuel from ship */ X fuel = gravity(p) * s->mass * LAUNCH_GRAV_MASS_FACTOR; X if (s->fuel < fuel) { X printf("Ship #%d does not have enough fuel! (%.1f)\n",shipno, fuel); X launch_handler(); X } X s->fuel -= fuel; X s->mass -= fuel * MASS_FUEL; X X X if (s->type == OTYPE_CANIST) X s->orders.object.number = 20; /* canister dissapates after 20 turns */ X X s->notified = 0; X putship(launch_shdata, s, shipno); X close(launch_shdata); X X if (!p->is_explored) { X /* not yet explored by owner; space exploration causes the X player to see a whole map */ X p->is_explored = 1; X putplanet(launch_pdata,p,Stars[s->storbits]->planetpos[s->pnumorbits]); X close(launch_pdata); X } X free(p); X X printf("%s #%d launched from planet,", Shipnames[s->type], shipno); X printf(" using %.1f fuel.\n",fuel); X if (s->type == OTYPE_CANIST) X printf("A thick cloud of dust envelops your planet.\n"); X X free(s); X X } X X} X X Xlaunch_handler() X{ X Locks(0); X close(launch_pdata); X close(launch_shdata); X longjmp(main_jenv,1); X} END_OF_FILE if test 3825 -ne `wc -c <'launch.c'`; then echo shar: \"'launch.c'\" unpacked with wrong size! fi # end of 'launch.c' fi if test -f 'name.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'name.c'\" else echo shar: Extracting \"'name.c'\" \(3449 characters\) sed "s/^X//" >'name.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * name.c -- rename something to something else X */ X X#include "vars.h" X#include "races.h" X#include "ships.h" X#include X#include X#include X#include Xextern jmp_buf main_jenv; Xint name_shdata,name_stardata; X Xname(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xplanettype *p; Xplacetype where; Xchar st[COMMANDSIZE],*ch; Xregister int i; Xbool check=0; Xint name_handler(); X Xname_stardata = NEUTRAL_FD; Xsignal(SIGINT, name_handler); X X if (argn==1) { /* no args */ X printf("Rename: "); X scanf("%[^\n]",st); X getchr(); X } else sscanf(args[1],"%s",st); X if (!strcmp(st,"race")) { X if (enufAP(Sdata.AP, APcount)) X deductAPs(APcount,0,1); X else X name_handler(); X free(Race); X getrace(&Race, Race->Playernum); X printf("Change racial name %s to:",Race->name); X dots(RNAMESIZE); X scanf("%[^\n]",Race->name); X getchr(); X putrace(Race); X deductAPs(APcount, 0, 1); X return; X } X where = Getplace(st,0); X if (where.err) { X printf("Not found.\n"); X return; X } else if (where.level==LEVEL_SHIP) { X printf("You cannot name a ship.\n"); X return; X } X X printf("Rename %s to:", Dispplace(&where) ); X dots(NAMESIZE); /* make a bunch of dots */ X scanf("%20[^\n]",st); /* change "20" if NAMESIZE altered */ X getchr(); X ch = st; X while (*ch!='\0') X check |= (isspace(*ch) || iscntrl(*ch) || (*(ch++)=='/') ); X /* make sure there are no ^'s or '/' in name */ X if (strlen(st) < 1 || check) { X printf("Illegal name %s.\n", check ? "form" : "length" ); X name_handler(); X } X switch (where.level) { X case LEVEL_STAR: X free(Stars[where.snum]); X openstardata(&name_stardata); X getstar(name_stardata, &Stars[where.snum], where.snum); X if (!enufAP(Stars[where.snum]->AP, APcount)) X name_handler(); X /* can't name the place if you don't have the most AP's */ X if (!MostAPs(Stars[where.snum])) { X printf("You don't have the most AP's in that system.\n"); X name_handler(); X } X strncpy(Stars[where.snum]->name,st,NAMESIZE-1); X putstar(name_stardata, Stars[where.snum], where.snum); X close(name_stardata); X deductAPs(APcount, where.snum, 0); X break; X X case LEVEL_PLAN: X free(Stars[where.snum]); X openstardata(&name_stardata); X getstar(name_stardata, &Stars[where.snum], where.snum); X if (!MostAPs(Stars[where.snum])) { X printf("You don't have the most AP's in that system.\n"); X name_handler(); X } X strncpy(Stars[where.snum]->pnames[where.pnum],st,NAMESIZE-1); X putstar(name_stardata, Stars[where.snum], where.snum); X close(name_stardata); X deductAPs(APcount, where.snum, 0); X break; X X /*case LEVEL_SHIP: X /* shipptr already gotten */ X /*if (where.shipptr->owner!=Playernum || where.err) { X printf("Name: bad ship #.\n"); X DontOwnErr(where.shipno); X name_handler(); X } X strncpy(where.shipptr->name,st,NAMESIZE-1); X openshdata(&name_shdata); X putship(name_shdata, where.shipptr, where.shipno); X close(name_shdata); X if (where.shipptr->whatorbits==LEVEL_UNIV) X deductAPs(APcount, 0, 1); X else X deductAPs(APcount, where.shipptr->storbits, 0); X break;*/ X X case LEVEL_UNIV: X default: X printf("You can't do that.\n"); X return; X } X docommand("cs :"); /* trick */ X} X X Xint MostAPs(s) Xstartype *s; X{ X register int i,t = 0; X X for (i=0; iAP[i] > s->AP[t]) X t = i; X X return (t == Playernum); X X} X X Xname_handler() X{ X close(name_stardata); X /*close(name_shdata);*/ X longjmp(main_jenv,1); X} END_OF_FILE if test 3449 -ne `wc -c <'name.c'`; then echo shar: \"'name.c'\" unpacked with wrong size! fi # end of 'name.c' fi if test -f 'scrap.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'scrap.c'\" else echo shar: Extracting \"'scrap.c'\" \(3575 characters\) sed "s/^X//" >'scrap.c' <<'END_OF_FILE' X X X/* X * Galactic Bloodshed (Robert Chansky, smq@ssyx.ucsc.edu) X * scrap.c -- turn a ship to junk X */ X X#include "vars.h" X#include "ships.h" X#include X#include Xextern jmp_buf main_jenv; Xextern int Shipdata[NUMSTYPES][NUMABILS]; Xint scrap_shdata, scrap_pdata; X X Xscrap(APcount, argn,args) Xint APcount; Xint argn; Xchar args[MAXARGS][COMMANDSIZE]; X{ Xplanettype *planet; Xsectortype *sect; Xshiptype *s; Xint i,shfdata,mask,shipno,scrapval; Xint scrap_handler(); X X Xscrap_shdata = scrap_pdata = NEUTRAL_FD; Xsignal(SIGINT, scrap_handler); X X X if (argn<2) { X printf("ship #"); X scanf("%d",&shipno); X getchr(); X } else X sscanf(args[1] + (*args[1]=='#'), &shipno); X X openshdata(&scrap_shdata); X if (!getship(scrap_shdata,&s,shipno)) { X scrap_handler(); X } X X if (s->owner!=Playernum || s->is_dead) { X DontOwnErr(shipno); X free(s); X scrap_handler(); X } X X if (s->whatorbits==LEVEL_UNIV) { X if (!enufAP(Sdata.AP, APcount)) X scrap_handler(); X } else X if (!enufAP(Stars[s->storbits]->AP, APcount)) X scrap_handler(); X X X if (s->whatorbits==LEVEL_PLAN && s->type==OTYPE_TOXWC) X printf("WARNING: This will release %d toxin points back into the atmosphere!!\n", s->orders.object.number); X X X if ( !(s->is_docked && s->whatdest==LEVEL_PLAN)) { X printf("%s #%d is not landed on a planet.\nNo resources can be reclaimed.\n",Shipnames[s->type], shipno); X if (s->destruct >= 1) { X tty_on(); X printf("self-destruct (y/n)?"); X if (getchr()!='y') { X free(s); X scrap_handler(); X } X tty_off(); X } else { X printf("The ship doesn't have a self-destruct charge.\n"); X scrap_handler(); X } X } X X if (s->whatorbits==LEVEL_PLAN) { X X openpdata(&scrap_pdata); X getplanet(scrap_pdata, &planet, Stars[s->storbits]->planetpos[s->pnumorbits]); X } X X scrapval = Shipdata[s->type][ABIL_COST] * .75; X if ( s->type!=OTYPE_VN ) scrapval += s->resource; X if (s->type==OTYPE_VN) X scrapval += .75 * (s->orders.object.number-1) * Shipdata[s->type][ABIL_COST]; X X if (s->is_docked && s->whatdest==LEVEL_PLAN) { X tty_on(); X printf("%s #%d:original cost: %d\n", X Shipnames[s->type], shipno, Shipdata[s->type][ABIL_COST]); X printf(" %s scrap value%s: %d.\n", X s->type==OTYPE_VN ? "total" : "", X s->resource ? "(with stockpile) " : "", scrapval); X X X printf("\nJunk (y/n)? "); X X if (getchr()!='y') { X tty_off(); X putchr('\n'); X scrap_handler(); X } X putchr('\n'); X } X X mask = sigblock(SIGQUIT | SIGSTOP | SIGINT); X X if (s->whatorbits==LEVEL_UNIV) X deductAPs(APcount, 0, 1); X else X deductAPs(APcount, s->storbits, 0); X X kill_ship(s); Xputship(scrap_shdata, &s, shipno); X X if (s->whatorbits==LEVEL_PLAN) { X X /* distribute poison over planet even if orbiting */ X if (s->type==OTYPE_TOXWC) { X if (planet->conditions[TOXIC] > 100 - s->orders.object.number) X planet->conditions[TOXIC] = 100; X else X planet->conditions[TOXIC] += s->orders.object.number; X printf("Planetary toxin concentration is now %d.\n", X planet->conditions[TOXIC]); X } X X if (s->is_docked && s->whatdest==LEVEL_PLAN) { X planet->info[Playernum-1].resource += scrapval; X planet->info[Playernum-1].destruct += s->destruct; X planet->info[Playernum-1].fuel += s->fuel; X } X X putplanet(scrap_pdata, planet, Stars[s->storbits]->planetpos[s->pnumorbits]); X close(scrap_pdata); X X } X X X if (s->is_docked && s->whatdest==LEVEL_PLAN) X puts("\nScrapped.\n"); X else X puts("\nDestroyed.\n"); X X putship(scrap_shdata,s,shipno); X X close(scrap_shdata); X free(s); X X tty_off(); X X sigsetmask(mask); /* reset mask */ X X} X X X Xscrap_handler() X{ X tty_off(); X close(scrap_shdata); X close(scrap_pdata); X longjmp(main_jenv,1); X} END_OF_FILE if test 3575 -ne `wc -c <'scrap.c'`; then echo shar: \"'scrap.c'\" unpacked with wrong size! fi # end of 'scrap.c' fi if test -f 'shipdata.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'shipdata.h'\" else echo shar: Extracting \"'shipdata.h'\" \(3652 characters\) sed "s/^X//" >'shipdata.h' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X */ X Xchar Shipltrs[]={ 'p','s','D','B','I','C','d','f','c','e','t','S','O','$', X '+','m','H','=','/','T','A','g','V','^',' ','L','w','Y','G','&', X '-','>','"','[' }; X Xint Shipdata[NUMSTYPES][NUMABILS] = { X /* cargo destcap guns fuelcap tech crew armr cost mass lnd sw sp*/ X/*SPd*/1, 0, 0, 20, 1, 1, 1, 10, 3, 1, 0, 1, X/*Shu*/10, 2, 1, 20, 10, 25, 1, 50, 2, 1, 0, 2, X/*Drn*/100, 500, 60, 500, 500, 60, 20, 2000, 40, 0, 0, 2, X/*BB */35, 300, 30, 200, 200, 100, 15, 500, 20, 1, 0, 2, X/*Int*/10, 120, 40, 200, 500, 20, 10, 1000, 5, 1, 0, 4, X/*CA */15, 200, 20, 120, 150, 60, 10, 300, 10, 1, 0, 3, X/*DD */10, 100, 10, 80, 100, 30, 5, 200, 5, 1, 0, 4, X/*FF */0, 50, 10, 10, 200, 1, 2, 30, 1, 1, 0, 4, X/*Crg*/1000, 1000, 5, 1000, 100, 100, 3, 200, 20, 1, 0, 2, X/*Exp*/0, 15, 5, 35, 20, 2, 1, 100, 1, 1, 0, 4, X/*Tnk*/15, 10, 5, 5000, 100, 50, 3, 400, 20, 1, 0, 2, X/*Stn*/5000, 250, 40, 500, 100, 1000, 10, 400, 100, 1, 0, 2, X/*OSP*/1000, 1000, 50, 1000, 200, 1000, 8, 800, 100, 0, 0, 2, X/*GOD*/50000, 50000, 50000, 50000, 5000, 50000, 100,100, 1, 1, 0, 4, X/*SMn*/0, 50, 0, 20, 50, 0, 5, 50, 10, 1, 1, 2, X /* cargo destcap guns fuelcap tech crew armr cost mass mv sw */ X/*mir*/200, 10, 1, 20, 200, 15, 1, 100, 100, 0, 0, 1, X/*Hab*/5000, 500, 20, 5000, 100, 2000, 9, 1000, 100, 0, 0, 1, X/*Stc*/0, 0, 0, 20, 50, 5, 1, 50, 2, 1, 0, 2, X/*Tsc*/0, 0, 0, 0, 5, 10, 1, 10, 5, 1, 0, 0, X/*T-R*/0, 0, 0, 1000, 100, 15, 1, 120, 10, 1, 1, 1, X/*APr*/0, 0, 0, 200, 50, 10, 1, 80, 40, 1, 1, 0, X/*CD */0, 0, 0, 1, 40, 0, 1, 20, 5, 1, 0, 1, X/*VN */20, 0, 0, 50, 80, 0, 1, 15, 10, 1, 1, 1, X/*PB */0, 20, 0, 5, 300, 0, 1, 100, 5, 1, 1, 1, X/*ClD*/0, 10, 0, 0, 250, 0, 1, 25, 6, 1, 1, 0, X/*OMCL*/0, 100, 10, 100, 350, 5, 1, 100, 4, 1, 1, 2, X/*TWC*/0, 0, 0, 20, 25, 0, 1, 50, 15, 1, 0, 1, X/*AY */0, 10, 0, 0, 90, 0, 1, 25, 6, 1, 0, 0, X/*Gr */0, 100, 25, 0, 80, 5, 1, 25, 6, 1, 0, 0, X/*SA */5000, 5000, 100, 50000, 10000, 0, 55, 1, 500, 1, 0, 1, X/*LTr*/100, 5, 5, 20, 0, 20, 2, 1, 4, 1, 1, 0, X/*Otr*/ 100, 5, 5, 20, 0, 20, 2, 3, 3, 1, 0, 0, X/*DgT*/1000, 1000, 0, 1000, 200, 1000, 1, 800, 80, 1, 1, 0, X/*TD */1000, 1000, 0, 1000, 400, 1000, 2, 1200, 80, 1, 1, 0 X}; X Xchar *Shipnames[NUMSTYPES] = { X "Spore pod", X "Shuttle", X "Dreadnaught", X "Battleship", X "Interceptor", X "Cruiser", X "Destroyer", X "Fighter", X "Cargo ship", X "Explorer", X "Tanker", X "Station", X "Ob Asst Pltfrm", X "GODSHIP", X "Space mine", X "Space mirror", X "Habitat", X "Space telescope", X "Ground telescope", X "* T-R beam", X "Atmosph processor", X "Canister of dust", X "V.Neumann machine", X "* Planet bomb", X "* cloaking device", X "Mind control Lsr", X "Tox waste canistr", X "*Amulet of Yendor", X "gamma ray laser", X "Space Amoeba!", X "* Land Transport", X "* Ocean Transport", X "* Dirigable Trans.", X "audio-vibatory-\n physio-molecular\n transport device", X}; END_OF_FILE if test 3652 -ne `wc -c <'shipdata.h'`; then echo shar: \"'shipdata.h'\" unpacked with wrong size! fi # end of 'shipdata.h' fi if test -f 'ships.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'ships.h'\" else echo shar: Extracting \"'ships.h'\" \(4923 characters\) sed "s/^X//" >'ships.h' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X */ X X X#define STYPE_POD 0 X#define STYPE_SHUTTLE 1 X#define STYPE_DREADNT 2 X#define STYPE_BATTLE 3 X#define STYPE_INTCPT 4 X#define STYPE_CRUISER 5 X#define STYPE_DESTROYER 6 X#define STYPE_FIGHTER 7 X#define STYPE_CARGO 8 X#define STYPE_EXPLORER 9 X#define STYPE_TANKER 10 X#define STYPE_STATION 11 X#define STYPE_ASS 12 X#define STYPE_GOD 13 X#define STYPE_MINE 14 X#define STYPE_MIRROR 15 X#define STYPE_HABITAT 16 X X#define OTYPE_STELE 17 X#define OTYPE_GTELE 18 X#define OTYPE_TRACT 19 X#define OTYPE_AP 20 X#define OTYPE_CANIST 21 X#define OTYPE_VN 22 X#define OTYPE_PLBOMB 23 X#define OTYPE_CLOAK 24 X#define OTYPE_OMCL 25 X#define OTYPE_TOXWC 26 X#define OTYPE_AMULET 27 X#define OTYPE_GR 28 X#define OTYPE_AMOEBA 29 X#define OTYPE_LANDTR 30 X#define OTYPE_OCTR 31 X#define OTYPE_DIRTR 32 X#define OTYPE_TRANSDEV 33 X X#define ABIL_CARGO 0 X/*#define ABIL_STEALTH 1*/ X#define ABIL_DESTCAP 1 X#define ABIL_GUNS 2 X#define ABIL_FUELCAP 3 X#define ABIL_TECH 4 X#define ABIL_MAXCREW 5 X#define ABIL_ARMOR 6 X#define ABIL_COST 7 X#define ABIL_MASS 8 X#define ABIL_CANLAND 9 X#define ABIL_HASSWITCH 10 X#define ABIL_SPEED 11 X X#define NUMSTYPES (OTYPE_TRANSDEV+1) X#define NUMABILS (ABIL_SPEED+1) X X Xtypedef struct ship shiptype; Xtypedef struct orders ordertype; Xtypedef struct place placetype; X Xstruct orders { /* standing orders for ships, planets */ X unsigned bombard : 1; /* bombard planet we're on */ X}; X Xstruct ship { X float xpos,ypos; X float fuel,mass; X /*char name[NAMESIZE];*/ X /*us abils[NUMABILS-2]; /* only certain abilities are kept track*/ X unsigned short destshipno; /* destination ship # */ X unsigned short nextship; /* next ship in orbit around whatever */ X unsigned short prevship; /* prev ship in orbit around whatever */ X union { X ordertype o; /* standing orders for ship */ X struct a { /* if the ship is a Space Mirror */ X short shipno; /* aimed at what ship */ X char snum; /* aimed at what star */ X percent intensity; /* intensity of aiming */ X unsigned pnum : BITS_MAXPLANETS; /* aimed at what planet */ X unsigned level : 2; /* aimed at what level */ X } aimed_at; X struct o2 { X short number; /* for misc functions */ X short number2; /* again */ X } object; X struct am { X char psuedo1x,psuedo1y; /* x,y loc for psuedopods */ X char psuedo2x,psuedo2y; X char psuedo3x,psuedo3y; X unsigned dig : 1; /* trying to digest a planet */ X unsigned dest : 1; /* has a destination in mind */ X unsigned div : 1; /* trying to divide in two */ X } amoeba; X } orders; X char storbits; /* what star # orbits */ X char deststar; /* destination star */ X unsigned destpnum : BITS_MAXPLANETS; /* destination planet */ X unsigned pnumorbits : BITS_MAXPLANETS; /* # of planet if orbiting */ X unsigned damage : 7; /* amt of damage */ X unsigned rad : 7; /* irradiated */ X unsigned destruct : 16; /* stuff it's carrying */ X unsigned resource : 16; X unsigned popn : 16; /* crew */ X unsigned owner : BITS_MAXPLAYERS; /* owner of ship */ X unsigned speed : 3; /* what speed to travel at */ X /*unsigned augmented : 4; /* # of times augmented (max 10) ? */ X unsigned whatdest : 2; /* where going (same as Dir) */ X unsigned whatorbits : 2; /* where orbited (same as Dir) */ X unsigned type : 6; /* what type ship is */ X unsigned is_cloaked : 1; /* 1 bit: is cloaked ship */ X unsigned is_sheep : 1; /* 1 bit: is under influence of mind control */ X unsigned is_docked : 1; /* 1 bit: is landed on a planet or docked */ X unsigned notified : 1; /* 1bit: has been notified of something */ X unsigned is_dead : 1; /* 1 bit: is destroyed ship */ X unsigned is_examined : 1; /* 1 bit: has been examined */ X unsigned on : 1; /* on or off */ X}; X Xstruct place { /* used in function return for finding place */ X char snum; X char pnum; X short shipno; X shiptype *shipptr; X unsigned level : 2; /* .level: same as Dir */ X unsigned err : 1; /* if error */ X}; X X /* whether ship is an object or not */ X#define is_object(s) ((s)->type > STYPE_MIRROR) X X /* can takeoff & land, is mobile, etc. */ X#define speed_rating(s) (Shipdata[(s)->type][ABIL_SPEED]) X X /* has an on/off switch */ X#define has_switch(s) (Shipdata[(s)->type][ABIL_HASSWITCH]) X X /* can bombard planets */ X#define can_bombard(s) \ X ( ((s)->type < STYPE_MIRROR) && Shipdata[(s)->type][ABIL_GUNS]) X X /* can aim at things. */ X#define can_aim(s) ((s)->type>=STYPE_MIRROR && (s)->type<=OTYPE_TRACT) X X /* macro for killing a ship. !notified means we have not yet written it X to the dead_ship file. */ X#define kill_ship(s) ((s)->is_dead = 1, (s)->notified = 0) X Xextern placetype Getplace(); Xextern char *Dispplace(),*Dispshiporbits(),*prin_ship_orbits(), X *prin_aimed_at(), *prin_ship_dest(); Xextern int Shipdata[NUMSTYPES][NUMABILS]; Xextern char Shipltrs[]; Xextern char *Shipnames[]; Xextern float tele_range(), gun_range(); X END_OF_FILE if test 4923 -ne `wc -c <'ships.h'`; then echo shar: \"'ships.h'\" unpacked with wrong size! fi # end of 'ships.h' fi if test -f 'shlmisc.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'shlmisc.c'\" else echo shar: Extracting \"'shlmisc.c'\" \(4085 characters\) sed "s/^X//" >'shlmisc.c' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@ssyx) X * miscellaneous stuff included in the shell X */ X X#include "vars.h" X#include "races.h" X#include X#include X#include X#include X X XDontOwnErr(shipno) Xreg int shipno; X{ X printf("You don't own ship #%d.\n",shipno); X} X X Xint enufAP(AP, x) Xreg char *AP; Xreg int x; X{ X reg int blah; X X if (blah = (AP[Playernum] < x) ) { X printf("You don't have %d action points there.\n", x); X } X return (!blah); X} X X Xint Getracenum(login) Xreg char *login; X{ X reg int i = 0; X char s[LOGIN_NAME_SIZE]; X FILE *fd; X X fd = fopen(PLAYERDATAFL, "r"); X s[0] = '\0'; X X while (!feof(fd) && strcmp(s,login) ) { X i++; X fscanf(fd,"%s",s); X } X fclose(fd); X return( (strcmp(s,login)) ? 0 : i ); X} X X X/* returns player # from string containing that players name or #. */ X XGetPlayer(name, rnum, race) Xchar *name; Xint *rnum; Xracetype **race; X{ Xint numraces; Xregister int i,l; X X numraces = Numraces(); X *rnum = 0; X X if (isdigit(*name)) { X if ( (*rnum = atoi(name)) < 1 || *rnum > numraces) { X *rnum = -1; X return; X } else { X getrace(race, *rnum); X return; X } X } else { X l = strlen(name); X for (i=1; !(*rnum) && i<=numraces; i++) { X getrace(race, i); X if (!strncmp(name, (*race)->name, l)) { X printf(" player %d\n",i); X *rnum = i; X return; X } else X free(*race); X } X } X} X X Xint deductAPs(n, snum, sdata) Xint n, snum; Xint sdata; /* whether or not sdata is involved */ X{ X int deductAPs_stardata, mask; X X if (n) { X X mask = sigblock(SIGINT|SIGQUIT|SIGSTOP); X /* keep people from cheating */ X X openstardata(&deductAPs_stardata); X X if (!sdata) { X free(Stars[snum]); X getstar(deductAPs_stardata, &Stars[snum], snum); X X if (Stars[snum]->AP[Playernum] >= n) X Stars[snum]->AP[Playernum] -= n; X else { X Stars[snum]->AP[Playernum] = 0; X printf("WHOA! You cheater! Oooohh! OOOOH!\n I'm tellllllllliiiiiiinnnnnnnnnggggggggg!!!!!!!\n"); X } X X putstar(deductAPs_stardata, Stars[snum], snum); X X if (Dir.level!=LEVEL_UNIV && Dir.snum == snum) { X /* fix the prompt */ X sprintf(Dir.prompt + 4, "%02d", Stars[snum]->AP[Playernum]); X Dir.prompt[6] = ']'; /* fix bracket (made '\0' by sprintf)*/ X } X } else { X getsdata(deductAPs_stardata,&Sdata); X Sdata.AP[Playernum] -= n; X if (Sdata.AP[Playernum] < 0) X Sdata.AP[Playernum] = 0; X putsdata(deductAPs_stardata,&Sdata); X X if (Dir.level==LEVEL_UNIV) { X sprintf(Dir.prompt + 2, "%02d", Sdata.AP[Playernum]); X Dir.prompt[3] = ']'; X } X } X close(deductAPs_stardata); X sigsetmask(mask); X } X X} X X X XGetMapSector(pl, x, y) Xplanettype *pl; Xint *x, *y; X{ X char c='\0'; X bool first=0; X X while ((*x)<0 || (*x)>=pl->Maxx || (*y)<0 || (*y)>=pl->Maxy) { X X if (first && c!='?') X printf("Illegal value.\n"); X else X first = 1; X X printf(" what sector (0-%d,0-%d,'?' for map): ",pl->Maxx-1,pl->Maxy-1); X while ( !(isdigit(c=getchr()) || c=='?' || c=='-') ) X ; X if (c=='?') { X getchr(); /* get \n */ X if (pl->info[Playernum-1].explored) X show_map(pl,0); X else X printf("\n\n\n*** No map available-- you haven't explored this planet yet. ***\n\n\n"); X } else if (isdigit(c) || c=='-') { X ungetc(c,stdin); X scanf("%d,%d", x, y); X getchr(); X } X X } X X} X X X Xvoid dots(i) Xregister int i; X{ Xregister int j; X X for (j=0; jhomesystem; X printf("%2d. %10s is %-15s on star %-13s planet %s\n",i,s,(*race)->name,Stars[home]->name,Stars[home]->pnames[(*race)->homeplanetnum]); X free(race); X i++; X } X fclose(fd); X} END_OF_FILE if test 4085 -ne `wc -c <'shlmisc.c'`; then echo shar: \"'shlmisc.c'\" unpacked with wrong size! fi # end of 'shlmisc.c' fi if test -f 'vars.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'vars.h'\" else echo shar: Extracting \"'vars.h'\" \(4506 characters\) sed "s/^X//" >'vars.h' <<'END_OF_FILE' X/* X * Galactic Bloodshed (Robert Chansky, smq@b) X * main bunch of variables X */ X X/* bit routines stolen from UNIX */ X#define setbit(a,i) ((a)[(i)/8] |= 1<<((i)%8)) X#define clrbit(a,i) ((a)[(i)/8] &= ~(1<<((i)%8))) X#define xbit(a,i) ((a)[(i)/8] ^= (1<<((i)%8))) X#define isset(a,i) ((a)[(i)/8] & (1<<((i)%8))) X#define isclr(a,i) (((a)[(i)/8] & (1<<((i)%8))) == 0) X#define howmanybytes(x) (((x)+7)/8) X X#define Bzero(x) bzero( (char *)&(x), sizeof(x) ) X#define Malloc(x) (x *)malloc( sizeof(x) ) X X#include "files.h" X#include "tweakables.h" X#include X#include X#include X X X#define LEVEL_UNIV 0 X#define LEVEL_STAR 1 X#define LEVEL_PLAN 2 X/*#define LEVEL_MOON 3*/ X#define LEVEL_SHIP 3 X X#define MAXPLAYERS 30 X#define BITS_MAXPLAYERS 5 /* # bits req'd to represent */ X Xtypedef struct sector sectortype; Xtypedef struct planet planettype; Xtypedef struct star startype; X X Xstruct plinfo { /* planetary stockpiles */ X unsigned fuel : 17; /* fuel for powering things */ X unsigned destruct : 17; /* destructive potential */ X unsigned resource : 17; /* resources in storage */ X unsigned numsectsowned : 10; X unsigned comread : 7; /* combat readiness */ X unsigned mob_set : 7; /* mobilization target */ X /*unsigned quota_resource : 7; X unsigned quota_destruct : 7; X unsigned quota_fuel : 7;*/ X unsigned explored : 1; /* 1 bit: explored by each player */ X unsigned autorep : 3; /* player wants autoreport */ X unsigned spied_on : 1; /* spied on */ X}; X Xstruct sector { X unsigned eff : 7; /* efficiency (0-100) */ X unsigned resource : 8; X unsigned fert : 7; /* max popn is proportional to this */ X unsigned popn : 10; X unsigned mobilization : 7; /* percent popn is mobilized for war */ X unsigned owner : BITS_MAXPLAYERS; /* owner of place */ X unsigned is_wasted : 1; /* 1 bit: is a wasted sector */ X /*unsigned is_cloaked : 1; /* 1 bit: is cloaked sector */ X unsigned des : 3; /* kind of land the place is */ X unsigned VN : 1; /* has a VN machine on it */ X unsigned amoeba : 1; /* has an amoeba on it */ X}; X X Xstruct planet { X float xpos,ypos; /* x,y relative to orbit */ X char conditions[TOXIC+1]; /* atmospheric conditions for terraforming */ X /*int nummoons;*/ X /*int moonpos[MAXMOONS]; /* filepos moons or ast around it */ X us ships; /* first ship in orbit (to be changed) */ X percent Maxx,Maxy; /* size of map */ X int sectormappos; /* file posn for sector map */ X char rottimer; /* same */ X struct plinfo info[MAXPLAYERS-1]; /* planetary stockpiles */ X unsigned popn : 20; X unsigned maxpopn : 20; /* maximum population */ X unsigned slaved_to : BITS_MAXPLAYERS; /* owner of place */ X unsigned type : 3; /* what type planet is */ X unsigned expltimer : 3; /* timer for explorations */ X unsigned is_explored : 1; /* is explored by owner */ X unsigned digested : 1; /* digested by space amoeba */ X unsigned is_sheep : 1; /* 1 bit: is emotion suppressed */ X}; X Xstruct star { X float xpos,ypos; X char stability; /* how close to nova it is */ X char name[NAMESIZE]; X char numplanets; /* # of same */ X char pnames[MAXPLANETS][NAMESIZE]; /* names of planets */ X int planetpos[MAXPLANETS]; /* file posns of planets */ X us ships; /* 1st ship in orbit */ X float gravity; /* attraction of star in "Standards". */ X char explored[howmanybytes(MAXPLAYERS)]; /* who's been here */ X char inhabited[howmanybytes(MAXPLAYERS)]; /* who lives here now */ X char AP[MAXPLAYERS]; /* action pts alotted */ X unsigned nova_stage : 4; /* stage of nova */ X /*unsigned is_cloaked : 1; /* pl is cloaked */ X}; X X X X /* this data will all be read at once */ Xstruct stardata { X int numstars; /* # of stars */ X us ships; /* 1st ship in orbit */ X char AP[MAXPLAYERS]; /* Action pts for each player */ X} Sdata; X Xstruct directory { X unsigned level : 2; /* what directory level */ X int snum; /* what star system obj # (level=0) */ X int pnum; /* number of planet */ X int shipno; /* # of ship */ X /*int moon; /* ptr to moon of planet obj # (lev=2)*/ X char prompt[NAMESIZE+NAMESIZE+NAMESIZE+5]; /* just to be safe */ X float lastx, lasty, zoom; /* last coords for zoom */ X} Dir; X X Xsectortype Smap[(MAX_X+1)*(MAX_Y+1) + 1]; X Xstartype *Stars[NUMSTARS]; X Xint Playernum; /* what player you are */ X Xextern float powscale(),logscale(),float_rand(),gravity(); Xchar *malloc(); END_OF_FILE if test 4506 -ne `wc -c <'vars.h'`; then echo shar: \"'vars.h'\" unpacked with wrong size! fi # end of 'vars.h' fi echo shar: End of archive 6 \(of 8\). cp /dev/null ark6isdone MISSING="" for I in 1 2 3 4 5 6 7 8 ; do if test ! -f ark${I}isdone ; then MISSING="${MISSING} ${I}" fi done if test "${MISSING}" = "" ; then echo You have unpacked all 8 archives. rm -f ark[1-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0