Indented with src/scripts/indent-emp.
This commit is contained in:
parent
5f263a7753
commit
9b7adfbecc
437 changed files with 52211 additions and 51052 deletions
|
@ -53,82 +53,82 @@ void
|
|||
ship_damage(struct shpstr *sp, int dam)
|
||||
{
|
||||
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
|
||||
mpr(sp->shp_own, "\t%s takes %d\n", prship(sp), dam);
|
||||
mpr(sp->shp_own, "\t%s takes %d\n", prship(sp), dam);
|
||||
|
||||
sp->shp_effic = damage((int)sp->shp_effic, dam);
|
||||
if (sp->shp_mobil > 0)
|
||||
sp->shp_mobil = damage((int)sp->shp_mobil, dam);
|
||||
if (opt_FUEL && sp->shp_fuel)
|
||||
sp->shp_fuel = damage((int)sp->shp_fuel, dam);
|
||||
sp->shp_nv = vl_damage(dam, sp->shp_vtype, sp->shp_vamt,
|
||||
(int) sp->shp_nv);
|
||||
sp->shp_effic = damage((int)sp->shp_effic, dam);
|
||||
if (sp->shp_mobil > 0)
|
||||
sp->shp_mobil = damage((int)sp->shp_mobil, dam);
|
||||
if (opt_FUEL && sp->shp_fuel)
|
||||
sp->shp_fuel = damage((int)sp->shp_fuel, dam);
|
||||
sp->shp_nv = vl_damage(dam, sp->shp_vtype, sp->shp_vamt,
|
||||
(int)sp->shp_nv);
|
||||
}
|
||||
|
||||
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 + sp->shp_armor / 100.0)));
|
||||
}
|
||||
|
||||
void
|
||||
land_damage(struct lndstr *lp, int dam)
|
||||
{
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
|
||||
mpr(lp->lnd_own, "\t%s takes %d\n", prland(lp), dam);
|
||||
if (lchr[(int)lp->lnd_type].l_flags & L_SPY) {
|
||||
/* Spies die! */
|
||||
lp->lnd_effic = 0;
|
||||
} else {
|
||||
lp->lnd_effic = damage((int)lp->lnd_effic, dam);
|
||||
if (lp->lnd_mobil > 0)
|
||||
lp->lnd_mobil = damage((int)lp->lnd_mobil, dam);
|
||||
if (opt_FUEL && lp->lnd_fuel)
|
||||
lp->lnd_fuel = damage((int)lp->lnd_fuel, dam);
|
||||
lp->lnd_nv = vl_damage(dam, lp->lnd_vtype, lp->lnd_vamt,
|
||||
(int) lp->lnd_nv);
|
||||
}
|
||||
mpr(lp->lnd_own, "\t%s takes %d\n", prland(lp), dam);
|
||||
if (lchr[(int)lp->lnd_type].l_flags & L_SPY) {
|
||||
/* Spies die! */
|
||||
lp->lnd_effic = 0;
|
||||
} else {
|
||||
lp->lnd_effic = damage((int)lp->lnd_effic, dam);
|
||||
if (lp->lnd_mobil > 0)
|
||||
lp->lnd_mobil = damage((int)lp->lnd_mobil, dam);
|
||||
if (opt_FUEL && lp->lnd_fuel)
|
||||
lp->lnd_fuel = damage((int)lp->lnd_fuel, dam);
|
||||
lp->lnd_nv = vl_damage(dam, lp->lnd_vtype, lp->lnd_vamt,
|
||||
(int)lp->lnd_nv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
landdamage(struct lndstr *lp, int dam)
|
||||
{
|
||||
double damage_factor, m;
|
||||
extern int land_mob_max;
|
||||
double damage_factor, m;
|
||||
extern int land_mob_max;
|
||||
|
||||
m = (double)land_mob_max;
|
||||
m = (double)land_mob_max;
|
||||
|
||||
/* fortification reduces damage */
|
||||
damage_factor = m / (m+((double)lp->lnd_harden));
|
||||
if (damage_factor == 0.0)
|
||||
damage_factor = 1.0;
|
||||
/* fortification reduces damage */
|
||||
damage_factor = m / (m + ((double)lp->lnd_harden));
|
||||
if (damage_factor == 0.0)
|
||||
damage_factor = 1.0;
|
||||
|
||||
/* vulnerable units take more damage */
|
||||
damage_factor *= lp->lnd_vul / 100.0;
|
||||
/* vulnerable units take more damage */
|
||||
damage_factor *= lp->lnd_vul / 100.0;
|
||||
|
||||
land_damage(lp, ldround(damage_factor * dam,1));
|
||||
land_damage(lp, ldround(damage_factor * dam, 1));
|
||||
}
|
||||
|
||||
void
|
||||
planedamage(struct plnstr *pp, int dam)
|
||||
{
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
if (dam <= 0)
|
||||
return;
|
||||
if (dam > 100)
|
||||
dam = 100;
|
||||
|
||||
mpr(pp->pln_own, "\t%s takes %d\n", prplane(pp), dam);
|
||||
pp->pln_effic = damage((int)pp->pln_effic, dam);
|
||||
if (pp->pln_mobil > 0)
|
||||
pp->pln_mobil = damage((int)pp->pln_mobil, dam);
|
||||
mpr(pp->pln_own, "\t%s takes %d\n", prplane(pp), dam);
|
||||
pp->pln_effic = damage((int)pp->pln_effic, dam);
|
||||
if (pp->pln_mobil > 0)
|
||||
pp->pln_mobil = damage((int)pp->pln_mobil, dam);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -138,62 +138,60 @@ planedamage(struct plnstr *pp, int dam)
|
|||
int
|
||||
nukedamage(struct nchrstr *ncp, int range, int airburst)
|
||||
{
|
||||
int dam;
|
||||
int rad;
|
||||
int dam;
|
||||
int rad;
|
||||
|
||||
rad = ncp->n_blast;
|
||||
if (airburst)
|
||||
rad = (int) (rad * 1.5);
|
||||
if (rad < range)
|
||||
return 0;
|
||||
if (airburst) {
|
||||
/* larger area, less center damage */
|
||||
dam = (int) ((ncp->n_dam * 0.75) - (range * 20));
|
||||
} else {
|
||||
/* smaller area, more center damage */
|
||||
dam = (int) (ncp->n_dam / (range + 1.0));
|
||||
}
|
||||
if (dam < 5)
|
||||
dam = 0;
|
||||
return dam;
|
||||
rad = ncp->n_blast;
|
||||
if (airburst)
|
||||
rad = (int)(rad * 1.5);
|
||||
if (rad < range)
|
||||
return 0;
|
||||
if (airburst) {
|
||||
/* larger area, less center damage */
|
||||
dam = (int)((ncp->n_dam * 0.75) - (range * 20));
|
||||
} else {
|
||||
/* smaller area, more center damage */
|
||||
dam = (int)(ncp->n_dam / (range + 1.0));
|
||||
}
|
||||
if (dam < 5)
|
||||
dam = 0;
|
||||
return dam;
|
||||
}
|
||||
|
||||
int
|
||||
damage(register int amt, int pct)
|
||||
{
|
||||
register int tmp;
|
||||
register int lost;
|
||||
register int tmp;
|
||||
register int lost;
|
||||
|
||||
if (amt <= 0)
|
||||
return 0;
|
||||
tmp = amt * pct;
|
||||
lost = tmp / 100;
|
||||
if ((random() % 100) < (tmp % 100))
|
||||
lost++;
|
||||
return amt - lost;
|
||||
if (amt <= 0)
|
||||
return 0;
|
||||
tmp = amt * pct;
|
||||
lost = tmp / 100;
|
||||
if ((random() % 100) < (tmp % 100))
|
||||
lost++;
|
||||
return amt - lost;
|
||||
}
|
||||
|
||||
/* asymptotic damage to commodities, efficiency, and sectors */
|
||||
int
|
||||
effdamage(register int amt, int dam)
|
||||
{
|
||||
return damage(amt, PERCENT_DAMAGE(dam));
|
||||
return damage(amt, PERCENT_DAMAGE(dam));
|
||||
}
|
||||
|
||||
int
|
||||
commdamage(register int amt, int dam, int vtype)
|
||||
{
|
||||
extern double people_damage;
|
||||
int lost;
|
||||
extern double people_damage;
|
||||
int lost;
|
||||
|
||||
if (vtype == V_BAR && opt_SUPER_BARS)
|
||||
return amt;
|
||||
if (vtype == V_BAR && opt_SUPER_BARS)
|
||||
return amt;
|
||||
|
||||
lost = amt - effdamage(amt, dam);
|
||||
lost = amt - effdamage(amt, dam);
|
||||
|
||||
if (vtype == V_MILIT ||
|
||||
vtype == V_CIVIL ||
|
||||
vtype == V_UW)
|
||||
lost = ldround(people_damage * lost, 1);
|
||||
return amt - lost;
|
||||
if (vtype == V_MILIT || vtype == V_CIVIL || vtype == V_UW)
|
||||
lost = ldround(people_damage * lost, 1);
|
||||
return amt - lost;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue