2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * arm.c: Arm planes (missiles) with nuclear devices
29 * Known contributors to this file:
33 * Markus Armbruster, 2006-2009
57 if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
59 while (nxtitem(&ni, &pl)) {
61 && relations_with(pl.pln_own, player->cnum) != ALLIED)
63 plc = &plchr[(int)pl.pln_type];
64 if ((plc->pl_flags & (P_O | P_N | P_MAR))
65 || (plc->pl_flags & (P_M | P_F)) == (P_M | P_F)) {
66 pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
70 if (ontradingblock(EF_PLANE, &pl)) {
71 pr("You cannot arm %s while it is on the trading block!\n",
76 if (!getnuke(nuk_on_plane(&pl), &nuke)) {
77 sprintf(prompt, "Nuclear device for %s: ", prplane(&pl));
78 p = getstarg(player->argp[2], prompt, buf);
81 if (!check_plane_ok(&pl))
84 if (!getnuke(nukno, &nuke) || !player->owner)
87 ncp = &nchr[nuke.nuk_type];
88 if (pln_load(&pl) < ncp->n_weight) {
89 pr("A %s cannot carry %s devices!\n",
90 plc->pl_name, ncp->n_name);
93 p = getstarg(player->argp[3], "Airburst [n]? ", buf);
97 if (!check_plane_ok(&pl) || !check_nuke_ok(&nuke))
100 if (nuke.nuk_plane >= 0 && nuke.nuk_plane != pl.pln_uid) {
101 pr("%s is already armed on plane #%d!\n",
102 prnuke(&nuke), nuke.nuk_plane);
106 if (*p == 'y' || *p == 'Y')
107 pl.pln_flags |= PLN_AIRBURST;
109 pl.pln_flags &= ~PLN_AIRBURST;
112 snprintf(buf, sizeof(buf), "armed on your %s in %s",
113 prplane(&pl), xyas(pl.pln_x, pl.pln_y, pl.pln_own));
114 gift(pl.pln_own, player->cnum, &nuke, buf);
115 nuke.nuk_plane = pl.pln_uid;
116 putplane(pl.pln_uid, &pl);
117 putnuke(nuke.nuk_uid, &nuke);
118 pr("%s armed with %s.\n", prplane(&pl), prnuke(&nuke));
119 pr("Warhead on %s is programmed to %s\n",
121 pl.pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
136 if (!snxtitem(&ni, EF_PLANE, player->argp[1], NULL))
138 while (nxtitem(&ni, &pl)) {
141 if (!getnuke(nuk_on_plane(&pl), &nuke))
144 if (ontradingblock(EF_PLANE, &pl)) {
145 pr("You cannot disarm %s while it is on the trading block!\n",
150 getsect(nuke.nuk_x, nuke.nuk_y, §);
152 && relations_with(sect.sct_own, player->cnum) != ALLIED) {
153 pr("Disarming %s in sector %s requires an alliance!\n",
154 prplane(&pl), xyas(sect.sct_x, sect.sct_y, player->cnum));
157 snprintf(buf, sizeof(buf), "unloaded in your %s at %s",
158 dchr[sect.sct_type].d_name,
159 xyas(sect.sct_x, sect.sct_y, sect.sct_own));
160 gift(sect.sct_own, player->cnum, &nuke, buf);
162 pl.pln_flags &= ~PLN_AIRBURST;
163 putplane(pl.pln_uid, &pl);
164 putnuke(nuke.nuk_uid, &nuke);
165 pr("%s removed from %s and added to %s\n",
166 prnuke(&nuke), prplane(&pl),
167 xyas(pl.pln_x, pl.pln_y, player->cnum));