Don't store plane stats in struct plnstr
New pln_att(), pln_def(), pln_acc(), pln_range_max(), pln_load() replace the struct plnstr members with the same names. Make plane selectors att and def virtual.
This commit is contained in:
parent
d1a193ff07
commit
ffc5d0cfd7
15 changed files with 111 additions and 73 deletions
|
@ -62,14 +62,8 @@ struct plnstr {
|
||||||
short pln_radius; /* mission radius */
|
short pln_radius; /* mission radius */
|
||||||
/* end of part matching struct empobj */
|
/* end of part matching struct empobj */
|
||||||
unsigned char pln_range; /* total distance, not radius */
|
unsigned char pln_range; /* total distance, not radius */
|
||||||
unsigned char pln_range_max; /* max range for this plane */
|
|
||||||
short pln_ship; /* pointer to carrier */
|
short pln_ship; /* pointer to carrier */
|
||||||
short pln_land; /* pointer to carrier */
|
short pln_land; /* pointer to carrier */
|
||||||
int pln_att; /* plane air-air attack/defense values */
|
|
||||||
int pln_def;
|
|
||||||
int pln_acc;
|
|
||||||
int pln_load;
|
|
||||||
int pln_fuel; /* (unused) */
|
|
||||||
signed char pln_harden; /* for missiles */
|
signed char pln_harden; /* for missiles */
|
||||||
signed char pln_nuketype; /* type of nuclear armament (if any) */
|
signed char pln_nuketype; /* type of nuclear armament (if any) */
|
||||||
signed char pln_flags; /* State of the plane */
|
signed char pln_flags; /* State of the plane */
|
||||||
|
@ -154,6 +148,11 @@ extern int pl_def(struct plchrstr *, int);
|
||||||
extern int pl_acc(struct plchrstr *, int);
|
extern int pl_acc(struct plchrstr *, int);
|
||||||
extern int pl_range(struct plchrstr *, int);
|
extern int pl_range(struct plchrstr *, int);
|
||||||
extern int pl_load(struct plchrstr *, int);
|
extern int pl_load(struct plchrstr *, int);
|
||||||
|
extern int pln_att(struct plnstr *);
|
||||||
|
extern int pln_def(struct plnstr *);
|
||||||
|
extern int pln_acc(struct plnstr *);
|
||||||
|
extern int pln_range_max(struct plnstr *);
|
||||||
|
extern int pln_load(struct plnstr *);
|
||||||
|
|
||||||
/* src/lib/subs/aircombat.c */
|
/* src/lib/subs/aircombat.c */
|
||||||
extern void ac_combat_headers(natid, natid);
|
extern void ac_combat_headers(natid, natid);
|
||||||
|
|
|
@ -90,7 +90,7 @@ arm(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ncp = &nchr[nuke.nuk_type];
|
ncp = &nchr[nuke.nuk_type];
|
||||||
if (pl.pln_load < ncp->n_weight) {
|
if (pln_load(&pl) < ncp->n_weight) {
|
||||||
pr("A %s cannot carry %s devices!\n",
|
pr("A %s cannot carry %s devices!\n",
|
||||||
plc->pl_name, ncp->n_name);
|
plc->pl_name, ncp->n_name);
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
|
|
|
@ -849,7 +849,7 @@ pinflak_planedamage(struct plnstr *pp, struct plchrstr *pcp, natid from,
|
||||||
natid plane_owner;
|
natid plane_owner;
|
||||||
int dam;
|
int dam;
|
||||||
|
|
||||||
dam = ac_flak_dam(flak, pp->pln_def, pcp->pl_flags);
|
dam = ac_flak_dam(flak, pln_def(pp), pcp->pl_flags);
|
||||||
disp = 0;
|
disp = 0;
|
||||||
plane_owner = pp->pln_own;
|
plane_owner = pp->pln_own;
|
||||||
eff = pp->pln_effic;
|
eff = pp->pln_effic;
|
||||||
|
|
|
@ -783,7 +783,6 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
|
||||||
plane.pln_opy = 0;
|
plane.pln_opy = 0;
|
||||||
plane.pln_radius = 0;
|
plane.pln_radius = 0;
|
||||||
plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
|
plane.pln_range = UCHAR_MAX; /* will be adjusted by pln_set_tech() */
|
||||||
plane.pln_range_max = plane.pln_range;
|
|
||||||
plane.pln_wing = 0;
|
plane.pln_wing = 0;
|
||||||
plane.pln_ship = -1;
|
plane.pln_ship = -1;
|
||||||
plane.pln_land = -1;
|
plane.pln_land = -1;
|
||||||
|
|
|
@ -202,7 +202,7 @@ launch_as(struct plnstr *pp)
|
||||||
pr("No satellites there!\n");
|
pr("No satellites there!\n");
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
if (msl_hit(pp, plane.pln_def, EF_PLANE, N_SAT_KILL, N_SAT_KILL,
|
if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL,
|
||||||
prplane(&plane), sx, sy, plane.pln_own)) {
|
prplane(&plane), sx, sy, plane.pln_own)) {
|
||||||
dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1);
|
dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1);
|
||||||
oldown = plane.pln_own;
|
oldown = plane.pln_own;
|
||||||
|
|
|
@ -228,22 +228,22 @@ pdump(void)
|
||||||
pr(" %d", plane.pln_tech);
|
pr(" %d", plane.pln_tech);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
pr(" %d", plane.pln_att);
|
pr(" %d", pln_att(&plane));
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
pr(" %d", plane.pln_def);
|
pr(" %d", pln_def(&plane));
|
||||||
break;
|
break;
|
||||||
case 10:
|
case 10:
|
||||||
pr(" %d", plane.pln_acc);
|
pr(" %d", pln_acc(&plane));
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
pr(" %d", plane.pln_range);
|
pr(" %d", plane.pln_range);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
pr(" %d", plane.pln_range_max);
|
pr(" %d", pln_range_max(&plane));
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
pr(" %d", plane.pln_load);
|
pr(" %d", pln_load(&plane));
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
pr(" %d", plchr[(int)plane.pln_type].pl_fuel);
|
pr(" %d", plchr[(int)plane.pln_type].pl_fuel);
|
||||||
|
|
|
@ -66,7 +66,7 @@ plan(void)
|
||||||
prxy("%4d,%-4d", plane.pln_x, plane.pln_y, player->cnum);
|
prxy("%4d,%-4d", plane.pln_x, plane.pln_y, player->cnum);
|
||||||
pr(" %1.1s %c%3d%% %3d %3d %4d %3d %3d",
|
pr(" %1.1s %c%3d%% %3d %3d %4d %3d %3d",
|
||||||
&plane.pln_wing, plane.pln_off ? '!' : ' ', plane.pln_effic,
|
&plane.pln_wing, plane.pln_off ? '!' : ' ', plane.pln_effic,
|
||||||
plane.pln_mobil, plane.pln_def, plane.pln_tech,
|
plane.pln_mobil, pln_def(&plane), plane.pln_tech,
|
||||||
plane.pln_range, plane.pln_harden);
|
plane.pln_range, plane.pln_harden);
|
||||||
if (plane.pln_ship >= 0)
|
if (plane.pln_ship >= 0)
|
||||||
pr("%5dS", plane.pln_ship);
|
pr("%5dS", plane.pln_ship);
|
||||||
|
|
|
@ -58,10 +58,10 @@ pstat(void)
|
||||||
pr(" %3d%% %4d %3d %3d %3d %3d %4d %4d",
|
pr(" %3d%% %4d %3d %3d %3d %3d %4d %4d",
|
||||||
plane.pln_effic,
|
plane.pln_effic,
|
||||||
plane.pln_tech,
|
plane.pln_tech,
|
||||||
plane.pln_att,
|
pln_att(&plane),
|
||||||
plane.pln_def,
|
pln_def(&plane),
|
||||||
plane.pln_acc,
|
pln_acc(&plane),
|
||||||
plane.pln_range_max, plane.pln_load,
|
pln_range_max(&plane), pln_load(&plane),
|
||||||
plchr[(int)plane.pln_type].pl_fuel);
|
plchr[(int)plane.pln_type].pl_fuel);
|
||||||
pr("\n");
|
pr("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ range(void)
|
||||||
{
|
{
|
||||||
struct nstr_item np;
|
struct nstr_item np;
|
||||||
struct plnstr plane;
|
struct plnstr plane;
|
||||||
int i;
|
int i, rmax;
|
||||||
char *p;
|
char *p;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
|
@ -56,8 +56,8 @@ range(void)
|
||||||
return RET_SYN;
|
return RET_SYN;
|
||||||
if (!p || (i = atoi(p)) < 0)
|
if (!p || (i = atoi(p)) < 0)
|
||||||
continue;
|
continue;
|
||||||
plane.pln_range = (plane.pln_range_max < i) ?
|
rmax = pln_range_max(&plane);
|
||||||
plane.pln_range_max : i;
|
plane.pln_range = MIN(rmax, i);
|
||||||
pr("Plane %d range changed to %d\n",
|
pr("Plane %d range changed to %d\n",
|
||||||
plane.pln_uid, plane.pln_range);
|
plane.pln_uid, plane.pln_range);
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ plane_sona(struct emp_qelem *plane_list, int x, int y,
|
||||||
pcp = ip->pcp;
|
pcp = ip->pcp;
|
||||||
if (!(pcp->pl_flags & P_A)) /* if it isn't an ASW plane */
|
if (!(pcp->pl_flags & P_A)) /* if it isn't an ASW plane */
|
||||||
continue;
|
continue;
|
||||||
range = (int)techfact(pp->pln_tech, (100.0 - pp->pln_acc) / 10.0);
|
range = (int)techfact(pp->pln_tech, (100.0 - pln_acc(pp)) / 10.0);
|
||||||
for (i = 0; getship(i, &s); i++) {
|
for (i = 0; getship(i, &s); i++) {
|
||||||
targ = &s;
|
targ = &s;
|
||||||
if (targ->shp_own == pp->pln_own || targ->shp_own == 0)
|
if (targ->shp_own == pp->pln_own || targ->shp_own == 0)
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
#include "product.h"
|
#include "product.h"
|
||||||
|
|
||||||
static void *nsc_ver(struct valstr *, natid, void *);
|
static void *nsc_ver(struct valstr *, natid, void *);
|
||||||
|
static void *nsc_pln_att(struct valstr *, natid, void *);
|
||||||
|
static void *nsc_pln_def(struct valstr *, natid, void *);
|
||||||
|
|
||||||
/* Ugly hack to improve legibility by avoid long lines */
|
/* Ugly hack to improve legibility by avoid long lines */
|
||||||
#define fldoff(fld) offsetof(CURSTR, fld)
|
#define fldoff(fld) offsetof(CURSTR, fld)
|
||||||
|
@ -282,8 +284,6 @@ struct castr plane_ca[] = {
|
||||||
{"range", fldoff(pln_range), NSC_UCHAR, 0, NULL, EF_BAD, 0},
|
{"range", fldoff(pln_range), NSC_UCHAR, 0, NULL, EF_BAD, 0},
|
||||||
{"ship", fldoff(pln_ship), NSC_SHORT, 0, NULL, EF_BAD, 0},
|
{"ship", fldoff(pln_ship), NSC_SHORT, 0, NULL, EF_BAD, 0},
|
||||||
{"land", fldoff(pln_land), NSC_SHORT, 0, NULL, EF_BAD, 0},
|
{"land", fldoff(pln_land), NSC_SHORT, 0, NULL, EF_BAD, 0},
|
||||||
{"att", fldoff(pln_att), NSC_INT, 0, NULL, EF_BAD, NSC_EXTRA},
|
|
||||||
{"def", fldoff(pln_def), NSC_INT, 0, NULL, EF_BAD, NSC_EXTRA},
|
|
||||||
{"harden", fldoff(pln_harden), NSC_CHAR, 0, NULL, EF_BAD, 0},
|
{"harden", fldoff(pln_harden), NSC_CHAR, 0, NULL, EF_BAD, 0},
|
||||||
{"nuketype", fldoff(pln_nuketype), NSC_CHAR, 0, NULL, EF_BAD, 0},
|
{"nuketype", fldoff(pln_nuketype), NSC_CHAR, 0, NULL, EF_BAD, 0},
|
||||||
{"flags", fldoff(pln_flags), NSC_CHAR, 0, NULL,
|
{"flags", fldoff(pln_flags), NSC_CHAR, 0, NULL,
|
||||||
|
@ -292,6 +292,8 @@ struct castr plane_ca[] = {
|
||||||
{"timestamp", fldoff(pln_timestamp), NSC_TIME, 0, NULL,
|
{"timestamp", fldoff(pln_timestamp), NSC_TIME, 0, NULL,
|
||||||
EF_BAD, NSC_EXTRA},
|
EF_BAD, NSC_EXTRA},
|
||||||
{"theta", fldoff(pln_theta), NSC_FLOAT, 0, NULL, EF_BAD, 0},
|
{"theta", fldoff(pln_theta), NSC_FLOAT, 0, NULL, EF_BAD, 0},
|
||||||
|
{"att", 0, NSC_LONG, 0, nsc_pln_att, EF_BAD, NSC_EXTRA},
|
||||||
|
{"def", 0, NSC_LONG, 0, nsc_pln_def, EF_BAD, NSC_EXTRA},
|
||||||
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
|
{NULL, 0, NSC_NOTYPE, 0, NULL, EF_BAD, 0}
|
||||||
#undef CURSTR
|
#undef CURSTR
|
||||||
};
|
};
|
||||||
|
@ -725,3 +727,17 @@ nsc_ver(struct valstr *val, natid cnum, void *ptr)
|
||||||
val->val_as.sym.get = NULL;
|
val->val_as.sym.get = NULL;
|
||||||
return kp->km_data;
|
return kp->km_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
nsc_pln_def(struct valstr *val, natid cnum, void *ptr)
|
||||||
|
{
|
||||||
|
val->val_as.lng = pln_def(ptr);;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void *
|
||||||
|
nsc_pln_att(struct valstr *val, natid cnum, void *ptr)
|
||||||
|
{
|
||||||
|
val->val_as.lng = pln_att(ptr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -84,3 +84,33 @@ pl_load(struct plchrstr *pcp, int tech)
|
||||||
{
|
{
|
||||||
return PLN_LOAD(pcp->pl_load, MAX(0, tech - pcp->pl_tech));
|
return PLN_LOAD(pcp->pl_load, MAX(0, tech - pcp->pl_tech));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pln_att(struct plnstr *pp)
|
||||||
|
{
|
||||||
|
return pl_att(plchr + pp->pln_type, pp->pln_tech);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pln_def(struct plnstr *pp)
|
||||||
|
{
|
||||||
|
return pl_def(plchr + pp->pln_type, pp->pln_tech);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pln_acc(struct plnstr *pp)
|
||||||
|
{
|
||||||
|
return pl_acc(plchr + pp->pln_type, pp->pln_tech);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pln_range_max(struct plnstr *pp)
|
||||||
|
{
|
||||||
|
return pl_range(plchr + pp->pln_type, pp->pln_tech);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
pln_load(struct plnstr *pp)
|
||||||
|
{
|
||||||
|
return pl_load(plchr + pp->pln_type, pp->pln_tech);
|
||||||
|
}
|
||||||
|
|
|
@ -622,15 +622,13 @@ ac_dog(struct plist *ap, struct plist *dp)
|
||||||
PR(def_own, " %3.3s #%-4d %3.3s #%-4d",
|
PR(def_own, " %3.3s #%-4d %3.3s #%-4d",
|
||||||
dp->pcp->pl_name,
|
dp->pcp->pl_name,
|
||||||
dp->plane.pln_uid, ap->pcp->pl_name, ap->plane.pln_uid);
|
dp->plane.pln_uid, ap->pcp->pl_name, ap->plane.pln_uid);
|
||||||
if (ap->plane.pln_att == 0) {
|
att = pln_att(&ap->plane);
|
||||||
att = ap->plane.pln_def * ap->plane.pln_effic / 100;
|
if (att == 0)
|
||||||
|
att = pln_def(&ap->plane);
|
||||||
|
att = att * ap->plane.pln_effic / 100;
|
||||||
att = MAX(att, ap->pcp->pl_def / 2);
|
att = MAX(att, ap->pcp->pl_def / 2);
|
||||||
} else {
|
|
||||||
att = ap->plane.pln_att * ap->plane.pln_effic / 100;
|
|
||||||
att = MAX(att, ap->pcp->pl_att / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
def = dp->plane.pln_def * dp->plane.pln_effic / 100;
|
def = pln_def(&dp->plane) * dp->plane.pln_effic / 100;
|
||||||
def = MAX(def, dp->pcp->pl_def / 2);
|
def = MAX(def, dp->pcp->pl_def / 2);
|
||||||
|
|
||||||
if ((ap->pcp->pl_flags & P_F) && ap->bombs != 0)
|
if ((ap->pcp->pl_flags & P_F) && ap->bombs != 0)
|
||||||
|
@ -954,7 +952,7 @@ ac_fireflak(struct emp_qelem *list, natid from, int guns)
|
||||||
for (qp = list->q_forw; qp != list; qp = next) {
|
for (qp = list->q_forw; qp != list; qp = next) {
|
||||||
next = qp->q_forw;
|
next = qp->q_forw;
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
n = ac_flak_dam(guns, plp->plane.pln_def, plp->pcp->pl_flags);
|
n = ac_flak_dam(guns, pln_def(&plp->plane), plp->pcp->pl_flags);
|
||||||
ac_planedamage(plp, from, n, 0, 2, 1, msg);
|
ac_planedamage(plp, from, n, 0, 2, 1, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -988,7 +988,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
|
||||||
{
|
{
|
||||||
struct plchrstr *pcp;
|
struct plchrstr *pcp;
|
||||||
struct plnstr *pp;
|
struct plnstr *pp;
|
||||||
int needed;
|
int load, needed;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct shpstr ship;
|
struct shpstr ship;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -1014,6 +1014,7 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
|
||||||
item[I_PETROL] -= pcp->pl_fuel;
|
item[I_PETROL] -= pcp->pl_fuel;
|
||||||
rval = 0;
|
rval = 0;
|
||||||
if (!(flags & P_F)) {
|
if (!(flags & P_F)) {
|
||||||
|
load = pln_load(pp);
|
||||||
itype = I_NONE;
|
itype = I_NONE;
|
||||||
needed = 0;
|
needed = 0;
|
||||||
switch (mission) {
|
switch (mission) {
|
||||||
|
@ -1021,35 +1022,35 @@ mission_pln_equip(struct plist *plp, struct ichrstr *ip, int flags,
|
||||||
case 'p':
|
case 'p':
|
||||||
if (pp->pln_nuketype == -1) {
|
if (pp->pln_nuketype == -1) {
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = pp->pln_load;
|
needed = load;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
||||||
break;
|
break;
|
||||||
itype = ip->i_uid;
|
itype = ip->i_uid;
|
||||||
needed = (pp->pln_load * 2) / ip->i_lbs;
|
needed = (load * 2) / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
||||||
break;
|
break;
|
||||||
itype = ip->i_uid;
|
itype = ip->i_uid;
|
||||||
needed = (pp->pln_load * 2) / ip->i_lbs;
|
needed = (load * 2) / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
if ((pcp->pl_flags & (P_V | P_C)) == 0)
|
if ((pcp->pl_flags & (P_V | P_C)) == 0)
|
||||||
break;
|
break;
|
||||||
itype = I_MILIT;
|
itype = I_MILIT;
|
||||||
needed = pp->pln_load / ip->i_lbs;
|
needed = load / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (pp->pln_nuketype == -1)
|
if (pp->pln_nuketype == -1)
|
||||||
rval = -1;
|
rval = -1;
|
||||||
break;
|
break;
|
||||||
case 'i': /* missile interception */
|
case 'i': /* missile interception */
|
||||||
if (pp->pln_load) {
|
if (load) {
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = pp->pln_load;
|
needed = load;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -595,7 +595,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
|
||||||
{
|
{
|
||||||
struct plchrstr *pcp;
|
struct plchrstr *pcp;
|
||||||
struct plnstr *pp;
|
struct plnstr *pp;
|
||||||
int needed;
|
int load, needed;
|
||||||
struct lndstr land;
|
struct lndstr land;
|
||||||
struct shpstr ship;
|
struct shpstr ship;
|
||||||
struct sctstr sect;
|
struct sctstr sect;
|
||||||
|
@ -635,6 +635,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
|
||||||
item[I_PETROL] -= pcp->pl_fuel;
|
item[I_PETROL] -= pcp->pl_fuel;
|
||||||
rval = 0;
|
rval = 0;
|
||||||
if ((flags & P_F) == 0) {
|
if ((flags & P_F) == 0) {
|
||||||
|
load = pln_load(pp);
|
||||||
itype = I_NONE;
|
itype = I_NONE;
|
||||||
needed = 0;
|
needed = 0;
|
||||||
switch (mission) {
|
switch (mission) {
|
||||||
|
@ -642,7 +643,7 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
|
||||||
case 'p':
|
case 'p':
|
||||||
if (pp->pln_nuketype == -1) {
|
if (pp->pln_nuketype == -1) {
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = pp->pln_load;
|
needed = load;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
|
@ -650,19 +651,19 @@ pln_equip(struct plist *plp, struct ichrstr *ip, int flags, char mission)
|
||||||
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
if ((pcp->pl_flags & P_C) == 0 || ip == 0)
|
||||||
break;
|
break;
|
||||||
itype = ip->i_uid;
|
itype = ip->i_uid;
|
||||||
needed = (pp->pln_load * 2) / ip->i_lbs;
|
needed = (load * 2) / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
if ((pcp->pl_flags & P_MINE) == 0)
|
if ((pcp->pl_flags & P_MINE) == 0)
|
||||||
break;
|
break;
|
||||||
itype = I_SHELL;
|
itype = I_SHELL;
|
||||||
needed = (pp->pln_load * 2) / ip->i_lbs;
|
needed = (load * 2) / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'a':
|
case 'a':
|
||||||
if ((pcp->pl_flags & (P_V | P_C)) == 0)
|
if ((pcp->pl_flags & (P_V | P_C)) == 0)
|
||||||
break;
|
break;
|
||||||
itype = I_MILIT;
|
itype = I_MILIT;
|
||||||
needed = pp->pln_load / ip->i_lbs;
|
needed = load / ip->i_lbs;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
if (pp->pln_nuketype == -1)
|
if (pp->pln_nuketype == -1)
|
||||||
|
@ -1010,7 +1011,7 @@ plane_sweep(struct emp_qelem *plane_list, coord x, coord y)
|
||||||
if (!(pcp->pl_flags & P_SWEEP)) /* if it isn't an sweep plane */
|
if (!(pcp->pl_flags & P_SWEEP)) /* if it isn't an sweep plane */
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (chance((100.0 - pp->pln_acc) / 100.0)) {
|
if (chance((100.0 - pln_acc(pp)) / 100.0)) {
|
||||||
pr("Sweep! in %s\n",
|
pr("Sweep! in %s\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, pp->pln_own));
|
xyas(sect.sct_x, sect.sct_y, pp->pln_own));
|
||||||
mines_there--;
|
mines_there--;
|
||||||
|
@ -1109,7 +1110,7 @@ pln_hitchance(struct plnstr *pp, int hardtarget, int type)
|
||||||
struct plchrstr *pcp = plchr + pp->pln_type;
|
struct plchrstr *pcp = plchr + pp->pln_type;
|
||||||
double tfact = (double)(pp->pln_tech - pcp->pl_tech) /
|
double tfact = (double)(pp->pln_tech - pcp->pl_tech) /
|
||||||
(pp->pln_tech - pcp->pl_tech / 2);
|
(pp->pln_tech - pcp->pl_tech / 2);
|
||||||
int acc = pp->pln_acc;
|
int acc = pln_acc(pp);
|
||||||
int hitchance;
|
int hitchance;
|
||||||
|
|
||||||
if (type == EF_SHIP) {
|
if (type == EF_SHIP) {
|
||||||
|
@ -1137,7 +1138,7 @@ pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
|
||||||
{
|
{
|
||||||
struct nukstr nuke;
|
struct nukstr nuke;
|
||||||
struct plchrstr *pcp = plchr + pp->pln_type;
|
struct plchrstr *pcp = plchr + pp->pln_type;
|
||||||
int i;
|
int load, i;
|
||||||
int hitroll;
|
int hitroll;
|
||||||
int dam = 0;
|
int dam = 0;
|
||||||
int aim;
|
int aim;
|
||||||
|
@ -1157,12 +1158,13 @@ pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
|
||||||
}
|
}
|
||||||
*nukedamp = 0;
|
*nukedamp = 0;
|
||||||
|
|
||||||
if (!pp->pln_load) /* e.g. ab, blowing up on launch pad */
|
load = pln_load(pp);
|
||||||
|
if (!load) /* e.g. ab, blowing up on launch pad */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
i = roll(pp->pln_load) + 1;
|
i = roll(load) + 1;
|
||||||
if (i > pp->pln_load)
|
if (i > load)
|
||||||
i = pp->pln_load;
|
i = load;
|
||||||
|
|
||||||
if (pcp->pl_flags & P_M) {
|
if (pcp->pl_flags & P_M) {
|
||||||
if (pcp->pl_flags & P_MAR)
|
if (pcp->pl_flags & P_MAR)
|
||||||
|
@ -1170,18 +1172,15 @@ pln_damage(struct plnstr *pp, coord x, coord y, char type, int *nukedamp,
|
||||||
} else if (pcp->pl_flags & P_T)
|
} else if (pcp->pl_flags & P_T)
|
||||||
pinbomber = 1;
|
pinbomber = 1;
|
||||||
|
|
||||||
aim = 100 - pp->pln_acc;
|
aim = pln_acc(pp);
|
||||||
if (type == 's') {
|
if (type == 's') {
|
||||||
if (pinbomber) {
|
effective = !pinbomber;
|
||||||
aim = pp->pln_acc;
|
aim = 30 + (pinbomber ? aim : 100 - aim);
|
||||||
effective = 0;
|
|
||||||
}
|
|
||||||
aim += 30;
|
|
||||||
} else {
|
} else {
|
||||||
if (!pinbomber) {
|
effective = pinbomber;
|
||||||
effective = 0;
|
aim = 100 - aim;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (i--) {
|
while (i--) {
|
||||||
dam += roll(6);
|
dam += roll(6);
|
||||||
hitroll = roll(100);
|
hitroll = roll(100);
|
||||||
|
@ -1225,7 +1224,7 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
|
||||||
if ((flags & P_F) || (flags & P_ESC))
|
if ((flags & P_F) || (flags & P_ESC))
|
||||||
cost /= 2;
|
cost /= 2;
|
||||||
|
|
||||||
return ldround(cost * dist / pp->pln_range_max + 5, 1);
|
return ldround(cost * dist / pln_range_max(pp) + 5, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1235,18 +1234,14 @@ void
|
||||||
pln_set_tech(struct plnstr *pp, int tlev)
|
pln_set_tech(struct plnstr *pp, int tlev)
|
||||||
{
|
{
|
||||||
struct plchrstr *pcp = plchr + pp->pln_type;
|
struct plchrstr *pcp = plchr + pp->pln_type;
|
||||||
int limited_range = pp->pln_range < pp->pln_range_max;
|
int limited_range = pp->pln_range < pln_range_max(pp);
|
||||||
|
int range_max;
|
||||||
|
|
||||||
if (CANT_HAPPEN(tlev < pcp->pl_tech))
|
if (CANT_HAPPEN(tlev < pcp->pl_tech))
|
||||||
tlev = pcp->pl_tech;
|
tlev = pcp->pl_tech;
|
||||||
|
|
||||||
pp->pln_tech = tlev;
|
pp->pln_tech = tlev;
|
||||||
pp->pln_att = pl_att(pcp, tlev);
|
|
||||||
pp->pln_def = pl_def(pcp, tlev);
|
|
||||||
pp->pln_acc = pl_acc(pcp, tlev);
|
|
||||||
pp->pln_range_max = pl_range(pcp, tlev);
|
|
||||||
pp->pln_load = pl_load(pcp, tlev);
|
|
||||||
|
|
||||||
if (!limited_range || pp->pln_range > pp->pln_range_max)
|
range_max = pln_range_max(pp);
|
||||||
pp->pln_range = pp->pln_range_max;
|
if (!limited_range || pp->pln_range > range_max)
|
||||||
|
pp->pln_range = range_max;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue