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(gameengine): turkiye rank perks and auras with ground rings
Olcay Seygan49d44f400b0c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3c10cc2ec..5540c4fcd 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -144,7 +144,8 @@ found and fixed — EA's own, not port damage.**- Thermal Vision at the Barracks lets the spotter team and the Cobra see out to 550 and through stealth. The Airfield sells Fuel Cells, which double how long a Bayraktar or an Akinci stays over the target, and Swarm Software, which sends each Bayraktar munition at the most expensive target in reach rather than the nearest one.- Turkish units move at their own speeds. The engineer, the spotter team and the Kirpi are slow, and the Korkut keeps up with the tanks.- A Turkish computer player fires its powers, the Minefield included, as soon as they are ready, and pulls its spotter teams back out of the enemy's reach while keeping the enemy in sight.-- Turkish units climb the Turkish Land Forces' own ladder: 21 promotions from Er through Onbaşı, Çavuş, Uzman Çavuş and six astsubay grades to Teğmen, Yüzbaşı, Albay, the four generals and Mareşal at the top. The names read in Turkish in every language, and each grade wears its own insignia: chevrons for the enlisted men, gold bars for the astsubays, stars for the officers, the oak wreath under a field officer's stars and the crescent and star over a general's. The climb costs what it costs everyone else, a unit turns Veteran at Uzman Çavuş, Elite at Teğmen and Heroic at Albay, and the bonuses follow America's split, since the army still fights in American bodies. The Maroon Beret starts as an Albay, as Burton starts as a Colonel. Before this a Turkish unit wore EA's three chevrons.+- Turkish units climb the Turkish Land Forces' own ladder: 21 promotions from Er through Onbaşı, Çavuş, Uzman Çavuş and six astsubay grades to Teğmen, Yüzbaşı, Albay, the four generals and Mareşal at the top. The names read in Turkish in every language, and each grade wears its own insignia: chevrons for the enlisted men, gold bars for the astsubays, stars for the officers, the oak wreath under a field officer's stars and the crescent and star over a general's. The climb costs what it costs everyone else, a unit turns Veteran at Uzman Çavuş, Elite at Teğmen and Heroic at Albay. Its bonuses lean on health: at Mareşal a unit has 42% more of it, fires 25% faster, hits 19% harder and reaches 12% further. The Maroon Beret starts as an Albay, as Burton starts as a Colonel. Before this a Turkish unit wore EA's three chevrons.+- 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 each thing it gives the men around it shows as its own slowly turning ring on the ground, orange for fire, blue for sight, green for armour, purple for the guns' reach and white for the last stand; 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 and air defense sites, sends supply trucks, fields the new army, artillery included, and attacks.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 6c1da6626..a282cc65d 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -1,4 +1,5 @@CMakeLists.txt+Data/Art/Textures/ReforgedAuraRing.tgaData/Art/Textures/ReforgedBarAmericaCenter.tgaData/Art/Textures/ReforgedBarAmericaLeft.tgaData/Art/Textures/ReforgedBarAmericaRight.tga@@ -315,6 +316,7 @@ Data/Scenarios/overlordlong.txtData/Scenarios/overlordrush.txtData/Scenarios/parade.txtData/Scenarios/particles100k.txt+Data/Scenarios/rankaura.txtData/Scenarios/rankladder.txtData/Scenarios/rankzero.txtData/Scenarios/reachshot.txtdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedAuraRing.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedAuraRing.tganew file mode 100644index 000000000..a278b5a09Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedAuraRing.tga differdiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex 623382153..3f2da5c23 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -1835,7 +1835,28 @@ End; America: rate of fire and health, range to 107%.; China: health, and ranked men in a horde fire 10% faster.; GLA: rate of fire, speed to 114%, self repair to 2% a second.-; Turkiye: America's split, since it fights with America's units for now.+; Turkiye: health first, then rate of fire, range to 112%, and the only side with perks so far.+;+; A grade can carry perks besides its stats, one Perk_<side> line each: grade, kind, strength. A+; grade holds every perk of the grades below it, and of one kind the strongest, so Turkiye's sight+; goes 110%, 120%, 130% with each line replacing the last. A grade with no line is stats only.+;+; SIGHT 110% its own shroud clearing, past the half-again-its-weapon cap+; STILL_GUARD 10% 10% less damage taken while it is not walking a path+; MEND 1% heals 1% of max health a second once SelfRepairDelay unhurt+; SPOTTER sees and is jammed the way the Gozcu timi is (SpotterSight)+; SCATTER 15% its own weapons scatter 15% less+; DEATH_RALLY 15% when it dies, allies within its aura radius take 15% less damage for RallyTime+; DETECT 100 stealthed enemies within 100 are detected+; AURA_RADIUS 200% its aura radius doubled+; AURA_<kind> n% friendly units within AuraRadius: RATE_OF_FIRE added to rate of fire (never+; past AuraRateOfFireCap), SIGHT on shroud clearing, GUARD off damage taken,+; RANGE on an artillery weapon's range (AcquiresBeyondVision, or a minimum range)+;+; Auras are refilled once a second. A unit in range of several leaders takes the strongest of each+; kind; kinds multiply. A leader's aura never reaches the leader, and buildings take none. AuraRadius+; is 150, the reach of a tank gun: a Maresal's 300 covers a company. Each kind draws a ring on the+; ground under a selected or hovered leader for its owner and allies (AuraRing_<kind>, client only).Veterancy; America China GLA Turkiye@@ -1845,16 +1866,81 @@ VeterancyElitePin = 13 10 10 11 ; W-1 Warrant Officer, Second Lieutenant, Raid Captain, TegmenHeroicPin = 22 15 15 16 ; O-5 Lieutenant Colonel, Colonel, Warlord, AlbayHeroStart = 23 15 15 16 ; O-6 Colonel (Burton), Colonel, Warlord, Albay (the Maroon Beret)- RateOfFire = 142% 130% 148% 142%+ RateOfFire = 142% 130% 148% 125%Damage = 119% 119% 114% 119%Health = 142% 155% 142% 142%- Range = 107% 100% 100% 107%+ Range = 107% 100% 100% 112%Speed = 100% 100% 114% 100%SelfRepair = 0% 0% 2% 0%+ AuraRadius = 0 0 0 150WorthGain = 1.4CrateGrades = 3SelfRepairDelay = 5000WeaponBonus_China = HORDE RATE_OF_FIRE 110%++ Perk_Turkiye = 3 SIGHT 110% ; Cavus+ Perk_Turkiye = 4 STILL_GUARD 10% ; Uzman Cavus+ Perk_Turkiye = 6 MEND 1% ; Astsubay Kidemli Cavus+ Perk_Turkiye = 8 SIGHT 120% ; Astsubay Kidemli Ustcavus+ Perk_Turkiye = 10 AURA_RATE_OF_FIRE 5% ; Astsubay Kidemli Bascavus+ Perk_Turkiye = 11 SPOTTER ; Tegmen+ Perk_Turkiye = 13 AURA_SIGHT 10% ; Yuzbasi+ Perk_Turkiye = 14 SCATTER 15% ; Binbasi+ Perk_Turkiye = 16 AURA_RATE_OF_FIRE 10% ; Albay+ Perk_Turkiye = 17 DEATH_RALLY 15% ; Tuggeneral+ Perk_Turkiye = 18 SIGHT 130% ; Tumgeneral+ Perk_Turkiye = 18 DETECT 100+ Perk_Turkiye = 19 AURA_GUARD 10% ; Korgeneral+ Perk_Turkiye = 20 AURA_RANGE 5% ; Orgeneral+ Perk_Turkiye = 21 AURA_RADIUS 200% ; Maresal+ AuraRateOfFireCap = 18%+ RallyTime = 10000++ AuraRing_RateOfFire+ Texture = ReforgedAuraRing+ Style = SHADOW_ADDITIVE_DECAL+ Color = R:255 G:140 B:20+ OpacityMin = 45%+ OpacityMax = 90%+ OpacityThrobTime = 1600+ SpinTime = 9000+ End+ AuraRing_Sight+ Texture = ReforgedAuraRing+ Style = SHADOW_ADDITIVE_DECAL+ Color = R:40 G:140 B:255+ OpacityMin = 45%+ OpacityMax = 90%+ OpacityThrobTime = 1600+ SpinTime = -11000+ End+ AuraRing_Guard+ Texture = ReforgedAuraRing+ Style = SHADOW_ADDITIVE_DECAL+ Color = R:40 G:230 B:80+ OpacityMin = 45%+ OpacityMax = 90%+ OpacityThrobTime = 1600+ SpinTime = 13000+ End+ AuraRing_Range+ Texture = ReforgedAuraRing+ Style = SHADOW_ADDITIVE_DECAL+ Color = R:180 G:60 B:255+ OpacityMin = 45%+ OpacityMax = 90%+ OpacityThrobTime = 1600+ SpinTime = -15000+ End+ AuraRing_Rally+ Texture = ReforgedAuraRing+ Style = SHADOW_ADDITIVE_DECAL+ Color = R:230 G:230 B:230+ OpacityMin = 30%+ OpacityMax = 70%+ OpacityThrobTime = 2400+ SpinTime = 20000+ EndEnd; ---- a plane shot down blows up and burns where it lands -----------------------------------------diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex fd8989c77..c5212c750 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -2194,6 +2194,54 @@ RANK:NextRank"Next rank %d/%d XP"END+RANK:PerkSIGHT+"Sight +%d%%"+END++RANK:PerkSTILL_GUARD+"Standing still: %d%% less damage taken"+END++RANK:PerkMEND+"Out of combat: heals %d%% a second"+END++RANK:PerkSPOTTER+"Spots for the artillery"+END++RANK:PerkSCATTER+"Artillery scatter -%d%%"+END++RANK:PerkDEATH_RALLY+"When it falls, allies nearby take %d%% less damage for 10 seconds"+END++RANK:PerkDETECT+"Detects stealth within %d"+END++RANK:PerkAURA_RADIUS+"Aura reach +%d%%"+END++RANK:PerkAURA_RATE_OF_FIRE+"Aura: rate of fire +%d%%"+END++RANK:PerkAURA_SIGHT+"Aura: sight +%d%%"+END++RANK:PerkAURA_GUARD+"Aura: %d%% less damage taken"+END++RANK:PerkAURA_RANGE+"Aura: artillery range +%d%%"+END+RANK:America0"E-1 Private"ENDdiff --git a/GeneralsMD/Code/Data/Scenarios/rankaura.txt b/GeneralsMD/Code/Data/Scenarios/rankaura.txtnew file mode 100644index 000000000..f012ea789--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/rankaura.txt@@ -0,0 +1,21 @@+# Turkiye's rank auras (2026-10-22): an Albay Altay (grade 16, rate of fire +10%, sight +10%) and an+# Astsubay Kidemli Bascavus Sungur team (grade 10, rate of fire +5%) stand beside a grade 0+# Mehmetcik. The Mehmetcik is in both leaders' 150 and must hold 0.10 rate of fire, the stronger+# one, not 0.15. Each leader holds the other's and never its own: the Sungur 0.10 and sight 0.10,+# the Altay 0.05 and no sight. The Cobra 500 east is out of reach and logs nothing. Each change is+# one "RANK AURA" line in the log. The Kirpi is an ambulance and cannot be ranked.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover+# -side 0 FactionTurkiye -side 1 FactionGLA -seed 1 -maxframes 900 -scenario rankaura -logPrefix rankaura_++10 spawn 0 TurkiyeInfantrySungur 1 3350 3640+10 spawn 0 TurkiyeInfantryMehmetcik 1 3400 3640+10 spawn 0 TurkiyeTankAltay 1 3450 3640+10 spawn 0 TurkiyeVehicleCobra 1 3910 3640+10 spawn 1 GLAVehicleTechnical 1 3330 4290++12 rank 0 TurkiyeInfantrySungur grade 10+12 rank 0 TurkiyeTankAltay grade 16++400 tally 0 *diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex b69c95cea..3010de0a1 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -16578,6 +16578,54 @@ RANK:NextRank"Sonraki rütbe %d/%d XP"END+RANK:PerkSIGHT+"Görüş +%d%%"+END++RANK:PerkSTILL_GUARD+"Dururken %d%% daha az hasar alır"+END++RANK:PerkMEND+"Çatışma dışında saniyede %d%% iyileşir"+END++RANK:PerkSPOTTER+"Topçuya gözcülük yapar"+END++RANK:PerkSCATTER+"Topçu saçılması -%d%%"+END++RANK:PerkDEATH_RALLY+"Düştüğünde yakındaki dostlar 10 saniye %d%% daha az hasar alır"+END++RANK:PerkDETECT+"%d içindeki gizli birimleri görür"+END++RANK:PerkAURA_RADIUS+"Aura menzili +%d%%"+END++RANK:PerkAURA_RATE_OF_FIRE+"Aura: atış hızı +%d%%"+END++RANK:PerkAURA_SIGHT+"Aura: görüş +%d%%"+END++RANK:PerkAURA_GUARD+"Aura: %d%% daha az hasar"+END++RANK:PerkAURA_RANGE+"Aura: topçu menzili +%d%%"+END+RANK:America0"E-1 Er"ENDdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 73e66a171..75b72c8b4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -44,6 +44,7 @@#include "Common/GameCommon.h"#include "Common/Money.h"#include "Common/WindowMode.h"+#include "GameClient/RadiusDecal.h"// FORWARD DECLARATIONS ///////////////////////////////////////////////////////////////////////////struct FieldParse;@@ -87,6 +88,44 @@ enum RankStatRANK_STAT_COUNT};+/** What a grade carries besides its stats, the Perk_<side> lines. A grade holds every perk of the+ * grades below it, and of one kind the strongest, so a later line of the same kind replaces an+ * earlier one by being larger. */+enum RankPerk+{+ RANK_PERK_SIGHT, ///< own shroud clearing, a multiplier+ RANK_PERK_STILL_GUARD, ///< share of damage taken away while standing still+ RANK_PERK_MEND, ///< share of max health healed a second once SelfRepairDelay unhurt+ RANK_PERK_SPOTTER, ///< sees as a spotter does (ThingTemplate SpotterSight), and is jammed as one+ RANK_PERK_SCATTER, ///< share of its own weapons' scatter taken away+ RANK_PERK_DEATH_RALLY, ///< on death, allies within its aura radius take this share less damage for RallyTime+ RANK_PERK_DETECT, ///< stealthed enemies within this radius are detected+ RANK_PERK_AURA_RADIUS, ///< its aura radius, a multiplier+ RANK_PERK_AURA_RATE_OF_FIRE, ///< the first of the aura perks, in RankAura order+ RANK_PERK_AURA_SIGHT,+ RANK_PERK_AURA_GUARD,+ RANK_PERK_AURA_RANGE,++ RANK_PERK_COUNT+};++/** A leader's bonus to friendly units within its aura radius, refilled once a second. Of one kind a+ * unit takes the strongest leader's and nothing more. RALLY is the death rally, timed instead. */+enum RankAura+{+ RANK_AURA_RATE_OF_FIRE, ///< added to weapon rate of fire, up to RankAuraRateOfFireCap+ RANK_AURA_SIGHT, ///< shroud clearing, 1 + this+ RANK_AURA_GUARD, ///< damage taken, 1 - this+ RANK_AURA_RANGE, ///< an artillery weapon's range, added+ RANK_AURA_RALLY, ///< damage taken, 1 - this, until the rally runs out++ RANK_AURA_COUNT,+ RANK_AURA_PASSED = RANK_AURA_RALLY ///< the kinds the once-a-second pass writes+};++extern const char *const TheRankPerkNames[RANK_PERK_COUNT + 1];+extern const char *const TheRankAuraNames[RANK_AURA_COUNT];+/** One side's rank ladder, the Veterancy block in BalanceReforged.ini (docs/plans/RANK-LADDER.md).* A unit's grade is a pure function of its experience and its template's E, its regular* ExperienceValue: the step to grade g costs E x ratio^(g-1), the ratio set so the top grade costs@@ -99,11 +138,14 @@ struct RankLadderInt m_pin[LEVEL_COUNT]; ///< the grade each EA level starts on; m_pin[LEVEL_REGULAR] is 0Int m_heroStart; ///< the insignia a hero wears at grade 0Real m_statTop[RANK_STAT_COUNT]; ///< each stat at the top of the ladder+ Real m_auraRadius; ///< a leader's aura radius before RANK_PERK_AURA_RADIUS+ Real m_perkAt[RANK_GRADES_MAX + 1][RANK_PERK_COUNT]; ///< the perks a grade's own lines name, 0 for none// filled by finish()Real m_ratio;Real m_total[RANK_GRADES_MAX + 1]; ///< experience to hold grade g, in EReal m_stat[RANK_GRADES_MAX + 1][RANK_STAT_COUNT]; ///< each stat at grade g+ Real m_perk[RANK_GRADES_MAX + 1][RANK_PERK_COUNT]; ///< each perk grade g holds, the strongest of its grade and those belowvoid clear();/** The ratio from m_grades and m_top, the totals, and the stats: worth (rate of fire times damage@@ -117,6 +159,9 @@ struct RankLadder* lifts one grade at most. Experience past the next-to-last grade is not clipped. */Int clipGain( Int unitValue, Int experience, Int gain ) const;Int insigniaIndex( Int grade, Bool hero ) const; ///< a hero's insignia runs from m_heroStart to the top over its grades+ Real perk( Int grade, RankPerk perk ) const; ///< what the grade holds of the kind, 0 for nothing+ Real auraRadius( Int grade ) const; ///< m_auraRadius times the AURA_RADIUS perk+ Real aura( Int grade, RankAura aura ) const; ///< what a leader of this grade gives; RALLY is its death rallystatic Int unitValue( const ThingTemplate *thing ); ///< E: the regular ExperienceValue, else half the Veteran threshold, at least 1};@@ -612,6 +657,9 @@ public:Int m_rankCrateGrades; ///< grades a veterancy crate gives per EA level it would haveWeaponBonusSet* m_veterancyWeaponBonus[VETERANCY_SIDE_COUNT]; ///< NULL: nothing beyond the gradeUnsignedInt m_veterancySelfRepairDelay; ///< frames unhurt before self-repair starts+ Real m_rankAuraRateOfFireCap; ///< the most a rate-of-fire aura adds+ UnsignedInt m_rankRallyTime; ///< frames a death rally lasts+ RadiusDecalTemplate m_rankAuraRing[RANK_AURA_COUNT]; ///< the ground ring under a selected leader, one per aura kind (client)static VeterancySide veterancySideOf( const ThingTemplate *thing );const RankLadder *getRankLadder( const ThingTemplate *thing ) const; ///< NULL: the thing's side keeps EA's levelsdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 7be6e0d5e..cbf7e70e6 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1265,6 +1265,7 @@ protected:void destroyPlacementIcons( void ); ///< Destroy placement iconsvoid handleBuildPlacements( void ); ///< handle updating of placement icons based on mouse posvoid handleRadiusCursor(); ///< handle updating of "radius cursors" that follow the mouse pos+ void updateAuraRings(); ///< the ground ring of each aura a selected or hovered leader givesvoid incrementSelectCount( void ) { ++m_selectCount; } ///< Increase by one the running total of "selected" drawablesvoid decrementSelectCount( void ) { --m_selectCount; } ///< Decrease by one the running total of "selected" drawables@@ -1553,6 +1554,16 @@ protected:RadiusDecal m_curRadiusCursor;RadiusCursorType m_curRcType;+ enum { AURA_RING_MAX = 32 };+ struct AuraRing+ {+ ObjectID id; ///< INVALID_ID: a free slot+ Int kind; ///< RankAura+ Real radius; ///< as drawn+ RadiusDecal decal;+ };+ AuraRing m_auraRings[AURA_RING_MAX];+//Floating Text DataFloatingTextList m_floatingTextList; ///< Our list of floating textUnsignedInt m_floatingTextTimeOut; ///< Ini value of our floating text timeoutdiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h b/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.hindex 915be0cb8..65f268c96 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/RadiusDecal.h@@ -78,6 +78,7 @@ private:UnsignedInt m_opacityThrobTime;Color m_color;Bool m_onlyVisibleToOwningPlayer;+ Int m_spinTime; ///< milliseconds a turn takes, below 0 the other way; 0 stands stillpublic:RadiusDecalTemplate();diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.hindex 1ca382eed..590c9eb87 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h@@ -179,8 +179,8 @@ inline void Shadow::setOpacity(Int value){Real fvalue=(Real)m_opacity/255.0f;m_diffuse=REAL_TO_INT(((Real)(m_color & 0xff) * fvalue))- |REAL_TO_INT(((Real)((m_color >> 8) & 0xff) * fvalue))- |REAL_TO_INT(((Real)((m_color >> 16) & 0xff) * fvalue));+ |(REAL_TO_INT(((Real)((m_color >> 8) & 0xff) * fvalue)) << 8)+ |(REAL_TO_INT(((Real)((m_color >> 16) & 0xff) * fvalue)) << 16);}}}@@ -199,8 +199,8 @@ inline void Shadow::setColor(Color value){Real fvalue=(Real)m_opacity/255.0f;m_diffuse=REAL_TO_INT(((Real)(m_color & 0xff) * fvalue))- |REAL_TO_INT(((Real)((m_color >> 8) & 0xff) * fvalue))- |REAL_TO_INT(((Real)((m_color >> 16) & 0xff) * fvalue));+ |(REAL_TO_INT(((Real)((m_color >> 8) & 0xff) * fvalue)) << 8)+ |(REAL_TO_INT(((Real)((m_color >> 16) & 0xff) * fvalue)) << 16);}}}diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex c0754c6b7..7751321a2 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -39,6 +39,7 @@#include "Common/Snapshot.h"#include "Common/SpecialPowerMaskType.h"#include "Common/DisabledTypes.h"+#include "Common/GlobalData.h" // RankPerk, RankAura#include "Common/Thing.h"#include "Common/ObjectStatusTypes.h"#include "Common/Upgrade.h"@@ -297,6 +298,18 @@ public:VeterancyLevel getVeterancyLevel() const;Int getRankGrade() const; ///< my grade on my side's rank ladder; 0 without one+ // the ladder's perks and the auras leaders give (RankPerk, RankAura in GlobalData.h)+ Real getRankPerk( RankPerk perk ) const; ///< what my grade carries, 0 without a ladder+ Real getRankAura( RankAura aura ) const; ///< the strongest leader's on me now+ void clearRankAuras(); ///< the once-a-second pass starts over; RALLY runs on+ void raiseRankAura( RankAura aura, Real strength ); ///< a leader has me in range; the stronger stays+ void raiseRankRally( Real strength, UnsignedInt until ); ///< a fallen leader's rally; the stronger stays, the later end+ Real getRankSightScalar() const; ///< my own sight perk times the sight aura on me+ Real getRankDamageTakenScalar() const; ///< guard, rally and the still guard perk, multiplied+ Bool isSpotter() const; ///< SpotterSight on the template, or the SPOTTER perk+ void onRankSightChanged( Real oldScalar ); ///< look again if the rank sight moved+ void giveRankRally(); ///< I fell: my death rally reaches the allies around me+inline const AsciiString& getName() const { return m_name; }inline void setName( const AsciiString& newName ) { m_name = newName; }@@ -797,6 +810,8 @@ private:Real m_shroudClearingRange; ///< looking range for shroud ONLYReal m_shroudRange; ///< like looking range, this is how far I shroud others' looksInt m_sightJammerCount; ///< enemy jammers in whose field this stands; above zero its sight shrinks to a few feet+ Real m_rankAura[ RANK_AURA_COUNT ]; ///< the strongest leader's of each kind, refilled once a second+ UnsignedInt m_rankRallyUntil; ///< the frame the death rally on me endsDisabledMaskType m_disabledMask;UnsignedInt m_disabledTillFrame[ DISABLED_COUNT ];diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex e77747cf3..17de244b2 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -115,6 +115,29 @@ static void parseLadderPercents( INI *ini, void *, void *store, const void *memb*(Real *)( (char *)( (RankLadder *)store + side ) + (size_t)member ) = INI::scanPercentToReal( ini->getNextToken() );}+const char *const TheRankPerkNames[RANK_PERK_COUNT + 1] =+{+ "SIGHT", "STILL_GUARD", "MEND", "SPOTTER", "SCATTER", "DEATH_RALLY", "DETECT", "AURA_RADIUS",+ "AURA_RATE_OF_FIRE", "AURA_SIGHT", "AURA_GUARD", "AURA_RANGE", NULL+};++const char *const TheRankAuraNames[RANK_AURA_COUNT] = { "RateOfFire", "Sight", "Guard", "Range", "Rally" };++// Perk_<side> = grade kind [value]: a percent, a plain number (DETECT's radius), or nothing for 1+// (SPOTTER). userData is the side, store is m_rankLadder.+static void parseLadderPerk( INI *ini, void *, void *store, const void *side )+{+ const Int grade = INI::scanInt( ini->getNextToken() );+ const Int perk = INI::scanIndexList( ini->getNextToken(), TheRankPerkNames );+ const char *token = ini->getNextTokenOrNull();+ if( grade < 0 || grade > RANK_GRADES_MAX )+ throw INI_INVALID_DATA;+ Real value = 1.0f;+ if( token )+ value = token[ strlen( token ) - 1 ] == '%' ? INI::scanPercentToReal( token ) : INI::scanReal( token );+ ( (RankLadder *)store + (size_t)side )->m_perkAt[ grade ][ perk ] = value;+}+#define LADDER_FIELD( token, parser, member ) \{ token, parser, (const void *)offsetof( RankLadder, member ), offsetof( GlobalData, m_rankLadder ) }@@ -134,6 +157,18 @@ static const FieldParse theVeterancyFieldParseTable[] =LADDER_FIELD( "Range", parseLadderPercents, m_statTop[RANK_STAT_RANGE] ),LADDER_FIELD( "Speed", parseLadderPercents, m_statTop[RANK_STAT_SPEED] ),LADDER_FIELD( "SelfRepair", parseLadderPercents, m_statTop[RANK_STAT_SELF_REPAIR] ),+ LADDER_FIELD( "AuraRadius", parseLadderReals, m_auraRadius ),+ { "Perk_America", parseLadderPerk, (const void *)VETERANCY_SIDE_AMERICA, offsetof( GlobalData, m_rankLadder ) },+ { "Perk_China", parseLadderPerk, (const void *)VETERANCY_SIDE_CHINA, offsetof( GlobalData, m_rankLadder ) },+ { "Perk_GLA", parseLadderPerk, (const void *)VETERANCY_SIDE_GLA, offsetof( GlobalData, m_rankLadder ) },+ { "Perk_Turkiye", parseLadderPerk, (const void *)VETERANCY_SIDE_TURKIYE, offsetof( GlobalData, m_rankLadder ) },+ { "AuraRateOfFireCap", INI::parsePercentToReal, NULL, offsetof( GlobalData, m_rankAuraRateOfFireCap ) },+ { "RallyTime", INI::parseDurationUnsignedInt, NULL, offsetof( GlobalData, m_rankRallyTime ) },+ { "AuraRing_RateOfFire", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( GlobalData, m_rankAuraRing[RANK_AURA_RATE_OF_FIRE] ) },+ { "AuraRing_Sight", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( GlobalData, m_rankAuraRing[RANK_AURA_SIGHT] ) },+ { "AuraRing_Guard", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( GlobalData, m_rankAuraRing[RANK_AURA_GUARD] ) },+ { "AuraRing_Range", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( GlobalData, m_rankAuraRing[RANK_AURA_RANGE] ) },+ { "AuraRing_Rally", RadiusDecalTemplate::parseRadiusDecalTemplate, NULL, offsetof( GlobalData, m_rankAuraRing[RANK_AURA_RALLY] ) },{ "WorthGain", INI::parseReal, NULL, offsetof( GlobalData, m_rankWorthGain ) },{ "CrateGrades", INI::parseInt, NULL, offsetof( GlobalData, m_rankCrateGrades ) },{ "WeaponBonus_America", parseVeterancyWeaponBonus, NULL, offsetof( GlobalData, m_veterancyWeaponBonus[VETERANCY_SIDE_AMERICA] ) },@@ -171,11 +206,14 @@ void RankLadder::clear()m_ratio = 1.0f;for( Int stat = 0; stat < RANK_STAT_COUNT; ++stat )m_statTop[ stat ] = stat == RANK_STAT_SELF_REPAIR ? 0.0f : 1.0f;+ m_auraRadius = 0.0f;for( Int grade = 0; grade <= RANK_GRADES_MAX; ++grade ){m_total[ grade ] = (Real)grade;for( Int stat = 0; stat < RANK_STAT_COUNT; ++stat )m_stat[ grade ][ stat ] = stat == RANK_STAT_SELF_REPAIR ? 0.0f : 1.0f;+ for( Int perk = 0; perk < RANK_PERK_COUNT; ++perk )+ m_perkAt[ grade ][ perk ] = m_perk[ grade ][ perk ] = 0.0f;}}@@ -246,6 +284,8 @@ void RankLadder::finish( Real worthGain )for( Int stat = 0; stat < RANK_STAT_COUNT; ++stat )m_stat[ grade ][ stat ] = stat == RANK_STAT_SELF_REPAIR ? (Real)( m_statTop[ stat ] * share ): (Real)rankExp( share * rankLn( (double)m_statTop[ stat ] ) );+ for( Int perk = 0; perk < RANK_PERK_COUNT; ++perk )+ m_perk[ grade ][ perk ] = MAX( m_perkAt[ grade ][ perk ], grade > 0 ? m_perk[ grade - 1 ][ perk ] : 0.0f );}}@@ -290,6 +330,24 @@ Int RankLadder::insigniaIndex( Int grade, Bool hero ) constreturn m_heroStart + ( m_grades - m_heroStart ) * grade / m_grades;}+//-------------------------------------------------------------------------------------------------+Real RankLadder::perk( Int grade, RankPerk perk ) const+{+ return m_perk[ MIN( grade, MAX( m_grades, 0 ) ) ][ perk ];+}++//-------------------------------------------------------------------------------------------------+Real RankLadder::auraRadius( Int grade ) const+{+ return m_auraRadius * MAX( 1.0f, perk( grade, RANK_PERK_AURA_RADIUS ) );+}++//-------------------------------------------------------------------------------------------------+Real RankLadder::aura( Int grade, RankAura aura ) const+{+ return perk( grade, aura == RANK_AURA_RALLY ? RANK_PERK_DEATH_RALLY : (RankPerk)( RANK_PERK_AURA_RATE_OF_FIRE + aura ) );+}+//-------------------------------------------------------------------------------------------------/*static*/ Int RankLadder::unitValue( const ThingTemplate *thing ){@@ -1361,6 +1419,8 @@ GlobalData::GlobalData()m_rankWorthGain = 1.4f;m_rankCrateGrades = 3;m_veterancySelfRepairDelay = 0;+ m_rankAuraRateOfFireCap = 0.0f;+ m_rankRallyTime = 0;m_shellMapName.set("Maps\\ShellMap1\\ShellMap1.map");m_shellMapOn =TRUE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 6bd8fda9b..c39cacbec 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -167,6 +167,23 @@ static void portraitRankTooltip( GameWindow *window, WinInstanceData *instData,label.format( "RANK:%s%d", TheVeterancySideNames[ GlobalData::veterancySideOf( obj->getTemplate() ) ],ladder->insigniaIndex( grade, obj->isKindOf( KINDOF_HERO ) ) );UnicodeString text = TheGameText->fetch( label );++ // what the grade carries, one line a perk: RANK:Perk<kind> takes the strength as a whole percent+ // (a radius for DETECT, a multiple's gain for SIGHT and AURA_RADIUS)+ for( Int perk = 0; perk < RANK_PERK_COUNT; ++perk )+ {+ Real value = ladder->perk( grade, (RankPerk)perk );+ if( value <= 0.0f )+ continue;+ if( perk == RANK_PERK_SIGHT || perk == RANK_PERK_AURA_RADIUS )+ value -= 1.0f;+ label.format( "RANK:Perk%s", TheRankPerkNames[ perk ] );+ UnicodeString line;+ line.format( TheGameText->fetch( label ), REAL_TO_INT( perk == RANK_PERK_DETECT ? value : value * 100.0f + 0.5f ) );+ text.concat( (WideChar)'\n' );+ text.concat( line );+ }+if( grade < ladder->m_grades ){const Int unitValue = RankLadder::unitValue( obj->getTemplate() );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex daa6cc940..2d9159b36 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -1067,6 +1067,9 @@ InGameUI::InGameUI(){Int i;+ for( i = 0; i < AURA_RING_MAX; ++i )+ m_auraRings[ i ].id = INVALID_ID;+for( i = 0; i < MAX_MOVE_HINTS; i++ ){m_moveHint[ i ].pos.zero();@@ -1500,6 +1503,90 @@ void InGameUI::setRadiusCursor(RadiusCursorType cursorType, const SpecialPowerTehandleRadiusCursor();}+//-------------------------------------------------------------------------------------------------+/** A leader's auras on the ground: one ring for each kind it gives, under a selected or hovered+ * leader of the player at this machine or an ally, while that player can see it. Each further ring+ * of one leader is drawn a little inside the one before, so four of them do not lie on one line.+ * Reads the logic's grades and draws; nothing goes back. */+//-------------------------------------------------------------------------------------------------+void InGameUI::updateAuraRings()+{+ struct Wanted { ObjectID id; Int kind; Real radius; Coord3D pos; };+ Wanted wanted[ AURA_RING_MAX ];+ Int wantedCount = 0;++ Player *local = ThePlayerList->getLocalPlayer();+ auto consider = [&]( const Drawable *draw )+ {+ const Object *obj = draw ? draw->getObject() : NULL;+ const RankLadder *ladder = obj ? TheGlobalData->getRankLadder( obj->getTemplate() ) : NULL;+ if( ladder == NULL || local == NULL || obj->isEffectivelyDead()+ || ( obj->getControllingPlayer() != local && local->getRelationship( obj->getTeam() ) != ALLIES )+ || obj->getShroudedStatus( local->getPlayerIndex() ) != OBJECTSHROUD_CLEAR )+ return;+ const Int grade = obj->getRankGrade();+ Int shown = 0;+ for( Int kind = 0; kind < RANK_AURA_COUNT && wantedCount < AURA_RING_MAX; ++kind )+ {+ if( ladder->aura( grade, (RankAura)kind ) <= 0.0f || !TheGlobalData->m_rankAuraRing[ kind ].valid() )+ continue;+ Bool twice = FALSE; // the hovered leader may be selected too+ for( Int i = 0; i < wantedCount; ++i )+ twice = twice || ( wanted[ i ].id == obj->getID() && wanted[ i ].kind == kind );+ if( twice )+ continue;+ // ponytail: the inset makes an inner ring a little short of the real reach; one radius for all kinds today+ wanted[ wantedCount ].id = obj->getID();+ wanted[ wantedCount ].kind = kind;+ wanted[ wantedCount ].radius = ladder->auraRadius( grade ) * ( 1.0f - 0.05f * shown++ );+ wanted[ wantedCount ].pos = *draw->getPosition();+ ++wantedCount;+ }+ };+ consider( TheGameClient->findDrawableByID( getMousedOverDrawableID() ) );+ for( DrawableList::const_iterator it = m_selectedDrawables.begin(); it != m_selectedDrawables.end(); ++it )+ consider( *it );++ // a ring nobody wants goes; one whose radius changed goes too and comes back at the new size+ for( Int slot = 0; slot < AURA_RING_MAX; ++slot )+ {+ AuraRing &ring = m_auraRings[ slot ];+ if( ring.id == INVALID_ID )+ continue;+ Bool keep = FALSE;+ for( Int i = 0; i < wantedCount && !keep; ++i )+ keep = wanted[ i ].id == ring.id && wanted[ i ].kind == ring.kind && wanted[ i ].radius == ring.radius;+ if( !keep )+ {+ ring.decal.clear();+ ring.id = INVALID_ID;+ }+ }++ for( Int i = 0; i < wantedCount; ++i )+ {+ Int slot = -1, freeSlot = -1;+ for( Int s = 0; s < AURA_RING_MAX; ++s )+ {+ if( m_auraRings[ s ].id == wanted[ i ].id && m_auraRings[ s ].kind == wanted[ i ].kind )+ slot = s;+ else if( m_auraRings[ s ].id == INVALID_ID && freeSlot < 0 )+ freeSlot = s;+ }+ if( slot < 0 )+ {+ slot = freeSlot;+ AuraRing &ring = m_auraRings[ slot ];+ ring.id = wanted[ i ].id;+ ring.kind = wanted[ i ].kind;+ ring.radius = wanted[ i ].radius;+ TheGlobalData->m_rankAuraRing[ ring.kind ].createRadiusDecal( wanted[ i ].pos, ring.radius, local, ring.decal );+ }+ m_auraRings[ slot ].decal.setPosition( wanted[ i ].pos );+ m_auraRings[ slot ].decal.update();+ }+}+//-------------------------------------------------------------------------------------------------/** handle updating of "radius cursors" that follow the mouse pos *///-------------------------------------------------------------------------------------------------@@ -2302,6 +2389,8 @@ void InGameUI::preDraw( void )// handle radius-cursors, if anyhandleRadiusCursor();+ updateAuraRings();+// where the selection is headed, read fresh from the units themselvesupdateOrderHints();@@ -2699,6 +2788,12 @@ void InGameUI::reset( void )}m_nextMoveHint = 0;+ for( Int i = 0; i < AURA_RING_MAX; ++i )+ {+ m_auraRings[ i ].id = INVALID_ID;+ m_auraRings[ i ].decal.clear();+ }+m_isQuitMenuVisible = FALSE;TheObserverCamera.reset();CinemaDirector_forgetHudHidden();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cppindex b862cc75c..0ab0de6de 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp@@ -54,6 +54,7 @@ RadiusDecalTemplate::RadiusDecalTemplate() :m_opacityThrobTime(LOGICFRAMES_PER_SECOND),m_color(0),m_onlyVisibleToOwningPlayer(true),+ m_spinTime(0),m_name(AsciiString::TheEmptyString) // Added By Sadullah Nader for Init purposes{}@@ -132,6 +133,7 @@ void RadiusDecalTemplate::xferRadiusDecalTemplate( Xfer *xfer ){ "OpacityThrobTime", INI::parseDurationUnsignedInt,NULL, offsetof( RadiusDecalTemplate, m_opacityThrobTime ) },{ "Color", INI::parseColorInt, NULL, offsetof( RadiusDecalTemplate, m_color ) },{ "OnlyVisibleToOwningPlayer", INI::parseBool, NULL, offsetof( RadiusDecalTemplate, m_onlyVisibleToOwningPlayer ) },+ { "SpinTime", INI::parseInt, NULL, offsetof( RadiusDecalTemplate, m_spinTime ) },{ 0, 0, 0, 0 }};@@ -217,6 +219,14 @@ void RadiusDecal::update()opac = 0;}m_decal->setOpacity(opac);++ // a turn every SpinTime, on the logic clock like the throb, so a paused game holds it still+ if (m_template->m_spinTime != 0)+ {+ const UnsignedInt period = MAX(1, abs(m_template->m_spinTime) * LOGICFRAMES_PER_SECOND / 1000);+ const Real angle = (2*PI) * (Real)(now % period) / (Real)period;+ m_decal->setAngle(m_template->m_spinTime > 0 ? angle : -angle);+ }}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cppindex 18f9fc6f3..354212a0e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp@@ -561,6 +561,8 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )// Apply the damage scalar (extra bonuses -- like strategy center defensive battle plan)// And remember not to adjust unresistable damage, just like the armor code can't.amount *= m_damageScalar;+ // a leader's guard aura, a fallen leader's rally, a rank's guard standing still+ amount *= obj->getRankDamageTakenScalar();}// one hit kill: anything that got through the armour at all takes the whole bardiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 899d26f7d..91d3d2ced 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -307,6 +307,9 @@ Object::Object( const ThingTemplate *tt, const ObjectStatusMaskType &objectStatum_shroudClearingRange = m_visionRange;// Backwards compatible, and perfectly logical default to assignm_shroudRange = 0.0f;m_sightJammerCount = 0;+ for( Int aura = 0; aura < RANK_AURA_COUNT; ++aura )+ m_rankAura[ aura ] = 0.0f;+ m_rankRallyUntil = 0;m_singleUseCommandUsed = false;@@ -3506,6 +3509,12 @@ void Object::onRankChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, InDEBUG_LOG(("RANK frame=%d template=%s grade %d to %d xp=%d\n", TheGameLogic->getFrame(), getTemplate()->getName().str(),oldGrade, newGrade, getExperienceTracker()->getCurrentExperience()));+ // the sight and spotter perks change how far it looks; one born on a pin has not looked yet+ if( !m_partitionLastLook->isInvalid()+ && ( ladder->perk( oldGrade, RANK_PERK_SIGHT ) != ladder->perk( newGrade, RANK_PERK_SIGHT )+ || ladder->perk( oldGrade, RANK_PERK_SPOTTER ) != ladder->perk( newGrade, RANK_PERK_SPOTTER ) ) )+ handleShroud();+if( newGrade > oldGrade && provideFeedback && TheGameLogic->getDrawIconUI() && isLogicallyVisible() && !isKindOf( KINDOF_IGNORED_IN_GUI )&& Drawable::getRankInsignia( this ) != NULL )floatRankGain( ladder->insigniaIndex( newGrade, isKindOf( KINDOF_HERO ) ) );@@ -4502,13 +4511,14 @@ void Object::crc( Xfer *xfer )* 11: the cached angle, which the matrix does not give back bit for bit* 12: the last threat and value sightings* 13: how many enemy jammers are cutting its sight+ * 14: the rank auras on it and when its death rally ends*///-------------------------------------------------------------------------------------------------void Object::xfer( Xfer *xfer ){// version- const XferVersion currentVersion = 13;+ const XferVersion currentVersion = 14;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -4972,6 +4982,13 @@ void Object::xfer( Xfer *xfer )if( version >= 13 )xfer->xferInt( &m_sightJammerCount );+ if( version >= 14 )+ {+ for( Int aura = 0; aura < RANK_AURA_COUNT; ++aura )+ xfer->xferReal( &m_rankAura[ aura ] );+ xfer->xferUnsignedInt( &m_rankRallyUntil );+ }+} // end xfer//-------------------------------------------------------------------------------------------------@@ -5129,6 +5146,8 @@ void Object::onDie( DamageInfo *damageInfo )Bool selfInflicted = (damageInfo->in.m_sourceID == getID());+ giveRankRally();+//// FIRST, call our die modules - unless nothing has been built here yet, in which case they are// exactly what must not run: the die modules are the explosion, the collapse and the rubble of a@@ -5509,6 +5528,99 @@ void Object::removeSightJammer()handleShroud();}+//-------------------------------------------------------------------------------------------------+Real Object::getRankPerk( RankPerk perk ) const+{+ const RankLadder *ladder = TheGlobalData->getRankLadder( getTemplate() );+ return ladder ? ladder->perk( getRankGrade(), perk ) : 0.0f;+}++//-------------------------------------------------------------------------------------------------+Real Object::getRankAura( RankAura aura ) const+{+ if( aura == RANK_AURA_RALLY && TheGameLogic->getFrame() >= m_rankRallyUntil )+ return 0.0f;+ return m_rankAura[ aura ];+}++//-------------------------------------------------------------------------------------------------+void Object::clearRankAuras()+{+ for( Int aura = 0; aura < RANK_AURA_PASSED; ++aura )+ m_rankAura[ aura ] = 0.0f;+}++//-------------------------------------------------------------------------------------------------+void Object::raiseRankAura( RankAura aura, Real strength )+{+ m_rankAura[ aura ] = MAX( m_rankAura[ aura ], strength );+}++//-------------------------------------------------------------------------------------------------+void Object::raiseRankRally( Real strength, UnsignedInt until )+{+ m_rankAura[ RANK_AURA_RALLY ] = MAX( getRankAura( RANK_AURA_RALLY ), strength );+ m_rankRallyUntil = MAX( m_rankRallyUntil, until );+}++//-------------------------------------------------------------------------------------------------+Real Object::getRankSightScalar() const+{+ return MAX( 1.0f, getRankPerk( RANK_PERK_SIGHT ) ) * ( 1.0f + m_rankAura[ RANK_AURA_SIGHT ] );+}++//-------------------------------------------------------------------------------------------------+/** Standing still is not walking a path: a tank turning its turret on the spot holds its guard. */+//-------------------------------------------------------------------------------------------------+Real Object::getRankDamageTakenScalar() const+{+ Real scalar = ( 1.0f - m_rankAura[ RANK_AURA_GUARD ] ) * ( 1.0f - getRankAura( RANK_AURA_RALLY ) );+ const Real still = getRankPerk( RANK_PERK_STILL_GUARD );+ if( still > 0.0f && !( m_ai && m_ai->isMoving() ) )+ scalar *= 1.0f - still;+ return scalar;+}++//-------------------------------------------------------------------------------------------------+Bool Object::isSpotter() const+{+ return getTemplate()->hasSpotterSight() || getRankPerk( RANK_PERK_SPOTTER ) > 0.0f;+}++//-------------------------------------------------------------------------------------------------+void Object::onRankSightChanged( Real oldScalar )+{+ if( getRankSightScalar() != oldScalar && !m_partitionLastLook->isInvalid() )+ handleShroud();+}++//-------------------------------------------------------------------------------------------------+/** A fallen leader's last order: the allies within its aura radius take less damage for RallyTime.+ * The list walk is the object list's own order; the strongest rally stays, so order is moot. */+//-------------------------------------------------------------------------------------------------+void Object::giveRankRally()+{+ const RankLadder *ladder = TheGlobalData->getRankLadder( getTemplate() );+ if( ladder == NULL )+ return;+ const Int grade = getRankGrade();+ const Real strength = ladder->aura( grade, RANK_AURA_RALLY );+ if( strength <= 0.0f )+ return;+ const Real radius = ladder->auraRadius( grade );+ const UnsignedInt until = TheGameLogic->getFrame() + TheGlobalData->m_rankRallyTime;+ for( Object *other = TheGameLogic->getFirstObject(); other; other = other->getNextObject() )+ {+ if( other == this || other->isEffectivelyDead() || other->isKindOf( KINDOF_STRUCTURE )+ || getRelationship( other ) != ALLIES+ || ThePartitionManager->getDistanceSquared( this, other, FROM_CENTER_2D ) > radius * radius )+ continue;+ other->raiseRankRally( strength, until );+ }+ DEBUG_LOG(("RANK RALLY frame=%d template=%s strength=%.2f radius=%.0f\n", TheGameLogic->getFrame(),+ getTemplate()->getName().str(), strength, radius));+}+//-------------------------------------------------------------------------------------------------void Object::look(){@@ -5545,8 +5657,10 @@ void Object::look()// was blind: it keeps its template's sight. So does a spotter, whose sight is its job and// whose carbine is for showReal shroudClearingRange = getShroudClearingRange();- if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) && !getTemplate()->hasSpotterSight() )+ if( !isKindOf( KINDOF_STRUCTURE ) && !isKindOf( KINDOF_DOZER ) && !isSpotter() )shroudClearingRange = Object_armedShroudClearingRange( shroudClearingRange, getLargestWeaponRange() );+ // a rank's eyes and a leader's sight aura reach past the weapon cap; onRankSightChanged looks again+ shroudClearingRange *= getRankSightScalar();if( isSightJammed() )shroudClearingRange = min( shroudClearingRange, JAMMED_SHROUD_CLEARING_RANGE );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cppindex f5d6974f4..2c3bee491 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/JammerUpdate.cpp@@ -127,7 +127,7 @@ UpdateSleepTime JammerUpdate::update( void )continue;}- if( obj->isKindOf( KINDOF_DRONE ) || obj->getTemplate()->hasSpotterSight() )+ if( obj->isKindOf( KINDOF_DRONE ) || obj->isSpotter() )inField.push_back( obj->getID() );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex 97cb7e697..e57e52341 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -1090,6 +1090,10 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate//victimObj = NULL; // his position is already in victimPos, if he existed+ // a rank's steadier hand on the guns+ if( sourceObj )+ scatterRadius *= 1.0f - sourceObj->getRankPerk( RANK_PERK_SCATTER );+//Randomize the scatter radius (sometimes it can be more accurate than others)scatterRadius = GameLogicRandomValueReal( 0, scatterRadius );Real scatterAngleRadian = GameLogicRandomValueReal( 0, 2*PI );@@ -2151,6 +2155,15 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraB}else if (TheGlobalData->m_weaponBonusSet)TheGlobalData->m_weaponBonusSet->appendBonuses(flags, bonus);++ // a leader's auras reach any friendly unit, on a ladder or not; range only an artillery piece's+ const Real auraRateOfFire = MIN(source->getRankAura(RANK_AURA_RATE_OF_FIRE), TheGlobalData->m_rankAuraRateOfFireCap);+ if (auraRateOfFire > 0.0f)+ bonus.setField(WeaponBonus::RATE_OF_FIRE, bonus.getField(WeaponBonus::RATE_OF_FIRE) + auraRateOfFire);+ const Real auraRange = source->getRankAura(RANK_AURA_RANGE);+ if (auraRange > 0.0f && (sourceTemplate->acquiresBeyondVision() || m_template->getMinimumAttackRange() > 0.0f))+ bonus.setField(WeaponBonus::RANGE, bonus.getField(WeaponBonus::RANGE) + auraRange);+const WeaponBonusSet* extra = m_template->getExtraBonus();if (extra)extra->appendBonuses(flags, bonus);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cppindex e393ef811..7f0125235 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp@@ -3906,6 +3906,82 @@ static void unitTimings(void)}#endif+//-------------------------------------------------------------------------------------------------+/** The rank auras, once a second (docs/plans/RANK-LADDER.md in the wrapper). Every unit's slots are+ * cleared, then each leader writes its strength into the slots of the friendly units within its+ * radius, keeping the larger, so three leaders of one kind give the strongest one's and the walk's+ * order does not matter. A leader never reaches itself, and buildings take nothing. The DETECT+ * perk works here too: a stealthed enemy within its radius stays detected until the next pass.+ * A unit whose sight moved looks again. */+//-------------------------------------------------------------------------------------------------+static void updateRankAuras( Object *objList )+{+ struct Before { Real sight; Real aura[ RANK_AURA_PASSED ]; };+ static std::vector<Before> before;+ before.clear();+ for( Object *obj = objList; obj; obj = obj->getNextObject() )+ {+ Before was;+ was.sight = obj->getRankSightScalar();+ for( Int aura = 0; aura < RANK_AURA_PASSED; ++aura )+ was.aura[ aura ] = obj->getRankAura( (RankAura)aura );+ before.push_back( was );+ obj->clearRankAuras();+ }++ for( Object *leader = objList; leader; leader = leader->getNextObject() )+ {+ const RankLadder *ladder = TheGlobalData->getRankLadder( leader->getTemplate() );+ if( ladder == NULL || leader->isEffectivelyDead() || leader->testStatus( OBJECT_STATUS_UNDER_CONSTRUCTION ) )+ continue;+ const Int grade = leader->getRankGrade();+ Real strength[ RANK_AURA_PASSED ];+ Bool gives = FALSE;+ for( Int aura = 0; aura < RANK_AURA_PASSED; ++aura )+ {+ strength[ aura ] = ladder->aura( grade, (RankAura)aura );+ gives = gives || strength[ aura ] > 0.0f;+ }+ const Real detect = ladder->perk( grade, RANK_PERK_DETECT );+ if( !gives && detect <= 0.0f )+ continue;++ const Real radius = ladder->auraRadius( grade );+ const Coord3D *at = leader->getPosition();+ for( Object *other = objList; other; other = other->getNextObject() )+ {+ if( other == leader || other->isEffectivelyDead() )+ continue;+ const Real dx = other->getPosition()->x - at->x, dy = other->getPosition()->y - at->y;+ const Real distSqr = dx * dx + dy * dy;+ if( detect > 0.0f && distSqr <= detect * detect && other->getStealth()+ && other->testStatus( OBJECT_STATUS_STEALTHED ) && leader->getRelationship( other ) == ENEMIES )+ other->getStealth()->markAsDetected( LOGICFRAMES_PER_SECOND + 1 );+ if( !gives || distSqr > radius * radius || other->isKindOf( KINDOF_STRUCTURE )+ || leader->getRelationship( other ) != ALLIES )+ continue;+ for( Int aura = 0; aura < RANK_AURA_PASSED; ++aura )+ if( strength[ aura ] > 0.0f )+ other->raiseRankAura( (RankAura)aura, strength[ aura ] );+ }+ }++ // a unit that came into or left a leader's reach logs what it holds now+ size_t index = 0;+ for( Object *obj = objList; obj; obj = obj->getNextObject(), ++index )+ {+ Bool moved = FALSE;+ for( Int aura = 0; aura < RANK_AURA_PASSED; ++aura )+ moved = moved || obj->getRankAura( (RankAura)aura ) != before[ index ].aura[ aura ];+ if( moved )+ DEBUG_LOG(("RANK AURA frame=%d id=%d template=%s grade=%d rof=%.2f sight=%.2f guard=%.2f range=%.2f\n",+ TheGameLogic->getFrame(), obj->getID(), obj->getTemplate()->getName().str(), obj->getRankGrade(),+ obj->getRankAura( RANK_AURA_RATE_OF_FIRE ), obj->getRankAura( RANK_AURA_SIGHT ),+ obj->getRankAura( RANK_AURA_GUARD ), obj->getRankAura( RANK_AURA_RANGE )));+ obj->onRankSightChanged( before[ index ].sight );+ }+}+DECLARE_PERF_TIMER(GameLogic_update)DECLARE_PERF_TIMER(GameLogic_update_normal)DECLARE_PERF_TIMER(GameLogic_update_sleepy)@@ -5033,11 +5109,14 @@ void GameLogic::update( void )// Faction veterancy's self-repair (GLA): once a second a ranked unit that has gone unhurt for// the Veterancy block's SelfRepairDelay heals its side's share of its max health. Healing itself earns it// nothing (Object::scoreTheHeal).+ // A grade's MEND perk is the same heal at its own rate.if( m_frame % LOGICFRAMES_PER_SECOND == 0 ){+ updateRankAuras( m_objList );for( Object *obj = m_objList; obj; obj = obj->getNextObject() ){- const Real share = TheGlobalData->getRankStat( obj->getTemplate(), obj->getRankGrade(), RANK_STAT_SELF_REPAIR );+ const Real share = MAX( TheGlobalData->getRankStat( obj->getTemplate(), obj->getRankGrade(), RANK_STAT_SELF_REPAIR ),+ obj->getRankPerk( RANK_PERK_MEND ) );if( share <= 0.0f || obj->isEffectivelyDead() )continue;const BodyModuleInterface *body = obj->getBodyModule();diff --git a/GeneralsMD/Code/Tests/test_rank_ladder.cpp b/GeneralsMD/Code/Tests/test_rank_ladder.cppindex 8870c658d..09c552151 100644--- a/GeneralsMD/Code/Tests/test_rank_ladder.cpp+++ b/GeneralsMD/Code/Tests/test_rank_ladder.cpp@@ -159,3 +159,42 @@ TEST(rank_ladder_hero_insignia_runs_from_its_start_to_the_top)CHECK_EQ( china().insigniaIndex( 0, TRUE ), 15 );CHECK_EQ( china().insigniaIndex( 19, TRUE ), 19 );}++TEST(rank_ladder_perks_carry_up_and_the_strongest_of_a_kind_holds)+{+ /* Turkiye's Perk_ lines: sight 110%, 120%, 130% at 3, 8, 18; the rate-of-fire aura 5% at 10, 10% at 16 */+ RankLadder ladder;+ ladder.clear();+ ladder.m_grades = 21;+ ladder.m_top = 120.0f;+ ladder.m_pin[LEVEL_VETERAN] = 4;+ ladder.m_pin[LEVEL_ELITE] = 11;+ ladder.m_pin[LEVEL_HEROIC] = 16;+ ladder.m_auraRadius = 150.0f;+ ladder.m_perkAt[ 3 ][ RANK_PERK_SIGHT ] = 1.10f;+ ladder.m_perkAt[ 8 ][ RANK_PERK_SIGHT ] = 1.20f;+ ladder.m_perkAt[ 18 ][ RANK_PERK_SIGHT ] = 1.30f;+ ladder.m_perkAt[ 10 ][ RANK_PERK_AURA_RATE_OF_FIRE ] = 0.05f;+ ladder.m_perkAt[ 16 ][ RANK_PERK_AURA_RATE_OF_FIRE ] = 0.10f;+ ladder.m_perkAt[ 17 ][ RANK_PERK_DEATH_RALLY ] = 0.15f;+ ladder.m_perkAt[ 21 ][ RANK_PERK_AURA_RADIUS ] = 2.0f;+ ladder.finish( 1.4f );++ CHECK_EQ( ladder.perk( 2, RANK_PERK_SIGHT ), 0.0f );+ CHECK_NEAR( ladder.perk( 3, RANK_PERK_SIGHT ), 1.10f, 1e-6f );+ CHECK_NEAR( ladder.perk( 7, RANK_PERK_SIGHT ), 1.10f, 1e-6f );+ CHECK_NEAR( ladder.perk( 8, RANK_PERK_SIGHT ), 1.20f, 1e-6f );+ CHECK_NEAR( ladder.perk( 21, RANK_PERK_SIGHT ), 1.30f, 1e-6f );++ /* the Albay's 10% replaces the Bascavus's 5%, it does not add to it */+ CHECK_EQ( ladder.aura( 9, RANK_AURA_RATE_OF_FIRE ), 0.0f );+ CHECK_NEAR( ladder.aura( 10, RANK_AURA_RATE_OF_FIRE ), 0.05f, 1e-6f );+ CHECK_NEAR( ladder.aura( 16, RANK_AURA_RATE_OF_FIRE ), 0.10f, 1e-6f );+ CHECK_NEAR( ladder.aura( 17, RANK_AURA_RALLY ), 0.15f, 1e-6f );+ CHECK_EQ( ladder.aura( 16, RANK_AURA_RALLY ), 0.0f );++ /* the Maresal's double reach, and a grade past the top reads the top */+ CHECK_NEAR( ladder.auraRadius( 20 ), 150.0f, 1e-3f );+ CHECK_NEAR( ladder.auraRadius( 21 ), 300.0f, 1e-3f );+ CHECK_NEAR( ladder.auraRadius( 40 ), 300.0f, 1e-3f );+}