2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, 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:
58 int isfleet = 0, rflags = (-2), zero;
63 if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
66 if (player->argp[1] != (s_char *)0)
67 if (isalpha(player->argp[1][0]))
69 if (player->argp[2] != (s_char *)0)
70 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
74 if (pq != (s_char *)0) {
75 fl = getstarg(player->argp[3],
76 "Retreat conditions [i|t|s|h|b|d|u|c]? ", buf2);
81 for (x = 0; x < strlen(fl); x++)
85 rflags |= RET_INJURED;
93 rflags |= RET_SONARED;
97 rflags |= RET_HELPLESS;
101 rflags |= RET_BOMBED;
105 rflags |= RET_DCHRGED;
109 rflags |= RET_BOARDED;
116 pr("bad condition\n");
118 pr("i\tretreat when injured\n");
119 pr("t\tretreat when torped\n");
120 pr("s\tretreat when sonared\n");
121 pr("h\tretreat when helpless\n");
122 pr("b\tretreat when bombed\n");
123 pr("d\tretreat when depth-charged\n");
124 pr("u\tretreat when boarded\n");
126 if (rflags == isfleet) {
127 pr("Must give retreat conditions!\n");
135 zero = (rflags == -1);
139 while (nxtitem(&ni, (s_char *)&ship)) {
140 if (!player->owner || ship.shp_own == 0)
142 if (ship.shp_type < 0 || ship.shp_type > shp_maxno) {
143 pr("bad ship type %d (#%d)\n", ship.shp_type, ni.cur);
147 bzero(ship.shp_rpath, RET_LEN);
149 if (pq != (s_char *)0) {
150 bzero(ship.shp_rpath, RET_LEN);
151 bcopy(pq, ship.shp_rpath, strlen(pq));
152 putship(ship.shp_uid, &ship);
155 ship.shp_rflags = rflags;
156 putship(ship.shp_uid, &ship);
161 pr("shp# ship type x,y fl path as flt? flags\n");
164 pr("%3d ", ship.shp_own);
166 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
167 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
168 pr("%1c", ship.shp_fleet);
169 pr(" %-11s", ship.shp_rpath);
170 if (ship.shp_rflags & RET_GROUP)
174 if (ship.shp_rflags & RET_INJURED)
176 if (ship.shp_rflags & RET_TORPED)
178 if (ship.shp_rflags & RET_SONARED)
180 if (ship.shp_rflags & RET_HELPLESS)
182 if (ship.shp_rflags & RET_BOMBED)
184 if (ship.shp_rflags & RET_DCHRGED)
186 if (ship.shp_rflags & RET_BOARDED)
192 pr("%s: No ship(s)\n", player->argp[1]);
194 pr("%s: No ship(s)\n", "");
197 pr("%d ship%s\n", nships, splur(nships));
208 int isarmy = 0, rflags = (-2), zero;
213 if (!snxtitem(&ni, EF_LAND, player->argp[1]))
216 if (player->argp[1] != (s_char *)0)
217 if (isalpha(player->argp[1][0]))
219 if (player->argp[2] != (s_char *)0)
220 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
223 if (pq != (s_char *)0) {
224 fl = getstarg(player->argp[3], "Retreat conditions [i|h|b|c]? ",
230 for (x = 0; x < strlen(fl); x++)
234 rflags |= RET_INJURED;
238 rflags |= RET_HELPLESS;
242 rflags |= RET_BOMBED;
249 pr("bad condition\n");
251 pr("i\tretreat when injured\n");
252 pr("h\tretreat when helpless\n");
253 pr("b\tretreat when bombed\n");
255 if (rflags == isarmy) {
256 pr("Must give retreat conditions!\n");
264 zero = (rflags == -1);
268 while (nxtitem(&ni, (s_char *)&land)) {
269 if (!player->owner || land.lnd_own == 0)
271 if (land.lnd_type < 0 || land.lnd_type > lnd_maxno) {
272 pr("bad unit type %d (#%d)\n", land.lnd_type, ni.cur);
276 bzero(land.lnd_rpath, RET_LEN);
278 if (pq != (s_char *)0) {
279 bzero(land.lnd_rpath, RET_LEN);
280 bcopy(pq, land.lnd_rpath, strlen(pq));
281 putland(land.lnd_uid, &land);
284 land.lnd_rflags = rflags;
285 putland(land.lnd_uid, &land);
291 pr("lnd# unit type x,y ar path as army? flags\n");
294 pr("%3d ", land.lnd_own);
296 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
297 prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
298 pr("%1c", land.lnd_army);
299 pr(" %-11s", land.lnd_rpath);
300 if (land.lnd_rflags & RET_GROUP)
304 if (land.lnd_rflags & RET_INJURED)
306 if (land.lnd_rflags & RET_TORPED)
308 if (land.lnd_rflags & RET_SONARED)
310 if (land.lnd_rflags & RET_HELPLESS)
312 if (land.lnd_rflags & RET_BOMBED)
314 if (land.lnd_rflags & RET_DCHRGED)
316 if (land.lnd_rflags & RET_BOARDED)
322 pr("%s: No unit(s)\n", player->argp[1]);
324 pr("%s: No unit(s)\n", "");
327 pr("%d unit%s\n", nunits, splur(nunits));