(ac_calc_flak,ac_fireflak,pinflak_planedamage): New ac_calc_flak().
Move common flak damage code from ac_fireflak() and pinflak_planedamage() to ac_calc_flak().
This commit is contained in:
parent
3645ee77c8
commit
2c4b89e2d1
4 changed files with 35 additions and 40 deletions
|
@ -175,6 +175,7 @@ extern void ac_doflak(struct emp_qelem *, struct sctstr *);
|
||||||
extern void ac_shipflak(struct emp_qelem *, coord, coord);
|
extern void ac_shipflak(struct emp_qelem *, coord, coord);
|
||||||
extern void ac_landflak(struct emp_qelem *, coord, coord);
|
extern void ac_landflak(struct emp_qelem *, coord, coord);
|
||||||
extern void ac_fireflak(struct emp_qelem *, natid, natid, int);
|
extern void ac_fireflak(struct emp_qelem *, natid, natid, int);
|
||||||
|
extern int ac_flak_dam(int);
|
||||||
extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
|
extern void ac_encounter(struct emp_qelem *, struct emp_qelem *, coord,
|
||||||
coord, s_char *, int, int,
|
coord, s_char *, int, int,
|
||||||
struct emp_qelem *, struct emp_qelem *);
|
struct emp_qelem *, struct emp_qelem *);
|
||||||
|
|
|
@ -885,11 +885,6 @@ strat_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
putsect(§);
|
putsect(§);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLAK_MAX 15
|
|
||||||
float lflaktable[16] = { 0.20, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50,
|
|
||||||
0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85,
|
|
||||||
};
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
||||||
int flak)
|
int flak)
|
||||||
|
@ -902,26 +897,13 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
natid plane_owner;
|
natid plane_owner;
|
||||||
int dam;
|
int dam;
|
||||||
float mult;
|
|
||||||
|
|
||||||
flak -= (pp->pln_def + 1);
|
flak -= (pp->pln_def + 1);
|
||||||
if (pcp->pl_flags & P_X)
|
if (pcp->pl_flags & P_X)
|
||||||
flak -= 2;
|
flak -= 2;
|
||||||
if (pcp->pl_flags & P_H)
|
if (pcp->pl_flags & P_H)
|
||||||
flak -= 1;
|
flak -= 1;
|
||||||
if (flak > 8)
|
dam = ac_flak_dam(flak);
|
||||||
mult = lflaktable[FLAK_MAX] * 1.33;
|
|
||||||
else if (flak < -7)
|
|
||||||
mult = lflaktable[0] * 0.66;
|
|
||||||
else {
|
|
||||||
flak += 7;
|
|
||||||
mult = lflaktable[flak];
|
|
||||||
}
|
|
||||||
mult *= flakscale;
|
|
||||||
dam = (int)((roll(8) + 2) * mult);
|
|
||||||
if (dam > 100)
|
|
||||||
dam = 100;
|
|
||||||
|
|
||||||
disp = 0;
|
disp = 0;
|
||||||
plane_owner = pp->pln_own;
|
plane_owner = pp->pln_own;
|
||||||
eff = pp->pln_effic;
|
eff = pp->pln_effic;
|
||||||
|
|
|
@ -161,7 +161,7 @@ double bankint = 0.25; /* bank interest rate (dt * bars) */
|
||||||
double tradetax = 0.99; /* Tax charged on trade */
|
double tradetax = 0.99; /* Tax charged on trade */
|
||||||
double buytax = 1.0; /* Tax charged on market purchases */
|
double buytax = 1.0; /* Tax charged on market purchases */
|
||||||
int startmob = 127; /* Sanctuary starting mobility */
|
int startmob = 127; /* Sanctuary starting mobility */
|
||||||
double flakscale = 1.75; /* Scale factor for flak damage */
|
float flakscale = 1.75f; /* Scale factor for flak damage */
|
||||||
|
|
||||||
/* money gained from taxes, paid to military, and reservists */
|
/* money gained from taxes, paid to military, and reservists */
|
||||||
double money_civ = 0.0083333;
|
double money_civ = 0.0083333;
|
||||||
|
|
|
@ -61,13 +61,6 @@ static void getilist(struct emp_qelem *list, natid own,
|
||||||
struct emp_qelem *c, struct emp_qelem *d);
|
struct emp_qelem *c, struct emp_qelem *d);
|
||||||
static void ac_dog(struct plist *ap, struct plist *dp);
|
static void ac_dog(struct plist *ap, struct plist *dp);
|
||||||
|
|
||||||
#define FLAK_MAX 15
|
|
||||||
|
|
||||||
/* -7 -6 -5 -4 -3 -2 -1 0 */
|
|
||||||
float flaktable[16] = { 0.20, 0.20, 0.25, 0.30, 0.35, 0.40, 0.45, 0.50,
|
|
||||||
0.50, 0.55, 0.60, 0.65, 0.70, 0.75, 0.80, 0.85,
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
ac_encounter(struct emp_qelem *bomb_list, struct emp_qelem *esc_list,
|
||||||
coord x, coord y, s_char *path, int mission_flags,
|
coord x, coord y, s_char *path, int mission_flags,
|
||||||
|
@ -940,7 +933,6 @@ ac_fireflak(struct emp_qelem *list, natid from, natid other, int guns)
|
||||||
struct plnstr *pp;
|
struct plnstr *pp;
|
||||||
struct plist *plp;
|
struct plist *plp;
|
||||||
int n;
|
int n;
|
||||||
float mult;
|
|
||||||
int diff;
|
int diff;
|
||||||
struct emp_qelem *qp;
|
struct emp_qelem *qp;
|
||||||
struct emp_qelem *next;
|
struct emp_qelem *next;
|
||||||
|
@ -964,22 +956,42 @@ ac_fireflak(struct emp_qelem *list, natid from, natid other, int guns)
|
||||||
diff -= 2;
|
diff -= 2;
|
||||||
if (plp->pcp->pl_flags & P_H)
|
if (plp->pcp->pl_flags & P_H)
|
||||||
diff -= 1;
|
diff -= 1;
|
||||||
if (diff > 8)
|
n = ac_flak_dam(diff);
|
||||||
mult = flaktable[FLAK_MAX] * 1.33;
|
|
||||||
else if (diff < -7)
|
|
||||||
mult = flaktable[0] * 0.66;
|
|
||||||
else {
|
|
||||||
diff += 7;
|
|
||||||
mult = flaktable[diff];
|
|
||||||
}
|
|
||||||
mult *= flakscale;
|
|
||||||
n = (int)((roll(8) + 2) * mult);
|
|
||||||
if (n > 100)
|
|
||||||
n = 100;
|
|
||||||
ac_planedamage(plp, from, n, other, 2, 1, msg);
|
ac_planedamage(plp, from, n, other, 2, 1, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculate flak damage
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
ac_flak_dam(int flak)
|
||||||
|
{
|
||||||
|
int dam;
|
||||||
|
float mult;
|
||||||
|
/* <-7 -7 -6 -5 -4 */
|
||||||
|
static float flaktable[18] = { 0.132f, 0.20f, 0.20f, 0.25f, 0.30f,
|
||||||
|
/* -3 -2 -1 0 +1 +2 +3 +4 */
|
||||||
|
0.35f, 0.40f, 0.45f, 0.50f, 0.50f, 0.55f, 0.60f, 0.65f,
|
||||||
|
/* +5 +6 +7 +8 >+8 */
|
||||||
|
0.70f,0.75f, 0.80f, 0.85f, 1.1305f };
|
||||||
|
enum { FLAK_MAX = sizeof(flaktable)/sizeof(flaktable[0]) };
|
||||||
|
|
||||||
|
if (flak > 8)
|
||||||
|
mult = flaktable[FLAK_MAX];
|
||||||
|
else if (flak < -7)
|
||||||
|
mult = flaktable[0];
|
||||||
|
else {
|
||||||
|
flak += 8;
|
||||||
|
mult = flaktable[flak];
|
||||||
|
}
|
||||||
|
mult *= flakscale;
|
||||||
|
dam = (int)((roll(8) + 2) * mult);
|
||||||
|
if (dam > 100)
|
||||||
|
dam = 100;
|
||||||
|
return(dam);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* See if this plane is flying in this list
|
* See if this plane is flying in this list
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue