|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T a
Length: 5192 (0x1448) Types: TextFile Names: »aliens.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Mpss/aliens.c«
/********VERSION 1.4!!! (Files from different Versions are INCOMPATIBLE!*******/ /******************************************************************************* ******************************************************************************** ******************************************************************************** PERMISSION TO COPY THIS SOFTWARE IS HEREBY GIVEN BY THE AUTHOR PROVIDED THAT THIS LEADING MESSAGE IS INCLUDED IN ALL OF THE RELEVANT SOURCE FILES. P. SCHMITZ, UNIVERSITY OF KEELE, MAY 1988. ******************************************************************************** ******************************************************************************** *******************************************************************************/ #include "ships.h" #include "header.h" makealien(cp) register struct player *cp; { char *malloc(); struct player *aa; aa=(struct player *)malloc(sizeof(struct player)); i=(int)rnd(0,10); if (i>5) { aa->id=ROMID; aa->xpos=600; aa->ypos=100; } else { aa->id=KLINGID; aa->xpos=600; aa->ypos=575; } aa->impulsemove=0; aa->cm[0]='\0'; aa->cl[0]='\0'; aa->cm[0]='\0'; aa->terminalfile[0]='\0'; aa->shipno=28; aa->tty_type= -1; aa->pid=99999; aa->doneit=0; aa->reason=10; aa->oldxpos=aa->xpos; aa->oldypos=aa->ypos; aa->beeping=ON; aa->maxvel=MAXWARP; aa->xvel=0; aa->yvel=0; aa->chflg=FLAG; aa->clflg=OFF; aa->stat=3; aa->energy=STARTENERGY; aa->maxenergy=STARTENERGY; aa->phaserbanks=STARTPHASER; aa->maxphaser=STARTPHASER; aa->photontorpedos=STARTPHOTON; aa->maxphoton=STARTPHOTON; aa->photonpower=PHOTONPOWER; aa->phaserpower=PHASERPOWER; if (aa->id==ROMID) { aa->photonpower= aa->photonpower+20; aa->phaserpower= aa->phaserpower+20; } aa->photonreach=WEAPONREACH+4; aa->phaserreach=WEAPONREACH+4; aa->weaponselect=0; aa->score=0; aa->cloakingdevice=OFF; aa->shields=OFF; for(k=0;k<30;++k) aa->planets[k]=0; aa->planetno=0; for (k=0; k<=3; k++) { aa->channel[k].enemy=NULL; aa->channel[k].xloc=0; aa->channel[k].yloc=0; } aa->flyto= -1; aa->messindex=0; addtolist(aa); ++noofaliens; } servicealien(cp) register struct player *cp; { if (cp->messindex==1) { if (autopilotalien(cp)==0) goto movealien; else { /*we have arrived. Now attack the guy*/ if (cp->weaponselect==0) { i=rand()%100; if (i<6) { if (cp->planets[1]!=0) { fire_torpedo(cp,'9',0); fire_torpedo(cp,'9',0); } else fire_torpedo(cp,'6',0); cp->messindex=0; cp->planets[1]=0; i=rand()%100; if (i<50) cp->yvel=1; } } else { i=rand()%100; if (i<6) { if (cp->planets[1]!=0) { fire_torpedo(cp,'7',0); fire_torpedo(cp,'7',0); } else fire_torpedo(cp,'4',0); cp->messindex=0; cp->planets[1]=0; i=rand()%100; if (i<50) { cp->yvel=1; cp->xvel=1; } } } } } i=rand()%10000; if (i==9995) { j=rand()%10; if (cp->messindex==0 && j<2) lockonalien(cp,NULL); else cp->messindex=0; } if (i<9920) {goto movealien;} if ((i>=9920)&&(i<9995)) {cp->xvel=0; cp->yvel=0; goto movealien;} if (i==9996) {cp->xvel = -1; goto movealien;} if (i==9997) {cp->xvel = 1; goto movealien;} if (i==9998) {cp->yvel = 1; goto movealien;} if (i==9999) cp->yvel = -1; movealien : cp->oldxpos=cp->xpos; cp->oldypos=cp->ypos; cp->xpos+=cp->xvel; cp->ypos+=cp->yvel; if (((cp->yvel!=0)||(cp->xvel!=0))&&(cp->stat<12)) cp->chflg=FLAG; } gethim(who,enemyid) register struct player *who; char enemyid; { register struct player *x; if (noofplayers>1) return(0); x=startlist; while (x!=NULL && (x->id!=enemyid || x->messindex==1)) x=x->next; if (x!=NULL) lockonalien(x,who); } lockonalien(cp,who) register struct player *cp,*who; { register struct player *x; if (cp->stat==12) return(0); i=rand()%1000; if (i>500) cp->weaponselect=0; else cp->weaponselect=1; if (i>500) { if (i>750) cp->screenenergy=6; else cp->screenenergy=7; } else { if (i>250) cp->screenenergy=5; else cp->screenenergy=8; } i=rand()%100; if (i>30) cp->planets[1]=0; else cp->planets[1]=abs((rand()%10)-5); if (who==NULL) { x=startlist; while (x!=NULL) { if (x==cp) {x=x->next; continue;} if ((x->shields==OFF)&&(x->id!=ROMID)&&(x->id!=KLINGID)) { cp->channel[1].enemy=x; cp->channel[1].xloc=0; cp->channel[1].yloc=0; cp->messindex=1; } x=x->next; } } else { cp->channel[1].enemy=who; cp->channel[1].xloc=0; cp->channel[1].yloc=0; cp->messindex=1; } } autopilotalien(cp) register struct player *cp; { int g; g = cp->planets[1]; if (cp->weaponselect==0) { if (cp->xpos!=(cp->channel[1].enemy->xpos-cp->screenenergy)) { if (cp->xpos<(cp->channel[1].enemy->xpos-cp->screenenergy)) cp->xvel=1; else cp->xvel= -1; } else cp->xvel=0; } else { if (cp->xpos!=(cp->channel[1].enemy->xpos+cp->screenenergy)) { if (cp->xpos<(cp->channel[1].enemy->xpos+cp->screenenergy)) cp->xvel=1; else cp->xvel= -1; } else cp->xvel=0; } if (cp->ypos!=(cp->channel[1].enemy->ypos-g)) { if (cp->ypos<(cp->channel[1].enemy->ypos-g)) cp->yvel=1; else cp->yvel= -1; } else cp->yvel=0; /* arrival at location*/ if ((cp->xvel==0)&&(cp->yvel==0)) return(1); else return(0); }