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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(turkiye): kargu drones take off from an airfield and dive in
Olcay Seygan4b7b1c70573b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dd16cfde5..0f63fc2ae 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -146,7 +146,7 @@ found and fixed — EA's own, not port damage.**- The Korkut is air defense and nothing else. Its cannons reach 350 into the air and no longer fire at the ground, where they used to outrange the Altay; three Korkut that cut down eight Rangers without a scratch now lose to them, and still shoot down three Comanches untouched. The Kizilelma's missiles hit the ground as well as the air, and it costs 1800 instead of 2200. It carried 380 health on a Raptor's frame and shot a Raptor down in 29 seconds while the Raptor needed 86 for it; at the Raptor's 160 the duel is even and the dearer jet loses on price. The Akinci drops its own bomb, one a sortie; it had been dropping the Aurora's. With 420 health no ground air defense paid for itself against it. At 200 a Gattling Tank or a Missile Defender beats it for the money and a Quad Cannon breaks even.- Every Turkish unit has its own command bar with only buttons that work: no drone buttons on the Altay and the Cobra, no TOW on the Cobra, no rocket pods on the Bayraktar, no flash-bang switch on the Mehmetcik. The Barracks sells Capture Building, so the Mehmetcik's capture button works.- Turkiye's first rank buys its own power, a Minefield a cargo plane sows wherever you point, beside the Spy Drone and Fuel Resupply, which keeps the drones over the target longer. Rank 3 offers a loitering munition that dives on whatever it is pointed at, Electronic Blinding, which shuts every enemy radar in the area off for 30 seconds, and Rapid Deployment, six Mehmetcik and two Sungur gunners by parachute. The top rank buys the Swarm Strike: ten munitions over a wide circle, each on a different target and the most expensive first, so a column of tanks loses its tanks and the riflemen walking beside them are left standing. Beside it sit the Fire Mission, 36 heavy shells from off the map, and the Commando Raid, a Maroon Beret and two spotter teams dropped behind the enemy's lines. The American Paradrop, Leaflet Drop, Spectre gunship and CIA intelligence are gone from the Headquarters and the power bar.-- Turkiye has a superweapon: the Kargu Drone Base. It costs 5000, draws 10 power, opens once you have a Factory and a Radar Tower, counts against the lobby's superweapon limit like the Particle Cannon, the nuke and the Scud Storm, and every player watches its five-minute countdown. Fire it and twelve kamikaze drones lift off the hangar's roof, fly across the map where everyone can see them coming and split up over the target circle, each one diving into one of the twelve most expensive things inside it for 700. With fewer targets than drones the spares go round again, dearest first. Fired across Twilight Flame into an American base, it killed four of eight Crusaders and three of six Humvees and took a third off the Command Center, the War Factory and both power plants. The Turkish computer builds and fires it on every difficulty: Hard as soon as it can pay, about fifteen minutes in on that map, Medium after seventeen minutes and Easy after thirty, the same clock America's plans keep for their Particle Cannon. The building is the Particle Cannon on loan and the announcer calls it a Scud Storm until Turkiye has art and voices of its own.+- Turkiye has a superweapon: the Kargu Drone Base. It costs 5000, draws 10 power, opens once you have a Factory and a Radar Tower, counts against the lobby's superweapon limit like the Particle Cannon, the nuke and the Scud Storm, and every player watches its five-minute countdown. The base is an airfield with two runways and four hangars, and you tell it from Turkiye's own airfield at a glance because it wears China's. Fire it and the twelve kamikaze drones roll out of the hangars one after another, run down the runways, lift off and climb, then fly straight across the map where everyone can see them coming. Each goes for one of the twelve most expensive things inside the target circle, tips into its dive about 120 short and hits for 700. With fewer targets than drones the spares go round again, dearest first, and a drone whose target died on the way takes the dearest enemy left in the circle. They are aircraft, so anti-air shoots them down on the way in. The last drone leaves its hangar thirteen seconds after you fire and the last one hits after twenty-seven. Fired across Twilight Flame into an undefended American base, the swarm killed three of eight Crusaders and three of six Humvees, took 39% off the War Factory, 43% off the two power plants and 11% off the Command Center. The Turkish computer builds and fires it on every difficulty: Hard as soon as it can pay, about fifteen minutes in on that map, Medium after seventeen minutes and Easy after thirty, the same clock America's plans keep for their Particle Cannon. China's airfield and the Hellfire drone are on loan, and the announcer calls it a Scud Storm until Turkiye has art and voices of its own.- Two engineers on one building put it up in half the time, three in a third.- The Koral electronic warfare vehicle jams everything within 400 of it. Enemy drones and spotters inside the field go nearly blind, and guided missiles fired into it lose their lock and fly wide.- The Maroon Beret is a hero against every side. He is camouflaged, sees 350 for the artillery from inside the camouflage, and carries Burton's knife and timed and remote charges. He no longer hijacks supply trucks, which used him up for good and found nothing to take from America.diff --git a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini b/GeneralsMD/Code/Data/INI/CommandSetReforged.iniindex b6bfc9b17..7d5bd9e30 100644--- a/GeneralsMD/Code/Data/INI/CommandSetReforged.ini+++ b/GeneralsMD/Code/Data/INI/CommandSetReforged.ini@@ -916,14 +916,14 @@ CommandButton Command_TurkiyeCommandoRaidFromShortcutInvalidCursorName = GenericInvalidEnd-; The Kargu base, Turkiye's superweapon, and its swarm: the uplink's cameo for the building, the-; Hellfire drone's for the swarm.+; The Kargu base, Turkiye's superweapon, and its swarm: China's airfield cameo for the building,+; which is that airfield, the Hellfire drone's for the swarm.CommandButton Command_ConstructTurkiyeKarguBaseCommand = DOZER_CONSTRUCTObject = TurkiyeKarguBaseTextLabel = CONTROLBAR:ConstructTurkiyeKarguBase- ButtonImage = SAUplink+ ButtonImage = SNAirfieldButtonBorderType = BUILDDescriptLabel = CONTROLBAR:ToolTipTurkiyeKarguBaseEnddiff --git a/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini b/GeneralsMD/Code/Data/INI/TurkiyeReforged.iniindex f32045bb3..c580b9b76 100644--- a/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini+++ b/GeneralsMD/Code/Data/INI/TurkiyeReforged.ini@@ -231,17 +231,22 @@ Object TurkiyeRadarTowerEndEnd-; The Kargu base, Turkiye's superweapon: a hangar whose swarm of kamikaze drones flies out to the-; twelve dearest targets in a wide circle and dives into them, each drone a projectile from the-; building to its target (TurkiyeKarguDrone, TurkiyeKarguDroneWeapon). With fewer than twelve-; targets in the circle the spare drones go round them again, dearest first. The Particle Cannon-; lends it the body, price, power draw, superweapon limit and public countdown; its beam and the-; ability that drives it go. Turkiye has no Strategy Center, so the Factory and a Radar Tower open-; it: an Easy computer, on America's Easy plan, never builds an Airfield. The power's enum is the-; Scud Storm's, the nearest EVA has: the announcements say Scud Storm until Turkiye has voices of-; its own.--ObjectReskin TurkiyeKarguBase AmericaParticleCannonUplink+; The Kargu base, Turkiye's superweapon: a drone airfield whose swarm of twelve kamikaze drones+; flies out to the twelve dearest targets in a wide circle and dives into them. With fewer than+; twelve targets in the circle the spare drones go round them again, dearest first. The drones are+; jets (TurkiyeKarguDrone): each one rolls out of a hangar, down one of the two runways and climbs+; away, and the four hangars send the twelve out as they empty, one every half second at most+; (ParkingPlaceBehavior::scramble). It is China's airfield, so it looks nothing like Turkiye's own,+; the American one, and it carries what the Particle Cannon lent it before: price, build time,+; power draw, health and armour, the superweapon limit and the public countdown. Turkiye has no+; Strategy Center, so the Factory and a Radar Tower open it: an Easy computer, on America's Easy+; plan, never builds an Airfield. It is no FS_AIRFIELD: with it the computer held the base back as an+; extra airfield its jets did not need yet and never built it, no jet lands here and the+; select-airfields key leaves it out. A jet takes off from a superweapon's parking as from an+; airfield's (JetAIUpdate's getPP). The power's enum is the Scud Storm's, the nearest EVA has: the+; announcements say Scud Storm until Turkiye has voices of its own.++ObjectReskin TurkiyeKarguBase ChinaAirfieldEndObject TurkiyeKarguBase@@ -252,15 +257,55 @@ Object TurkiyeKarguBaseObject = TurkiyeWarFactoryObject = TurkiyeRadarTowerEnd- RemoveModule ModuleTag_11- RemoveModule ModuleTag_12+ BuildCost = 5000+ BuildTime = 60.0+ EnergyProduction = -10+ ShroudRevealToAllRange = 60+ ArmorSet+ Conditions = None+ Armor = StructureArmorTough+ DamageFX = StructureDamageFXNoShake+ End+ ExperienceValue = 400 400 400 400+ MaxSimultaneousOfType = DeterminedBySuperweaponRestriction+ MaxSimultaneousLinkKey = Superweapon+ VoiceSelect = AirfieldUSASelect+ KindOf = PRELOAD STRUCTURE SELECTABLE IMMOBILE SCORE CAPTURABLE FS_TECHNOLOGY POWERED MP_COUNT_FOR_VICTORY FS_SUPERWEAPON+ ReplaceModule ModuleTag_09+ Body = StructureBody ModuleTag_09_Turkiye+ MaxHealth = 4000.0+ InitialHealth = 4000.0+ SubdualDamageCap = 4200+ SubdualDamageHealRate = 500+ SubdualDamageHealAmount = 100+ End+ End+ ; China's airfield, but a drone's climb out ends at 30 rather than 50, and its hangar is free sooner+ ReplaceModule ModuleTag_10+ Behavior = ParkingPlaceBehavior ModuleTag_10_Turkiye+ HealAmountPerSecond = 10+ NumRows = 2+ NumCols = 2+ HasRunways = Yes+ ApproachHeight = 30+ ParkInHangars = Yes+ End+ End+ AddModule+ Behavior = BaseRegenerateUpdate ModuleTag_TurkiyeKarguRegenerate+ End+ End+ AddModule+ Behavior = SpecialPowerCreate ModuleTag_TurkiyeKarguPowerCreate+ End+ EndAddModuleBehavior = SwarmStrikeSpecialPower ModuleTag_TurkiyeKarguSwarmSpecialPowerTemplate = SuperweaponTurkiyeKarguSwarmRadius = 350TargetCount = 12RepeatTargets = Yes- Weapon = TurkiyeKarguDroneWeapon+ Drone = TurkiyeKarguDroneEndEndEnd@@ -1134,14 +1179,143 @@ Object TurkiyeClusterMineSide = TurkiyeEnd-; The Kargu base's drone: the Tomahawk missile, which cruises at 120 and dives on its target, drawn-; as the Hellfire drone. Its fuel lasts 30 seconds rather than 4, enough to cross a large map.-; The Tomahawk names no side, so a Firtina's missile stays a missile (ThingFactory::newObject).--ObjectReskin TurkiyeKarguDrone TomahawkMissile+; The Kargu base's drone, drawn as the Hellfire drone. It is a jet on the MiG's frame (no other+; Turkiye object is a MiG, and ThingFactory::newObject wants one Turkiye reskin per source), so it+; taxis out of its hangar, rolls down the runway, lifts off and climbs (JetAIUpdate's takeoff), then+; flies straight at its target on a jet's banked turns. Its one weapon lets go of the diving drone+; below and the jet is gone the same frame (KamikazeRange); with its target dead on the way it takes+; the dearest enemy within 350 of itself instead. Nobody can select it, so nobody can call it home.+; Shot down, it falls and bursts like a scout drone, without its warhead.++Locomotor TurkiyeKarguDroneLocomotor+ Surfaces = AIR+ Speed = 160+ SpeedDamaged = 120+ MinSpeed = 60+ TurnRate = 120+ TurnRateDamaged = 90+ Acceleration = 120+ AccelerationDamaged = 60+ Lift = 120+ LiftDamaged = 80+ Braking = 10+ MinTurnSpeed = 100+ PreferredHeight = 80+ AllowAirborneMotiveForce = Yes+ ZAxisBehavior = SURFACE_RELATIVE_HEIGHT+ CirclingRadius = 80+ Appearance = WINGS+ PitchInDirectionOfZVelFactor = 1.0+ PitchStiffness = 0.5+ RollStiffness = 0.4+ PitchDamping = 0.9+ RollDamping = 0.8+ ForwardVelocityPitchFactor = 0+ LateralVelocityRollFactor = 0.2+ Apply2DFrictionWhenAirborne = Yes+ AirborneTargetingHeight = 30+ LocomotorWorksWhenDead = Yes+End++; on its wheels a light drone rolls out half as fast again as a jet (BasicJetTaxiLocomotor, 50)+Locomotor TurkiyeKarguDroneTaxiLocomotor+ Surfaces = GROUND+ Speed = 80+ SpeedDamaged = 80+ TurnRate = 180+ TurnRateDamaged = 180+ Acceleration = 160+ AccelerationDamaged = 160+ Braking = 160+ MinTurnSpeed = 0+ ZAxisBehavior = NO_Z_MOTIVE_FORCE+ Appearance = FOUR_WHEELS+End++ObjectReskin TurkiyeKarguDrone ChinaJetMIGEndObject TurkiyeKarguDrone+ Side = Turkiye+ DisplayName = GUI:SuperweaponTurkiyeKarguSwarm+ SelectPortrait = SAHellfire_L+ ButtonImage = SAHellfire+ VisionRange = 150+ ShroudClearingRange = 150+ KindOf = PRELOAD CAN_CAST_REFLECTIONS CAN_ATTACK VEHICLE AIRCRAFT+ WeaponSet+ Conditions = None+ Weapon = PRIMARY TurkiyeKarguDroneWeapon+ End+ ReplaceModule ModuleTag_01+ Draw = W3DModelDraw ModuleTag_01_Turkiye+ OkToChangeModelColor = Yes+ DefaultConditionState+ Model = AVHellDrone+ WeaponLaunchBone = PRIMARY WeaponA+ End+ ConditionState = REALLYDAMAGED+ Model = AVHellDrone_d+ End+ End+ End+ ReplaceModule ModuleTag_02+ Body = ActiveBody ModuleTag_02_Turkiye+ MaxHealth = 100.0+ InitialHealth = 100.0+ End+ End+ ReplaceModule ModuleTag_03+ Behavior = JetSlowDeathBehavior ModuleTag_03_Turkiye+ DestructionDelay = 99999999+ RollRate = 0.4+ RollRateDelta = 100%+ PitchRate = 0.0+ FallHowFast = 150.0%+ FXInitialDeath = FX_BattleDroneDamageTransitionSmall+ FXOnGroundDeath = FX_AmericaScoutDroneExplode+ FXHitGround = FX_AmericaScoutDroneExplode+ OCLHitGround = OCL_AmericaScoutDroneExplode+ DelayFinalBlowUpFromHitGround = 0+ End+ End+ ReplaceModule ModuleTag_06+ Behavior = JetAIUpdate ModuleTag_06_Turkiye+ TakeoffDistForMaxLift = 0%+ TakeoffPause = 200+ MinHeight = 3+ KeepsParkingSpaceWhenAirborne = No+ KamikazeRange = 350+ End+ Locomotor = SET_NORMAL TurkiyeKarguDroneLocomotor+ Locomotor = SET_TAXIING TurkiyeKarguDroneTaxiLocomotor+ End+End++; The drone's dive, the last 150: the Tomahawk missile drawn as the drone, let go at the drone's+; height and speed and pointed at the target, so the swap from the jet does not show. No ignition+; flash, no smoke trail and a steady homing locomotor, where the Tomahawk's thrust snaked. The+; Tomahawk names no side, so a Firtina's missile stays a missile (ThingFactory::newObject).++Locomotor TurkiyeKarguDroneDiveLocomotor+ Surfaces = AIR+ Speed = 200+ MinSpeed = 120+ Acceleration = 300+ Braking = 0+ TurnRate = 240+ MaxThrustAngle = 15+ AllowAirborneMotiveForce = Yes+ Appearance = THRUST+ PreferredHeight = 80+ AirborneTargetingHeight = 30+ PreferredHeightDamping = 0.7+End++ObjectReskin TurkiyeKarguDroneDive TomahawkMissile+End++Object TurkiyeKarguDroneDiveReplaceModule ModuleTag_01Draw = W3DModelDraw ModuleTag_01_TurkiyeOkToChangeModelColor = Yes@@ -1156,15 +1330,14 @@ Object TurkiyeKarguDroneReplaceModule ModuleTag_07Behavior = MissileAIUpdate ModuleTag_07_TurkiyeTryToFollowTarget = Yes- FuelLifetime = 30000+ FuelLifetime = 6000IgnitionDelay = 0- IgnitionFX = FX_TomahawkIgnition- InitialVelocity = 50- DistanceToTravelBeforeTurning = 80- DistanceToTargetBeforeDiving = 100+ InitialVelocity = 160+ DistanceToTravelBeforeTurning = 10+ DistanceToTargetBeforeDiving = 120DistanceToTargetForLock = 10End- Locomotor = SET_NORMAL TomahawkMissileLocomotor+ Locomotor = SET_NORMAL TurkiyeKarguDroneDiveLocomotorEndEnddiff --git a/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini b/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.iniindex 450c9555d..c167e25d1 100644--- a/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini+++ b/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini@@ -837,27 +837,28 @@ Weapon TurkiyeSwarmStrikeWeaponAntiAirborneInfantry = NoEnd-; The Kargu base's drone, one per target (TurkiyeKarguBase). Unlike the rank tree's munitions it is a-; projectile: it leaves the hangar, flies the whole way at cruise height and dives on its target,-; so it can be seen coming and shot down on the way. 700 kills any tank but the Overlord and+; The Kargu drone's one shot, itself (TurkiyeKarguBase, TurkiyeKarguDrone): within 150 of its+; target the jet lets go of the diving drone, a projectile, and is gone. Unlike the rank tree's+; munitions it can be seen coming and shot down on the way. 700 kills any tank but the Overlord and; the Emperor, and twelve of them are the Scud Storm's nine missiles spread over a wider circle.+; RETURN_TO_BASE with a clip of one is what tells the jet it has fired (JetAIUpdate KamikazeRange).Weapon TurkiyeKarguDroneWeaponPrimaryDamage = 700.0PrimaryDamageRadius = 20.0SecondaryDamage = 150.0SecondaryDamageRadius = 50.0- AttackRange = 99999.0+ AttackRange = 150.0+ AcceptableAimDelta = 30DamageType = EXPLOSIONDeathType = EXPLODEDWeaponSpeed = 99999- FireFX = FX_TomahawkIgnitionFireSound = TomahawkWeapon- ProjectileObject = TurkiyeKarguDrone- ProjectileExhaust = MissileExhaust+ ProjectileObject = TurkiyeKarguDroneDiveProjectileDetonationFX = WeaponFX_BombTruckDefaultBombDetonation+ AutoReloadsClip = RETURN_TO_BASE; NOT_SIMILAR: a drone's blast took the swarm's drones beside it out of the airRadiusDamageAffects = ALLIES ENEMIES NEUTRALS NOT_SIMILAR- ClipSize = 0+ ClipSize = 1AntiAirborneVehicle = NoAntiAirborneInfantry = NoEnddiff --git a/GeneralsMD/Code/Data/Scenarios/kargu.txt b/GeneralsMD/Code/Data/Scenarios/kargu.txtindex b285ca8e0..a420946fe 100644--- a/GeneralsMD/Code/Data/Scenarios/kargu.txt+++ b/GeneralsMD/Code/Data/Scenarios/kargu.txt@@ -1,13 +1,17 @@# Turkiye's Kargu base fired across Twilight Flame into an American base: a War Factory, two power# plants and the command centre, eight Crusaders and six Humvees spread around them. The swarm is-# called at frame 60; the twelve drones leave the hangar's roof and cross the 1400 to the base in-# about eight seconds. Compare the tallies at frame 50 and frame 340, after the last hit and before-# the American buildings heal, and read the SWARM lines for the targets the drones were sent at.-# The drones themselves are tallied on the way.+# called at frame 60. The drones roll out of the base's four hangars, take off from its two runways+# one after another and fly the 1400 to the American base; a SCRAMBLE line says when each one left+# its hangar (the last about 13 seconds after the call) and a KAMIKAZE line where it began its dive+# (the last about 27 seconds after). The tallies of TurkiyeKarguDrone count the jets rolling or in+# the air, those of TurkiyeKarguDroneDive the drones in their dive. Compare the American tallies at+# frame 50 and at frame 950, after the last hit and before the buildings heal, and read the SWARM+# lines for the targets the drones were sent at. SCRAMBLE and KAMIKAZE count logic frames, 60 a+# second; the frames of this file are 30 a second.## generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover-# -side 0 FactionTurkiye -side 1 FactionAmerica -seed 1 -maxframes 800 -scenario kargu+# -side 0 FactionTurkiye -side 1 FactionAmerica -seed 1 -maxframes 2000 -scenario kargu# -logPrefix kargu_10 spawn 0 TurkiyeKarguBase 1 start0:0:250@@ -27,10 +31,19 @@60 power 0 TurkiyeKarguBase start1100 tally 0 TurkiyeKarguDrone200 tally 0 TurkiyeKarguDrone-340 tally 0 TurkiyeKarguDrone-340 tally 1 AmericaWarFactory-340 tally 1 AmericaPowerPlant-340 tally 1 AmericaCommandCenter-340 tally 1 AmericaTankCrusader-340 tally 1 AmericaVehicleHumvee-340 tally 1 *+300 tally 0 TurkiyeKarguDrone+400 tally 0 TurkiyeKarguDrone+400 tally 0 TurkiyeKarguDroneDive+500 tally 0 TurkiyeKarguDrone+500 tally 0 TurkiyeKarguDroneDive+600 tally 0 TurkiyeKarguDrone+600 tally 0 TurkiyeKarguDroneDive+700 tally 0 TurkiyeKarguDrone+800 tally 0 TurkiyeKarguDrone+950 tally 0 TurkiyeKarguDrone+950 tally 1 AmericaWarFactory+950 tally 1 AmericaPowerPlant+950 tally 1 AmericaCommandCenter+950 tally 1 AmericaTankCrusader+950 tally 1 AmericaVehicleHumvee+950 tally 1 *diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.hindex d8803f3e7..ced9d50c5 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/JetAIUpdate.h@@ -71,6 +71,7 @@ public:Real m_lockonAngleSpin; ///< how many times to spin around itReal m_lockonBlinky;UnsignedInt m_returnToBaseIdleTime; ///< if we're idle for this long, return to base+ Real m_kamikazeRange; ///< if nonzero, its one shot is itself, and with its target gone it takes the dearest enemy this near where it was sentJetAIUpdateModuleData();static void buildFieldParse(MultiIniFieldParse& p);@@ -137,6 +138,8 @@ public:AICommandType friend_getHeldOrder( ObjectID& targetID, Coord3D& targetPos ) const;Bool friend_isRearming() const;void friend_purgePendingCommand();+ /// a kamikaze whose target dies on the way looks for another here, and dives here when there is none+ void friend_setKamikazeArea( const Coord3D *pos ) { m_kamikazeArea = *pos; }protected:@@ -180,6 +183,7 @@ private:Int m_flags;Coord3D m_landingPosForHelipadStuff;Bool m_enginesOn; ///<+ Coord3D m_kamikazeArea; ///< where a kamikaze was sent (friend_setKamikazeArea)void getProducerLocation();void buildLockonDrawableIfNecessary();diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.hindex 713f4b2dd..6fc4211e9 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ParkingPlaceBehavior.h@@ -133,6 +133,7 @@ public:// DieModulevirtual void onDie( const DamageInfo *damageInfo );+ virtual void onCapture( Player *oldOwner, Player *newOwner );// ParkingPlaceBehaviorInterfacevirtual Bool shouldReserveDoorWhenQueued(const ThingTemplate* thing) const;@@ -157,8 +158,19 @@ public:virtual const std::vector<Coord3D>* getTaxiLocations( ObjectID id ) const { return NULL; }virtual const std::vector<Coord3D>* getCreationLocations( ObjectID id ) const { return NULL; }+ /// a new jet of this kind comes out of the next free space, one every half second at most, and is+ /// sent at the target, or at the point when the target is gone by then (the Kargu base's swarm)+ void scramble( const ThingTemplate *jet, ObjectID target, const Coord3D *pos );+private:+ struct ScrambleInfo+ {+ const ThingTemplate* m_jet;+ ObjectID m_target;+ Coord3D m_pos;+ };+struct ParkingPlaceInfo{Coord3D m_hangarStart;@@ -203,12 +215,15 @@ private:std::vector<ParkingPlaceInfo> m_spaces;std::vector<RunwayInfo> m_runways;std::list<HealingInfo> m_healing; // note, this list can vary in size, and be larger than the parking space count+ std::list<ScrambleInfo> m_scrambles;+ UnsignedInt m_nextScrambleFrame;UnsignedInt m_nextHealFrame;Bool m_gotInfo;void buildInfo();void purgeDead();void resetWakeFrame();+ void launchScramble();ParkingPlaceInfo* findPPI(ObjectID id);ParkingPlaceInfo* findEmptyPPI();diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.hindex 3728da030..72a468817 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SwarmStrikeSpecialPower.h@@ -21,6 +21,8 @@// Turkiye'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. With RepeatTargets// all TargetCount shots go: round the targets again, dearest first, or at the click with none.+// With a Drone, each shot is one of those jets instead, scrambled from the building's airfield+// (ParkingPlaceBehavior::scramble) and sent at its target./////////////////////////////////////////////////////////////////////////////////////////////////////@@ -48,6 +50,7 @@ public:Bool m_repeatTargets;const WeaponTemplate *m_weapon;const FXList *m_targetFX;+ AsciiString m_droneName;};//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cppindex ac68fc1d7..f4a6e4fcb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/ParkingPlaceBehavior.cpp@@ -31,7 +31,9 @@// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine#include "Common/CRCDebug.h"+#include "Common/Player.h"#include "Common/Xfer.h"+#include "Common/ThingFactory.h"#include "Common/ThingTemplate.h"#include "GameClient/Drawable.h"#include "GameLogic/AI.h"@@ -43,7 +45,8 @@#include "GameLogic/Module/JetAIUpdate.h"#include "GameLogic/Object.h"#include "GameLogic/TerrainLogic.h"-#include "Common/Team.h"+#include "GameLogic/Weapon.h"+#include "Common/Team.h"#ifdef _INTERNAL// for occasional debugging...@@ -66,6 +69,7 @@ ParkingPlaceBehavior::ParkingPlaceBehavior( Thing *thing, const ModuleData* modu//m_heliRallyPointExists = FALSE;+ m_nextScrambleFrame = 0;m_nextHealFrame = FOREVER;setWakeFrame(getObject(), UPDATE_SLEEP_NONE);}@@ -691,9 +695,66 @@ void ParkingPlaceBehavior::killAllParkedUnits()//-------------------------------------------------------------------------------------------------void ParkingPlaceBehavior::onDie( const DamageInfo *damageInfo ){+ m_scrambles.clear();killAllParkedUnits();}+//-------------------------------------------------------------------------------------------------+// the old owner's scramble was aimed at the old owner's enemies+void ParkingPlaceBehavior::onCapture( Player *oldOwner, Player *newOwner )+{+ m_scrambles.clear();+}++//-------------------------------------------------------------------------------------------------+// one scrambled jet at most every this many frames, so a full field does not roll out on one frame+const UnsignedInt SCRAMBLE_INTERVAL_FRAMES = LOGICFRAMES_PER_SECOND / 2;++//-------------------------------------------------------------------------------------------------+void ParkingPlaceBehavior::scramble( const ThingTemplate *jet, ObjectID target, const Coord3D *pos )+{+ ScrambleInfo info;+ info.m_jet = jet;+ info.m_target = target;+ info.m_pos = *pos;+ m_scrambles.push_back( info );+}++//-------------------------------------------------------------------------------------------------+/** The next scrambled jet, when its turn has come and a space is free: it comes out of the hangar+ * like a built one and is handed its target, which it takes off for. */+//-------------------------------------------------------------------------------------------------+void ParkingPlaceBehavior::launchScramble()+{+ UnsignedInt now = TheGameLogic->getFrame();+ if( m_scrambles.empty() || now < m_nextScrambleFrame )+ return;++ const ScrambleInfo& next = m_scrambles.front();+ ExitDoorType door = reserveDoorForExit( next.m_jet, NULL );+ if( door == DOOR_NONE_AVAILABLE )+ return;++ Object *jet = TheThingFactory->newObject( next.m_jet, getObject()->getControllingPlayer()->getDefaultTeam() );+ jet->setProducer( getObject() );+ exitObjectViaDoor( jet, door );+ jet->getAIUpdateInterface()->getJetAIUpdate()->friend_setKamikazeArea( &next.m_pos );++ // a script's order: a human player's unit given CMD_FROM_AI will not fly out of its sight to chase+ // (AIAttackApproachTargetState), and this target is a map away+ Object *target = TheGameLogic->findObjectByID( next.m_target );+ if( target && !target->isEffectivelyDead() )+ jet->getAIUpdateInterface()->aiAttackObject( target, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT );+ else+ jet->getAIUpdateInterface()->aiAttackPosition( &next.m_pos, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT );+ DEBUG_LOG(( "SCRAMBLE frame %d '%s' %d from door %d at %d (%.0f,%.0f), %d to go\n", now,+ next.m_jet->getName().str(), jet->getID(), (Int)door, next.m_target, next.m_pos.x, next.m_pos.y,+ (Int)m_scrambles.size() - 1 ));++ m_scrambles.pop_front();+ m_nextScrambleFrame = now + SCRAMBLE_INTERVAL_FRAMES;+}+//-------------------------------------------------------------------------------------------------UpdateSleepTime ParkingPlaceBehavior::update(){@@ -703,6 +764,7 @@ UpdateSleepTime ParkingPlaceBehavior::update()// there are generally at most only a few airfields at any given time.buildInfo();purgeDead();+ launchScramble();UnsignedInt now = TheGameLogic->getFrame();if (now >= m_nextHealFrame)@@ -932,14 +994,15 @@ void ParkingPlaceBehavior::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 4: the scramble queue */// ------------------------------------------------------------------------------------------------void ParkingPlaceBehavior::xfer( Xfer *xfer ){Int i;// version- const XferVersion currentVersion = 3;+ const XferVersion currentVersion = 4;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -1108,6 +1171,37 @@ void ParkingPlaceBehavior::xfer( Xfer *xfer )}}+ if (version >= 4)+ {+ xfer->xferUnsignedInt(&m_nextScrambleFrame);+ Int scrambleCount = (Int)m_scrambles.size();+ xfer->xferInt(&scrambleCount);+ if (xfer->getXferMode() == XFER_SAVE)+ {+ for (std::list<ScrambleInfo>::iterator it = m_scrambles.begin(); it != m_scrambles.end(); ++it)+ {+ AsciiString name = it->m_jet->getName();+ xfer->xferAsciiString(&name);+ xfer->xferObjectID(&it->m_target);+ xfer->xferCoord3D(&it->m_pos);+ }+ }+ else if (xfer->getXferMode() == XFER_LOAD)+ {+ m_scrambles.clear();+ for (i = 0; i < scrambleCount; ++i)+ {+ AsciiString name;+ ScrambleInfo info;+ xfer->xferAsciiString(&name);+ xfer->xferObjectID(&info.m_target);+ xfer->xferCoord3D(&info.m_pos);+ info.m_jet = TheThingFactory->findTemplate(name);+ m_scrambles.push_back(info);+ }+ }+ }+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cppindex 6058d51bb..1f73552ec 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SwarmStrikeSpecialPower.cpp@@ -25,12 +25,14 @@#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine+#include "Common/ThingFactory.h"#include "Common/ThingTemplate.h"#include "Common/Xfer.h"#include "GameClient/FXList.h"#include "GameLogic/GameLogic.h"#include "GameLogic/Object.h"#include "GameLogic/Weapon.h"+#include "GameLogic/Module/ParkingPlaceBehavior.h"#include "GameLogic/Module/SwarmStrikeSpecialPower.h"// ------------------------------------------------------------------------------------------------@@ -55,6 +57,7 @@ SwarmStrikeSpecialPowerModuleData::SwarmStrikeSpecialPowerModuleData( void ){ "RepeatTargets", INI::parseBool, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_repeatTargets ) },{ "Weapon", INI::parseWeaponTemplate, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_weapon ) },{ "TargetFX", INI::parseFXList, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_targetFX ) },+ { "Drone", INI::parseAsciiString, NULL, offsetof( SwarmStrikeSpecialPowerModuleData, m_droneName ) },{ 0, 0, 0, 0 }};p.add( dataFieldParse );@@ -72,27 +75,24 @@ SwarmStrikeSpecialPower::~SwarmStrikeSpecialPower( void )}// -------------------------------------------------------------------------------------------------/** One shot, at the target or else at the point. A projectile is made at the shooter's foot when its- * model has no launch bone, and a drone made at the foot of a building met the ground the frame it- * left, so it starts from the roof. */+/** One shot, at the target or else at the point: the Weapon, or a Drone scrambled from the+ * building's runways, which flies there and dives in. */// -------------------------------------------------------------------------------------------------static void fireShot( const WeaponTemplate *weapon, const Object *source, Object *target, const Coord3D *pos )+static void fireShot( const SwarmStrikeSpecialPowerModuleData *data, Object *source, Object *target, const Coord3D *pos ){- Weapon *w = TheWeaponStore->allocateNewWeapon( weapon, PRIMARY_WEAPON );- w->loadAmmoNow( source );- ObjectID projectileID = INVALID_ID;- if( target )- w->fireWeapon( source, target, &projectileID );- else- w->fireWeapon( source, pos, &projectileID );- w->deleteInstance();-- Object *projectile = TheGameLogic->findObjectByID( projectileID );- if( projectile == NULL )- return; // a hit with no projectile, the rank tree's munitions- Coord3D roof = *projectile->getPosition();- roof.z += source->getGeometryInfo().getMaxHeightAbovePosition();- projectile->setPosition( &roof );+ if( data->m_droneName.isEmpty() )+ {+ if( target )+ TheWeaponStore->createAndFireTempWeapon( data->m_weapon, source, target );+ else+ TheWeaponStore->createAndFireTempWeapon( data->m_weapon, source, pos );+ return;+ }++ static NameKeyType parkingKey = TheNameKeyGenerator->nameToKey( "ParkingPlaceBehavior" );+ ParkingPlaceBehavior *airfield = (ParkingPlaceBehavior *)source->findUpdateModule( parkingKey );+ airfield->scramble( TheThingFactory->findTemplate( data->m_droneName ), target ? target->getID() : INVALID_ID,+ target ? target->getPosition() : pos );}// ------------------------------------------------------------------------------------------------@@ -111,7 +111,7 @@ void SwarmStrikeSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real{DEBUG_LOG(( "SWARM '%s' picks '%s' %d\n", getPowerName().str(), (*it)->getTemplate()->getName().str(), (*it)->getID() ));FXList::doFXPos( data->m_targetFX, (*it)->getPosition() );- fireShot( data->m_weapon, getObject(), *it, NULL );+ fireShot( data, getObject(), *it, NULL );}if( !data->m_repeatTargets )@@ -119,7 +119,7 @@ void SwarmStrikeSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real// the spare shots: round the same targets again, dearest first, or at the click when none stood therefor( Int shot = (Int)targets.size(); shot < data->m_targetCount; ++shot )- fireShot( data->m_weapon, getObject(), targets.empty() ? NULL : targets[ shot % targets.size() ], loc );+ fireShot( data, getObject(), targets.empty() ? NULL : targets[ shot % targets.size() ], loc );DEBUG_LOG(( "SWARM '%s' frame %d sends %d at %d targets around (%.0f,%.0f)\n", getPowerName().str(),TheGameLogic->getFrame(), data->m_targetCount, (Int)targets.size(), loc->x, loc->y ));}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cppindex e2445f2d2..d455f83e0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp@@ -244,8 +244,10 @@ static ParkingPlaceBehaviorInterface* getPP(ObjectID id, Object** airfieldPP = Nif (airfieldPP)*airfieldPP = NULL;+ // the Kargu base's drones roll off a superweapon's runways, which is no airfield to anyone elseObject* airfield = TheGameLogic->findObjectByID( id );- if (airfield == NULL || airfield->isEffectivelyDead() || !airfield->isKindOf(KINDOF_FS_AIRFIELD) || airfield->testStatus(OBJECT_STATUS_SOLD))+ if (airfield == NULL || airfield->isEffectivelyDead() || airfield->testStatus(OBJECT_STATUS_SOLD) ||+ !(airfield->isKindOf(KINDOF_FS_AIRFIELD) || airfield->isKindOf(KINDOF_FS_SUPERWEAPON)))return NULL;if (airfieldPP)@@ -1978,6 +1980,7 @@ JetAIUpdateModuleData::JetAIUpdateModuleData()m_lockonFreq = ConvertRetailPerFrameRate(0.5f);m_lockonAngleSpin = 720;m_returnToBaseIdleTime = 0;+ m_kamikazeRange = 0.0f;}//-------------------------------------------------------------------------------------------------@@ -2007,6 +2010,7 @@ JetAIUpdateModuleData::JetAIUpdateModuleData(){ "LockonAngleSpin", INI::parseAngleReal, NULL, offsetof( JetAIUpdateModuleData, m_lockonAngleSpin ) },{ "LockonBlinky", INI::parseBool, NULL, offsetof( JetAIUpdateModuleData, m_lockonBlinky ) },{ "ReturnToBaseIdleTime", INI::parseDurationUnsignedInt, NULL, offsetof( JetAIUpdateModuleData, m_returnToBaseIdleTime ) },+ { "KamikazeRange", INI::parseReal, NULL, offsetof( JetAIUpdateModuleData, m_kamikazeRange ) },{ 0, 0, 0, 0 }};p.add(dataFieldParse);@@ -2037,6 +2041,7 @@ JetAIUpdate::JetAIUpdate( Thing *thing, const ModuleData* moduleData ) : AIUpdatm_returnToBaseFrame = 0;m_lockonDrawable = NULL;m_landingPosForHelipadStuff.zero();+ m_kamikazeArea.zero();//Added By Sadullah Nader//Initializations missing and needed@@ -2159,6 +2164,22 @@ UpdateSleepTime JetAIUpdate::update()ParkingPlaceBehaviorInterface* pp = getPP(getObject()->getProducerID());+ // a kamikaze whose target is gone takes the dearest enemy left in the area it was sent to, or dives+ // into the area, rather than flying home with its one shot (notifyVictimIsDead) to land and wait+ if (d->m_kamikazeRange > 0.0f && getFlag(ALLOW_AIR_LOCO) && !getFlag(TAKEOFF_IN_PROGRESS) &&+ !getFlag(LANDING_IN_PROGRESS) && !getFlag(HAS_PENDING_COMMAND) && AIUpdateInterface::isIdle())+ {+ std::vector<Object*> found;+ Weapon_findMostValuableEnemies(jet, &m_kamikazeArea, d->m_kamikazeRange, 1, found);+ DEBUG_LOG(("KAMIKAZE frame %d '%s' %d lost its target at (%.0f,%.0f), %s\n", TheGameLogic->getFrame(), jet->getTemplate()->getName().str(),+ jet->getID(), jet->getPosition()->x, jet->getPosition()->y, found.empty() ? "dives into the area" : found.front()->getTemplate()->getName().str()));+ // a script's order, as the scramble gave (ParkingPlaceBehavior::launchScramble), so it chases+ if (!found.empty())+ aiAttackObject(found.front(), NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT);+ else+ aiAttackPosition(&m_kamikazeArea, NO_MAX_SHOTS_LIMIT, CMD_FROM_SCRIPT);+ }+// If idle & out of ammo, return// have to call our parent's isIdle, because we override it to never return true// when we have a pending command...@@ -2364,6 +2385,15 @@ UpdateSleepTime JetAIUpdate::update()/*UpdateSleepTime ret =*/ AIUpdateInterface::update();++ // a kamikaze's shot is the jet itself: the projectile it just let go flies on from where it was+ if (d->m_kamikazeRange > 0.0f && getFlag(ALLOW_AIR_LOCO) && isOutOfSpecialReloadAmmo())+ {+ DEBUG_LOG(("KAMIKAZE frame %d '%s' %d dives from (%.0f,%.0f) at %.0f above the ground\n", TheGameLogic->getFrame(),+ jet->getTemplate()->getName().str(), jet->getID(), jet->getPosition()->x, jet->getPosition()->y, jet->getHeightAboveTerrain()));+ TheGameLogic->destroyObject(jet);+ }+//return (mine < ret) ? mine : ret;/// @todo srj -- someday, make sleepy. for now, must not sleep.return UPDATE_SLEEP_NONE;@@ -2944,13 +2974,14 @@ void JetAIUpdate::crc( Xfer *xfer )* 1: Initial version* 2: Save engine on/off state.* 3: TheSuperHackers @bugfix Save the helipad landing position.- * 4: the most recent command keeps its source */+ * 4: the most recent command keeps its source+ * 5: a kamikaze's area */// ------------------------------------------------------------------------------------------------void JetAIUpdate::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 4;+ XferVersion currentVersion = 5;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -3009,6 +3040,11 @@ void JetAIUpdate::xfer( Xfer *xfer )xfer->xferCoord3D( &m_landingPosForHelipadStuff );}+ if( version >= 5 )+ {+ xfer->xferCoord3D( &m_kamikazeArea );+ }+} // end xfer// ------------------------------------------------------------------------------------------------