Remove non-mission land unit reaction

Land unit reactions are overly complex because we have two different
concepts controlling them: reaction radius (set with lrange) and
reserve mission (set with mission).  You need to deal with both to set
up or query reactions.

Commit 8d0e1af5 "fixed" this by making reserve missions meaningless.

The previous commit made reserve missions meaningful again: they
support an op-area now.  This brought back the problem of having to
deal with two separate commands to accomplish one thing.

Fix this for good by removing non-mission land unit reaction
alltogether.  The only feature we lose by that is the ability to order
land units to react until the order is explicitely cancelled.  That's
because missions are implicitely cleared by many commands and events,
while non-mission reaction wasn't.  Closes #858121 and #858122.

Remove the non-mission reaction case from att_reacting_units().

Don't limit reserve missions to the land unit's reaction radius: make
lnd_reaction_range() return the type's maximum radius instead of
lnd_rad_max.

The reaction radius is now useless.  Remove the lrange command, and
struct lndstr member lnd_rad_max along with its selector react.
Remove land command's column rd.  Make ldump show column react as
zero.  Deprecate edit key 'P' in dounit(), and don't show it in
pr_land().
This commit is contained in:
Markus Armbruster 2008-11-24 20:31:22 -05:00
parent 8e527b6cff
commit bf89453f8a
17 changed files with 23 additions and 98 deletions

View file

@ -72,7 +72,6 @@ struct lndstr {
short lnd_retreat; /* retreat percentage */ short lnd_retreat; /* retreat percentage */
int lnd_rflags; /* When do I retreat? */ int lnd_rflags; /* When do I retreat? */
char lnd_rpath[RET_LEN]; /* retreat path */ char lnd_rpath[RET_LEN]; /* retreat path */
unsigned char lnd_rad_max; /* max radius for this unit */
unsigned char lnd_scar; /* how experienced the unit is (not used) */ unsigned char lnd_scar; /* how experienced the unit is (not used) */
short lnd_item[I_MAX+1]; /* amount of items on board */ short lnd_item[I_MAX+1]; /* amount of items on board */
short lnd_pstage; /* plague stage */ short lnd_pstage; /* plague stage */

View file

@ -149,7 +149,6 @@ int load(void);
int look(void); int look(void);
int lost(void); int lost(void);
int lrad(void); int lrad(void);
int lrange(void);
int lretr(void); int lretr(void);
int lsta(void); int lsta(void);
int ltend(void); int ltend(void);

View file

@ -133,20 +133,18 @@ strength of your sectors.
.s1 .s1
.L "(4) Move reacting defensive units to the target sector." .L "(4) Move reacting defensive units to the target sector."
.s1 .s1
If the target is not a mountain, then defensive units in nearby If the target is not a mountain, then nearby land units on reserve
sectors may react. Defensive units will keep reacting until the missions may react. Reserve units will keep reacting until the
defense strength is 1.2 times the offense strength. The following defense strength is 1.2 times the offense strength. The following
restrictions apply to reacting land units: restrictions apply to reacting land units:
.NF .NF
- The target must be in the mission's op-area, and in reaction range.
- The efficiency of the unit must be higher than it's retreat percentage. - The efficiency of the unit must be higher than it's retreat percentage.
- The unit must be in supply. - The unit must be in supply.
- The unit must have enough mobility to get to the target. - The unit must have enough mobility to get to the target.
- The unit must be in range.
.FI .FI
If the unit is in a 60% efficient headquarters, then 1 is added to its If the unit is in a 60% efficient headquarters, then 1 is added to its
reaction radius. reaction range.
Note that you can limit the reaction radius of your land
units using the "lrange" command.
.s1 .s1
.L "(5) Calculate support." .L "(5) Calculate support."
.s1 .s1

View file

@ -24,19 +24,19 @@ Let's look at a typical land unit:
.s1 .s1
.EX land * .EX land *
.NF .NF
# unit type x,y a eff mil fort mu fd tech retr rd xl ship # unit type x,y a eff mil frt mu fd tch retr xl ln carry
0 inf infantry 8,0 96% 100 0 93 24 0 42% 1 0 0 inf infantry 8,0 96% 100 0 93 1 50 42% 0 0
1 unit 1 unit
.FI .FI
.s1 .s1
This land unit is an infantry unit, located at 8,0. In many games, you will This land unit is an infantry unit, located at 8,0. In many games, you will
start with 1-2 basic land units of this type. Some of the things about it are start with 1-2 basic land units of this type. Some of the things about it are
familiar. It is 96% efficient, has 93 mobility units, carries 1 food, familiar. It is 96% efficient, has 93 mobility units, carries 1 food,
and is tech 0 and currently contains 100 mi. It carries 0 extra-light and is tech 50 and currently contains 100 mi. It carries 0 extra-light
planes, and is not on a ship. The 'a' planes and land units, and is not on a ship. The 'a'
stands for army, and is just like fleets or wings, i.e. a way of grouping your stands for army, and is just like fleets or wings, i.e. a way of grouping your
units. (See info \*Qarmy\*U for more information) units. (See info \*Qarmy\*U for more information)
Fort is the level of fortification of the land Frt is the level of fortification of the land
unit. The higher the fortification, the harder the unit is to hurt. unit. The higher the fortification, the harder the unit is to hurt.
.s1 .s1
The 'retr' stands for retreat percentage. This The 'retr' stands for retreat percentage. This
@ -48,18 +48,6 @@ you can set this to 100% or some other high number. (For information on
setting this, see info \*Qmorale\*U. For information on morale checks, see info setting this, see info \*Qmorale\*U. For information on morale checks, see info
\*QAttacking\*U) \*QAttacking\*U)
.s1 .s1
The 'rd' field is referred to as the unit's 'reaction radius',
and is the distance to which the unit can react to defend your country.
Basically, if an enemy attacks a sector close enough to the unit, it will go
to the threatened sector and fight, like a plane intercepting. If it survives
the attack without failing a morale check, it will return to the sector it
started from, just like a plane would. (For more information on reacting and
morale checks, see info \*QAttacking\*U) Just as you can use \*Qrange\*U to change the
range of your planes and control how far away they'll intercept, you can
change the reaction radius for land units with \*Qlrange\*U. Units with a base reaction
radius of 0, or those whose radius you have set to 0, will not react.
When built, the unit will have as its reaction radius set to zero.
.s1
.L Cargo .L Cargo
.s1 .s1
Each land unit can carry cargo. The cargo display for land units is very Each land unit can carry cargo. The cargo display for land units is very
@ -186,9 +174,6 @@ Don't confuse this spy value with the "spy" capability of a unit. See
"info \*QSpies\*U" for more information. "info \*QSpies\*U" for more information.
.s1 .s1
Rad is the maximum reaction radius for the unit. Rad is the maximum reaction radius for the unit.
If you change the reaction radius by using
the \*Qlrange\*U command, you will be able to select any value that is
between 0 and the maximum.
.s1 .s1
Frg is the unit's firing range. The unit can fire as far as the frg, modified Frg is the unit's firing range. The unit can fire as far as the frg, modified
by the unit's tech. Accuracy is the unit's firing accuracy, and helps to by the unit's tech. Accuracy is the unit's firing accuracy, and helps to

View file

@ -17,8 +17,7 @@ the new server:
(1) Build 100% forts and put 10 guns and at least 100 shells in them. (1) Build 100% forts and put 10 guns and at least 100 shells in them.
(2) Put at least 5 mil in all of your coastal sectors. (2) Put at least 5 mil in all of your coastal sectors.
(3) Build infantry units, put them in the forts, "fortify" them, (3) Build infantry units, put them in the forts, "fortify" them,
put them on "reserve" mission (info mission) and set their and put them on "reserve" mission (info mission).
reaction radius to maximum (info lrange).
(4) Build battleships and artillery and put them on "interdiction" (4) Build battleships and artillery and put them on "interdiction"
mission. Put the artillery in forts and fortify them. mission. Put the artillery in forts and fortify them.
(5) Put infantry units in your banks and capitals and fortify them. (5) Put infantry units in your banks and capitals and fortify them.

View file

@ -6,10 +6,10 @@ The land unit report command is a census of your land units. For
example: example:
.EX land * .EX land *
.NF .NF
# unit type x,y a eff mil frt mu fd tch retr rd xl ln carry # unit type x,y a eff mil frt mu fd tch retr xl ln carry
0 cav cavalry 1,-1 100% 10 0 127 12 992 75% 3 0 0 0 cav cavalry 1,-1 100% 10 0 127 12 992 75% 0 0
1 cav cavalry 0,0 100% 0 0 127 12 968 75% 3 0 0 1 cav cavalry 0,0 100% 0 0 127 12 968 75% 0 0
2 cav cavalry 0,0 100% 10 0 127 12 40 75% 3 0 0 2 cav cavalry 0,0 100% 10 0 127 12 40 75% 0 0
3 units 3 units
.FI .FI
.s1 .s1
@ -38,8 +38,6 @@ the amount of food on board,
the tech level of the land unit, the tech level of the land unit,
.L retr .L retr
the retreat percentage of the land unit (see info \*morale\*U), the retreat percentage of the land unit (see info \*morale\*U),
.L rd
the land unit's reaction radius (see info \*Qfortify\*U),
.L xl .L xl
the number of extra-light planes on board, the number of extra-light planes on board,
.L ln .L ln

View file

@ -1,11 +0,0 @@
.TH Command LRANGE
.NA lrange "Edit the reaction range of a unit"
.LV Expert
.SY "lrange <UNITS> <reaction-radius>"
The \*Qlrange\*U command is used to limit the maximum reaction radius of
land units. This can be useful in restricting the area which a unit will
attempt to defend. (see info attack for details of the reaction process)
.s1
A unit with a radius of 0 will not react.
.s1
.SA "attack, LandUnits"

View file

@ -67,7 +67,7 @@ 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 on interdiction, reaction range (Firing range for ships & land units on interdiction, reaction range
for land units on reserve, changeable with lrange command, flying for land units on reserve, flying
range for planes, changeable with range command). 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

View file

@ -347,7 +347,6 @@ pr_land(struct lndstr *land)
pr("Fortification <F>: %d\t", land->lnd_harden); pr("Fortification <F>: %d\t", land->lnd_harden);
pr("Land unit <Y>: %d\n", land->lnd_land); pr("Land unit <Y>: %d\n", land->lnd_land);
pr("Ship <S>: %d\t\t", land->lnd_ship); pr("Ship <S>: %d\t\t", land->lnd_ship);
pr("Radius <P>: %d\n", land->lnd_rad_max);
pr("Retreat percentage <Z>: %d\n", land->lnd_retreat); pr("Retreat percentage <Z>: %d\n", land->lnd_retreat);
pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n", pr("Retreat path <R>: '%s'\t\tRetreat Flags <W>: %d\n",
land->lnd_rpath, land->lnd_rflags); land->lnd_rpath, land->lnd_rflags);
@ -915,7 +914,7 @@ dounit(char op, int arg, char *p, struct lndstr *land)
land->lnd_ship = arg; land->lnd_ship = arg;
break; break;
case 'P': case 'P':
land->lnd_rad_max = arg; warn_deprecated(op);
break; break;
case 'Z': case 'Z':
land->lnd_retreat = arg; land->lnd_retreat = arg;

View file

@ -57,7 +57,7 @@ land(void)
if (player->god) if (player->god)
pr("own "); pr("own ");
pr(" # unit type x,y a eff mil frt mu fd"); pr(" # unit type x,y a eff mil frt mu fd");
pr(" tch retr rd xl ln carry\n"); pr(" tch retr xl ln carry\n");
} }
if (land.lnd_off) if (land.lnd_off)
noff++; noff++;
@ -74,7 +74,6 @@ land(void)
pr("%4d", land.lnd_item[I_FOOD]); pr("%4d", land.lnd_item[I_FOOD]);
pr("%4d ", land.lnd_tech); pr("%4d ", land.lnd_tech);
pr("%3d%%", land.lnd_retreat); pr("%3d%%", land.lnd_retreat);
pr("%3d", land.lnd_rad_max);
pr("%3d", lnd_nxlight(&land)); pr("%3d", lnd_nxlight(&land));
pr("%3d", lnd_nland(&land)); pr("%3d", lnd_nland(&land));
if (land.lnd_ship >= 0) if (land.lnd_ship >= 0)

View file

@ -343,7 +343,7 @@ ldump(void)
pr(" %d", land.lnd_retreat); pr(" %d", land.lnd_retreat);
break; break;
case 13: case 13:
pr(" %d", land.lnd_rad_max); pr(" 0");
break; break;
case 14: case 14:
pr(" %d", lnd_nxlight(&land)); pr(" %d", lnd_nxlight(&land));

View file

@ -68,34 +68,3 @@ range(void)
return RET_OK; return RET_OK;
} }
int
lrange(void)
{
struct nstr_item np;
struct lndstr land;
int i;
char *p;
char prompt[128];
char buf[1024];
if (!snxtitem(&np, EF_LAND, player->argp[1], NULL))
return RET_SYN;
while (nxtitem(&np, &land)) {
if (!player->owner || land.lnd_own == 0)
continue;
sprintf(prompt, "New range for %s? ", prland(&land));
if ((p = getstarg(player->argp[2], prompt, buf)) == 0)
return RET_SYN;
if (!check_land_ok(&land))
return RET_SYN;
if ((i = atoi(p)) < 0)
continue;
land.lnd_rad_max = MIN(i, lchr[land.lnd_type].l_rad);
pr("%s reaction radius changed to %d\n",
prland(&land), land.lnd_rad_max);
putland(land.lnd_uid, &land);
}
return RET_OK;
}

