- case IHC: /* Hit a commander */
- case IHS:
- if (Rand() <= 0.05) {
- crmena(1, iquad, 2, ix, iy);
- prout(" uses anti-photon device;");
- prout(" torpedo neutralized.");
- return;
- }
- case IHR: /* Hit a regular enemy */
- case IHK:
- /* find the enemy */
- for (ll=1; ll <= nenhere; ll++)
- if (ix==game.kx[ll] && iy==game.ky[ll]) break;
- kp = fabs(game.kpower[ll]);
- h1 = 700.0 + 100.0*Rand() -
- 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
- fabs(sin(bullseye-angle));
- h1 = fabs(h1);
- if (kp < h1) h1 = kp;
- game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
- if (game.kpower[ll] == 0) {
- deadkl(ix, iy, iquad, ix, iy);
- return;
- }
- crmena(1, iquad, 2, ix, iy);
- /* If enemy damaged but not destroyed, try to displace */
- ang = angle + 2.5*(Rand()-0.5);
- temp = fabs(sin(ang));
- if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
- xx = -sin(ang)/temp;
- yy = cos(ang)/temp;
- jx=ix+xx+0.5;
- jy=iy+yy+0.5;
- if (jx<1 || jx>10 || jy<1 ||jy > 10) {
- prout(" damaged but not destroyed.");
- return;
- }
- if (game.quad[jx][jy]==IHBLANK) {
- prout(" buffeted into black hole.");
- deadkl(ix, iy, iquad, jx, jy);
- return;
- }
- if (game.quad[jx][jy]!=IHDOT) {
- /* can't move into object */
- prout(" damaged but not destroyed.");
- return;
- }
- proutn(" damaged--");
- game.kx[ll] = jx;
- game.ky[ll] = jy;
- shoved = 1;
- break;
- case IHB: /* Hit a base */
- skip(1);
- prout("***STARBASE DESTROYED..");
- if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0;
- for (ll=1; ll<=game.state.rembase; ll++) {
- if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) {
- game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
- game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];
- break;
- }
- }
- game.quad[ix][iy]=IHDOT;
- game.state.rembase--;
- basex=basey=0;
- game.state.galaxy[quadx][quady] -= 10;
- game.state.basekl++;
- newcnd();
- return;
- case IHP: /* Hit a planet */
- crmena(1, iquad, 2, ix, iy);
- prout(" destroyed.");
- game.state.nplankl++;
- game.state.newstuf[quadx][quady] -= 1;
- DESTROY(&game.state.plnets[iplnet]);
- iplnet = 0;
- plnetx = plnety = 0;
- game.quad[ix][iy] = IHDOT;
- if (landed==1) {
- /* captain parishes on planet */
- finish(FDPLANET);
- }
- return;
- case IHSTAR: /* Hit a star */
- if (Rand() > 0.10) {
- nova(ix, iy);
- return;
- }
- crmena(1, IHSTAR, 2, ix, iy);
- prout(" unaffected by photon blast.");
- return;
- case IHQUEST: /* Hit a thingy */
- if (Rand()>0.7) { // Used to be certain death
- skip(1);
- prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");
- skip(1);
- prouts(" HACK! HACK! HACK! *CHOKE!* ");
- skip(1);
- proutn("Mr. Spock-");
- prouts(" \"Fascinating!\"");
- skip(1);
- deadkl(ix, iy, iquad, ix, iy);
- } else {
- /*
- * Stas Sergeev added the possibility that
- * you can shove the Thingy.
- */
- iqengry=1;
- shoved=1;
- }
- return;
- case IHBLANK: /* Black hole */
- skip(1);
- crmena(1, IHBLANK, 2, ix, iy);
- prout(" swallows torpedo.");
- return;
- case IHWEB: /* hit the web */
- skip(1);
- prout("***Torpedo absorbed by Tholian web.");
- return;
- case IHT: /* Hit a Tholian */
- h1 = 700.0 + 100.0*Rand() -
- 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
- fabs(sin(bullseye-angle));
- h1 = fabs(h1);
- if (h1 >= 600) {
-#ifndef SERGEEV
- prout(" destroyed.");
-#endif /* SERGEEV */
- game.quad[ix][iy] = IHDOT;
- ithere = 0;
- ithx = ithy = 0;
-#ifdef SERGEEV
- deadkl(ix, iy, iquad, ix, iy);
-#endif /* SERGEEV */
- return;
- }
- skip(1);
- crmena(1, IHT, 2, ix, iy);
- if (Rand() > 0.05) {
- prout(" survives photon blast.");
- return;
- }
- prout(" disappears.");
- game.quad[ix][iy] = IHWEB;
- ithere = ithx = ithy = 0;
- nenhere--;
- {
- int dum, my;
- dropin(IHBLANK, &dum, &my);
- }
- return;
-
- default: /* Problem! */
- skip(1);
- proutn("Don't know how to handle collision with ");
- crmena(1, iquad, 2, ix, iy);
- skip(1);
- return;
+ case IHC: /* Hit a commander */
+ case IHS:
+ if (Rand() <= 0.05) {
+ crmena(1, iquad, 2, ix, iy);
+ prout(" uses anti-photon device;");
+ prout(" torpedo neutralized.");
+ return;
+ }
+ case IHR: /* Hit a regular enemy */
+ case IHK:
+ /* find the enemy */
+ for (ll=1; ll <= nenhere; ll++)
+ if (ix==game.kx[ll] && iy==game.ky[ll]) break;
+ kp = fabs(game.kpower[ll]);
+ h1 = 700.0 + 100.0*Rand() -
+ 1000.0*sqrt(square(ix-inx)+square(iy-iny))*
+ fabs(sin(bullseye-angle));
+ h1 = fabs(h1);
+ if (kp < h1) h1 = kp;
+ game.kpower[ll] -= (game.kpower[ll]<0 ? -h1 : h1);
+ if (game.kpower[ll] == 0) {
+ deadkl(ix, iy, iquad, ix, iy);
+ return;
+ }
+ crmena(1, iquad, 2, ix, iy);
+ /* If enemy damaged but not destroyed, try to displace */
+ ang = angle + 2.5*(Rand()-0.5);
+ temp = fabs(sin(ang));
+ if (fabs(cos(ang)) > temp) temp = fabs(cos(ang));
+ xx = -sin(ang)/temp;
+ yy = cos(ang)/temp;
+ jx=ix+xx+0.5;
+ jy=iy+yy+0.5;
+ if (jx<1 || jx>QUADSIZE || jy<1 ||jy > QUADSIZE) {
+ prout(" damaged but not destroyed.");
+ return;
+ }
+ if (game.quad[jx][jy]==IHBLANK) {
+ prout(" buffeted into black hole.");
+ deadkl(ix, iy, iquad, jx, jy);
+ return;
+ }
+ if (game.quad[jx][jy]!=IHDOT) {
+ /* can't move into object */
+ prout(" damaged but not destroyed.");
+ return;
+ }
+ proutn(" damaged--");
+ game.kx[ll] = jx;
+ game.ky[ll] = jy;
+ shoved = 1;
+ break;
+ case IHB: /* Hit a base */
+ skip(1);
+ prout("***STARBASE DESTROYED..");
+ if (game.starch[quadx][quady] < 0) game.starch[quadx][quady] = 0;
+ for (ll=1; ll<=game.state.rembase; ll++) {
+ if (game.state.baseqx[ll]==quadx && game.state.baseqy[ll]==quady) {
+ game.state.baseqx[ll]=game.state.baseqx[game.state.rembase];
+ game.state.baseqy[ll]=game.state.baseqy[game.state.rembase];
+ break;