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(turkiye): ai fields artillery with spotters, artillery nerf

Olcay Seyganea6c8439abbc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 39304666c..9f1e10dcd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -136,7 +136,7 @@ found and fixed — EA's own, not port damage.**
- Turkiye is a fourth side in the skirmish and multiplayer lobbies, listed as Turkiye (Experimental), Türkiye (Deneysel) in Turkish. The label is there because the side is not finished: its powers and abilities are still being worked on and will change. It has an army of its own: Mehmetcik riflemen, Sungur missile teams and Maroon Berets from the Barracks; the Altay tank, the Kirpi carrier, Korkut air defense, Firtina howitzers and Sakarya rocket launchers from the Factory; Bayraktar and Akinci drones, the Gokbey helicopter and the Kizilelma fighter from the Airfield. Every name and tooltip reads in English and in Turkish.
- Turkiye kills from range and cannot see for itself. The Firtina throws a shell 600 and sees 100, so it waits until a spotter team, a Bayraktar or a Radar Tower finds the target, then fires on its own. Force it to shell ground nobody can see and the shots go wide, about half of them off a barracks-sized target. Extended Range and Precision Guidance at the Factory push the guns further and tighten the blind spread.
-- Once something sees for it, the artillery is what kills. A Firtina shell does 300 where it lands and 100 out to 45, every 6 seconds, where it did 150 inside 10 every 7, less than an Altay. A Sakarya salvo is six rockets of 100 each with a 40 blast, every 12 seconds. The Sakarya never hit anything before: its rockets left the launcher level and went nowhere, and it now aims them up the way the Firtina does. Two Firtinas and a spotter team wipe four Crusaders and five Rangers standing in the open in 40 seconds, where they used to leave a Crusader and two Rangers alive; two Sakaryas used to leave all nine untouched and now leave none.
+- Once something sees for it, the artillery is what kills. A Firtina shell does 200 where it lands and 60 out to 35, every 7 seconds, where it did 150 inside 10, less than an Altay. A Sakarya salvo is six rockets of 70 each with a 30 blast, every 14 seconds. The Sakarya never hit anything before: its rockets left the launcher level and went nowhere, and it now aims them up the way the Firtina does. Four Battlemasters or sixteen Rangers marching straight at two Firtinas and their spotter, the same 3500 in money, die before they get there. Crusaders and Scorpions get through with one to three tanks left. Come at the guns from the side with that money in tanks and the tanks win seven fights in eight, so a raid on the flank or a dead spotter is how a gun line falls.
- Sight is what Turkiye pays for. The Bayraktar is the artillery's real eye, 550 from the air, and costs 900 instead of 500. The Cobra sees 250 instead of 400 and is a fast car with five seats, no longer the cheapest spotter. The Radar Tower costs 800 instead of 400 and draws 3 power. The spotter team sees 500, has 200 health, moves faster and hides while it stands still. The free Spy Satellite Scan is gone, and the Sungur gunner sees 200 instead of 300.
- Combat Engineers build the base in place of a dozer. They are infantry, so they can be shot and run over. The Barracks' Mine Kit lets them bury mines, and the Factory's Reinforced Hull, which used to be called the Armor Pack, gives the Kirpi and the Altay 20% more health.
- The engineers dig in at the front. The Siper is a bunker for five infantry, 500, that goes up wherever an engineer stands: the army moves up, digs a Siper, spots and shells. Mehmetcik inside it hold off infantry and Sungur gunners hold off tanks. It takes the place of the air defense site, a Chinese gattling cannon that fired at everything. The Patriot battery is now called Hisar and is the base's one fixed air defense.
@@ -153,6 +153,7 @@ found and fixed — EA's own, not port damage.**
- Turkish ranks carry more than numbers. A Çavuş sees 10% further, an Uzman Çavuş takes 10% less damage standing still, and from the sixth grade a unit patches itself up out of a fight at 1% a second. Sight grows to 20% and 30% further at the astsubay and general ranks. A Teğmen spots for the Firtina and the Sakarya the way the spotter team does, a Binbaşı's own guns spread 15% less, and a Tümgeneral finds stealthed enemies within 100 of it. Officers lead: the Astsubay Kıdemli Başçavuş makes every friendly unit within 150 fire 5% faster and the Albay 10%, the Yüzbaşı lets them see 10% further, the Korgeneral cuts the damage they take by 10% and the Orgeneral puts 5% on the artillery's range. A Tuğgeneral who falls leaves the men around him taking 15% less damage for ten seconds, and a Mareşal's leadership reaches 300. Two officers of the same kind never add up: a tank between an Albay and a Başçavuş fires 10% faster, the Albay's figure alone. Select or hover a leader and what it gives the men around it shows on the ground as one quiet dial at the edge of its reach, each gift in its own band and its own pattern: short ticks round the rim for fire, a dotted line for sight, a notched line for armour, a graduated scale for the guns' reach and a faint wash inside for the last stand, so an Albay draws two bands and a Mareşal the whole dial; the portrait's tooltip lists what the rank carries. Only you and your allies see the rings. Making those colours work fixed a mistake in how the game tints glowing ground marks, which had drawn every one of them in pure blue. The grid a spy satellite or a radar scan lays over what it reveals is now the dim grey-blue EA's data asks for, and about half as bright as before.
- The units still borrow American and other sides' models, voices and cameos.
- The computer plays Turkiye too. A Turkish AI puts up a full base with radar towers, Hisar batteries and Siper bunkers it fills with its own infantry, sends supply trucks, fields the new army, artillery included, fires its own powers and attacks.
+- The Turkish computer brings its guns and the eyes to aim them. A Firtina or Sakarya that comes out for one of its attack groups now sends for spotter teams, one on Easy and Medium and two on Hard, and the group waits for them before it leaves; until now the guns walked out blind and the spotters it did buy sat in its bunkers. The American battle plans it plays never put a Firtina in an Easy attack and only reach one after a quarter of an hour on Medium, so it adds a gun of its own to every Easy attack group, every second Medium one and every fourth on Hard. In three fifteen-minute matches a difficulty on Twilight Flame against America, Easy fielded 21 guns, Medium 48 and Hard 27, and all 41 that came out for an attack group sent for their spotters. The computer pays the Turkish price for them now. A Firtina used to cost it the American 1200 whenever that was all it had in the bank.
## Zero Hour on a Mac, on Linux and on the Steam Deck
diff --git a/GeneralsMD/Code/Data/INI/AIDataReforged.ini b/GeneralsMD/Code/Data/INI/AIDataReforged.ini
index 936f52202..c174efc7e 100644
--- a/GeneralsMD/Code/Data/INI/AIDataReforged.ini
+++ b/GeneralsMD/Code/Data/INI/AIDataReforged.ini
@@ -22,6 +22,12 @@ AIData
ResourceGatherersNormal = 2
ResourceGatherersHard = 2
BaseDefenseStructure1 = AmericaPatriotBattery
+ ; the Firtina and Sakarya fire past their own sight. America's scripts name a Tomahawk in no Easy
+ ; team and in Medium's only from the third wave, so a share of the attack teams with no gun takes
+ ; one of these (AIDifficultyProfile ArtilleryShare: all of Easy's, half of Medium's, a quarter of
+ ; Hard's), and an attack team trains ArtillerySpotters of the Spotter when its gun comes out (1, 1, 2)
+ Artillery = TurkiyeVehicleFirtina TurkiyeVehicleSakarya
+ Spotter = TurkiyeInfantrySpotter
SkillSet1
Science = SCIENCE_TurkiyeMinefield
diff --git a/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini b/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini
index 1420826f1..58bd791af 100644
--- a/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini
+++ b/GeneralsMD/Code/Data/INI/TurkiyeWeaponReforged.ini
@@ -185,14 +185,15 @@ Weapon TurkiyeKorkutGunAir
End
; TomahawkMissileWeapon: Tomahawk missile out to 600, wide when blind. The artillery is the faction's
-; punch once something sees for it: 300 inside 20 and 100 out to 45 every 6 seconds, where the
-; Tomahawk's 150 inside 10 every 7 did less than an Altay. The blind spread stays the price of firing
-; at ground nobody sees.
+; punch once something sees for it: 200 inside 15 and 60 out to 35 every 7 seconds, where the
+; Tomahawk's 150 inside 10 did less than an Altay. 300 inside 20 and 100 out to 45 every 6 won 15 of
+; 16 equal-money staged raids on the gun line, flank included; this wins 4. The blind spread stays
+; the price of firing at ground nobody sees.
Weapon TurkiyeFirtinaShell
- PrimaryDamage = 300.0
- PrimaryDamageRadius = 20.0
- SecondaryDamage = 100.0
- SecondaryDamageRadius = 45.0
+ PrimaryDamage = 200.0
+ PrimaryDamageRadius = 15.0
+ SecondaryDamage = 60.0
+ SecondaryDamageRadius = 35.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 600
PreAttackDelay = 250
@@ -209,7 +210,7 @@ Weapon TurkiyeFirtinaShell
FireSound = TomahawkWeapon
DelayBetweenShots = 1
ClipSize = 1
- ClipReloadTime = 6000
+ ClipReloadTime = 7000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 120
@@ -217,10 +218,10 @@ End
; TomahawkMissileWeapon: Extended Range: 690
Weapon TurkiyeFirtinaShellLong
- PrimaryDamage = 300.0
- PrimaryDamageRadius = 20.0
- SecondaryDamage = 100.0
- SecondaryDamageRadius = 45.0
+ PrimaryDamage = 200.0
+ PrimaryDamageRadius = 15.0
+ SecondaryDamage = 60.0
+ SecondaryDamageRadius = 35.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 690
PreAttackDelay = 250
@@ -237,7 +238,7 @@ Weapon TurkiyeFirtinaShellLong
FireSound = TomahawkWeapon
DelayBetweenShots = 1
ClipSize = 1
- ClipReloadTime = 6000
+ ClipReloadTime = 7000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 120
@@ -245,10 +246,10 @@ End
; TomahawkMissileWeapon: Precision Guidance: blind spread 30
Weapon TurkiyeFirtinaShellGuided
- PrimaryDamage = 300.0
- PrimaryDamageRadius = 20.0
- SecondaryDamage = 100.0
- SecondaryDamageRadius = 45.0
+ PrimaryDamage = 200.0
+ PrimaryDamageRadius = 15.0
+ SecondaryDamage = 60.0
+ SecondaryDamageRadius = 35.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 600
PreAttackDelay = 250
@@ -265,7 +266,7 @@ Weapon TurkiyeFirtinaShellGuided
FireSound = TomahawkWeapon
DelayBetweenShots = 1
ClipSize = 1
- ClipReloadTime = 6000
+ ClipReloadTime = 7000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 30
@@ -273,10 +274,10 @@ End
; TomahawkMissileWeapon: both
Weapon TurkiyeFirtinaShellLongGuided
- PrimaryDamage = 300.0
- PrimaryDamageRadius = 20.0
- SecondaryDamage = 100.0
- SecondaryDamageRadius = 45.0
+ PrimaryDamage = 200.0
+ PrimaryDamageRadius = 15.0
+ SecondaryDamage = 60.0
+ SecondaryDamageRadius = 35.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 690
PreAttackDelay = 250
@@ -293,19 +294,19 @@ Weapon TurkiyeFirtinaShellLongGuided
FireSound = TomahawkWeapon
DelayBetweenShots = 1
ClipSize = 1
- ClipReloadTime = 6000
+ ClipReloadTime = 7000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 30
End
-; TomahawkMissileWeapon: six Tomahawk-like rockets out to 500, 100 inside 15 and 40 out to 40 each,
-; a salvo every 12 seconds (was 70 inside 10 every 15)
+; TomahawkMissileWeapon: six Tomahawk-like rockets out to 500, 70 inside 12 and 25 out to 30 each,
+; a salvo every 14 seconds (was 70 inside 10 every 15, then 100 inside 15 every 12, too much)
Weapon TurkiyeSakaryaSalvo
- PrimaryDamage = 100
- PrimaryDamageRadius = 15.0
- SecondaryDamage = 40
- SecondaryDamageRadius = 40.0
+ PrimaryDamage = 70
+ PrimaryDamageRadius = 12.0
+ SecondaryDamage = 25
+ SecondaryDamageRadius = 30.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 500
PreAttackDelay = 0
@@ -322,7 +323,7 @@ Weapon TurkiyeSakaryaSalvo
FireSound = TomahawkWeapon
DelayBetweenShots = 250
ClipSize = 6
- ClipReloadTime = 12000
+ ClipReloadTime = 14000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 120
@@ -331,10 +332,10 @@ End
; TomahawkMissileWeapon: Sakarya with Extended Range
Weapon TurkiyeSakaryaSalvoLong
- PrimaryDamage = 100
- PrimaryDamageRadius = 15.0
- SecondaryDamage = 40
- SecondaryDamageRadius = 40.0
+ PrimaryDamage = 70
+ PrimaryDamageRadius = 12.0
+ SecondaryDamage = 25
+ SecondaryDamageRadius = 30.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 575
PreAttackDelay = 0
@@ -351,7 +352,7 @@ Weapon TurkiyeSakaryaSalvoLong
FireSound = TomahawkWeapon
DelayBetweenShots = 250
ClipSize = 6
- ClipReloadTime = 12000
+ ClipReloadTime = 14000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 120
@@ -360,10 +361,10 @@ End
; TomahawkMissileWeapon: Sakarya with Precision Guidance
Weapon TurkiyeSakaryaSalvoGuided
- PrimaryDamage = 100
- PrimaryDamageRadius = 15.0
- SecondaryDamage = 40
- SecondaryDamageRadius = 40.0
+ PrimaryDamage = 70
+ PrimaryDamageRadius = 12.0
+ SecondaryDamage = 25
+ SecondaryDamageRadius = 30.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 500
PreAttackDelay = 0
@@ -380,7 +381,7 @@ Weapon TurkiyeSakaryaSalvoGuided
FireSound = TomahawkWeapon
DelayBetweenShots = 250
ClipSize = 6
- ClipReloadTime = 12000
+ ClipReloadTime = 14000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 30
@@ -389,10 +390,10 @@ End
; TomahawkMissileWeapon: Sakarya with both
Weapon TurkiyeSakaryaSalvoLongGuided
- PrimaryDamage = 100
- PrimaryDamageRadius = 15.0
- SecondaryDamage = 40
- SecondaryDamageRadius = 40.0
+ PrimaryDamage = 70
+ PrimaryDamageRadius = 12.0
+ SecondaryDamage = 25
+ SecondaryDamageRadius = 30.0
ScatterRadiusVsInfantry = 20.0
AttackRange = 575
PreAttackDelay = 0
@@ -409,7 +410,7 @@ Weapon TurkiyeSakaryaSalvoLongGuided
FireSound = TomahawkWeapon
DelayBetweenShots = 250
ClipSize = 6
- ClipReloadTime = 12000
+ ClipReloadTime = 14000
CapableOfFollowingWaypoints = Yes
ProjectileCollidesWith = STRUCTURES
BlindScatterRadius = 30
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
index d840d8788..30fac658a 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h
@@ -116,6 +116,8 @@ public:
TSkillSet m_skillSet4;
TSkillSet m_skillSet5;
AsciiString m_baseDefenseStructure1;
+ AsciiString m_spotter; ///< the unit sent along with a gun that fires past its own sight; empty for a side without one
+ std::vector<AsciiString> m_artillery; ///< the side's guns that fire past their own sight, one of them added to a share of its attack teams (AIDifficultyProfile m_artilleryShare)
AISideInfo *m_next;
};
EMPTY_DTOR(AISideInfo)
@@ -274,6 +276,10 @@ struct AIDifficultyProfile
Int m_siteBuildersLost; ///< ... and any site whose builders died this many times with nothing built in between
Real m_siteRetrySeconds; ///< how long a cancelled site's spot is left alone before it is placed again
Bool m_stageDozers; ///< an idle dozer walks to the site the base builder waits on money for
+
+ // Artillery that fires past its own sight
+ Int m_artillerySpotters; ///< the side's spotters (AISideInfo m_spotter) added to a team that brings such a gun and no spotter
+ Real m_artilleryShare; ///< the share of a side's attack teams with no such gun that are given one of its own (AISideInfo m_artillery)
};
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h
index 5e11885ca..210e6bab7 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h
@@ -536,6 +536,7 @@ protected:
void clearTeamsInQueue( void ); ///< Delete all teams in the build queue.
void computeCenterAndRadiusOfBase(Coord3D *center, Real *radius);
Object *findFactory(const ThingTemplate *thing, Bool busyOK); ///< Find a factory to build a unit. If force is true, may return a busy factory.
+ void sendForSpotters( TeamInQueue *team, const Object *gun ); ///< a gun that fires past its own sight came out for this team: train its spotters
void queueUnits( void ); ///< Check the team build list, & queue up units at any idle factories.
void checkForSupplyCenter( BuildListInfo *info, Object *bldg);
void queueSupplyTruck(void);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
index b528ed428..fdfba7a20 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp
@@ -258,6 +258,8 @@ void AI::parseSideInfo(INI *ini, void *instance, void* /*store*/, const void* /*
{ "ResourceGatherersNormal", INI::parseInt, NULL, offsetof( AISideInfo, m_normal ) },
{ "ResourceGatherersHard", INI::parseInt, NULL, offsetof( AISideInfo, m_hard ) },
{ "BaseDefenseStructure1", INI::parseAsciiString, NULL, offsetof( AISideInfo, m_baseDefenseStructure1 ) },
+ { "Spotter", INI::parseAsciiString, NULL, offsetof( AISideInfo, m_spotter ) },
+ { "Artillery", INI::parseAsciiStringVector, NULL, offsetof( AISideInfo, m_artillery ) },
{ "SkillSet1", AI::parseSkillSet, NULL, offsetof( AISideInfo, m_skillSet1 ) },
{ "SkillSet2", AI::parseSkillSet, NULL, offsetof( AISideInfo, m_skillSet2 ) },
{ "SkillSet3", AI::parseSkillSet, NULL, offsetof( AISideInfo, m_skillSet3 ) },
@@ -1331,12 +1333,23 @@ Real AI::getAdjustedVisionRangeForObject(const Object *object, Int factorsToCons
* and its spot (and the dock it was for) left alone for retry seconds. stage sends an idle dozer
* ahead to the site the base builder is waiting on money for. Easy gives up latest and does not stage.
*
- * scoutS maxSc decis cntr mass ttk indiv team infl focus save harv expand guard hoard econ micro gate answer massU bankS floor payoff upgr nonc share backlog push minPow siege beam strikeE strikeT swDef stall lost retry stage */
+ * spot, 2026-10-22: Turkiye's Firtina and Sakarya see 100 and shoot 500 to 600, so they hit what
+ * somebody else shows them. America's scripts, which Turkiye runs, put a Tomahawk or a Paladin in a
+ * team with no Pathfinder, and the guns walked out blind. An attack team with no spotter now trains
+ * this many of the side's (AISideInfo Spotter) the moment such a gun comes out for it, and waits for
+ * them (AIPlayer::sendForSpotters): one for Easy and Medium, two for Hard, so that losing one does
+ * not blind the gun. Those scripts name a Tomahawk in no Easy team at all, in Medium's from the
+ * third wave, about seventeen minutes in, and in Hard's from about seven, so arty, the share of the
+ * attack teams with no gun that are given one of the side's own (AISideInfo Artillery), is all of
+ * Easy's few, half of Medium's and a quarter of Hard's. A side that names no Artillery or Spotter
+ * draws nothing and plays as before.
+ *
+ * scoutS maxSc decis cntr mass ttk indiv team infl focus save harv expand guard hoard econ micro gate answer massU bankS floor payoff upgr nonc share backlog push minPow siege beam strikeE strikeT swDef stall lost retry stage spot arty */
static const AIDifficultyProfile s_defaultSkillLadder[ AISKILL_COUNT ] =
{
- /* Easy */ { 75.0f, 1, 7.0f, 0.00f, FALSE, 0.00f, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, 120.0f, 6000, 4.0f, 720.0f, 0.05f, 0.05f, 90.0f, 360.0f, 1500.0f, 80.0f, 0.00f, 0.0f, 2.0f, 3, 300.0f, 3, 300.0f, FALSE },
- /* Medium */ { 45.0f, 1, 3.0f, 0.50f, FALSE, 0.35f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 6000, FALSE, FALSE, FALSE, FALSE, FALSE, 60.0f, 5000, 2.5f, 420.0f, 0.05f, 0.25f, 75.0f, 300.0f, 2000.0f, 120.0f, 1.00f, 2.0f, 1.0f, 6, 240.0f, 2, 240.0f, TRUE },
- /* Hard */ { 25.0f, 2, 1.5f, 1.00f, TRUE, 0.50f, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 4000, TRUE, TRUE, TRUE, TRUE, FALSE, 30.0f, 4000, 1.5f, 180.0f, 0.05f, 1.00f, 45.0f, 240.0f, 4500.0f, 160.0f, 0.25f, 3.0f, 0.0f, DEFENSES_PER_SUPERWEAPON, 180.0f, 2, 180.0f, TRUE }
+ /* Easy */ { 75.0f, 1, 7.0f, 0.00f, FALSE, 0.00f, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, 0, FALSE, FALSE, FALSE, FALSE, FALSE, 120.0f, 6000, 4.0f, 720.0f, 0.05f, 0.05f, 90.0f, 360.0f, 1500.0f, 80.0f, 0.00f, 0.0f, 2.0f, 3, 300.0f, 3, 300.0f, FALSE, 1, 1.00f },
+ /* Medium */ { 45.0f, 1, 3.0f, 0.50f, FALSE, 0.35f, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, 6000, FALSE, FALSE, FALSE, FALSE, FALSE, 60.0f, 5000, 2.5f, 420.0f, 0.05f, 0.25f, 75.0f, 300.0f, 2000.0f, 120.0f, 1.00f, 2.0f, 1.0f, 6, 240.0f, 2, 240.0f, TRUE, 1, 0.50f },
+ /* Hard */ { 25.0f, 2, 1.5f, 1.00f, TRUE, 0.50f, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, 4000, TRUE, TRUE, TRUE, TRUE, FALSE, 30.0f, 4000, 1.5f, 180.0f, 0.05f, 1.00f, 45.0f, 240.0f, 4500.0f, 160.0f, 0.25f, 3.0f, 0.0f, DEFENSES_PER_SUPERWEAPON, 180.0f, 2, 180.0f, TRUE, 2, 0.25f }
};
//-------------------------------------------------------------------------------------------------
@@ -2279,6 +2292,8 @@ void AI::parseSkillLevel(INI *ini, void *instance, void* /*store*/, const void*
{ "SiteBuildersLost", INI::parseInt, NULL, offsetof( AIDifficultyProfile, m_siteBuildersLost ) },
{ "SiteRetrySeconds", INI::parseReal, NULL, offsetof( AIDifficultyProfile, m_siteRetrySeconds ) },
{ "StageDozers", INI::parseBool, NULL, offsetof( AIDifficultyProfile, m_stageDozers ) },
+ { "ArtillerySpotters", INI::parseInt, NULL, offsetof( AIDifficultyProfile, m_artillerySpotters ) },
+ { "ArtilleryShare", INI::parseReal, NULL, offsetof( AIDifficultyProfile, m_artilleryShare ) },
{ NULL, NULL, NULL, 0 }
};
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
index 996747610..2d0cc2388 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
@@ -2010,6 +2010,7 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )
// put new unit into the team under construction
if (team->m_team)
unit->setTeam( team->m_team );
+ sendForSpotters( team, unit );
if (team->m_reinforcement) {
team->m_reinforcementID = unit->getID();
}
@@ -2688,6 +2689,114 @@ static Bool sideCanNeverField( const Player *player, const ThingTemplate *thing
TheThingFactory->findSideReskin( thing, side ) == NULL;
}
+// ------------------------------------------------------------------------------------------------
+/** The side's own reskin of a unit another side's scripts name, a Turkiye player's Firtina for the
+ * Tomahawk, else the unit itself. A team order for the American template was costed and saved for
+ * at the American price while the factory made and charged the Turkish one, and Money::withdraw
+ * takes what is there: a Firtina came out for the Tomahawk's 1200 with 1200 in the bank. */
+// ------------------------------------------------------------------------------------------------
+static const ThingTemplate *ownTemplate( const Player *player, const ThingTemplate *thing )
+{
+ const ThingTemplate *own = TheThingFactory->findSideReskin( thing, player->getSide() );
+ return own != NULL ? own : thing;
+}
+
+// ------------------------------------------------------------------------------------------------
+/** The side's spotter (AISideInfo m_spotter) for a team the scripts send at the enemy that names no
+ * spotter of its own, else NULL: a gun kept at home has the base's sight. */
+// ------------------------------------------------------------------------------------------------
+static const ThingTemplate *missingSpotterFor( const Player *player, const TeamPrototype *proto )
+{
+ const AISideInfo *sideInfo = TheAI->getAiData()->findSideInfo( player );
+ if( sideInfo == NULL || sideInfo->m_spotter.isEmpty() )
+ return NULL; // a side that never fires blind
+ const TeamTemplateInfo *info = proto->getTemplateInfo();
+ if( info->m_isBaseDefense || info->m_isPerimeterDefense || !aiTeamAttacks( info ) )
+ return NULL;
+
+ const ThingTemplate *spotter = TheThingFactory->findTemplate( sideInfo->m_spotter );
+ for( Int i = 0; i < info->m_numUnitsInfo; ++i )
+ {
+ const ThingTemplate *unit = TheThingFactory->findTemplate( info->m_unitsInfo[ i ].unitThingName, FALSE );
+ if( unit == NULL || info->m_unitsInfo[ i ].maxUnits <= 0 )
+ continue; // an empty slot, or a map's team naming a unit this game does not have
+ if( ownTemplate( player, unit )->isEquivalentTo( spotter ) )
+ return NULL;
+ }
+ return spotter;
+}
+
+// ------------------------------------------------------------------------------------------------
+/** A gun that fires past its own sight came out for a team still being built: it trains the rung's
+ * ArtillerySpotters of the side's spotter as part of the team, once. They used to be ordered with
+ * the team, and a barracks turns a 700 spotter out long before a war factory has saved for a 1400
+ * gun: Hard bought 23 to 34 spotters in fifteen minutes for 5 to 11 guns, the teams whose gun never
+ * came disbanded and the spotters sat in the Sipers. */
+// ------------------------------------------------------------------------------------------------
+void AIPlayer::sendForSpotters( TeamInQueue *team, const Object *gun )
+{
+ const Int spotters = getSkillProfile()->m_artillerySpotters;
+ if( !isSkirmishAI() || spotters <= 0 || !gun->getTemplate()->acquiresBeyondVision() )
+ return;
+ const ThingTemplate *spotter = missingSpotterFor( m_player, team->m_team->getPrototype() );
+ const char *why = spotter == NULL ? "a team kept at home or with its own spotter" : "sends for its spotters";
+ for( WorkOrder *order = team->m_workOrders; spotter && order; order = order->m_next )
+ if( order->m_thing->isEquivalentTo( spotter ) )
+ {
+ why = "its spotters already sent for"; // the team's second gun
+ spotter = NULL;
+ }
+ if( spotter )
+ {
+ // a computer player holds canBuildUnits off between team orders, and the barracks check reads it
+ const Bool canBuildUnits = m_player->getCanBuildUnits();
+ m_player->setCanBuildUnits( TRUE );
+ if( findFactory( spotter, TRUE ) == NULL )
+ {
+ why = "no barracks to train its spotters";
+ spotter = NULL;
+ }
+ m_player->setCanBuildUnits( canBuildUnits );
+ }
+ if( spotter )
+ {
+ WorkOrder *order = newInstance(WorkOrder);
+ order->m_thing = spotter;
+ order->m_factoryID = INVALID_ID;
+ order->m_numRequired = spotters;
+ order->m_required = true;
+ order->m_next = team->m_workOrders;
+ team->m_workOrders = order;
+ }
+ DEBUG_LOG(("AI ARTILLERY frame %d player %d '%s' %d comes out for team '%s', %s\n", TheGameLogic->getFrame(),
+ m_player->getPlayerIndex(), gun->getTemplate()->getName().str(), gun->getID(), team->m_team->getName().str(), why));
+}
+
+// ------------------------------------------------------------------------------------------------
+/** Can this team be given one of the side's guns (AISideInfo m_artillery): one the scripts send at the
+ * enemy, all of it on the ground, with no gun that fires past its sight already, no builder and no
+ * harvester in it. */
+// ------------------------------------------------------------------------------------------------
+static Bool takesArtillery( const Player *player, const TeamPrototype *proto )
+{
+ const TeamTemplateInfo *info = proto->getTemplateInfo();
+ if( info->m_isBaseDefense || info->m_isPerimeterDefense || !aiTeamAttacks( info ) )
+ return FALSE;
+ Bool fielded = FALSE;
+ for( Int i = 0; i < info->m_numUnitsInfo; ++i )
+ {
+ const ThingTemplate *unit = TheThingFactory->findTemplate( info->m_unitsInfo[ i ].unitThingName, FALSE );
+ if( unit == NULL || info->m_unitsInfo[ i ].maxUnits <= 0 || sideCanNeverField( player, unit ) )
+ continue;
+ unit = ownTemplate( player, unit );
+ if( unit->isKindOf( KINDOF_AIRCRAFT ) || unit->isKindOf( KINDOF_DOZER ) || unit->isKindOf( KINDOF_HARVESTER ) ||
+ unit->acquiresBeyondVision() )
+ return FALSE;
+ fielded = TRUE;
+ }
+ return fielded;
+}
+
// ------------------------------------------------------------------------------------------------
/** Return true if team can be considered for building */
// ------------------------------------------------------------------------------------------------
@@ -2708,6 +2817,7 @@ Bool AIPlayer::isPossibleToBuildTeam( TeamPrototype *proto, Bool requireIdleFact
continue;
}
if (thing) {
+ thing = ownTemplate(m_player, thing);
anyFielded = true;
Int thingCost = thing->calcCostToBuild(m_player);
// One walk of the build list, not two: findFactory hands back the first idle factory
@@ -4622,7 +4732,7 @@ void AIPlayer::buildSpecificAITeam( TeamPrototype *teamProto, Bool priorityBuild
int count = unitInfo[i].maxUnits-unitInfo[i].minUnits;
if (count>0) {
WorkOrder *order = newInstance(WorkOrder);
- order->m_thing = thing;
+ order->m_thing = ownTemplate(m_player, thing);
order->m_factoryID = INVALID_ID;
order->m_numRequired = count;
// prepend to head of list
@@ -4639,7 +4749,7 @@ void AIPlayer::buildSpecificAITeam( TeamPrototype *teamProto, Bool priorityBuild
{
int count = unitInfo[i].minUnits;
WorkOrder *order = newInstance(WorkOrder);
- order->m_thing = thing;
+ order->m_thing = ownTemplate(m_player, thing);
order->m_factoryID = INVALID_ID;
order->m_numRequired = count;
order->m_required = true;
@@ -4648,7 +4758,30 @@ void AIPlayer::buildSpecificAITeam( TeamPrototype *teamProto, Bool priorityBuild
orders = order;
}
}
- if (orders)
+ // a share of the attack teams of a side whose guns fire past their own sight takes one of them
+ // (AISideInfo Artillery), when a factory is up to make it: the scripts it runs may name none
+ const AISideInfo *sideInfo = isSkirmishAI() ? TheAI->getAiData()->findSideInfo( m_player ) : NULL;
+ const ThingTemplate *gun = NULL;
+ if (orders && sideInfo && !sideInfo->m_artillery.empty() && takesArtillery( m_player, teamProto ) &&
+ GameLogicRandomValueReal( 0.0f, 1.0f ) < getSkillProfile()->m_artilleryShare)
+ {
+ gun = TheThingFactory->findTemplate( sideInfo->m_artillery[ GameLogicRandomValue( 0, (Int)sideInfo->m_artillery.size() - 1 ) ] );
+ if (findFactory( gun, true ) == NULL)
+ gun = NULL;
+ }
+ if (gun)
+ {
+ WorkOrder *order = newInstance(WorkOrder);
+ order->m_thing = gun;
+ order->m_factoryID = INVALID_ID;
+ order->m_numRequired = 1;
+ order->m_required = true;
+ order->m_next = orders;
+ orders = order;
+ DEBUG_LOG(("AI ARTILLERY frame %d player %d team '%s' takes an added '%s'\n", TheGameLogic->getFrame(),
+ m_player->getPlayerIndex(), teamProto->getName().str(), gun->getName().str()));
+ }
+ if (orders)
{
/* We have something to build. */
TeamInQueue *team = newInstance(TeamInQueue);