View file

@ -344,7 +344,6 @@ struct castr land_ca[] = {
{"rflags", fldoff(lnd_rflags), NSC_INT, 0, NULL, {"rflags", fldoff(lnd_rflags), NSC_INT, 0, NULL,
EF_RETREAT_FLAGS, NSC_BITS}, EF_RETREAT_FLAGS, NSC_BITS},
{"rpath", fldoff(lnd_rpath), NSC_STRINGY, RET_LEN, NULL, EF_BAD, 0}, {"rpath", fldoff(lnd_rpath), NSC_STRINGY, RET_LEN, NULL, EF_BAD, 0},
{"react", fldoff(lnd_rad_max), NSC_UCHAR, 0, NULL, EF_BAD, 0},
NSC_IVEC(fldoff(lnd_item), ""), NSC_IVEC(fldoff(lnd_item), ""),
{"pstage", fldoff(lnd_pstage), NSC_SHORT, 0, NULL, {"pstage", fldoff(lnd_pstage), NSC_SHORT, 0, NULL,
EF_PLAGUE_STAGES, NSC_DEITY}, EF_PLAGUE_STAGES, NSC_DEITY},

View file

@ -142,7 +142,6 @@ struct cmndstr player_coms[] = {
{"lookout <SHIPS>", 1, look, 0, NORM + CAP}, {"lookout <SHIPS>", 1, look, 0, NORM + CAP},
{"lost", 0, lost, 0, NORM}, {"lost", 0, lost, 0, NORM},
{"lradar <UNITS | SECTS>", 1, lrad, 0, NORM + CAP}, {"lradar <UNITS | SECTS>", 1, lrad, 0, NORM + CAP},
{"lrange <UNITS> <range>", 1, lrange, C_MOD, NORM + CAP},
{"lretreat <UNITS|ARMY> <PATH> [i|h|b|c]", {"lretreat <UNITS|ARMY> <PATH> [i|h|b|c]",
1, lretr, C_MOD, NORM + CAP}, 1, lretr, C_MOD, NORM + CAP},
{"lstat <UNITS>", 0, lsta, C_MOD, NORM}, {"lstat <UNITS>", 0, lsta, C_MOD, NORM},

View file

@ -1481,7 +1481,7 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
while (nxtitem(&ni, &land) && dtotal + new_land * eff < 1.2 * ototal) { while (nxtitem(&ni, &land) && dtotal + new_land * eff < 1.2 * ototal) {
if (!land.lnd_own) if (!land.lnd_own)
continue; continue;
if (!land.lnd_rad_max) if (land.lnd_mission != MI_RESERVE)
continue; continue;
if ((land.lnd_x == def->x) && (land.lnd_y == def->y)) if ((land.lnd_x == def->x) && (land.lnd_y == def->y))
continue; continue;
@ -1500,14 +1500,8 @@ att_reacting_units(struct combat *def, struct emp_qelem *list, int a_spy,
if (!has_supply(&land)) if (!has_supply(&land))
continue; continue;
if (land.lnd_mission == MI_RESERVE) { if (!in_oparea((struct empobj *)&land, def->x, def->y))
if (!in_oparea((struct empobj *)&land, def->x, def->y)) continue;
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, &sect); getsect(land.lnd_x, land.lnd_y, &sect);
getsect(def->x, def->y, &dsect); getsect(def->x, def->y, &dsect);

View file

@ -131,8 +131,8 @@ lnd_reaction_range(struct lndstr *lp)
getsect(lp->lnd_x, lp->lnd_y, &sect); getsect(lp->lnd_x, lp->lnd_y, &sect);
if (sect.sct_type == SCT_HEADQ && sect.sct_effic >= 60) if (sect.sct_type == SCT_HEADQ && sect.sct_effic >= 60)
return lp->lnd_rad_max + 1; return lchr[lp->lnd_type].l_rad + 1;
return lp->lnd_rad_max; return lchr[lp->lnd_type].l_rad;
} }
void void

View file

@ -353,7 +353,6 @@ unit_wipe_orders(struct empobj *unit)
lp->lnd_retreat = morale_base; lp->lnd_retreat = morale_base;
lp->lnd_rflags = 0; lp->lnd_rflags = 0;
lp->lnd_rpath[0] = 0; lp->lnd_rpath[0] = 0;
lp->lnd_rad_max = 0;
break; break;
case EF_NUKE: case EF_NUKE:
break; break;