Change nuke storage and commands to match other units:
(nukstr): Hold one nuke instead of a stockpile: replace members nuk_n, nuk_types by nuk_type, nuk_plane. Add nuk_land for completeness, like nuk_ship it's not yet used. (nuke_ca): Update accordingly: replace selectors number and types by type and plane. (build_nuke): Update accordingly. (ndump, nuke): Update accordingly. Output is no longer sorted by location, and nukes in same location no longer share id. nuke's extra columns for nuclear plants are repeated for every nuke. (trade_desc): Update accordingly. (cede, grab_sect, check_nuke_ok, detonate, trade_nameof): Talk about nukes instead of nuclear stockpiles. (arm, disarm): Rewrite, split off new disarm(). Don't remove nuke from the nuke file on arm. Allow usual plane syntax, not just plane number. Change second argument from nuke type to nuke number. When plane is already armed, ignore nuke argument and rearm (broken in 4.2.6). (tran_nuke): Update for changed struct nukstr, make as similar as possible to tran_plane. Change syntax to match transport plane. (player_coms): Update arm, disarm and transport accordingly. (prnuke, nuk_on_plane): New. (nuk_add, nuk_delete): Stockpile management, remove.
This commit is contained in:
parent
e86beb9626
commit
2e40a4bb90
16 changed files with 220 additions and 293 deletions
|
@ -52,73 +52,55 @@ arm(void)
|
|||
struct nchrstr *ncp;
|
||||
struct plchrstr *plc;
|
||||
struct plnstr pl;
|
||||
struct plnstr start; /* Used for sanity checking */
|
||||
struct nukstr nuke;
|
||||
char *p;
|
||||
int pno;
|
||||
int nuketype;
|
||||
int found;
|
||||
int pno, nukno;
|
||||
struct nstr_item ni;
|
||||
char buf[1024];
|
||||
int disarm = **player->argp == 'd';
|
||||
char *prompt = disarm ? "Disarm plane: " : "Arm plane: ";
|
||||
char prompt[128];
|
||||
|
||||
if (!(p = getstarg(player->argp[1], prompt, buf)) || !*p)
|
||||
if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
|
||||
return RET_SYN;
|
||||
pno = atoi(p);
|
||||
if (pno < 0 || !getplane(pno, &pl) || pl.pln_own != player->cnum)
|
||||
return RET_FAIL;
|
||||
memcpy(&start, &pl, sizeof(struct plnstr));
|
||||
plc = &plchr[(int)pl.pln_type];
|
||||
if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
|
||||
pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (opt_MARKET) {
|
||||
if (ontradingblock(EF_PLANE, &pl)) {
|
||||
pr("You cannot arm/disarm an item on the trading block!\n");
|
||||
while (nxtitem(&ni, &pl)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
plc = &plchr[(int)pl.pln_type];
|
||||
if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
|
||||
pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (pl.pln_nuketype == -1) {
|
||||
if (disarm) {
|
||||
pr("%s is not carrying any nuclear devices\n", prplane(&pl));
|
||||
return RET_FAIL;
|
||||
}
|
||||
if ((p = getstarg(player->argp[2], "Device type: ", buf)) == 0)
|
||||
return RET_SYN;
|
||||
if (!check_plane_ok(&start))
|
||||
return RET_FAIL;
|
||||
nuketype = typematch(p, EF_NUKE);
|
||||
if (nuketype < 0) {
|
||||
pr("No such nuke type!\n");
|
||||
return RET_SYN;
|
||||
}
|
||||
ncp = &nchr[nuketype];
|
||||
found = 0;
|
||||
snxtitem_xy(&ni, EF_NUKE, pl.pln_x, pl.pln_y);
|
||||
while (nxtitem(&ni, &nuke)) {
|
||||
if (nuke.nuk_own == player->cnum) {
|
||||
found = 1;
|
||||
break;
|
||||
if (opt_MARKET) {
|
||||
if (ontradingblock(EF_PLANE, &pl)) {
|
||||
pr("You cannot disarm %s while it is on the trading block!\n",
|
||||
prplane(&pl));
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
pr("You don't own any nukes in that sector.\n");
|
||||
return RET_FAIL;
|
||||
}
|
||||
if (nuke.nuk_types[nuketype] == 0) {
|
||||
pr("No nukes of that type in that sector.\n");
|
||||
return RET_FAIL;
|
||||
if (pl.pln_nuketype < 0) {
|
||||
sprintf(prompt, "Nuclear device for %s: ", prplane(&pl));
|
||||
p = getstarg(player->argp[2], prompt, buf);
|
||||
if (!p || !*p)
|
||||
return RET_SYN;
|
||||
if (!check_plane_ok(&pl))
|
||||
return RET_FAIL;
|
||||
nukno = atoi(p);
|
||||
if (!getnuke(nukno, &nuke) || !player->owner)
|
||||
return RET_FAIL;
|
||||
} else {
|
||||
if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
|
||||
CANT_REACH();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
ncp = &nchr[nuke.nuk_type];
|
||||
if (pl.pln_load < ncp->n_weight) {
|
||||
pr("A %s cannot carry %s devices!\n", plc->pl_name,
|
||||
ncp->n_name);
|
||||
pr("A %s cannot carry %s devices!\n",
|
||||
plc->pl_name, ncp->n_name);
|
||||
return RET_FAIL;
|
||||
}
|
||||
p = getstarg(player->argp[3], "Airburst [n]? ", buf);
|
||||
|
||||
if (!check_plane_ok(&start))
|
||||
if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
|
||||
return RET_FAIL;
|
||||
|
||||
if (p && (*p == 'y' || *p == 'Y'))
|
||||
|
@ -126,26 +108,52 @@ arm(void)
|
|||
else
|
||||
pl.pln_flags &= ~PLN_AIRBURST;
|
||||
|
||||
pl.pln_nuketype = nuketype;
|
||||
nuk_delete(&nuke, nuketype, 1);
|
||||
} else if (!disarm) {
|
||||
pr("%s already carrying a warhead.\n", prplane(&pl));
|
||||
}
|
||||
if (disarm) {
|
||||
pr("%s warhead removed from %s and added to %s\n",
|
||||
nchr[(int)pl.pln_nuketype].n_name,
|
||||
prplane(&pl), xyas(pl.pln_x, pl.pln_y, player->cnum));
|
||||
nuk_add(pl.pln_x, pl.pln_y, pl.pln_nuketype, 1);
|
||||
pl.pln_nuketype = -1;
|
||||
pl.pln_flags &= ~PLN_AIRBURST;
|
||||
} else {
|
||||
pr("%s armed with a %s warhead.\n", prplane(&pl),
|
||||
nchr[(int)pl.pln_nuketype].n_name);
|
||||
pl.pln_nuketype = nuke.nuk_type;
|
||||
nuke.nuk_plane = pl.pln_uid;
|
||||
putplane(pl.pln_uid, &pl);
|
||||
putnuke(nuke.nuk_uid, &nuke);
|
||||
pr("%s armed with %s.\n", prplane(&pl), prnuke(&nuke));
|
||||
pr("Warhead on %s is programmed to %s\n",
|
||||
prplane(&pl),
|
||||
pl.pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
|
||||
}
|
||||
|
||||
putplane(pl.pln_uid, &pl);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int
|
||||
disarm(void)
|
||||
{
|
||||
struct plnstr pl;
|
||||
struct nukstr nuke;
|
||||
struct nstr_item ni;
|
||||
|
||||
if (!snxtitem(&ni, EF_PLANE, player->argp[1]))
|
||||
return RET_SYN;
|
||||
while (nxtitem(&ni, &pl)) {
|
||||
if (!player->owner)
|
||||
continue;
|
||||
if (pl.pln_nuketype == -1)
|
||||
continue;
|
||||
if (opt_MARKET) {
|
||||
if (ontradingblock(EF_PLANE, &pl)) {
|
||||
pr("You cannot disarm %s while it is on the trading block!\n",
|
||||
prplane(&pl));
|
||||
return RET_FAIL;
|
||||
}
|
||||
}
|
||||
if (nuk_on_plane(&nuke, pl.pln_uid) < 0) {
|
||||
CANT_REACH();
|
||||
continue;
|
||||
}
|
||||
nuke.nuk_plane = -1;
|
||||
pl.pln_nuketype = -1;
|
||||
pl.pln_flags &= ~PLN_AIRBURST;
|
||||
putplane(pl.pln_uid, &pl);
|
||||
putnuke(nuke.nuk_uid, &nuke);
|
||||
pr("%s removed from %s and added to %s\n",
|
||||
prnuke(&nuke), prplane(&pl),
|
||||
xyas(pl.pln_x, pl.pln_y, player->cnum));
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue