(ac_flak_dam): Redesign so that code common to all its callers ends up
in this function.
This commit is contained in:
parent
d9c48789fb
commit
d240bad7f8
3 changed files with 13 additions and 25 deletions
|
@ -157,7 +157,7 @@ struct shiplist {
|
|||
/* src/lib/subs/aircombat.c */
|
||||
extern void ac_combat_headers(natid, natid);
|
||||
extern void ac_airtoair(struct emp_qelem *, struct emp_qelem *);
|
||||
extern int ac_flak_dam(int);
|
||||
extern int ac_flak_dam(int, int, int);
|
||||
extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
|
||||
coord, char *, int, int,
|
||||
struct emp_qelem *, struct emp_qelem *);
|
||||
|
|
|
@ -864,14 +864,7 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
|||
natid plane_owner;
|
||||
int dam;
|
||||
|
||||
flak -= pp->pln_def;
|
||||
if ((pcp->pl_flags & P_T) == 0)
|
||||
flak--;
|
||||
if (pcp->pl_flags & P_X)
|
||||
flak -= 2;
|
||||
if (pcp->pl_flags & P_H)
|
||||
flak -= 1;
|
||||
dam = ac_flak_dam(flak);
|
||||
dam = ac_flak_dam(flak, pp->pln_def, pcp->pl_flags);
|
||||
disp = 0;
|
||||
plane_owner = pp->pln_own;
|
||||
eff = pp->pln_effic;
|
||||
|
|
|
@ -958,22 +958,9 @@ ac_fireflak(struct emp_qelem *list, natid from, int guns)
|
|||
plp = (struct plist *)list->q_forw;
|
||||
|
||||
for (qp = list->q_forw; qp != list; qp = next) {
|
||||
/*
|
||||
* fighters don't get shot at by flak
|
||||
* non-tactical bombers are harder to hit with flak.
|
||||
* ('Cause they're not dive-bombing?)
|
||||
*/
|
||||
next = qp->q_forw;
|
||||
plp = (struct plist *)qp;
|
||||
pp = &plp->plane;
|
||||
diff = guns - pp->pln_def;
|
||||
if ((plp->pcp->pl_flags & P_T) == 0)
|
||||
diff--;
|
||||
if (plp->pcp->pl_flags & P_X)
|
||||
diff -= 2;
|
||||
if (plp->pcp->pl_flags & P_H)
|
||||
diff -= 1;
|
||||
n = ac_flak_dam(diff);
|
||||
n = ac_flak_dam(guns, plp->plane.pln_def, plp->pcp->pl_flags);
|
||||
ac_planedamage(plp, from, n, 0, 2, 1, msg);
|
||||
}
|
||||
}
|
||||
|
@ -982,9 +969,9 @@ ac_fireflak(struct emp_qelem *list, natid from, int guns)
|
|||
* Calculate flak damage
|
||||
*/
|
||||
int
|
||||
ac_flak_dam(int flak)
|
||||
ac_flak_dam(int guns, int def, int pl_flags)
|
||||
{
|
||||
int dam;
|
||||
int flak, dam;
|
||||
float mult;
|
||||
/* <-7 -7 -6 -5 -4 */
|
||||
static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
|
||||
|
@ -994,6 +981,14 @@ ac_flak_dam(int flak)
|
|||
0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
|
||||
enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) - 1 };
|
||||
|
||||
flak = guns - def;
|
||||
if ((pl_flags & P_T) == 0)
|
||||
flak--;
|
||||
if (pl_flags & P_X)
|
||||
flak -= 2;
|
||||
if (pl_flags & P_H)
|
||||
flak -= 1;
|
||||
|
||||
if (flak > 8)
|
||||
mult = flaktable[FLAK_MAX];
|
||||
else if (flak < -7)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue