2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * arm.c: Arm planes (missiles) with nuclear devices
30 * Known contributors to this file:
56 struct plnstr start; /* Used for sanity checking */
66 int disarm = **player->argp == 'd';
67 s_char *prompt = disarm ? "Disarm plane: " : "Arm plane: ";
69 if (!(p = getstarg(player->argp[1], prompt, buf)) || !*p)
72 if (pno < 0 || !getplane(pno, &pl) || pl.pln_own != player->cnum)
74 memcpy(&start, &pl, sizeof(struct plnstr));
75 plc = &plchr[(int)pl.pln_type];
76 if ((plc->pl_flags & (P_O | P_M)) == (P_O | P_M)) {
77 pr("A %s cannot carry nuclear devices!\n", plc->pl_name);
81 if (ontradingblock(EF_PLANE, (int *)&pl)) {
82 pr("You cannot arm/disarm an item on the trading block!\n");
86 if (pl.pln_nuketype == -1) {
88 pr("%s is not carrying any nuclear devices\n", prplane(&pl));
91 if ((p = getstarg(player->argp[2], "Device type: ", buf)) == 0)
93 if (!check_plane_ok(&start))
96 for (i = 0, ncp = nchr; i < N_MAXNUKE; i++, ncp++) {
97 if (strncmp(ncp->n_name, p, len) == 0)
100 if (i >= N_MAXNUKE) {
101 pr("No such nuke type!\n");
106 snxtitem_all(&ni, EF_NUKE);
107 while (nxtitem(&ni, (s_char *)&nuke)) {
108 if (nuke.nuk_own != player->cnum)
110 if (nuke.nuk_x != pl.pln_x || nuke.nuk_y != pl.pln_y)
116 pr("You don't own any nukes in that sector.\n");
119 if (nuke.nuk_types[nuketype] == 0) {
120 pr("No nukes of that type in that sector.\n");
123 if (pl.pln_load < ncp->n_weight) {
124 pr("A %s cannot carry %s devices!\n", plc->pl_name,
128 p = getstarg(player->argp[3], "Airburst [n]? ", buf);
130 if (!check_plane_ok(&start))
133 if (p && (*p == 'y' || *p == 'Y'))
134 pl.pln_flags |= PLN_AIRBURST;
136 pl.pln_flags &= ~PLN_AIRBURST;
138 pl.pln_nuketype = nuketype;
139 nuk_delete(&nuke, nuketype, 1);
140 } else if (!disarm) {
141 pr("%s already carrying a warhead.\n", prplane(&pl));
144 pr("%s warhead removed from %s and added to %s\n",
145 nchr[(int)pl.pln_nuketype].n_name,
146 prplane(&pl), xyas(pl.pln_x, pl.pln_y, player->cnum));
147 nuk_add(pl.pln_x, pl.pln_y, pl.pln_nuketype, 1);
148 pl.pln_nuketype = -1;
149 pl.pln_flags &= ~PLN_AIRBURST;
151 pr("%s armed with a %s warhead.\n", prplane(&pl),
152 nchr[(int)pl.pln_nuketype].n_name);
153 pr("Warhead on %s is programmed to %s\n",
155 pl.pln_flags & PLN_AIRBURST ? "airburst" : "groundburst");
158 putplane(pl.pln_uid, &pl);