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): each side's veterans fight their own way
Olcay Seyganfb2444c7a4d4
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex aebcde5bf..49d00f48d 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,6 +8,15 @@ found and fixed — EA's own, not port damage.**---+## Each side's veterans fight their own way++- A promotion gave every unit in the game the same thing, whichever army trained it. Each side's ranks now carry a bonus of their own, paid for by giving back part of the old one, so a rank is still worth about what it was: rate of fire times damage times health stays within 5% of EA's at every rank before the side's own bonus is counted.+- An American veteran shoots 3% further, an elite 4% and a heroic 5%. Rank adds less health in return, 15%, 25% and 45% where it used to add 20%, 30% and 50%.+- Chinese ranks add more health, 25%, 40% and 65%, and less rate of fire, 15%, 30% and 45% where it was 20%, 40% and 60%. A ranked Chinese unit in a horde fires 10% faster again.+- GLA veterans move 5% faster, elites 7% and heroics 10%, and hit less hard for it, 5%, 15% and 25% extra damage where it was 10%, 20% and 30%. A ranked GLA unit that has gone five seconds without being hit mends itself, 1% of its health a second as a veteran, 1.5% as an elite and 2% as a heroic, on top of Junk Repair.+- Each side wears its rank its own way beside the health bar, where EA gave every army the same chevrons. America stacks gold bars, one under another. China counts gold stars and GLA skulls: one alone, two side by side, and a heroic's three as a triangle. A unit that gains a rank sends the same marks floating up over its head in place of the gold chevron.+- Every general's army takes its side's veterans. Replays recorded before this change play out differently.+## A new loading screen- Skirmish, LAN, online and replay loads show every player on a card: the general's portrait, or the side's crest for a plain side, the name in the player's colour, the army, and for a computer seat its difficulty and personality. Teams face each other in two columns with the map between them, its start spots drawn as the room draws them: the blue ring, filled with the player's colour and his seat number where the others may see who starts there. Three teams or more share the columns, and a game where everyone plays alone says Free for all.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 4545efdba..74f7f4639 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -28,6 +28,8 @@ Data/Art/Textures/ReforgedMineGlowBlue.tgaData/Art/Textures/ReforgedMineGlowRed.tgaData/Art/Textures/ReforgedMineLedBlue.tgaData/Art/Textures/ReforgedMineLedRed.tga+Data/Art/Textures/ReforgedRankBar.tga+Data/Art/Textures/ReforgedRankSkull.tgaData/Art/Textures/ReforgedSignalAttack.tgaData/Art/Textures/ReforgedSignalDefend.tgaData/Art/Textures/ReforgedSignalLook.tga@@ -146,6 +148,7 @@ Data/Cinema/v240_hook.txtData/Cinema/v240_hook2.txtData/Cinema/v240_md.txtData/Cinema/v240_tank.txt+Data/Cinema/vetranks.txtData/Cinema/wreckcheck.txtData/German/Generals.strData/INI/BalanceReforged.ini@@ -169,6 +172,7 @@ Data/INI/MappedImages/HandCreated/ReforgedHudHelpbox.iniData/INI/MappedImages/HandCreated/ReforgedHudObsCommandBar.iniData/INI/MappedImages/HandCreated/ReforgedHudObsPlayerWindow.iniData/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini+Data/INI/MappedImages/HandCreated/ReforgedRankInsignia.iniData/INI/ObjectCreationListReforged.iniData/INI/ParticleSystemReforged.iniData/INI/ScienceReforged.ini@@ -355,6 +359,7 @@ Data/Scenarios/v240_tank.txtData/Scenarios/vehicleaccel.txtData/Scenarios/vehiclelean.txtData/Scenarios/vehicleturn.txt+Data/Scenarios/vetranks.txtData/Scenarios/vision.txtData/Scenarios/wallgarrison.txtData/Scenarios/wreckcheck.txt@@ -4017,6 +4022,7 @@ Tools/package-common.shTools/packaging-resolution-check.shTools/peacetime_layout.pyTools/pink_laser.py+Tools/rank_insignia.pyTools/record-dx11-shaders.ps1Tools/replay-check.shTools/root-readonly-check.shdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRankBar.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRankBar.tganew file mode 100644index 000000000..191568d3dBinary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRankBar.tga differdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRankSkull.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRankSkull.tganew file mode 100644index 000000000..f4e3083b1Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRankSkull.tga differdiff --git a/GeneralsMD/Code/Data/Cinema/vetranks.txt b/GeneralsMD/Code/Data/Cinema/vetranks.txtnew file mode 100644index 000000000..29003e850--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/vetranks.txt@@ -0,0 +1,19 @@+# Scenarios/vetranks.txt: the three rows of rank insignia. No hud line: -cinema keeps the HUD+# only when told, and the icons need it, since with the HUD hidden Drawable::drawIconUI draws no+# health bar and no insignia. The cinema clock here reads about (logic frame + 14) / 60, so the+# walk south starts near 3.8 s; each close cut sits a little south of its row's spawn line.+# Pass 1 (zoom 0.4 relative, 0.49 absolute) was far too close: one tank in a corner.++0.0 hud on+# the rank-up float, about 110 logic frames after the rank lines (logic 24); it rises well above+# its unit, so this looks further north than the overview to keep the GLA row's float in frame+0.5 cut 3410 3990 1.4 0 0+2.0 shot+2.2 cut 3410 3930 1.25 0 0+4.4 shot+4.5 cut 3410 3780 0.7 0 0+4.8 shot+4.9 cut 3410 3925 0.7 0 0+5.2 shot+5.3 cut 3410 4075 0.7 0 0+5.6 shotdiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex 25fc066f7..23a6ea75f 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -1809,6 +1809,58 @@ Armor DemoGenTerroristArmorArmor = POISON 50%End+; ---- each side's veterans fight their own way ----------------------------------------------------+;+; EA gives every ranked unit the same thing (GameData.ini): Veteran +20% rate of fire, +10% damage,+; +20% health; Elite +40%, +20%, +30%; Heroic +60%, +30%, +50%. Each side here gives a share of+; that back and takes its own bonus for it, so a rank is worth about what it was: rate of fire+; times damage times health is within 5% of EA's at every rank, before the side's own bonus.+;+; USA, a tech army: less health, more range.+; China, a mass army: less rate of fire, more health, and ranked men in a horde fire faster still.+; GLA, hit and run: less damage, more speed, and repairs itself out of the fight.+;+; A unit's side is its template's Side, so every general's copy takes its side's table. A side's+; WeaponBonus lines stand in for EA's VETERAN, ELITE and HERO lines; HealthBonus is Veteran, Elite,+; Heroic and stands in for HealthBonus_*. SpeedBonus multiplies the unit's speed. SelfRepair is the+; share of max health healed a second once the unit has gone SelfRepairDelay milliseconds unhurt.+; Every unit keeps every way of earning a rank.++Veterancy+ ; USA: EA's fire, health 115/125/145 (EA 120/130/150), range +3/4/5%+ WeaponBonus_America = VETERAN RATE_OF_FIRE 120%+ WeaponBonus_America = VETERAN DAMAGE 110%+ WeaponBonus_America = VETERAN RANGE 103%+ WeaponBonus_America = ELITE RATE_OF_FIRE 140%+ WeaponBonus_America = ELITE DAMAGE 120%+ WeaponBonus_America = ELITE RANGE 104%+ WeaponBonus_America = HERO RATE_OF_FIRE 160%+ WeaponBonus_America = HERO DAMAGE 130%+ WeaponBonus_America = HERO RANGE 105%+ HealthBonus_America = 115% 125% 145%++ ; China: rate of fire 115/130/145 (EA 120/140/160), health 125/140/165, +10% rate of fire in a horde+ WeaponBonus_China = VETERAN RATE_OF_FIRE 115%+ WeaponBonus_China = VETERAN DAMAGE 110%+ WeaponBonus_China = ELITE RATE_OF_FIRE 130%+ WeaponBonus_China = ELITE DAMAGE 120%+ WeaponBonus_China = HERO RATE_OF_FIRE 145%+ WeaponBonus_China = HERO DAMAGE 130%+ WeaponBonus_China = HORDE RATE_OF_FIRE 110%+ HealthBonus_China = 125% 140% 165%++ ; GLA: damage 105/115/125 (EA 110/120/130), speed +5/7/10%, repairs 1/1.5/2% a second+ WeaponBonus_GLA = VETERAN RATE_OF_FIRE 120%+ WeaponBonus_GLA = VETERAN DAMAGE 105%+ WeaponBonus_GLA = ELITE RATE_OF_FIRE 140%+ WeaponBonus_GLA = ELITE DAMAGE 115%+ WeaponBonus_GLA = HERO RATE_OF_FIRE 160%+ WeaponBonus_GLA = HERO DAMAGE 125%+ SpeedBonus_GLA = 105% 107% 110%+ SelfRepair_GLA = 1% 1.5% 2%+ SelfRepairDelay = 5000+End+; ---- a plane shot down blows up and burns where it lands -----------------------------------------;; ObjectCreationListReforged.ini says when a crash goes off; this is what goes off. All threediff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRankInsignia.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRankInsignia.ininew file mode 100644index 000000000..127aad1d2--- /dev/null+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRankInsignia.ini@@ -0,0 +1,19 @@+; The rank marks America and GLA wear beside a unit's health bar, one for each rank. Written by+; Tools/rank_insignia.py with the textures it names; do not edit by hand. Mapped images are not in+; the multiplayer INI checksum.++MappedImage ReforgedRankBar+ Texture = ReforgedRankBar.tga+ TextureWidth = 32+ TextureHeight = 16+ Coords = Left:0 Top:0 Right:32 Bottom:16+ Status = NONE+End++MappedImage ReforgedRankSkull+ Texture = ReforgedRankSkull.tga+ TextureWidth = 32+ TextureHeight = 32+ Coords = Left:0 Top:0 Right:32 Bottom:32+ Status = NONE+Enddiff --git a/GeneralsMD/Code/Data/Scenarios/vetranks.txt b/GeneralsMD/Code/Data/Scenarios/vetranks.txtnew file mode 100644index 000000000..080ef2760--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/vetranks.txt@@ -0,0 +1,90 @@+# Rank insignia of the three sides side by side (2026-10-21): seats 0-3 are allied, one seat a+# rank (0 regular, 1 veteran, 2 elite, 3 heroic), and each spawns the same six units in its own+# column, so a faction's row reads regular to heroic from left to right. The insignia follow the+# template's side, not the seat's, so any seat can carry any faction's units. Seat 4 is the lone+# enemy that keeps the match open. Everything walks 400 south from scenario frame 120 (logic 240),+# and Cinema/vetranks.txt shoots each row in the first two seconds of that walk.+#+# generals.exe -win -borderless -xres 1920 -yres 1080 -msaa 0 -quickstart -noshellmap -observer+# -multiInstance -fps 120 -noFPSLimit -particlecap 2500+# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 5 -takeover+# -team 0 0 -team 1 0 -team 2 0 -team 3 0 -team 4 1 -seed 1+# -scenario vetranks -cinema vetranks -maxframes 600+#+# Columns x 3300 / 3365 / 3430 / 3495, tank on the column and its infantry 25 east of it.+# Rows: USA y 3800, China 3960, GLA 4120. The rank lines name exact templates, not America*:+# a prefix would also take the seat's own command center, which has no experience tracker.++10 spawn 0 AmericaTankCrusader 1 3300 3800+10 spawn 0 AmericaInfantryRanger 1 3325 3800+10 spawn 0 ChinaTankBattleMaster 1 3300 3960+10 spawn 0 ChinaInfantryRedguard 1 3325 3960+10 spawn 0 GLATankScorpion 1 3300 4120+10 spawn 0 GLAInfantryRebel 1 3325 4120++10 spawn 1 AmericaTankCrusader 1 3365 3800+10 spawn 1 AmericaInfantryRanger 1 3390 3800+10 spawn 1 ChinaTankBattleMaster 1 3365 3960+10 spawn 1 ChinaInfantryRedguard 1 3390 3960+10 spawn 1 GLATankScorpion 1 3365 4120+10 spawn 1 GLAInfantryRebel 1 3390 4120++10 spawn 2 AmericaTankCrusader 1 3430 3800+10 spawn 2 AmericaInfantryRanger 1 3455 3800+10 spawn 2 ChinaTankBattleMaster 1 3430 3960+10 spawn 2 ChinaInfantryRedguard 1 3455 3960+10 spawn 2 GLATankScorpion 1 3430 4120+10 spawn 2 GLAInfantryRebel 1 3455 4120++10 spawn 3 AmericaTankCrusader 1 3495 3800+10 spawn 3 AmericaInfantryRanger 1 3520 3800+10 spawn 3 ChinaTankBattleMaster 1 3495 3960+10 spawn 3 ChinaInfantryRedguard 1 3520 3960+10 spawn 3 GLATankScorpion 1 3495 4120+10 spawn 3 GLAInfantryRebel 1 3520 4120++12 rank 1 AmericaTankCrusader veteran+12 rank 1 AmericaInfantryRanger veteran+12 rank 1 ChinaTankBattleMaster veteran+12 rank 1 ChinaInfantryRedguard veteran+12 rank 1 GLATankScorpion veteran+12 rank 1 GLAInfantryRebel veteran+12 rank 2 AmericaTankCrusader elite+12 rank 2 AmericaInfantryRanger elite+12 rank 2 ChinaTankBattleMaster elite+12 rank 2 ChinaInfantryRedguard elite+12 rank 2 GLATankScorpion elite+12 rank 2 GLAInfantryRebel elite+12 rank 3 AmericaTankCrusader heroic+12 rank 3 AmericaInfantryRanger heroic+12 rank 3 ChinaTankBattleMaster heroic+12 rank 3 ChinaInfantryRedguard heroic+12 rank 3 GLATankScorpion heroic+12 rank 3 GLAInfantryRebel heroic++120 move 0 AmericaTankCrusader 3300 3400+120 move 0 AmericaInfantryRanger 3325 3400+120 move 0 ChinaTankBattleMaster 3300 3560+120 move 0 ChinaInfantryRedguard 3325 3560+120 move 0 GLATankScorpion 3300 3720+120 move 0 GLAInfantryRebel 3325 3720+120 move 1 AmericaTankCrusader 3365 3400+120 move 1 AmericaInfantryRanger 3390 3400+120 move 1 ChinaTankBattleMaster 3365 3560+120 move 1 ChinaInfantryRedguard 3390 3560+120 move 1 GLATankScorpion 3365 3720+120 move 1 GLAInfantryRebel 3390 3720+120 move 2 AmericaTankCrusader 3430 3400+120 move 2 AmericaInfantryRanger 3455 3400+120 move 2 ChinaTankBattleMaster 3430 3560+120 move 2 ChinaInfantryRedguard 3455 3560+120 move 2 GLATankScorpion 3430 3720+120 move 2 GLAInfantryRebel 3455 3720+120 move 3 AmericaTankCrusader 3495 3400+120 move 3 AmericaInfantryRanger 3520 3400+120 move 3 ChinaTankBattleMaster 3495 3560+120 move 3 ChinaInfantryRedguard 3520 3560+120 move 3 GLATankScorpion 3495 3720+120 move 3 GLAInfantryRebel 3520 3720++200 tally 0 *diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 00d142966..d03dbd23a 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -51,11 +51,23 @@ enum _TerrainLOD : Int;class GlobalData;class INI;class WeaponBonusSet;+class ThingTemplate;enum BodyDamageType : Int;enum AIDebugOptions : Int;// PUBLIC /////////////////////////////////////////////////////////////////////////////////////////+/// the three sides whose ranks carry their own bonuses (m_veterancyWeaponBonus and the rest)+enum VeterancySide+{+ VETERANCY_SIDE_NONE = -1,+ VETERANCY_SIDE_AMERICA,+ VETERANCY_SIDE_CHINA,+ VETERANCY_SIDE_GLA,++ VETERANCY_SIDE_COUNT+};+const Int MAX_GLOBAL_LIGHTS = 3;//-------------------------------------------------------------------------------------------------@@ -142,6 +154,7 @@ public:Int getEffectiveParticleCap() const { return (m_particleCapOverride > 0) ? m_particleCapOverride : m_maxParticleCount; }static void parseGameDataDefinition( INI* ini );+ static void parseVeterancyDefinition( INI* ini ); ///< the Veterancy block, m_veterancy*//-----------------------------------------------------------------------------------------------struct TerrainLighting@@ -535,6 +548,22 @@ public:Int m_maxFieldParticleCount; ///< maximum number of field-type particles that can exist (roughly)WeaponBonusSet* m_weaponBonusSet;Real m_healthBonus[LEVEL_COUNT]; ///< global bonuses to health for veterancy.++ /** Faction veterancy, set in BalanceReforged.ini. A ranked unit whose template's Side starts with+ * America, China or GLA (so every general's copy too) reads its side's tables; Boss and civilian+ * units keep the global ones. A side's weapon table stands in for the VETERAN, ELITE and HERO+ * lines of WeaponBonus, and any other condition in it (China's HORDE) counts only while ranked. */+ WeaponBonusSet* m_veterancyWeaponBonus[VETERANCY_SIDE_COUNT]; ///< NULL: the side takes WeaponBonus as it is+ Real m_veterancyHealthBonus[VETERANCY_SIDE_COUNT][LEVEL_COUNT]; ///< 0: the side takes HealthBonus_*+ Real m_veterancySpeedBonus[VETERANCY_SIDE_COUNT][LEVEL_COUNT]; ///< locomotor speed factor+ Real m_veterancySelfRepair[VETERANCY_SIDE_COUNT][LEVEL_COUNT]; ///< share of max health healed a second+ UnsignedInt m_veterancySelfRepairDelay; ///< frames unhurt before self-repair starts++ static VeterancySide veterancySideOf( const ThingTemplate *thing );+ const WeaponBonusSet *getVeterancyWeaponBonus( const ThingTemplate *thing, VeterancyLevel level ) const;+ Real getVeterancyHealthBonus( const ThingTemplate *thing, VeterancyLevel level ) const;+ Real getVeterancySpeedBonus( const ThingTemplate *thing, VeterancyLevel level ) const;+ Real getVeterancySelfRepair( const ThingTemplate *thing, VeterancyLevel level ) const;Real m_defaultStructureRubbleHeight; ///< for rubbled structures, compress height to this if none specifiedAsciiString m_shellMapName; ///< Holds the shell map namediff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex 8b04ff90b..8f42cf50c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -931,7 +931,10 @@ private://Perhaps we can move this out of Drawable???public:static void killStaticImages();-+ /// the rank marks of the thing's side, one a level, at `scale` times their health bar size; FALSE when+ /// the side has none and wears EA's chevrons. `centred` puts the widest row's middle on `x`.+ static Bool drawRankInsignia( const ThingTemplate *thing, VeterancyLevel level, Int x, Int top, Bool centred, Real scale, Color color );+#ifdef DIRTY_CONDITION_FLAGS// only for StDrawableDirtyStuffLocker!static void friend_lockDirtyStuffForIteration();diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex ac6c2c546..c11ddc836 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -340,6 +340,8 @@ public:UnsignedInt m_expireFrame; ///< frame we expire onWorldAnimationOptions m_options; ///< optionsReal m_zRisePerSecond; ///< Z units to rise per second+ const ThingTemplate *m_rankOf; ///< a rank gained: its side's marks are drawn instead of the animation, when it has them+ VeterancyLevel m_rankLevel; ///< the rank gained};typedef std::list< WorldAnimationData *> WorldAnimationList;@@ -1208,7 +1210,9 @@ public:const Coord3D *pos,WorldAnimationOptions options,Real durationInSeconds,- Real zRisePerSecond );+ Real zRisePerSecond,+ const ThingTemplate *rankOf = NULL,+ VeterancyLevel rankLevel = LEVEL_REGULAR );#if defined(_DEBUG) || defined(_INTERNAL)virtual void DEBUG_addFloatingText(const AsciiString& text,const Coord3D * pos, Color color);diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.hindex 74d4b8d12..278595c40 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Locomotor.h@@ -355,6 +355,8 @@ public:DEBUG_ASSERTCRASH(!(speed <= 0.0f && m_template->m_appearance == LOCO_THRUST), ("THRUST locos may not have zero speeds!\n"));m_maxSpeed = speed;}+ /// the owner's rank bonus on the template's speed (GLA veterans), applied before the setMaxSpeed cap+ inline void setSpeedFactor(Real factor) { m_speedFactor = factor; }inline void setMaxAcceleration(Real accel) { m_maxAccel = accel; }inline void setMaxBraking(Real braking) { m_maxBraking = braking; }inline void setMaxTurnRate(Real turn) { m_maxTurnRate = turn; }@@ -522,6 +524,7 @@ private:Real m_brakingFactor;Real m_maxLift;Real m_maxSpeed;+ Real m_speedFactor;Real m_maxAccel;Real m_maxBraking;Real m_maxTurnRate;diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.hindex ed73635b8..a2d2eba43 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/LocomotorSet.h@@ -103,6 +103,8 @@ public:void addLocomotor(const LocomotorTemplate* lt);Locomotor* findLocomotor(LocomotorSurfaceTypeMask t);++ void setSpeedFactor(Real factor); ///< Locomotor::setSpeedFactor on eachvoid xferSelfAndCurLocoPtr(Xfer *xfer, Locomotor** loco);diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.hindex c0d850f14..b810af54e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h@@ -595,6 +595,7 @@ public:inline Real getPathExtraDistance() const { return m_pathExtraDistance; }virtual Bool chooseLocomotorSet(LocomotorSetType wst);+ void refreshVeterancySpeed(); ///< the rank's speed bonus onto every locomotor in the setvirtual CommandSourceType getLastCommandSource() const { return m_lastCommandSource; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex 4e5ae42c7..bba37f9b3 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -92,6 +92,7 @@ enum ScenarioActionTypeSCENARIO_ACTION_RESPOND, ///< respond <slot> <selector> <position>; from now, how long each unit takes to point its gun at the position, fire with it pointed there, and get closer to itSCENARIO_ACTION_GUARD, ///< guard <slot> <selector> <targetSlot> <targetSelector>; a guard order on one object, as a script gives itSCENARIO_ACTION_REPEAT, ///< repeat <slot> <building> <template> on|off; the Ctrl+Alt build key, as MSG_SET_REPEAT_UNIT onto the message stream+ SCENARIO_ACTION_RANK, ///< rank <slot> <selector> veteran|elite|heroic; sets each match's veterancy, as the rank cheat doesSCENARIO_ACTION_GIVEMONEY ///< givemoney <slot> <targetSlot> <amount>; the Tab screen's Send, as MSG_TRANSFER_MONEY onto the message stream};diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex be736387e..cb5168c03 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -51,6 +51,7 @@#include "Common/Monitors.h"#include "Common/OptionsCatalog.h"#include "Common/Registry.h"+#include "Common/ThingTemplate.h"#include "Common/UserPreferences.h"#include "Common/version.h"@@ -82,6 +83,49 @@ static void parseIgnoredField( INI *, void *, void *, const void * )// millions of cells on a large map, a huge one leaves the whole map in a handful of cells.static const INI::RealRange PARTITION_CELL_SIZE_RANGE = { 20.0f, 400.0f };+// A side's weapon table exists from its first line on, so a side BalanceReforged.ini never names+// keeps a NULL table and the global WeaponBonus lines.+static void parseVeterancyWeaponBonus( INI *ini, void *, void *store, const void * )+{+ WeaponBonusSet **table = (WeaponBonusSet **)store;+ if( *table == NULL )+ *table = newInstance( WeaponBonusSet );+ (*table)->parseWeaponBonusSet( ini );+}++// Three percentages, Veteran, Elite and Heroic, into a Real[LEVEL_COUNT]; Regular stays as it was.+static void parseVeterancyRanks( INI *ini, void *, void *store, const void * )+{+ Real *ranks = (Real *)store;+ for( Int level = LEVEL_VETERAN; level <= LEVEL_HEROIC; ++level )+ ranks[ level ] = INI::scanPercentToReal( ini->getNextToken() );+}++/** The Veterancy block, BalanceReforged.ini's: its own keyword rather than a second GameData block,+ * because parseGameDataDefinition also re-reads Options.ini, which would overrule the command line. */+static const FieldParse theVeterancyFieldParseTable[] =+{+ { "WeaponBonus_America", parseVeterancyWeaponBonus, NULL, offsetof( GlobalData, m_veterancyWeaponBonus[VETERANCY_SIDE_AMERICA] ) },+ { "WeaponBonus_China", parseVeterancyWeaponBonus, NULL, offsetof( GlobalData, m_veterancyWeaponBonus[VETERANCY_SIDE_CHINA] ) },+ { "WeaponBonus_GLA", parseVeterancyWeaponBonus, NULL, offsetof( GlobalData, m_veterancyWeaponBonus[VETERANCY_SIDE_GLA] ) },+ { "HealthBonus_America", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancyHealthBonus[VETERANCY_SIDE_AMERICA] ) },+ { "HealthBonus_China", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancyHealthBonus[VETERANCY_SIDE_CHINA] ) },+ { "HealthBonus_GLA", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancyHealthBonus[VETERANCY_SIDE_GLA] ) },+ { "SpeedBonus_America", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySpeedBonus[VETERANCY_SIDE_AMERICA] ) },+ { "SpeedBonus_China", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySpeedBonus[VETERANCY_SIDE_CHINA] ) },+ { "SpeedBonus_GLA", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySpeedBonus[VETERANCY_SIDE_GLA] ) },+ { "SelfRepair_America", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySelfRepair[VETERANCY_SIDE_AMERICA] ) },+ { "SelfRepair_China", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySelfRepair[VETERANCY_SIDE_CHINA] ) },+ { "SelfRepair_GLA", parseVeterancyRanks, NULL, offsetof( GlobalData, m_veterancySelfRepair[VETERANCY_SIDE_GLA] ) },+ { "SelfRepairDelay", INI::parseDurationUnsignedInt, NULL, offsetof( GlobalData, m_veterancySelfRepairDelay ) },+ { NULL, NULL, NULL, 0 }+};++/*static*/ void GlobalData::parseVeterancyDefinition( INI *ini )+{+ ini->initFromINI( TheWritableGlobalData, theVeterancyFieldParseTable );+}+///////////////////////////////////////////////////////////////////////////////////////////////////// PRIVATE DATA //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////@@ -1136,6 +1180,18 @@ GlobalData::GlobalData()m_defaultStructureRubbleHeight = 1.0f;m_weaponBonusSet = newInstance(WeaponBonusSet);+ for (i = 0; i < VETERANCY_SIDE_COUNT; ++i)+ {+ m_veterancyWeaponBonus[i] = NULL;+ for (j = LEVEL_FIRST; j <= LEVEL_LAST; ++j)+ {+ m_veterancyHealthBonus[i][j] = 0.0f;+ m_veterancySpeedBonus[i][j] = 1.0f;+ m_veterancySelfRepair[i][j] = 0.0f;+ }+ }+ m_veterancySelfRepairDelay = 0;+m_shellMapName.set("Maps\\ShellMap1\\ShellMap1.map");m_shellMapOn =TRUE;m_playIntro = TRUE;@@ -1276,6 +1332,12 @@ GlobalData::~GlobalData( void )if (m_weaponBonusSet)m_weaponBonusSet->deleteInstance();+ // a map's override is a memberwise copy sharing the original's side tables, so only the original+ // owns them+ for (Int side = 0; side < VETERANCY_SIDE_COUNT && m_theOriginal == this; ++side)+ if (m_veterancyWeaponBonus[side])+ m_veterancyWeaponBonus[side]->deleteInstance();+if( m_theOriginal == this ) {m_theOriginal = NULL;TheWritableGlobalData = NULL;@@ -1283,6 +1345,54 @@ GlobalData::~GlobalData( void )} // end ~GlobalData+//-------------------------------------------------------------------------------------------------+/** The side a unit's rank belongs to: its template's Side, so a general's copy (ChinaTankGeneral) is+ * China and a captured tank keeps the bonuses of the army that trained it. */+//-------------------------------------------------------------------------------------------------+/*static*/ VeterancySide GlobalData::veterancySideOf( const ThingTemplate *thing )+{+ const AsciiString &side = thing->getDefaultOwningSide();+ if( side.startsWith( "America" ) )+ return VETERANCY_SIDE_AMERICA;+ if( side.startsWith( "China" ) )+ return VETERANCY_SIDE_CHINA;+ if( side.startsWith( "GLA" ) )+ return VETERANCY_SIDE_GLA;+ return VETERANCY_SIDE_NONE;+}++//-------------------------------------------------------------------------------------------------+const WeaponBonusSet *GlobalData::getVeterancyWeaponBonus( const ThingTemplate *thing, VeterancyLevel level ) const+{+ if( level == LEVEL_REGULAR )+ return NULL;+ const VeterancySide side = veterancySideOf( thing );+ return side == VETERANCY_SIDE_NONE ? NULL : m_veterancyWeaponBonus[ side ];+}++//-------------------------------------------------------------------------------------------------+Real GlobalData::getVeterancyHealthBonus( const ThingTemplate *thing, VeterancyLevel level ) const+{+ const VeterancySide side = level == LEVEL_REGULAR ? VETERANCY_SIDE_NONE : veterancySideOf( thing );+ if( side == VETERANCY_SIDE_NONE || m_veterancyHealthBonus[ side ][ level ] == 0.0f )+ return m_healthBonus[ level ];+ return m_veterancyHealthBonus[ side ][ level ];+}++//-------------------------------------------------------------------------------------------------+Real GlobalData::getVeterancySpeedBonus( const ThingTemplate *thing, VeterancyLevel level ) const+{+ const VeterancySide side = level == LEVEL_REGULAR ? VETERANCY_SIDE_NONE : veterancySideOf( thing );+ return side == VETERANCY_SIDE_NONE ? 1.0f : m_veterancySpeedBonus[ side ][ level ];+}++//-------------------------------------------------------------------------------------------------+Real GlobalData::getVeterancySelfRepair( const ThingTemplate *thing, VeterancyLevel level ) const+{+ const VeterancySide side = level == LEVEL_REGULAR ? VETERANCY_SIDE_NONE : veterancySideOf( thing );+ return side == VETERANCY_SIDE_NONE ? 0.0f : m_veterancySelfRepair[ side ][ level ];+}+//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------Bool GlobalData::setTimeOfDay( TimeOfDay tod )diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cppindex 522e489e9..2e6013e65 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp@@ -138,6 +138,7 @@ static const BlockParse theTypeTable[] ={ "ShellMenuScheme", INI::parseShellMenuSchemeDefinition },{ "Terrain", INI::parseTerrainDefinition },{ "Upgrade", INI::parseUpgradeDefinition },+ { "Veterancy", GlobalData::parseVeterancyDefinition },{ "Video", INI::parseVideoDefinition },{ "WaterSet", INI::parseWaterSettingDefinition },{ "WaterTransparency", INI::parseWaterTransparencyDefinition},diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex bb8e0741f..a85817146 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -305,6 +305,17 @@ const Int MAX_ENABLED_MODULES = 16;/*static*/ Int Drawable::s_modelLockCount = 0;#endif+/// How a side wears its rank beside the health bar, in place of EA's chevrons: one mark a level+struct RankInsignia+{+ const Image* image; ///< NULL: the side keeps the chevrons+ Int width; ///< screen pixels+ Int height;+ Int step; ///< screen pixels from one row of marks to the next+ Bool pyramid; ///< two to a row with the third centred under them, rather than one under another+};+static RankInsignia s_rankInsignia[VETERANCY_SIDE_COUNT];+// ------------------------------------------------------------------------------------------------/*static*/ void Drawable::initStaticImages(){@@ -315,6 +326,14 @@ const Int MAX_ENABLED_MODULES = 16;s_veterancyImage[1] = TheMappedImageCollection->findImageByName("SCVeter1");s_veterancyImage[2] = TheMappedImageCollection->findImageByName("SCVeter2");s_veterancyImage[3] = TheMappedImageCollection->findImageByName("SCVeter3");+ // America stacks gold bars and GLA lays out skulls, both the fork's own art, and China the score+ // screen's gold star. A side left out here keeps EA's chevrons.+ const RankInsignia america = { TheMappedImageCollection->findImageByName("ReforgedRankBar"), 16, 8, 7, FALSE };+ const RankInsignia china = { TheMappedImageCollection->findImageByName("Star-Gold"), 12, 12, 10, TRUE };+ const RankInsignia gla = { TheMappedImageCollection->findImageByName("ReforgedRankSkull"), 13, 13, 11, TRUE };+ s_rankInsignia[VETERANCY_SIDE_AMERICA] = america;+ s_rankInsignia[VETERANCY_SIDE_CHINA] = china;+ s_rankInsignia[VETERANCY_SIDE_GLA] = gla;s_fullAmmo = TheMappedImageCollection->findImageByName("SCPAmmoFull");s_emptyAmmo = TheMappedImageCollection->findImageByName("SCPAmmoEmpty");@@ -4666,11 +4685,47 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )screenCenter.x += healthBoxWidth * scale * 0.5f;+ // a side's own marks from where the chevrons start; a building's bar is lifted over its roof, so they+ // start under the bar when it sits lower than that+ Int top = screenCenter.y + 2;+ if( healthBarRegion )+ top = MAX( top, healthBarRegion->hi.y + 2 );+ if( drawRankInsignia( obj->getTemplate(), level, screenCenter.x + 1, top, FALSE, 1.0f, GameMakeColor( 255, 255, 255, 255 ) ) )+ return;+// draw the imageTheDisplay->drawImage(image, screenCenter.x + 1, screenCenter.y + 1, screenCenter.x + 1 + vetBoxWidth, screenCenter.y + 1 + vetBoxHeight);} // end drawVeterancy+// ------------------------------------------------------------------------------------------------+/** A side's rank marks, one a level: America's bars one under another, China's stars and GLA's skulls+ * alone, side by side, then two with the third centred under them. Drawn beside the health bar and+ * floating up over a unit the moment it gains the rank. */+// ------------------------------------------------------------------------------------------------+/*static*/ Bool Drawable::drawRankInsignia( const ThingTemplate *thing, VeterancyLevel level, Int x, Int top, Bool centred, Real scale, Color color )+{+ const VeterancySide side = GlobalData::veterancySideOf( thing );+ if( side == VETERANCY_SIDE_NONE || s_rankInsignia[side].image == NULL )+ return FALSE;++ const RankInsignia &rank = s_rankInsignia[side];+ const Int width = REAL_TO_INT( rank.width * scale );+ const Int height = REAL_TO_INT( rank.height * scale );+ const Int step = REAL_TO_INT( rank.step * scale );+ if( centred )+ x -= ( rank.pyramid && level > LEVEL_VETERAN ? 2 * width : width ) / 2;+ for( Int mark = 0; mark < level; ++mark )+ {+ // a pyramid puts two on the first row and centres the third under them+ const Int row = rank.pyramid ? mark / 2 : mark;+ const Int left = x + ( rank.pyramid ? ( mark % 2 ) * width + row * width / 2 : 0 );+ const Int markTop = top + row * step;+ TheDisplay->drawImage( rank.image, left, markTop, left + width, markTop + height, color );+ }+ return TRUE;+}+// ------------------------------------------------------------------------------------------------/** The capture clock, drawn under the health bar of the building being taken.*diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 3594395f5..dff8ccfe1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -9996,6 +9996,8 @@ WorldAnimationData::WorldAnimationData( void )m_expireFrame = 0;m_options = WORLD_ANIM_NO_OPTIONS;m_zRisePerSecond = 0.0f;+ m_rankOf = NULL;+ m_rankLevel = LEVEL_REGULAR;} // end WorldAnimationData@@ -10006,12 +10008,14 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate,const Coord3D *pos,WorldAnimationOptions options,Real durationInSeconds,- Real zRisePerSecond )+ Real zRisePerSecond,+ const ThingTemplate *rankOf,+ VeterancyLevel rankLevel ){if( LogicThread::defersEffects() && pos != NULL ){const Coord3D at = *pos;- LogicThread::callAfterTick( [=]() { addWorldAnimation( animTemplate, &at, options, durationInSeconds, zRisePerSecond ); } );+ LogicThread::callAfterTick( [=]() { addWorldAnimation( animTemplate, &at, options, durationInSeconds, zRisePerSecond, rankOf, rankLevel ); } );return;}LOGIC_CENSUS( CENSUS_INGAMEUI );@@ -10035,6 +10039,8 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate,wad->m_options = options;wad->m_worldPos = *pos;wad->m_zRisePerSecond = zRisePerSecond;+ wad->m_rankOf = rankOf;+ wad->m_rankLevel = rankLevel;// add to listm_worldAnimationList.push_front( wad );@@ -10128,6 +10134,7 @@ void InGameUI::updateAndDrawWorldAnimations( void )} // end if// update translucency value+ Real alpha = 1.0f;if( BitTest( wad->m_options, WORLD_ANIM_FADE_ON_EXPIRE ) ){@@ -10137,7 +10144,7 @@ void InGameUI::updateAndDrawWorldAnimations( void ){// compute alpha level so that we're totally gone by the expire frame- Real alpha = INT_TO_REAL( framesTillExpire ) / INT_TO_REAL( FRAMES_BEFORE_EXPIRE_TO_FADE );+ alpha = INT_TO_REAL( framesTillExpire ) / INT_TO_REAL( FRAMES_BEFORE_EXPIRE_TO_FADE );wad->m_anim->setAlpha( alpha );} // end if@@ -10155,6 +10162,17 @@ void InGameUI::updateAndDrawWorldAnimations( void )// zoom value, which is gone; this number is the size the artwork was drawn against.const Real WORLD_ANIM_ZOOM_REFERENCE = 1.3f;Real zoomScale = WORLD_ANIM_ZOOM_REFERENCE / TheTacticalView->getZoom();++ // a rank gained floats up as the side's own marks, twice their health bar size, centred where+ // the chevron would have been+ const Real RANK_GAIN_SCALE = 2.0f;+ if( wad->m_rankOf && Drawable::drawRankInsignia( wad->m_rankOf, wad->m_rankLevel, screen.x, screen.y - REAL_TO_INT( height * zoomScale / 2 ),+ TRUE, RANK_GAIN_SCALE * zoomScale, GameMakeColor( 255, 255, 255, REAL_TO_INT( 255 * alpha ) ) ) )+ {+ ++it;+ continue;+ }+width *= zoomScale;height *= zoomScale;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cppindex 5c2427dbf..41333a6f9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp@@ -1567,8 +1567,8 @@ void ActiveBody::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLeve} );}- Real oldBonus = TheGlobalData->m_healthBonus[oldLevel];- Real newBonus = TheGlobalData->m_healthBonus[newLevel];+ Real oldBonus = TheGlobalData->getVeterancyHealthBonus(getObject()->getTemplate(), oldLevel);+ Real newBonus = TheGlobalData->getVeterancyHealthBonus(getObject()->getTemplate(), newLevel);Real mult = newBonus / oldBonus;// get this before calling setMaxHealth, since it can clip curHealthdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cppindex 6d8a339fc..a48c44a3d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Locomotor.cpp@@ -811,6 +811,7 @@ Locomotor::Locomotor(const LocomotorTemplate* tmpl)m_brakingFactor = 1.0f;m_maxLift = BIGNUM;m_maxSpeed = BIGNUM;+ m_speedFactor = 1.0f;m_maxAccel = BIGNUM;m_maxBraking = BIGNUM;m_maxTurnRate = BIGNUM;@@ -850,6 +851,7 @@ Locomotor::Locomotor(const Locomotor& that)m_brakingFactor = that.m_brakingFactor;m_maxLift = that.m_maxLift;m_maxSpeed = that.m_maxSpeed;+ m_speedFactor = that.m_speedFactor;m_maxAccel = that.m_maxAccel;m_maxBraking = that.m_maxBraking;m_maxTurnRate = that.m_maxTurnRate;@@ -880,6 +882,7 @@ Locomotor& Locomotor::operator=(const Locomotor& that)m_brakingFactor = that.m_brakingFactor;m_maxLift = that.m_maxLift;m_maxSpeed = that.m_maxSpeed;+ m_speedFactor = that.m_speedFactor;m_maxAccel = that.m_maxAccel;m_maxBraking = that.m_maxBraking;m_maxTurnRate = that.m_maxTurnRate;@@ -920,12 +923,13 @@ void Locomotor::crc( Xfer *xfer )* 1: Initial version* 3: m_diveDistance* 4: m_yawRate, m_driveAccelX, m_driveAccelY- * 5: m_driveSpeed, m_driveFrame */+ * 5: m_driveSpeed, m_driveFrame+ * 6: m_speedFactor */// ------------------------------------------------------------------------------------------------void Locomotor::xfer( Xfer *xfer ){// version- const XferVersion currentVersion = 5;+ const XferVersion currentVersion = 6;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -966,6 +970,9 @@ void Locomotor::xfer( Xfer *xfer )xfer->xferUnsignedInt(&m_driveFrame);}+ if (version >= 6)+ xfer->xferReal(&m_speedFactor);+} // end xfer// ------------------------------------------------------------------------------------------------@@ -993,6 +1000,7 @@ Real Locomotor::getMaxSpeedForCondition(BodyDamageType condition) constelsespeed = m_template->m_maxSpeedDamaged;+ speed *= m_speedFactor;if (speed > m_maxSpeed)speed = m_maxSpeed;@@ -4028,4 +4036,11 @@ Locomotor* LocomotorSet::findLocomotor(LocomotorSurfaceTypeMask t)return NULL;}+//-------------------------------------------------------------------------------------------------+void LocomotorSet::setSpeedFactor(Real factor)+{+ for (LocomotorVector::iterator it = m_locomotors.begin(); it != m_locomotors.end(); ++it)+ (*it)->setSpeedFactor(factor);+}+diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex a19215f66..1eecb644e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -3493,7 +3493,10 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel neBodyModuleInterface* body = getBodyModule();if (body)body->onVeterancyLevelChanged( oldLevel, newLevel, provideFeedback );-++ if (m_ai)+ m_ai->refreshVeterancySpeed();+// Whether the promotion shows is simply whether this watcher can see the unit. The rule used// to be spelled out here as "mine, or not stealthed, or detected, or disguised", which reads// the same for a player but is wrong for everyone else at the table: an ally who shares your@@ -3558,7 +3561,8 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel ne&pos,WORLD_ANIM_FADE_ON_EXPIRE,TheGlobalData->m_levelGainAnimationDisplayTimeInSeconds,- TheGlobalData->m_levelGainAnimationZRisePerSecond);+ TheGlobalData->m_levelGainAnimationZRisePerSecond,+ getTemplate(), newLevel );}AudioEventRTS soundToPlay = TheAudio->getMiscAudio()->m_unitPromoted;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 77ed56d9e..672b42216 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -1047,11 +1047,19 @@ Bool AIUpdateInterface::chooseLocomotorSetExplicit(LocomotorSetType wst)m_locomotorSet.addLocomotor(lt);}m_curLocomotorSet = wst;+ refreshVeterancySpeed();return TRUE;}return FALSE;}+//-------------------------------------------------------------------------------------------------+void AIUpdateInterface::refreshVeterancySpeed()+{+ const Object* obj = getObject();+ m_locomotorSet.setSpeedFactor(TheGlobalData->getVeterancySpeedBonus(obj->getTemplate(), obj->getVeterancyLevel()));+}+//-------------------------------------------------------------------------------------------------void AIUpdateInterface::chooseGoodLocomotorFromCurrentSet( void ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cppindex 466314d25..179959b4e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cpp@@ -90,7 +90,7 @@ void MaxHealthUpgrade::upgradeImplementation( )// Veterancy multiplies max health when it arrives, so an addition made after a promotion has// to carry the promotion's bonus too. Without it an Elite Paladin that researched Composite// Armor ended on 750 where one armored first and promoted later ended on 780.- Real add = data->m_addMaxHealth * TheGlobalData->m_healthBonus[ obj->getVeterancyLevel() ];+ Real add = data->m_addMaxHealth * TheGlobalData->getVeterancyHealthBonus( obj->getTemplate(), obj->getVeterancyLevel() );body->setMaxHealth( body->getMaxHealth() + add, data->m_maxHealthChangeType );}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex f507eb07b..e3f357515 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -2121,7 +2121,17 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraBflags |= theirContain->getWeaponBonusPassedToPassengers();}- if (TheGlobalData->m_weaponBonusSet)+ // a ranked unit of a side with its own veterancy table takes that side's VETERAN, ELITE and HERO+ // lines instead of the global ones, and the table's other lines (China's horde) with them+ const WeaponBonusSet* sideSet = TheGlobalData->getVeterancyWeaponBonus(source->getTemplate(), source->getVeterancyLevel());+ if (sideSet)+ {+ const WeaponBonusConditionFlags RANK_FLAGS = (1 << WEAPONBONUSCONDITION_VETERAN)+ | (1 << WEAPONBONUSCONDITION_ELITE) | (1 << WEAPONBONUSCONDITION_HERO);+ TheGlobalData->m_weaponBonusSet->appendBonuses(flags & ~RANK_FLAGS, bonus);+ sideSet->appendBonuses(flags, bonus);+ }+ else if (TheGlobalData->m_weaponBonusSet)TheGlobalData->m_weaponBonusSet->appendBonuses(flags, bonus);const WeaponBonusSet* extra = m_template->getExtraBonus();if (extra)diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cppindex 11eb2ea6f..7b75d139c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp@@ -5030,6 +5030,25 @@ 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).+ if( m_frame % LOGICFRAMES_PER_SECOND == 0 )+ {+ for( Object *obj = m_objList; obj; obj = obj->getNextObject() )+ {+ const Real share = TheGlobalData->getVeterancySelfRepair( obj->getTemplate(), obj->getVeterancyLevel() );+ if( share <= 0.0f || obj->isEffectivelyDead() )+ continue;+ const BodyModuleInterface *body = obj->getBodyModule();+ const UnsignedInt lastHurt = body->getLastDamageTimestamp();+ if( body->getHealth() >= body->getMaxHealth()+ || ( lastHurt <= m_frame && m_frame - lastHurt < TheGlobalData->m_veterancySelfRepairDelay ) )+ continue;+ obj->attemptHealing( body->getMaxHealth() * share, obj );+ }+ }+diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 05f3c0f2a..8552990b7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -38,6 +38,7 @@#include "Common/ThingTemplate.h"#include "GameLogic/AI.h"#include "GameLogic/AIPathfind.h"+#include "GameLogic/ExperienceTracker.h"#include "GameLogic/GameLogic.h"#include "GameLogic/Module/AIUpdate.h"#include "GameLogic/Module/BehaviorModule.h"@@ -243,6 +244,8 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio*action = SCENARIO_ACTION_REPEAT;else if (token == "givemoney")*action = SCENARIO_ACTION_GIVEMONEY;+ else if (token == "rank")+ *action = SCENARIO_ACTION_RANK;elsereturn FALSE;@@ -342,6 +345,7 @@ static Int tokensNeededFor( ScenarioActionType action )case SCENARIO_ACTION_PRODUCE: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_REPEAT: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_GIVEMONEY: return SCENARIO_TOKENS_STANCE;+ case SCENARIO_ACTION_RANK: return SCENARIO_TOKENS_STANCE;case SCENARIO_ACTION_STOP: return SCENARIO_TOKENS_STOP;case SCENARIO_ACTION_TALLY: return SCENARIO_TOKENS_STOP;case SCENARIO_ACTION_ARRIVE: return SCENARIO_TOKENS_ARRIVE;@@ -468,6 +472,12 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *areturn SCENARIO_PARSE_BAD_ACTION;break;+ case SCENARIO_ACTION_RANK:+ action->name = tokens[ SCENARIO_STANCE_NAME_TOKEN ];+ if (action->name != "veteran" && action->name != "elite" && action->name != "heroic")+ return SCENARIO_PARSE_BAD_ACTION;+ break;+case SCENARIO_ACTION_PRODUCE:{action->targetSelector = tokens[ 4 ]; // what to make@@ -1803,6 +1813,18 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Coreturn TRUE;}+ case SCENARIO_ACTION_RANK:+ {+ const VeterancyLevel level = action.name == "veteran" ? LEVEL_VETERAN+ : action.name == "elite" ? LEVEL_ELITE : LEVEL_HEROIC;+ const VecObjectID &ids = group->getAllIDs();+ for (VecObjectID::const_iterator it = ids.begin(); it != ids.end(); ++it)+ TheGameLogic->findObjectByID( *it )->getExperienceTracker()->setVeterancyLevel( level );+ DEBUG_LOG(("SCENARIO: frame %d rank slot %d '%s' x%d %s\n",+ action.frame, action.slot, action.selector.str(), taken, action.name.str()));+ break;+ }+case SCENARIO_ACTION_STOP:{group->groupIdle( CMD_FROM_SCRIPT );diff --git a/GeneralsMD/Code/Tools/rank_insignia.py b/GeneralsMD/Code/Tools/rank_insignia.pynew file mode 100644index 000000000..498fd76b7--- /dev/null+++ b/GeneralsMD/Code/Tools/rank_insignia.py@@ -0,0 +1,101 @@+"""The rank marks America and GLA wear beside a unit's health bar, one for each rank: a gold bar for+America, stacked one under the other, and a skull for GLA, laid out like China's gold stars.++Both have a black edge and no background, so they read over any ground the way the score screen's+star does. The game draws them twelve to fourteen pixels across, so the shapes are few and blunt.++ python Tools/rank_insignia.py+ writes Data/Art/Textures/ReforgedRankBar.tga, ReforgedRankSkull.tga and the+ ReforgedRankInsignia.ini that maps both.++Drawn sixteen times too big and brought down, which is the antialiasing."""+import os++from PIL import Image, ImageChops, ImageDraw, ImageFilter++HERE = os.path.dirname(os.path.abspath(__file__))+SCALE = 16+OUTLINE = 41 # a MaxFilter size, odd: the black edge round every mark, 20 drawn pixels+BONE = (236, 228, 204)+GOLD_TOP = (255, 232, 120)+GOLD_BOTTOM = (196, 134, 24)+TEXTURES = os.path.join(HERE, "..", "Data", "Art", "Textures")+INI_PATH = os.path.join(HERE, "..", "Data", "INI", "MappedImages", "HandCreated", "ReforgedRankInsignia.ini")+INI_HEADER = """; The rank marks America and GLA wear beside a unit's health bar, one for each rank. Written by+; Tools/rank_insignia.py with the textures it names; do not edit by hand. Mapped images are not in+; the multiplayer INI checksum.+"""+INI_ENTRY = """+MappedImage %s+ Texture = %s.tga+ TextureWidth = %d+ TextureHeight = %d+ Coords = Left:0 Top:0 Right:%d Bottom:%d+ Status = NONE+End+"""+++def scaled(box):+ """A box or point in shipped pixels, in drawn pixels."""+ return tuple(round(value * SCALE) for value in box)+++def skull():+ """The bone of a 32-pixel skull with its holes cut, and its colour."""+ size = scaled((32, 32))+ bone = Image.new("L", size, 0)+ draw = ImageDraw.Draw(bone)+ draw.ellipse(scaled((4, 2, 28, 24)), fill=255) # cranium+ draw.rounded_rectangle(scaled((9, 17, 23, 29)), radius=3 * SCALE, fill=255) # jaw+ holes = Image.new("L", size, 0)+ draw = ImageDraw.Draw(holes)+ # big sockets: at twelve pixels the eyes are what makes it a skull and not a white dot+ draw.ellipse(scaled((6.5, 9, 14.5, 17.5)), fill=255)+ draw.ellipse(scaled((17.5, 9, 25.5, 17.5)), fill=255)+ draw.polygon([scaled((16, 17.5)), scaled((13.5, 21.5)), scaled((18.5, 21.5))], fill=255) # nose+ for x in (13, 16, 19): # gaps between the teeth+ draw.rectangle(scaled((x - 0.75, 24, x + 0.75, 29)), fill=255)+ shape = ImageChops.subtract(bone, holes)+ colour = Image.new("RGB", size, BONE)+ return shape, colour+++def bar():+ """A 32 by 16 gold bar, light along the top and dark along the bottom like struck metal."""+ size = scaled((32, 16))+ shape = Image.new("L", size, 0)+ ImageDraw.Draw(shape).rounded_rectangle(scaled((3, 3, 29, 13)), radius=2 * SCALE, fill=255)+ colour = Image.new("RGB", size)+ draw = ImageDraw.Draw(colour)+ for y in range(size[1]):+ share = min(1.0, max(0.0, (y - 3 * SCALE) / (10 * SCALE)))+ draw.line((0, y, size[0], y), fill=tuple(round(top + (bottom - top) * share)+ for top, bottom in zip(GOLD_TOP, GOLD_BOTTOM)))+ return shape, colour+++def finish(shape, colour):+ """The mark on black where the edge goes; holes stay inside the edge, so they come out black."""+ alpha = shape.filter(ImageFilter.MaxFilter(OUTLINE))+ black = Image.new("RGB", shape.size, (0, 0, 0))+ art = Image.composite(colour, black, shape)+ art.putalpha(alpha)+ return art.resize((shape.width // SCALE, shape.height // SCALE), Image.LANCZOS)+++def main():+ ini_text = INI_HEADER+ for name, (shape, colour) in (("ReforgedRankBar", bar()), ("ReforgedRankSkull", skull())):+ art = finish(shape, colour)+ path = os.path.join(TEXTURES, name + ".tga")+ art.save(path)+ print(path)+ ini_text += INI_ENTRY % (name, name, art.width, art.height, art.width, art.height)+ with open(INI_PATH, "w", newline="\r\n") as ini:+ ini.write(ini_text)+ print(INI_PATH)+++if __name__ == "__main__":+ main()diff --git a/Tools/Balance/vetduel.py b/Tools/Balance/vetduel.pynew file mode 100644index 000000000..8af3d339e--- /dev/null+++ b/Tools/Balance/vetduel.py@@ -0,0 +1,126 @@+"""A ranked army against a bigger regular one; run it once with each veterancy table and compare.++Every side's veterans fight regular armies of both other sides, tanks against tanks and infantry+against infantry, at each rank, from both start points and on two seeds. The regular army's money is+the ranked army's times three quarters of EA's rank multiple (rate of fire x damage x health: 1.58,+2.18, 3.12), so a fight is close under EA's veterancy and a change to a rank moves it.++The answer per fight is the ranked army's health left as a fraction of its own at the start, minus+the regular army's: +1 the ranked army lost nothing and wiped the other, -1 the reverse. The report+averages it per side and rank over the side's 16 fights (4 pairs, 2 start points, 2 seeds).++ python vetduel.py <exe name in Run> <tag> [pair filter]+ python vetduel.py --report <tag> [<tag> ...]+"""++import concurrent.futures+import json+import re+import subprocess+import sys++import siege++TANK_BUDGET = 4800+INFANTRY_BUDGET = 1800+MAX_FRAMES = 3000 * siege.LOGIC_FPS // siege.SCENARIO_FPS+SPAWN_FRAME = 30+RANK_FRAME = 40+ATTACK_FRAME = 60+TALLY_FRAME = 2950+LEFT_AT = (500, 1100) # open ground on generated map 1 small: a block of 42 Rebels or 19 Overlords+RIGHT_AT = (1250, 1100) # stands whole at either+SPACING = 25+HANDICAP = 0.75 # the regular army's money as a share of an even fight's+SEEDS = (1, 2)++RANKS = {"veteran": 1.2 * 1.1 * 1.2, "elite": 1.4 * 1.2 * 1.3, "heroic": 1.6 * 1.3 * 1.5}+UNITS = { # side: (tank, its price, infantry, its price)+ "USA": ("AmericaTankCrusader", 900, "AmericaInfantryRanger", 225),+ "China": ("ChinaTankBattleMaster", 800, "ChinaInfantryRedguard", 300),+ "GLA": ("GLATankScorpion", 600, "GLAInfantryRebel", 150),+}+PAIRS = [(side, UNITS[side][kind], UNITS[side][kind + 1], UNITS[other][kind], UNITS[other][kind + 1])+ for side in UNITS for other in UNITS if other != side for kind in (0, 2)]+++def run_one(exe: str, tag: str, index: int, pair: tuple, rank: str, swapped: bool, seed: int) -> dict:+ side, ranked, ranked_price, regular, regular_price = pair+ ranked_at, regular_at = (RIGHT_AT, LEFT_AT) if swapped else (LEFT_AT, RIGHT_AT)+ budget = INFANTRY_BUDGET if "Infantry" in ranked else TANK_BUDGET+ ranked_count = round(budget / ranked_price)+ regular_count = round(budget * RANKS[rank] * HANDICAP / regular_price)+ name = "vd%s%03d" % (tag, index)+ lines = [+ "%d spawn 0 %s %d %d %d %d" % (SPAWN_FRAME, ranked, ranked_count, *ranked_at, SPACING),+ "%d spawn 1 %s %d %d %d %d" % (SPAWN_FRAME, regular, regular_count, *regular_at, SPACING),+ "%d rank 0 %s %s" % (RANK_FRAME, siege.selector(ranked), rank),+ "%d attackmove 0 %s %d %d" % (ATTACK_FRAME, siege.selector(ranked), *regular_at),+ "%d attackmove 1 %s %d %d" % (ATTACK_FRAME, siege.selector(regular), *ranked_at),+ ]+ for frame in (ATTACK_FRAME, TALLY_FRAME):+ lines.append("%d tally 0 %s" % (frame, siege.selector(ranked)))+ lines.append("%d tally 1 %s" % (frame, siege.selector(regular)))+ scenario = siege.SCENARIO_DIR / (name + ".txt")+ scenario.write_text("\n".join(lines) + "\n", encoding="ascii")+ log = siege.RUN_DIR / (name + "_DebugLogFile.txt")+ log.unlink(missing_ok=True)+ arguments = [str(siege.RUN_DIR / exe), "-headless", "-quickstart", "-noshellmap", "-observer", "-multiInstance",+ "-noFPSLimit", "-randommap", "1", "2", "small", "-autoskirmish", "2", "-takeover",+ "-side", "0", "FactionAmerica", "-side", "1", "FactionChina", "-seed", str(seed),+ "-maxframes", str(MAX_FRAMES), "-scenario", name, "-logPrefix", name + "_"]+ process = subprocess.Popen(arguments, cwd=siege.RUN_DIR, creationflags=subprocess.ABOVE_NORMAL_PRIORITY_CLASS)+ try:+ process.wait(timeout=siege.TIMEOUT_SECONDS)+ except subprocess.TimeoutExpired:+ process.kill()+ scenario.unlink()+ health = {}+ for match in siege.TALLY.finditer(log.read_text(encoding="latin-1", errors="replace")):+ health[(int(match.group(1)), int(match.group(2)))] = int(match.group(5))+ log.unlink()+ return {"side": side, "ranked": ranked, "regular": regular, "rank": rank, "swapped": swapped, "seed": seed,+ "rankedStart": health.get((ATTACK_FRAME, 0)), "rankedEnd": health.get((TALLY_FRAME, 0)),+ "regularStart": health.get((ATTACK_FRAME, 1)), "regularEnd": health.get((TALLY_FRAME, 1))}+++def net(row: dict) -> float:+ return row["rankedEnd"] / row["rankedStart"] - row["regularEnd"] / row["regularStart"]+++def report(tags: list) -> None:+ tables = {}+ for tag in tags:+ cells = {}+ for row in json.loads((siege.OUT_DIR / ("vetduel_" + tag + ".json")).read_text()):+ if None not in (row["rankedStart"], row["rankedEnd"], row["regularStart"], row["regularEnd"]):+ cells.setdefault((row["side"], row["rank"]), []).append(net(row))+ tables[tag] = {key: (sum(v) / len(v), len(v)) for key, v in cells.items()}+ print("%-6s %-8s" % ("side", "rank") + "".join("%14s" % tag for tag in tags))+ for side in UNITS:+ for rank in RANKS:+ print("%-6s %-8s" % (side, rank) + "".join(+ "%14s" % ("%+.2f (%d)" % tables[tag][(side, rank)] if (side, rank) in tables[tag] else "-")+ for tag in tags))+++def main() -> int:+ if sys.argv[1] == "--report":+ report(sys.argv[2:])+ return 0+ exe, tag = sys.argv[1], sys.argv[2]+ runs = [(pair, rank, swapped, seed) for pair in PAIRS for rank in RANKS for swapped in (False, True)+ for seed in SEEDS if len(sys.argv) < 4 or re.search(sys.argv[3], pair[1] + " " + pair[3])]+ results = []+ with concurrent.futures.ThreadPoolExecutor(siege.PARALLEL_RUNS) as pool:+ for row in pool.map(lambda item: run_one(exe, tag, item[0], *item[1]), enumerate(runs)):+ results.append(row)+ print("%-24s %-8s %s/%s vs %-24s %s/%s" % (row["ranked"], row["rank"], row["rankedEnd"], row["rankedStart"],+ row["regular"], row["regularEnd"], row["regularStart"]), flush=True)+ siege.OUT_DIR.mkdir(exist_ok=True)+ (siege.OUT_DIR / ("vetduel_" + tag + ".json")).write_text(json.dumps(results, indent=1), encoding="utf-8")+ return 0+++if __name__ == "__main__":+ sys.exit(main())