Change launch of anti-sat to take plane# argument

Before, it took a sector argument, and targeted the lowest-numbered
satellite there.  Rather inconvenient when your own satellite masks
one of the enemy's.

Moreover, the command could be abused to find all sectors with
satellites.  Now it can "only" be abused to find satellite ids, and
whether they're in range.  Still not ideal, but tolerable.
This commit is contained in:
Markus Armbruster 2009-09-13 13:19:19 -04:00
parent 2b31f644db
commit 1ee0287595
2 changed files with 12 additions and 26 deletions

View file

@ -1,7 +1,7 @@
.TH Command LAUNCH .TH Command LAUNCH
.NA launch "Launch missiles or satellites" .NA launch "Launch missiles or satellites"
.LV Expert .LV Expert
.SY "launch <PLANES> <SECT|SHIP>" .SY "launch <PLANES> <SECT|SHIP|PLANE>"
The launch command is used to launch missiles (or satellites) The launch command is used to launch missiles (or satellites)
from sectors or submarines owned by you. from sectors or submarines owned by you.
.s1 .s1

View file

@ -136,39 +136,26 @@ laun(void)
static int static int
launch_as(struct plnstr *pp) launch_as(struct plnstr *pp)
{ {
coord sx, sy;
char *cp, buf[1024]; char *cp, buf[1024];
struct plnstr plane; struct plnstr plane;
struct nstr_item ni;
int goodtarget;
int dam, nukedam; int dam, nukedam;
natid oldown; natid oldown;
cp = getstarg(player->argp[2], "Target sector? ", buf); cp = getstarg(player->argp[2], "Target satellite? ", buf);
if (!check_plane_ok(pp)) if (!check_plane_ok(pp))
return RET_FAIL; return RET_FAIL;
if (!cp || !*cp) if (!cp || !*cp)
return RET_SYN; return RET_SYN;
if (!sarg_xy(cp, &sx, &sy)) { if (!getplane(atoi(cp), &plane) || !plane.pln_own
pr("Bad sector designation!\n"); || !pln_is_in_orbit(&plane)) {
return RET_SYN; pr("No such satellite exists!\n");
}
if (mapdist(pp->pln_x, pp->pln_y, sx, sy) > pp->pln_range) {
pr("Range too great!\n");
return RET_FAIL; return RET_FAIL;
/* Can be abused to find satellite ids. Tolerable. */
} }
goodtarget = 0;
snxtitem_xy(&ni, EF_PLANE, sx, sy);
while (!goodtarget && nxtitem(&ni, &plane)) {
if (!plane.pln_own)
continue;
if (!pln_is_in_orbit(&plane))
continue;
goodtarget = 1;
} if (mapdist(pp->pln_x, pp->pln_y, plane.pln_x, plane.pln_y)
if (!goodtarget) { > pp->pln_range) {
pr("No satellites there!\n"); pr("Range too great!\n");
return RET_FAIL; return RET_FAIL;
} }
if (msl_equip(pp, 'p') < 0) { if (msl_equip(pp, 'p') < 0) {
@ -176,10 +163,9 @@ launch_as(struct plnstr *pp)
return RET_FAIL; return RET_FAIL;
} }
if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL, if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL,
prplane(&plane), sx, sy, plane.pln_own)) { prplane(&plane), plane.pln_x, plane.pln_y, plane.pln_own)) {
dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1); dam = pln_damage(pp, plane.pln_x, plane.pln_y, 'p', &nukedam, 1);
if (CANT_HAPPEN(nukedam)) CANT_HAPPEN(nukedam);
return RET_OK;
oldown = plane.pln_own; oldown = plane.pln_own;
planedamage(&plane, dam); planedamage(&plane, dam);
pr("Hit satellite for %d%% damage!\n", dam); pr("Hit satellite for %d%% damage!\n", dam);