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 * rada.c: Do radar from a ship/unit/sector
30 * Known contributors to this file:
31 * Ron Koenderink, 2006
43 return radar(EF_SHIP);
49 return radar(EF_LAND);
60 union empobj_storage item;
64 if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
67 sprintf(prompt, "Radar from (%s # or sector(s)) : ", ef_nameof(type));
68 cp = getstarg(player->argp[1], prompt, buf);
72 switch (sarg_type(cp)) {
74 if (!snxtsct(&ns, cp))
76 tech = tfact(player->cnum, 8.0);
77 if (tech > WORLD_Y / 4.0)
79 if (tech > WORLD_X / 8.0)
81 while (nxtsct(&ns, &item.sect)) {
82 if (item.sect.sct_type != SCT_RADAR)
86 radmap(item.sect.sct_x, item.sect.sct_y, item.sect.sct_effic,
87 (int)(tech * 2.0), 0.0);
92 /* assumes a NS_LIST return is a unit no */
93 if (!snxtitem(&ni, type, cp, NULL)) {
94 pr("Specify at least one %s\n", ef_nameof(type));
97 while (nxtitem(&ni, &item)) {
101 if (type == EF_SHIP) {
102 if (mchr[(int)item.ship.shp_type].m_flags & M_SONAR)
103 tf = techfact(item.ship.shp_tech, 1.0);
104 tech = techfact(item.ship.shp_tech,
105 mchr[(int)item.ship.shp_type].m_vrnge);
107 if (!(lchr[(int)item.land.lnd_type].l_flags & L_RADAR)) {
108 pr("%s can't use radar!\n", prland(&item.land));
111 if (item.land.lnd_ship >= 0) {
112 pr("Units on ships can't use radar!\n");
115 tech = techfact(item.land.lnd_tech,
116 lchr[item.land.lnd_type].l_spy);
119 pr("%s at ", obj_nameof(&item.gen));
120 if (tech > WORLD_Y / 2.0)
121 tech = WORLD_Y / 2.0;
122 if (tech > WORLD_X / 4.0)
123 tech = WORLD_X / 4.0;
124 radmap(item.gen.x, item.gen.y, item.gen.effic,
129 pr("Must use a %s or sector specifier\n", ef_nameof(type));