(pln_onewaymission, carriersatxy): Change to match ordinary sorties:

offer carriers regardless of the sector they're in, require carriers
to be efficient.  Closes #875376.
This commit is contained in:
Markus Armbruster 2004-08-17 18:34:53 +00:00
parent 4fd7da248a
commit cdad6db4ac
2 changed files with 55 additions and 83 deletions

View file

@ -94,7 +94,6 @@ carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
struct nstr_item ni; struct nstr_item ni;
struct mchrstr *mp; struct mchrstr *mp;
struct shpstr ship; struct shpstr ship;
int allied;
first = 1; first = 1;
ships = 0; ships = 0;
@ -102,8 +101,10 @@ carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
while (nxtitem(&ni, (s_char *)&ship)) { while (nxtitem(&ni, (s_char *)&ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
continue; continue;
allied = (getrel(getnatp(ship.shp_own), own) == ALLIED); if (ship.shp_own != own
if ((ship.shp_own != own) && !allied) && getrel(getnatp(ship.shp_own), own) != ALLIED)
continue;
if (ship.shp_effic < SHP_AIROPS_EFF)
continue; continue;
mp = &mchr[(int)ship.shp_type]; mp = &mchr[(int)ship.shp_type];
if (wantflags) { if (wantflags) {

View file

@ -60,16 +60,58 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
int nships; int nships;
int cno; int cno;
int flags; int flags;
int n;
struct shpstr ship; struct shpstr ship;
s_char buf[1024]; char buf[1024];
s_char *p; char *p;
flags = *flagp; flags = *flagp;
if ((target->sct_own && target->sct_own != player->cnum &&
(getrel(getnatp(target->sct_own), player->cnum) != ALLIED)) && /* offer carriers */
(target->sct_type != SCT_HARBR) && nships = carriersatxy(target->sct_x, target->sct_y,
(target->sct_type != SCT_BSPAN)) { M_FLY | M_CHOPPER, 0, player->cnum);
if (nships) {
for (;;) {
if (!(p = getstarg(0, "Carrier #? ", buf)) || !*p)
break;
cno = atoi(p);
if (cno < 0
|| !getship(cno, &ship)
|| (!player->owner
&& (getrel(getnatp(ship.shp_own), player->cnum)
!= ALLIED))) {
pr("Not yours\n");
continue;
}
if (ship.shp_x != target->sct_x || ship.shp_y != target->sct_y) {
pr("Ship #%d not in %s\n", cno,
xyas(target->sct_x, target->sct_y, player->cnum));
continue;
}
if ((!(mchr[(int)ship.shp_type].m_flags & M_FLY)
&& !(mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
&& !(mchr[(int)ship.shp_type].m_flags & M_CHOPPER))
|| ship.shp_effic < SHP_AIROPS_EFF) {
pr("Can't land on %s.\n", prship(&ship));
continue;
}
/* clear to land on ship#CNO */
pr("landing on carrier %d\n", cno);
if (mchr[(int)ship.shp_type].m_flags & M_FLY)
flags |= P_L;
if (mchr[(int)ship.shp_type].m_flags & M_CHOPPER)
flags |= P_K;
if (mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
flags |= P_E;
*shipno = cno;
*flagp = flags;
return 0;
}
}
/* try to land at sector */
if (target->sct_own != player->cnum
&& getrel(getnatp(target->sct_own), player->cnum) != ALLIED) {
pr("Nowhere to land at sector %s!\n", pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum)); xyas(target->sct_x, target->sct_y, player->cnum));
return -1; return -1;
@ -79,82 +121,11 @@ pln_onewaymission(struct sctstr *target, int *shipno, int *flagp)
xyas(target->sct_x, target->sct_y, player->cnum)); xyas(target->sct_x, target->sct_y, player->cnum));
return -1; return -1;
} }
cno = -1;
if (target->sct_type != SCT_AIRPT || target->sct_effic < 60) if (target->sct_type != SCT_AIRPT || target->sct_effic < 60)
flags |= P_V; flags |= P_V;
if (target->sct_type == SCT_WATER || target->sct_type == SCT_HARBR
|| target->sct_type == SCT_BSPAN) {
nships = carriersatxy(target->sct_x, target->sct_y,
M_FLY | M_CHOPPER, 0, player->cnum);
if (nships <= 0) {
if (target->sct_type == SCT_WATER) {
pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
} else {
if ((target->sct_own && target->sct_own != player->cnum)
&& (getrel(getnatp(target->sct_own), player->cnum) !=
ALLIED)) {
pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
}
*shipno = cno;
*flagp = flags;
return 0;
}
}
cno = (-1);
n = (-1);
while (cno < 0) {
if (!(p = getstarg(0, "Carrier #? ", buf)) || !*p)
break;
n = atoi(p);
if (n < 0 || !getship(n, &ship)
|| (!player->owner
&& (getrel(getnatp(ship.shp_own), player->cnum)
!= ALLIED))) {
pr("Not yours\n");
continue;
}
if (ship.shp_x != target->sct_x || ship.shp_y != target->sct_y) {
pr("Ship #%d not in %s\n", n,
xyas(target->sct_x, target->sct_y, player->cnum));
continue;
}
if (!(mchr[(int)ship.shp_type].m_flags & M_FLY)
&& !(mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
&& !(mchr[(int)ship.shp_type].m_flags & M_CHOPPER)
) {
pr("Can't land on %s.\n", prship(&ship));
continue;
}
pr("landing on carrier %d\n", n);
cno = n;
flags &= ~P_V;
if (mchr[(int)ship.shp_type].m_flags & M_FLY)
flags |= P_L;
if (mchr[(int)ship.shp_type].m_flags & M_CHOPPER)
flags |= P_K;
if (mchr[(int)ship.shp_type].m_flags & M_XLIGHT)
flags |= P_E;
}
if ((target->sct_own && target->sct_own != player->cnum) &&
(getrel(getnatp(target->sct_own), player->cnum) != ALLIED) &&
(cno == -1)) {
pr("Nowhere to land at sector %s!\n",
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
}
}
if ((target->sct_own == 0) && (cno < 0)) { /* clear to land at sector */
pr("Nowhere to land at sector %s!\n", *shipno = -1;
xyas(target->sct_x, target->sct_y, player->cnum));
return -1;
}
*shipno = cno;
*flagp = flags; *flagp = flags;
return 0; return 0;
} }