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.

feat(gameengine): cooperative builders, jamming, swarm powers, unit speed scale

Olcay Seyganc776f64a09b0
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index 2024fee27..d1f46a671 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -642,6 +642,7 @@ GameEngine/Include/GameLogic/Module/ImmortalBody.h
GameEngine/Include/GameLogic/Module/InactiveBody.h
GameEngine/Include/GameLogic/Module/InstantDeathBehavior.h
GameEngine/Include/GameLogic/Module/InternetHackContain.h
+GameEngine/Include/GameLogic/Module/JammerUpdate.h
GameEngine/Include/GameLogic/Module/JetAIUpdate.h
GameEngine/Include/GameLogic/Module/JetSlowDeathBehavior.h
GameEngine/Include/GameLogic/Module/KeepObjectDie.h
@@ -692,6 +693,7 @@ GameEngine/Include/GameLogic/Module/ProneUpdate.h
GameEngine/Include/GameLogic/Module/PropagandaCenterBehavior.h
GameEngine/Include/GameLogic/Module/PropagandaTowerBehavior.h
GameEngine/Include/GameLogic/Module/QueueProductionExitUpdate.h
+GameEngine/Include/GameLogic/Module/RadarJamSpecialPower.h
GameEngine/Include/GameLogic/Module/RadarUpdate.h
GameEngine/Include/GameLogic/Module/RadarUpgrade.h
GameEngine/Include/GameLogic/Module/RadiusDecalUpdate.h
@@ -714,6 +716,7 @@ GameEngine/Include/GameLogic/Module/SabotageSupplyCenterCrateCollide.h
GameEngine/Include/GameLogic/Module/SabotageSupplyDropzoneCrateCollide.h
GameEngine/Include/GameLogic/Module/SalvageCrateCollide.h
GameEngine/Include/GameLogic/Module/ShroudCrateCollide.h
+GameEngine/Include/GameLogic/Module/SightUpgrade.h
GameEngine/Include/GameLogic/Module/SlavedUpdate.h
GameEngine/Include/GameLogic/Module/SlowDeathBehavior.h
GameEngine/Include/GameLogic/Module/SmartBombTargetHomingUpdate.h
@@ -748,6 +751,7 @@ GameEngine/Include/GameLogic/Module/SupplyTruckAIUpdate.h
GameEngine/Include/GameLogic/Module/SupplyWarehouseCreate.h
GameEngine/Include/GameLogic/Module/SupplyWarehouseCripplingBehavior.h
GameEngine/Include/GameLogic/Module/SupplyWarehouseDockUpdate.h
+GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h
GameEngine/Include/GameLogic/Module/TechBuildingBehavior.h
GameEngine/Include/GameLogic/Module/TempWeaponBonusHelper.h
GameEngine/Include/GameLogic/Module/TensileFormationUpdate.h
@@ -1299,9 +1303,11 @@ GameEngine/Source/GameLogic/Object/SpecialPower/DefectorSpecialPower.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/DemoralizeSpecialPower.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/FireWeaponPower.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cpp
+GameEngine/Source/GameLogic/Object/SpecialPower/RadarJamSpecialPower.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/SpecialAbility.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
GameEngine/Source/GameLogic/Object/SpecialPower/SpyVisionSpecialPower.cpp
+GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp
GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/AIUpdate/AssaultTransportAIUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp
@@ -1350,6 +1356,7 @@ GameEngine/Source/GameLogic/Object/Update/HeightDieUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/HelicopterSlowDeathUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/HijackerUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp
+GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/LaserUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/LifetimeUpdate.cpp
GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp
@@ -1402,6 +1409,7 @@ GameEngine/Source/GameLogic/Object/Upgrade/PassengersFireUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/PowerPlantUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/RadarUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/ReplaceObjectUpgrade.cpp
+GameEngine/Source/GameLogic/Object/Upgrade/SightUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/StatusBitsUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/StealthUpgrade.cpp
GameEngine/Source/GameLogic/Object/Upgrade/SubObjectsUpgrade.cpp
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
index fcfb407b9..f19423fc0 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
@@ -525,6 +525,7 @@ public:
void removeRadar( Bool disableProof );///< One less thing produces radar
void disableRadar(); ///< No matter how many radar producers I have, I do not have radar
void enableRadar(); ///< remove the restriction imposed by disableRadar
+ void jamRadarUntil( UnsignedInt frame ); ///< an enemy's electronic blinding: no radar at all, disable proof or not, before this frame
Bool hasRadar() const;///< A positive number of radar producers, plus my radar is not disabled
Bool okToPlayRadarEdgeSound();///< just like it "sounds"
//Battle plans effect the players abilities... so may as well add it here. Also
@@ -943,6 +944,7 @@ private:
Int m_radarCount; ///< # of facilities that have a radar under the players control
Int m_disableProofRadarCount; ///< # of disable proof radars. A disable proof one will be in both refcounts
Bool m_radarDisabled; ///< The radar is disabled regardless of the number of radar objects
+ UnsignedInt m_radarJammedUntilFrame; ///< no radar at all before this logic frame (jamRadarUntil)
Int m_bombardBattlePlans; ///< Number of strategy centers with active bombardment plan
Int m_holdTheLineBattlePlans; ///< Number of strategy centers with active hold the line plan
Int m_searchAndDestroyBattlePlans;///< Number of strategy centers with active search and destroy plan
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Science.h b/GeneralsMD/Code/GameEngine/Include/Common/Science.h
index e2fc55a25..458be0baa 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Science.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Science.h
@@ -65,6 +65,7 @@ private:
ScienceVec m_prereqSciences;
Int m_sciencePurchasePointCost;
Bool m_grantable;
+ AsciiString m_grantedUpgradeName; // a player upgrade the player completes the moment it has this science
ScienceInfo() :
m_science(SCIENCE_INVALID),
@@ -108,6 +109,9 @@ public:
Int getSciencePurchaseCost(ScienceType science) const;
+ /// GrantsUpgrade: the player upgrade that comes with the science, empty when none
+ AsciiString getGrantedUpgradeName(ScienceType science) const;
+
/// does st name prereq among its own prerequisites (one level, not the whole chain)
Bool isDirectPrereq(ScienceType prereq, ScienceType st) const;
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/SpecialPower.h b/GeneralsMD/Code/GameEngine/Include/Common/SpecialPower.h
index 9d5862b57..4e05da944 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/SpecialPower.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/SpecialPower.h
@@ -126,6 +126,7 @@ public:
Real getViewObjectRange( void ) const { return getFO()->m_viewObjectRange; }
Real getRadiusCursorRadius() const { return getFO()->m_radiusCursorRadius; }
Bool isShortcutPower() const { return getFO()->m_shortcutPower; }
+ Bool isFiredByAIWhenReady() const { return getFO()->m_aiFiresWhenReady; }
AcademyClassificationType getAcademyClassificationType() const { return m_academyClassificationType; }
private:
@@ -148,6 +149,7 @@ private:
Bool m_publicTimer; ///< display a countdown timer for this special power for all to see
Bool m_sharedNSync; ///< If true, this is a special that is shared between all of a player's command centers
Bool m_shortcutPower; ///< Is this shortcut power capable of being fired by the side panel?
+ Bool m_aiFiresWhenReady; ///< the skirmish AI fires it on its own (AIPlayer::doReadySpecialPowers); no script names it
static const FieldParse m_specialPowerFieldParse[]; ///< the parse table
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
index 0ce223057..d4c3ed4ca 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/ThingTemplate.h
@@ -436,7 +436,11 @@ public:
Bool acquiresBeyondVision() const { return m_acquiresBeyondVision; }
/// SpotterSight: it keeps its whole ShroudClearingRange however short its weapon is (Object::look)
Bool hasSpotterSight() const { return m_spotterSight; }
-
+ /// CooperativeBuilder: it keeps building a site another builder of its player is already on, and both add progress
+ Bool isCooperativeBuilder() const { return m_cooperativeBuilder; }
+ /// SpeedScale: multiplies the speeds of every locomotor it drives on, which a reskin shares with its source
+ Real getSpeedScale() const { return m_speedScale; }
+
//This one is okay to check directly... because it doesn't get effected by bonuses.
Real getShroudRevealToAllRange() const { return m_shroudRevealToAllRange; }
@@ -750,6 +754,8 @@ private:
Real m_shroudClearingRange; ///< Since So many things got added to "Seeing" functionality, we need to split this part out.
Bool m_acquiresBeyondVision; ///< Turkey's artillery: idle auto-acquire reaches its weapon range through a spotter's eyes
Bool m_spotterSight; ///< Turkey's spotters: sight not capped at half as far again as the weapon reaches
+ Bool m_cooperativeBuilder; ///< Turkey's engineers: two on one site build it twice as fast
+ Real m_speedScale; ///< Turkey's units: their plan's speeds on the American locomotors
Real m_shroudRevealToAllRange; ///< When > zero, the shroud gets revealed to all players.
Real m_placementViewAngle; ///< when placing buildings this will be the angle of the building when "floating" at the mouse
Real m_factoryExitWidth; ///< when placing buildings this will be the width of the reserved exit area on the right side.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
index 41962ab95..58c89a7f8 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h
@@ -325,6 +325,9 @@ public:
*/
Bool isGroundVehicle(const Object* obj) const;
+ /// the owner's SpeedScale: Turkey's reskins drive on the American locomotors at their own pace
+ inline void setSpeedScale(Real scale) { m_speedScale = scale; }
+
/// this is handy for doing things like forcing helicopters to crash realistically: cut their lift.
inline void setMaxLift(Real lift) { m_maxLift = lift; }
inline void setMaxSpeed(Real speed)
@@ -487,6 +490,7 @@ private:
Real m_brakingFactor;
Real m_maxLift;
Real m_maxSpeed;
+ Real m_speedScale; ///< multiplies the template's speeds; 1 unless the owner's template sets SpeedScale
Real m_maxAccel;
Real m_maxBraking;
Real m_maxTurnRate;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h
index ed73635b8..acb2bbcad 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h
@@ -102,6 +102,8 @@ public:
void addLocomotor(const LocomotorTemplate* lt);
+ void setSpeedScale(Real scale); ///< on every locomotor in the set (Locomotor::setSpeedScale)
+
Locomotor* findLocomotor(LocomotorSurfaceTypeMask t);
void xferSelfAndCurLocoPtr(Xfer *xfer, Locomotor** loco);
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JammerUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JammerUpdate.h
new file mode 100644
index 000000000..6f925fb24
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JammerUpdate.h
@@ -0,0 +1,69 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: JammerUpdate.h //////////////////////////////////////////////////////////////////////////
+//
+// Turkey's Koral. Within Radius, enemy drones and spotters see only what is under them, and an
+// enemy guided missile loses its lock and comes down scattered (MissileAIUpdate::projectileNowJammed).
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef __JAMMER_UPDATE_H_
+#define __JAMMER_UPDATE_H_
+
+#include "GameLogic/Module/UpdateModule.h"
+
+//-------------------------------------------------------------------------------------------------
+class JammerUpdateModuleData : public UpdateModuleData
+{
+public:
+
+ Real m_radius;
+ UnsignedInt m_scanFrames;
+
+ JammerUpdateModuleData();
+
+ static void buildFieldParse( MultiIniFieldParse& p );
+};
+
+//-------------------------------------------------------------------------------------------------
+class JammerUpdate : public UpdateModule
+{
+
+ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( JammerUpdate, "JammerUpdate" )
+ MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( JammerUpdate, JammerUpdateModuleData );
+
+public:
+
+ JammerUpdate( Thing *thing, const ModuleData* moduleData );
+ // virtual destructor prototype provided by memory pool declaration
+
+ virtual UpdateSleepTime update();
+ virtual void onDelete( void );
+ virtual DisabledMaskType getDisabledTypesToProcess() const { return DISABLEDMASK_ALL; }
+
+private:
+
+ void releaseAll();
+
+ std::vector<ObjectID> m_jammed; ///< whose sight this one is holding down, in the order it took them
+};
+
+#endif // __JAMMER_UPDATE_H_
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarJamSpecialPower.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarJamSpecialPower.h
new file mode 100644
index 000000000..8dd1c0bc1
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/RadarJamSpecialPower.h
@@ -0,0 +1,65 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: RadarJamSpecialPower.h //////////////////////////////////////////////////////////////////
+//
+// Turkey's electronic blinding: every enemy player with a structure within Radius of the click
+// loses its radar for Duration, disable-proof radar included.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef __RADAR_JAM_SPECIAL_POWER_H_
+#define __RADAR_JAM_SPECIAL_POWER_H_
+
+#include "GameLogic/Module/SpecialPowerModule.h"
+
+class FXList;
+
+//-------------------------------------------------------------------------------------------------
+class RadarJamSpecialPowerModuleData : public SpecialPowerModuleData
+{
+public:
+
+ RadarJamSpecialPowerModuleData( void );
+
+ static void buildFieldParse( MultiIniFieldParse& p );
+
+ Real m_radius;
+ UnsignedInt m_durationFrames;
+ const FXList *m_fx;
+};
+
+//-------------------------------------------------------------------------------------------------
+class RadarJamSpecialPower : public SpecialPowerModule
+{
+
+ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( RadarJamSpecialPower, "RadarJamSpecialPower" )
+ MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( RadarJamSpecialPower, RadarJamSpecialPowerModuleData )
+
+public:
+
+ RadarJamSpecialPower( Thing *thing, const ModuleData *moduleData );
+ // virtual destructor provided by memory pool object
+
+ virtual void doSpecialPowerAtObject( Object *obj, UnsignedInt commandOptions );
+ virtual void doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions );
+};
+
+#endif // end __RADAR_JAM_SPECIAL_POWER_H_
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SightUpgrade.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SightUpgrade.h
new file mode 100644
index 000000000..af09a9db7
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SightUpgrade.h
@@ -0,0 +1,62 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: SightUpgrade.h //////////////////////////////////////////////////////////////////////////
+//
+// Turkey's thermal sights: the upgrade sets VisionRange and ShroudClearingRange, and with
+// EnablesStealthDetector switches on a StealthDetectorUpdate the unit carries InitiallyDisabled.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef __SIGHT_UPGRADE_H_
+#define __SIGHT_UPGRADE_H_
+
+#include "GameLogic/Module/UpgradeModule.h"
+
+//-------------------------------------------------------------------------------------------------
+class SightUpgradeModuleData : public UpgradeModuleData
+{
+public:
+ SightUpgradeModuleData( void );
+ static void buildFieldParse( MultiIniFieldParse& p );
+
+ Real m_visionRange;
+ Real m_shroudClearingRange;
+ Bool m_enablesStealthDetector;
+};
+
+//-------------------------------------------------------------------------------------------------
+class SightUpgrade : public UpgradeModule
+{
+
+ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( SightUpgrade, "SightUpgrade" )
+ MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( SightUpgrade, SightUpgradeModuleData );
+
+public:
+
+ SightUpgrade( Thing *thing, const ModuleData* moduleData );
+ // virtual destructor prototype defined by MemoryPoolObject
+
+protected:
+ virtual void upgradeImplementation( );
+ virtual Bool isSubObjectsUpgrade() { return false; }
+};
+
+#endif // __SIGHT_UPGRADE_H_
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h
new file mode 100644
index 000000000..a755cb805
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h
@@ -0,0 +1,67 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: SwarmStrikeSpecialPower.h ///////////////////////////////////////////////////////////////
+//
+// Turkey's loitering munitions: within Radius of the click, the TargetCount most expensive enemies
+// on the ground each take one Weapon shot, and TargetFX plays on each of them.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#pragma once
+
+#ifndef __SWARM_STRIKE_SPECIAL_POWER_H_
+#define __SWARM_STRIKE_SPECIAL_POWER_H_
+
+#include "GameLogic/Module/SpecialPowerModule.h"
+
+class FXList;
+class WeaponTemplate;
+
+//-------------------------------------------------------------------------------------------------
+class SwarmStrikeSpecialPowerModuleData : public SpecialPowerModuleData
+{
+public:
+
+ SwarmStrikeSpecialPowerModuleData( void );
+
+ static void buildFieldParse( MultiIniFieldParse& p );
+
+ Real m_radius;
+ Int m_targetCount;
+ const WeaponTemplate *m_weapon;
+ const FXList *m_targetFX;
+};
+
+//-------------------------------------------------------------------------------------------------
+class SwarmStrikeSpecialPower : public SpecialPowerModule
+{
+
+ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( SwarmStrikeSpecialPower, "SwarmStrikeSpecialPower" )
+ MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( SwarmStrikeSpecialPower, SwarmStrikeSpecialPowerModuleData )
+
+public:
+
+ SwarmStrikeSpecialPower( Thing *thing, const ModuleData *moduleData );
+ // virtual destructor provided by memory pool object
+
+ virtual void doSpecialPowerAtObject( Object *obj, UnsignedInt commandOptions );
+ virtual void doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions );
+};
+
+#endif // end __SWARM_STRIKE_SPECIAL_POWER_H_
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
index 43b5a03f0..ebb4cc5a0 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h
@@ -485,6 +485,9 @@ public:
Real getOwnShroudClearingRange() const { return m_shroudClearingRange; } ///< the range set on us, before a scaffold's zero; what a scalar multiplies
void setShroudClearingRange( Real newShroudClearingRange ); ///< Access to setting someone's clear shroud distance
void setVisionSpied(Bool setting, Int byWhom);///< Change who is looking through our eyes
+ void addSightJammer(); ///< an enemy jammer's field took it in: its sight shrinks until the last one lets go
+ void removeSightJammer(); ///< a jammer's field let go of it
+ Bool isSightJammed() const { return m_sightJammerCount > 0; }
// Both of these calls are intended to only be used by TerrainLogic, specifically setActiveBoundary()
void friend_prepareForMapBoundaryAdjust(void);
@@ -788,6 +791,7 @@ private:
Real m_visionRange; ///< looking range
Real m_shroudClearingRange; ///< looking range for shroud ONLY
Real m_shroudRange; ///< like looking range, this is how far I shroud others' looks
+ Int m_sightJammerCount; ///< enemy jammers in whose field this stands; above zero its sight shrinks to a few feet
DisabledMaskType m_disabledMask;
UnsignedInt m_disabledTillFrame[ DISABLED_COUNT ];
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
index 5cb019baa..035956c20 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Weapon.h
@@ -411,6 +411,7 @@ public:
inline Real getShockWaveTaperOff() const { return m_shockWaveTaperOff; }
inline Real getRequestAssistRange() const {return m_requestAssistRange;}
+ inline Bool seeksMostValuable() const { return m_seeksMostValuable; }
inline AsciiString getName() const { return m_name; }
inline AsciiString getProjectileStreamName() const { return m_projectileStreamName; }
inline AsciiString getLaserName() const { return m_laserName; }
@@ -511,6 +512,7 @@ private:
Real m_aimDelta; ///< when aiming, consider yourself "aimed" if you are within +/- this much of an angle
Real m_scatterRadius; ///< Radius of area actual fire point will be in, default is zero for no deviation
Real m_blindScatterRadius; ///< added to the scatter when the firer's player cannot see where the shot is going
+ Bool m_seeksMostValuable; ///< fired at a unit, it goes for the most expensive enemy within its range instead
Real m_scatterTargetScalar; ///< Radius of area covered by the coordinates in the scatterTarget table
std::vector<Coord2D> m_scatterTargets; ///< instead of pure randomness, this is the list of places I will randomly choose from to attack
DamageType m_damageType; ///< damage type enum
@@ -922,5 +924,10 @@ extern Real Weapon_elevationRangeBonus( Real range, Real heightAboveTarget );
///< range as source reaches something standing at targetZ; an aircraft gets no high ground
extern Real Weapon_elevatedRange( const Object *source, Real range, Real targetZ );
+///< source's enemies on the ground within radius of center, the most expensive first and the lower
+///< ObjectID first among equals, at most maxCount of them; the order is the same on every machine
+extern void Weapon_findMostValuableEnemies( const Object *source, const Coord3D *center, Real radius,
+ Int maxCount, std::vector<Object*>& found );
+
#endif // __WEAPON_H_
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index 68ca4ae47..93481c2a5 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -363,6 +363,7 @@ Player::Player( Int playerIndex )
m_radarCount = 0;
m_disableProofRadarCount = 0;
m_radarDisabled = FALSE;
+ m_radarJammedUntilFrame = 0;
m_bombardBattlePlans = 0;
m_holdTheLineBattlePlans = 0;
m_searchAndDestroyBattlePlans = 0;
@@ -415,6 +416,7 @@ void Player::init(const PlayerTemplate* pt)
m_radarCount = 0;
m_disableProofRadarCount = 0;
m_radarDisabled = FALSE;
+ m_radarJammedUntilFrame = 0;
m_bombardBattlePlans = 0;
m_holdTheLineBattlePlans = 0;
@@ -2736,9 +2738,19 @@ Bool Player::addScience(ScienceType science)
}
+ // a science can carry a player upgrade (Turkey's fuel resupply): it lands on every unit the
+ // player has now and every unit it builds later, the same as a bought one
+ AsciiString grantedUpgradeName = TheScienceStore->getGrantedUpgradeName(science);
+ if (!grantedUpgradeName.isEmpty())
+ {
+ const UpgradeTemplate *grantedUpgrade = TheUpgradeCenter->findUpgrade(grantedUpgradeName);
+ DEBUG_ASSERTCRASH(grantedUpgrade, ("science %s grants unknown upgrade %s\n", TheScienceStore->getInternalNameForScience(science).str(), grantedUpgradeName.str()));
+ addUpgrade(grantedUpgrade, UPGRADE_STATUS_COMPLETE);
+ }
+
// notify the script engine
TheScriptEngine->notifyOfAcquiredScience(getPlayerIndex(), science);
-
+
return true;
}
@@ -3820,10 +3832,28 @@ void Player::enableRadar()
}
}
+//-------------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------------
+void Player::jamRadarUntil( UnsignedInt frame )
+{
+ Bool hadRadar = hasRadar();
+ m_radarJammedUntilFrame = max( m_radarJammedUntilFrame, frame );
+
+ if( hadRadar && !hasRadar() && okToPlayRadarEdgeSound() )
+ {
+ AudioEventRTS soundToPlay = TheAudio->getMiscAudio()->m_radarOfflineSound;
+ soundToPlay.setPlayerIndex(getPlayerIndex());
+ TheAudio->addAudioEvent(&soundToPlay);
+ }
+}
+
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
Bool Player::hasRadar() const
{
+ if( TheGameLogic->getFrame() < m_radarJammedUntilFrame )
+ return FALSE;
+
if( m_radarDisabled && (m_disableProofRadarCount == 0) )
return FALSE;// Nope, no matter how many you have, if I say no, you don't have it
@@ -4641,13 +4671,14 @@ void Player::crc( Xfer *xfer )
* 9: The shift queue, m_orderQueue (fork).
* 10: The vision spies (fork).
* 11: m_attackedFrame, which the skirmish AI's base-under-attack test reads (fork).
+ * 12: m_radarJammedUntilFrame, an enemy's electronic blinding (fork).
*/
// ------------------------------------------------------------------------------------------------
void Player::xfer( Xfer *xfer )
{
// version
- const XferVersion currentVersion = 11;
+ const XferVersion currentVersion = 12;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -5211,6 +5242,11 @@ void Player::xfer( Xfer *xfer )
else
m_attackedFrame = 0;
+ if( version >= 12 )
+ xfer->xferUnsignedInt( &m_radarJammedUntilFrame );
+ else
+ m_radarJammedUntilFrame = 0;
+
} // end xfer
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Science.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Science.cpp
index 9cc11a4f8..d93b29dcb 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Science.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Science.cpp
@@ -178,6 +178,7 @@ const ScienceInfo* ScienceStore::findScienceInfo(ScienceType st) const
{ "IsGrantable", INI::parseBool, NULL, offsetof( ScienceInfo, m_grantable ) },
{ "DisplayName", INI::parseAndTranslateLabel, NULL, offsetof( ScienceInfo, m_name) },
{ "Description", INI::parseAndTranslateLabel, NULL, offsetof( ScienceInfo, m_description) },
+ { "GrantsUpgrade", INI::parseAsciiString, NULL, offsetof( ScienceInfo, m_grantedUpgradeName) },
{ 0, 0, 0, 0 }
};
@@ -250,6 +251,13 @@ Int ScienceStore::getSciencePurchaseCost(ScienceType st) const
}
}
+//-----------------------------------------------------------------------------
+AsciiString ScienceStore::getGrantedUpgradeName(ScienceType st) const
+{
+ const ScienceInfo* si = findScienceInfo(st);
+ return si ? si->m_grantedUpgradeName : AsciiString::TheEmptyString;
+}
+
//-----------------------------------------------------------------------------
/** Does st ask for prereq directly - the way Artillery Barrage 2 asks for Artillery Barrage 1? */
Bool ScienceStore::isDirectPrereq(ScienceType prereq, ScienceType st) const
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
index 661a2428a..5881f78ec 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/SpecialPower.cpp
@@ -210,6 +210,7 @@ void SpecialPowerStore::parseSpecialPowerDefinition( INI *ini )
{ "ViewObjectRange", INI::parseReal, NULL, offsetof( SpecialPowerTemplate, m_viewObjectRange ) },
{ "RadiusCursorRadius", INI::parseReal, NULL, offsetof( SpecialPowerTemplate, m_radiusCursorRadius ) },
{ "ShortcutPower", INI::parseBool, NULL, offsetof( SpecialPowerTemplate, m_shortcutPower ) },
+ { "AIFiresWhenReady", INI::parseBool, NULL, offsetof( SpecialPowerTemplate, m_aiFiresWhenReady ) },
{ "AcademyClassify", INI::parseIndexList, TheAcademyClassificationTypeNames, offsetof( SpecialPowerTemplate, m_academyClassificationType ) },
{ NULL, NULL, NULL, 0 } // keep this last
@@ -230,6 +231,7 @@ SpecialPowerTemplate::SpecialPowerTemplate()
m_viewObjectRange = 0;
m_radiusCursorRadius = 0;
m_shortcutPower = FALSE;
+ m_aiFiresWhenReady = FALSE;
} // end SpecialPowerTemplate
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/MemoryInit.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/MemoryInit.cpp
index a81ffc482..19c163a46 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/MemoryInit.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/MemoryInit.cpp
@@ -352,6 +352,7 @@ static PoolSizeRec sizes[] =
{ "WaveGuideUpdate", 16, 16 },
{ "WeaponBonusUpgrade", 512, 128 },
{ "WeaponSetUpgrade", 512, 128 },
+ { "SightUpgrade", 32, 32 },
{ "ArmorUpgrade", 512, 128 },
{ "WorkerAIUpdate", 128, 128 },
{ "WorkerStateMachine", 128, 128 },
@@ -390,6 +391,8 @@ static PoolSizeRec sizes[] =
{ "DemoralizeSpecialPower", 16, 16, },
#endif
{ "CashHackSpecialPower", 32, 32 },
+ { "SwarmStrikeSpecialPower", 32, 32 },
+ { "RadarJamSpecialPower", 32, 32 },
{ "CommandSetUpgrade", 32, 32 },
{ "PassengersFireUpgrade", 32, 32 },
{ "GrantUpgradeCreate", 256, 32 },
@@ -398,6 +401,7 @@ static PoolSizeRec sizes[] =
{ "ModelConditionUpgrade", 32, 32 },
{ "SpyVisionSpecialPower", 256, 32 },
{ "StealthDetectorUpdate", 256, 32 },
+ { "JammerUpdate", 32, 32 },
{ "StealthUpdate", 512, 128 },
{ "StealthUpgrade", 256, 32 },
{ "StatusBitsUpgrade", 128, 128 },
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ModuleFactory.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ModuleFactory.cpp
index f167561f7..ced33c31e 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ModuleFactory.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ModuleFactory.cpp
@@ -170,6 +170,7 @@
#include "GameLogic/Module/SpecialAbilityUpdate.h"
#include "GameLogic/Module/MissileLauncherBuildingUpdate.h"
#include "GameLogic/Module/StealthDetectorUpdate.h"
+#include "GameLogic/Module/JammerUpdate.h"
#include "GameLogic/Module/StealthUpdate.h"
#include "GameLogic/Module/SpawnPointProductionExitUpdate.h"
#include "GameLogic/Module/SpawnBehavior.h"
@@ -211,6 +212,7 @@
#include "GameLogic/Module/UnpauseSpecialPowerUpgrade.h"
#include "GameLogic/Module/WeaponBonusUpgrade.h"
#include "GameLogic/Module/WeaponSetUpgrade.h"
+#include "GameLogic/Module/SightUpgrade.h"
#include "GameLogic/Module/CostModifierUpgrade.h"
#include "GameLogic/Module/ExperienceScalarUpgrade.h"
#include "GameLogic/Module/MaxHealthUpgrade.h"
@@ -263,6 +265,8 @@
// special power modules
#include "GameLogic/Module/CashHackSpecialPower.h"
+#include "GameLogic/Module/SwarmStrikeSpecialPower.h"
+#include "GameLogic/Module/RadarJamSpecialPower.h"
#include "GameLogic/Module/DefectorSpecialPower.h"
#ifdef ALLOW_DEMORALIZE
#include "GameLogic/Module/DemoralizeSpecialPower.h"
@@ -393,6 +397,7 @@ void ModuleFactory::init( void )
addModule( AutoFindHealingUpdate );
addModule( BaseRegenerateUpdate );
addModule( StealthDetectorUpdate );
+ addModule( JammerUpdate );
addModule( StealthUpdate );
addModule( DeletionUpdate );
addModule( SmartBombTargetHomingUpdate );
@@ -494,6 +499,7 @@ void ModuleFactory::init( void )
addModule( UnpauseSpecialPowerUpgrade );
addModule( WeaponBonusUpgrade );
addModule( WeaponSetUpgrade );
+ addModule( SightUpgrade );
addModule( ExperienceScalarUpgrade );
addModule( MaxHealthUpgrade );
@@ -545,6 +551,8 @@ void ModuleFactory::init( void )
// special power modules
addModule( CashHackSpecialPower );
+ addModule( SwarmStrikeSpecialPower );
+ addModule( RadarJamSpecialPower );
addModule( DefectorSpecialPower );
#ifdef ALLOW_DEMORALIZE
addModule( DemoralizeSpecialPower );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
index 2ac56974c..3ef6231f3 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp
@@ -128,6 +128,8 @@ const FieldParse ThingTemplate::s_objectFieldParseTable[] =
{ "ShroudClearingRange", INI::parseReal, NULL, offsetof( ThingTemplate, m_shroudClearingRange ) },
{ "AcquiresBeyondVision", INI::parseBool, NULL, offsetof( ThingTemplate, m_acquiresBeyondVision ) },
{ "SpotterSight", INI::parseBool, NULL, offsetof( ThingTemplate, m_spotterSight ) },
+ { "CooperativeBuilder", INI::parseBool, NULL, offsetof( ThingTemplate, m_cooperativeBuilder ) },
+ { "SpeedScale", INI::parseReal, NULL, offsetof( ThingTemplate, m_speedScale ) },
{ "ShroudRevealToAllRange", INI::parseReal, NULL, offsetof( ThingTemplate, m_shroudRevealToAllRange ) },
{ "PlacementViewAngle", INI::parseAngleReal, NULL, offsetof( ThingTemplate, m_placementViewAngle ) },
@@ -1089,6 +1091,8 @@ ThingTemplate::ThingTemplate() :
m_shroudClearingRange = -1.0f;
m_acquiresBeyondVision = FALSE;
m_spotterSight = FALSE;
+ m_cooperativeBuilder = FALSE;
+ m_speedScale = 1.0f;
m_shroudRevealToAllRange = -1.0f;
m_buildCost = 0;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
index 50338e5d4..a5b8064eb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp
@@ -778,6 +778,7 @@ Locomotor::Locomotor(const LocomotorTemplate* tmpl)
m_brakingFactor = 1.0f;
m_maxLift = BIGNUM;
m_maxSpeed = BIGNUM;
+ m_speedScale = 1.0f;
m_maxAccel = BIGNUM;
m_maxBraking = BIGNUM;
m_maxTurnRate = BIGNUM;
@@ -816,6 +817,7 @@ Locomotor::Locomotor(const Locomotor& that)
m_brakingFactor = that.m_brakingFactor;
m_maxLift = that.m_maxLift;
m_maxSpeed = that.m_maxSpeed;
+ m_speedScale = that.m_speedScale;
m_maxAccel = that.m_maxAccel;
m_maxBraking = that.m_maxBraking;
m_maxTurnRate = that.m_maxTurnRate;
@@ -845,6 +847,7 @@ Locomotor& Locomotor::operator=(const Locomotor& that)
m_brakingFactor = that.m_brakingFactor;
m_maxLift = that.m_maxLift;
m_maxSpeed = that.m_maxSpeed;
+ m_speedScale = that.m_speedScale;
m_maxAccel = that.m_maxAccel;
m_maxBraking = that.m_maxBraking;
m_maxTurnRate = that.m_maxTurnRate;
@@ -884,12 +887,13 @@ void Locomotor::crc( Xfer *xfer )
* 1: Initial version
* 3: m_sineDescentDistance
* 4: m_yawRate, m_driveAccelX, m_driveAccelY
- * 5: m_driveSpeed, m_driveFrame */
+ * 5: m_driveSpeed, m_driveFrame
+ * 6: m_speedScale */
// ------------------------------------------------------------------------------------------------
void Locomotor::xfer( Xfer *xfer )
{
// version
- const XferVersion currentVersion = 5;
+ const XferVersion currentVersion = 6;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -930,6 +934,9 @@ void Locomotor::xfer( Xfer *xfer )
xfer->xferUnsignedInt(&m_driveFrame);
}
+ if (version >= 6)
+ xfer->xferReal(&m_speedScale);
+
} // end xfer
// ------------------------------------------------------------------------------------------------
@@ -956,6 +963,7 @@ Real Locomotor::getMaxSpeedForCondition(BodyDamageType condition) const
speed = m_template->m_maxSpeed;
else
speed = m_template->m_maxSpeedDamaged;
+ speed *= m_speedScale;
if (speed > m_maxSpeed)
speed = m_maxSpeed;
@@ -3683,6 +3691,13 @@ void LocomotorSet::clear()
m_downhillOnly = FALSE;
}
+//-------------------------------------------------------------------------------------------------
+void LocomotorSet::setSpeedScale(Real scale)
+{
+ for (int i = 0; i < m_locomotors.size(); ++i)
+ m_locomotors[i]->setSpeedScale(scale);
+}
+
//-------------------------------------------------------------------------------------------------
void LocomotorSet::addLocomotor(const LocomotorTemplate* lt)
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index fce48c071..198636ae7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -305,7 +305,8 @@ Object::Object( const ThingTemplate *tt, const ObjectStatusMaskType &objectStatu
if( m_shroudClearingRange == -1.0f )
m_shroudClearingRange = m_visionRange;// Backwards compatible, and perfectly logical default to assign
m_shroudRange = 0.0f;
-
+ m_sightJammerCount = 0;
+
m_singleUseCommandUsed = false;
// assign unique object id
@@ -4424,13 +4425,14 @@ void Object::crc( Xfer *xfer )
* 9: Extra sighting for reveal to all with different range units
* 10: each player's memory of it while it is out of their sight
* 11: the cached angle, which the matrix does not give back bit for bit
+ * 12: how many enemy jammers are cutting its sight
*/
//-------------------------------------------------------------------------------------------------
void Object::xfer( Xfer *xfer )
{
// version
- const XferVersion currentVersion = 11;
+ const XferVersion currentVersion = 12;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -4873,6 +4875,9 @@ void Object::xfer( Xfer *xfer )
else
m_isReceivingDifficultyBonus = FALSE;
+ if( version >= 12 )
+ xfer->xferInt( &m_sightJammerCount );
+
} // end xfer
//-------------------------------------------------------------------------------------------------
@@ -5389,7 +5394,26 @@ void Object::removeThreat()
m_partitionLastThreat->reset();
}
+//-------------------------------------------------------------------------------------------------
+/** A jammed drone or spotter still sees what is under its feet, and nothing a battery could use. */
+//-------------------------------------------------------------------------------------------------
+static const Real JAMMED_SHROUD_CLEARING_RANGE = 30.0f;
+void Object::addSightJammer()
+{
+ ++m_sightJammerCount;
+ if( m_sightJammerCount == 1 )
+ handleShroud();
+}
+
+//-------------------------------------------------------------------------------------------------
+void Object::removeSightJammer()
+{
+ DEBUG_ASSERTCRASH( m_sightJammerCount > 0, ("removeSightJammer on '%s' with no jammer on it", getTemplate()->getName().str()) );
+ --m_sightJammerCount;
+ if( m_sightJammerCount == 0 )
+ handleShroud();
+}
//-------------------------------------------------------------------------------------------------
void Object::look()
@@ -5429,6 +5453,8 @@ void Object::look()
Real shroudClearingRange = getShroudClearingRange();
if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) && !getTemplate()->hasSpotterSight() )
shroudClearingRange = Object_armedShroudClearingRange( shroudClearingRange, getLargestWeaponRange() );
+ if( isSightJammed() )
+ shroudClearingRange = min( shroudClearingRange, JAMMED_SHROUD_CLEARING_RANGE );
if( shroudClearingRange > 0.0f )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/RadarJamSpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/RadarJamSpecialPower.cpp
new file mode 100644
index 000000000..85d1e817d
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/RadarJamSpecialPower.cpp
@@ -0,0 +1,132 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: RadarJamSpecialPower.cpp ////////////////////////////////////////////////////////////////
+//
+// Radar belongs to a player, not to a place, so "blind a part of the map" reads as: the players
+// whose buildings stand in that part go without radar for a while.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include "Common/Player.h"
+#include "Common/PlayerList.h"
+#include "Common/Xfer.h"
+#include "GameClient/FXList.h"
+#include "GameLogic/GameLogic.h"
+#include "GameLogic/Object.h"
+#include "GameLogic/PartitionManager.h"
+#include "GameLogic/Module/RadarJamSpecialPower.h"
+
+// ------------------------------------------------------------------------------------------------
+RadarJamSpecialPowerModuleData::RadarJamSpecialPowerModuleData( void )
+{
+ m_radius = 0.0f;
+ m_durationFrames = 0;
+ m_fx = NULL;
+}
+
+// ------------------------------------------------------------------------------------------------
+/*static*/ void RadarJamSpecialPowerModuleData::buildFieldParse( MultiIniFieldParse& p )
+{
+ SpecialPowerModuleData::buildFieldParse( p );
+
+ static const FieldParse dataFieldParse[] =
+ {
+ { "Radius", INI::parseReal, NULL, offsetof( RadarJamSpecialPowerModuleData, m_radius ) },
+ { "Duration", INI::parseDurationUnsignedInt, NULL, offsetof( RadarJamSpecialPowerModuleData, m_durationFrames ) },
+ { "FX", INI::parseFXList, NULL, offsetof( RadarJamSpecialPowerModuleData, m_fx ) },
+ { 0, 0, 0, 0 }
+ };
+ p.add( dataFieldParse );
+}
+
+// ------------------------------------------------------------------------------------------------
+RadarJamSpecialPower::RadarJamSpecialPower( Thing *thing, const ModuleData *moduleData )
+ : SpecialPowerModule( thing, moduleData )
+{
+}
+
+// ------------------------------------------------------------------------------------------------
+RadarJamSpecialPower::~RadarJamSpecialPower( void )
+{
+}
+
+// ------------------------------------------------------------------------------------------------
+void RadarJamSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions )
+{
+ if( getObject()->isDisabled() )
+ return;
+
+ SpecialPowerModule::doSpecialPowerAtLocation( loc, angle, commandOptions );
+
+ const RadarJamSpecialPowerModuleData *data = getRadarJamSpecialPowerModuleData();
+ PartitionFilterRelationship filterEnemies( getObject(), PartitionFilterRelationship::ALLOW_ENEMIES );
+ PartitionFilterAcceptByKindOf filterStructures( MAKE_KINDOF_MASK( KINDOF_STRUCTURE ), KINDOFMASK_NONE );
+ PartitionFilterAlive filterAlive;
+ PartitionFilter *filters[] = { &filterEnemies, &filterStructures, &filterAlive, NULL };
+ ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( loc, data->m_radius, FROM_CENTER_2D, filters );
+ MemoryPoolObjectHolder hold( iter );
+
+ UnsignedInt jammedUntil = TheGameLogic->getFrame() + data->m_durationFrames;
+ for( Object *obj = iter->first(); obj; obj = iter->next() )
+ {
+ Player *victim = obj->getControllingPlayer();
+ if( victim->hasRadar() )
+ DEBUG_LOG(( "RADARJAM frame %d player %d loses radar until %d\n", TheGameLogic->getFrame(), victim->getPlayerIndex(), jammedUntil ));
+ victim->jamRadarUntil( jammedUntil );
+ }
+
+ FXList::doFXPos( data->m_fx, loc );
+}
+
+// ------------------------------------------------------------------------------------------------
+void RadarJamSpecialPower::doSpecialPowerAtObject( Object *obj, UnsignedInt commandOptions )
+{
+ if( getObject()->isDisabled() )
+ return;
+
+ doSpecialPowerAtLocation( obj->getPosition(), INVALID_ANGLE, commandOptions );
+}
+
+// ------------------------------------------------------------------------------------------------
+void RadarJamSpecialPower::crc( Xfer *xfer )
+{
+ SpecialPowerModule::crc( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+/** Xfer method
+ * Version Info:
+ * 1: Initial version */
+// ------------------------------------------------------------------------------------------------
+void RadarJamSpecialPower::xfer( Xfer *xfer )
+{
+ XferVersion currentVersion = 1;
+ XferVersion version = currentVersion;
+ xfer->xferVersion( &version, currentVersion );
+
+ SpecialPowerModule::xfer( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+void RadarJamSpecialPower::loadPostProcess( void )
+{
+ SpecialPowerModule::loadPostProcess();
+}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp
new file mode 100644
index 000000000..a171edc0a
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp
@@ -0,0 +1,124 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: SwarmStrikeSpecialPower.cpp /////////////////////////////////////////////////////////////
+//
+// Turkey's loitering munitions. A nuke burns one spot; this spends one munition on each of the
+// most expensive targets in a wide circle, so a spread-out army hurts more than a packed base.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include "Common/ThingTemplate.h"
+#include "Common/Xfer.h"
+#include "GameClient/FXList.h"
+#include "GameLogic/Object.h"
+#include "GameLogic/Weapon.h"
+#include "GameLogic/Module/SwarmStrikeSpecialPower.h"
+
+// ------------------------------------------------------------------------------------------------
+SwarmStrikeSpecialPowerModuleData::SwarmStrikeSpecialPowerModuleData( void )
+{
+ m_radius = 0.0f;
+ m_targetCount = 1;
+ m_weapon = NULL;
+ m_targetFX = NULL;
+}
+
+// ------------------------------------------------------------------------------------------------
+/*static*/ void SwarmStrikeSpecialPowerModuleData::buildFieldParse( MultiIniFieldParse& p )
+{
+ SpecialPowerModuleData::buildFieldParse( p );
+
+ static const FieldParse dataFieldParse[] =
+ {
+ { "Radius", INI::parseReal, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_radius ) },
+ { "TargetCount", INI::parseInt, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_targetCount ) },
+ { "Weapon", INI::parseWeaponTemplate, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_weapon ) },
+ { "TargetFX", INI::parseFXList, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_targetFX ) },
+ { 0, 0, 0, 0 }
+ };
+ p.add( dataFieldParse );
+}
+
+// ------------------------------------------------------------------------------------------------
+SwarmStrikeSpecialPower::SwarmStrikeSpecialPower( Thing *thing, const ModuleData *moduleData )
+ : SpecialPowerModule( thing, moduleData )
+{
+}
+
+// ------------------------------------------------------------------------------------------------
+SwarmStrikeSpecialPower::~SwarmStrikeSpecialPower( void )
+{
+}
+
+// ------------------------------------------------------------------------------------------------
+void SwarmStrikeSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions )
+{
+ if( getObject()->isDisabled() )
+ return;
+
+ SpecialPowerModule::doSpecialPowerAtLocation( loc, angle, commandOptions );
+
+ const SwarmStrikeSpecialPowerModuleData *data = getSwarmStrikeSpecialPowerModuleData();
+ std::vector<Object*> targets;
+ Weapon_findMostValuableEnemies( getObject(), loc, data->m_radius, data->m_targetCount, targets );
+
+ for( std::vector<Object*>::iterator it = targets.begin(); it != targets.end(); ++it )
+ {
+ DEBUG_LOG(( "SWARM '%s' picks '%s' %d\n", getPowerName().str(), (*it)->getTemplate()->getName().str(), (*it)->getID() ));
+ FXList::doFXPos( data->m_targetFX, (*it)->getPosition() );
+ TheWeaponStore->createAndFireTempWeapon( data->m_weapon, getObject(), *it );
+ }
+}
+
+// ------------------------------------------------------------------------------------------------
+void SwarmStrikeSpecialPower::doSpecialPowerAtObject( Object *obj, UnsignedInt commandOptions )
+{
+ if( getObject()->isDisabled() )
+ return;
+
+ doSpecialPowerAtLocation( obj->getPosition(), INVALID_ANGLE, commandOptions );
+}
+
+// ------------------------------------------------------------------------------------------------
+void SwarmStrikeSpecialPower::crc( Xfer *xfer )
+{
+ SpecialPowerModule::crc( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+/** Xfer method
+ * Version Info:
+ * 1: Initial version */
+// ------------------------------------------------------------------------------------------------
+void SwarmStrikeSpecialPower::xfer( Xfer *xfer )
+{
+ XferVersion currentVersion = 1;
+ XferVersion version = currentVersion;
+ xfer->xferVersion( &version, currentVersion );
+
+ SpecialPowerModule::xfer( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+void SwarmStrikeSpecialPower::loadPostProcess( void )
+{
+ SpecialPowerModule::loadPostProcess();
+}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 3216c0d6d..0aef65bf2 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -1040,6 +1040,7 @@ Bool AIUpdateInterface::chooseLocomotorSetExplicit(LocomotorSetType wst)
if (lt)
m_locomotorSet.addLocomotor(lt);
}
+ m_locomotorSet.setSpeedScale(obj->getTemplate()->getSpeedScale());
m_curLocomotorSet = wst;
return TRUE;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
index 4abc17a57..3b1db5300 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp
@@ -379,7 +379,10 @@ StateReturnType DozerActionMoveToActionPosState::update( void )
// First will register, and idle for a frame, second will see first as not active and say yes
// Next frame, first will start the build task, without reasking validity
// Infinite number of workers can be told to build something with just two in progress buildings
- if( (m_task == DOZER_TASK_BUILD) && goalObject && (goalObject->getBuilderID() != dozer->getID()) )
+ // A cooperative builder (Turkey's engineers) is meant to double up: each one on the site adds its
+ // own share of progress every frame, so two of them finish it in half the time.
+ if( (m_task == DOZER_TASK_BUILD) && goalObject && (goalObject->getBuilderID() != dozer->getID()) &&
+ !dozer->getTemplate()->isCooperativeBuilder() )
{
// Geebus. Returning failure is ignored, so you have to explicitly make the ai stop trying to restart the machine
if ( ai )
@@ -548,6 +551,16 @@ StateReturnType DozerActionDoActionState::update( void )
if (dozer->getControllingPlayer() != goalObject->getControllingPlayer())//Yipes, SOmehow I have changed sides in mid build!
return STATE_FAILURE;
+ // a cooperative builder can find the site finished by the other one on it; finishing it
+ // again would add progress to CONSTRUCTION_COMPLETE and never stop
+ if( dozer->getTemplate()->isCooperativeBuilder() &&
+ !goalObject->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
+ {
+ dozerAI->finishBuildingSound();
+ complete = TRUE;
+ break;
+ }
+
// if we need to select the dock location and move there do so
if( dozerAI->getBuildSubTask() == DOZER_SELECT_BUILD_DOCK_LOCATION )
{
@@ -593,12 +606,12 @@ StateReturnType DozerActionDoActionState::update( void )
// the builder is now actively constructing something
dozer->setModelConditionState( MODELCONDITION_ACTIVELY_CONSTRUCTING );
-
+
// increase the construction percent of the goal object
Int framesToBuild = goalObject->getTemplate()->calcTimeToBuild( dozer->getControllingPlayer() );
Real percentProgressThisFrame = 100.0f / framesToBuild;
- goalObject->setConstructionPercent( goalObject->getConstructionPercent() +
+ goalObject->setConstructionPercent( goalObject->getConstructionPercent() +
percentProgressThisFrame );
//
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp
new file mode 100644
index 000000000..f5d6974f4
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp
@@ -0,0 +1,187 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: JammerUpdate.cpp ////////////////////////////////////////////////////////////////////////
+//
+// Each scan takes the enemy drones and spotters inside the field and lets go of the ones that left
+// it. The hold is a count on the victim (Object::addSightJammer), so two Korals over one drone do
+// not undo each other, and a dead or switched-off Koral lets go of everything it held.
+//
+///////////////////////////////////////////////////////////////////////////////////////////////////
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include <algorithm>
+
+#include "Common/ThingTemplate.h"
+#include "Common/Xfer.h"
+#include "GameLogic/GameLogic.h"
+#include "GameLogic/Object.h"
+#include "GameLogic/PartitionManager.h"
+#include "GameLogic/Module/JammerUpdate.h"
+
+//-------------------------------------------------------------------------------------------------
+JammerUpdateModuleData::JammerUpdateModuleData()
+{
+ m_radius = 0.0f;
+ m_scanFrames = LOGICFRAMES_PER_SECOND / 6;
+}
+
+//-------------------------------------------------------------------------------------------------
+/*static*/ void JammerUpdateModuleData::buildFieldParse( MultiIniFieldParse& p )
+{
+ UpdateModuleData::buildFieldParse( p );
+
+ static const FieldParse dataFieldParse[] =
+ {
+ { "Radius", INI::parseReal, NULL, offsetof( JammerUpdateModuleData, m_radius ) },
+ { "ScanRate", INI::parseDurationUnsignedInt, NULL, offsetof( JammerUpdateModuleData, m_scanFrames ) },
+ { 0, 0, 0, 0 }
+ };
+ p.add( dataFieldParse );
+}
+
+//-------------------------------------------------------------------------------------------------
+JammerUpdate::JammerUpdate( Thing *thing, const ModuleData* moduleData ) : UpdateModule( thing, moduleData )
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+JammerUpdate::~JammerUpdate( void )
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+static Bool isInList( const std::vector<ObjectID>& ids, ObjectID id )
+{
+ return std::find( ids.begin(), ids.end(), id ) != ids.end();
+}
+
+//-------------------------------------------------------------------------------------------------
+void JammerUpdate::releaseAll()
+{
+ for( std::vector<ObjectID>::const_iterator it = m_jammed.begin(); it != m_jammed.end(); ++it )
+ {
+ Object *victim = TheGameLogic->findObjectByID( *it );
+ if( victim )
+ victim->removeSightJammer();
+ }
+ m_jammed.clear();
+}
+
+//-------------------------------------------------------------------------------------------------
+void JammerUpdate::onDelete( void )
+{
+ releaseAll();
+}
+
+//-------------------------------------------------------------------------------------------------
+UpdateSleepTime JammerUpdate::update( void )
+{
+ const JammerUpdateModuleData *data = getJammerUpdateModuleData();
+ Object *me = getObject();
+
+ if( me->isEffectivelyDead() )
+ {
+ releaseAll();
+ return UPDATE_SLEEP_FOREVER;
+ }
+
+ if( me->isDisabled() || me->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
+ {
+ releaseAll();
+ return UPDATE_SLEEP( data->m_scanFrames );
+ }
+
+ PartitionFilterRelationship filterEnemies( me, PartitionFilterRelationship::ALLOW_ENEMIES );
+ PartitionFilterAlive filterAlive;
+ PartitionFilterSameMapStatus filterMapStatus( me );
+ PartitionFilter *filters[] = { &filterEnemies, &filterAlive, &filterMapStatus, NULL };
+ ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( me, data->m_radius, FROM_CENTER_2D, filters );
+ MemoryPoolObjectHolder hold( iter );
+
+ std::vector<ObjectID> inField;
+ for( Object *obj = iter->first(); obj; obj = iter->next() )
+ {
+ ProjectileUpdateInterface *projectile = obj->getProjectileUpdateInterface();
+ if( projectile )
+ {
+ DEBUG_LOG(( "JAMMER frame %d '%s' jams projectile '%s' %d\n", TheGameLogic->getFrame(),
+ me->getTemplate()->getName().str(), obj->getTemplate()->getName().str(), obj->getID() ));
+ projectile->projectileNowJammed();
+ continue;
+ }
+
+ if( obj->isKindOf( KINDOF_DRONE ) || obj->getTemplate()->hasSpotterSight() )
+ inField.push_back( obj->getID() );
+ }
+
+ for( std::vector<ObjectID>::const_iterator it = m_jammed.begin(); it != m_jammed.end(); ++it )
+ {
+ if( isInList( inField, *it ) )
+ continue;
+ Object *victim = TheGameLogic->findObjectByID( *it );
+ if( victim )
+ victim->removeSightJammer();
+ }
+
+ for( std::vector<ObjectID>::const_iterator it = inField.begin(); it != inField.end(); ++it )
+ {
+ if( isInList( m_jammed, *it ) )
+ continue;
+ Object *victim = TheGameLogic->findObjectByID( *it );
+ DEBUG_LOG(( "JAMMER frame %d '%s' blinds '%s' %d\n", TheGameLogic->getFrame(),
+ me->getTemplate()->getName().str(), victim->getTemplate()->getName().str(), victim->getID() ));
+ victim->addSightJammer();
+ }
+
+ m_jammed.swap( inField );
+ return UPDATE_SLEEP( data->m_scanFrames );
+}
+
+//-------------------------------------------------------------------------------------------------
+void JammerUpdate::crc( Xfer *xfer )
+{
+ UpdateModule::crc( xfer );
+}
+
+//-------------------------------------------------------------------------------------------------
+/** Xfer method
+ * Version Info:
+ * 1: Initial version */
+//-------------------------------------------------------------------------------------------------
+void JammerUpdate::xfer( Xfer *xfer )
+{
+ XferVersion currentVersion = 1;
+ XferVersion version = currentVersion;
+ xfer->xferVersion( &version, currentVersion );
+
+ UpdateModule::xfer( xfer );
+
+ Int count = (Int)m_jammed.size();
+ xfer->xferInt( &count );
+ m_jammed.resize( count );
+ for( Int i = 0; i < count; ++i )
+ xfer->xferObjectID( &m_jammed[ i ] );
+}
+
+//-------------------------------------------------------------------------------------------------
+void JammerUpdate::loadPostProcess( void )
+{
+ UpdateModule::loadPostProcess();
+}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/SightUpgrade.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/SightUpgrade.cpp
new file mode 100644
index 000000000..09831f8b8
--- /dev/null
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/SightUpgrade.cpp
@@ -0,0 +1,103 @@
+/*
+** Command & Conquer Generals Zero Hour(tm)
+** Copyright 2025 Electronic Arts Inc.
+**
+** This program is free software: you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation, either version 3 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+// FILE: SightUpgrade.cpp ////////////////////////////////////////////////////////////////////////
+
+#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+
+#include "Common/Xfer.h"
+#include "GameLogic/Object.h"
+#include "GameLogic/Module/SightUpgrade.h"
+#include "GameLogic/Module/StealthDetectorUpdate.h"
+
+//-------------------------------------------------------------------------------------------------
+SightUpgradeModuleData::SightUpgradeModuleData( void )
+{
+ m_visionRange = 0.0f;
+ m_shroudClearingRange = 0.0f;
+ m_enablesStealthDetector = FALSE;
+}
+
+//-------------------------------------------------------------------------------------------------
+void SightUpgradeModuleData::buildFieldParse( MultiIniFieldParse& p )
+{
+ UpgradeModuleData::buildFieldParse( p );
+
+ static const FieldParse dataFieldParse[] =
+ {
+ { "VisionRange", INI::parseReal, NULL, offsetof( SightUpgradeModuleData, m_visionRange ) },
+ { "ShroudClearingRange", INI::parseReal, NULL, offsetof( SightUpgradeModuleData, m_shroudClearingRange ) },
+ { "EnablesStealthDetector", INI::parseBool, NULL, offsetof( SightUpgradeModuleData, m_enablesStealthDetector ) },
+ { 0, 0, 0, 0 }
+ };
+ p.add( dataFieldParse );
+}
+
+//-------------------------------------------------------------------------------------------------
+SightUpgrade::SightUpgrade( Thing *thing, const ModuleData* moduleData ) : UpgradeModule( thing, moduleData )
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+SightUpgrade::~SightUpgrade( void )
+{
+}
+
+//-------------------------------------------------------------------------------------------------
+void SightUpgrade::upgradeImplementation( )
+{
+ const SightUpgradeModuleData *data = getSightUpgradeModuleData();
+ Object *obj = getObject();
+
+ obj->setVisionRange( data->m_visionRange );
+ obj->setShroudClearingRange( data->m_shroudClearingRange );
+
+ if( data->m_enablesStealthDetector )
+ {
+ static NameKeyType key_StealthDetectorUpdate = NAMEKEY( "StealthDetectorUpdate" );
+ StealthDetectorUpdate *detector = (StealthDetectorUpdate*)obj->findUpdateModule( key_StealthDetectorUpdate );
+ DEBUG_ASSERTCRASH( detector, ("SightUpgrade on '%s' enables a StealthDetectorUpdate it does not have", obj->getTemplate()->getName().str()) );
+ detector->setSDEnabled( true );
+ }
+}
+
+// ------------------------------------------------------------------------------------------------
+void SightUpgrade::crc( Xfer *xfer )
+{
+ UpgradeModule::crc( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+/** Xfer method
+ * Version Info:
+ * 1: Initial version */
+// ------------------------------------------------------------------------------------------------
+void SightUpgrade::xfer( Xfer *xfer )
+{
+ XferVersion currentVersion = 1;
+ XferVersion version = currentVersion;
+ xfer->xferVersion( &version, currentVersion );
+
+ UpgradeModule::xfer( xfer );
+}
+
+// ------------------------------------------------------------------------------------------------
+void SightUpgrade::loadPostProcess( void )
+{
+ UpgradeModule::loadPostProcess();
+}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index c25365e10..596050d2e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -222,6 +222,7 @@ const FieldParse WeaponTemplate::TheWeaponTemplateFieldParseTable[] =
{ "AcceptableAimDelta", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_aimDelta) },
{ "ScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterRadius) },
{ "BlindScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_blindScatterRadius) },
+ { "SeeksMostValuable", INI::parseBool, NULL, offsetof(WeaponTemplate, m_seeksMostValuable) },
{ "ScatterTargetScalar", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterTargetScalar) },
{ "ScatterRadiusVsInfantry", INI::parseReal, NULL, offsetof( WeaponTemplate, m_infantryInaccuracyDist ) },
{ "DamageType", DamageTypeFlags::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageType) },
@@ -310,6 +311,7 @@ WeaponTemplate::WeaponTemplate() : m_nextTemplate(NULL)
m_aimDelta = 0.0f;
m_scatterRadius = 0.0f;
m_blindScatterRadius = 0.0f;
+ m_seeksMostValuable = FALSE;
m_scatterTargetScalar = 0.0f;
m_shockWaveAmount = 0.0f;
m_shockWaveRadius = 0.0f;
@@ -2992,10 +2994,64 @@ void Weapon::preFireWeapon( const Object *source, const Object *victim )
}
}
+//-------------------------------------------------------------------------------------------------
+struct ValuedEnemy
+{
+ Int cost;
+ Object *obj;
+};
+
+static Bool isMoreValuable( const ValuedEnemy& a, const ValuedEnemy& b )
+{
+ if( a.cost != b.cost )
+ return a.cost > b.cost;
+ return a.obj->getID() < b.obj->getID();
+}
+
+void Weapon_findMostValuableEnemies( const Object *source, const Coord3D *center, Real radius,
+ Int maxCount, std::vector<Object*>& found )
+{
+ found.clear();
+
+ PartitionFilterRelationship filterEnemies( source, PartitionFilterRelationship::ALLOW_ENEMIES );
+ PartitionFilterAlive filterAlive;
+ PartitionFilterSameMapStatus filterMapStatus( source );
+ PartitionFilterStealthedAndUndetected filterHidden( source, FALSE );
+ PartitionFilter *filters[] = { &filterEnemies, &filterAlive, &filterMapStatus, &filterHidden, NULL };
+ ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( center, radius, FROM_CENTER_2D, filters );
+ MemoryPoolObjectHolder hold( iter );
+
+ std::vector<ValuedEnemy> candidates;
+ for( Object *obj = iter->first(); obj; obj = iter->next() )
+ {
+ if( obj->isAirborneTarget() || obj->isKindOf( KINDOF_PROJECTILE ) || obj->isKindOf( KINDOF_MINE ) ||
+ obj->isKindOf( KINDOF_UNATTACKABLE ) || obj->isKindOf( KINDOF_INERT ) )
+ continue;
+
+ ValuedEnemy candidate;
+ candidate.cost = obj->getTemplate()->calcCostToBuild( obj->getControllingPlayer() );
+ candidate.obj = obj;
+ candidates.push_back( candidate );
+ }
+
+ std::sort( candidates.begin(), candidates.end(), isMoreValuable );
+ for( Int i = 0; i < (Int)candidates.size() && i < maxCount; ++i )
+ found.push_back( candidates[ i ].obj );
+}
+
//-------------------------------------------------------------------------------------------------
Bool Weapon::fireWeapon(const Object *source, Object *target, ObjectID* projectileID)
{
//CRCDEBUG_LOG(("Weapon::fireWeapon() for %s at %s\n", DescribeObject(source).str(), DescribeObject(target).str()));
+ /* Turkey's swarm software: the munition picks its own target, the most expensive enemy it can
+ reach, whatever the drone was aimed at. */
+ if( m_template->seeksMostValuable() && target )
+ {
+ std::vector<Object*> found;
+ Weapon_findMostValuableEnemies( source, source->getPosition(), getAttackRange( source ), 1, found );
+ if( !found.empty() )
+ target = found.front();
+ }
return privateFireWeapon( source, target, NULL, false, false, 0, projectileID, TRUE );
}