home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Star Trek IG style by Kevin Moody */ #include "st1b.h" main(argc, argv) int argc; char *argv[]; { int i; char c; stp = string; calltype = 1; loc = 0; for(i=1; i<argc; i++) { if(!strcmp(argv[i], "LOCAL")) { calltype=0; loc=1; } if(!strcmp(argv[i], "local")) { calltype=0; loc=1; } } foremout("G#I>0:s>0:k>0:C>2,0:B>0,190,640,200,0:S>0,0,0,0:S>1,0,0,0:S>2,0,0,0:S>3,0,0,0:C>2,2:B>20,20,620,32,0:C>2,1:B>20,32,620,44,0:G>1,3,20,20,620,44:&>44,150,24,0,G,4,2,3,20,x:C>2,0:H>0:B>20,176,620,188,0:C>2,3:\r "); foremout("G#B>20,20,300,103,0:L>35,32,41,26:D>47,32:D>32,28:D>50,28:D>35,32:L>38,29,45,29:G>1,3,32,26,50,32:&>32,220,46,0,G,4,2,3,x,26:G>1,3,32,26,280,32:&>26,80,15,0,G,4,2,3,32,x:G>1,3,32,26,239,32:\r "); foremout("G#&>34,76,15,0,G,4,2,3,55,x:G>1,3,20,20,620,200:s>0:S>1,6,6,6:S>2,6,0,0:S>3,0,0,4:E>0,20,0:&>200,20,1,0,G,4,2,3,20,x:E>0,10,0:b>8:W>250,12,STAR BATTLE@\r "); foremout("G#W>230,195,By Kevin Moody@C>2,0:b>17:s>0:B>0,190,640,199,0:\r "); foremout("G#b>22,12:&>1,1,1,0,n,60,12,1,15,55,220,0:12,1,15,60,80,1:12,1,15,65,255,1:12,1,15,64,100,1:12,1,15,60,60,1:12,1,15,57,60,1:12,1,15,62,60,1:12,1,15,67,255,1:12,1,15,67,60,1:12,1,15,71,300,1:\r "); load(); planet(); foremout("G#I>0:s>0:k>0:S>0,7,7,7:S>2,0,0,4:S>3,4,4,7:C>2,2:A>2,8,1:B>0,0,639,199,0:C>2,3:A>2,7,1:B>5,4,275,134,1:C>2,2:A>2,8,1:B>12,8,267,130,1:C>2,3:A>2,6,1:B>284,4,634,138,0:C>2,1:A>2,8,1:B>308,22,616,132,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:A>2,5,1:A>2,5,1:O>300,15,7:O>621,15,7:C>1,0:&>352,572,44,0,L,4,x,22,x,132:&>44,110,22,0,L,4,308,x,615,x:C>2,1:A>2,4,1:B>4,140,636,197,1:E>1,10,0:M>2:C>3,1:W>393,18,Ship View Screen@\r "); foremout("G#M>1:C>2,0:A>2,4,1:B>17,173,623,194,1:E>0,10,0:M>2:C>3,3:W>95,21,Ship Status@E>4,9,0:C>3,0:W>25,38,STRUCTURE@W>25,46,PHASORS@W>25,54,TORPEDOS@W>25,62,ENGINES@W>25,70,CLASS@W>25,78,SCORE@W>25,86,CRYSTALS@\r "); foremout("G#W>25,118,CAPT.@M>1:C>2,1:A>2,6,1:B>18,144,623,169,1:C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#M>2:C>3,1:A>2,6,1:W>52,160,Cruise@W>168,160,Warp@W>285,160,Scan@W>402,160,Quit@W>519,160,Help@M>1:C>2,1:A>1,1,1:O>209,91,33:E>4,9,0:M>2:C>3,0:W>87,95,Turns Left@\r "); foremout("G#X>4,0,32,147,123,167,1,C:X>4,1,149,147,240,167,1,W:X>4,2,266,147,350,167,1,S:X>4,3,383,147,474,167,1,Q:X>4,4,500,147,591,167,1,H:p>5,22:\r "); draw(p->px, YOU); update(); while (zap != 1) { zap = 0; holy = 1; foremout("G#T>1,6,4:b>7:<>1,2,1:\r "); c = foremgetc(); /* Respond to mouse button */ if(c=='C') /* Cruise */ { foremout("G#X>4,9999:S>3,6,4,1:S>2,0,4,3:C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:M>2:C>3,1:A>2,6,1:W>52,160,Up@W>168,160,Down@W>285,160,Left@W>402,160,Right@W>519,160,Bridge@\r "); foremout("G#X>4,0,32,147,123,167,1,U:X>4,1,149,147,240,167,1,D:X>4,2,266,147,350,167,1,L:X>4,3,383,147,474,167,1,R:X>4,4,500,147,591,167,1,B:\r "); cruise(); } if(c=='W') warp(); if(c=='S') scan(); if(c=='Q') zap=1; if(c=='?') zap=2; if(zap==0) { /* define and draw main buttons */ foremout("G#X>4,9999:S>2,0,0,4:S>3,4,4,7:X>4,47,1,1,638,198,1,?:C>2,1:A>2,8,1:B>308,22,616,132,1:C>1,0:&>352,572,44,0,L,4,x,22,x,132:&>44,110,22,0,L,4,308,x,615,x:\r "); foremout("G#C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:M>2:C>3,1:A>2,6,1:W>52,160,Cruise@W>168,160,Warp@W>285,160,Scan@W>402,160,Quit@W>519,160,Help@\r "); foremout("G#X>4,0,32,147,123,167,1,C:X>4,1,149,147,240,167,1,W:X>4,2,266,147,350,167,1,S:X>4,3,383,147,474,167,1,Q:X>4,4,500,147,591,167,1,H:\r "); draw(p->px, YOU); update(); } } /* Player chose to quit game */ save(); foremout("G#:I>0:s>0:S>2,7,0,0:S>3,0,7,0:k>1:\r "); Pterm(0); } cruise() { int x; char c; /* draw and define cruise buttons - arrows */ do{ update(); foremout("G#<>1,2,1:\r "); c=foremgetc(); old = x = p->px; if(c=='U') /* move up 1 space */ { if(x<7) x += 28; else x -= 7; } if(c=='D') { if(x>27) x -= 28; else x += 7; } if(c=='L') { t = x % 7; if(t==0) x += 6; else x -= 1; } if(c=='R') { t = (x+1) % 7; if(t==0) x -= 6; else x += 1; } if(c=='B') break; if(c=='?') ; if(p->energy==0) rebuild(ENGINES); if(p->energy > 0) { if(c!='?') foremout("G#b>12:\r "); draw(old, NONE); draw(x, YOU); p->px = x; if(x!=old) { turn(); p->energy -= 10; } if(p->energy <= 0) p->energy=0; } }while(); nocry = 0; } warp() { int dep, rer=0, where; foremout("G#M>1:C>2,0:A>2,4,1:B>17,173,623,194,1:\r "); do{ foremout("G#p>5,22:\r Warp to Sector (1 - 35): (0=Exit) "); foremin(stp); sscanf(string,"%d", &where); if(where==0) break; if((where < 0) || (where > 35)) continue; if(p->energy==0) rebuild(ENGINES); if(p->energy > 0) { foremout("G#b>5:\r "); old = p->px; p->px = where - 1; draw(old, NONE); draw(p->px,YOU); if(p->px!=old) p->energy -= 30; nocry = 0; update(); } break; }while(); } draw(m,n) int m, n; { int x; static char eex[10], eey[10], bigy[30]; for (x=0;x<30;x++) bigy[x]='\0'; grid(m); itoa(eex, a); itoa(eey, b); foremout("G#M>1:H>0:A>1,1,1:\r "); switch(n) { case MOON: foremout("G#C>2,0:\r "); break; case OTHER: foremout("G#H>1:C>2,3:\r "); break; case ALIEN: foremout("G#H>1:C>2,2:\r "); break; case YOU: foremout("G#H>1:C>2,0:\r "); break; case NONE: foremout("G#C>2,1:\r "); break; } strcpy(bigy,"G#O>"); strcat(bigy,eex); strcat(bigy,","); strcat(bigy,eey); strcat(bigy,",12:\r "); foremout(bigy); /* radius of old circle */ } scan() { int planet = 0, x, hm=0; char i; setscan(); do{ combat(); update(); foremout("G#<>1,2,1:\r "); i=foremgetc(); if(i=='O') /* orbit nearby planet */ { for(x=0; x<35; x++) if(brd[p->px][x] == MOON) planet = TRUE; if(planet == FALSE) { foremout("G#p>5,22:\r No Planet in this sector...."); foremout("G#t>1:\r "); } else {orbit(); setscan(); } } if(i=='A') { attack(); setscan(); } if(i=='B') break; /* Bridge */ if(i=='C') /* communicate */ { for(x=0; x<35; x++) if(brd[(p->px)][x] == ALIEN) { foremout("G#p>5,22:\r Aliens attacking...Communications aborted! G#t>1:\r "); combat(); hm=1; break; } if(!hm) showp(); } if(i=='?') ; foremout("G#p>5,22:\r "); }while(); } orbit() { int cry, x, fel, treaty=0, recv, barb, mu, mine=0; static char eex[10], c, st[2], bigy[10]; for (x=0; x< MAX; x++) { if(brd[(p->px)][x] == ALIEN) { foremout("G#p>5,22:\r Aliens attacking...Planet Orbiting is aborted!"); foremout("G#t>1:p>5,22:\r "); return; } } fel = rnd(10); cry = rnd(200) + 1000*(pl[p->px].class) + rnd(5); mu = pl[p->px].align; /* Erase sectors with black fill box and draw increasing fill circle*/ foremout("G#X>4,9999:S>2,4,0,0:C>2,1:A>2,8,1:B>308,22,616,132,1:C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:M>2:C>3,1:A>2,6,1:W>52,160,Treaty@W>168,160,Comm@W>285,160,Mine@W>402,160,Bridge@\r "); barb = rnd(4); if(barb==0) barb=2; if(barb==1) barb=3; itoa(st, barb); strcpy(bigy, "G#C>2,"); strcat(bigy,st); strcat(bigy,":\r "); foremout(bigy); foremout("G#&>3,120,12,0,O,3,462,77,x:X>4,0,32,147,123,167,1,T:X>4,1,149,147,240,167,1,C:X>4,2,266,147,350,167,1,M:X>4,3,383,147,474,167,1,B:\r "); p->energy -= 5; if(p->energy <= 0) p->energy=0; do{ update(); foremout("G#p>5,22:<>1,2,1:\r "); c=foremgetc(); if(c=='T') /* Make peace treaty with planet */ { treaty = 1; mine =1; turn(); p->energy -= 5; if(p->energy <= 0) p->energy=0; foremout("G#p>5,22:\r Peace Treaty is acknowledged and accepted"); foremout("G#t>1:\r "); } if(c=='C') /* Comm link to get market stats */ { if( ( mu==2 || ( mu==1 && fel<6 ) ) && !treaty ) { foremout("G#p>5,22:\r Planet demands Treaty..Planet attacks!"); foremout("G#t>1:p>5,22:\r "); if(p->shield > 0) p->shield -= rnd(50); if(p->shield <= 0) p->shield = 0; rebuild(); } else { foremout("G#b>8:\r "); foremout("G#p>5,22:\r Planet Market Statistics..."); planp(cry); mine = 1; } } if(c=='M') /* Mine planet for crystals */ { if(mine) { foremout("G#b>12:\r "); turn(); recv = (cry - 10*(pl[p->px].align))/100 + rnd(10); foremout("G#p>5,22:\r Amount of Crystals mined from planet is "); if(recv<0) recv=0; itoa(eex, recv); foremout(eex); foremout("G#t>1:\r "); p->crystal += recv; } else { foremout("G#p>5,22:\r Planet demands Treaty..Planet attacks!"); foremout("G#t>1:\r "); if(p->shield > 0) p->shield -= rnd(50); if(p->shield <= 0) p->shield = 0; rebuild(); } } if(c=='B') break; if(c=='?') ; }while(); } setscan() { int x, y, ct; foremout("G#X>4,9999:S>3,6,4,1:S>2,4,0,0:X>4,47,1,1,638,198,1,?:C>2,1:A>2,8,1:B>308,22,616,132,1:C>1,0:&>352,572,44,0,L,4,x,22,x,132:&>44,110,22,0,L,4,308,x,615,x:\r "); foremout("G#C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:M>2:C>3,1:A>2,6,1:E>0,9,0:W>52,160,Comm@W>168,160,Orbit@W>285,160,Attack@W>402,160,Bridge@W>519,160,Help@\r "); foremout("G#X>4,0,32,147,123,167,1,C:X>4,1,149,147,240,167,1,O:X>4,2,266,147,350,167,1,A:X>4,3,383,147,474,167,1,B:X>4,4,500,147,591,167,1,H:\r "); turn(); more = 1; draw(p->px, NONE); for (x=0; x<pc; x++) if (pl[x].ppx == p->px) draw(pl[x].ppy, MOON); for (x=0; x<num_recs; x++) if (u[x].px == p->px) if (strcmp(u[x].name,user)!=0) { draw(u[x].py, OTHER); strcpy(others[more], u[x].name); ++more; } if(holy) { ct = anum = rnd(3); while(ct) { y = rnd(35); if(brd[(p->px)][y] == NONE) { brd[(p->px)][y] = ALIEN; draw(y, ALIEN); --ct; } } } holy = 0; x = 0; do { y = rnd(35); if(brd[(p->px)][y] == NONE) { brd[(p->px)][y] = YOU; p->py = y; draw(y, YOU); x = 1; } } while (x == 0); for (x=0; x<MAX; x++) if (brd[p->px][x] == ALIEN){ draw(x, ALIEN); } } attack() { static int x, miss, deter, dmg, zed; char c; foremout("G#X>4,9999:S>3,6,4,1:S>2,4,0,0:X>4,47,1,1,638,198,1,?:C>2,1:A>2,8,1:B>308,22,616,132,1:\r "); foremout("G#C>2,3:A>2,8,1:B>32,147,123,167,1:B>149,147,240,167,1:B>266,147,350,167,1:B>383,147,474,167,1:B>500,147,591,167,1:\r "); foremout("G#X>4,47,1,1,638,198,1,?:M>2:C>3,1:A>2,6,1:W>52,160,Phasors@W>168,160,Torpedos@W>285,160,Bridge@\r "); foremout("G#X>4,0,32,147,123,167,1,P:X>4,1,149,147,240,167,1,T:X>4,2,266,147,350,167,1,B:\r "); if(alock==100) { showp(); if(its==0) return; aatk = TRUE; } foremout("G#M>1:C>2,3:A>1,1,1:Q>455,44,32,8:C>2,2:A>1,1,1:Q>455,44,18,3:C>2,3:A>3,5,1:B>449,50,459,75,0:T>2,1,17:K>454,105,65,0,175:C>2,2:A>2,8,1:Q>454,76,83,9:\r "); foremout("G#C>2,1:A>2,6,1:B>387,74,518,79,0:C>2,1:A>2,4,1:O>388,106,19:O>519,106,19:T>2,1,1:\r "); do{ update(); foremout("G#p>5,22:<>1,2,1:\r "); c=foremgetc(); if(c=='T') { if(p->torpedo == 0 ) rebuild(TORPEDOS); if(p->torpedo > 0) { foremout("G#b>18:t>1:\r "); /* 10 - 60 points */ dmg = 10 + rnd(50); p->torpedo -= 1; if(p->torpedo < 0) p->torpedo = 0; } } if(c=='P') { if(p->phasor == 0 ) rebuild(PHASORS); if(p->phasor > 0) { foremout("G#b>9:t>1:\r "); /* 5 - 30 points */ dmg = 5 + rnd(25); p->phasor -= 1; if(p->phasor < 0) p->phasor = 0; } } if(c=='?') ; /* OPPS */ if(c=='B') break; /* Back to Bridge */ turn(); deter = rnd(10); if(deter > 2) { if(aflag) a_dam -= dmg; if(aatk) u[q].shield -= dmg; if(u[q].shield <=0 && u[q].crystal >4) { u[q].shield = 200; u[q].crystal -= 5; } if(a_dam <= 0 || u[q].shield <= 0) { if(aflag) { p->score += 200; brd[p->px][alock] = NONE; } if(aatk) { p->score += 2000; brd[p->px][(u[q].py)] = NONE; u[q].class=0;} foremout("G#b>6:&>0,7,1,20,S,4,2,x,0,0:&>7,0,1,20,S,4,2,x,0,0:S>2,4,0,0:C>2,1:A>1,1,1:&>3,120,12,0,Q,4,462,77,x,50:b>6:\r "); foremout("G#p>5,22:\r GOT HIM!"); a_dam = 60; zed = 1;} if(!zed) foremout("G#p>5,22:b>6:&>0,7,1,20,S,4,2,x,0,0:&>7,0,1,20,S,4,2,x,0,0:S>3,6,4,1:S>2,4,0,0:\r Capt, we've HIT our target"); } if(deter < 3) foremout("G#p>5,22:\r We missed our Target, Capt"); combat(); zed = 0; if(alock!=100){ foremout("G#M>1:C>2,3:A>1,1,1:Q>455,44,32,8:C>2,2:A>1,1,1:Q>455,44,18,3:C>2,3:A>3,5,1:B>449,50,459,75,0:T>2,1,17:K>454,105,65,0,175:C>2,2:A>2,8,1:Q>454,76,83,9:\r "); foremout("G#C>2,1:A>2,6,1:B>387,74,518,79,0:C>2,1:A>2,4,1:O>388,106,19:O>519,106,19:T>2,1,1:\r "); } }while(); aatk = 0; } combat() { int chance, x; aflag = 0; alock=100; foremout("G#t>1:p>5,22:\r "); for(x=0; x<35; x++) if(brd[(p->px)][x] == ALIEN) { aflag = 1; alock = x; } if(aflag==1 || aatk==1) { foremout("G#b>0:\r "); chance = rnd(10); if (chance > 2) { /* 80% chance its a hit */ foremout("G#b>6:\r "); foremout("G#p>5,22:&>0,7,1,20,S,4,1,x,0,0:&>7,0,1,20,S,4,1,x,0,0:S>1,0,0,0:S>0,7,7,7:\r Computer reports damage to our structure Capt. "); if(aatk) p->shield -= (5 + rnd(50)); if(aflag) p->shield -= (5 + rnd(25)); if(p->shield <= 0) { p->shield = 0; rebuild(SHIELDS); } } if(chance < 3) { foremout("G#p>5,22:\r The enemy has missed their attack "); foremout("G#t>1:\r "); } } } planp(dilith) int dilith; { int x; static char eex[10], bigy[80], c; foremout("G#M>2:A>0,1,1:B>317,26,607,33,0:E>1,8,0:C>3,0:W>328,32,ALIGN CLASS CRYSTALS NAME@E>0,8,0:\r "); strcpy(bigy,"G#W>328,44,"); switch(pl[p->px].align) { case 0: strcat(bigy, "FREINDLY "); break; case 1: strcat(bigy, "NUETRAL "); break; case 2: strcat(bigy, "HOSTILE "); break; } switch(pl[p->px].class) { case 0: strcat(bigy, " POOR "); break; case 1: strcat(bigy, " NORMAL "); break; case 2: strcat(bigy, " RICH "); break; } itoa(eex, dilith); strcat(bigy, eex); strcat(bigy, " "); strcat(bigy, pl[p->px].name); strcat(bigy,"@\r "); foremout(bigy); } showp() { int x, y, z, poe=42, gain=0, offs=6; static char eex[10], eey[10], eez[10], bigy[80], c; foremout("G#b>8:M>1:C>2,1:A>2,8,1:B>308,22,616,132,1:M>1:C>2,2:A>0,1,1:H>1:B>317,26,607,33,0:B>317,36,606,130,0:E>1,8,0:C>3,0:W>328,32,LIST CLASS CRYSTALS NAME@E>0,8,0:\r "); for(x=0; x<more; x++) { for(y=0; y<num_recs; y++) { if (strcmp(others[x],u[y].name)==0) { strcpy(bigy,"G#W>328,"); ++gain; itoa(eex, poe); strcat(bigy, eex); strcat(bigy, ","); poe += offs; itoa(eey, gain); strcat(bigy, eey); strcat(bigy, " "); switch(u[y].class) { case 1: strcat(bigy, "FEDER "); break; case 2: strcat(bigy, "KLING "); break; case 3: strcat(bigy, "ROMUL "); break; } itoa(eez, u[y].crystal); strcat(bigy, eez); strcat(bigy," "); strcat(bigy, u[y].name); strcat(bigy,"@\r "); foremout(bigy); }}} if(gain!=0) { do { foremout("G#p>5,22:\r Select player by his number above. (0 = Exit) "); foremin(stp); sscanf(string,"%d", &its); if(its<=0) {its=0; break;} if(its>more) continue; for(x=0; x<num_recs; x++) if (strcmp(others[its],u[x].name)==0) q = x; foremout("G#p>5,22:\r "); foremout(u[q].name); foremout(" has his ship set on AUTO ATTACK "); }while(); } if(gain==0) { foremout("G#M>1:C>2,0:A>2,4,1:B>17,173,623,194,1:p>5,22:\r "); foremout("G#p>5,22:\r Your all alone here. "); its=0; } } grid(pos) /* look up table for grid position */ int pos; { switch(pos) { case 0: a=330 + 0*44; b=33 + 0*22; break; case 1: a=330 + 1*44; b=33 + 0*22; break; case 2: a=330 + 2*44; b=33 + 0*22; break; case 3: a=330 + 3*44; b=33 + 0*22; break; case 4: a=330 + 4*44; b=33 + 0*22; break; case 5: a=330 + 5*44; b=33 + 0*22; break; case 6: a=330 + 6*44; b=33 + 0*22; break; case 7: a=330 + 0*44; b=33 + 1*22; break; case 8: a=330 + 1*44; b=33 + 1*22; break; case 9: a=330 + 2*44; b=33 + 1*22; break; case 10: a=330 + 3*44; b=33 + 1*22; break; case 11: a=330 + 4*44; b=33 + 1*22; break; case 12: a=330 + 5*44; b=33 + 1*22; break; case 13: a=330 + 6*44; b=33 + 1*22; break; case 14: a=330 + 0*44; b=33 + 2*22; break; case 15: a=330 + 1*44; b=33 + 2*22; break; case 16: a=330 + 2*44; b=33 + 2*22; break; case 17: a=330 + 3*44; b=33 + 2*22; break; case 18: a=330 + 4*44; b=33 + 2*22; break; case 19: a=330 + 5*44; b=33 + 2*22; break; case 20: a=330 + 6*44; b=33 + 2*22; break; case 21: a=330 + 0*44; b=33 + 3*22; break; case 22: a=330 + 1*44; b=33 + 3*22; break; case 23: a=330 + 2*44; b=33 + 3*22; break; case 24: a=330 + 3*44; b=33 + 3*22; break; case 25: a=330 + 4*44; b=33 + 3*22; break; case 26: a=330 + 5*44; b=33 + 3*22; break; case 27: a=330 + 6*44; b=33 + 3*22; break; case 28: a=330 + 0*44; b=33 + 4*22; break; case 29: a=330 + 1*44; b=33 + 4*22; break; case 30: a=330 + 2*44; b=33 + 4*22; break; case 31: a=330 + 3*44; b=33 + 4*22; break; case 32: a=330 + 4*44; b=33 + 4*22; break; case 33: a=330 + 5*44; b=33 + 4*22; break; case 34: a=330 + 6*44; b=33 + 4*22; break; } } turn() { static char st[5], bigy[70]; strcpy(bigy,"G#M>1:C>2,3:A>1,1,1:V>209,91,33,"); itoa(st, bang); strcat(bigy, st); strcat(bigy, ","); itoa(st, eang); strcat(bigy, st); strcat(bigy, ":\r "); foremout(bigy); bang += 10; eang += 10; turn_left -= 1; if(turn_left == 0) { foremout("G#p>5,22:\r You have used up all your TURNS -- Sorry Capt. G#t>2:\r "); end_game(); } } update() { int slev, x; static char st[5], bigy[27]; foremout("G#M>2:C>2,0:A>0,1,1:B>167,32,263,38,0:B>167,40,263,46,0:B>167,48,263,54,0:B>167,56,263,62,0:\r "); foremout("G#M>1:C>2,1:A>1,1,1:B>168,33,262,37,0:B>168,41,262,45,0:B>168,49,262,53,0:B>168,57,262,61,0:M>1:C>2,2:A>1,1,1:B>102,30,164,91,0:\r "); foremout("G#c>0,1:c>1,0:p>14,4:\r "); itoa(st,p->shield); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,5:\r "); itoa(st,p->phasor); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,6:\r "); itoa(st,p->torpedo); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,7:\r "); itoa(st,p->energy); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,8:\r "); switch(p->class) { case 0: /* clear screen / quit game */ break; case 1: foremout("Federation "); break; case 2: foremout("Klingon "); break; case 3: foremout("Romulan "); break; } foremout("G#p>14,9:\r "); itoa(st,p->score); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,10:\r "); itoa(st,p->crystal); foremout( st ); for(x=0;x<5;x++) st[x]='\0'; foremout("G#p>14,14:\r "); foremout(user); foremout("G#C>2,3:\r "); slev = (((p->phasor)*94)/ptot) + 168; itoa(st, slev); strcpy(bigy,"G#B>168,41,"); strcat(bigy, st); strcat(bigy, ",45,0:\r "); foremout(bigy); slev = (((p->shield)*94)/stot) + 168; itoa(st, slev); strcpy(bigy,"G#B>168,33,"); strcat(bigy, st); strcat(bigy, ",37,0:\r "); foremout(bigy); slev = ((p->energy)*94)/etot + 168; itoa(st, slev); strcpy(bigy,"G#B>168,57,"); strcat(bigy, st); strcat(bigy, ",61,0:\r "); foremout(bigy); slev = ((p->torpedo)*94)/ttot + 168; itoa(st, slev); strcpy(bigy,"G#B>168,49,"); strcat(bigy, st); strcat(bigy, ",53,0:\r "); foremout(bigy); foremout("G#M>1:C>2,0:A>2,4,1:B>17,173,623,194,1:c>0,0:c>1,3:p>5,22:\r "); } rebuild(it) int it; { switch(it) { case SHIELDS: if(p->shield==0 && p->crystal > 4) { p->crystal -= 5; p->shield = stot; update(); } else { foremout("G#p>5,22:\r You have been destroyed. Better Luck Next Time! G#t>1:\r "); p->class = 0; end_game(); } break; case TORPEDOS: if(p->torpedo==0 && p->crystal > 4) { p->crystal -= 5; p->torpedo = ttot; update(); } else foremout("G#p>5,22:\r We have no more crystals to replenish torpedos! "); break; case ENGINES: if(p->energy==0 && p->crystal > 4) { p->crystal -= 5; p->energy = etot; update(); } else foremout("G#p>5,22:\r We have no more crystals to supply energy! "); break; case PHASORS: if(p->phasor==0 && p->crystal > 4) { p->crystal -= 5; p->phasor = ptot; update(); } else foremout("G#p>5,22:\r We have no more crystals to replenish phasor banks! "); break; } } end_game() { save(); foremout("G#:I>0:s>0:S>2,7,0,0:S>3,0,7,0:k>1:\r "); Pterm(0); } add_p() { int x; x = num_recs; do { u[x].px = rnd(MAX); u[x].py = rnd(MAX); } while (brd[ (u[x].px )][ (u[x].py )] != NONE); brd[ (u[x].px )][ (u[x].py )] = YOU; strcpy(u[x].name, user); u[x].energy = etot; u[x].phasor = ptot; u[x].torpedo = ttot; u[x].shield = stot; u[x].crystal = 5; u[x].score = 0; u[x].class = rnd(3) + 1; p = &u[x]; ++num_recs; } load() { FILE *p_file; int x, found=0; get_foremdat(); if((p_file = fopen("trek.dat", "r")) == NULL) { add_p(); save(); return; } fscanf(p_file, "%d", &num_recs); for (x=0; x<num_recs; x++) { fscanf(p_file, "%s", u[x].name); fscanf(p_file, "%d", &u[x].px); fscanf(p_file, "%d", &u[x].py); fscanf(p_file, "%d", &u[x].energy); fscanf(p_file, "%d", &u[x].phasor); fscanf(p_file, "%d", &u[x].torpedo); fscanf(p_file, "%d", &u[x].shield); fscanf(p_file, "%d", &u[x].crystal); fscanf(p_file, "%d", &u[x].score); fscanf(p_file, "%d", &u[x].class); fscanf(p_file, "%s", u[x].rec_messg); brd[(u[x].px)][(u[x].py)] = OTHER; if (strcmp(u[x].name, user)==0) { brd[(u[x].px)][(u[x].py)] = YOU; p = &u[x]; /* player p is present */ found = 1; } } if(found!=1) /* player is new */ add_p(); save(); fclose(p_file); } save() { FILE *p_file; static int x, killp, count; for(x=0; x<num_recs; x++) { if(u[x].class == 0) ++killp; } count = num_recs - killp; p_file = fopen("trek.dat", "w"); fprintf(p_file, "%d\n", count); for (x=0; x<num_recs; ++x) { if(u[x].class != 0) { fprintf(p_file, "%s\n", u[x].name); fprintf(p_file, "%d\n", u[x].px); fprintf(p_file, "%d\n", u[x].py); fprintf(p_file, "%d\n", u[x].energy); fprintf(p_file, "%d\n", u[x].phasor); fprintf(p_file, "%d\n", u[x].torpedo); fprintf(p_file, "%d\n", u[x].shield); fprintf(p_file, "%d\n", u[x].crystal); fprintf(p_file, "%d\n", u[x].score); fprintf(p_file, "%d\n", u[x].class); fprintf(p_file, "%s\n", u[x].rec_messg); } } fclose(p_file); } planet() { FILE *p_file; int x=0, peer, tip=0; if( (p_file = fopen("planet.dat", "r"))==NULL) { tip = 1; p_file = fopen("planet.dat", "w"); for (x=0; x<MAX; x++) { peer = rnd(4); if(peer<3) { pl[pc].ppx = x; pl[pc].ppy = rnd(MAX); pl[pc].align = rnd(3); pl[pc].class = rnd(3); ++pc; } } fprintf(p_file, "%d\n", pc); for(x=0; x<pc; x++) { fprintf(p_file, "%d\n", pl[x].ppx); fprintf(p_file, "%d\n", pl[x].ppy); fprintf(p_file, "%d\n", pl[x].align); fprintf(p_file, "%d\n", pl[x].class); fprintf(p_file, "%s\n", list[x]); } } if(tip==0) { fscanf(p_file, "%d", &pc); for (x=0; x<pc; x++) { fscanf(p_file, "%d\n", &pl[x].ppx); fscanf(p_file, "%d\n", &pl[x].ppy); fscanf(p_file, "%d\n", &pl[x].align); fscanf(p_file, "%d\n", &pl[x].class); fscanf(p_file, "%s\n", pl[x].name); } } for(x=0; x<pc; x++) brd[(pl[x].ppx)][(pl[x].ppy)] = MOON; fclose(p_file); } get_foremdat() { FILE *fd; int x; fd=fopen("C:\\FOREM\\DOORS\\DORINFO1.DEF","r"); if(fd==NULL) Pterm(0); for(x=0; x<7; x++) fgets(user, 30, fd); fclose(fd); } foremout(string1) char *string1; { int i,j; char teken; j = strlen(string1); /*for(i=0; i<j; i++) string[i] = '\0'; strcpy(string , string1);*/ for(i=0;i<j;i++) { teken = *string1; /* Bconout(2,(int)teken); */ if (calltype) { if (!carrier()) return 1; Bconout(1,(int)teken); } string1++; } sflush(); return 0; /* Good return */ } foremin(string1) char *string1; { char teken = 0x00; int console=0,modem=0,flag = 0; int aantal = 0; timeinfo tijd,tijd1; tijd.realtime = Tgettime(); while( (!calltype || (carrier())) && (teken != 13)) { if ( ( (modem = Bconstat(1)) ) || ( (console = Bconstat(2)) ) ) { tijd.realtime = Tgettime(); flag = 0; teken = (char)(Bconin( (-modem) + (2*(-console)) )) & 0x00FF; if (teken == '\b') /* backspace */ { aantal--; if (aantal<0) aantal = 0; else { foremputc(teken); foremputc(' '); foremputc('\b'); string1--; } } else /*if (isprint(teken))*/ { foremputc(teken); *string1 = teken; string1++; aantal++; } } tijd1.realtime = Tgettime(); if (tijd1.realtime - tijd.realtime >= 30) { foremout("\r\nTimeout, program terminating....\r\n"); save(); Pterm(0); return 1; } else if ( (tijd1.realtime - tijd.realtime >= 15) && !flag) { foremout("\r\n30 seconds until time-out termination.\r\n"); flag = 1; } } foremout("\r "); *string1 = (char)0; if (calltype) return !carrier(); else return 0; } foremputc(teken) char teken; { Bconout(2,(int)teken); if (calltype) /* if this is a remote call */ { while (Bcostat(1)==0) { if (!carrier()) return 1; } Bconout(1,(int)teken); } return 0; } foremgetc() { char teken, bat; int console = 0,modem = 0,flag = 0,loss=1024; timeinfo tijd,tijd1; tijd.realtime = Tgettime(); while( !calltype || (carrier()) ) { if ( ( (modem = Bconstat(1)) ) || ( (console = Bconstat(2)) ) ) { tijd.realtime = Tgettime(); flag = 0; teken = (char)((Bconin( (-modem) + (2*(-console)) )) & 0x00FF); return teken; } tijd1.realtime = Tgettime(); if (tijd1.realtime - tijd.realtime >= 30) { foremout("\r\nTimeout, program terminating....\r\n"); Pterm(0); return loss; } else if ( (tijd1.realtime - tijd.realtime == 15) && !flag) { foremout("\r\n30 seconds until time-out termination.\r\n"); flag = 1; } } return loss; } carrier() /* returns 1 if carrier present, 0 if not */ { long save_ssp; int carrier; char *carptr; carptr = (char *)0xfffa01L; save_ssp = Super(0L); carrier = (!((*carptr) & 2)); Super(save_ssp); if(!carrier) { save(); Pterm(0); } return carrier; } /* This function clears input buffers */ sflush() { int fl; while(Bconstat(AUX)) fl=Bconin(AUX); while(Bconstat(CON)) fl=Bconin(CON); } rnd(n) int n; { int r; r=(int) Random(); r=abs(r)%n; return(r); }