2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * arm.c: Arm planes (missiles) with nuclear devices
30 * Known contributors to this file:
34 * Markus Armbruster, 2006-2009
58 if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
60 while (nxtitem(&ni, &pl)) {
62 && getrel(getnatp(pl.pln_own), player->cnum) != ALLIED)
64 plc = &plchr[(int)pl.pln_type];
65 if ((plc->pl_flags & (P_O | P_N | P_MAR))
66 || (plc->pl_flags & (P_M | P_F)) == (P_M | P_F)) {
67 pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
71 if (ontradingblock(EF_PLANE, &pl)) {
72 pr("You cannot arm %s while it is on the trading block!\n",
77 if (!getnuke(nuk_on_plane(&pl), &nuke)) {
78 sprintf(prompt, "Nuclear device for %s: ", prplane(&pl));
79 p = getstarg(player->argp[2], prompt, buf);
82 if (!check_plane_ok(&pl))
85 if (!getnuke(nukno, &nuke) || !player->owner)
88 ncp = &nchr[nuke.nuk_type];
89 if (pln_load(&pl) < ncp->n_weight) {
90 pr("A %s cannot carry %s devices!\n",
91 plc->pl_name, ncp->n_name);
94 p = getstarg(player->argp[3], "Airburst [n]? ", buf);
98 if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
101 if (nuke.nuk_plane >= 0 && nuke.nuk_plane != pl.pln_uid) {
102 pr("%s is already armed on plane #%d!\n",
103 prnuke(&nuke), nuke.nuk_plane);
107 if (*p == 'y' || *p == 'Y')
108 pl.pln_flags |= PLN_AIRBURST;
110 pl.pln_flags &= ~PLN_AIRBURST;
113 snprintf(buf, sizeof(buf), "armed on your %s in %s",
114 prplane(&pl), xyas(pl.pln_x, pl.pln_y, pl.pln_own));
115 gift(pl.pln_own, player->cnum, &nuke, buf);
116 nuke.nuk_plane = pl.pln_uid;
117 putplane(pl.pln_uid, &pl);
118 putnuke(nuke.nuk_uid, &nuke);
119 pr("%s armed with %s.\n", prplane(&pl), prnuke(&nuke));
120 pr("Warhead on %s is programmed to %s\n",
122 pl.pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
137 if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
139 while (nxtitem(&ni, &pl)) {
142 if (!getnuke(nuk_on_plane(&pl), &nuke))
145 if (ontradingblock(EF_PLANE, &pl)) {
146 pr("You cannot disarm %s while it is on the trading block!\n",
151 getsect(nuke.nuk_x, nuke.nuk_y, §);
153 && getrel(getnatp(sect.sct_own), player->cnum) != ALLIED) {
154 pr("Disarming %s in sector %s requires an alliance!\n",
155 prplane(&pl), xyas(sect.sct_x, sect.sct_y, player->cnum));
158 snprintf(buf, sizeof(buf), "unloaded in your %s at %s",
159 dchr[sect.sct_type].d_name,
160 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
161 gift(sect.sct_own, player->cnum, &nuke, buf);
163 pl.pln_flags &= ~PLN_AIRBURST;
164 putplane(pl.pln_uid, &pl);
165 putnuke(nuke.nuk_uid, &nuke);
166 pr("%s removed from %s and added to %s\n",
167 prnuke(&nuke), prplane(&pl),
168 xyas(pl.pln_x, pl.pln_y, player->cnum));