Factor out common torpedo fire code into shp_torp()
This takes care of a number of bugs / inconsistencies: * Submarines with zero mobility could interdict. Change to require positive mobility. * Submarines with zero firing range could not interdict. Fix by dropping the test from perform_mission(). No ships in the stock game are affected. * Submarines without capability torp could fire return torpedoes and interdict. Stock sbc, nm and msb were affected by the return fire bug. Closes bug#950936. * Shell resupply bugs: quiet_bigdef(), fire_torp() and perform_mission() resupplied before checking all other requirements and could thus get more shells than actually needed. torp() no longer resupplies shells. It's hardly worth the bother, and fire doesn't do it either.
This commit is contained in:
parent
21733d1473
commit
6d83090aad
5 changed files with 60 additions and 105 deletions
|
@ -507,34 +507,15 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
a sub. */
|
||||
if (*s != 's')
|
||||
continue;
|
||||
if (sp->shp_effic < 60)
|
||||
continue;
|
||||
if (sp->shp_frnge == 0)
|
||||
continue;
|
||||
if (sp->shp_item[I_MILIT] < 1)
|
||||
continue;
|
||||
if (sp->shp_mobil < 0)
|
||||
continue;
|
||||
gun = sp->shp_item[I_GUN];
|
||||
if (gun < 1)
|
||||
continue;
|
||||
shell = sp->shp_item[I_SHELL];
|
||||
if (shell < SHP_TORP_SHELLS)
|
||||
shell += supply_commod(sp->shp_own,
|
||||
sp->shp_x, sp->shp_y, I_SHELL,
|
||||
SHP_TORP_SHELLS - shell);
|
||||
if (shell < SHP_TORP_SHELLS)
|
||||
continue;
|
||||
|
||||
range = roundrange(torprange(sp));
|
||||
if (md > range)
|
||||
continue;
|
||||
|
||||
if (!line_of_sight(NULL, x, y, gp->x, gp->y))
|
||||
continue;
|
||||
sp->shp_item[I_SHELL] = shell - SHP_TORP_SHELLS;
|
||||
sp->shp_mobil -= shp_mobcost(sp) / 2.0;
|
||||
dam2 = shp_torp(sp, 1);
|
||||
putship(sp->shp_uid, sp);
|
||||
if (dam2 < 0)
|
||||
continue;
|
||||
hitchance = DTORP_HITCHANCE(md, sp->shp_visib);
|
||||
|
||||
wu(0, sp->shp_own,
|
||||
|
@ -546,7 +527,7 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
"\tWhooosh... Hitchance = %d%%\n",
|
||||
(int)(hitchance * 100));
|
||||
|
||||
if (hitchance < 1.0 && !chance(hitchance)) {
|
||||
if (!chance(hitchance)) {
|
||||
wu(0, sp->shp_own, "\tMissed\n");
|
||||
mpr(victim,
|
||||
"Incoming torpedo sighted @ %s missed (whew)!\n",
|
||||
|
@ -554,8 +535,6 @@ perform_mission(coord x, coord y, natid victim, struct emp_qelem *list,
|
|||
continue;
|
||||
}
|
||||
wu(0, sp->shp_own, "\tBOOM!...\n");
|
||||
dam2 = TORP_DAMAGE();
|
||||
|
||||
dam += dam2;
|
||||
nreport(victim, N_TORP_SHIP, 0, 1);
|
||||
wu(0, sp->shp_own,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue