2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2005, 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 * retr.c: Set retreat conditionals for ships
30 * Known contributors to this file:
61 if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
64 if (player->argp[1] != (s_char *)0)
65 if (isalpha(player->argp[1][0]))
67 if (player->argp[2] != (s_char *)0)
68 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
72 if (pq != (s_char *)0) {
73 fl = getstarg(player->argp[3],
74 "Retreat conditions [i|t|s|h|b|d|u|c]? ", buf2);
79 for (x = 0; x < strlen(fl); x++)
83 rflags |= RET_INJURED;
91 rflags |= RET_SONARED;
95 rflags |= RET_HELPLESS;
103 rflags |= RET_DCHRGED;
107 rflags |= RET_BOARDED;
114 pr("bad condition\n");
117 pr("i\tretreat when injured\n");
118 pr("t\tretreat when torped\n");
119 pr("s\tretreat when sonared\n");
120 pr("h\tretreat when helpless\n");
121 pr("b\tretreat when bombed\n");
122 pr("d\tretreat when depth-charged\n");
123 pr("u\tretreat when boarded\n");
125 if (rflags == isfleet) {
126 pr("Must give retreat conditions!\n");
134 zero = (rflags == -1);
138 while (nxtitem(&ni, &ship)) {
139 if (!player->owner || ship.shp_own == 0)
142 memset(ship.shp_rpath, 0, sizeof(ship.shp_rpath));
144 if (pq != (s_char *)0) {
145 strncpy(ship.shp_rpath, pq, sizeof(ship.shp_rpath));
146 putship(ship.shp_uid, &ship);
149 ship.shp_rflags = rflags;
150 putship(ship.shp_uid, &ship);
155 pr("shp# ship type x,y fl path as flt? flags\n");
158 pr("%3d ", ship.shp_own);
160 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
161 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
162 pr("%1c", ship.shp_fleet);
163 pr(" %-11s", ship.shp_rpath);
164 if (ship.shp_rflags & RET_GROUP)
168 if (ship.shp_rflags & RET_INJURED)
170 if (ship.shp_rflags & RET_TORPED)
172 if (ship.shp_rflags & RET_SONARED)
174 if (ship.shp_rflags & RET_HELPLESS)
176 if (ship.shp_rflags & RET_BOMBED)
178 if (ship.shp_rflags & RET_DCHRGED)
180 if (ship.shp_rflags & RET_BOARDED)
186 pr("%s: No ship(s)\n", player->argp[1]);
188 pr("%s: No ship(s)\n", "");
191 pr("%d ship%s\n", nships, splur(nships));
209 if (!snxtitem(&ni, EF_LAND, player->argp[1]))
212 if (player->argp[1] != (s_char *)0)
213 if (isalpha(player->argp[1][0]))
215 if (player->argp[2] != (s_char *)0)
216 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
219 if (pq != (s_char *)0) {
220 fl = getstarg(player->argp[3], "Retreat conditions [i|h|b|c]? ",
226 for (x = 0; x < strlen(fl); x++)
230 rflags |= RET_INJURED;
234 rflags |= RET_HELPLESS;
238 rflags |= RET_BOMBED;
245 pr("bad condition\n");
248 pr("i\tretreat when injured\n");
249 pr("h\tretreat when helpless\n");
250 pr("b\tretreat when bombed\n");
252 if (rflags == isarmy) {
253 pr("Must give retreat conditions!\n");
261 zero = (rflags == -1);
265 while (nxtitem(&ni, &land)) {
266 if (!player->owner || land.lnd_own == 0)
269 memset(land.lnd_rpath, 0, sizeof(land.lnd_rpath));
271 if (pq != (s_char *)0) {
272 strncpy(land.lnd_rpath, pq, sizeof(land.lnd_rpath));
273 putland(land.lnd_uid, &land);
276 land.lnd_rflags = rflags;
277 putland(land.lnd_uid, &land);
283 pr("lnd# unit type x,y ar path as army? flags\n");
286 pr("%3d ", land.lnd_own);
288 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
289 prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
290 pr("%1c", land.lnd_army);
291 pr(" %-11s", land.lnd_rpath);
292 if (land.lnd_rflags & RET_GROUP)
296 if (land.lnd_rflags & RET_INJURED)
298 if (land.lnd_rflags & RET_TORPED)
300 if (land.lnd_rflags & RET_SONARED)
302 if (land.lnd_rflags & RET_HELPLESS)
304 if (land.lnd_rflags & RET_BOMBED)
306 if (land.lnd_rflags & RET_DCHRGED)
308 if (land.lnd_rflags & RET_BOARDED)
314 pr("%s: No unit(s)\n", player->argp[1]);
316 pr("%s: No unit(s)\n", "");
319 pr("%d unit%s\n", nunits, splur(nunits));