Before 4.0.6, depth charges required no guns, one military, did damage
like shell fire from two guns, and used two shells. Missions were not
quite consistent with that (bug). 4.0.6 changed depth charges to work
exactly like shell fire (but without updating documentation
accordingly): require guns and gun crew, non-zero firing range, scale
damage and ammunition use with guns.
Go back to the old model, but with damage like three guns, to avoid
changing the stock game's dd now (three gun damage for two shells).
Stock game's af changes from two gun damage for one shell, and nas
from four gun damage for two shells.
Factor out common depth-charging code into shp_dchrg().
extern int m_frnge(struct mchrstr *, int);
extern int m_glim(struct mchrstr *, int);
extern int m_frnge(struct mchrstr *, int);
extern int m_glim(struct mchrstr *, int);
+extern int shp_dchrg(struct shpstr *);
+
fort damage = guns * eff * (random(30) + 20) / 7
unit damage = guns * eff * (5 + random(6))
ship damage = guns * eff * (10 + random(6))
fort damage = guns * eff * (random(30) + 20) / 7
unit damage = guns * eff * (5 + random(6))
ship damage = guns * eff * (10 + random(6))
- depth damage = 2 * eff * (10 + random(6))
+ depth damage = 3 * eff * (10 + random(6))
torp damage = 40 + random(40) + random(40)
Note that for forts, a maximum of 7 guns may be fired.
torp damage = 40 + random(40) + random(40)
Note that for forts, a maximum of 7 guns may be fired.
pr("Not enough military for firing crew.\n");
continue;
}
pr("Not enough military for firing crew.\n");
continue;
}
- gun = fship.shp_item[I_GUN];
- gun = MIN(gun, fship.shp_glim);
- if (fship.shp_frnge == 0 || gun == 0) {
- pr("Insufficient arms.\n");
- continue;
- }
- shell = fship.shp_item[I_SHELL];
- if (shell < 2)
- shell += supply_commod(fship.shp_own,
- fship.shp_x, fship.shp_y,
- I_SHELL, 2 - shell);
- if (shell <= 0) {
- pr("Klick! ...\n");
- continue;
- }
if (fship.shp_effic < 60) {
pr("Ship #%d is crippled (%d%%)\n",
fshipno, fship.shp_effic);
if (fship.shp_effic < 60) {
pr("Ship #%d is crippled (%d%%)\n",
fshipno, fship.shp_effic);
range = effrange(fship.shp_frnge, fship.shp_tech);
range2 = roundrange(range);
pr("range is %d.00 (%.2f)\n", range2, range);
range = effrange(fship.shp_frnge, fship.shp_tech);
range2 = roundrange(range);
pr("range is %d.00 (%.2f)\n", range2, range);
- if (target == targ_sub) {
- if ((mchr[(int)fship.shp_type].m_flags & M_DCH) == 0) {
+ if (target == targ_sub
+ && (mchr[(int)fship.shp_type].m_flags & M_DCH)) {
+ dam = shp_dchrg(&fship);
+ putship(fship.shp_uid, &fship);
+ if (dam < 0) {
+ pr("Not enough shells for depth charge!\n");
+ continue;
+ }
+ } else {
+ if (target == targ_sub)
/* Don't tell it's a sub */
range2 = -1;
/* Don't tell it's a sub */
range2 = -1;
- } else if (shell < 2) {
- pr("Not enough shells for depth charge!\n");
+ gun = fship.shp_item[I_GUN];
+ gun = MIN(gun, fship.shp_glim);
+ if (fship.shp_frnge == 0 || gun == 0) {
+ pr("Insufficient arms.\n");
+ continue;
+ }
+ shell = fship.shp_item[I_SHELL];
+ shell += supply_commod(fship.shp_own,
+ fship.shp_x, fship.shp_y,
+ I_SHELL, 2 - shell);
+ if (shell <= 0) {
+ pr("Klick! ...\n");
+ gun = MIN(gun, shell * 2);
+ gun = MIN(gun, mil / 2);
+ gun = MAX(gun, 1);
+ shots = gun;
+ guneff = seagun(fship.shp_effic, shots);
+ dam = (int)guneff;
+ shell -= ldround(shots / 2.0, 1);
+ fship.shp_item[I_SHELL] = shell;
+ putship(fship.shp_uid, &fship);
- gun = MIN(gun, shell * 2);
- gun = MIN(gun, mil / 2);
- gun = MAX(gun, 1);
- shots = gun;
- guneff = seagun(fship.shp_effic, shots);
- dam = (int)guneff;
- shell -= ldround(shots / 2.0, 1);
- fship.shp_item[I_SHELL] = shell;
- if (opt_NOMOBCOST == 0)
+ if (opt_NOMOBCOST == 0) {
fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
fship.shp_mobil = MAX(fship.shp_mobil - 15, -100);
- putship(fship.shp_uid, &fship);
+ putship(fship.shp_uid, &fship);
+ }
} else if (attacker == targ_unit) {
if (fland.lnd_own != player->cnum) {
pr("Not your unit!\n");
} else if (attacker == targ_unit) {
if (fland.lnd_own != player->cnum) {
pr("Not your unit!\n");
continue;
if (dd.shp_own != vshipown)
continue;
continue;
if (dd.shp_own != vshipown)
continue;
- if (dd.shp_effic < 60)
- continue;
-
if (!canshoot(&dd, &sub))
continue;
if (!canshoot(&dd, &sub))
continue;
- shells = sp->shp_item[I_SHELL];
- gun = sp->shp_item[I_GUN];
- gun = MIN(gun, sp->shp_glim);
- gun = MIN(gun, sp->shp_item[I_MILIT] / 2);
+ if ((mchr[(int)targ->shp_type].m_flags & M_SUB) == 0) {
+ shells = sp->shp_item[I_SHELL];
+ gun = sp->shp_item[I_GUN];
+ gun = MIN(gun, sp->shp_glim);
+ gun = MIN(gun, sp->shp_item[I_MILIT] / 2);
- shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
- I_SHELL, (gun + 1) / 2 - shells);
+ shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
+ I_SHELL, (gun + 1) / 2 - shells);
- gun = MIN(gun, shells * 2);
- if (gun == 0)
- return;
+ gun = MIN(gun, shells * 2);
+ if (gun == 0)
+ return;
- /* ok, all set.. now, we shoot */
- shells -= ldround(gun / 2.0, 1);
- sp->shp_item[I_SHELL] = shells;
- putship(sp->shp_uid, sp);
+ /* ok, all set.. now, we shoot */
+ shells -= ldround(gun / 2.0, 1);
+ sp->shp_item[I_SHELL] = shells;
+ putship(sp->shp_uid, sp);
- guneff = seagun(sp->shp_effic, gun);
- dam = (int)guneff;
- if (ntargets > 2)
- dam /= ntargets / 2;
+ guneff = seagun(sp->shp_effic, gun);
+ dam = (int)guneff;
+ if (ntargets > 2)
+ dam /= ntargets / 2;
- if ((mchr[(int)targ->shp_type].m_flags & M_SUB) == 0) {
pr_beep();
pr("Kaboom!!! Incoming shells!\n");
if (sp->shp_own != 0)
pr_beep();
pr("Kaboom!!! Incoming shells!\n");
if (sp->shp_own != 0)
shipdamage(targ, dam);
putship(targ->shp_uid, targ);
} else {
shipdamage(targ, dam);
putship(targ->shp_uid, targ);
} else {
+ dam = shp_dchrg(sp);
+ putship(sp->shp_uid, sp);
+ if (dam < 0)
+ return;
+ if (ntargets > 2)
+ dam /= ntargets / 2;
+
pr("\nCAPTAIN! !!Depth charges!!...\n");
if (sp->shp_own != 0)
wu(0, sp->shp_own,
pr("\nCAPTAIN! !!Depth charges!!...\n");
if (sp->shp_own != 0)
wu(0, sp->shp_own,
return (int)fortgun(sp->sct_effic, guns);
}
return (int)fortgun(sp->sct_effic, guns);
}
+/*
+ * Drop depth-charges from ship SP.
+ * Use ammo, resupply if necessary.
+ * Return damage if the ship drops depth-charges, else -1.
+ */
+int
+shp_dchrg(struct shpstr *sp)
+{
+ int shells;
+
+ if (sp->shp_effic < 60 || (mchr[sp->shp_type].m_flags & M_DCH) == 0)
+ return -1;
+ if (sp->shp_item[I_MILIT] == 0)
+ return -1;
+ shells = sp->shp_item[I_SHELL];
+ shells += supply_commod(sp->shp_own, sp->shp_x, sp->shp_y,
+ I_SHELL, 2 - shells);
+ if (shells < 2)
+ return -1;
+ sp->shp_item[I_SHELL] = shells - 2;
+ return (int)seagun(sp->shp_effic, 3);
+}
+
/*
* Return effective firing range for range factor RNG at tech TLEV.
*/
/*
* Return effective firing range for range factor RNG at tech TLEV.
*/
range = roundrange(effrange(sp->shp_frnge, sp->shp_tech));
if (md > range)
continue;
range = roundrange(effrange(sp->shp_frnge, sp->shp_tech));
if (md > range)
continue;
- gun = sp->shp_item[I_GUN];
- gun = MIN(gun, sp->shp_glim);
- shell = sp->shp_item[I_SHELL];
- if (shell < gun)
- shell += supply_commod(sp->shp_own,
- sp->shp_x, sp->shp_y, I_SHELL,
- gun - shell);
- gun = MIN(gun, shell);
- gun = MIN(gun, sp->shp_item[I_MILIT] / 2.0);
- if (gun == 0)
- continue;
- gun = MAX(gun, 1);
- dam2 = seagun(sp->shp_effic, gun);
+ if (mission == MI_SINTERDICT) {
+ dam2 = shp_dchrg(sp);
+ putship(sp->shp_uid, sp);
+ if (dam2 < 0)
+ continue;
+ } else {
+ gun = sp->shp_item[I_GUN];
+ gun = MIN(gun, sp->shp_glim);
+ shell = sp->shp_item[I_SHELL];
+ if (shell < gun)
+ shell += supply_commod(sp->shp_own,
+ sp->shp_x, sp->shp_y, I_SHELL,
+ gun - shell);
+ gun = MIN(gun, shell);
+ gun = MIN(gun, sp->shp_item[I_MILIT] / 2.0);
+ if (gun == 0)
+ continue;
+ gun = MAX(gun, 1);
+ dam2 = seagun(sp->shp_effic, gun);
+ sp->shp_item[I_SHELL] = shell - gun;
+ putship(sp->shp_uid, sp);
+ }
if (range == 0.0)
prb = 1.0;
else
if (range == 0.0)
prb = 1.0;
else
mpr(victim, "%s %s fires at you at %s\n",
cname(sp->shp_own), prship(sp), xyas(x, y, victim));
mpr(victim, "%s %s fires at you at %s\n",
cname(sp->shp_own), prship(sp), xyas(x, y, victim));
-
- sp->shp_item[I_SHELL] = shell - gun;
- putship(sp->shp_uid, sp);
}
} else if (glp->thing->ef_type == EF_PLANE) {
pcp = glp->cp;
}
} else if (glp->thing->ef_type == EF_PLANE) {
pcp = glp->cp;