(shp_mobcost): New.

(use_ammo, eta_calc, torp, fire_torp, perform_mission, retreat_ship1)
(shp_sweep, shp_nav_one_sector, cost_ship): Use it.

(perform_mission): Fix mobility cost of torpedo: charged full sector
cost instead of half.
This commit is contained in:
Markus Armbruster 2006-05-20 19:28:29 +00:00
parent 2cd8e99f49
commit 16b9c41b39
8 changed files with 18 additions and 54 deletions

View file

@ -219,7 +219,6 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor)
int mines, m, max, shells;
int changed = 0;
int stopping = 0;
double mobcost;
for (qp = ship_list->q_back; qp != ship_list; qp = next) {
next = qp->q_back;
@ -242,10 +241,7 @@ shp_sweep(struct emp_qelem *ship_list, int verbose, natid actor)
prship(&mlp->ship));
continue;
}
mobcost = mlp->ship.shp_effic * 0.01 * mlp->ship.shp_speed;
mobcost = 480.0 / (mobcost +
techfact(mlp->ship.shp_tech, mobcost));
mlp->mobil -= mobcost;
mlp->mobil -= shp_mobcost(&mlp->ship);
mlp->ship.shp_mobil = (int)mlp->mobil;
putship(mlp->ship.shp_uid, &mlp->ship);
if (!(mines = sect.sct_mines))
@ -859,9 +855,7 @@ shp_nav_one_sector(struct emp_qelem *list, int dir, natid actor,
shp_mess("is out of mobility", mlp);
continue;
}
mobcost = mlp->ship.shp_effic * 0.01 * mlp->ship.shp_speed;
mobcost = 480.0 /
(mobcost + techfact(mlp->ship.shp_tech, mobcost));
mobcost = shp_mobcost(&mlp->ship);
mlp->ship.shp_x = newx;
mlp->ship.shp_y = newy;
if (mlp->mobil - mobcost < -127) {
@ -1062,6 +1056,13 @@ shp_missdef(struct shpstr *sp, natid victim)
free(mlp);
}
double
shp_mobcost(struct shpstr *sp)
{
double effspd = sp->shp_effic * 0.01 * sp->shp_speed;
return 480.0 / (effspd + techfact(sp->shp_tech, effspd));
}
/*
* Set SP's tech to TLEV along with everything else that depends on it.
*/