X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=battle.c;h=5389821ab5d3dd048a2867eeaaa83b9a265b1fea;hp=455801b9e2b43bc4b6366fcb4aa9fdbeec9f68c3;hb=a67634b9dc32d47cba5f75341bff2349d9ebbbcf;hpb=49483a1747cd310e33eea758b32a453fb46d4aac diff --git a/battle.c b/battle.c index 455801b..5389821 100644 --- a/battle.c +++ b/battle.c @@ -1,8 +1,5 @@ -#ifdef SERGEEV -#include #include -#include "sstlinux.h" -#endif /* SERGEEV */ +#include "conio.h" #include "sst.h" void doshield(int i) { @@ -176,12 +173,10 @@ void ram(int ibumpd, int ienm, int ix, int iy) { return; } -void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { +void torpedo(double course, double r, int inx, int iny, double *hit, int wait, int i, int n) { int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll; -#ifdef SERGEEV int crx,cry; -#endif /* SERGEEV */ double ac=course + 0.25*r; double angle = (15.0-ac)*0.5235988; double bullseye = (15.0 - course)*0.5235988; @@ -192,12 +187,10 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { if (fabs(deltay) > bigger) bigger = fabs(deltay); deltax /= bigger; deltay /= bigger; -#ifdef SERGEEV crx=wherex(); cry=wherey(); - if (game.damage[DSRSENS]==0 || condit==IHDOCKED) setwnd(1); - else setwnd(4); -#endif /* SERGEEV */ + if (game.damage[DSRSENS]==0 || condit==IHDOCKED) setwnd(LEFTUPPER_WINDOW); + else setwnd(LOWER_WINDOW); /* Loop to move a single torpedo */ for (l=1; l <= 15; l++) { x += deltax; @@ -206,49 +199,13 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { y += deltay; iy = y + 0.5; if (iy < 1 || iy > 10) break; -#ifndef SERGEEV - if (l==4 || l==9) skip(1); - proutn("%d - %d ", (int)x, (int)y); iquad=game.quad[ix][iy]; -#else - iquad=game.quad[ix][iy]; - if (game.damage[DSRSENS]==0 || condit==IHDOCKED){ - drawmaps(2); - delay((wait!=1)*400); - wait=1; - gotoxy(iy*2+3,ix+2); - if ((game.quad[ix][iy]==IHDOT)||(game.quad[ix][iy]==IHBLANK)){ - game.quad[ix][iy]='+'; - drawmaps(2); - game.quad[ix][iy]=iquad; - sound(l*10); - delay(100); - nosound(); - } - else { - game.quad[ix][iy]|=128; - drawmaps(2); - game.quad[ix][iy]=iquad; - _setcursortype(_NOCURSOR); - sound(500); - delay(1000); - nosound(); - lowvideo(); - _setcursortype(_NORMALCURSOR); - } - } - else { - proutn("%d - %d ", (int)x, (int)y); - } -#endif /* SERGEEV */ + tracktorpedo(x, y, ix, iy, wait, l, i, n, iquad); + wait = 1; if (iquad==IHDOT) continue; /* hit something */ -#ifndef SERGEEV - skip(1); -#else - setwnd(4); + setwnd(LOWER_WINDOW); gotoxy(crx,cry); -#endif switch(iquad) { case IHE: /* Hit our ship */ case IHF: @@ -260,9 +217,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { 1000.0*sqrt(square(ix-inx)+square(iy-iny))* fabs(sin(bullseye-angle)); *hit = fabs(*hit); -#ifndef SERGEEV - newcnd(); /* undock */ -#endif /* SERGEEV */ + newcnd(); /* we're blown out of dock */ /* We may be displaced. */ if (landed==1 || condit==IHDOCKED) return; /* Cheat if on a planet */ ang = angle + 2.5*(Rand()-0.5); @@ -414,15 +369,10 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { 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); @@ -450,12 +400,10 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { } break; } -#ifdef SERGEEV - if(curwnd!=4) { - setwnd(4); + if(curwnd!=LOWER_WINDOW) { + setwnd(LOWER_WINDOW); gotoxy(crx,cry); } -#endif /* SERGEEV */ if (shoved) { game.quad[jx][jy]=iquad; game.quad[ix][iy]=IHDOT; @@ -465,9 +413,7 @@ void torpedo(double course, double r, int inx, int iny, double *hit, int wait) { sortkl(); return; } -#ifndef SERGEEV skip(1); -#endif /* SERGEEV */ prout("Torpedo missed."); return; } @@ -568,7 +514,7 @@ void attack(int k) { prout(" "); r = (Rand()+Rand())*0.5 -0.5; r += 0.002*game.kpower[l]*r; - torpedo(course, r, jx, jy, &hit, 0); + torpedo(course, r, jx, jy, &hit, 0, 1, 1); if (game.state.remkl==0) finish(FWON); /* Klingons did themselves in! */ if (game.state.galaxy[quadx][quady] == 1000 || alldone) return; /* Supernova or finished */ @@ -654,9 +600,7 @@ void deadkl(int ix, int iy, int type, int ixx, int iyy) { int i,j; -#ifdef SERGEEV skip(1); -#endif /* SERGEEV */ crmena(1, type, 2, ixx, iyy); /* Decide what kind of enemy it is and update approriately */ if (type == IHR) { @@ -873,17 +817,7 @@ void photon(void) { } } if (shldup || condit == IHDOCKED) r *= 1.0 + 0.0001*shield; -#ifndef SERGEEV - if (n != 1) { - skip(1); - proutn("Track for torpedo number %d- ", i); - } - else { - skip(1); - proutn("Torpedo track- "); - } -#endif /* SERGEEV */ - torpedo(course[i], r, sectx, secty, &dummy, i); + torpedo(course[i], r, sectx, secty, &dummy, 0, i, n); if (alldone || game.state.galaxy[quadx][quady]==1000) return; } if (game.state.remkl==0) finish(FWON); @@ -1234,9 +1168,6 @@ void phasers(void) { void hittem(double *hits) { double kp, kpow, wham, hit, dustfac, kpini; -#ifdef SERGEEV - int crx, cry; -#endif /* SERGEEV */ int nenhr2=nenhere, k=1, kk=1, ii, jj, ienm; skip(1); @@ -1253,27 +1184,8 @@ void hittem(double *hits) { ii = game.kx[kk]; jj = game.ky[kk]; if (hit > 0.005) { -#ifdef SERGEEV - if (game.damage[DSRSENS]==0){ - crx=wherex(); - cry=wherey(); - setwnd(1); - drawmaps(2); - gotoxy(jj*2+3,ii+2); - highvideo(); - proutn("%c", game.quad[ii][jj]); - gotoxy(wherex()-1,wherey()); - sound(500); - delay(1000); - nosound(); - lowvideo(); - proutn("%c", game.quad[ii][jj]); - setwnd(4); - gotoxy(crx,cry); - _setcursortype(_NORMALCURSOR); - delay(500); - } -#endif /* SERGEEV */ + if (game.damage[DSRSENS]==0) + boom(ii, jj); proutn("%d unit hit on ", (int)hit); } else