(shp_set_tech, pln_set_tech, lnd_set_tech): New, factored out of build
and upgrade code. (build_ship, build_plane, build_land, supgr, pupgr, lupgr): Use them. Upgrading planes no longer sets plane range to maximum. (pupgr): Just clear the mission, don't bother to clear op area. (doship, doplane, dounit): Editing tech now updates stats, like an upgrade command. Proper range checking. (warn_deprecated): New. (pr_ship, doship): Deprecate key 'D'. (pr_land, dounit): Deprecate key 'A' and 'D'.
This commit is contained in:
parent
65ff91877f
commit
c2debd73fc
8 changed files with 113 additions and 102 deletions
|
@ -1383,3 +1383,36 @@ lnd_fortify (struct lndstr *lp, int hard_amt)
|
|||
|
||||
return hard_amt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set LP's tech to TLEV along with everything else that depends on it.
|
||||
*/
|
||||
void
|
||||
lnd_set_tech(struct lndstr *lp, int tlev)
|
||||
{
|
||||
struct lchrstr *lcp = lchr + lp->lnd_type;
|
||||
int tech_diff = tlev - lcp->l_tech;
|
||||
|
||||
if (CANT_HAPPEN(tech_diff < 0)) {
|
||||
tlev -= tech_diff;
|
||||
tech_diff = 0;
|
||||
}
|
||||
|
||||
lp->lnd_tech = tlev;
|
||||
lp->lnd_att = (float)LND_ATTDEF(lcp->l_att, tech_diff);
|
||||
lp->lnd_def = (float)LND_ATTDEF(lcp->l_def, tech_diff);
|
||||
lp->lnd_vul = (int)LND_VUL(lcp->l_vul, tech_diff);
|
||||
lp->lnd_spd = (int)LND_SPD(lcp->l_spd, tech_diff);
|
||||
lp->lnd_vis = (int)LND_VIS(lcp->l_vis, tech_diff);
|
||||
lp->lnd_spy = (int)LND_SPY(lcp->l_spy, tech_diff);
|
||||
lp->lnd_rad = (int)LND_RAD(lcp->l_rad, tech_diff);
|
||||
lp->lnd_frg = (int)LND_FRG(lcp->l_frg, tech_diff);
|
||||
lp->lnd_acc = (int)LND_ACC(lcp->l_acc, tech_diff);
|
||||
lp->lnd_dam = (int)LND_DAM(lcp->l_dam, tech_diff);
|
||||
lp->lnd_ammo = (int)LND_AMM(lcp->l_ammo, lcp->l_dam, tech_diff);
|
||||
lp->lnd_aaf = (int)LND_AAF(lcp->l_aaf, tech_diff);
|
||||
lp->lnd_fuelc = (int)LND_FC(lcp->l_fuelc, tech_diff);
|
||||
lp->lnd_fuelu = (int)LND_FU(lcp->l_fuelu, tech_diff);
|
||||
lp->lnd_maxlight = (int)LND_XPL(lcp->l_nxlight, tech_diff);
|
||||
lp->lnd_maxland = (int)LND_MXL(lcp->l_mxland, tech_diff);
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
* Steve McClure, 1998-2000
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "misc.h"
|
||||
#include "player.h"
|
||||
#include "var.h"
|
||||
|
@ -1165,3 +1166,29 @@ pln_mobcost(int dist, struct plnstr *pp, int flags)
|
|||
|
||||
return min(32 + pp->pln_mobil, cost + 5);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set PP's tech to TLEV along with everything else that depends on it.
|
||||
*/
|
||||
void
|
||||
pln_set_tech(struct plnstr *pp, int tlev)
|
||||
{
|
||||
struct plchrstr *pcp = plchr + pp->pln_type;
|
||||
int tech_diff = tlev - pcp->pl_tech;
|
||||
int limited_range = pp->pln_range < pp->pln_range_max;
|
||||
|
||||
if (CANT_HAPPEN(tech_diff < 0)) {
|
||||
tlev -= tech_diff;
|
||||
tech_diff = 0;
|
||||
}
|
||||
|
||||
pp->pln_tech = tlev;
|
||||
pp->pln_att = PLN_ATTDEF(pcp->pl_att, tech_diff);
|
||||
pp->pln_def = PLN_ATTDEF(pcp->pl_def, tech_diff);
|
||||
pp->pln_acc = PLN_ACC(pcp->pl_acc, tech_diff);
|
||||
pp->pln_range_max = PLN_RAN(pcp->pl_range, tech_diff);
|
||||
pp->pln_load = PLN_LOAD(pcp->pl_load, tech_diff);
|
||||
|
||||
if (!limited_range || pp->pln_range > pp->pln_range_max)
|
||||
pp->pln_range = pp->pln_range_max;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
* Steve McClure, 1996-2000
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "misc.h"
|
||||
#include "queue.h"
|
||||
#include "player.h"
|
||||
|
@ -1059,3 +1060,25 @@ shp_missdef(struct shpstr *sp, natid victim)
|
|||
if (!QEMPTY(&list))
|
||||
free(mlp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set SP's tech to TLEV along with everything else that depends on it.
|
||||
*/
|
||||
void
|
||||
shp_set_tech(struct shpstr *sp, int tlev)
|
||||
{
|
||||
struct mchrstr *mcp = mchr + sp->shp_type;
|
||||
int tech_diff = tlev - mcp->m_tech;
|
||||
|
||||
if (CANT_HAPPEN(tech_diff < 0)) {
|
||||
tlev -= tech_diff;
|
||||
tech_diff = 0;
|
||||
}
|
||||
|
||||
sp->shp_tech = tlev;
|
||||
sp->shp_armor = (short)SHP_DEF(mcp->m_armor, tech_diff);
|
||||
sp->shp_speed = (short)SHP_SPD(mcp->m_speed, tech_diff);
|
||||
sp->shp_visib = (short)SHP_VIS(mcp->m_visib, tech_diff);
|
||||
sp->shp_frnge = (short)SHP_RNG(mcp->m_frnge, tech_diff);
|
||||
sp->shp_glim = (short)SHP_FIR(mcp->m_glim, tech_diff);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue