static int
launch_as(struct plnstr *pp)
{
- coord sx, sy;
char *cp, buf[1024];
struct plnstr plane;
- struct nstr_item ni;
- int goodtarget;
int dam, nukedam;
natid oldown;
- cp = getstarg(player->argp[2], "Target sector? ", buf);
+ cp = getstarg(player->argp[2], "Target satellite? ", buf);
if (!check_plane_ok(pp))
return RET_FAIL;
if (!cp || !*cp)
return RET_SYN;
- if (!sarg_xy(cp, &sx, &sy)) {
- pr("Bad sector designation!\n");
- return RET_SYN;
- }
- if (mapdist(pp->pln_x, pp->pln_y, sx, sy) > pp->pln_range) {
- pr("Range too great!\n");
+ if (!getplane(atoi(cp), &plane) || !plane.pln_own
+ || !pln_is_in_orbit(&plane)) {
+ pr("No such satellite exists!\n");
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 (!goodtarget) {
- pr("No satellites there!\n");
+ if (mapdist(pp->pln_x, pp->pln_y, plane.pln_x, plane.pln_y)
+ > pp->pln_range) {
+ pr("Range too great!\n");
return RET_FAIL;
}
if (msl_equip(pp, 'p') < 0) {
return RET_FAIL;
}
if (msl_hit(pp, pln_def(&plane), EF_PLANE, N_SAT_KILL, N_SAT_KILL,
- prplane(&plane), sx, sy, plane.pln_own)) {
- dam = pln_damage(pp, sx, sy, 'p', &nukedam, 1);
- if (CANT_HAPPEN(nukedam))
- return RET_OK;
+ prplane(&plane), plane.pln_x, plane.pln_y, plane.pln_own)) {
+ dam = pln_damage(pp, plane.pln_x, plane.pln_y, 'p', &nukedam, 1);
+ CANT_HAPPEN(nukedam);
oldown = plane.pln_own;
planedamage(&plane, dam);
pr("Hit satellite for %d%% damage!\n", dam);
return RET_SYN;
if (!check_plane_ok(pp))
return RET_FAIL;
- if (opt_PINPOINTMISSILE && sarg_type(cp) == NS_LIST) {
+ if (sarg_type(cp) == NS_LIST) {
if (!(pcp->pl_flags & P_MAR)) {
pr("Missile not designed to attack ships!\n");
return RET_FAIL;
pr("Bad ship number!\n");
return RET_FAIL;
}
- } /* not PINPOINTMISSILE for ships */
- else if (!sarg_xy(cp, &sx, &sy)) {
+ } else if (!sarg_xy(cp, &sx, &sy)) {
pr("Not a sector!\n");
return RET_FAIL;
- } else if (opt_PINPOINTMISSILE) {
+ } else {
if (pcp->pl_flags & P_MAR) {
pr("Missile designed to attack ships!\n");
return RET_FAIL;
}
}
- /* end PINPOINTMISSILE */
+
if (mapdist(pp->pln_x, pp->pln_y, sx, sy) > pp->pln_range) {
pr("Range too great; try again!\n");
return RET_FAIL;
pr("%s not enough shells!\n", prplane(pp));
return RET_FAIL;
}
- if (opt_PINPOINTMISSILE == 0 || !(pcp->pl_flags & P_MAR)) {
+ if (!(pcp->pl_flags & P_MAR)) {
getsect(sx, sy, §);
if (opt_SLOW_WAR) {
natp = getnatp(player->cnum);
sectdamage(§, dam);
putsect(§);
}
- } /* end PINPOINTMISSILE conditional */
- else if (opt_PINPOINTMISSILE) { /* else */
+ } else {
if (!msl_hit(pp, shp_hardtarget(&target_ship), EF_SHIP,
N_SHP_MISS, N_SHP_SMISS, prship(&target_ship),
target_ship.shp_x, target_ship.shp_y,
if (!target_ship.shp_own)
pr("%s sunk!\n", prship(&target_ship));
}
- /* end PINPOINTMISSILE */
return RET_OK;
}
return RET_FAIL;
}
p = getstring("Geostationary orbit? ", buf);
- if (p == 0)
+ if (!p)
return RET_SYN;
if (!check_plane_ok(pp))
return RET_FAIL;
pr("Your trajectory was a little off.\n");
}
nreport(player->cnum, N_LAUNCH, 0, 1);
- pr("%s positioned over %s", prplane(pp), xyas(sx, sy, player->cnum));
if (msl_intercept(sx, sy, pp->pln_own, pcp->pl_def, sublaunch, P_O, 0)) {
return RET_OK;
}
pp->pln_flags |= PLN_LAUNCHED;
pp->pln_mobil = pp->pln_mobil > dist ? pp->pln_mobil - dist : 0;
putplane(pp->pln_uid, pp);
- pr(", will be ready for use in %d time units\n",
+ pr("%s positioned over %s, will be ready for use in %d time units\n",
+ prplane(pp), xyas(sx, sy, player->cnum),
plane_mob_max - pp->pln_mobil);
return RET_OK;
}