Make escort mission obey op-area

Before, the escort mission didn't support an op-area, and planes on
escort mission escorted anywhere.  Change mission() to define the
op-area for escort missions as well.  Show it in mission() and
show_mission().  Check it in find_escorts().
This commit is contained in:
Markus Armbruster 2008-11-22 14:52:20 -05:00
parent bf89453f8a
commit a9b2d9c7f3
3 changed files with 8 additions and 15 deletions

View file

@ -222,7 +222,8 @@ Only planes with the 'tactical' ability can fly support missions.
ESCORT MISSIONS (planes only) ESCORT MISSIONS (planes only)
.s1 .s1
When given an escort mission, an escort or intercept capable plane will attempt When given an escort mission, an escort or intercept capable plane will attempt
to escort any plane flying a support or interdict mission from the same airport. to escort any plane flying a support or interdict mission from the
same airport into its op-area.
If even 1 plane flies a support or interdiction mission from an airport, all If even 1 plane flies a support or interdiction mission from an airport, all
planes on escort duty at that airport will attempt to escort. Planes with escort planes on escort duty at that airport will attempt to escort. Planes with escort
duty will NOT attempt to escort planes taking off from other airports, so it duty will NOT attempt to escort planes taking off from other airports, so it

View file

@ -148,7 +148,7 @@ mission(void)
return RET_FAIL; return RET_FAIL;
} }
if (mission && mission != MI_ESCORT) { if (mission) {
if ((p = getstarg(player->argp[4], "operations point? ", buf)) == 0 if ((p = getstarg(player->argp[4], "operations point? ", buf)) == 0
|| *p == 0) || *p == 0)
return RET_SYN; return RET_SYN;
@ -207,7 +207,7 @@ mission(void)
radius = 999; radius = 999;
if (mission == MI_INTERDICT || mission == MI_SUPPORT || if (mission == MI_INTERDICT || mission == MI_SUPPORT ||
mission == MI_OSUPPORT || mission == MI_DSUPPORT || mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
mission == MI_RESERVE || mission == MI_RESERVE || mission == MI_ESCORT ||
mission == MI_AIR_DEFENSE) { mission == MI_AIR_DEFENSE) {
radius = oprange(gp, mission); radius = oprange(gp, mission);
if (radius < dist) { if (radius < dist) {
@ -285,7 +285,7 @@ mission(void)
if (mission == MI_INTERDICT || mission == MI_SUPPORT || if (mission == MI_INTERDICT || mission == MI_SUPPORT ||
mission == MI_OSUPPORT || mission == MI_DSUPPORT || mission == MI_OSUPPORT || mission == MI_DSUPPORT ||
mission == MI_RESERVE || mission == MI_RESERVE || mission == MI_ESCORT ||
mission == MI_AIR_DEFENSE) mission == MI_AIR_DEFENSE)
gp->radius = radius; gp->radius = radius;
else else
@ -293,7 +293,7 @@ mission(void)
if (mission == MI_SUPPORT || mission == MI_OSUPPORT || if (mission == MI_SUPPORT || mission == MI_OSUPPORT ||
mission == MI_DSUPPORT || mission == MI_INTERDICT || mission == MI_DSUPPORT || mission == MI_INTERDICT ||
mission == MI_RESERVE || mission == MI_RESERVE || mission == MI_ESCORT ||
mission == MI_AIR_DEFENSE) { mission == MI_AIR_DEFENSE) {
pr("%s on %s mission, centered on %s, radius %d\n", pr("%s on %s mission, centered on %s, radius %d\n",
obj_nameof(gp), mission_name(mission), obj_nameof(gp), mission_name(mission),

View file

@ -355,20 +355,15 @@ find_escorts(coord x, coord y, natid cn, struct emp_qelem *escorts)
struct nstr_item ni; struct nstr_item ni;
struct plist *plp; struct plist *plp;
struct plnstr plane; struct plnstr plane;
int dist;
snxtitem_all(&ni, EF_PLANE); snxtitem_all(&ni, EF_PLANE);
while (nxtitem(&ni, &plane)) { while (nxtitem(&ni, &plane)) {
if (plane.pln_own != cn) if (plane.pln_own != cn)
continue; continue;
if (plane.pln_mission != MI_ESCORT) if (plane.pln_mission != MI_ESCORT)
continue; continue;
if (!in_oparea((struct empobj *)&plane, x, y))
dist = mapdist(x, y, plane.pln_x, plane.pln_y);
if (dist > plane.pln_range / 2)
continue; continue;
plp = malloc(sizeof(struct plist)); plp = malloc(sizeof(struct plist));
memset(plp, 0, sizeof(struct plist)); memset(plp, 0, sizeof(struct plist));
plp->pcp = &plchr[(int)plane.pln_type]; plp->pcp = &plchr[(int)plane.pln_type];
@ -768,16 +763,13 @@ show_mission(int type, struct nstr_item *np)
case MI_INTERDICT: case MI_INTERDICT:
case MI_SUPPORT: case MI_SUPPORT:
case MI_RESERVE: case MI_RESERVE:
case MI_ESCORT:
case MI_AIR_DEFENSE: case MI_AIR_DEFENSE:
case MI_DSUPPORT: case MI_DSUPPORT:
case MI_OSUPPORT: case MI_OSUPPORT:
prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum); prxy(" %3d,%-3d", gp->opx, gp->opy, player->cnum);
pr(" %4d", gp->radius); pr(" %4d", gp->radius);
break; break;
case MI_ESCORT:
pr(" ");
pr(" %4d", item.plane.pln_range / 2);
break;
default: default:
CANT_REACH(); CANT_REACH();
/* fall through */ /* fall through */