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 and land units
30 * Known contributors to this file:
45 static int retreat(short);
50 return retreat(EF_SHIP);
56 return retreat(EF_LAND);
65 union empobj_storage unit;
68 char *name, *rpath, *what;
73 if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
76 if (!snxtitem(&ni, type, player->argp[1]))
79 if (player->argp[2] != NULL)
80 pq = getstarg(player->argp[2], "Retreat path? ", buf1);
86 fl = getstarg(player->argp[3],
88 ? "Retreat conditions [i|t|s|h|b|d|u|c]? "
89 : "Retreat conditions [i|h|b|c]? ",
94 for (i = 0; fl[i]; i++) {
98 rflags |= RET_INJURED;
104 rflags |= RET_TORPED;
110 rflags |= RET_SONARED;
114 rflags |= RET_HELPLESS;
118 rflags |= RET_BOMBED;
124 rflags |= RET_DCHRGED;
130 rflags |= RET_BOARDED;
138 pr("bad condition\n");
141 pr("i\tretreat when injured\n");
142 if (type == EF_SHIP) {
143 pr("t\tretreat when torped\n");
144 pr("s\tretreat when sonared\n");
146 pr("h\tretreat when helpless\n");
147 pr("b\tretreat when bombed\n");
148 if (type == EF_SHIP) {
149 pr("d\tretreat when depth-charged\n");
150 pr("u\tretreat when boarded\n");
154 if (*pq && !rflags) {
155 pr("Must give retreat conditions!\n");
158 if (ni.sel == NS_GROUP && ni.group)
164 while (nxtitem(&ni, &unit)) {
165 if (!player->owner || unit.gen.own == 0)
167 if (type == EF_SHIP) {
171 pr("shp# ship type x,y fl path as flt? flags\n");
173 name = mchr[unit.ship.shp_type].m_name;
174 rpath = unit.ship.shp_rpath;
175 rflagsp = &unit.ship.shp_rflags;
180 pr("lnd# unit type x,y ar path as army? flags\n");
182 name = lchr[unit.land.lnd_type].l_name;
183 rpath = unit.land.lnd_rpath;
184 rflagsp = &unit.land.lnd_rflags;
187 strncpy(rpath, pq, RET_LEN - 1);
189 put_empobj(type, unit.gen.uid, &unit);
192 pr("%3d ", unit.gen.own);
194 pr("%-16.16s ", name);
195 prxy("%4d,%-4d ", unit.gen.x, unit.gen.y, player->cnum);
196 pr("%1.1s", &unit.gen.group);
199 if (rflags & RET_GROUP)
203 if (rflags & RET_INJURED)
205 if (rflags & RET_TORPED)
207 if (rflags & RET_SONARED)
209 if (rflags & RET_HELPLESS)
211 if (rflags & RET_BOMBED)
213 if (rflags & RET_DCHRGED)
215 if (rflags & RET_BOARDED)
219 what = type == EF_SHIP ? "ship" : "unit";
222 pr("%s: No %s(s)\n", player->argp[1], what);
224 pr("%s: No %s(s)\n", "", what);
227 pr("%d %s%s\n", nunits, what, splur(nunits));