Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameengine): a silenced nuke silo raises no banner and no ai aim

Olcay Seygan2390058b0ac4
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3cb40ff98..b274be80c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1020,7 +1020,7 @@ A third pass went through the generals' powers, promotions and unit abilities.
- Superweapons are a dropdown instead of a tick box. Allow Superweapons is the game as it plays without a rule. Limit Superweapons leaves each player one Particle Cannon, one Nuclear Missile or one Scud Storm at a time. No Superweapons bars them.
- No Superweapons can be picked. The dropdown sits low on the settings page, and its last row hung past the bottom edge of the panel: it drew, but a click on it went to nobody and the list stayed on whatever it said before. Any dropdown row past the edge of its panel takes the click now.
- The USA Superweapon General is the exception to both, because the rule that reads as a handicap to everyone else reads as a deletion to him: three superweapons of his own are what he pays for weaker tanks, weaker infantry and a worse air force with. Under Limit he keeps four of each of his. Under No he keeps one. Play him against a lobby that has banned superweapons and you are playing the army you paid for, not an empty base.
-- No Superweapons leaves China its upgrades. The Nuclear Missile silo is where China buys Uranium Shells, Nuclear Tanks and Neutron Shells, so banning it took them off every China general. Each player may now put up one silo under No, the Superweapon General too, and its missile never launches. Nothing treats it as a superweapon either: no fire button, no shortcut, no countdown on anybody's screen, no announcer telling the enemy one is up, and the doors stay shut. The Particle Cannon and the Scud Storm are still banned. A replay of a No Superweapons match recorded before this, where a silo went up or a missile flew, will not play back the same.
+- No Superweapons leaves China its upgrades. The Nuclear Missile silo is where China buys Uranium Shells, Nuclear Tanks and Neutron Shells, so banning it took them off every China general. Each player may now put up one silo under No, the Superweapon General too, and its missile never launches. Nothing treats it as a superweapon either: no fire button, no shortcut, no countdown on anybody's screen, no announcer telling the enemy one is up, and the doors stay shut. The banner under the match clock had not heard: eight Tank Generals under No put up eight red "built" banners, one per silo, and a player read that as eight nukes on the way. A silo whose missile never launches goes up with no banner and no line in the match feed now, and the computer no longer picks nuke targets, up to thirty times a second, for a missile it cannot fire. The Particle Cannon and the Scud Storm are still banned. A replay of a No Superweapons match recorded before this, where a silo went up or a missile flew, will not play back the same.
- The computer pays for every superweapon in base defences. Twelve finished defences let it put up one, twenty-four let it put up two, and with fewer than twelve it waits. It was four until the computer learned to build its guns as a steady mix. Its Particle Cannons, silos and Scud Storms all count against one allowance, and a superweapon counts from the moment its foundation goes down, so it cannot start two on the same twelve towers. A defence counts only once it is finished: a scaffold put down and cancelled unlocks nothing. Tunnel Networks and Propaganda Towers count as defences; the tunnel a Sneak Attack drops for free does not. The silo whose missile never launches, under No Superweapons or Pro Rules, is only there for China's upgrades and goes up without a single tower. Lose its towers and the superweapons it has keep standing, but the next one waits. You are not asked for towers at all: for a human player the lobby's limit and Pro Rules are the whole rule, as they were before the towers rule came in, and the buttons never grey out for want of defences. Campaign and Generals Challenge missions are left as they were. A replay from a build that held humans to the towers too plays out differently if a human's superweapon was turned away in it.
- The tick box was one number for everybody, which is why it could only ever say yes or no. A ticked box in a settings file from an older build reads back as No Superweapons.
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
index fcfb407b9..f273637eb 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
@@ -205,6 +205,8 @@ Bool ProRulesRefuseSpecialPower( const Player *player, SpecialPowerType specialP
// no fire button, no shortcut. Both read game setup only, the same on every machine.
Bool SuperweaponMissileSilenced( SpecialPowerType specialPowerType, Bool proRules, Int superweaponRestriction );
Bool SuperweaponMissileSilencedInMatch( SpecialPowerType specialPowerType );
+// the silo of a missile the one above silences: no banner, no feed line, announced as a building
+Bool SuperweaponSiloSilencedInMatch( const Object *structure );
// Rule 9: no foundation this close to an enemy building, edge to edge. The same 300 world units
// the derrick cluster rules measure with, which is also more than a Patriot or a Stinger Site
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index 9f9f8bdc1..5d757b26d 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -3154,6 +3154,14 @@ Bool SuperweaponMissileSilencedInMatch( SpecialPowerType specialPowerType )
TheGameLogic->getSuperweaponRestriction() );
}
+Bool SuperweaponSiloSilencedInMatch( const Object *structure )
+{
+ return ( structure->hasSpecialPower( SPECIAL_NEUTRON_MISSILE )
+ || structure->hasSpecialPower( NUKE_SPECIAL_NEUTRON_MISSILE )
+ || structure->hasSpecialPower( SUPW_SPECIAL_NEUTRON_MISSILE ) )
+ && SuperweaponMissileSilencedInMatch( SPECIAL_NEUTRON_MISSILE );
+}
+
Bool ProRulesRefuseSpecialPower( const Player *player, SpecialPowerType specialPowerType )
{
return SuperweaponMissileSilencedInMatch( specialPowerType )
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
index 661a2428a..902256e65 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
@@ -355,7 +355,12 @@ Bool SpecialPowerStore::canUseSpecialPower( Object *obj, const SpecialPowerTempl
} // end if
-
+ // a silo silenced by No Superweapons or Pro Rules, or a Pro Rules Carpet Bomb below rank 3, is
+ // refused when fired; saying so here keeps the skirmish script's "special power is ready" false,
+ // or the computer player scores the whole map for a target on every frame the silo is charged
+ if( ProRulesRefuseSpecialPower( obj->getControllingPlayer(), specialPowerTemplate->getSpecialPowerType() ) )
+ return FALSE;
+
// I THINK THIS IS WHERE WE BAIL OUT IF A DIFFERENT CONYARD IS ALREADY CHARGIN THIS SPECIAL RIGHT NOW //LORENZEN
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 9ae50bfd0..aa148890c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -4748,7 +4748,8 @@ void InGameUI::feedSpecialPower( const Object *source, const AsciiString &powerN
//-------------------------------------------------------------------------------------------------
void InGameUI::feedStructure( Object *structure, Bool finished )
{
- const Bool superweapon = structure->isKindOf( KINDOF_FS_SUPERWEAPON );
+ // a silo whose missile can never fire is not news: no feed line and no banner for every player
+ const Bool superweapon = structure->isKindOf( KINDOF_FS_SUPERWEAPON ) && !SuperweaponSiloSilencedInMatch( structure );
if( !superweapon && !structure->isKindOf( KINDOF_FS_ADVANCED_TECH ) )
return;