Factor out common fortress fire code into fort_fire()
This takes care of a number of bugs / inconsistencies: * sb() fired support even when there were not enough mil. * Shell resupply bugs: multifire() and quiet_bigdef() resupplied shells before checking all other requirements and could thus get more shells than actually needed. Rename landgun() to fortgun() for consistency.
This commit is contained in:
parent
3812cde100
commit
e8595066d1
8 changed files with 50 additions and 81 deletions
|
@ -181,9 +181,7 @@ sb(natid att, natid def, struct sctstr *sp, coord tx, coord ty, int noisy,
|
|||
{
|
||||
int damage;
|
||||
natid own;
|
||||
int shell;
|
||||
int range;
|
||||
int range2, gun;
|
||||
int range, range2;
|
||||
|
||||
own = sp->sct_own;
|
||||
if (own == 0)
|
||||
|
@ -194,18 +192,10 @@ sb(natid att, natid def, struct sctstr *sp, coord tx, coord ty, int noisy,
|
|||
range2 = mapdist(sp->sct_x, sp->sct_y, tx, ty);
|
||||
if (range < range2)
|
||||
return 0;
|
||||
gun = sp->sct_item[I_GUN];
|
||||
if (gun == 0)
|
||||
return 0;
|
||||
shell = sp->sct_item[I_SHELL];
|
||||
if (shell <= 0)
|
||||
shell += supply_commod(sp->sct_own, sp->sct_x, sp->sct_y,
|
||||
I_SHELL, 1);
|
||||
if (shell <= 0)
|
||||
return 0;
|
||||
sp->sct_item[I_SHELL] = shell - 1;
|
||||
damage = fort_fire(sp);
|
||||
putsect(sp);
|
||||
damage = landgun((int)sp->sct_effic, gun);
|
||||
if (damage < 0)
|
||||
return 0;
|
||||
if (sp->sct_own != def)
|
||||
wu(0, sp->sct_own,
|
||||
"%s fired on %s in %s in defense of %s, doing %d damage!\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue