2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2008, 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 * retr.c: Set retreat conditionals for ships
30 * Known contributors to this file:
56 if (!snxtitem(&ni, EF_SHIP, player->argp[1]))
59 if (player->argp[2] != NULL)
60 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
66 fl = getstarg(player->argp[3],
67 "Retreat conditions [i|t|s|h|b|d|u|c]? ", buf2);
71 for (i = 0; fl[i]; i++) {
75 rflags |= RET_INJURED;
83 rflags |= RET_SONARED;
87 rflags |= RET_HELPLESS;
95 rflags |= RET_DCHRGED;
99 rflags |= RET_BOARDED;
106 pr("bad condition\n");
109 pr("i\tretreat when injured\n");
110 pr("t\tretreat when torped\n");
111 pr("s\tretreat when sonared\n");
112 pr("h\tretreat when helpless\n");
113 pr("b\tretreat when bombed\n");
114 pr("d\tretreat when depth-charged\n");
115 pr("u\tretreat when boarded\n");
118 if (*pq && !rflags) {
119 pr("Must give retreat conditions!\n");
122 if (ni.sel == NS_GROUP && ni.group)
128 while (nxtitem(&ni, &ship)) {
129 if (!player->owner || ship.shp_own == 0)
132 strncpy(ship.shp_rpath, pq, sizeof(ship.shp_rpath) - 1);
133 ship.shp_rflags = rflags;
134 putship(ship.shp_uid, &ship);
139 pr("shp# ship type x,y fl path as flt? flags\n");
142 pr("%3d ", ship.shp_own);
144 pr("%-16.16s ", mchr[(int)ship.shp_type].m_name);
145 prxy("%4d,%-4d ", ship.shp_x, ship.shp_y, player->cnum);
146 pr("%1.1s", &ship.shp_fleet);
147 pr(" %-11s", ship.shp_rpath);
148 if (ship.shp_rflags & RET_GROUP)
152 if (ship.shp_rflags & RET_INJURED)
154 if (ship.shp_rflags & RET_TORPED)
156 if (ship.shp_rflags & RET_SONARED)
158 if (ship.shp_rflags & RET_HELPLESS)
160 if (ship.shp_rflags & RET_BOMBED)
162 if (ship.shp_rflags & RET_DCHRGED)
164 if (ship.shp_rflags & RET_BOARDED)
170 pr("%s: No ship(s)\n", player->argp[1]);
172 pr("%s: No ship(s)\n", "");
175 pr("%d ship%s\n", nships, splur(nships));
191 if (!snxtitem(&ni, EF_LAND, player->argp[1]))
194 if (player->argp[2] != NULL)
195 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
201 fl = getstarg(player->argp[3], "Retreat conditions [i|h|b|c]? ",
206 for (i = 0; fl[i]; i++) {
210 rflags |= RET_INJURED;
214 rflags |= RET_HELPLESS;
218 rflags |= RET_BOMBED;
225 pr("bad condition\n");
228 pr("i\tretreat when injured\n");
229 pr("h\tretreat when helpless\n");
230 pr("b\tretreat when bombed\n");
233 if (*pq && !rflags) {
234 pr("Must give retreat conditions!\n");
237 if (ni.sel == NS_GROUP && ni.group)
243 while (nxtitem(&ni, &land)) {
244 if (!player->owner || land.lnd_own == 0)
247 strncpy(land.lnd_rpath, pq, sizeof(land.lnd_rpath) - 1);
248 land.lnd_rflags = rflags;
249 putland(land.lnd_uid, &land);
255 pr("lnd# unit type x,y ar path as army? flags\n");
258 pr("%3d ", land.lnd_own);
260 pr("%-16.16s ", lchr[(int)land.lnd_type].l_name);
261 prxy("%4d,%-4d ", land.lnd_x, land.lnd_y, player->cnum);
262 pr("%1.1s", &land.lnd_army);
263 pr(" %-11s", land.lnd_rpath);
264 if (land.lnd_rflags & RET_GROUP)
268 if (land.lnd_rflags & RET_INJURED)
270 if (land.lnd_rflags & RET_TORPED)
272 if (land.lnd_rflags & RET_SONARED)
274 if (land.lnd_rflags & RET_HELPLESS)
276 if (land.lnd_rflags & RET_BOMBED)
278 if (land.lnd_rflags & RET_DCHRGED)
280 if (land.lnd_rflags & RET_BOARDED)
286 pr("%s: No unit(s)\n", player->argp[1]);
288 pr("%s: No unit(s)\n", "");
291 pr("%d unit%s\n", nunits, splur(nunits));