Missiles attacking ground targets (sectors, ships or land units) can
be intercepted, missiles targeting planes can't. Except msl_launch()
checked the missile's capabilities instead of its target, and thus
intercepted missiles that *could* target ground even when they
targeted planes.
This broke the missile interception code's assumption that
interceptors aren't intercepted, and crashed the server through
infinite recursion: tactical abm #1 intercepts, tactical abm #2
intercepts #1, #1 intercepts #2, ...
Same bug in msl_hit() printed "incoming missile" for missiles that
could target ground but do target planes.
Broken in Empire 2. Bug can't bite with the stock game's planes.
Collateral damage was disabled, because after msl_hit() reported a
miss, the missile may or may not have reached the target.
Fix by splitting msl_launch() off msl_hit().
Drop the disabled collateral damage code for sector targets, because
sectors can't be missed. Enable it for ships and land units.
Since msl_launch() returns whether the missile is sub-launched, drop
launch_missile() parameter sublaunch, and simplify its caller.
Keep only the common part in msl_intercept(), and give it internal
linkage. Wrap new msl_abm_intercept() and msl_asat_intercept() around
it. They are simpler to use.
Ship interdiction works sector by sector. Interdicting missiles
targeted all ships not yet interdicted, not just the ones in the
current sector. This could lead to interdiction outside missile range
or op area.
Before Empire 2, nukes could be delivered only with bomb (special
mission 'n', airburst only) and launch (targeting sectors or
satellites only).
Empire 2 made nukes available for any kind of bombing, and for any
missile strike on sectors or ships. This included interdiction and
support missions. Nuclear-tipped anti-sats and bomb mission n were
removed.
Unfortunately, this was done in a messy way, which led to
inconsistencies and bugs. The problem is that ordinary damage affects
just the target, while nuke damage affects an area. Code dealing with
plane damage was designed for the former. Instead of rewriting it to
cope with area damage cleanly, nuke damage got shoehorned into
pln_damage(), the function to compute conventional plane damage, as a
side effect: computing damage blasted sectors in the area.
If the plane carried a nuke, pln_damage() returned zero (conventional)
damage. Without further logic, this simply bypassed the code to apply
damage to the target. This worked out okay when the target already
got damaged correctly by the side effect.
However, some targets are immune to the side effect: when interdicting
a move or explore command, the commodities being moved are not in any
sector.
For other targets, damage has effects other than damaging the target:
offensive and defensive support don't apply the (conventional) damage
to the target sector. Instead, they turn it into a combat bonus.
Without further logic, nuclear damage doesn't contribute to that.
To make all that work, pln_damage() returned the nuclear damage for
ground zero as well. Because a plane does either conventional or
nuclear damage, one of them is always zero.
Most callers simply ignored the nuclear damage, and applied only the
conventional damage.
Bug: land units and ships failed to retreat when pin-bombed or
missiled with a nuke. That's because they received zero conventional
damage.
The mission code flies planes and missiles and tallies their damage.
This mission damage included nuclear damage at ground zero (except for
missiles sometimes, see below), to make support and commodity
interdiction work. Unfortunately, this broke other things.
Bug: when bombers interdicted ships or land units, nukes first damaged
the ships or land units by the side effect, then again through mission
damage. Interdicting missiles had a special case to avoid this.
Bug: when interdicting move, explore or transport, nukes first damaged
the sector by the side effect, then again through mission damage's
collateral damage.
There may well be more bugs hiding in this mess.
The mess is not worth fixing. While the idea of interdicting and
supporting with nukes sounds kind of cool, I believe it's pretty
irrelevant in actual play.
Instead, go back to a variation of the original rules: nukes can be
delivered only through bomb mission 's' and launch at sectors.
Make arm reject marine missiles in addition to satellites, ABMs and
SAMs, and clear the mission. Make mission reject planes armed with
nukes. Oops when they show up in mission_pln_equip() anyway.
Make pln_equip() allow planes with nukes only for missions 's' and
't'.
Clean up pln_damage() to just compute damage, without side effect.
Change strat_bomb() and launch_missile() to detonate nukes. Simplify
the other callers. Parameter mission of msl_launch_mindam() is now
unused, remove it.
Missiles exploding on launch no longer set off their nukes. That was
pretty ridiculous anyway.
msl_equip() used mission_pln_equip(), which is for automatic defenses,
and therefore silent. Its users launch_as(), launch_missile() and
launch_sat() printed failure diagnostics based on assumptions on what
could go wrong.
Switch to the appropriate function for commands, pln_equip(), and
remove the guesswork. Implement mission 'i' there. When launching
from a foreign base, its owner now gets informed. Unimportant at this
time, as players can't easily deploy missiles in foreign bases.
This change also switches off automatic supply for launch. Consistent
with bomb.
When a manually launched anti-sat hits, it now always destroys the
satellite. This matches what it does when it intercepts
automatically. Before, it only damaged the satellite.
Before, satellites could be disarmed and armed even in orbit. Nukes
on satellites went along into orbit, where they did nothing in
particular.
Nukes on ABMs and SAMs were lost without effect when their missile
intercepted.
The stock game is not affected, because its satellites, ABMs and SAMs
all have zero load.
These were leftovers from Chainsaw, and their only remaining effect
was a flak bonus.
The got replaced except for flak by plane selector stealth under
Chainsaw option STEALTHV, which became mandatory in Empire 2. It is
unclear why STEALTHV didn't cover flak. No planes with these
capabilities have existed in the stock game since Empire 2.
The various bombing functions silently skipped planes not carrying
bombs. This sanity check was wrong: it checked capabilities "tactical
or not cargo" instead of "tactical or bomber", and failed for
non-tactical cargo bombers. No such planes exist in the stock game.
The broken check comes from Chainsaw; it replaced an equally wrong
"not cargo" check.
Because pln_sel() lets only suitable planes go on a bombing run, the
broken sanity check is unnecessary. Drop it.
There are three ways to fly cargo: transport (fly command with a
commodity argument), cargo drops (drop command that isn't a sea mine
drop), and paradrops.
A cargo flight can be either an airlift or an airdrop. Airlifts carry
more cargo than airdrops. A cargo drop or paradrop with a non-VTOL
plane is an airdrop. Anything else is an airlift.
Before, paradrop always behaved like an airdrop, regardless of VTOL,
and drop always like an airlift. This made little sense.
Effect of the change on the stock game: paradrop with tc carries twice
the punch, and np/tr/jt can drop less than they can fly. In
particular, tr can't drop guns anymore, and jt can drop only one
instead of three.
Plane flying commands first select the planes to fly the mission and
their escorts, then equip them. They all fail when no planes to fly
the mission can be equipped.
Unlike bomb and paradrop, commands drop, fly, recon and sweep had an
additional check that made them fail when no planes to fly the mission
could be selected. Because "none selected" implies "none equipped",
the additional check is redundant. Remove it.
While there, break lines in calls of pln_sel() more tastefully.
Before, bomb selected any plane, but planes with zero load could not
be equipped. Cargo planes could be equipped fine, and they flew bombs
to the target, where they silently vanished.
Closes#1388263.
Initially, paradrop capability was implied both by capability cargo
and by capability VTOL. Chainsaw changed para() to require cargo, and
added compile-time option PARAFLAG to additionally require new
capability para. The optional PARAFLAG rule became mandatory in
Empire 2.
Chainsaw left the old tests for "cargo or VTOL" in place. Because
para() checked "cargo and para" first, the old tests for "cargo or
VTOL" always passed, so they had no effect.
Clean them up anyway.
These missions imply the cargo type, just like bombing missions. Use
the implied type instead of cargo type parameter ip there. Parameter
ip is now optional except for missions 't' (transport) and 'd' (drop).
Simplify para() not to pass the optional cargo type. Leave drop()
alone, because always passing the type is simpler there.
pln_arm(), pln_equip(), mission_pln_arm() mission_pln_equip() took a
mission parameter encoding the kind of sortie (strategic bomb,
pinpoint bomb, transport, ...), a flag parameter to further specify
the plane's role, and a parameter ip to specify the load.
The flags argument was always either P_F (intercept), P_F | P_ESC
(escort), or zero (any other role).
With non-zero flags, mission and ip argument were not used in any way.
Use mission 'e' and null load for escorts, and remove flags.
Intercept can still be identified by mission zero.
Also change pln_mobcost() to take a mission parameter instead of
flags, so that pln_arm() and mission_pln_arm() can simply pass on
their mission.
Check the true load instead of the ip parameter. Makes a difference
only when callers pass a bogus ip that isn't actually used. Happens
for escorts, but then the call can only be reached for deities,
because for mortals the transports fail before the escorts.
Don't print hit chance for nuclear warheads, it's always 100%.
Instead, print "Arming nuclear warheads" there. That message is now
printed after interception instead of before.
Before, it took a sector argument, and targeted the lowest-numbered
satellite there. Rather inconvenient when your own satellite masks
one of the enemy's.
Moreover, the command could be abused to find all sectors with
satellites. Now it can "only" be abused to find satellite ids, and
whether they're in range. Still not ideal, but tolerable.