/* end of part matching struct empobj */
unsigned char shp_nplane; /* number of planes on board */
unsigned char shp_nland; /* number of land units on board */
- short shp_armor;
- short shp_speed;
- short shp_visib;
- short shp_frnge;
- short shp_glim;
coord shp_destx[2]; /* location for ship destination */
coord shp_desty[2];
i_type shp_tstart[TMAX]; /* what goods to pick up at start point */
extern int m_visib(struct mchrstr *, int);
extern int m_frnge(struct mchrstr *, int);
extern int m_glim(struct mchrstr *, int);
+extern int shp_armor(struct shpstr *);
+extern int shp_speed(struct shpstr *);
+extern int shp_visib(struct shpstr *);
+extern int shp_frnge(struct shpstr *);
+extern int shp_glim(struct shpstr *);
extern int shp_dchrg(struct shpstr *);
extern int shp_fire(struct shpstr *);
continue;
tmcp = &mchr[(int)sp->shp_type];
if (smcp->m_flags & M_SUB)
- vrange = (int)(sp->shp_visib * range / 30.0);
+ vrange = (int)(shp_visib(sp) * range / 30.0);
else
- vrange = (int)(sp->shp_visib * range / 20.0);
+ vrange = (int)(shp_visib(sp) * range / 20.0);
getsect(sp->shp_x, sp->shp_y, §);
if (sect.sct_type != SCT_WATER)
vrange = MAX(1, vrange);
pr("Not enough mil on ship #%d\n", item.ship.shp_uid);
continue;
}
- if (item.ship.shp_glim == 0) {
+ if (mchr[item.ship.shp_type].m_glim == 0) {
pr("Ships %d cannot fire guns!\n", item.ship.shp_uid);
continue;
}
pr(" %d", ship.shp_item[I_RAD]);
break;
case 27:
- pr(" %d", ship.shp_armor);
+ pr(" %d", shp_armor(&ship));
break;
case 28:
- pr(" %d", ship.shp_speed);
+ pr(" %d", shp_speed(&ship));
break;
case 29:
- pr(" %d", ship.shp_visib);
+ pr(" %d", shp_visib(&ship));
break;
case 30:
- pr(" %d", ship.shp_frnge);
+ pr(" %d", shp_frnge(&ship));
break;
case 31:
- pr(" %d", ship.shp_glim);
+ pr(" %d", shp_glim(&ship));
break;
case 32:
/*
struct mchrstr *tmcp;
struct nstr_sect ns;
int range;
- int pingrange;
+ int visib, pingrange;
int srange;
int vrange;
int dist;
if (targ.shp_own == player->cnum || targ.shp_own == 0)
continue;
tmcp = &mchr[(int)targ.shp_type];
- pingrange = MIN(7, MAX(targ.shp_visib, 10) * range / 10);
+ visib = shp_visib(&targ);
+ pingrange = MIN(7, MAX(visib, 10) * range / 10);
vrange = pingrange * ship.shp_effic / 200;
dist = mapdist(targ.shp_x, targ.shp_y, ship.shp_x, ship.shp_y);
pingrange = (MAX(pingrange, 2) * targ.shp_effic) / 100;
continue;
if (tmcp->m_flags & M_SUB &&
getrel(getnatp(targ.shp_own), player->cnum) < FRIENDLY) {
- if (mcp->m_vrnge + targ.shp_visib < 8)
+ if (mcp->m_vrnge + visib < 8)
pr("Sonar detects sub #%d @ %s\n",
targ.shp_uid,
xyas(targ.shp_x, targ.shp_y, player->cnum));
- else if (mcp->m_vrnge + targ.shp_visib < 10)
+ else if (mcp->m_vrnge + visib < 10)
pr("Sonar detects %s @ %s\n",
prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
cname(targ.shp_own), prship(&targ),
xyas(targ.shp_x, targ.shp_y, player->cnum));
- if (targ.shp_visib > vis[y][x]) {
- vis[y][x] = targ.shp_visib;
+ if (visib > vis[y][x]) {
+ vis[y][x] = visib;
/* &~0x20 makes it a cap letter */
rad[y][x] = (*mchr[(int)targ.shp_type].m_name) & ~0x20;
}
struct plist *ip;
struct sctstr sect;
int found = 0;
- int range, i;
+ int range, i, vis;
int pingrange;
int vrange;
int dist;
if (roll(100) > pln_identchance(pp, shp_hardtarget(targ),
EF_SHIP))
continue;
- pingrange = MAX(targ->shp_visib, 10) * range / 10;
+ vis = shp_visib(targ);
+ pingrange = MAX(vis, 10) * range / 10;
vrange = pingrange * (pp->pln_effic / 200.0);
dist = mapdist(targ->shp_x, targ->shp_y, x, y);
pingrange = (MAX(pingrange, 2) * targ->shp_effic);
pr(" %3d%% %4d %3d %3d %3d %3d %3d",
ship.shp_effic,
ship.shp_tech,
- ship.shp_armor,
- ship.shp_speed, ship.shp_visib, ship.shp_frnge, ship.shp_glim);
+ shp_armor(&ship), shp_speed(&ship), shp_visib(&ship),
+ shp_frnge(&ship), shp_glim(&ship));
pr("\n");
}
if (nships == 0) {
{
return SHP_FIR(mcp->m_glim, MAX(0, tech - mcp->m_tech));
}
+
+int
+shp_armor(struct shpstr *sp)
+{
+ return m_armor(mchr + sp->shp_type, sp->shp_tech);
+}
+
+int
+shp_speed(struct shpstr *sp)
+{
+ return m_speed(mchr + sp->shp_type, sp->shp_tech);
+}
+
+int
+shp_visib(struct shpstr *sp)
+{
+ return m_visib(mchr + sp->shp_type, sp->shp_tech);
+}
+
+int
+shp_frnge(struct shpstr *sp)
+{
+ return m_frnge(mchr + sp->shp_type, sp->shp_tech);
+}
+
+int
+shp_glim(struct shpstr *sp)
+{
+ return m_glim(mchr + sp->shp_type, sp->shp_tech);
+}
}
getship(off->shp_uid, &aship);
getship(def->shp_uid, &dship);
- if (techfact(aship.shp_tech, 1.0) * aship.shp_speed * off->eff
- <= techfact(dship.shp_tech, 1.0) * dship.shp_speed * def->eff) {
+ if (techfact(aship.shp_tech, shp_speed(&aship)) * off->eff
+ <= techfact(dship.shp_tech, shp_speed(&dship)) * def->eff) {
pr("Victim ship moves faster than you do!\n");
if (def->own)
wu(0, def->own,
case EF_SHIP:
/* the 2 in the formula below is a fudge factor */
getship(def->shp_uid, &ship);
- off->mobcost += (def->eff / 100) * (ship.shp_speed / 2);
+ off->mobcost += (def->eff / 100) * (shp_speed(&ship) / 2);
}
}
}
eff = sector_strength(getsectp(com->x, com->y));
} else if (com->type == EF_SHIP && com->own != player->cnum) {
getship(com->shp_uid, &ship);
- eff = 1.0 + ship.shp_armor / 100.0;
+ eff = 1.0 + shp_armor(&ship) / 100.0;
}
return eff;
}
void
shipdamage(struct shpstr *sp, int dam)
{
- ship_damage(sp, (int)(dam / (1.0 + sp->shp_armor / 100.0)));
+ ship_damage(sp, (int)(dam / (1.0 + shp_armor(sp) / 100.0)));
}
void
int
shp_usable_guns(struct shpstr *sp)
{
- return MIN(sp->shp_glim, sp->shp_item[I_GUN]);
+ return MIN(shp_glim(sp), sp->shp_item[I_GUN]);
}
/*
double
shp_fire_range(struct shpstr *sp)
{
- return effrange(sp->shp_frnge, sp->shp_tech);
+ return effrange(shp_frnge(sp), sp->shp_tech);
}
/*
double
torprange(struct shpstr *sp)
{
- return effrange(sp->shp_frnge * 2, sp->shp_tech)
+ return effrange(shp_frnge(sp) * 2, sp->shp_tech)
* sp->shp_effic / 100.0;
}
double
shp_torp_hitchance(struct shpstr *sp, int range)
{
- return DTORP_HITCHANCE(range, sp->shp_visib);
+ return DTORP_HITCHANCE(range, shp_visib(sp));
}
/*
radmap2(int owner,
int cx, int cy, int eff, int range, double seesub, int pr_flag)
{
- int rng;
+ int visib, rng;
struct sctstr sect;
struct shpstr ship;
struct plnstr plane;
x = deltx(&ns.range, (int)ship.shp_x);
y = delty(&ns.range, (int)ship.shp_y);
- rng = (int)(range * ship.shp_visib / 20.0);
+ visib = shp_visib(&ship);
+ rng = (int)(range * visib / 20.0);
if (ni.curdist > rng)
continue;
if ((mchr[(int)ship.shp_type].m_flags & M_SUB) &&
ni.curdist > rng * seesub)
continue;
- if (ship.shp_visib > vis[y][x]) {
- vis[y][x] = ship.shp_visib;
+ if (visib > vis[y][x]) {
+ vis[y][x] = visib;
/* &~0x20 makes it a cap letter */
rad[y][x] = (*mchr[(int)ship.shp_type].m_name) & ~0x20;
}
int vis, onsea;
struct mchrstr *mcp = mchr + sp->shp_type;
- vis = sp->shp_visib;
+ vis = shp_visib(sp);
getsect(sp->shp_x, sp->shp_y, §);
onsea = sect.sct_type == SCT_WATER;
if (mcp->m_flags & M_SUB)
vis *= 4;
return (int)((sp->shp_effic / 100.0) *
- (20 + sp->shp_speed * onsea / 2.0 - vis));
+ (20 + shp_speed(sp) * onsea / 2.0 - vis));
}
static int
double
shp_mobcost(struct shpstr *sp)
{
- return speed_factor(sp->shp_effic * 0.01 * sp->shp_speed,
+ return speed_factor(sp->shp_effic * 0.01 * shp_speed(sp),
sp->shp_tech);
}
tlev = mcp->m_tech;
sp->shp_tech = tlev;
- sp->shp_armor = m_armor(mcp, tlev);
- sp->shp_speed = m_speed(mcp, tlev);
- sp->shp_visib = m_visib(mcp, tlev);
- sp->shp_frnge = m_frnge(mcp, tlev);
- sp->shp_glim = m_glim(mcp, tlev);
}
wf = 0;
/* only military can work on a military boat */
- if (ship->shp_glim > 0)
+ if (mp->m_glim != 0)
wf = etus * ship->shp_item[I_MILIT] / 2;
else
wf = etus * (ship->shp_item[I_CIVIL] / 2 + ship->shp_item[I_MILIT] / 5);