projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Experimental X code
[super-star-trek.git]
/
battle.c
diff --git
a/battle.c
b/battle.c
index 549039999cdbf594490e157a670a81c466325d2b..56a981fc97e54a6cd74dc1876b48f90b472850b1 100644
(file)
--- a/
battle.c
+++ b/
battle.c
@@
-168,7
+168,7
@@
void ram(int ibumpd, int ienm, int ix, int iy)
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
shldup = 0;
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
shldup = 0;
- if (
game.state.remkl
) {
+ if (
KLINGREM
) {
pause_game(2);
dreprt();
}
pause_game(2);
dreprt();
}
@@
-176,7
+176,7
@@
void ram(int ibumpd, int ienm, int ix, int iy)
return;
}
return;
}
-void torpedo(double course, double r, int inx, int iny, double *hit, int
wait, int i, int n)
+void torpedo(double course, double r, int inx, int iny, double *hit, int
i, int n)
{
int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll;
{
int l, iquad=0, ix=0, iy=0, jx=0, jy=0, shoved=0, ll;
@@
-202,8
+202,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
iy = y + 0.5;
if (!VALID_SECTOR(ix, iy)) break;
iquad=game.quad[ix][iy];
iy = y + 0.5;
if (!VALID_SECTOR(ix, iy)) break;
iquad=game.quad[ix][iy];
- tracktorpedo(x, y, ix, iy, wait, l, i, n, iquad);
- wait = 1;
+ tracktorpedo(ix, iy, l, i, n, iquad);
if (iquad==IHDOT) continue;
/* hit something */
setwnd(message_window);
if (iquad==IHDOT) continue;
/* hit something */
setwnd(message_window);
@@
-255,7
+254,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
case IHR: /* Hit a regular enemy */
case IHK:
/* find the enemy */
- for
(ll=1; ll <= nenhere; ll++
)
+ for
_local_enemies(ll
)
if (ix==game.kx[ll] && iy==game.ky[ll]) break;
kp = fabs(game.kpower[ll]);
h1 = 700.0 + 100.0*Rand() -
if (ix==game.kx[ll] && iy==game.ky[ll]) break;
kp = fabs(game.kpower[ll]);
h1 = 700.0 + 100.0*Rand() -
@@
-299,7
+298,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
case IHB: /* Hit a base */
skip(1);
prout("***STARBASE DESTROYED..");
case IHB: /* Hit a base */
skip(1);
prout("***STARBASE DESTROYED..");
- for
(ll=1; ll<=game.state.rembase; ll++
) {
+ for
_starbases(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];
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];
@@
-350,7
+349,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
} else {
/*
* Stas Sergeev added the possibility that
} else {
/*
* Stas Sergeev added the possibility that
- * you can shove the Thingy a
b
d piss it off.
+ * you can shove the Thingy a
n
d piss it off.
* It then becomes an enemy and may fire at you.
*/
iqengry=1;
* It then becomes an enemy and may fire at you.
*/
iqengry=1;
@@
-410,7
+409,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
game.quad[jx][jy]=iquad;
game.quad[ix][iy]=IHDOT;
prout(" displaced by blast to %s ", cramlc(sector, jx, jy));
game.quad[jx][jy]=iquad;
game.quad[ix][iy]=IHDOT;
prout(" displaced by blast to %s ", cramlc(sector, jx, jy));
- for
(ll=1; ll<=nenhere; ll++
)
+ for
_local_enemies(ll
)
game.kdist[ll] = game.kavgd[ll] = sqrt(square(sectx-game.kx[ll])+square(secty-game.ky[ll]));
sortkl();
return;
game.kdist[ll] = game.kavgd[ll] = sqrt(square(sectx-game.kx[ll])+square(secty-game.ky[ll]));
sortkl();
return;
@@
-482,7
+481,7
@@
void attack(int torps_ok)
if (shldchg == 1) chgfac = 0.25+0.5*Rand();
skip(1);
if (skill <= SKILL_FAIR) i = 2;
if (shldchg == 1) chgfac = 0.25+0.5*Rand();
skip(1);
if (skill <= SKILL_FAIR) i = 2;
- for
(l=1; l <= nenhere; l++
) {
+ for
_local_enemies(l
) {
if (game.kpower[l] < 0) continue; /* too weak to attack */
/* compute hit strength and diminsh shield power */
r = Rand();
if (game.kpower[l] < 0) continue; /* too weak to attack */
/* compute hit strength and diminsh shield power */
r = Rand();
@@
-518,8
+517,8
@@
void attack(int torps_ok)
prout(" ");
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
prout(" ");
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
- torpedo(course, r, jx, jy, &hit,
0,
1, 1);
- if (
game.state.remkl
==0)
+ torpedo(course, r, jx, jy, &hit, 1, 1);
+ if (
KLINGREM
==0)
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[quadx][quady].supernova || alldone)
return; /* Supernova or finished */
finish(FWON); /* Klingons did themselves in! */
if (game.state.galaxy[quadx][quady].supernova || alldone)
return; /* Supernova or finished */
@@
-595,7
+594,7
@@
void attack(int torps_ok)
}
}
/* After attack, reset average distance to enemies */
}
}
/* After attack, reset average distance to enemies */
- for
(l = 1; l <= nenhere; l++
)
+ for
_local_enemies(l
)
game.kavgd[l] = game.kdist[l];
sortkl();
return;
game.kavgd[l] = game.kdist[l];
sortkl();
return;
@@
-614,7
+613,6
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
/* chalk up a Romulan */
game.state.galaxy[quadx][quady].romulans--;
irhere--;
/* chalk up a Romulan */
game.state.galaxy[quadx][quady].romulans--;
irhere--;
- game.state.nromkl++;
game.state.nromrem--;
}
else if (type == IHT) {
game.state.nromrem--;
}
else if (type == IHT) {
@@
-629,7
+627,6
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
/* Some type of a Klingon */
game.state.galaxy[quadx][quady].klingons--;
klhere--;
/* Some type of a Klingon */
game.state.galaxy[quadx][quady].klingons--;
klhere--;
- game.state.remkl--;
switch (type) {
case IHC:
comhere = 0;
switch (type) {
case IHC:
comhere = 0;
@@
-640,18
+637,17
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
game.state.cx[game.state.remcom] = 0;
game.state.cy[game.state.remcom] = 0;
game.state.remcom--;
game.state.cx[game.state.remcom] = 0;
game.state.cy[game.state.remcom] = 0;
game.state.remcom--;
- game.future[FTBEAM] =
1e30
;
+ game.future[FTBEAM] =
FOREVER
;
if (game.state.remcom != 0)
game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom);
if (game.state.remcom != 0)
game.future[FTBEAM] = game.state.date + expran(1.0*incom/game.state.remcom);
- game.state.killc++;
break;
case IHK:
break;
case IHK:
- game.state.
killk++
;
+ game.state.
remkl--
;
break;
case IHS:
break;
case IHS:
- game.state.nscrem
= ishere = game.state.isx = game.state.isy = isatb = iscate = 0
;
-
game.state.nsckill = 1
;
- game.future[FSCMOVE] = game.future[FSCDBAS] =
1e30
;
+ game.state.nscrem
--
;
+
ishere = game.state.isx = game.state.isy = isatb = iscate = 0
;
+ game.future[FSCMOVE] = game.future[FSCDBAS] =
FOREVER
;
break;
}
}
break;
}
}
@@
-659,14
+655,14
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
/* For each kind of enemy, finish message to player */
prout(" destroyed.");
game.quad[ix][iy] = IHDOT;
/* For each kind of enemy, finish message to player */
prout(" destroyed.");
game.quad[ix][iy] = IHDOT;
- if (
game.state.remkl
==0) return;
+ if (
KLINGREM
==0) return;
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
/* Remove enemy ship from arrays describing local conditions */
game.state.remtime = game.state.remres/(game.state.remkl + 4*game.state.remcom);
/* Remove enemy ship from arrays describing local conditions */
- if (game.future[FCDBAS] <
1e30
&& batx==quadx && baty==quady && type==IHC)
- game.future[FCDBAS] =
1e30
;
- for
(i=1; i<=nenhere; i++
)
+ if (game.future[FCDBAS] <
FOREVER
&& batx==quadx && baty==quady && type==IHC)
+ game.future[FCDBAS] =
FOREVER
;
+ for
_local_enemies(i
)
if (game.kx[i]==ix && game.ky[i]==iy) break;
nenhere--;
if (i <= nenhere) {
if (game.kx[i]==ix && game.ky[i]==iy) break;
nenhere--;
if (i <= nenhere) {
@@
-827,11
+823,11
@@
void photon(void)
}
if (shldup || condit == IHDOCKED)
r *= 1.0 + 0.0001*shield;
}
if (shldup || condit == IHDOCKED)
r *= 1.0 + 0.0001*shield;
- torpedo(course[i], r, sectx, secty, &dummy,
0,
i, n);
+ torpedo(course[i], r, sectx, secty, &dummy, i, n);
if (alldone || game.state.galaxy[quadx][quady].supernova)
return;
}
if (alldone || game.state.galaxy[quadx][quady].supernova)
return;
}
- if (
game.state.remkl
==0) finish(FWON);
+ if (
KLINGREM
==0) finish(FWON);
}
}
@@
-997,7
+993,7
@@
void phasers(void)
irec=0;
do {
chew();
irec=0;
do {
chew();
- if (!kz) for
(i = 1; i <= nenhere; i++
)
+ if (!kz) for
_local_enemies(i
)
irec+=fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
(1.01+0.05*Rand()) + 1.0;
kz=1;
irec+=fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]))*
(1.01+0.05*Rand()) + 1.0;
kz=1;
@@
-1032,7
+1028,7
@@
void phasers(void)
if (nenhere) {
extra = 0.0;
powrem = rpow;
if (nenhere) {
extra = 0.0;
powrem = rpow;
- for
(i = 1; i <= nenhere; i++
) {
+ for
_local_enemies(i
) {
hits[i] = 0.0;
if (powrem <= 0) continue;
hits[i] = fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]));
hits[i] = 0.0;
if (powrem <= 0) continue;
hits[i] = fabs(game.kpower[i])/(PHASEFAC*pow(0.90,game.kdist[i]));
@@
-1212,7
+1208,7
@@
void hittem(double *hits)
skip(1);
if (kpow == 0) {
deadkl(ii, jj, ienm, ii, jj);
skip(1);
if (kpow == 0) {
deadkl(ii, jj, ienm, ii, jj);
- if (
game.state.remkl
==0) finish(FWON);
+ if (
KLINGREM
==0) finish(FWON);
if (alldone) return;
kk--; /* don't do the increment */
}
if (alldone) return;
kk--; /* don't do the increment */
}