Make land units on reserve mission react within op-area
Before, they always reacted to their maximum range, and the op-area was unused. Change mission() to define the op-area for reserve missions as well. Remove the special-case for showing reserve missions from mission() and show_mission(). New lnd_reaction_range() factored out of att_reacting_units(). Use it in oprange() to cover reserve missions. Pass the mission as separate parameter to oprange() for now, because miss() doesn't set it in the object until later.
This commit is contained in:
parent
40d8357746
commit
8e527b6cff
7 changed files with 40 additions and 52 deletions
|
@ -179,6 +179,7 @@ extern double lnd_mobcost(struct lndstr *, struct sctstr *);
|
||||||
|
|
||||||
extern double attack_val(int, struct lndstr *);
|
extern double attack_val(int, struct lndstr *);
|
||||||
extern double defense_val(struct lndstr *);
|
extern double defense_val(struct lndstr *);
|
||||||
|
extern int lnd_reaction_range(struct lndstr *);
|
||||||
extern void lnd_print(struct ulist *, char *);
|
extern void lnd_print(struct ulist *, char *);
|
||||||
extern void lnd_delete(struct ulist *, char *);
|
extern void lnd_delete(struct ulist *, char *);
|
||||||
extern int lnd_take_casualty(int, struct ulist *, int);
|
extern int lnd_take_casualty(int, struct ulist *, int);
|
||||||
|
|
|
@ -484,7 +484,7 @@ extern int ground_interdict(coord, coord, natid, char *);
|
||||||
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
extern int unit_interdict(coord, coord, natid, char *, int, int);
|
||||||
extern int off_support(coord, coord, natid, natid);
|
extern int off_support(coord, coord, natid, natid);
|
||||||
extern int def_support(coord, coord, natid, natid);
|
extern int def_support(coord, coord, natid, natid);
|
||||||
extern int oprange(struct empobj *);
|
extern int oprange(struct empobj *, int);
|
||||||
extern int in_oparea(struct empobj *, coord, coord);
|
extern int in_oparea(struct empobj *, coord, coord);
|
||||||
extern int cando(int, int);
|
extern int cando(int, int);
|
||||||
extern void show_mission(int, struct nstr_item *);
|
extern void show_mission(int, struct nstr_item *);
|
||||||
|
|
|
@ -66,8 +66,9 @@ OPERATIONS SECTORS
|
||||||
Some missions require the designation of an 'op sector', short for operations
|
Some missions require the designation of an 'op sector', short for operations
|
||||||
sector. This is the center of an area that the mission is focused on.
|
sector. This is the center of an area that the mission is focused on.
|
||||||
The op sector may be any sector that is within the unit's range.
|
The op sector may be any sector that is within the unit's range.
|
||||||
(Firing range, for ships & land units, flying range for planes,
|
(Firing range for ships & land units on interdiction, reaction range
|
||||||
changeable with range command).
|
for land units on reserve, changeable with lrange command, flying
|
||||||
|
range for planes, changeable with range command).
|
||||||
The unit will exert influence in a radius around the op sector.
|
The unit will exert influence in a radius around the op sector.
|
||||||
By default, the radius will be as large as possible, i.e. the biggest range
|
By default, the radius will be as large as possible, i.e. the biggest range
|
||||||
so that the unit/ship/plane could legally act there.)
|
so that the unit/ship/plane could legally act there.)
|
||||||
|
@ -289,18 +290,14 @@ lost his planes.
|
||||||
.s1
|
.s1
|
||||||
RESERVE MISSIONS (land units only)
|
RESERVE MISSIONS (land units only)
|
||||||
.s1
|
.s1
|
||||||
This mission has no effect at this time.
|
A land unit on a reserve mission may react to enemy attacks within its
|
||||||
|
op-area. See info \*QAttacking\*U for more on land unit reactions.
|
||||||
.s1
|
.s1
|
||||||
Note that units with a reserve mission retain this status even when they
|
Note that units with a reserve mission retain this status even when they
|
||||||
react to a threatened sector and return. This is an exception to the normal
|
react to a threatened sector and return. This is an exception to the normal
|
||||||
rules on losing your mission status. If, however, the land unit is forced to
|
rules on losing your mission status. If, however, the land unit is forced to
|
||||||
retreat from the combat (see land combat for details), it DOES lose its status.
|
retreat from the combat (see land combat for details), it DOES lose its status.
|
||||||
.s1
|
.s1
|
||||||
When a unit with a reserve mission is listed, the op sector is the sector
|
|
||||||
the unit is in, and the radius is the units maximum reaction radius, including
|
|
||||||
the bonus for HQ (if applicable). Note that the unit's
|
|
||||||
actual radius might be different if it was changed by lrange command.
|
|
||||||
.s1
|
|
||||||
Note: information gained from planes flying missions is automatically
|
Note: information gained from planes flying missions is automatically
|
||||||
added to your bmap.
|
added to your bmap.
|
||||||
.s1
|
.s1
|
||||||
|
|
|
@ -148,7 +148,7 @@ mission(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mission && ((mission != MI_RESERVE) && (mission != MI_ESCORT))) {
|
if (mission && mission != MI_ESCORT) {
|
||||||
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;
|
||||||
|
@ -205,10 +205,11 @@ mission(void)
|
||||||
|
|
||||||
dist = mapdist(gp->x, gp->y, x, y);
|
dist = mapdist(gp->x, gp->y, x, y);
|
||||||
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_AIR_DEFENSE)) {
|
mission == MI_RESERVE ||
|
||||||
radius = oprange(gp);
|
mission == MI_AIR_DEFENSE) {
|
||||||
|
radius = oprange(gp, mission);
|
||||||
if (radius < dist) {
|
if (radius < dist) {
|
||||||
pr("%s: out of range! (range %d)\n",
|
pr("%s: out of range! (range %d)\n",
|
||||||
obj_nameof(gp), radius);
|
obj_nameof(gp), radius);
|
||||||
|
@ -284,6 +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_AIR_DEFENSE)
|
mission == MI_AIR_DEFENSE)
|
||||||
gp->radius = radius;
|
gp->radius = radius;
|
||||||
else
|
else
|
||||||
|
@ -291,21 +293,11 @@ 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_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),
|
||||||
xyas(x, y, player->cnum), gp->radius);
|
xyas(x, y, player->cnum), gp->radius);
|
||||||
} else if (mission == MI_RESERVE) {
|
|
||||||
radius = ((struct lndstr *)gp)->lnd_rad_max;
|
|
||||||
if (radius) {
|
|
||||||
getsect(gp->x, gp->y, &opsect);
|
|
||||||
if ((opsect.sct_type == SCT_HEADQ)
|
|
||||||
&& (opsect.sct_effic >= 60))
|
|
||||||
radius++;
|
|
||||||
}
|
|
||||||
|
|
||||||
pr("%s on %s mission with maximum reaction radius %d\n",
|
|
||||||
obj_nameof(gp), mission_name(mission), radius);
|
|
||||||
} else if (mission) {
|
} else if (mission) {
|
||||||
pr("%s on %s mission\n", obj_nameof(gp),
|
pr("%s on %s mission\n", obj_nameof(gp),
|
||||||
mission_name(mission));
|
mission_name(mission));
|
||||||
|
|
|
@ -1469,8 +1469,6 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
|
||||||
double new_land = 0;
|
double new_land = 0;
|
||||||
double mobcost;
|
double mobcost;
|
||||||
double pathcost;
|
double pathcost;
|
||||||
int dist;
|
|
||||||
int radius;
|
|
||||||
int origx, origy;
|
int origx, origy;
|
||||||
double eff = att_combat_eff(def);
|
double eff = att_combat_eff(def);
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
@ -1502,18 +1500,16 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
|
||||||
if (!has_supply(&land))
|
if (!has_supply(&land))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
dist = mapdist(land.lnd_x, land.lnd_y, def->x, def->y);
|
if (land.lnd_mission == MI_RESERVE) {
|
||||||
|
if (!in_oparea((struct empobj *)&land, def->x, def->y))
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
if (mapdist(land.lnd_x, land.lnd_y, def->x, def->y)
|
||||||
|
> lnd_reaction_range(&land))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
getsect(land.lnd_x, land.lnd_y, §);
|
getsect(land.lnd_x, land.lnd_y, §);
|
||||||
/* Units on efficient headquarters can react 1 farther */
|
|
||||||
if ((sect.sct_type == SCT_HEADQ) && (sect.sct_effic >= 60))
|
|
||||||
radius = land.lnd_rad_max + 1;
|
|
||||||
else
|
|
||||||
radius = land.lnd_rad_max;
|
|
||||||
|
|
||||||
if (dist > radius)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
getsect(def->x, def->y, &dsect);
|
getsect(def->x, def->y, &dsect);
|
||||||
if (!BestLandPath(buf, §, &dsect, &pathcost,
|
if (!BestLandPath(buf, §, &dsect, &pathcost,
|
||||||
lnd_mobtype(&land)))
|
lnd_mobtype(&land)))
|
||||||
|
|
|
@ -124,6 +124,17 @@ defense_val(struct lndstr *lp)
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
lnd_reaction_range(struct lndstr *lp)
|
||||||
|
{
|
||||||
|
struct sctstr sect;
|
||||||
|
|
||||||
|
getsect(lp->lnd_x, lp->lnd_y, §);
|
||||||
|
if (sect.sct_type == SCT_HEADQ && sect.sct_effic >= 60)
|
||||||
|
return lp->lnd_rad_max + 1;
|
||||||
|
return lp->lnd_rad_max;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
lnd_print(struct ulist *llp, char *s)
|
lnd_print(struct ulist *llp, char *s)
|
||||||
{
|
{
|
||||||
|
|
|
@ -749,10 +749,9 @@ mission_name(short mission)
|
||||||
void
|
void
|
||||||
show_mission(int type, struct nstr_item *np)
|
show_mission(int type, struct nstr_item *np)
|
||||||
{
|
{
|
||||||
int first = 1, radius;
|
int first = 1;
|
||||||
union empobj_storage item;
|
union empobj_storage item;
|
||||||
struct empobj *gp;
|
struct empobj *gp;
|
||||||
struct sctstr sect;
|
|
||||||
|
|
||||||
while (nxtitem(np, &item)) {
|
while (nxtitem(np, &item)) {
|
||||||
gp = (struct empobj *)&item;
|
gp = (struct empobj *)&item;
|
||||||
|
@ -768,23 +767,13 @@ show_mission(int type, struct nstr_item *np)
|
||||||
switch (gp->mission) {
|
switch (gp->mission) {
|
||||||
case MI_INTERDICT:
|
case MI_INTERDICT:
|
||||||
case MI_SUPPORT:
|
case MI_SUPPORT:
|
||||||
|
case MI_RESERVE:
|
||||||
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_RESERVE:
|
|
||||||
radius = item.land.lnd_rad_max;
|
|
||||||
|
|
||||||
if (radius) {
|
|
||||||
getsect(gp->x, gp->y, §);
|
|
||||||
if ((sect.sct_type == SCT_HEADQ) && (sect.sct_effic >= 60))
|
|
||||||
radius++;
|
|
||||||
}
|
|
||||||
prxy(" %3d,%-3d", gp->x, gp->y, player->cnum);
|
|
||||||
pr(" %4d", radius);
|
|
||||||
break;
|
|
||||||
case MI_ESCORT:
|
case MI_ESCORT:
|
||||||
pr(" ");
|
pr(" ");
|
||||||
pr(" %4d", item.plane.pln_range / 2);
|
pr(" %4d", item.plane.pln_range / 2);
|
||||||
|
@ -803,12 +792,14 @@ show_mission(int type, struct nstr_item *np)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
oprange(struct empobj *gp)
|
oprange(struct empobj *gp, int mission)
|
||||||
{
|
{
|
||||||
switch (gp->ef_type) {
|
switch (gp->ef_type) {
|
||||||
case EF_SHIP:
|
case EF_SHIP:
|
||||||
return ldround(shp_fire_range((struct shpstr *)gp), 1);
|
return ldround(shp_fire_range((struct shpstr *)gp), 1);
|
||||||
case EF_LAND:
|
case EF_LAND:
|
||||||
|
if (mission == MI_RESERVE)
|
||||||
|
return lnd_reaction_range((struct lndstr *)gp);
|
||||||
return ldround(lnd_fire_range((struct lndstr *)gp), 1);
|
return ldround(lnd_fire_range((struct lndstr *)gp), 1);
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
/* missiles go one way, so we can use all the range */
|
/* missiles go one way, so we can use all the range */
|
||||||
|
@ -827,7 +818,7 @@ int
|
||||||
in_oparea(struct empobj *gp, coord x, coord y)
|
in_oparea(struct empobj *gp, coord x, coord y)
|
||||||
{
|
{
|
||||||
return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
|
return mapdist(x, y, gp->opx, gp->opy) <= gp->radius
|
||||||
&& mapdist(x, y, gp->x, gp->y) <= oprange(gp);
|
&& mapdist(x, y, gp->x, gp->y) <= oprange(gp, gp->mission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue