build: Report missing stuff more nicely for nukes
By switching build_nuke() to sector_can_build(), build_charge(). Changes reporting of missing stuff to be like for ships, planes and land units: * Report missing available work, or else missing materials, or else missing money instead of materials, or else money, or else work. * Report what materials are missing instead of how much materials have to be there. * Clean up stray ';' in reporting of missing work. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
eeb62ab280
commit
1c0315048a
2 changed files with 26 additions and 43 deletions
|
@ -312,44 +312,32 @@ build_land(struct sctstr *sp, int type, int tlev)
|
|||
static int
|
||||
build_nuke(struct sctstr *sp, int type, int tlev)
|
||||
{
|
||||
short *vec = sp->sct_item;
|
||||
struct nchrstr *np = &nchr[type];
|
||||
short mat[I_MAX+1];
|
||||
int work;
|
||||
struct nukstr nuke;
|
||||
int avail;
|
||||
|
||||
if (sp->sct_type != SCT_NUKE && !player->god) {
|
||||
pr("Nuclear weapons must be built in nuclear plants.\n");
|
||||
return 0;
|
||||
}
|
||||
if (sp->sct_effic < 60 && !player->god) {
|
||||
pr("Sector %s is not 60%% efficient.\n",
|
||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||
return 0;
|
||||
}
|
||||
if (vec[I_HCM] < np->n_hcm || vec[I_LCM] < np->n_lcm ||
|
||||
vec[I_OIL] < np->n_oil || vec[I_RAD] < np->n_rad) {
|
||||
pr("Not enough materials for a %s bomb in %s\n",
|
||||
np->n_name, xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||
pr("(%d hcm, %d lcm, %d oil, & %d rads).\n",
|
||||
np->n_hcm, np->n_lcm, np->n_oil, np->n_rad);
|
||||
return 0;
|
||||
}
|
||||
if (!build_can_afford(np->n_cost, 100, np->n_name))
|
||||
return 0;
|
||||
avail = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
|
||||
/*
|
||||
* XXX when nukes turn into units (or whatever), then
|
||||
* make them start at 20%. Since they don't have efficiency
|
||||
* now, we charge all the work right away.
|
||||
*/
|
||||
if (sp->sct_avail < avail) {
|
||||
pr("Not enough available work in %s to build a %s;\n",
|
||||
xyas(sp->sct_x, sp->sct_y, player->cnum), np->n_name);
|
||||
pr(" (%d available work required)\n", avail);
|
||||
memset(mat, 0, sizeof(mat));
|
||||
mat[I_LCM] = np->n_lcm;
|
||||
mat[I_HCM] = np->n_hcm;
|
||||
mat[I_OIL] = np->n_oil;
|
||||
mat[I_RAD] = np->n_rad;
|
||||
work = NUK_BLD_WORK(np->n_lcm, np->n_hcm, np->n_oil, np->n_rad);
|
||||
|
||||
if (!sector_can_build(sp, mat, work, 100, np->n_name))
|
||||
return 0;
|
||||
}
|
||||
sp->sct_avail -= avail;
|
||||
player->dolcost += np->n_cost;
|
||||
if (!build_can_afford(np->n_cost, 100, np->n_name))
|
||||
return 0;
|
||||
build_charge(sp, mat, work, np->n_cost, 100);
|
||||
|
||||
ef_blank(EF_NUKE, pick_unused_unit_uid(EF_NUKE), &nuke);
|
||||
nuke.nuk_x = sp->sct_x;
|
||||
|
@ -361,11 +349,6 @@ build_nuke(struct sctstr *sp, int type, int tlev)
|
|||
nuke.nuk_tech = tlev;
|
||||
unit_wipe_orders((struct empobj *)&nuke);
|
||||
|
||||
vec[I_HCM] -= np->n_hcm;
|
||||
vec[I_LCM] -= np->n_lcm;
|
||||
vec[I_OIL] -= np->n_oil;
|
||||
vec[I_RAD] -= np->n_rad;
|
||||
|
||||
putnuke(nuke.nuk_uid, &nuke);
|
||||
pr("%s created in %s\n", prnuke(&nuke),
|
||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||
|
|
|
@ -578,8 +578,10 @@
|
|||
Play#4 output Play#4 6 0 635
|
||||
Play#4 input build n 3:5,3 10kt
|
||||
Play#4 command build
|
||||
Play#4 output Play#4 1 Not enough materials for a 10kt fission bomb in 3,3
|
||||
Play#4 output Play#4 1 (50 hcm, 50 lcm, 25 oil, & 70 rads).
|
||||
Play#4 output Play#4 1 Not enough oil in 3,3 (need 25 more)
|
||||
Play#4 output Play#4 1 Not enough light products in 3,3 (need 50 more)
|
||||
Play#4 output Play#4 1 Not enough heavy products in 3,3 (need 50 more)
|
||||
Play#4 output Play#4 1 Not enough radioactive materials in 3,3 (need 70 more)
|
||||
Play#4 output Play#4 1 Sector 5,3 is not 60% efficient.
|
||||
Play#4 output Play#4 6 0 634
|
||||
Play#4 input move l -1,3 49 jh
|
||||
|
@ -624,10 +626,8 @@
|
|||
Play#4 output Play#4 6 0 626
|
||||
Play#4 input build n 1:3,3 10kt
|
||||
Play#4 command build
|
||||
Play#4 output Play#4 1 Not enough materials for a 10kt fission bomb in 1,3
|
||||
Play#4 output Play#4 1 (50 hcm, 50 lcm, 25 oil, & 70 rads).
|
||||
Play#4 output Play#4 1 Not enough materials for a 10kt fission bomb in 3,3
|
||||
Play#4 output Play#4 1 (50 hcm, 50 lcm, 25 oil, & 70 rads).
|
||||
Play#4 output Play#4 1 Not enough light products in 1,3 (need 1 more)
|
||||
Play#4 output Play#4 1 Not enough heavy products in 3,3 (need 1 more)
|
||||
Play#4 output Play#4 6 0 625
|
||||
Play#4 input move l -1,3 1 jh
|
||||
Play#4 command move
|
||||
|
@ -651,10 +651,8 @@
|
|||
Play#4 output Play#4 6 0 621
|
||||
Play#4 input build n 1:3,3 10kt
|
||||
Play#4 command build
|
||||
Play#4 output Play#4 1 Not enough materials for a 10kt fission bomb in 1,3
|
||||
Play#4 output Play#4 1 (50 hcm, 50 lcm, 25 oil, & 70 rads).
|
||||
Play#4 output Play#4 1 Not enough materials for a 10kt fission bomb in 3,3
|
||||
Play#4 output Play#4 1 (50 hcm, 50 lcm, 25 oil, & 70 rads).
|
||||
Play#4 output Play#4 1 Not enough oil in 1,3 (need 1 more)
|
||||
Play#4 output Play#4 1 Not enough radioactive materials in 3,3 (need 1 more)
|
||||
Play#4 output Play#4 6 0 620
|
||||
Play#4 input move l -1,3 100 jh
|
||||
Play#4 command move
|
||||
|
@ -715,12 +713,14 @@
|
|||
Play#4 input build n 1:3,3 10kt 3 290
|
||||
Play#4 command build
|
||||
Play#4 output Play#4 1 Building with tech level 290.
|
||||
Play#4 output Play#4 1 Not enough available work in 1,3 to build a 10kt fission;
|
||||
Play#4 output Play#4 1 Not enough available work in 1,3 to build a 10kt fission
|
||||
Play#4 output Play#4 1 (49 available work required)
|
||||
Play#4 output Play#4 1 10kt fission warhead #2 created in 3,3
|
||||
Play#4 output Play#4 1 Not enough available work in 1,3 to build a 10kt fission
|
||||
Play#4 output Play#4 1 (49 available work required)
|
||||
Play#4 output Play#4 1 Not enough money left to build a 10kt fission
|
||||
Play#4 output Play#4 1 Not enough money left to build a 10kt fission
|
||||
Play#4 output Play#4 1 Not enough money left to build a 10kt fission
|
||||
Play#4 output Play#4 1 Not enough available work in 1,3 to build a 10kt fission
|
||||
Play#4 output Play#4 1 (49 available work required)
|
||||
Play#4 output Play#4 1 Not enough money left to build a 10kt fission
|
||||
Play#4 output Play#4 1 That just cost you $10000.00
|
||||
Play#4 output Play#4 6 0 609
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue