Make depth-charging code and documentation match
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().
This commit is contained in:
parent
e8595066d1
commit
a3ad623b2a
6 changed files with 112 additions and 72 deletions
|
@ -183,4 +183,6 @@ extern int m_visib(struct mchrstr *, int);
|
||||||
extern int m_frnge(struct mchrstr *, int);
|
extern int m_frnge(struct mchrstr *, int);
|
||||||
extern int m_glim(struct mchrstr *, int);
|
extern int m_glim(struct mchrstr *, int);
|
||||||
|
|
||||||
|
extern int shp_dchrg(struct shpstr *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,7 +17,7 @@ You can be shelled by a fort, artillery unit, ship, depth-charge, or torpedo:
|
||||||
fort damage = guns * eff * (random(30) + 20) / 7
|
fort damage = guns * eff * (random(30) + 20) / 7
|
||||||
unit damage = guns * eff * (5 + random(6))
|
unit damage = guns * eff * (5 + random(6))
|
||||||
ship damage = guns * eff * (10 + 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)
|
torp damage = 40 + random(40) + random(40)
|
||||||
Note that for forts, a maximum of 7 guns may be fired.
|
Note that for forts, a maximum of 7 guns may be fired.
|
||||||
|
|
||||||
|
|
|
@ -308,21 +308,6 @@ multifire(void)
|
||||||
pr("Not enough military for firing crew.\n");
|
pr("Not enough military for firing crew.\n");
|
||||||
continue;
|
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) {
|
if (fship.shp_effic < 60) {
|
||||||
pr("Ship #%d is crippled (%d%%)\n",
|
pr("Ship #%d is crippled (%d%%)\n",
|
||||||
fshipno, fship.shp_effic);
|
fshipno, fship.shp_effic);
|
||||||
|
@ -331,14 +316,31 @@ multifire(void)
|
||||||
range = effrange(fship.shp_frnge, fship.shp_tech);
|
range = effrange(fship.shp_frnge, fship.shp_tech);
|
||||||
range2 = roundrange(range);
|
range2 = roundrange(range);
|
||||||
pr("range is %d.00 (%.2f)\n", range2, range);
|
pr("range is %d.00 (%.2f)\n", range2, range);
|
||||||
if (target == targ_sub) {
|
if (target == targ_sub
|
||||||
if ((mchr[(int)fship.shp_type].m_flags & M_DCH) == 0) {
|
&& (mchr[(int)fship.shp_type].m_flags & M_DCH)) {
|
||||||
/* Don't tell it's a sub */
|
dam = shp_dchrg(&fship);
|
||||||
range2 = -1;
|
putship(fship.shp_uid, &fship);
|
||||||
} else if (shell < 2) {
|
if (dam < 0) {
|
||||||
pr("Not enough shells for depth charge!\n");
|
pr("Not enough shells for depth charge!\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (target == targ_sub)
|
||||||
|
/* Don't tell it's a sub */
|
||||||
|
range2 = -1;
|
||||||
|
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");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
gun = MIN(gun, shell * 2);
|
gun = MIN(gun, shell * 2);
|
||||||
gun = MIN(gun, mil / 2);
|
gun = MIN(gun, mil / 2);
|
||||||
|
@ -348,9 +350,12 @@ multifire(void)
|
||||||
dam = (int)guneff;
|
dam = (int)guneff;
|
||||||
shell -= ldround(shots / 2.0, 1);
|
shell -= ldround(shots / 2.0, 1);
|
||||||
fship.shp_item[I_SHELL] = shell;
|
fship.shp_item[I_SHELL] = shell;
|
||||||
if (opt_NOMOBCOST == 0)
|
putship(fship.shp_uid, &fship);
|
||||||
|
}
|
||||||
|
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) {
|
} else if (attacker == targ_unit) {
|
||||||
if (fland.lnd_own != player->cnum) {
|
if (fland.lnd_own != player->cnum) {
|
||||||
pr("Not your unit!\n");
|
pr("Not your unit!\n");
|
||||||
|
|
|
@ -240,9 +240,6 @@ anti_torp(int f, int ntorping, int vshipown)
|
||||||
continue;
|
continue;
|
||||||
if (dd.shp_own != vshipown)
|
if (dd.shp_own != vshipown)
|
||||||
continue;
|
continue;
|
||||||
if (dd.shp_effic < 60)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!canshoot(&dd, &sub))
|
if (!canshoot(&dd, &sub))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -326,6 +323,7 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
||||||
int gun;
|
int gun;
|
||||||
double guneff;
|
double guneff;
|
||||||
|
|
||||||
|
if ((mchr[(int)targ->shp_type].m_flags & M_SUB) == 0) {
|
||||||
shells = sp->shp_item[I_SHELL];
|
shells = sp->shp_item[I_SHELL];
|
||||||
gun = sp->shp_item[I_GUN];
|
gun = sp->shp_item[I_GUN];
|
||||||
gun = MIN(gun, sp->shp_glim);
|
gun = MIN(gun, sp->shp_glim);
|
||||||
|
@ -348,7 +346,6 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
||||||
if (ntargets > 2)
|
if (ntargets > 2)
|
||||||
dam /= ntargets / 2;
|
dam /= ntargets / 2;
|
||||||
|
|
||||||
if ((mchr[(int)targ->shp_type].m_flags & M_SUB) == 0) {
|
|
||||||
pr_beep();
|
pr_beep();
|
||||||
pr("Kaboom!!! Incoming shells!\n");
|
pr("Kaboom!!! Incoming shells!\n");
|
||||||
if (sp->shp_own != 0)
|
if (sp->shp_own != 0)
|
||||||
|
@ -359,6 +356,13 @@ fire_dchrg(struct shpstr *sp, struct shpstr *targ, int ntargets)
|
||||||
shipdamage(targ, dam);
|
shipdamage(targ, dam);
|
||||||
putship(targ->shp_uid, targ);
|
putship(targ->shp_uid, targ);
|
||||||
} else {
|
} 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");
|
pr("\nCAPTAIN! !!Depth charges!!...\n");
|
||||||
if (sp->shp_own != 0)
|
if (sp->shp_own != 0)
|
||||||
wu(0, sp->shp_own,
|
wu(0, sp->shp_own,
|
||||||
|
|
|
@ -101,6 +101,29 @@ fort_fire(struct sctstr *sp)
|
||||||
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.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -569,6 +569,12 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
range = roundrange(effrange(sp->shp_frnge, sp->shp_tech));
|
range = roundrange(effrange(sp->shp_frnge, sp->shp_tech));
|
||||||
if (md > range)
|
if (md > range)
|
||||||
continue;
|
continue;
|
||||||
|
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 = sp->shp_item[I_GUN];
|
||||||
gun = MIN(gun, sp->shp_glim);
|
gun = MIN(gun, sp->shp_glim);
|
||||||
shell = sp->shp_item[I_SHELL];
|
shell = sp->shp_item[I_SHELL];
|
||||||
|
@ -582,6 +588,9 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
continue;
|
continue;
|
||||||
gun = MAX(gun, 1);
|
gun = MAX(gun, 1);
|
||||||
dam2 = seagun(sp->shp_effic, gun);
|
dam2 = seagun(sp->shp_effic, gun);
|
||||||
|
sp->shp_item[I_SHELL] = shell - gun;
|
||||||
|
putship(sp->shp_uid, sp);
|
||||||
|
}
|
||||||
if (range == 0.0)
|
if (range == 0.0)
|
||||||
prb = 1.0;
|
prb = 1.0;
|
||||||
else
|
else
|
||||||
|
@ -600,9 +609,6 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
||||||
|
|
||||||
mpr(victim, "%s %s fires at you at %s\n",
|
mpr(victim, "%s %s fires at you at %s\n",
|
||||||
cname(sp->shp_own), prship(sp), xyas(x, y, victim));
|
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) {
|
} else if (glp->thing->ef_type == EF_PLANE) {
|
||||||
pcp = glp->cp;
|
pcp = glp->cp;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue