X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=battle.c;fp=battle.c;h=75ac19035437662a1a48dfdab3db81b450ded6f8;hb=5db6160de8bad4de189d3b54dd54011260c7a34f;hp=f8c81eba6d4b7b4b367514f32cb8c564b063e51b;hpb=64f8a6155517ae8b894617ebd93e5eb48cdf4c0e;p=super-star-trek.git diff --git a/battle.c b/battle.c index f8c81eb..75ac190 100644 --- 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; - 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! */ } @@ -422,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; - 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; @@ -430,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 */ - for (l = 1; l <= ncrit && l <= NDEVICES; l++) { + for (l = 0; l < ncrit && 0 < NDEVICES; l++) { do { - j = NDEVICES*Rand()+1.0; + j = NDEVICES*Rand(); /* 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; - if (l > 1) { + if (l > 0) { for (ll=2; ll<=l && j != cdam[ll-1]; ll++) ; if (ll<=l) continue; ktr += 1;