projects
/
super-star-trek.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rewrite to get ride of FORTRANish galaxy and newstuff arrays. It's
[super-star-trek.git]
/
battle.c
diff --git
a/battle.c
b/battle.c
index f539c3fd375eee8ed583aa4b0395a7ee2f8b5d93..5356e3d14f9f11a1bdcb6a7ed057dc8d20274610 100644
(file)
--- a/
battle.c
+++ b/
battle.c
@@
-159,9
+159,11
@@
void ram(int ibumpd, int ienm, int ix, int iy)
icas = 10.0+20.0*Rand();
prout("***Sickbay reports %d casualties", icas);
casual += icas;
icas = 10.0+20.0*Rand();
prout("***Sickbay reports %d casualties", icas);
casual += icas;
- for (l=1; l <= NDEVICES; l++) {
- if (l == DDRAY) continue; // Don't damage deathray
- if (game.damage[l] < 0) continue;
+ for (l=0; l < NDEVICES; l++) {
+ if (l == DDRAY)
+ continue; // Don't damage deathray
+ if (game.damage[l] < 0)
+ continue;
extradm = (10.0*type*Rand()+1.0)*damfac;
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
extradm = (10.0*type*Rand()+1.0)*damfac;
game.damage[l] += Time + extradm; /* Damage for at least time of travel! */
}
@@
-298,7
+300,6
@@
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..");
- 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];
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];
@@
-309,7
+310,8
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
game.quad[ix][iy]=IHDOT;
game.state.rembase--;
basex=basey=0;
game.quad[ix][iy]=IHDOT;
game.state.rembase--;
basex=basey=0;
- game.state.galaxy[quadx][quady] -= BASE_PLACE;
+ game.state.galaxy[quadx][quady].starbase--;
+ game.state.chart[quadx][quady].starbase--;
game.state.basekl++;
newcnd();
return;
game.state.basekl++;
newcnd();
return;
@@
-317,7
+319,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
crmena(1, iquad, 2, ix, iy);
prout(" destroyed.");
game.state.nplankl++;
crmena(1, iquad, 2, ix, iy);
prout(" destroyed.");
game.state.nplankl++;
- game.state.
newstuf[quadx][quady] -= 1
;
+ game.state.
galaxy[quadx][quady].planets--
;
DESTROY(&game.state.plnets[iplnet]);
iplnet = 0;
plnetx = plnety = 0;
DESTROY(&game.state.plnets[iplnet]);
iplnet = 0;
plnetx = plnety = 0;
@@
-336,7
+338,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
prout(" unaffected by photon blast.");
return;
case IHQUEST: /* Hit a thingy */
prout(" unaffected by photon blast.");
return;
case IHQUEST: /* Hit a thingy */
- if (
Rand()>0.7) { // Used to be certain death
+ if (
!(game.options & OPTION_THINGY) || Rand()>0.7) {
skip(1);
prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");
skip(1);
skip(1);
prouts("AAAAIIIIEEEEEEEEAAAAAAAAUUUUUGGGGGHHHHHHHHHHHH!!!");
skip(1);
@@
-349,7
+351,8
@@
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.
+ * you can shove the Thingy abd piss it off.
+ * It then becomes an enemy and may fire at you.
*/
iqengry=1;
shoved=1;
*/
iqengry=1;
shoved=1;
@@
-421,7
+424,7
@@
void torpedo(double course, double r, int inx, int iny, double *hit, int wait, i
static void fry(double hit)
{
double ncrit, extradm;
static void fry(double hit)
{
double ncrit, extradm;
- int ktr=1, l, ll, j, cdam[NDEVICES
+1
];
+ int ktr=1, l, ll, j, cdam[NDEVICES];
/* a critical hit occured */
if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return;
/* a critical hit occured */
if (hit < (275.0-25.0*skill)*(1.0+0.5*Rand())) return;
@@
-429,16
+432,16
@@
static void fry(double hit)
ncrit = 1.0 + hit/(500.0+100.0*Rand());
proutn("***CRITICAL HIT--");
/* Select devices and cause damage */
ncrit = 1.0 + hit/(500.0+100.0*Rand());
proutn("***CRITICAL HIT--");
/* Select devices and cause damage */
- for (l =
1; l <= ncrit && l <=
NDEVICES; l++) {
+ for (l =
0; l < ncrit && 0 <
NDEVICES; l++) {
do {
do {
- j = NDEVICES*Rand()
+1.0
;
+ j = NDEVICES*Rand();
/* Cheat to prevent shuttle damage unless on ship */
/* Cheat to prevent shuttle damage unless on ship */
- } while
(game.damage[j] < 0.0 || (j == DSHUTTL && iscraft != 1) ||
-
j ==
DDRAY);
+ } while
+
(game.damage[j]<0.0 || (j==DSHUTTL && iscraft!=1) || j==
DDRAY);
cdam[l] = j;
extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand()));
game.damage[j] += extradm;
cdam[l] = j;
extradm = (hit*damfac)/(ncrit*(75.0+25.0*Rand()));
game.damage[j] += extradm;
- if (l >
1
) {
+ if (l >
0
) {
for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;
if (ll<=l) continue;
ktr += 1;
for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ;
if (ll<=l) continue;
ktr += 1;
@@
-517,9
+520,10
@@
void attack(int torps_ok)
r = (Rand()+Rand())*0.5 -0.5;
r += 0.002*game.kpower[l]*r;
torpedo(course, r, jx, jy, &hit, 0, 1, 1);
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) finish(FWON); /* Klingons did themselves in! */
- if (game.state.galaxy[quadx][quady] == SUPERNOVA_PLACE ||
- alldone) return; /* Supernova or finished */
+ if (game.state.remkl==0)
+ finish(FWON); /* Klingons did themselves in! */
+ if (game.state.galaxy[quadx][quady].supernova || alldone)
+ return; /* Supernova or finished */
if (hit == 0) continue;
}
if (shldup != 0 || shldchg != 0 || condit==IHDOCKED) {
if (hit == 0) continue;
}
if (shldup != 0 || shldchg != 0 || condit==IHDOCKED) {
@@
-609,7
+613,7
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
/* Decide what kind of enemy it is and update approriately */
if (type == IHR) {
/* chalk up a Romulan */
/* Decide what kind of enemy it is and update approriately */
if (type == IHR) {
/* chalk up a Romulan */
- game.state.
newstuf[quadx][quady] -= ROMULAN_PLACE
;
+ game.state.
galaxy[quadx][quady].romulans--
;
irhere--;
game.state.nromkl++;
game.state.nromrem--;
irhere--;
game.state.nromkl++;
game.state.nromrem--;
@@
-624,7
+628,7
@@
void deadkl(int ix, int iy, int type, int ixx, int iyy)
}
else {
/* Some type of a Klingon */
}
else {
/* Some type of a Klingon */
- game.state.galaxy[quadx][quady]
-= KLINGON_PLACE
;
+ game.state.galaxy[quadx][quady]
.klingons--
;
klhere--;
game.state.remkl--;
switch (type) {
klhere--;
game.state.remkl--;
switch (type) {
@@
-825,7
+829,7
@@
void photon(void)
if (shldup || condit == IHDOCKED)
r *= 1.0 + 0.0001*shield;
torpedo(course[i], r, sectx, secty, &dummy, 0, i, n);
if (shldup || condit == IHDOCKED)
r *= 1.0 + 0.0001*shield;
torpedo(course[i], r, sectx, secty, &dummy, 0, i, n);
- if (alldone
||game.state.galaxy[quadx][quady]==SUPERNOVA_PLACE
)
+ if (alldone
|| game.state.galaxy[quadx][quady].supernova
)
return;
}
if (game.state.remkl==0) finish(FWON);
return;
}
if (game.state.remkl==0) finish(FWON);