plnsub: Make takeoff/landing in mountains consistent

One-way sorties (fly, recon and sweep) reject mountain destinations
with a "Nowhere to land" message.  However, planes can land there just
fine when they return to base (bomb, drop, paradrop, missions).
Already inconsistent in BSD Empire 1.1.

Fix the inconsistency by changing pln_where_to_land() to permit only
helicopters to land in mountains, and pln_airbase_ok() to permit only
helicopters and missiles to take off there, i.e. reject fixed-wing
aircraft.

The flying commands now reject fixed-wing planes based in mountains
with an "is in a mountain and can't take off" message.

Commands flying to a mountain now select only helicopters and silently
ignore the rest, exactly like they select only VTOL planes for flying
to a non-airfield.  If no planes can be selected, the command fails
with a "No planes could be equipped" message.  This is admittedly less
clear than the "Nowhere to land" message we got before.

Missions now ignore fixed-wing planes based in mountains, exactly like
they ignore non-VTOL planes outside airfields.  This may make players
wonder why the fixed-wing VTOL planes they transported up that
mountain don't obey missions.  Missions are always quiet unless they
execute.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-05-17 22:03:40 +02:00
parent 3f2f201ddb
commit 6157b6cbe4

View file

@ -131,6 +131,7 @@ int
pln_where_to_land(coord x, coord y, pln_where_to_land(coord x, coord y,
union empobj_storage *target, int *flagsp) union empobj_storage *target, int *flagsp)
{ {
/* Keep conditions for landing consistent with pln_airbase_ok() */
int nships; int nships;
int cno; int cno;
int fl; int fl;
@ -176,11 +177,10 @@ pln_where_to_land(coord x, coord y,
pr("Nowhere to land at sector %s!\n", xyas(x, y, player->cnum)); pr("Nowhere to land at sector %s!\n", xyas(x, y, player->cnum));
return -1; return -1;
} }
if (target->sect.sct_type == SCT_MOUNT) {
pr("Nowhere to land at sector %s!\n", xyas(x, y, player->cnum));
return -1;
}
/* clear to land at sector */ /* clear to land at sector */
if (target->sect.sct_type == SCT_MOUNT) {
*flagsp |= P_K;
}
if (target->sect.sct_type != SCT_AIRPT || target->sect.sct_effic < 60) if (target->sect.sct_type != SCT_AIRPT || target->sect.sct_effic < 60)
*flagsp |= P_V; *flagsp |= P_V;
return 0; return 0;
@ -457,9 +457,15 @@ carrier_planes(struct shpstr *sp, int msl)
return res; return res;
} }
/*
* Can @pp operate out its sector?
* If @oneway, consider only takeoff, else takeoff and landing.
* If @noisy, report to current player when it can't.
*/
int int
pln_airbase_ok(struct plnstr *pp, int oneway, int noisy) pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
{ {
/* Keep conditions for landing consistent with pln_where_to_land() */
struct shpstr ship; struct shpstr ship;
struct lndstr land; struct lndstr land;
struct sctstr sect; struct sctstr sect;
@ -501,11 +507,18 @@ pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
return 0; return 0;
} else { } else {
/* sector: needs to be own or allied, efficient airfield */ /* sector: needs to be own or allied, efficient, suitable type */
if (!getsect(pp->pln_x, pp->pln_y, &sect)) { if (!getsect(pp->pln_x, pp->pln_y, &sect)) {
CANT_REACH(); CANT_REACH();
return 0; return 0;
} }
/* mountain requires helo or missile */
if (sect.sct_type == SCT_MOUNT && !(pcp->pl_flags & (P_K | P_M))) {
if (noisy)
pr("(note) %s is in a mountain and can't take off\n",
prplane(pp));
return 0;
}
if (relations_with(sect.sct_own, pp->pln_own) != ALLIED) { if (relations_with(sect.sct_own, pp->pln_own) != ALLIED) {
if (noisy) if (noisy)