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): a rank ladder for every army
Olcay Seygan173513265948
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 26335c9fc..195d7d388 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -8,14 +8,14 @@ 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 rank ladder for every army++- Three chevrons are now a whole army's ladder. An American unit climbs 28 promotions from E-1 Private to General of the Army, a Chinese one 19 from Private to General, a GLA one 20 from Recruit to Supreme Liberator. Every unit starts unranked with a bare health bar and no bonus; from the first promotion on, each grade wears its own insignia beside the health bar and floats it up over the unit's head the moment it is earned. Hover the portrait for the rank's name and how far the next one is: "Next rank 340/420 XP".+- The climb is long. The first promotion is one kill of a unit like your own, every step after costs a fixed share more, and the top is 120 such kills on every side: 12,000 experience for a Crusader. One kill lifts a unit one grade at most, so a Ranger who kills a tank early gets two grades out of it, not five. Six kills used to make a tank Heroic; now they make it an American Corporal, a Chinese Staff Sergeant or a GLA Hardened Raider.+- Every grade makes a unit a little better, on one curve for all three armies: rate of fire times damage times health is 1.13 times a regular's after the first kill, about 1.25 at Veteran, 1.6 at Elite, 2 at Heroic and 2.4 at the very top, where EA's Heroic gave 3.1 after six kills. Each army takes it its own way: America in rate of fire, health and up to 7% more range, China in health and a 10% faster horde, GLA in rate of fire, up to 14% more speed and up to 2% of its health mended a second once it has gone five seconds unhurt.+- Veteran, Elite and Heroic still exist and still bring their weapons, voices and upgrades: America turns Veteran at Corporal, Elite at Warrant Officer and Heroic at Lieutenant Colonel; China at Sergeant, Second Lieutenant and Colonel; GLA at Raider, Raid Captain and Warlord. Red Guard Training and the other trainings, a pilot climbing into a vehicle, map-placed veterans and the Heroic cheat land on those ranks. A veterancy crate is worth three grades, never past Heroic, since one EA level is up to 42 kills on this ladder.+- Burton, Black Lotus and Jarmen Kell climb like everyone else but wear high rank from the start: Burton is a Colonel on his first day and a General of the Army at the top, Lotus goes from Colonel to General, Kell from Warlord to Supreme Liberator.+- Every general's army takes its side's ladder; civilians and other armies keep EA's three ranks. Replays recorded before this change play out differently.## A new loading screendiff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 74f7f4639..49548d91e 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -30,6 +30,9 @@ Data/Art/Textures/ReforgedMineLedBlue.tgaData/Art/Textures/ReforgedMineLedRed.tgaData/Art/Textures/ReforgedRankBar.tgaData/Art/Textures/ReforgedRankSkull.tga+Data/Art/Textures/ReforgedRanksChina.tga+Data/Art/Textures/ReforgedRanksGLA.tga+Data/Art/Textures/ReforgedRanksUSA.tgaData/Art/Textures/ReforgedSignalAttack.tgaData/Art/Textures/ReforgedSignalDefend.tgaData/Art/Textures/ReforgedSignalLook.tga@@ -45,6 +48,7 @@ Data/Cinema/drawlooks.txtData/Cinema/explreel.txtData/Cinema/filterblur.txtData/Cinema/filterbw.txt+Data/Cinema/firelook.txtData/Cinema/gunfx.txtData/Cinema/headlights.txtData/Cinema/hero_loop.txt@@ -86,6 +90,8 @@ Data/Cinema/nohud.txtData/Cinema/nukedome.txtData/Cinema/nukefade.txtData/Cinema/nukewarp.txt+Data/Cinema/rankladder.txt+Data/Cinema/rankzero.txtData/Cinema/rf_ai.txtData/Cinema/rf_ai_wave.txtData/Cinema/rf_beach.txt@@ -173,6 +179,9 @@ Data/INI/MappedImages/HandCreated/ReforgedHudObsCommandBar.iniData/INI/MappedImages/HandCreated/ReforgedHudObsPlayerWindow.iniData/INI/MappedImages/HandCreated/ReforgedLobbySpot.iniData/INI/MappedImages/HandCreated/ReforgedRankInsignia.ini+Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini+Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini+Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.iniData/INI/ObjectCreationListReforged.iniData/INI/ParticleSystemReforged.iniData/INI/ScienceReforged.ini@@ -215,6 +224,7 @@ Data/Scenarios/exitmovebuild.txtData/Scenarios/exitorders.txtData/Scenarios/expansionbunker.txtData/Scenarios/explreel.txt+Data/Scenarios/firelook.txtData/Scenarios/fogleak.txtData/Scenarios/givemoney.txtData/Scenarios/glowbase.txt@@ -287,6 +297,8 @@ Data/Scenarios/overlordlong.txtData/Scenarios/overlordrush.txtData/Scenarios/parade.txtData/Scenarios/particles100k.txt+Data/Scenarios/rankladder.txt+Data/Scenarios/rankzero.txtData/Scenarios/reachshot.txtData/Scenarios/repeatbuild.txtData/Scenarios/rf_mass840.txt@@ -3035,6 +3047,7 @@ Tests/test_posixlocalfilesystem_stubs.cppTests/test_posixpath.cppTests/test_premain_strings.cppTests/test_production_input.inc+Tests/test_rank_ladder.cppTests/test_registryfile.cppTests/test_render_hooks.cppTests/test_road_buffer.cpp@@ -4023,6 +4036,10 @@ Tools/packaging-resolution-check.shTools/peacetime_layout.pyTools/pink_laser.pyTools/rank_insignia.py+Tools/rank_insignia_cells.py+Tools/rank_insignia_china.py+Tools/rank_insignia_gla.py+Tools/rank_insignia_usa.pyTools/record-dx11-shaders.ps1Tools/replay-check.shTools/root-readonly-check.shdiff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txtindex 08184d3e9..176ade7b4 100644--- a/GeneralsMD/Code/CMakeLists.txt+++ b/GeneralsMD/Code/CMakeLists.txt@@ -2286,6 +2286,14 @@ set_target_properties(test_water_grid PROPERTIES CXX_STANDARD 17)if(ZH_PLATFORM_POSIX)target_link_libraries(test_water_grid PRIVATE posixdevice w3ddevice)endif()+# The rank ladder's arithmetic (RankLadder, GlobalData.cpp): thresholds, pins, the one-grade clip, the+# stat split. Linked like test_water_grid.+add_lib_test(test_rank_ladder gameengine)+target_sources(test_rank_ladder PRIVATE ${TESTS}/test_gameengine_stubs.cpp)+set_target_properties(test_rank_ladder PROPERTIES CXX_STANDARD 17)+if(ZH_PLATFORM_POSIX)+ target_link_libraries(test_rank_ladder PRIVATE posixdevice w3ddevice)+endif()# Off Windows the device layer's hooks are the game's own: the renderer's from W3DDevice, the CD# manager from PosixDevice. On Windows the test's own stubs stand in for gameenginedevice, which it# does not link (B6).@@ -2311,10 +2319,10 @@ target_compile_definitions(test_gameengine PRIVATEOPTIONS_MENU_WND="${CMAKE_CURRENT_SOURCE_DIR}/Data/Window/Menus/OptionsMenuClassic.wnd"PLATE_TEXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/Data/Art/Textures")-# W3: these three link the engine without its device and WinMain, whose Debug-only names it reads+# W3: these four link the engine without its device and WinMain, whose Debug-only names it reads# (Tests/debug_build_stubs.cpp; empty outside _DEBUG).if(MSVC)- foreach(name test_gameengine test_terrain_golden test_water_grid)+ foreach(name test_gameengine test_terrain_golden test_water_grid test_rank_ladder)target_sources(${name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Tests/debug_build_stubs.cpp)target_compile_definitions(${name} PRIVATE ZH_DEBUG_STUBS_ENGINE)endforeach()diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tganew file mode 100644index 000000000..8740d5bfdBinary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksChina.tga differdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksGLA.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksGLA.tganew file mode 100644index 000000000..753357abaBinary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksGLA.tga differdiff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tganew file mode 100644index 000000000..f37b5bc45Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksUSA.tga differdiff --git a/GeneralsMD/Code/Data/Cinema/rankladder.txt b/GeneralsMD/Code/Data/Cinema/rankladder.txtnew file mode 100644index 000000000..fe9cf157b--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/rankladder.txt@@ -0,0 +1,17 @@+# Scenarios/rankladder.txt: one grid of every grade a side, at the game's own play distance+# (zoom 1.03 relative logs about 1.27, what -camera opens at). hud on keeps the insignia, which+# -cinema otherwise hides with the HUD. Run with a -video range so this clock is the logic frame+# over 60: the drive east starts at 4.0 s, and each look point sits about 26 south of its grid's+# middle so the grid rides above the control bar.++0.0 hud on+0.5 cut 3485 3726 1.03 0 0+4.4 shot+4.5 cut 3485 3961 1.03 0 0+4.7 shot+# the GLA grid has a fifth row (the grade 20 Technical at y 4290), so its look point sits 40+# further north than the other two to keep that row clear of the top-left capture messages+4.8 cut 3485 4191 1.03 0 0+5.0 shot+5.1 cut 3485 3965 1.6 0 0+5.4 shotdiff --git a/GeneralsMD/Code/Data/Cinema/rankzero.txt b/GeneralsMD/Code/Data/Cinema/rankzero.txtnew file mode 100644index 000000000..fe4eba356--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/rankzero.txt@@ -0,0 +1,9 @@+# Scenarios/rankzero.txt: the four structures and the unranked units between them, HUD on so the+# health bars draw. Run with a -video range so this clock is the logic frame over 60; the units+# start east at 2.0 s.++0.0 hud on+0.5 cut 3480 3920 1.3 0 0+4.5 shot+4.6 cut 3520 3930 0.8 0 0+5.2 shotdiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex 23a6ea75f..64bd9bfbb 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -1809,56 +1809,51 @@ Armor DemoGenTerroristArmorArmor = POISON 50%End-; ---- each side's veterans fight their own way ----------------------------------------------------+; ---- the rank ladder ------------------------------------------------------------------------------;-; 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.+; Every rank in the art is a grade: 28 promotions for America (E-1 to General of the Army), 19 for+; China (Private to General), 20 for GLA (Recruit to Supreme Liberator). Grade 0 is unranked on every+; side, with no insignia and no bonus; America's E-1 wears nothing anyway, and China's Private and+; GLA's Recruit are a first promotion. The grade comes from a unit's experience and E, its own regular ExperienceValue+; (what killing a regular copy of itself pays). The step to grade g costs E x r^(g-1), so the first+; promotion is one same-class kill, and r is solved so the top grade costs Top x E. One gain, a kill+; or a heal, lifts one grade at most. docs/plans/RANK-LADDER.md in the wrapper has the tables.;-; 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.+; EA's four levels follow the grade: a unit is Veteran from VeteranPin on, and so on. Crates, Red+; Guard Training, map objects, the rank cheat and scripts land on a pin; a veterancy crate gives+; CrateGrades grades instead of one level, never past the Heroic pin. A hero's insignia starts on+; HeroStart and reaches the top with the hero's last grade; its stats are its grade's like anyone's.;-; 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.+; Stats come from the grade in place of EA's VETERAN, ELITE and HERO lines and HealthBonus_*. Worth+; (rate of fire x damage x health) is 1 + WorthGain x sqrt(experience / Top E) at the grade's+; experience, the same curve on every side, and each side splits it in its own proportions, reached+; at the top: every stat at a grade is its top value raised to ln(worth) / ln(1 + WorthGain). Range+; and Speed multiply as the others do; SelfRepair is the share of max health healed a second once the+; unit has gone SelfRepairDelay milliseconds unhurt. A side's WeaponBonus lines add what a grade+; does not carry and count from the Veteran pin on.+;+; 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.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%+ ; America China GLA+ Grades = 28 19 20+ Top = 120 120 120+ VeteranPin = 4 4 4 ; E-4 Corporal, Sergeant, Raider+ ElitePin = 13 10 10 ; W-1 Warrant Officer, Second Lieutenant, Raid Captain+ HeroicPin = 22 15 15 ; O-5 Lieutenant Colonel, Colonel, Warlord+ HeroStart = 23 15 15 ; O-6 Colonel (Burton), Colonel, Warlord+ RateOfFire = 142% 130% 148%+ Damage = 119% 119% 114%+ Health = 142% 155% 142%+ Range = 107% 100% 100%+ Speed = 100% 100% 114%+ SelfRepair = 0% 0% 2%+ WorthGain = 1.4+ CrateGrades = 3SelfRepairDelay = 5000+ WeaponBonus_China = HORDE RATE_OF_FIRE 110%End; ---- a plane shot down blows up and burns where it lands -----------------------------------------diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ininew file mode 100644index 000000000..1140ceb82--- /dev/null+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini@@ -0,0 +1,168 @@+; China's rank marks, one per PLA Ground Force rank, all in one texture. Written by+; Tools/rank_insignia_china.py with the texture it names; do not edit by hand. Mapped images are+; not in the multiplayer INI checksum.+++MappedImage RankChina_1+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:68 Top:22 Right:124 Bottom:42+ Status = NONE+End++MappedImage RankChina_2+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:132 Top:16 Right:188 Bottom:48+ Status = NONE+End++MappedImage RankChina_3+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:196 Top:22 Right:252 Bottom:42+ Status = NONE+End++MappedImage RankChina_4+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:260 Top:16 Right:316 Bottom:48+ Status = NONE+End++MappedImage RankChina_5+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:324 Top:10 Right:380 Bottom:54+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_6+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:385 Top:10 Right:435 Bottom:54+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_7+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:449 Top:10 Right:512 Bottom:54+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_8+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:1 Top:74 Right:64 Bottom:118+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_9+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:65 Top:74 Right:128 Bottom:118+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_10+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:146 Top:74 Right:174 Bottom:100+ Status = NONE+End++MappedImage RankChina_11+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:203 Top:74 Right:245 Bottom:100+ Status = NONE+End++MappedImage RankChina_12+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:259 Top:74 Right:317 Bottom:100+ Status = NONE+End++MappedImage RankChina_13+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:338 Top:74 Right:366 Bottom:106+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_14+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:395 Top:74 Right:437 Bottom:106+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_15+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:451 Top:74 Right:509 Bottom:106+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_16+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:0 Top:138 Right:64 Bottom:170+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_17+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:70 Top:135 Right:122 Bottom:172+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_18+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:134 Top:135 Right:186 Bottom:172+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankChina_19+ Texture = ReforgedRanksChina.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:194 Top:135 Right:254 Bottom:172+ Status = NONE+ DisplayHeight = 14+Enddiff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ininew file mode 100644index 000000000..fa1364dfa--- /dev/null+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini@@ -0,0 +1,171 @@+; GLA's rank marks, one cell of ReforgedRanksGLA.tga per rank from Recruit to Supreme Liberator. Written+; by Tools/rank_insignia_gla.py with the texture it names; do not edit by hand. Mapped images are+; not in the multiplayer INI checksum.+++MappedImage RankGLA_1+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:88 Top:8 Right:105 Bottom:56+ Status = NONE+End++MappedImage RankGLA_2+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:146 Top:8 Right:174 Bottom:58+ Status = NONE+End++MappedImage RankGLA_3+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:205 Top:6 Right:243 Bottom:57+ Status = NONE+End++MappedImage RankGLA_4+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:263 Top:6 Right:312 Bottom:58+ Status = NONE+End++MappedImage RankGLA_5+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:324 Top:6 Right:381 Bottom:58+ Status = NONE+End++MappedImage RankGLA_6+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:392 Top:8 Right:439 Bottom:53+ Status = NONE+End++MappedImage RankGLA_7+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:455 Top:11 Right:512 Bottom:51+ Status = NONE+End++MappedImage RankGLA_8+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:6 Top:76 Right:64 Bottom:115+ Status = NONE+End++MappedImage RankGLA_9+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:69 Top:76 Right:128 Bottom:115+ Status = NONE+End++MappedImage RankGLA_10+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:139 Top:72 Right:181 Bottom:118+ Status = NONE+End++MappedImage RankGLA_11+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:201 Top:74 Right:256 Bottom:116+ Status = NONE+End++MappedImage RankGLA_12+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:263 Top:74 Right:312 Bottom:116+ Status = NONE+End++MappedImage RankGLA_13+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:326 Top:73 Right:380 Bottom:121+ Status = NONE+End++MappedImage RankGLA_14+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:386 Top:66 Right:446 Bottom:126+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_15+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:454 Top:64 Right:506 Bottom:127+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_16+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:5 Top:131 Right:64 Bottom:188+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_17+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:70 Top:132 Right:124 Bottom:187+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_18+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:130 Top:130 Right:190 Bottom:190+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_19+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:192 Top:128 Right:256 Bottom:192+ Status = NONE+ DisplayHeight = 14+End++MappedImage RankGLA_20+ Texture = ReforgedRanksGLA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:256 Top:128 Right:320 Bottom:192+ Status = NONE+ DisplayHeight = 14+Enddiff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ininew file mode 100644index 000000000..2d3e36f08--- /dev/null+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini@@ -0,0 +1,268 @@+; Every rank of the United States Army, one mapped image per rank in one atlas. Written by+; Tools/rank_insignia_usa.py with the texture it names; do not edit by hand. Mapped images are not+; in the multiplayer INI checksum.++; E-1, Private (PV1)++; E-2, Private (PV2)+MappedImage RankAmerica_1+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:64 Top:22 Right:128 Bottom:42+ Status = NONE+End++; E-3, Private First Class+MappedImage RankAmerica_2+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:128 Top:13 Right:192 Bottom:51+ Status = NONE+End++; E-4, Specialist+MappedImage RankAmerica_3+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:192 Top:3 Right:256 Bottom:61+ Status = NONE+End++; E-4, Corporal+MappedImage RankAmerica_4+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:256 Top:18 Right:320 Bottom:45+ Status = NONE+End++; E-5, Sergeant+MappedImage RankAmerica_5+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:320 Top:15 Right:384 Bottom:49+ Status = NONE+End++; E-6, Staff Sergeant+MappedImage RankAmerica_6+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:384 Top:6 Right:448 Bottom:58+ Status = NONE+ DisplayHeight = 14+End++; E-7, Sergeant First Class+MappedImage RankAmerica_7+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:450 Top:1 Right:510 Bottom:63+ Status = NONE+ DisplayHeight = 14+End++; E-8, Master Sergeant+MappedImage RankAmerica_8+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:7 Top:65 Right:57 Bottom:127+ Status = NONE+ DisplayHeight = 14+End++; E-8, First Sergeant+MappedImage RankAmerica_9+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:64 Top:69 Right:127 Bottom:124+ Status = NONE+ DisplayHeight = 14+End++; E-9, Sergeant Major+MappedImage RankAmerica_10+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:128 Top:69 Right:190 Bottom:124+ Status = NONE+ DisplayHeight = 14+End++; E-9, Command Sergeant Major+MappedImage RankAmerica_11+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:192 Top:69 Right:255 Bottom:124+ Status = NONE+ DisplayHeight = 14+End++; E-9, Sergeant Major of the Army+MappedImage RankAmerica_12+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:256 Top:69 Right:318 Bottom:124+ Status = NONE+ DisplayHeight = 14+End++; W-1, Warrant Officer 1+MappedImage RankAmerica_13+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:320 Top:82 Right:384 Bottom:110+ Status = NONE+End++; W-2, Chief Warrant Officer 2+MappedImage RankAmerica_14+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:384 Top:82 Right:448 Bottom:110+ Status = NONE+End++; W-3, Chief Warrant Officer 3+MappedImage RankAmerica_15+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:448 Top:82 Right:512 Bottom:110+ Status = NONE+End++; W-4, Chief Warrant Officer 4+MappedImage RankAmerica_16+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:0 Top:146 Right:64 Bottom:174+ Status = NONE+End++; W-5, Chief Warrant Officer 5+MappedImage RankAmerica_17+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:64 Top:146 Right:128 Bottom:174+ Status = NONE+End++; O-1, Second Lieutenant+MappedImage RankAmerica_18+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:128 Top:146 Right:192 Bottom:174+ Status = NONE+End++; O-2, First Lieutenant+MappedImage RankAmerica_19+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:192 Top:146 Right:256 Bottom:174+ Status = NONE+End++; O-3, Captain+MappedImage RankAmerica_20+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:256 Top:140 Right:320 Bottom:180+ Status = NONE+End++; O-4, Major+MappedImage RankAmerica_21+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:324 Top:129 Right:379 Bottom:192+ Status = NONE+ DisplayHeight = 14+End++; O-5, Lieutenant Colonel+MappedImage RankAmerica_22+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:388 Top:129 Right:443 Bottom:192+ Status = NONE+ DisplayHeight = 14+End++; O-6, Colonel+MappedImage RankAmerica_23+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:448 Top:139 Right:512 Bottom:182+ Status = NONE+ DisplayHeight = 14+End++; O-7, Brigadier General+MappedImage RankAmerica_24+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:2 Top:195 Right:62 Bottom:253+ Status = NONE+End++; O-8, Major General+MappedImage RankAmerica_25+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:66 Top:208 Right:126 Bottom:240+ Status = NONE+End++; O-9, Lieutenant General+MappedImage RankAmerica_26+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:130 Top:212 Right:190 Bottom:236+ Status = NONE+End++; O-10, General+MappedImage RankAmerica_27+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:194 Top:215 Right:254 Bottom:233+ Status = NONE+End++; O-11, General of the Army+MappedImage RankAmerica_28+ Texture = ReforgedRanksUSA.tga+ TextureWidth = 512+ TextureHeight = 256+ Coords = Left:256 Top:193 Right:320 Bottom:255+ Status = NONE+ DisplayHeight = 14+Enddiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 366af7350..5b10d0c65 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -2189,3 +2189,287 @@ ENDGUI:GraphNoData"Nothing was recorded in this match."END++RANK:NextRank+"Next rank %d/%d XP"+END++RANK:America0+"E-1 Private"+END++RANK:America1+"E-2 Private"+END++RANK:America2+"E-3 Private First Class"+END++RANK:America3+"E-4 Specialist"+END++RANK:America4+"E-4 Corporal"+END++RANK:America5+"E-5 Sergeant"+END++RANK:America6+"E-6 Staff Sergeant"+END++RANK:America7+"E-7 Sergeant First Class"+END++RANK:America8+"E-8 Master Sergeant"+END++RANK:America9+"E-8 First Sergeant"+END++RANK:America10+"E-9 Sergeant Major"+END++RANK:America11+"E-9 Command Sergeant Major"+END++RANK:America12+"E-9 Sergeant Major of the Army"+END++RANK:America13+"W-1 Warrant Officer"+END++RANK:America14+"W-2 Chief Warrant Officer"+END++RANK:America15+"W-3 Chief Warrant Officer"+END++RANK:America16+"W-4 Chief Warrant Officer"+END++RANK:America17+"W-5 Chief Warrant Officer"+END++RANK:America18+"O-1 Second Lieutenant"+END++RANK:America19+"O-2 First Lieutenant"+END++RANK:America20+"O-3 Captain"+END++RANK:America21+"O-4 Major"+END++RANK:America22+"O-5 Lieutenant Colonel"+END++RANK:America23+"O-6 Colonel"+END++RANK:America24+"O-7 Brigadier General"+END++RANK:America25+"O-8 Major General"+END++RANK:America26+"O-9 Lieutenant General"+END++RANK:America27+"O-10 General"+END++RANK:America28+"General of the Army"+END++RANK:China0+"Unranked"+END++RANK:China1+"Private"+END++RANK:China2+"Private First Class"+END++RANK:China3+"Corporal"+END++RANK:China4+"Sergeant"+END++RANK:China5+"Staff Sergeant Second Class"+END++RANK:China6+"Staff Sergeant First Class"+END++RANK:China7+"Master Sergeant Third Class"+END++RANK:China8+"Master Sergeant Second Class"+END++RANK:China9+"Master Sergeant First Class"+END++RANK:China10+"Second Lieutenant"+END++RANK:China11+"First Lieutenant"+END++RANK:China12+"Captain"+END++RANK:China13+"Major"+END++RANK:China14+"Lieutenant Colonel"+END++RANK:China15+"Colonel"+END++RANK:China16+"Senior Colonel"+END++RANK:China17+"Major General"+END++RANK:China18+"Lieutenant General"+END++RANK:China19+"General"+END++RANK:GLA0+"Unranked"+END++RANK:GLA1+"Recruit"+END++RANK:GLA2+"Irregular"+END++RANK:GLA3+"Fighter"+END++RANK:GLA4+"Raider"+END++RANK:GLA5+"Hardened Raider"+END++RANK:GLA6+"Squadhand"+END++RANK:GLA7+"Squad Leader"+END++RANK:GLA8+"Cell Leader"+END++RANK:GLA9+"Senior Cell Leader"+END++RANK:GLA10+"Raid Captain"+END++RANK:GLA11+"Column Captain"+END++RANK:GLA12+"Strike Commander"+END++RANK:GLA13+"Field Commander"+END++RANK:GLA14+"Sector Commander"+END++RANK:GLA15+"Warlord"+END++RANK:GLA16+"Regional Warlord"+END++RANK:GLA17+"High Warlord"+END++RANK:GLA18+"General"+END++RANK:GLA19+"Grand General"+END++RANK:GLA20+"Supreme Liberator"+ENDdiff --git a/GeneralsMD/Code/Data/Scenarios/rankladder.txt b/GeneralsMD/Code/Data/Scenarios/rankladder.txtnew file mode 100644index 000000000..c0f8a4f2b--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/rankladder.txt@@ -0,0 +1,236 @@+# Every grade of the rank ladder on a unit, one grid a side (2026-10-21): seats 0-4 are allied+# and are the grid's columns, each row is one template, and grade = 5 x row + seat, so a side's+# grid reads row by row from grade 0 (no insignia) at top left. A grade lands on every matching+# unit of a seat, which is why each row is its own template. Seat 5 is the lone enemy that keeps+# the match open. Everything drives 300 east from scenario frame 120 (logic 240), and+# Cinema/rankladder.txt shoots each grid in the first second of that drive, before the higher+# grades' speed pulls their column ahead.+#+# 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 6 -takeover+# -team 0 0 -team 1 0 -team 2 0 -team 3 0 -team 4 0 -team 5 1 -seed 1+# -scenario rankladder -cinema rankladder -video 260 340 rankladder -maxframes 360+#+# -video is there for its clock: while a range is set the shot list runs on the logic frame, not+# the wall clock, so a slow load cannot fire every shot before the units exist.+#+# Columns x 3330 + 70 x seat, rows 45 apart: USA y 3640-3865 (29 grades, 0-28), China 3920-4055+# (20, 0-19), GLA 4110-4290 (21, 0-20). Grade 0 is unranked on every side and wears nothing. South of y 3620 is cliff from x 3300 to 3440.++# USA: rows are Crusader, Paladin, Humvee, Tomahawk, Ranger, Missile Defender+10 spawn 0 AmericaTankCrusader 1 3330 3640+10 spawn 1 AmericaTankCrusader 1 3400 3640+10 spawn 2 AmericaTankCrusader 1 3470 3640+10 spawn 3 AmericaTankCrusader 1 3540 3640+10 spawn 4 AmericaTankCrusader 1 3610 3640+10 spawn 0 AmericaTankPaladin 1 3330 3685+10 spawn 1 AmericaTankPaladin 1 3400 3685+10 spawn 2 AmericaTankPaladin 1 3470 3685+10 spawn 3 AmericaTankPaladin 1 3540 3685+10 spawn 4 AmericaTankPaladin 1 3610 3685+10 spawn 0 AmericaVehicleHumvee 1 3330 3730+10 spawn 1 AmericaVehicleHumvee 1 3400 3730+10 spawn 2 AmericaVehicleHumvee 1 3470 3730+10 spawn 3 AmericaVehicleHumvee 1 3540 3730+10 spawn 4 AmericaVehicleHumvee 1 3610 3730+10 spawn 0 AmericaVehicleTomahawk 1 3330 3775+10 spawn 1 AmericaVehicleTomahawk 1 3400 3775+10 spawn 2 AmericaVehicleTomahawk 1 3470 3775+10 spawn 3 AmericaVehicleTomahawk 1 3540 3775+10 spawn 4 AmericaVehicleTomahawk 1 3610 3775+10 spawn 0 AmericaInfantryRanger 1 3330 3820+10 spawn 1 AmericaInfantryRanger 1 3400 3820+10 spawn 2 AmericaInfantryRanger 1 3470 3820+10 spawn 3 AmericaInfantryRanger 1 3540 3820+10 spawn 4 AmericaInfantryRanger 1 3610 3820+10 spawn 0 AmericaInfantryMissileDefender 1 3330 3865+10 spawn 1 AmericaInfantryMissileDefender 1 3400 3865+10 spawn 2 AmericaInfantryMissileDefender 1 3470 3865+10 spawn 3 AmericaInfantryMissileDefender 1 3540 3865++# China: rows are Battlemaster, Gattling Tank, Red Guard, Tank Hunter+10 spawn 0 ChinaTankBattleMaster 1 3330 3920+10 spawn 1 ChinaTankBattleMaster 1 3400 3920+10 spawn 2 ChinaTankBattleMaster 1 3470 3920+10 spawn 3 ChinaTankBattleMaster 1 3540 3920+10 spawn 4 ChinaTankBattleMaster 1 3610 3920+10 spawn 0 ChinaTankGattling 1 3330 3965+10 spawn 1 ChinaTankGattling 1 3400 3965+10 spawn 2 ChinaTankGattling 1 3470 3965+10 spawn 3 ChinaTankGattling 1 3540 3965+10 spawn 4 ChinaTankGattling 1 3610 3965+10 spawn 0 ChinaInfantryRedguard 1 3330 4010+10 spawn 1 ChinaInfantryRedguard 1 3400 4010+10 spawn 2 ChinaInfantryRedguard 1 3470 4010+10 spawn 3 ChinaInfantryRedguard 1 3540 4010+10 spawn 4 ChinaInfantryRedguard 1 3610 4010+10 spawn 0 ChinaInfantryTankHunter 1 3330 4055+10 spawn 1 ChinaInfantryTankHunter 1 3400 4055+10 spawn 2 ChinaInfantryTankHunter 1 3470 4055+10 spawn 3 ChinaInfantryTankHunter 1 3540 4055+10 spawn 4 ChinaInfantryTankHunter 1 3610 4055++# GLA: rows are Scorpion, Quad Cannon, Rebel, Tunnel Defender+10 spawn 0 GLATankScorpion 1 3330 4110+10 spawn 1 GLATankScorpion 1 3400 4110+10 spawn 2 GLATankScorpion 1 3470 4110+10 spawn 3 GLATankScorpion 1 3540 4110+10 spawn 4 GLATankScorpion 1 3610 4110+10 spawn 0 GLAVehicleQuadCannon 1 3330 4155+10 spawn 1 GLAVehicleQuadCannon 1 3400 4155+10 spawn 2 GLAVehicleQuadCannon 1 3470 4155+10 spawn 3 GLAVehicleQuadCannon 1 3540 4155+10 spawn 4 GLAVehicleQuadCannon 1 3610 4155+10 spawn 0 GLAInfantryRebel 1 3330 4200+10 spawn 1 GLAInfantryRebel 1 3400 4200+10 spawn 2 GLAInfantryRebel 1 3470 4200+10 spawn 3 GLAInfantryRebel 1 3540 4200+10 spawn 4 GLAInfantryRebel 1 3610 4200+10 spawn 0 GLAInfantryTunnelDefender 1 3330 4245+10 spawn 1 GLAInfantryTunnelDefender 1 3400 4245+10 spawn 2 GLAInfantryTunnelDefender 1 3470 4245+10 spawn 3 GLAInfantryTunnelDefender 1 3540 4245+10 spawn 4 GLAInfantryTunnelDefender 1 3610 4245+10 spawn 0 GLAVehicleTechnical 1 3330 4290++12 rank 1 AmericaTankCrusader grade 1+12 rank 2 AmericaTankCrusader grade 2+12 rank 3 AmericaTankCrusader grade 3+12 rank 4 AmericaTankCrusader grade 4+12 rank 0 AmericaTankPaladin grade 5+12 rank 1 AmericaTankPaladin grade 6+12 rank 2 AmericaTankPaladin grade 7+12 rank 3 AmericaTankPaladin grade 8+12 rank 4 AmericaTankPaladin grade 9+12 rank 0 AmericaVehicleHumvee grade 10+12 rank 1 AmericaVehicleHumvee grade 11+12 rank 2 AmericaVehicleHumvee grade 12+12 rank 3 AmericaVehicleHumvee grade 13+12 rank 4 AmericaVehicleHumvee grade 14+12 rank 0 AmericaVehicleTomahawk grade 15+12 rank 1 AmericaVehicleTomahawk grade 16+12 rank 2 AmericaVehicleTomahawk grade 17+12 rank 3 AmericaVehicleTomahawk grade 18+12 rank 4 AmericaVehicleTomahawk grade 19+12 rank 0 AmericaInfantryRanger grade 20+12 rank 1 AmericaInfantryRanger grade 21+12 rank 2 AmericaInfantryRanger grade 22+12 rank 3 AmericaInfantryRanger grade 23+12 rank 4 AmericaInfantryRanger grade 24+12 rank 0 AmericaInfantryMissileDefender grade 25+12 rank 1 AmericaInfantryMissileDefender grade 26+12 rank 2 AmericaInfantryMissileDefender grade 27+12 rank 3 AmericaInfantryMissileDefender grade 28+12 rank 1 ChinaTankBattleMaster grade 1+12 rank 2 ChinaTankBattleMaster grade 2+12 rank 3 ChinaTankBattleMaster grade 3+12 rank 4 ChinaTankBattleMaster grade 4+12 rank 0 ChinaTankGattling grade 5+12 rank 1 ChinaTankGattling grade 6+12 rank 2 ChinaTankGattling grade 7+12 rank 3 ChinaTankGattling grade 8+12 rank 4 ChinaTankGattling grade 9+12 rank 0 ChinaInfantryRedguard grade 10+12 rank 1 ChinaInfantryRedguard grade 11+12 rank 2 ChinaInfantryRedguard grade 12+12 rank 3 ChinaInfantryRedguard grade 13+12 rank 4 ChinaInfantryRedguard grade 14+12 rank 0 ChinaInfantryTankHunter grade 15+12 rank 1 ChinaInfantryTankHunter grade 16+12 rank 2 ChinaInfantryTankHunter grade 17+12 rank 3 ChinaInfantryTankHunter grade 18+12 rank 4 ChinaInfantryTankHunter grade 19+12 rank 1 GLATankScorpion grade 1+12 rank 2 GLATankScorpion grade 2+12 rank 3 GLATankScorpion grade 3+12 rank 4 GLATankScorpion grade 4+12 rank 0 GLAVehicleQuadCannon grade 5+12 rank 1 GLAVehicleQuadCannon grade 6+12 rank 2 GLAVehicleQuadCannon grade 7+12 rank 3 GLAVehicleQuadCannon grade 8+12 rank 4 GLAVehicleQuadCannon grade 9+12 rank 0 GLAInfantryRebel grade 10+12 rank 1 GLAInfantryRebel grade 11+12 rank 2 GLAInfantryRebel grade 12+12 rank 3 GLAInfantryRebel grade 13+12 rank 4 GLAInfantryRebel grade 14+12 rank 0 GLAInfantryTunnelDefender grade 15+12 rank 1 GLAInfantryTunnelDefender grade 16+12 rank 2 GLAInfantryTunnelDefender grade 17+12 rank 3 GLAInfantryTunnelDefender grade 18+12 rank 4 GLAInfantryTunnelDefender grade 19+12 rank 0 GLAVehicleTechnical* grade 20++120 move 0 AmericaTankCrusader 3630 3640+120 move 1 AmericaTankCrusader 3700 3640+120 move 2 AmericaTankCrusader 3770 3640+120 move 3 AmericaTankCrusader 3840 3640+120 move 4 AmericaTankCrusader 3910 3640+120 move 0 AmericaTankPaladin 3630 3685+120 move 1 AmericaTankPaladin 3700 3685+120 move 2 AmericaTankPaladin 3770 3685+120 move 3 AmericaTankPaladin 3840 3685+120 move 4 AmericaTankPaladin 3910 3685+120 move 0 AmericaVehicleHumvee 3630 3730+120 move 1 AmericaVehicleHumvee 3700 3730+120 move 2 AmericaVehicleHumvee 3770 3730+120 move 3 AmericaVehicleHumvee 3840 3730+120 move 4 AmericaVehicleHumvee 3910 3730+120 move 0 AmericaVehicleTomahawk 3630 3775+120 move 1 AmericaVehicleTomahawk 3700 3775+120 move 2 AmericaVehicleTomahawk 3770 3775+120 move 3 AmericaVehicleTomahawk 3840 3775+120 move 4 AmericaVehicleTomahawk 3910 3775+120 move 0 AmericaInfantryRanger 3630 3820+120 move 1 AmericaInfantryRanger 3700 3820+120 move 2 AmericaInfantryRanger 3770 3820+120 move 3 AmericaInfantryRanger 3840 3820+120 move 4 AmericaInfantryRanger 3910 3820+120 move 0 AmericaInfantryMissileDefender 3630 3865+120 move 1 AmericaInfantryMissileDefender 3700 3865+120 move 2 AmericaInfantryMissileDefender 3770 3865+120 move 3 AmericaInfantryMissileDefender 3840 3865+120 move 0 ChinaTankBattleMaster 3630 3920+120 move 1 ChinaTankBattleMaster 3700 3920+120 move 2 ChinaTankBattleMaster 3770 3920+120 move 3 ChinaTankBattleMaster 3840 3920+120 move 4 ChinaTankBattleMaster 3910 3920+120 move 0 ChinaTankGattling 3630 3965+120 move 1 ChinaTankGattling 3700 3965+120 move 2 ChinaTankGattling 3770 3965+120 move 3 ChinaTankGattling 3840 3965+120 move 4 ChinaTankGattling 3910 3965+120 move 0 ChinaInfantryRedguard 3630 4010+120 move 1 ChinaInfantryRedguard 3700 4010+120 move 2 ChinaInfantryRedguard 3770 4010+120 move 3 ChinaInfantryRedguard 3840 4010+120 move 4 ChinaInfantryRedguard 3910 4010+120 move 0 ChinaInfantryTankHunter 3630 4055+120 move 1 ChinaInfantryTankHunter 3700 4055+120 move 2 ChinaInfantryTankHunter 3770 4055+120 move 3 ChinaInfantryTankHunter 3840 4055+120 move 4 ChinaInfantryTankHunter 3910 4055+120 move 0 GLATankScorpion 3630 4110+120 move 1 GLATankScorpion 3700 4110+120 move 2 GLATankScorpion 3770 4110+120 move 3 GLATankScorpion 3840 4110+120 move 4 GLATankScorpion 3910 4110+120 move 0 GLAVehicleQuadCannon 3630 4155+120 move 1 GLAVehicleQuadCannon 3700 4155+120 move 2 GLAVehicleQuadCannon 3770 4155+120 move 3 GLAVehicleQuadCannon 3840 4155+120 move 4 GLAVehicleQuadCannon 3910 4155+120 move 0 GLAInfantryRebel 3630 4200+120 move 1 GLAInfantryRebel 3700 4200+120 move 2 GLAInfantryRebel 3770 4200+120 move 3 GLAInfantryRebel 3840 4200+120 move 4 GLAInfantryRebel 3910 4200+120 move 0 GLAInfantryTunnelDefender 3630 4245+120 move 1 GLAInfantryTunnelDefender 3700 4245+120 move 2 GLAInfantryTunnelDefender 3770 4245+120 move 3 GLAInfantryTunnelDefender 3840 4245+120 move 4 GLAInfantryTunnelDefender 3910 4245+120 move 0 GLAVehicleTechnical* 3630 4290++200 tally 0 *diff --git a/GeneralsMD/Code/Data/Scenarios/rankzero.txt b/GeneralsMD/Code/Data/Scenarios/rankzero.txtnew file mode 100644index 000000000..0655f6be5--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/rankzero.txt@@ -0,0 +1,27 @@+# Grade 0 and structures wear no rank mark (2026-10-21): a Chinese command center and war+# factory and a GLA command center and arms dealer on the open ground of Twilight Flame, with+# unranked Battlemasters, Red Guard, Scorpions and Rebels driving between them, all seat 0's.+# Health bars draw for everything with HealthBars = 0 (always) in Options.ini; the check is that+# no bar has a mark at its right end. Cinema/rankzero.txt holds the frame.+#+# generals.exe -win -borderless -xres 1920 -yres 1080 -msaa 0 -quickstart -noshellmap -observer+# -multiInstance -fps 120 -noFPSLimit -map "Maps\Twilight Flame\Twilight Flame.map"+# -autoskirmish 2 -takeover -seed 1 -scenario rankzero -cinema rankzero+# -video 260 340 rankzero -maxframes 360++10 spawn 0 ChinaCommandCenter 1 3360 3760+10 spawn 0 ChinaWarFactory 1 3600 3760+10 spawn 0 GLACommandCenter 1 3360 4120+10 spawn 0 GLAArmsDealer 1 3600 4120++10 spawn 0 ChinaTankBattleMaster 3 3300 3940 40+10 spawn 0 ChinaInfantryRedguard 4 3330 3900 14+10 spawn 0 GLATankScorpion 3 3300 3990 40+10 spawn 0 GLAInfantryRebel 4 3330 4030 14++60 move 0 ChinaTankBattleMaster 3800 3940+60 move 0 ChinaInfantryRedguard 3800 3900+60 move 0 GLATankScorpion 3800 3990+60 move 0 GLAInfantryRebel 3800 4030++100 tally 0 *diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 83a4e83bf..be60bb2a6 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -16573,3 +16573,287 @@ ENDGUI:GraphNoData"Bu maçta hiçbir şey kaydedilmedi."END++RANK:NextRank+"Sonraki rütbe %d/%d XP"+END++RANK:America0+"E-1 Er"+END++RANK:America1+"E-2 Er"+END++RANK:America2+"E-3 Birinci Sınıf Er"+END++RANK:America3+"E-4 Uzman Er"+END++RANK:America4+"E-4 Onbaşı"+END++RANK:America5+"E-5 Çavuş"+END++RANK:America6+"E-6 Kıdemli Çavuş"+END++RANK:America7+"E-7 Birinci Sınıf Çavuş"+END++RANK:America8+"E-8 Usta Çavuş"+END++RANK:America9+"E-8 Bölük Başçavuşu"+END++RANK:America10+"E-9 Başçavuş"+END++RANK:America11+"E-9 Komuta Başçavuşu"+END++RANK:America12+"E-9 Kara Kuvvetleri Başçavuşu"+END++RANK:America13+"W-1 Teknik Subay"+END++RANK:America14+"W-2 Kıdemli Teknik Subay"+END++RANK:America15+"W-3 Kıdemli Teknik Subay"+END++RANK:America16+"W-4 Kıdemli Teknik Subay"+END++RANK:America17+"W-5 Kıdemli Teknik Subay"+END++RANK:America18+"O-1 Teğmen"+END++RANK:America19+"O-2 Üsteğmen"+END++RANK:America20+"O-3 Yüzbaşı"+END++RANK:America21+"O-4 Binbaşı"+END++RANK:America22+"O-5 Yarbay"+END++RANK:America23+"O-6 Albay"+END++RANK:America24+"O-7 Tuğgeneral"+END++RANK:America25+"O-8 Tümgeneral"+END++RANK:America26+"O-9 Korgeneral"+END++RANK:America27+"O-10 Orgeneral"+END++RANK:America28+"Mareşal"+END++RANK:China0+"Rütbesiz"+END++RANK:China1+"Er"+END++RANK:China2+"Birinci Sınıf Er"+END++RANK:China3+"Onbaşı"+END++RANK:China4+"Çavuş"+END++RANK:China5+"İkinci Sınıf Kıdemli Çavuş"+END++RANK:China6+"Birinci Sınıf Kıdemli Çavuş"+END++RANK:China7+"Üçüncü Sınıf Usta Çavuş"+END++RANK:China8+"İkinci Sınıf Usta Çavuş"+END++RANK:China9+"Birinci Sınıf Usta Çavuş"+END++RANK:China10+"Teğmen"+END++RANK:China11+"Üsteğmen"+END++RANK:China12+"Yüzbaşı"+END++RANK:China13+"Binbaşı"+END++RANK:China14+"Yarbay"+END++RANK:China15+"Albay"+END++RANK:China16+"Kıdemli Albay"+END++RANK:China17+"Tümgeneral"+END++RANK:China18+"Korgeneral"+END++RANK:China19+"Orgeneral"+END++RANK:GLA0+"Rütbesiz"+END++RANK:GLA1+"Acemi"+END++RANK:GLA2+"Düzensiz"+END++RANK:GLA3+"Savaşçı"+END++RANK:GLA4+"Akıncı"+END++RANK:GLA5+"Pişkin Akıncı"+END++RANK:GLA6+"Tim Eri"+END++RANK:GLA7+"Tim Lideri"+END++RANK:GLA8+"Hücre Lideri"+END++RANK:GLA9+"Kıdemli Hücre Lideri"+END++RANK:GLA10+"Baskın Yüzbaşısı"+END++RANK:GLA11+"Kol Yüzbaşısı"+END++RANK:GLA12+"Vuruş Komutanı"+END++RANK:GLA13+"Saha Komutanı"+END++RANK:GLA14+"Sektör Komutanı"+END++RANK:GLA15+"Savaş Ağası"+END++RANK:GLA16+"Bölgesel Savaş Ağası"+END++RANK:GLA17+"Baş Savaş Ağası"+END++RANK:GLA18+"General"+END++RANK:GLA19+"Büyük General"+END++RANK:GLA20+"Yüce Kurtarıcı"+ENDdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex d03dbd23a..1976d95ab 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -68,6 +68,58 @@ enum VeterancySideVETERANCY_SIDE_COUNT};+/// America, China, GLA: the side in each rank insignia's image name and each rank's label+extern const char *const TheVeterancySideNames[VETERANCY_SIDE_COUNT];++enum { RANK_GRADES_MAX = 32 }; ///< promotions a side's ladder may have; America's 28 is the longest++/// the stats a grade carries, each looked up per grade in RankLadder::m_stat+enum RankStat+{+ RANK_STAT_RATE_OF_FIRE,+ RANK_STAT_DAMAGE,+ RANK_STAT_HEALTH,+ RANK_STAT_RANGE,+ RANK_STAT_SPEED,+ RANK_STAT_SELF_REPAIR, ///< share of max health healed a second, not a multiplier++ RANK_STAT_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+ * m_top x E. EA's level follows the grade through the pins. Nothing here is saved; the grade is+ * recomputed from the experience whenever it is needed. */+struct RankLadder+{+ Int m_grades; ///< promotions; 0 is a side without a ladder, on EA's four levels+ Real m_top; ///< experience to the top grade, in same-class kills (E)+ Int m_pin[LEVEL_COUNT]; ///< the grade each EA level starts on; m_pin[LEVEL_REGULAR] is 0+ Int m_heroStart; ///< the insignia a hero wears at grade 0+ Real m_statTop[RANK_STAT_COUNT]; ///< each stat at the top of the ladder++ // filled by finish()+ Real m_ratio;+ Real m_total[RANK_GRADES_MAX + 1]; ///< experience to hold grade g, in E+ Real m_stat[RANK_GRADES_MAX + 1][RANK_STAT_COUNT]; ///< each stat at grade g++ void clear();+ /** The ratio from m_grades and m_top, the totals, and the stats: worth (rate of fire times damage+ * times health) is 1 + worthGain x sqrt(experience / top) at each grade's experience, and every+ * stat is its top value raised to ln(worth) / ln(worth at the top), so the split holds all the way up. */+ void finish( Real worthGain );+ Int threshold( Int unitValue, Int grade ) const; ///< experience to hold the grade, rounded once+ Int gradeOf( Int unitValue, Int experience ) const; ///< the highest grade the experience holds+ VeterancyLevel levelOf( Int grade ) const; ///< the EA level whose pin the grade has passed+ /** A gain clipped one point short of the second threshold above the current grade, so one kill+ * 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++ static Int unitValue( const ThingTemplate *thing ); ///< E: the regular ExperienceValue, else half the Veteran threshold, at least 1+};+const Int MAX_GLOBAL_LIGHTS = 3;//-------------------------------------------------------------------------------------------------@@ -549,21 +601,22 @@ public: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+ /** The rank ladders, the Veterancy block in BalanceReforged.ini. A unit whose template's Side starts+ * with America, China or GLA (so every general's copy too) climbs its side's ladder, and its stats+ * come from the grade instead of EA's VETERAN, ELITE and HERO lines and HealthBonus_*; Boss and+ * civilian units keep EA's. A side's weapon table holds what the grade does not (China's HORDE)+ * and counts from the Veteran pin on. */+ RankLadder m_rankLadder[VETERANCY_SIDE_COUNT];+ Real m_rankWorthGain; ///< worth at the top of every ladder is 1 + this+ Int m_rankCrateGrades; ///< grades a veterancy crate gives per EA level it would have+ WeaponBonusSet* m_veterancyWeaponBonus[VETERANCY_SIDE_COUNT]; ///< NULL: nothing beyond the gradeUnsignedInt m_veterancySelfRepairDelay; ///< frames unhurt before self-repair startsstatic VeterancySide veterancySideOf( const ThingTemplate *thing );+ const RankLadder *getRankLadder( const ThingTemplate *thing ) const; ///< NULL: the thing's side keeps EA's levelsconst 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 getRankStat( const ThingTemplate *thing, Int grade, RankStat stat ) const; ///< the grade's stat, or none without a ladder+ Real getRankHealthBonus( const ThingTemplate *thing, VeterancyLevel level, Int grade ) const; ///< the grade's on a ladder, else HealthBonus_*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 8f42cf50c..9a2d06a61 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -931,9 +931,13 @@ 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 );+ /// one rank insignia of the thing's side (RankLadder::insigniaIndex), at `scale` times its health bar+ /// size; FALSE when there is none. `centred` puts its middle on `x`.+ static Bool drawRankInsignia( const ThingTemplate *thing, Int insignia, Int x, Int top, Bool centred, Real scale, Color color );+ static const Image *getRankInsignia( const ThingTemplate *thing, Int insignia ); ///< NULL: none drawn+ static const Image *getRankInsignia( const Object *obj ); ///< what obj wears now; NULL at grade 0 and for anything that cannot climb+ /// its health bar size: DisplayHeight high (12 when unset), width following up to 36, all times `scale`+ static void rankInsigniaSize( const Image *image, Real scale, Int *width, Int *height );#ifdef DIRTY_CONDITION_FLAGS// only for StDrawableDirtyStuffLocker!diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Image.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Image.hindex 79e211058..668851e9e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Image.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Image.h@@ -92,6 +92,7 @@ public:UnsignedInt setStatus( UnsignedInt bit ); ///< set status bitUnsignedInt clearStatus( UnsignedInt bit ); ///< clear status bitUnsignedInt getStatus( void ) const; ///< get status bits+ Int getDisplayHeight( void ) const { return m_displayHeight; } ///< pixels to draw it high at the reference size, 0 when it fills what it is drawn in// for parsing from INI@@ -110,6 +111,7 @@ friend class ImageCollection;ICoord2D m_imageSize; ///< dimensions of imagevoid *m_rawTextureData; ///< raw texture dataUnsignedInt m_status; ///< status bits from ImageStatus+ Int m_displayHeight; ///< DisplayHeight: the rank insignia's own size, height kept and width followingstatic const FieldParse m_imageFieldParseTable[]; ///< the parse table for INI definitiondiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex c11ddc836..7be6e0d5e 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -340,8 +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+ const ThingTemplate *m_rankOf; ///< a grade gained: its insignia is drawn instead of the animation, when it has one+ Int m_rankInsignia; ///< the grade gained, as RankLadder::insigniaIndex};typedef std::list< WorldAnimationData *> WorldAnimationList;@@ -1212,7 +1212,7 @@ public:Real durationInSeconds,Real zRisePerSecond,const ThingTemplate *rankOf = NULL,- VeterancyLevel rankLevel = LEVEL_REGULAR );+ Int rankInsignia = 0 );#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/ExperienceTracker.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ExperienceTracker.hindex 21470750c..e3c18d9fa 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ExperienceTracker.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ExperienceTracker.h@@ -85,6 +85,7 @@ public:ExperienceTracker(Object *parent);VeterancyLevel getVeterancyLevel() const { return m_currentLevel; } ///< What level am I?+ Int getGrade() const { return m_currentGrade; } ///< my grade on my side's rank ladder; 0 without oneInt getExperienceValue( const Object* killer ) const; ///< How much do give for being killedInt getCurrentExperience( void ) const { return m_currentExperience; }; ///< How much experience do I have at the moment?Bool isTrainable() const; ///< Can I gain experience?@@ -93,7 +94,10 @@ public:void setVeterancyLevel( VeterancyLevel newLevel, Bool provideFeedback = TRUE ); ///< Set Level to thisvoid setMinVeterancyLevel( VeterancyLevel newLevel ); ///< Set Level to AT LEAST this... if we are already >= this level, do nothing.void addExperiencePoints( Int experienceGain, Bool canScaleForBonus = TRUE ); ///< Gain this many exp.- Bool gainExpForLevel(Int levelsToGain, Bool canScaleForBonus = TRUE ); ///< Gain enough exp to gain a level. return false if can't gain a level.+ /** Gain enough exp to gain a level. return false if can't gain a level. On a rank ladder a crate+ * gives CrateGrades grades a level, up to the Heroic pin, and byLevel (a pilot's own levels) lands+ * on the pin of the summed level. */+ Bool gainExpForLevel(Int levelsToGain, Bool canScaleForBonus = TRUE, Bool byLevel = FALSE );Bool canGainExpForLevel(Int levelsToGain) const; ///< return same value as gainExpForLevel, but don't change anythingvoid setExperienceAndLevel(Int experienceIn, Bool provideFeedback = TRUE );void setExperienceSink( ObjectID sink ); ///< My experience actually goes to this person (loose couple)@@ -112,8 +116,14 @@ public:void loadPostProcess( void );private:+ /** Set the experience, derive the grade and level from it (the ladder's, or EA's thresholds), and+ * tell the object when either moved. Nothing clips here; addExperiencePoints does. */+ void applyExperience( Int experience, Bool provideFeedback );+ void recomputeRank(); ///< m_currentGrade and m_currentLevel from m_currentExperience+Object* m_parent; ///< Object I am owned byVeterancyLevel m_currentLevel; ///< Level of experience+ Int m_currentGrade; ///< grade on the side's rank ladder, from m_currentExperience; not savedInt m_currentExperience; ///< Number of experience pointsObjectID m_experienceSink; ///< ID of object I have pledged my experience point gains toReal m_experienceScalar; ///< Scales any experience gained by this multiplier.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.hindex eb6aa5891..d51c2e7d9 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Object.h@@ -288,10 +288,14 @@ public:void scoreTheKill( const Object *victim ); ///< I just killed this object.void scoreTheHeal( const Object *patient, Real restored, Real maxHealth ); ///< I just put restored health back on this object+ /// my experience moved my grade or my level: max health follows the grade, then the level's own work+ void onRankChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Int oldGrade, Int newGrade, Bool provideFeedback );+ void floatRankGain( Int insignia ); ///< the promotion floating up: the ladder's insignia, or EA's chevrons for -1void onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback = TRUE ); ///< I just achieved this level right this momentExperienceTracker* getExperienceTracker() {return m_experienceTracker;}const ExperienceTracker* getExperienceTracker() const {return m_experienceTracker;}VeterancyLevel getVeterancyLevel() const;+ Int getRankGrade() const; ///< my grade on my side's rank ladder; 0 without oneinline const AsciiString& getName() const { return m_name; }inline void setName( const AsciiString& newName ) { m_name = newName; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex bba37f9b3..d06e2767f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -92,7 +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 does+ SCENARIO_ACTION_RANK, ///< rank <slot> <selector> veteran|elite|heroic|xp N|grade N; a level as the rank cheat sets it (a ladder's pin), N same-class kills of experience, or a ladder gradeSCENARIO_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 cb5168c03..1da0ede30 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -93,37 +93,210 @@ static void parseVeterancyWeaponBonus( INI *ini, void *, void *store, const void(*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 * )+const char *const TheVeterancySideNames[VETERANCY_SIDE_COUNT] = { "America", "China", "GLA" };++// A ladder line holds one value per side, America, China and GLA, written into the same RankLadder+// member of each; the member's offset rides in userData and store is m_rankLadder.+static void parseLadderInts( INI *ini, void *, void *store, const void *member ){- Real *ranks = (Real *)store;- for( Int level = LEVEL_VETERAN; level <= LEVEL_HEROIC; ++level )- ranks[ level ] = INI::scanPercentToReal( ini->getNextToken() );+ for( Int side = 0; side < VETERANCY_SIDE_COUNT; ++side )+ *(Int *)( (char *)( (RankLadder *)store + side ) + (size_t)member ) = INI::scanInt( ini->getNextToken() );}+static void parseLadderReals( INI *ini, void *, void *store, const void *member )+{+ for( Int side = 0; side < VETERANCY_SIDE_COUNT; ++side )+ *(Real *)( (char *)( (RankLadder *)store + side ) + (size_t)member ) = INI::scanReal( ini->getNextToken() );+}++static void parseLadderPercents( INI *ini, void *, void *store, const void *member )+{+ for( Int side = 0; side < VETERANCY_SIDE_COUNT; ++side )+ *(Real *)( (char *)( (RankLadder *)store + side ) + (size_t)member ) = INI::scanPercentToReal( ini->getNextToken() );+}++#define LADDER_FIELD( token, parser, member ) \+ { token, parser, (const void *)offsetof( RankLadder, member ), offsetof( GlobalData, m_rankLadder ) }+/** 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[] ={+ LADDER_FIELD( "Grades", parseLadderInts, m_grades ),+ LADDER_FIELD( "Top", parseLadderReals, m_top ),+ LADDER_FIELD( "VeteranPin", parseLadderInts, m_pin[LEVEL_VETERAN] ),+ LADDER_FIELD( "ElitePin", parseLadderInts, m_pin[LEVEL_ELITE] ),+ LADDER_FIELD( "HeroicPin", parseLadderInts, m_pin[LEVEL_HEROIC] ),+ LADDER_FIELD( "HeroStart", parseLadderInts, m_heroStart ),+ LADDER_FIELD( "RateOfFire", parseLadderPercents, m_statTop[RANK_STAT_RATE_OF_FIRE] ),+ LADDER_FIELD( "Damage", parseLadderPercents, m_statTop[RANK_STAT_DAMAGE] ),+ LADDER_FIELD( "Health", parseLadderPercents, m_statTop[RANK_STAT_HEALTH] ),+ 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] ),+ { "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] ) },{ "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 }};+#undef LADDER_FIELD+/*static*/ void GlobalData::parseVeterancyDefinition( INI *ini ){ini->initFromINI( TheWritableGlobalData, theVeterancyFieldParseTable );+ for( Int side = 0; side < VETERANCY_SIDE_COUNT; ++side )+ {+ RankLadder &ladder = TheWritableGlobalData->m_rankLadder[ side ];+ if( ladder.m_grades > 0+ && ( ladder.m_grades > RANK_GRADES_MAX || ladder.m_pin[LEVEL_HEROIC] > ladder.m_grades || ladder.m_top < ladder.m_grades+ || ladder.m_pin[LEVEL_VETERAN] <= 0 || ladder.m_pin[LEVEL_VETERAN] >= ladder.m_pin[LEVEL_ELITE]+ || ladder.m_pin[LEVEL_ELITE] >= ladder.m_pin[LEVEL_HEROIC] || ladder.m_heroStart > ladder.m_grades ) )+ throw INI_INVALID_DATA;+ ladder.finish( TheWritableGlobalData->m_rankWorthGain );+ }+}++//-------------------------------------------------------------------------------------------------+void RankLadder::clear()+{+ m_grades = 0;+ m_top = 0.0f;+ for( Int level = 0; level < LEVEL_COUNT; ++level )+ m_pin[ level ] = level;+ m_heroStart = 0;+ 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;+ 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;+ }+}++//-------------------------------------------------------------------------------------------------+// The stat table needs a natural logarithm and an exponential. The CRT's differ by a bit between+// Windows, macOS and Linux, and a player on any of them can join any other, so these two use only+// + - * /, which are exact everywhere: ln by halving into [1, 2) and the atanh series, e by+// Taylor's series on what is left over a whole number of ln 2.+//-------------------------------------------------------------------------------------------------+static const double RANK_LN2 = 0.69314718055994530942;++static double rankLn( double x )+{+ Int twos = 0;+ while( x >= 2.0 ) { x *= 0.5; ++twos; }+ while( x < 1.0 ) { x *= 2.0; --twos; }+ const double y = ( x - 1.0 ) / ( x + 1.0 ), y2 = y * y;+ double term = y, sum = 0.0;+ for( Int odd = 1; odd < 61; odd += 2, term *= y2 )+ sum += term / odd;+ return 2.0 * sum + twos * RANK_LN2;+}++static double rankExp( double x )+{+ const Int twos = (Int)( x / RANK_LN2 );+ const double rest = x - twos * RANK_LN2;+ double term = 1.0, sum = 1.0;+ for( Int n = 1; n < 30; ++n )+ {+ term *= rest / n;+ sum += term;+ }+ for( Int i = 0; i < twos; ++i ) sum *= 2.0;+ for( Int i = 0; i > twos; --i ) sum *= 0.5;+ return sum;+}++//-------------------------------------------------------------------------------------------------+// The ratio by halving, multiplication only, so every machine finds the same one.+//-------------------------------------------------------------------------------------------------+void RankLadder::finish( Real worthGain )+{+ if( m_grades <= 0 )+ return;++ Real low = 1.0f, high = 2.0f;+ for( Int pass = 0; pass < 60; ++pass )+ {+ const Real ratio = ( low + high ) * 0.5f;+ Real sum = 0.0f, step = 1.0f;+ for( Int grade = 0; grade < m_grades; ++grade, step *= ratio )+ sum += step;+ ( sum < m_top ? low : high ) = ratio;+ }+ m_ratio = ( low + high ) * 0.5f;++ Real step = 1.0f;+ m_total[ 0 ] = 0.0f;+ for( Int grade = 1; grade <= RANK_GRADES_MAX; ++grade, step *= m_ratio )+ m_total[ grade ] = m_total[ grade - 1 ] + step;++ const Real topWorth = 1.0f + worthGain;+ for( Int grade = 0; grade <= RANK_GRADES_MAX; ++grade )+ {+ const Real held = MIN( m_total[ grade ], m_top );+ const double share = rankLn( 1.0 + worthGain * sqrt( (double)held / m_top ) ) / rankLn( (double)topWorth );+ 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 ] ) );+ }+}++//-------------------------------------------------------------------------------------------------+Int RankLadder::threshold( Int unitValue, Int grade ) const+{+ return REAL_TO_INT_FLOOR( unitValue * m_total[ MIN( grade, m_grades ) ] + 0.5f );+}++//-------------------------------------------------------------------------------------------------+Int RankLadder::gradeOf( Int unitValue, Int experience ) const+{+ Int grade = 0;+ while( grade < m_grades && experience >= threshold( unitValue, grade + 1 ) )+ ++grade;+ return grade;+}++//-------------------------------------------------------------------------------------------------+VeterancyLevel RankLadder::levelOf( Int grade ) const+{+ Int level = LEVEL_REGULAR;+ while( level < LEVEL_LAST && grade >= m_pin[ level + 1 ] )+ ++level;+ return (VeterancyLevel)level;+}++//-------------------------------------------------------------------------------------------------+Int RankLadder::clipGain( Int unitValue, Int experience, Int gain ) const+{+ const Int grade = gradeOf( unitValue, experience );+ if( grade + 2 > m_grades )+ return gain;+ return MIN( gain, MAX( 0, threshold( unitValue, grade + 2 ) - 1 - experience ) );+}++//-------------------------------------------------------------------------------------------------+Int RankLadder::insigniaIndex( Int grade, Bool hero ) const+{+ if( !hero )+ return grade;+ return m_heroStart + ( m_grades - m_heroStart ) * grade / m_grades;+}++//-------------------------------------------------------------------------------------------------+/*static*/ Int RankLadder::unitValue( const ThingTemplate *thing )+{+ Int value = thing->getExperienceValue( LEVEL_REGULAR );+ if( value <= 0 )+ value = thing->getExperienceRequired( LEVEL_VETERAN ) / 2;+ return MAX( value, 1 );}///////////////////////////////////////////////////////////////////////////////////////////////////@@ -1183,13 +1356,10 @@ GlobalData::GlobalData()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_rankLadder[i].clear();}+ m_rankWorthGain = 1.4f;+ m_rankCrateGrades = 3;m_veterancySelfRepairDelay = 0;m_shellMapName.set("Maps\\ShellMap1\\ShellMap1.map");@@ -1371,26 +1541,25 @@ const WeaponBonusSet *GlobalData::getVeterancyWeaponBonus( const ThingTemplate *}//--------------------------------------------------------------------------------------------------Real GlobalData::getVeterancyHealthBonus( const ThingTemplate *thing, VeterancyLevel level ) const+const RankLadder *GlobalData::getRankLadder( const ThingTemplate *thing ) 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 ];+ const VeterancySide side = veterancySideOf( thing );+ return side == VETERANCY_SIDE_NONE || m_rankLadder[ side ].m_grades <= 0 ? NULL : &m_rankLadder[ side ];}//--------------------------------------------------------------------------------------------------Real GlobalData::getVeterancySpeedBonus( const ThingTemplate *thing, VeterancyLevel level ) const+Real GlobalData::getRankStat( const ThingTemplate *thing, Int grade, RankStat stat ) const{- const VeterancySide side = level == LEVEL_REGULAR ? VETERANCY_SIDE_NONE : veterancySideOf( thing );- return side == VETERANCY_SIDE_NONE ? 1.0f : m_veterancySpeedBonus[ side ][ level ];+ const RankLadder *ladder = getRankLadder( thing );+ if( ladder )+ return ladder->m_stat[ MIN( grade, ladder->m_grades ) ][ stat ];+ return stat == RANK_STAT_SELF_REPAIR ? 0.0f : 1.0f;}//--------------------------------------------------------------------------------------------------Real GlobalData::getVeterancySelfRepair( const ThingTemplate *thing, VeterancyLevel level ) const+Real GlobalData::getRankHealthBonus( const ThingTemplate *thing, VeterancyLevel level, Int grade ) const{- const VeterancySide side = level == LEVEL_REGULAR ? VETERANCY_SIDE_NONE : veterancySideOf( thing );- return side == VETERANCY_SIDE_NONE ? 0.0f : m_veterancySelfRepair[ side ][ level ];+ return getRankLadder( thing ) ? getRankStat( thing, grade, RANK_STAT_HEALTH ) : m_healthBonus[ level ];}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 40c6dd2c1..cb96ec631 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -305,16 +305,14 @@ 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];+/// Each ladder grade's insignia, Rank<Side>_<n> in ReforgedRanks<Side>.ini; NULL for a grade drawn bare+/// (America's E-1)+static const Image* s_rankInsignia[VETERANCY_SIDE_COUNT][RANK_GRADES_MAX + 1];++/// An insignia drawn beside a health bar holds its DisplayHeight (12 unless its cell says otherwise)+/// and lets its width follow, up to this+static const Int RANK_INSIGNIA_DEFAULT_HEIGHT = 12;+static const Int RANK_INSIGNIA_MAX_WIDTH = 36;// ------------------------------------------------------------------------------------------------/*static*/ void Drawable::initStaticImages()@@ -326,16 +324,15 @@ static RankInsignia s_rankInsignia[VETERANCY_SIDE_COUNT];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. Each mark is about as big as a chevron:- // the textures carry a transparent margin, so the bar's 12x6 draws a bar about 10x5 and the star's- // and skull's 9 draw a mark about 8 across.- const RankInsignia america = { TheMappedImageCollection->findImageByName("ReforgedRankBar"), 12, 6, 5, FALSE };- const RankInsignia china = { TheMappedImageCollection->findImageByName("Star-Gold"), 9, 9, 7, TRUE };- const RankInsignia gla = { TheMappedImageCollection->findImageByName("ReforgedRankSkull"), 9, 9, 8, TRUE };- s_rankInsignia[VETERANCY_SIDE_AMERICA] = america;- s_rankInsignia[VETERANCY_SIDE_CHINA] = china;- s_rankInsignia[VETERANCY_SIDE_GLA] = gla;+ for( Int side = 0; side < VETERANCY_SIDE_COUNT; ++side )+ {+ for( Int insignia = 0; insignia <= RANK_GRADES_MAX; ++insignia )+ {+ AsciiString name;+ name.format( "Rank%s_%d", TheVeterancySideNames[ side ], insignia );+ s_rankInsignia[ side ][ insignia ] = TheMappedImageCollection->findImageByName( name );+ }+ }s_fullAmmo = TheMappedImageCollection->findImageByName("SCPAmmoFull");s_emptyAmmo = TheMappedImageCollection->findImageByName("SCPAmmoEmpty");@@ -4654,8 +4651,12 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )return;}+ // a unit on a rank ladder wears its grade's insignia, a grade with no insignia nothing; anyone else+ // EA's chevron for the level+ const RankLadder *ladder = TheGlobalData->getRankLadder( obj->getTemplate() );+ const Int insignia = ladder ? ladder->insigniaIndex( obj->getRankGrade(), obj->isKindOf( KINDOF_HERO ) ) : 0;VeterancyLevel level = obj->getVeterancyLevel();- const Image* image = s_veterancyImage[level];+ const Image* image = ladder ? getRankInsignia( obj ) : s_veterancyImage[level];if (!image)return;@@ -4687,13 +4688,22 @@ 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 ) ) )+ // the insignia in line with the bar, just past its right end and centred on it: the ammo and+ // passenger pips start from the left end, and hanging under the bar it read as part of the unit+ if( ladder )+ {+ Int left = screenCenter.x + 2;+ Int middle = screenCenter.y;+ if( healthBarRegion )+ {+ left = healthBarRegion->hi.x + 2;+ middle = ( healthBarRegion->lo.y + healthBarRegion->hi.y ) / 2;+ }+ Int width, height;+ rankInsigniaSize( image, 1.0f, &width, &height );+ drawRankInsignia( obj->getTemplate(), insignia, left, middle - height / 2, 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);@@ -4701,30 +4711,58 @@ void Drawable::drawVeterancy( const IRegion2D *healthBarRegion )} // 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 )+/*static*/ const Image *Drawable::getRankInsignia( const ThingTemplate *thing, Int insignia ){const VeterancySide side = GlobalData::veterancySideOf( thing );- if( side == VETERANCY_SIDE_NONE || s_rankInsignia[side].image == NULL )- return FALSE;+ if( side == VETERANCY_SIDE_NONE || insignia < 0 || insignia > RANK_GRADES_MAX )+ return NULL;+ return s_rankInsignia[ side ][ insignia ];+}- 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 )+// ------------------------------------------------------------------------------------------------+/** The insignia an object wears now, NULL for none: every unit starts unranked and bare, so grade 0+ * draws nothing on any side, and neither does anything that cannot climb (a structure, or an object+ * without a trainable tracker). The bar, the portrait and the promotion float all ask here. */+// ------------------------------------------------------------------------------------------------+/*static*/ const Image *Drawable::getRankInsignia( const Object *obj )+{+ const RankLadder *ladder = TheGlobalData->getRankLadder( obj->getTemplate() );+ const ExperienceTracker *tracker = obj->getExperienceTracker();+ if( ladder == NULL || tracker == NULL || !tracker->isTrainable() || obj->isKindOf( KINDOF_STRUCTURE ) || obj->getRankGrade() <= 0 )+ return NULL;+ return getRankInsignia( obj->getTemplate(), ladder->insigniaIndex( obj->getRankGrade(), obj->isKindOf( KINDOF_HERO ) ) );+}++// ------------------------------------------------------------------------------------------------+/*static*/ void Drawable::rankInsigniaSize( const Image *image, Real scale, Int *width, Int *height )+{+ const Real high = ( image->getDisplayHeight() > 0 ? image->getDisplayHeight() : RANK_INSIGNIA_DEFAULT_HEIGHT ) * scale;+ Real wide = high * image->getImageWidth() / image->getImageHeight();+ Real tall = high;+ if( wide > RANK_INSIGNIA_MAX_WIDTH * scale ){- // 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 );+ tall = high * RANK_INSIGNIA_MAX_WIDTH * scale / wide;+ wide = RANK_INSIGNIA_MAX_WIDTH * scale;}+ *width = REAL_TO_INT( wide );+ *height = REAL_TO_INT( tall );+}++// ------------------------------------------------------------------------------------------------+/** One grade's insignia, cropped to its ink in the atlas: drawn beside the health bar and floating up+ * over a unit the moment it gains the grade. */+// ------------------------------------------------------------------------------------------------+/*static*/ Bool Drawable::drawRankInsignia( const ThingTemplate *thing, Int insignia, Int x, Int top, Bool centred, Real scale, Color color )+{+ const Image *image = getRankInsignia( thing, insignia );+ if( image == NULL )+ return FALSE;++ Int width, height;+ rankInsigniaSize( image, scale, &width, &height );+ if( centred )+ x -= width / 2;+ TheDisplay->drawImage( image, x, top, x + width, top + height, color );return TRUE;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex b9f27956d..6bd8fda9b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -87,6 +87,8 @@#include "GameClient/GadgetStaticText.h"#include "GameClient/GadgetTextEntry.h"#include "GameClient/InGameUI.h"+#include "GameClient/Mouse.h"+#include "GameLogic/ExperienceTracker.h"#include "GameClient/WindowVideoManager.h"#include "GameClient/GadgetListBox.h"#include "GameClient/HotKey.h"@@ -150,6 +152,34 @@ static void commandButtonTooltip(GameWindow *window,TheControlBar->showBuildTooltipLayout(window);}+/** The portrait's tooltip for a unit on a rank ladder: its rank, and its way through the step to the+ * next one, experience since this grade's threshold over what the step costs. */+static void portraitRankTooltip( GameWindow *window, WinInstanceData *instData, UnsignedInt mouse )+{+ Drawable *draw = TheInGameUI->getFirstSelectedDrawable();+ const Object *obj = draw ? draw->getObject() : NULL;+ const RankLadder *ladder = obj ? TheGlobalData->getRankLadder( obj->getTemplate() ) : NULL;+ if( ladder == NULL || !obj->getExperienceTracker()->isTrainable() )+ return;++ const Int grade = obj->getRankGrade();+ AsciiString label;+ label.format( "RANK:%s%d", TheVeterancySideNames[ GlobalData::veterancySideOf( obj->getTemplate() ) ],+ ladder->insigniaIndex( grade, obj->isKindOf( KINDOF_HERO ) ) );+ UnicodeString text = TheGameText->fetch( label );+ if( grade < ladder->m_grades )+ {+ const Int unitValue = RankLadder::unitValue( obj->getTemplate() );+ const Int from = ladder->threshold( unitValue, grade );+ UnicodeString progress;+ progress.format( TheGameText->fetch( "RANK:NextRank" ), obj->getExperienceTracker()->getCurrentExperience() - from,+ ladder->threshold( unitValue, grade + 1 ) - from );+ text.concat( (WideChar)'\n' );+ text.concat( progress );+ }+ TheMouse->setCursorTooltip( text );+}+//-------------------------------------------------------------------------------------------------/** The place a command of `type` always stands at, or -1 for one that takes the next free place. *///-------------------------------------------------------------------------------------------------@@ -2771,6 +2801,7 @@ void ControlBar::initWindows( void )id = TheNameKeyGenerator->nameToKey( "ControlBar.wnd:CameoWindow" );m_rightHUDCameoWindow = TheWindowManager->winGetWindowFromId( NULL, id );+ m_rightHUDCameoWindow->winSetTooltipFunc( portraitRankTooltip );for( i = 0; i < MAX_RIGHT_HUD_UPGRADE_CAMEOS; i++ ){windowName.format( "ControlBar.wnd:UnitUpgrade%d", i+1 );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex 730519087..854acb7e0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -1097,6 +1097,12 @@ const Image* ControlBar::calculateVeterancyOverlayForObject( const Object *obj ){return NULL;}++ // a unit on a rank ladder shows its grade's insignia, which the button draws in its corner+ const RankLadder *ladder = TheGlobalData->getRankLadder( obj->getTemplate() );+ if( ladder )+ return Drawable::getRankInsignia( obj );+VeterancyLevel level = obj->getVeterancyLevel();//Return the appropriate image (including NULL if no veterancy levels)diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex dea349f2e..daa6cc940 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -9997,7 +9997,7 @@ WorldAnimationData::WorldAnimationData( void )m_options = WORLD_ANIM_NO_OPTIONS;m_zRisePerSecond = 0.0f;m_rankOf = NULL;- m_rankLevel = LEVEL_REGULAR;+ m_rankInsignia = 0;} // end WorldAnimationData@@ -10010,12 +10010,12 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate,Real durationInSeconds,Real zRisePerSecond,const ThingTemplate *rankOf,- VeterancyLevel rankLevel )+ Int rankInsignia ){if( LogicThread::defersEffects() && pos != NULL ){const Coord3D at = *pos;- LogicThread::callAfterTick( [=]() { addWorldAnimation( animTemplate, &at, options, durationInSeconds, zRisePerSecond, rankOf, rankLevel ); } );+ LogicThread::callAfterTick( [=]() { addWorldAnimation( animTemplate, &at, options, durationInSeconds, zRisePerSecond, rankOf, rankInsignia ); } );return;}LOGIC_CENSUS( CENSUS_INGAMEUI );@@ -10040,7 +10040,7 @@ void InGameUI::addWorldAnimation( Anim2DTemplate *animTemplate,wad->m_worldPos = *pos;wad->m_zRisePerSecond = zRisePerSecond;wad->m_rankOf = rankOf;- wad->m_rankLevel = rankLevel;+ wad->m_rankInsignia = rankInsignia;// add to listm_worldAnimationList.push_front( wad );@@ -10163,10 +10163,10 @@ void InGameUI::updateAndDrawWorldAnimations( void )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, half again their health bar size, centred- // where the chevron would have been+ // a grade gained floats up as its insignia, half again its health bar size, centred where the+ // chevron would have beenconst Real RANK_GAIN_SCALE = 1.5f;- if( wad->m_rankOf && Drawable::drawRankInsignia( wad->m_rankOf, wad->m_rankLevel, screen.x, screen.y - REAL_TO_INT( height * zoomScale / 2 ),+ if( wad->m_rankOf && Drawable::drawRankInsignia( wad->m_rankOf, wad->m_rankInsignia, 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;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/Image.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/Image.cppindex 2a7fda188..4be5582fb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/Image.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/Image.cpp@@ -54,6 +54,7 @@ const FieldParse Image::m_imageFieldParseTable[] ={ "TextureHeight", INI::parseInt, NULL, offsetof( Image, m_textureSize.y ) },{ "Coords", Image::parseImageCoords, NULL, offsetof( Image, m_UVCoords ) },{ "Status", Image::parseImageStatus, NULL, offsetof( Image, m_status ) },+ { "DisplayHeight", INI::parseInt, NULL, offsetof( Image, m_displayHeight ) },{ NULL, NULL, NULL, 0 }@@ -158,6 +159,7 @@ Image::Image( void )m_imageSize.y = 0;m_rawTextureData = NULL;m_status = IMAGE_STATUS_NONE;+ m_displayHeight = 0;} // end Imagediff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cppindex 41333a6f9..18f9fc6f3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp@@ -1567,18 +1567,8 @@ void ActiveBody::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLeve} );}- 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 curHealth- //Real newHealth = m_currentHealth * mult;-- // change the max- setMaxHealth(m_maxHealth * mult, PRESERVE_RATIO );-- // now change the cur (setMaxHealth now handles it)- //internalChangeHealth( newHealth - m_currentHealth );+ // the health bonus moves with the grade as well as the level, so Object::onRankChanged scales max+ // health for bothswitch (newLevel){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/VeterancyCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/VeterancyCrateCollide.cppindex ae7b98d1a..28a9899de 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/VeterancyCrateCollide.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/VeterancyCrateCollide.cpp@@ -141,7 +141,7 @@ Bool VeterancyCrateCollide::executeCrateBehavior( Object *other )// do just the colliderif (other != NULL){- other->getExperienceTracker()->gainExpForLevel( levelsToGain, ( ! md->m_isPilot) );+ other->getExperienceTracker()->gainExpForLevel( levelsToGain, ( ! md->m_isPilot), md->m_isPilot );}}else@@ -155,7 +155,7 @@ Bool VeterancyCrateCollide::executeCrateBehavior( Object *other )for( Object *potentialObject = iter->first(); potentialObject; potentialObject = iter->next() ){// This function will give just enough exp for the Object to gain a level, if it can- potentialObject->getExperienceTracker()->gainExpForLevel( levelsToGain, ( ! md->m_isPilot) );+ potentialObject->getExperienceTracker()->gainExpForLevel( levelsToGain, ( ! md->m_isPilot), md->m_isPilot );}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ExperienceTracker.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ExperienceTracker.cppindex c0516a97c..338893939 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ExperienceTracker.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ExperienceTracker.cpp@@ -30,6 +30,7 @@#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine+#include "Common/GlobalData.h"#include "Common/Xfer.h"#include "Common/ThingTemplate.h"#include "GameLogic/ExperienceTracker.h"@@ -47,6 +48,7 @@ExperienceTracker::ExperienceTracker(Object *parent) :m_parent(parent),m_currentLevel(LEVEL_REGULAR),+ m_currentGrade(0),m_experienceSink(INVALID_ID),m_experienceScalar( 1.0f ),m_currentExperience(0), // Added By Sadullah Nader@@ -170,6 +172,14 @@ void ExperienceTracker::setMinVeterancyLevel( VeterancyLevel newLevel )// This does not check for IsTrainable, because this function is for explicit setting,// so the setter is assumed to know what they are doing. The game function// of addExperiencePoints cares about Trainability.+ const RankLadder *ladder = TheGlobalData->getRankLadder( m_parent->getTemplate() );+ if (ladder)+ {+ // a ladder unit lands on the level's pin, from where it climbs on+ if (m_currentLevel < newLevel)+ applyExperience( ladder->threshold( RankLadder::unitValue( m_parent->getTemplate() ), ladder->m_pin[newLevel] ), TRUE );+ return;+ }if (m_currentLevel < newLevel){VeterancyLevel oldLevel = m_currentLevel;@@ -178,7 +188,7 @@ void ExperienceTracker::setMinVeterancyLevel( VeterancyLevel newLevel )if (m_parent){m_currentExperience = m_parent->getTemplate()->getExperienceRequired(m_currentLevel); //Minimum for this level- m_parent->onVeterancyLevelChanged( oldLevel, newLevel );+ m_parent->onRankChanged( oldLevel, newLevel, 0, 0, TRUE );}}}@@ -189,6 +199,13 @@ void ExperienceTracker::setVeterancyLevel( VeterancyLevel newLevel, Bool provide// This does not check for IsTrainable, because this function is for explicit setting,// so the setter is assumed to know what they are doing. The game function// of addExperiencePoints cares about Trainability, if flagged thus.+ const RankLadder *ladder = TheGlobalData->getRankLadder( m_parent->getTemplate() );+ if (ladder)+ {+ if (m_currentLevel != newLevel)+ applyExperience( ladder->threshold( RankLadder::unitValue( m_parent->getTemplate() ), ladder->m_pin[newLevel] ), provideFeedback );+ return;+ }if (m_currentLevel != newLevel){VeterancyLevel oldLevel = m_currentLevel;@@ -197,17 +214,32 @@ void ExperienceTracker::setVeterancyLevel( VeterancyLevel newLevel, Bool provideif (m_parent){m_currentExperience = m_parent->getTemplate()->getExperienceRequired(m_currentLevel); //Minimum for this level- m_parent->onVeterancyLevelChanged( oldLevel, newLevel, provideFeedback );+ m_parent->onRankChanged( oldLevel, newLevel, 0, 0, provideFeedback );}}}//--------------------------------------------------------------------------------------------------Bool ExperienceTracker::gainExpForLevel(Int levelsToGain, Bool canScaleForBonus)+Bool ExperienceTracker::gainExpForLevel(Int levelsToGain, Bool canScaleForBonus, Bool byLevel){Int newLevel = (Int)m_currentLevel + levelsToGain;if (newLevel > LEVEL_LAST)newLevel = LEVEL_LAST;++ // a ladder unit is set straight onto a grade, unclipped and unscaled: a crate's grades short of the+ // Heroic pin, or a pilot's summed level's pin+ const RankLadder *ladder = TheGlobalData->getRankLadder( m_parent->getTemplate() );+ if (ladder)+ {+ if (newLevel <= m_currentLevel)+ return false;+ const Int grade = byLevel ? ladder->m_pin[newLevel]+ : MIN( m_currentGrade + levelsToGain * TheGlobalData->m_rankCrateGrades, ladder->m_pin[LEVEL_LAST] );+ const Int experience = ladder->threshold( RankLadder::unitValue( m_parent->getTemplate() ), grade );+ if (experience > m_currentExperience)+ setExperienceAndLevel( experience );+ return true;+ }// gain what levels we can, even if we can't use 'em allif (newLevel > m_currentLevel){@@ -246,32 +278,54 @@ void ExperienceTracker::addExperiencePoints( Int experienceGain, Bool canScaleFoif( !isTrainable() )return; //safety- VeterancyLevel oldLevel = m_currentLevel;-Int amountToGain = experienceGain;if ( canScaleForBonus )amountToGain *= m_experienceScalar;+ // on a rank ladder one gain, a kill or a heal, lifts one grade at most+ const RankLadder *ladder = TheGlobalData->getRankLadder( m_parent->getTemplate() );+ if( ladder )+ amountToGain = ladder->clipGain( RankLadder::unitValue( m_parent->getTemplate() ), m_currentExperience, amountToGain );- m_currentExperience += amountToGain;+ applyExperience( m_currentExperience + amountToGain, TRUE );+}+//-------------------------------------------------------------------------------------------------+void ExperienceTracker::recomputeRank()+{+ const ThingTemplate *thing = m_parent->getTemplate();+ const RankLadder *ladder = TheGlobalData->getRankLadder( thing );+ if( ladder )+ {+ m_currentGrade = ladder->gradeOf( RankLadder::unitValue( thing ), m_currentExperience );+ m_currentLevel = ladder->levelOf( m_currentGrade );+ return;+ }++ m_currentGrade = 0;Int levelIndex = 0;- while( ( (levelIndex + 1) < LEVEL_COUNT)- && m_currentExperience >= m_parent->getTemplate()->getExperienceRequired(levelIndex + 1)+ while( ( (levelIndex + 1) < LEVEL_COUNT)+ && m_currentExperience >= thing->getExperienceRequired(levelIndex + 1)){// If there is a higher level to qualify for, and I qualify for it, advance the indexlevelIndex++;}-m_currentLevel = (VeterancyLevel)levelIndex;+}- if( oldLevel != m_currentLevel )- {- // Edge trigger special level gain effects.- m_parent->onVeterancyLevelChanged( oldLevel, m_currentLevel );- }+//-------------------------------------------------------------------------------------------------+void ExperienceTracker::applyExperience( Int experience, Bool provideFeedback )+{+ const VeterancyLevel oldLevel = m_currentLevel;+ const Int oldGrade = m_currentGrade;++ m_currentExperience = experience;+ recomputeRank();+ // Edge trigger special level gain effects; a grade moving inside one level counts too.+ if( oldLevel != m_currentLevel || oldGrade != m_currentGrade )+ m_parent->onRankChanged( oldLevel, m_currentLevel, oldGrade, m_currentGrade, provideFeedback ); //<<== this may be a level lost}//-------------------------------------------------------------------------------------------------void ExperienceTracker::setExperienceAndLevel( Int experienceIn, Bool provideFeedback )@@ -291,27 +345,7 @@ void ExperienceTracker::setExperienceAndLevel( Int experienceIn, Bool provideFeeif( !isTrainable() )return; //safety- VeterancyLevel oldLevel = m_currentLevel;-- m_currentExperience = experienceIn;-- Int levelIndex = 0;- while( ( (levelIndex + 1) < LEVEL_COUNT)- && m_currentExperience >= m_parent->getTemplate()->getExperienceRequired(levelIndex + 1)- )- {- // If there is a level to qualify for, and I qualify for it, advance the index- levelIndex++;- }-- m_currentLevel = (VeterancyLevel)levelIndex;-- if( oldLevel != m_currentLevel )- {- // Edge trigger special level gain effects.- m_parent->onVeterancyLevelChanged( oldLevel, m_currentLevel, provideFeedback ); //<<== paradox! this may be a level lost!- }-+ applyExperience( experienceIn, provideFeedback );}//-----------------------------------------------------------------------------@@ -359,6 +393,13 @@ void ExperienceTracker::xfer( Xfer *xfer )// current experiencexfer->xferInt( &m_currentExperience );+ // the grade is not saved; it follows from the experience+ if( xfer->getXferMode() == XFER_LOAD )+ {+ const RankLadder *ladder = TheGlobalData->getRankLadder( m_parent->getTemplate() );+ m_currentGrade = ladder ? ladder->gradeOf( RankLadder::unitValue( m_parent->getTemplate() ), m_currentExperience ) : 0;+ }+// experience sinkxfer->xferObjectID( &m_experienceSink );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex 1eecb644e..72405d9d0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -71,6 +71,7 @@#include "GameLogic/Module/AutoHealBehavior.h"#include "GameLogic/Module/BehaviorModule.h"#include "GameLogic/Module/BodyModule.h"+#include "Common/LogicThread.h"#include "GameLogic/Module/CollideModule.h"#include "GameLogic/Module/ContainModule.h"#include "GameLogic/Module/CountermeasuresBehavior.h"@@ -3282,7 +3283,14 @@ void Object::scoreTheKill( const Object *victim )//-------------------------------------------------------------------------------------------------VeterancyLevel Object::getVeterancyLevel() const{- return m_experienceTracker ? m_experienceTracker->getVeterancyLevel() : LEVEL_REGULAR;+ return m_experienceTracker ? m_experienceTracker->getVeterancyLevel() : LEVEL_REGULAR;+}++//-------------------------------------------------------------------------------------------------+// the AI module picks its locomotors, and reads the speed bonus, before the tracker exists+Int Object::getRankGrade() const+{+ return m_experienceTracker ? m_experienceTracker->getGrade() : 0;}//-------------------------------------------------------------------------------------------------@@ -3472,6 +3480,66 @@ Bool Object::hasAnySpecialPower() constreturn SPECIALPOWERMASK_ANY_SET( m_specialPowerBits );}+//-------------------------------------------------------------------------------------------------+void Object::onRankChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Int oldGrade, Int newGrade, Bool provideFeedback )+{+ if( isEffectivelyDead() )+ return;++ // max health carries the grade's bonus on a ladder and the level's anywhere else+ BodyModuleInterface* body = getBodyModule();+ const Real oldBonus = TheGlobalData->getRankHealthBonus( getTemplate(), oldLevel, oldGrade );+ const Real newBonus = TheGlobalData->getRankHealthBonus( getTemplate(), newLevel, newGrade );+ if( body && oldBonus != newBonus )+ body->setMaxHealth( body->getMaxHealth() * newBonus / oldBonus, PRESERVE_RATIO );++ if( oldLevel != newLevel )+ onVeterancyLevelChanged( oldLevel, newLevel, provideFeedback );+ else if( m_ai )+ m_ai->refreshVeterancySpeed();++ const RankLadder *ladder = TheGlobalData->getRankLadder( getTemplate() );+ if( ladder == NULL || newGrade == oldGrade )+ return;++ DEBUG_LOG(("RANK frame=%d template=%s grade %d to %d xp=%d\n", TheGameLogic->getFrame(), getTemplate()->getName().str(),+ oldGrade, newGrade, getExperienceTracker()->getCurrentExperience()));++ if( newGrade > oldGrade && provideFeedback && TheGameLogic->getDrawIconUI() && isLogicallyVisible() && !isKindOf( KINDOF_IGNORED_IN_GUI )+ && Drawable::getRankInsignia( this ) != NULL )+ floatRankGain( ladder->insigniaIndex( newGrade, isKindOf( KINDOF_HERO ) ) );++ // the portrait shows the grade, so a selected unit's bar redraws; the selection is the client's,+ // so the client asks after the tick+ const ObjectID objID = getID();+ LogicThread::callAfterTick( [objID]()+ {+ Drawable *draw = TheInGameUI->getFirstSelectedDrawable();+ if( draw && draw->getObject() && draw->getObject()->getID() == objID )+ TheControlBar->markUIDirty();+ } );+}++//-------------------------------------------------------------------------------------------------+/** The promotion floating up over the unit: a rank ladder's insignia, or EA's chevron animation for+ * insignia -1. */+//-------------------------------------------------------------------------------------------------+void Object::floatRankGain( Int insignia )+{+ if( TheAnim2DCollection == NULL || TheGlobalData->m_levelGainAnimationName.isEmpty() )+ return;++ Anim2DTemplate *animTemplate = TheAnim2DCollection->findTemplate( TheGlobalData->m_levelGainAnimationName );+ Coord3D pos = *getPosition();+ pos.add(&m_healthBoxOffset);+ TheInGameUI->addWorldAnimation( animTemplate,+ &pos,+ WORLD_ANIM_FADE_ON_EXPIRE,+ TheGlobalData->m_levelGainAnimationDisplayTimeInSeconds,+ TheGlobalData->m_levelGainAnimationZRisePerSecond,+ insignia < 0 ? NULL : getTemplate(), insignia );+}+//-------------------------------------------------------------------------------------------------void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback ){@@ -3550,20 +3618,9 @@ void Object::onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel neif( doAnimation && TheGameLogic->getDrawIconUI() && provideFeedback ){- if( TheAnim2DCollection && TheGlobalData->m_levelGainAnimationName.isEmpty() == FALSE )- {- Anim2DTemplate *animTemplate = TheAnim2DCollection->findTemplate( TheGlobalData->m_levelGainAnimationName );-- Coord3D pos = *getPosition();- pos.add(&m_healthBoxOffset);-- TheInGameUI->addWorldAnimation( animTemplate,- &pos,- WORLD_ANIM_FADE_ON_EXPIRE,- TheGlobalData->m_levelGainAnimationDisplayTimeInSeconds,- TheGlobalData->m_levelGainAnimationZRisePerSecond,- getTemplate(), newLevel );- }+ // a unit on a rank ladder floats each grade's insignia from onRankChanged instead+ if( TheGlobalData->getRankLadder( getTemplate() ) == NULL )+ floatRankGain( -1 );AudioEventRTS soundToPlay = TheAudio->getMiscAudio()->m_unitPromoted;soundToPlay.setObjectID( getID() );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 672b42216..7c6b0bdf8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -1057,7 +1057,7 @@ Bool AIUpdateInterface::chooseLocomotorSetExplicit(LocomotorSetType wst)void AIUpdateInterface::refreshVeterancySpeed(){const Object* obj = getObject();- m_locomotorSet.setSpeedFactor(TheGlobalData->getVeterancySpeedBonus(obj->getTemplate(), obj->getVeterancyLevel()));+ m_locomotorSet.setSpeedFactor(TheGlobalData->getRankStat(obj->getTemplate(), obj->getRankGrade(), RANK_STAT_SPEED));}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/MaxHealthUpgrade.cppindex 179959b4e..b3fb0803b 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->getVeterancyHealthBonus( obj->getTemplate(), obj->getVeterancyLevel() );+ Real add = data->m_addMaxHealth * TheGlobalData->getRankHealthBonus( obj->getTemplate(), obj->getVeterancyLevel(), obj->getRankGrade() );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 e3f357515..fee4417f4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -2121,15 +2121,22 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraBflags |= theirContain->getWeaponBonusPassedToPassengers();}- // 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)+ // a unit on a rank ladder takes its grade's rate of fire, damage and range instead of the global+ // VETERAN, ELITE and HERO lines, and from the Veteran pin its side's own lines (China's horde)+ const ThingTemplate* sourceTemplate = source->getTemplate();+ const RankLadder* ladder = TheGlobalData->getRankLadder(sourceTemplate);+ if (ladder){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);+ const WeaponBonusSet* sideSet = TheGlobalData->getVeterancyWeaponBonus(sourceTemplate, source->getVeterancyLevel());+ if (sideSet)+ sideSet->appendBonuses(flags, bonus);+ const Real* stat = ladder->m_stat[MIN(source->getRankGrade(), ladder->m_grades)];+ bonus.setField(WeaponBonus::RATE_OF_FIRE, bonus.getField(WeaponBonus::RATE_OF_FIRE) + stat[RANK_STAT_RATE_OF_FIRE] - 1.0f);+ bonus.setField(WeaponBonus::DAMAGE, bonus.getField(WeaponBonus::DAMAGE) + stat[RANK_STAT_DAMAGE] - 1.0f);+ bonus.setField(WeaponBonus::RANGE, bonus.getField(WeaponBonus::RANGE) + stat[RANK_STAT_RANGE] - 1.0f);}else if (TheGlobalData->m_weaponBonusSet)TheGlobalData->m_weaponBonusSet->appendBonuses(flags, bonus);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cppindex 7b75d139c..e393ef811 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp@@ -5037,7 +5037,7 @@ void GameLogic::update( void ){for( Object *obj = m_objList; obj; obj = obj->getNextObject() ){- const Real share = TheGlobalData->getVeterancySelfRepair( obj->getTemplate(), obj->getVeterancyLevel() );+ const Real share = TheGlobalData->getRankStat( obj->getTemplate(), obj->getRankGrade(), RANK_STAT_SELF_REPAIR );if( share <= 0.0f || obj->isEffectivelyDead() )continue;const BodyModuleInterface *body = obj->getBodyModule();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 8552990b7..d8c844602 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -474,6 +474,15 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *acase SCENARIO_ACTION_RANK:action->name = tokens[ SCENARIO_STANCE_NAME_TOKEN ];+ // xp N: N same-class kills of experience; grade N: the ladder's grade N+ if (action->name == "xp" || action->name == "grade")+ {+ if (count <= SCENARIO_STANCE_NAME_TOKEN + 1)+ return SCENARIO_PARSE_MISSING_ARGS;+ if (!parseWholeNumber( tokens[ SCENARIO_STANCE_NAME_TOKEN + 1 ], &action->count ))+ return SCENARIO_PARSE_BAD_COUNT;+ break;+ }if (action->name != "veteran" && action->name != "elite" && action->name != "heroic")return SCENARIO_PARSE_BAD_ACTION;break;@@ -1819,9 +1828,23 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Co: 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()));+ {+ Object *obj = TheGameLogic->findObjectByID( *it );+ ExperienceTracker *tracker = obj->getExperienceTracker();+ const RankLadder *ladder = TheGlobalData->getRankLadder( obj->getTemplate() );+ const Int unitValue = RankLadder::unitValue( obj->getTemplate() );+ if (action.name == "xp")+ tracker->setExperienceAndLevel( action.count * unitValue );+ else if (action.name == "grade" && ladder)+ tracker->setExperienceAndLevel( ladder->threshold( unitValue, action.count ) );+ else if (action.name != "grade")+ tracker->setVeterancyLevel( level );+ DEBUG_LOG(("SCENARIO: frame %d rank slot %d '%s' %s xp=%d grade=%d level=%d\n", action.frame, action.slot,+ obj->getTemplate()->getName().str(), action.name.str(), tracker->getCurrentExperience(),+ tracker->getGrade(), (Int)tracker->getVeterancyLevel()));+ }+ DEBUG_LOG(("SCENARIO: frame %d rank slot %d '%s' x%d %s %d\n",+ action.frame, action.slot, action.selector.str(), taken, action.name.str(), action.count));break;}diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cppindex 023992548..047bf3511 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp@@ -122,6 +122,28 @@ static const Real CLASSIC_KEY_BADGE_DESIGN_POINTS = 12.0f;* 800 and height over 600 - so the wider the screen against its height, the faster the lettering* grew away from the buttons it sits on. At 2560x1080 the markings came out half again too big.* One design size, times the bar's own scale, and a cameo looks the same on every monitor. */+//=============================================================================+/** EA's overlays (the chevrons) are drawn over the whole button. An image with its own DisplayHeight,+ * a rank insignia cropped to its ink, keeps its shape in the top left corner instead: that many+ * forty-eighths of the button's height, as wide as its shape says, up to half the button. */+static void drawOverlayImage( const Image *image, Int x, Int y, Int width, Int height )+{+ if( image->getDisplayHeight() <= 0 )+ {+ TheDisplay->drawImage( image, x, y, x + width, y + height );+ return;+ }+ Real high = height * image->getDisplayHeight() / 48.0f;+ Real wide = high * image->getImageWidth() / image->getImageHeight();+ if( wide > width * 0.5f )+ {+ high *= width * 0.5f / wide;+ wide = width * 0.5f;+ }+ const Int inset = 2;+ TheDisplay->drawImage( image, x + inset, y + inset, x + inset + REAL_TO_INT( wide ), y + inset + REAL_TO_INT( high ) );+}+//=============================================================================static GameFont *getBadgeFont( GameWindow *window, Real designPoints = BADGE_DESIGN_POINTS ){@@ -507,7 +529,7 @@ void W3DGadgetPushButtonDraw( GameWindow *window, WinInstanceData *instData )if( pData->overlayImage ){//Render the overlay image now.- TheDisplay->drawImage( pData->overlayImage, origin.x, origin.y, origin.x + size.x, origin.y + size.y );+ drawOverlayImage( pData->overlayImage, origin.x, origin.y, size.x, size.y );}if( pData->drawClock )@@ -684,7 +706,7 @@ void W3DGadgetPushButtonImageDrawOne( GameWindow *window,if( pData->overlayImage ){//Render the overlay image now.- TheDisplay->drawImage( pData->overlayImage, start.x, start.y, start.x + size.x, start.y + size.y );+ drawOverlayImage( pData->overlayImage, start.x, start.y, size.x, size.y );}if( pData->drawClock )@@ -952,7 +974,7 @@ void W3DGadgetPushButtonImageDrawThree(GameWindow *window, WinInstanceData *instif( pData->overlayImage ){//Render the overlay image now.- TheDisplay->drawImage( pData->overlayImage, origin.x, origin.y, origin.x + size.x, origin.y + size.y );+ drawOverlayImage( pData->overlayImage, origin.x, origin.y, size.x, size.y );}if( pData->drawClock )diff --git a/GeneralsMD/Code/Tests/test_rank_ladder.cpp b/GeneralsMD/Code/Tests/test_rank_ladder.cppnew file mode 100644index 000000000..8870c658d--- /dev/null+++ b/GeneralsMD/Code/Tests/test_rank_ladder.cpp@@ -0,0 +1,161 @@+/*+ * The rank ladder's arithmetic (RankLadder in GlobalData.h, docs/plans/RANK-LADDER.md in the+ * wrapper): the ratio each side's length and top give, the thresholds, the EA level on the pins, the+ * one-grade clip and the stat split.+ */+/* crc.h pulls winsock2.h, so it has to come before anything that drags in windows.h */+#include "Common/crc.h"++#include "test_harness.h"++#include <math.h>++#include "Common/GlobalData.h"++/* BalanceReforged.ini's Veterancy block, one side at a time */+static RankLadder makeLadder( Int grades, Int veteran, Int elite, Int heroic, Int heroStart,+ Real rateOfFire, Real damage, Real health )+{+ RankLadder ladder;+ ladder.clear();+ ladder.m_grades = grades;+ ladder.m_top = 120.0f;+ ladder.m_pin[LEVEL_VETERAN] = veteran;+ ladder.m_pin[LEVEL_ELITE] = elite;+ ladder.m_pin[LEVEL_HEROIC] = heroic;+ ladder.m_heroStart = heroStart;+ ladder.m_statTop[RANK_STAT_RATE_OF_FIRE] = rateOfFire;+ ladder.m_statTop[RANK_STAT_DAMAGE] = damage;+ ladder.m_statTop[RANK_STAT_HEALTH] = health;+ ladder.finish( 1.4f );+ return ladder;+}++static RankLadder america() { return makeLadder( 28, 4, 13, 22, 23, 1.42f, 1.19f, 1.42f ); }+static RankLadder china() { return makeLadder( 19, 4, 10, 15, 15, 1.30f, 1.19f, 1.55f ); }+static RankLadder gla() { return makeLadder( 20, 4, 10, 15, 15, 1.48f, 1.14f, 1.42f ); }++TEST(rank_ladder_ratio_puts_every_top_at_120_kills)+{+ /* grade 0 is unranked on every side, so China's Private and GLA's Recruit are grade 1 */+ CHECK_NEAR( america().m_ratio, 1.0935f, 0.0005f );+ CHECK_NEAR( china().m_ratio, 1.1775f, 0.0005f );+ CHECK_NEAR( gla().m_ratio, 1.1633f, 0.0005f );++ /* a Crusader, E 100: 12,000 to General of the Army, one kill to E-2 */+ const RankLadder usa = america();+ CHECK_NEAR( usa.threshold( 100, 28 ), 12000, 1 );+ CHECK_EQ( usa.threshold( 100, 1 ), 100 );+ CHECK_EQ( usa.threshold( 100, 0 ), 0 );+ /* the doc's table: Corporal 4.6 E, Warrant Officer 23.5 E, Lieutenant Colonel 65.7 E */+ CHECK_NEAR( usa.threshold( 100, 4 ), 460, 1 );+ CHECK_NEAR( usa.threshold( 100, 13 ), 2350, 3 );+ CHECK_NEAR( usa.threshold( 100, 22 ), 6570, 5 );+ /* the Heroic pins: China's Colonel 59.7 E, GLA's Warlord 53.1 E */+ CHECK_NEAR( china().threshold( 100, 15 ), 5972, 5 );+ CHECK_NEAR( gla().threshold( 100, 15 ), 5308, 5 );+ CHECK_EQ( china().threshold( 100, 1 ), 100 );+ CHECK_EQ( gla().threshold( 100, 1 ), 100 );+}++TEST(rank_ladder_small_values_round_once_and_never_fall_back)+{+ /* the Red Guard's E of 5: each threshold is rounded from the sum, never step by step */+ const RankLadder ladder = china();+ for( Int grade = 1; grade <= ladder.m_grades; ++grade )+ CHECK( ladder.threshold( 5, grade ) >= ladder.threshold( 5, grade - 1 ) );+ CHECK_NEAR( ladder.threshold( 5, 19 ), 600, 1 );+}++TEST(rank_ladder_grade_and_level_follow_experience_and_pins)+{+ const RankLadder usa = america();+ const Int corporal = usa.threshold( 100, 4 );+ CHECK_EQ( usa.gradeOf( 100, corporal - 1 ), 3 );+ CHECK_EQ( usa.gradeOf( 100, corporal ), 4 );+ CHECK_EQ( usa.gradeOf( 100, 0 ), 0 );+ CHECK_EQ( usa.gradeOf( 100, 1000000 ), 28 );++ CHECK_EQ( (Int)usa.levelOf( 3 ), (Int)LEVEL_REGULAR );+ CHECK_EQ( (Int)usa.levelOf( 4 ), (Int)LEVEL_VETERAN );+ CHECK_EQ( (Int)usa.levelOf( 12 ), (Int)LEVEL_VETERAN );+ CHECK_EQ( (Int)usa.levelOf( 13 ), (Int)LEVEL_ELITE );+ CHECK_EQ( (Int)usa.levelOf( 21 ), (Int)LEVEL_ELITE );+ CHECK_EQ( (Int)usa.levelOf( 22 ), (Int)LEVEL_HEROIC );+ CHECK_EQ( (Int)usa.levelOf( 28 ), (Int)LEVEL_HEROIC );+ CHECK_EQ( (Int)china().levelOf( 0 ), (Int)LEVEL_REGULAR );+ CHECK_EQ( (Int)china().levelOf( 3 ), (Int)LEVEL_REGULAR );+ CHECK_EQ( (Int)china().levelOf( 4 ), (Int)LEVEL_VETERAN );+ CHECK_EQ( (Int)china().levelOf( 14 ), (Int)LEVEL_ELITE );+ CHECK_EQ( (Int)china().levelOf( 15 ), (Int)LEVEL_HEROIC );+ CHECK_EQ( (Int)gla().levelOf( 9 ), (Int)LEVEL_VETERAN );+ CHECK_EQ( (Int)gla().levelOf( 10 ), (Int)LEVEL_ELITE );+}++TEST(rank_ladder_one_gain_lifts_one_grade_at_most)+{+ const RankLadder usa = america();++ /* a Ranger (E 20) at grade 0 kills a Crusader worth 100: he stops one point short of grade 2 */+ const Int ranger = usa.clipGain( 20, 0, 100 );+ CHECK_EQ( ranger, usa.threshold( 20, 2 ) - 1 );+ CHECK_EQ( usa.gradeOf( 20, ranger ), 1 );++ /* a gain that fits is untouched */+ CHECK_EQ( usa.clipGain( 100, 0, 150 ), 150 );++ /* halfway through a grade the cap is still the second threshold above it */+ const Int mid = usa.threshold( 100, 10 ) + 50;+ CHECK_EQ( usa.clipGain( 100, mid, 100000 ), usa.threshold( 100, 12 ) - 1 - mid );+ CHECK_EQ( usa.gradeOf( 100, mid + usa.clipGain( 100, mid, 100000 ) ), 11 );++ /* from the next-to-last grade on nothing is clipped, and experience keeps growing past the top */+ CHECK_EQ( usa.clipGain( 100, usa.threshold( 100, 27 ), 100000 ), 100000 );+ CHECK_EQ( usa.clipGain( 100, usa.threshold( 100, 28 ) + 5, 777 ), 777 );+}++TEST(rank_ladder_stats_split_one_worth_curve)+{+ const RankLadder ladders[] = { america(), china(), gla() };+ for( Int side = 0; side < 3; ++side )+ {+ const RankLadder &ladder = ladders[ side ];+ const Real *bottom = ladder.m_stat[ 0 ];+ CHECK_NEAR( bottom[RANK_STAT_RATE_OF_FIRE] * bottom[RANK_STAT_DAMAGE] * bottom[RANK_STAT_HEALTH], 1.0f, 0.0001f );+ const Real *top = ladder.m_stat[ ladder.m_grades ];+ CHECK_NEAR( top[RANK_STAT_RATE_OF_FIRE] * top[RANK_STAT_DAMAGE] * top[RANK_STAT_HEALTH], 2.40f, 0.01f );+ /* worth = 1 + 1.4 sqrt(total / 120) at every grade */+ for( Int grade = 1; grade <= ladder.m_grades; ++grade )+ {+ const Real *stat = ladder.m_stat[ grade ];+ const Real worth = stat[RANK_STAT_RATE_OF_FIRE] * stat[RANK_STAT_DAMAGE] * stat[RANK_STAT_HEALTH];+ CHECK_NEAR( worth, 1.0f + 1.4f * sqrtf( ladder.m_total[ grade ] / 120.0f ), 0.01f );+ CHECK( stat[RANK_STAT_HEALTH] >= ladder.m_stat[ grade - 1 ][RANK_STAT_HEALTH] );+ }+ }+ /* the hand-rolled ln and e agree with the CRT's: each stat is its top value to ln(worth) / ln(2.4) */+ const RankLadder &usa = ladders[ 0 ];+ for( Int grade = 0; grade <= usa.m_grades; ++grade )+ {+ const double share = log( 1.0 + 1.4 * sqrt( ( usa.m_total[ grade ] < 120.0f ? usa.m_total[ grade ] : 120.0f ) / 120.0 ) ) / log( 2.4 );+ CHECK_NEAR( usa.m_stat[ grade ][RANK_STAT_HEALTH], pow( 1.42, share ), 0.00001 );+ CHECK_NEAR( usa.m_stat[ grade ][RANK_STAT_RANGE], 1.0, 0.00001 );+ }+ CHECK_NEAR( usa.m_stat[ usa.m_grades ][RANK_STAT_RATE_OF_FIRE], 1.42f, 0.0005f );++ /* the first kill is worth 1.13 everywhere */+ const Real *first = ladders[ 0 ].m_stat[ 1 ];+ CHECK_NEAR( first[RANK_STAT_RATE_OF_FIRE] * first[RANK_STAT_DAMAGE] * first[RANK_STAT_HEALTH], 1.13f, 0.005f );+}++TEST(rank_ladder_hero_insignia_runs_from_its_start_to_the_top)+{+ const RankLadder usa = america();+ CHECK_EQ( usa.insigniaIndex( 0, TRUE ), 23 );+ CHECK_EQ( usa.insigniaIndex( 28, TRUE ), 28 );+ CHECK_EQ( usa.insigniaIndex( 14, TRUE ), 25 );+ CHECK_EQ( usa.insigniaIndex( 14, FALSE ), 14 );+ CHECK_EQ( gla().insigniaIndex( 20, TRUE ), 20 );+ CHECK_EQ( china().insigniaIndex( 0, TRUE ), 15 );+ CHECK_EQ( china().insigniaIndex( 19, TRUE ), 19 );+}diff --git a/GeneralsMD/Code/Tools/rank_insignia_cells.py b/GeneralsMD/Code/Tools/rank_insignia_cells.pynew file mode 100644index 000000000..9e8a8cc7f--- /dev/null+++ b/GeneralsMD/Code/Tools/rank_insignia_cells.py@@ -0,0 +1,39 @@+"""The rank atlases' mapped images as the game reads them, shared by the three rank_insignia_*.py+generators: each cell cropped to its ink, so a row of stars or a warrant bar draws at its own shape+instead of squeezed into a square; named for its grade, Rank<Side>_<n> in the order the atlas holds+them, which is the order of the side's ladder; and the stacked or busy cells given DisplayHeight 14+where the rest draw 12 high. A cell with no ink (America's E-1) gets no image and draws nothing."""+import re++ENTRY = re.compile(r"MappedImage (\S+)\n(.*?)Coords = Left:(\d+) Top:(\d+) Right:(\d+) Bottom:(\d+)\n(.*?)End\n", re.S)+INK = 16 # alpha under this is the antialiasing's fringe, not ink+TALL = " DisplayHeight = 14\n"+++def ink_entries(atlas, ini_text, side, tall=()):+ """ini_text with every entry renamed, cropped and sized; tall holds the grades drawn 14 high."""+ alpha = atlas.getchannel("A").point(lambda v: 255 if v >= INK else 0)+ grades = iter(range(len(ENTRY.findall(ini_text))))++ def rewrite(match):+ grade = next(grades)+ left, top, right, bottom = (int(v) for v in match.group(3, 4, 5, 6))+ box = alpha.crop((left, top, right, bottom)).getbbox()+ if box is None:+ return ""+ return "MappedImage Rank%s_%d\n%sCoords = Left:%d Top:%d Right:%d Bottom:%d\n%s%sEnd\n" % (+ side, grade, match.group(2), left + box[0], top + box[1], left + box[2], top + box[3],+ match.group(7), TALL if grade in tall else "")++ return ENTRY.sub(rewrite, ini_text)+++if __name__ == "__main__":+ from PIL import Image+ test = Image.new("RGBA", (128, 64), (0, 0, 0, 0))+ test.paste((255, 255, 255, 255), (70, 10, 90, 20))+ entry = "MappedImage A\n Texture = t.tga\n Coords = Left:%d Top:0 Right:%d Bottom:64\n Status = NONE\nEnd\n"+ out = ink_entries(test, "; x\n" + entry % (0, 64) + entry % (64, 128), "Test", tall=(1,))+ assert "RankTest_0" not in out, out+ assert "MappedImage RankTest_1" in out and "Left:70 Top:10 Right:90 Bottom:20" in out and TALL in out, out+ print("ok")diff --git a/GeneralsMD/Code/Tools/rank_insignia_china.py b/GeneralsMD/Code/Tools/rank_insignia_china.pynew file mode 100644index 000000000..d1fbf9bdc--- /dev/null+++ b/GeneralsMD/Code/Tools/rank_insignia_china.py@@ -0,0 +1,230 @@+"""Rank marks for China, one for every rank of the PLA Ground Force, from private to general.++Each mark is the shoulder board's sign without the board, simplified for twelve to fourteen pixels+high: silver chevrons for conscripts, gold for sergeants, the senior sergeants' pine branches traded+for one to four pips beside three chevrons, a row of big stars over one stripe for company officers+and two for field officers, and the generals' stars over a thick laurel arc. A dark red edge and no+background, so they read over sand and grass the way the America and GLA marks do.++The ranks are the 2022 ones. The reform renamed two sergeant grades and kept their boards:+二级上士 was 上士 and 一级上士 was 四级军士长, so those two marks serve the old names as well.++ python Tools/rank_insignia_china.py+ writes Data/Art/Textures/ReforgedRanksChina.tga, one 64-pixel cell per rank, and the+ ReforgedRanksChina.ini that names each cell RankChina_<code>.++ python Tools/rank_insignia_china.py preview <png>+ also writes a labelled sheet of every mark at game size and at full size.++Drawn eight times too big and brought down, which is the antialiasing."""+import math+import os+import sys++from PIL import Image, ImageDraw, ImageFilter, ImageFont++from rank_insignia_cells import ink_entries++HERE = os.path.dirname(os.path.abspath(__file__))+SCALE = 8+CELL = 64+COLUMNS = 8+ROWS = 4+OUTLINE = 21 # a MaxFilter size, odd: the dark edge round every mark, 10 drawn pixels+EDGE = (40, 6, 4)+GOLD_TOP = (255, 226, 110)+GOLD_BOTTOM = (200, 128, 20)+NAME = "ReforgedRanksChina"+TEXTURE_PATH = os.path.join(HERE, "..", "Data", "Art", "Textures", NAME + ".tga")+INI_PATH = os.path.join(HERE, "..", "Data", "INI", "MappedImages", "HandCreated", NAME + ".ini")+INI_HEADER = """; China's rank marks, one per PLA Ground Force rank, all in one texture. Written by+; Tools/rank_insignia_china.py with the texture it names; do not edit by hand. Mapped images are+; not in the multiplayer INI checksum.+"""+INI_ENTRY = """+MappedImage RankChina_%s+ Texture = %s.tga+ TextureWidth = %d+ TextureHeight = %d+ Coords = Left:%d Top:%d Right:%d Bottom:%d+ Status = NONE+End+"""++CHEVRON = 8.0 # every chevron one weight: the board's thin and thick came out alike at game size+GAP = 3.5+RISE = 9.0+PIP = 5.5 # radius of a senior sergeant's pip+PIP_PITCH = 12.5+SILVER_TOP = (252, 252, 252)+SILVER_BOTTOM = (138, 146, 160)++# code, English, Chinese, what the mark is: chevrons with their count, pips beside and metal;+# conscripts wear silver so a private and a corporal part by colour, not by a chevron's thickness,+# and the senior sergeants keep three chevrons and count pips instead of pine needles+RANKS = (+ ("NONE", "Unranked", "", ("none",)), # grade 0 on every side: no mark, so the cell stays empty+ ("PVT", "Private", "列兵", ("chevrons", 1, 0, "silver")),+ ("PFC", "Private First Class", "上等兵", ("chevrons", 2, 0, "silver")),+ ("CPL", "Corporal", "下士", ("chevrons", 1, 0, "gold")),+ ("SGT", "Sergeant", "中士", ("chevrons", 2, 0, "gold")),+ ("SSG2", "Staff Sergeant 2nd Class (was Staff Sergeant 上士)", "二级上士", ("chevrons", 3, 0, "gold")),+ ("SSG1", "Staff Sergeant 1st Class (was Master Sergeant 4th Class 四级军士长)", "一级上士",+ ("chevrons", 3, 1, "gold")),+ ("MSG3", "Master Sergeant 3rd Class", "三级军士长", ("chevrons", 3, 2, "gold")),+ ("MSG2", "Master Sergeant 2nd Class", "二级军士长", ("chevrons", 3, 3, "gold")),+ ("MSG1", "Master Sergeant 1st Class", "一级军士长", ("chevrons", 3, 4, "gold")),+ ("2LT", "Second Lieutenant", "少尉", ("officer", 1, 1)),+ ("1LT", "First Lieutenant", "中尉", ("officer", 1, 2)),+ ("CPT", "Captain", "上尉", ("officer", 1, 3)),+ ("MAJ", "Major", "少校", ("officer", 2, 1)),+ ("LTC", "Lieutenant Colonel", "中校", ("officer", 2, 2)),+ ("COL", "Colonel", "上校", ("officer", 2, 3)),+ ("SCOL", "Senior Colonel", "大校", ("officer", 2, 4)),+ ("MG", "Major General", "少将", ("general", 1)),+ ("LTG", "Lieutenant General", "中将", ("general", 2)),+ ("GEN", "General", "上将", ("general", 3)),+)+++def scaled(points):+ """Points in shipped pixels, in drawn pixels."""+ return [(x * SCALE, y * SCALE) for x, y in points]+++def star(draw, cx, cy, radius):+ """A five-pointed star, point up."""+ points = []+ for i in range(10):+ r = radius if i % 2 == 0 else radius * 0.5+ angle = math.radians(-90 + 36 * i)+ points.append((cx + r * math.cos(angle), cy + r * math.sin(angle)))+ draw.polygon(scaled(points), fill=255)+++def stars(draw, count, cy, radius, pitch):+ """count stars in a row centred across the cell at height cy."""+ for i in range(count):+ star(draw, 32 + (i - (count - 1) / 2) * pitch, cy, radius)+++def chevron(draw, cx, top, half_width):+ """A chevron pointing up, its apex at (cx, top)."""+ draw.polygon(scaled([(cx, top), (cx + half_width, top + RISE), (cx + half_width, top + RISE + CHEVRON),+ (cx, top + CHEVRON), (cx - half_width, top + RISE + CHEVRON),+ (cx - half_width, top + RISE)]), fill=255)+++def pips(draw, count, cx, cy):+ """Up to four pips two by two, the top row filled first."""+ rows = [min(count, 2), count - 2] if count > 2 else [count]+ for r, in_row in enumerate(rows):+ y = cy + (r - (len(rows) - 1) / 2) * PIP_PITCH+ for c in range(in_row):+ x = cx + (c - 0.5) * PIP_PITCH+ draw.ellipse(scaled([(x - PIP, y - PIP), (x + PIP, y + PIP)]), fill=255)+++def mark(kind):+ """The shape of one rank's mark, white on black, CELL by CELL in drawn pixels."""+ shape = Image.new("L", (CELL * SCALE, CELL * SCALE), 0)+ draw = ImageDraw.Draw(shape)+ if kind[0] == "chevrons":+ _, count, pip_count, _ = kind+ height = count * CHEVRON + (count - 1) * GAP + RISE+ top = (CELL - height) / 2+ cx, half_width = (19, 16) if pip_count else (32, 26)+ for i in range(count):+ chevron(draw, cx, top + i * (CHEVRON + GAP), half_width)+ if pip_count:+ pips(draw, pip_count, 50, top + height / 2)+ elif kind[0] == "none":+ pass+ elif kind[0] == "officer":+ # big stars over the board's stripe, one for company officers and two for field officers+ _, stripe_count, count = kind+ # the stripe only as wide as the stars, so a lone star is not a dot on a long bar+ radius, pitch = 8.5, 16.5+ half = max(12, ((count - 1) * pitch) / 2 + radius + 2)+ stars(draw, count, 20, radius, pitch)+ for i in range(stripe_count):+ draw.rectangle(scaled([(32 - half, 30 + 6.5 * i), (32 + half, 34 + 6.5 * i)]), fill=255)+ else:+ # bigger stars over a plain thick laurel arc for the wreath+ _, count = kind+ stars(draw, count, 18, 9.5, 19.5)+ draw.arc(scaled([(5, -14), (59, 42)]), start=25, end=155, fill=255, width=round(5.5 * SCALE))+ return shape+++def finish(shape, kind):+ """The mark in its metal, light at the top and dark at the bottom, on its dark edge."""+ size = shape.size+ colour = Image.new("RGB", size)+ draw = ImageDraw.Draw(colour)+ top_colour, bottom_colour = (SILVER_TOP, SILVER_BOTTOM) if kind[-1] == "silver" else (GOLD_TOP, GOLD_BOTTOM)+ for y in range(size[1]):+ share = y / (size[1] - 1)+ draw.line((0, y, size[0], y), fill=tuple(round(top + (bottom - top) * share)+ for top, bottom in zip(top_colour, bottom_colour)))+ art = Image.composite(colour, Image.new("RGB", size, EDGE), shape)+ art.putalpha(shape.filter(ImageFilter.MaxFilter(OUTLINE)))+ return art.resize((CELL, CELL), Image.LANCZOS)+++def cell_origin(index):+ return (index % COLUMNS) * CELL, (index // COLUMNS) * CELL+++def build():+ atlas = Image.new("RGBA", (COLUMNS * CELL, ROWS * CELL), (0, 0, 0, 0))+ cells = []+ ini_text = INI_HEADER+ for index, (code, _, _, kind) in enumerate(RANKS):+ art = finish(mark(kind), kind)+ x, y = cell_origin(index)+ atlas.paste(art, (x, y))+ cells.append(art)+ ini_text += INI_ENTRY % (code, NAME, atlas.width, atlas.height, x, y, x + CELL, y + CELL)+ return atlas, cells, ini_text+++def preview(cells, path):+ """Every mark at 16 and 64 pixels on sand and on grass, with its name in both languages."""+ font = ImageFont.truetype("msyh.ttc", 15)+ small_font = ImageFont.truetype("msyh.ttc", 12)+ row_h, width = 76, 900+ sheet = Image.new("RGB", (width, 40 + row_h * len(RANKS)), (30, 32, 34))+ draw = ImageDraw.Draw(sheet)+ draw.text((10, 10), "China ranks RankChina_<code> (16 px game size and 64 px cell, on sand and grass)",+ font=font, fill=(230, 230, 230))+ for i, ((code, english, chinese, _), art) in enumerate(zip(RANKS, cells)):+ top = 40 + i * row_h+ for j, ground in enumerate(((196, 170, 112), (78, 106, 48))):+ left = 10 + j * 120+ draw.rectangle((left, top, left + 112, top + row_h - 6), fill=ground)+ small = art.resize((16, 16), Image.LANCZOS)+ sheet.paste(small, (left + 6, top + 28), small)+ sheet.paste(art, (left + 40, top + 3), art)+ draw.text((260, top + 10), "%s %s" % (chinese, english), font=font, fill=(240, 240, 240))+ draw.text((260, top + 36), "RankChina_" + code, font=small_font, fill=(170, 170, 170))+ os.makedirs(os.path.dirname(os.path.abspath(path)), exist_ok=True)+ sheet.save(path)+ print(path)+++def main():+ atlas, cells, ini_text = build()+ # the three-chevron sergeants, the two-stripe field officers and the generals draw 14 high+ ini_text = ink_entries(atlas, ini_text, "China", tall=list(range(5, 10)) + list(range(13, 20)))+ atlas.save(TEXTURE_PATH)+ print(TEXTURE_PATH)+ with open(INI_PATH, "w", newline="\r\n") as ini:+ ini.write(ini_text)+ print(INI_PATH)+ if len(sys.argv) == 3 and sys.argv[1] == "preview":+ preview(cells, sys.argv[2])+++if __name__ == "__main__":+ main()diff --git a/GeneralsMD/Code/Tools/rank_insignia_gla.py b/GeneralsMD/Code/Tools/rank_insignia_gla.pynew file mode 100644index 000000000..f0eb687de--- /dev/null+++ b/GeneralsMD/Code/Tools/rank_insignia_gla.py@@ -0,0 +1,348 @@+"""GLA's rank ladder: twenty marks for an army that never had a regulation one, from a recruit's+single scratch to the Supreme Liberator's toothed plate.++Five families, each a step up from the last, and inside a family bars or a backing plate count the+grades:+ fighters scratched tally strokes, one to four, then the struck five+ unit leaders crossed machetes, then one to three upright rust bars beside them+ commanders the skull, then a bar, then blades or rifles behind it, then a rust plate+ warlords the scorpion, then a bar, then rifles behind it+ generals the scorpion on a round plate, then on a toothed one, then the skull on the+ toothed plate with rifles behind++Bone, rust and khaki on a dark edge with no background, so a mark reads over any ground. The game+draws these twelve to fourteen pixels high, so every stroke is blunt and the dark edge is thick.++ python Tools/rank_insignia_gla.py+ writes Data/Art/Textures/ReforgedRanksGLA.tga, one 64-pixel cell per rank, and the+ ReforgedRanksGLA.ini that names each cell RankGLA_<n>_<name>.+ python Tools/rank_insignia_gla.py preview <png>+ also writes a labelled sheet of every mark at game size and full size.++Drawn eight times too big and brought down, which is the antialiasing. Same bytes on every run."""+import math+import os+import random+import sys++from PIL import Image, ImageChops, ImageDraw, ImageFilter, ImageFont++from rank_insignia_cells import ink_entries++import rank_insignia++HERE = os.path.dirname(os.path.abspath(__file__))+CELL = 64+COLUMNS = 8+ROWS = 4+SCALE = 8+EDGE = 3.2 # the dark edge round every element, in shipped pixels+DARK = (24, 18, 12)+BONE = (236, 228, 204)+RUST = (178, 76, 36)+KHAKI = (196, 174, 116)+SAND = (150, 128, 84)+NAME = "ReforgedRanksGLA"+TEXTURE_PATH = os.path.join(HERE, "..", "Data", "Art", "Textures", NAME + ".tga")+INI_PATH = os.path.join(HERE, "..", "Data", "INI", "MappedImages", "HandCreated", NAME + ".ini")+INI_HEADER = """; GLA's rank marks, one cell of %s.tga per rank from Recruit to Supreme Liberator. Written+; by Tools/rank_insignia_gla.py with the texture it names; do not edit by hand. Mapped images are+; not in the multiplayer INI checksum.+""" % NAME+INI_ENTRY = """+MappedImage %s+ Texture = %s.tga+ TextureWidth = %d+ TextureHeight = %d+ Coords = Left:%d Top:%d Right:%d Bottom:%d+ Status = NONE+End+"""+++class Pen:+ """Maps the 64-unit design square into drawn pixels, moved by (dx, dy) and shrunk by s round+ the cell centre, so a symbol can make room for the bars under it."""++ def __init__(self, dx=0.0, dy=0.0, s=1.0):+ self.dx, self.dy, self.s = dx, dy, s++ def point(self, x, y):+ return (round(((x - 32) * self.s + 32 + self.dx) * SCALE),+ round(((y - 32) * self.s + 32 + self.dy) * SCALE))++ def box(self, x0, y0, x1, y1):+ return self.point(x0, y0) + self.point(x1, y1)++ def width(self, units):+ return max(1, round(units * self.s * SCALE))+++def blank():+ return Image.new("L", (CELL * SCALE, CELL * SCALE), 0)+++def placed(points, angle, cx, cy):+ """Local points turned by angle degrees and moved to (cx, cy)."""+ c, s = math.cos(math.radians(angle)), math.sin(math.radians(angle))+ return [(cx + x * c - y * s, cy + x * s + y * c) for x, y in points]+++def polygon(pen, mask, points):+ ImageDraw.Draw(mask).polygon([pen.point(x, y) for x, y in points], fill=255)+++def strokes(pen, count, struck):+ """count scratched upright strokes, uneven like a knife cut them; struck adds the slash that+ closes a five."""+ mask = blank()+ rng = random.Random(count * 7 + struck)+ spacing = 11+ first = 32 - spacing * (count - 1) / 2+ for i in range(count):+ x = first + spacing * i + rng.uniform(-0.8, 0.8)+ lean = rng.uniform(-2.5, 2.5)+ top, bottom = 10 + rng.uniform(-1, 1.5), 54 + rng.uniform(-1.5, 1)+ polygon(pen, mask, [(x - 2.4 + lean, top), (x + 3.2 + lean, top + 1.2),+ (x + 3.6 - lean, bottom), (x - 3.0 - lean, bottom - 1.0)])+ if struck:+ polygon(pen, mask, [(6, 44), (9, 40), (58, 21), (57, 26)])+ return [(mask, BONE)]+++def blade(pen, angle, cx=32, cy=32):+ """A machete pointing along angle: bone blade, rust grip and guard."""+ metal, grip = blank(), blank()+ polygon(pen, metal, placed([(-4, -6), (19, -6.5), (28, -1), (20, 6), (-4, 6)], angle, cx, cy))+ polygon(pen, grip, placed([(-22, -4.2), (-5, -4.2), (-5, 4.2), (-22, 4.2)], angle, cx, cy))+ polygon(pen, grip, placed([(-8, -9), (-3.5, -9), (-3.5, 9), (-8, 9)], angle, cx, cy))+ return [(metal, BONE), (grip, RUST)]+++def rifle(pen, angle, cx=32, cy=32):+ """A rifle silhouette pointing along angle, magazine curling under, all khaki."""+ mask = blank()+ for part in ([(-27, -3), (-14, -4), (-14, 4), (-27, 7)], # stock+ [(-15, -4), (10, -4), (10, 3), (-15, 3)], # receiver+ [(9, -3), (28, -3), (28, 1), (9, 1)], # barrel+ [(-5, 2), (1, 2), (5, 11), (-1, 12)]): # magazine+ polygon(pen, mask, placed(part, angle, cx, cy))+ return [(mask, KHAKI)]+++def crossed(item, pen, spread, cx=32, cy=32):+ """Two of item crossed at +-spread degrees, the second drawn over the first."""+ return item(pen, 180 + spread, cx, cy) + item(pen, -spread, cx, cy)+++def skull(pen, size, cx=32, cy=32):+ """rank_insignia's skull, size units across, centred on (cx, cy)."""+ shape, _ = rank_insignia.skull()+ drawn = pen.width(size)+ shape = shape.resize((drawn, drawn), Image.LANCZOS).point(lambda v: 255 if v > 127 else 0)+ mask = blank()+ x, y = pen.point(cx - size / 2, cy - size / 2)+ mask.paste(shape, (x, y))+ return [(mask, BONE)]+++def scorpion(pen, colour, cx=32, cy=30, k=1.0):+ """A scorpion seen from above, head up, pincers forward and the tail curling round its right.+ No legs and no jaw gaps: at twelve pixels they were the scribble round a blob, and the body, the+ two claws and the hooked tail are what reads."""+ mask = blank()+ draw = ImageDraw.Draw(mask)++ def at(x, y):+ return cx + x * k, cy + y * k++ def ellipse(x0, y0, x1, y1):+ draw.ellipse(pen.box(*at(x0, y0), *at(x1, y1)), fill=255)++ def line(points, width):+ draw.line([pen.point(*at(x, y)) for x, y in points], fill=255, width=pen.width(width * k),+ joint="curve")++ for side in (-1, 1):+ line([(side * 4, -6), (side * 14, -10), (side * 16, -17)], 5) # arm+ ellipse(side * 16 - 6.5, -27, side * 16 + 6.5, -14) # claw+ ellipse(-8, -5, 8, 14) # body+ ellipse(-6.5, -13, 6.5, -1) # head+ tail = [(0, 16), (3, 22), (8, 25), (14, 24), (18, 19)]+ for (x, y), r in zip(tail, (5.2, 5.0, 4.8, 4.6, 4.4)):+ ellipse(x - r, y - r, x + r, y + r)+ draw.polygon([pen.point(*at(x, y)) for x, y in ((15, 16), (22, 9), (23, 19))], fill=255) # sting+ return [(mask, colour)]+++ROOM_LEFT, ROOM_RIGHT = 3.5, 60.5 # inside the dark edge's reach of the cell's sides+BAR_PITCH, BAR_WIDTH = 8, 4.4+++def bars(count):+ """count upright rust bars at the cell's right, rough at the ends like cut cloth, each its own+ layer so the dark edge parts it from the next."""+ layers = []+ pen = Pen()+ for i in range(count):+ mask = blank()+ right = ROOM_RIGHT - BAR_PITCH * (count - 1 - i)+ left = right - BAR_WIDTH+ polygon(pen, mask, [(left + 0.5, 15), (right, 16), (right - 0.4, 48), (left, 47.5)])+ layers.append((mask, RUST))+ return layers+++def plate(teeth):+ """The rust disc the top ranks stand on; teeth gives it a saw rim of scrap metal, few and deep+ so the rim still reads as teeth at twelve pixels."""+ mask = blank()+ pen = Pen()+ if teeth:+ points = []+ for i in range(teeth * 2):+ r = 29 if i % 2 == 0 else 21.5+ a = math.pi * i / teeth - math.pi / 2+ points.append((32 + r * math.cos(a), 32 + r * math.sin(a)))+ polygon(pen, mask, points)+ else:+ ImageDraw.Draw(mask).ellipse(pen.box(6, 6, 58, 58), fill=255)+ return [(mask, RUST)]+++def with_bars(symbol, count):+ """symbol moved left and shrunk only as far as the count bars beside it need: under it they+ squeezed the symbol to two thirds and the bars to slivers."""+ bar_room = BAR_PITCH * count+ centre = (ROOM_LEFT + ROOM_RIGHT - bar_room) / 2+ scale = (ROOM_RIGHT - ROOM_LEFT - bar_room) / (ROOM_RIGHT - ROOM_LEFT - 2)+ return symbol(Pen(centre - 32, 0, scale)) + bars(count)+++RANKS = (+ ("Unranked", "grade 0 on every side: no mark, so the cell stays empty", lambda: [(blank(), BONE)]),+ ("Recruit", "one scratched stroke", lambda: strokes(Pen(), 1, False)),+ ("Irregular", "two scratched strokes", lambda: strokes(Pen(), 2, False)),+ ("Fighter", "three scratched strokes", lambda: strokes(Pen(), 3, False)),+ ("Raider", "four scratched strokes", lambda: strokes(Pen(), 4, False)),+ ("HardenedRaider", "four strokes struck through, the tally of five",+ lambda: strokes(Pen(), 4, True)),+ ("Squadhand", "crossed machetes", lambda: crossed(blade, Pen(), 45)),+ ("SquadLeader", "crossed machetes over one rust bar",+ lambda: with_bars(lambda pen: crossed(blade, pen, 45), 1)),+ ("CellLeader", "crossed machetes over two rust bars",+ lambda: with_bars(lambda pen: crossed(blade, pen, 45), 2)),+ ("SeniorCellLeader", "crossed machetes over three rust bars",+ lambda: with_bars(lambda pen: crossed(blade, pen, 45), 3)),+ ("RaidCaptain", "the skull", lambda: skull(Pen(), 46)),+ ("ColumnCaptain", "the skull over one rust bar",+ lambda: with_bars(lambda pen: skull(pen, 46), 1)),+ ("StrikeCommander", "the skull on crossed machetes",+ lambda: crossed(blade, Pen(), 40) + skull(Pen(), 38)),+ ("FieldCommander", "the skull on crossed rifles",+ lambda: crossed(rifle, Pen(), 40) + skull(Pen(), 38)),+ ("SectorCommander", "the skull on crossed rifles and a rust plate",+ lambda: plate(0) + crossed(rifle, Pen(), 40) + skull(Pen(), 42)),+ ("Warlord", "the khaki scorpion", lambda: scorpion(Pen(), KHAKI)),+ ("RegionalWarlord", "the khaki scorpion over one rust bar",+ lambda: with_bars(lambda pen: scorpion(pen, KHAKI), 1)),+ ("HighWarlord", "the bone scorpion on crossed rifles",+ lambda: crossed(rifle, Pen(), 40) + scorpion(Pen(), BONE, 32, 30, 0.85)),+ ("General", "the bone scorpion on a round rust plate",+ lambda: plate(0) + scorpion(Pen(), BONE, 32, 30, 0.8)),+ ("GrandGeneral", "the bone scorpion on a toothed rust plate",+ lambda: plate(8) + scorpion(Pen(), BONE, 32, 30, 0.72)),+ ("SupremeLiberator", "the skull on a toothed rust plate with crossed rifles behind it",+ lambda: crossed(rifle, Pen(), 40) + plate(8) + skull(Pen(), 40)),+)+++def dilated(mask):+ """mask grown by EDGE shipped pixels with round corners: a blur thresholded just above zero."""+ radius = EDGE * SCALE / 2+ return mask.filter(ImageFilter.GaussianBlur(radius)).point(lambda v: 255 if v > 6 else 0)+++def finish(layers):+ """Layers painted bottom up, each over a dark edge of its own, so crossing parts stay apart."""+ size = layers[0][0].size+ art = Image.new("RGB", size, DARK)+ alpha = Image.new("L", size, 0)+ dark = Image.new("RGB", size, DARK)+ for mask, colour in layers:+ edge = dilated(mask)+ art.paste(dark, (0, 0), edge)+ art.paste(Image.new("RGB", size, colour), (0, 0), mask)+ alpha = ImageChops.lighter(alpha, edge)+ art.putalpha(alpha)+ return art.resize((CELL, CELL), Image.LANCZOS)+++def image_name(index, name):+ return "RankGLA_%d_%s" % (index + 1, name)+++def build():+ """The atlas and the INI text."""+ atlas = Image.new("RGBA", (CELL * COLUMNS, CELL * ROWS), DARK + (0,))+ ini_text = INI_HEADER+ for index, (name, _, draw) in enumerate(RANKS):+ left, top = index % COLUMNS * CELL, index // COLUMNS * CELL+ atlas.paste(finish(draw()), (left, top))+ ini_text += INI_ENTRY % (image_name(index, name), NAME, atlas.width, atlas.height,+ left, top, left + CELL, top + CELL)+ return atlas, ini_text+++def preview(atlas, path):+ """Every mark at 12 and 16 pixels, as the game minifies it, and at its full 64, over dark+ ground and sand, with its name."""+ font = ImageFont.truetype("arialbd.ttf", 15)+ small = ImageFont.truetype("arial.ttf", 12)+ card_w, card_h, columns = 380, 92, 4+ sheet = Image.new("RGB", (card_w * columns, card_h * math.ceil(len(RANKS) / columns)), (40, 38, 34))+ draw = ImageDraw.Draw(sheet)+ for index, (name, about, _) in enumerate(RANKS):+ x0, y0 = index % columns * card_w, index // columns * card_h+ cell = atlas.crop((index % COLUMNS * CELL, index // COLUMNS * CELL,+ index % COLUMNS * CELL + CELL, index // COLUMNS * CELL + CELL))+ draw.rectangle((x0 + 4, y0 + 4, x0 + 76, y0 + 76), fill=(70, 74, 58))+ sheet.paste(cell, (x0 + 8, y0 + 8), cell)+ for column, ground in enumerate(((70, 74, 58), (200, 180, 140))):+ gx = x0 + 84 + column * 44+ draw.rectangle((gx, y0 + 4, gx + 40, y0 + 76), fill=ground)+ for size, gy in ((16, y0 + 12), (12, y0 + 46)):+ icon = cell.resize((size, size), Image.LANCZOS)+ sheet.paste(icon, (gx + 20 - size // 2, gy), icon)+ draw.text((x0 + 178, y0 + 10), "%d. %s" % (index + 1, name), fill=(240, 232, 210), font=font)+ draw.text((x0 + 178, y0 + 32), image_name(index, name), fill=(180, 170, 150), font=small)+ words, line = about.split(), ""+ lines = []+ for word in words:+ if draw.textlength(line + " " + word, font=small) > card_w - 186:+ lines.append(line)+ line = word+ else:+ line = (line + " " + word).strip()+ lines.append(line)+ for i, text in enumerate(lines[:2]):+ draw.text((x0 + 178, y0 + 50 + i * 14), text, fill=(200, 190, 160), font=small)+ sheet.save(path)+ print(path)+++def main():+ atlas, ini_text = build()+ # the plates and the scorpions, busiest at twelve, draw 14 high+ ini_text = ink_entries(atlas, ini_text, "GLA", tall=range(14, 21))+ atlas.save(TEXTURE_PATH)+ print(TEXTURE_PATH)+ with open(INI_PATH, "w", newline="\r\n") as ini:+ ini.write(ini_text)+ print(INI_PATH)+ if len(sys.argv) == 3 and sys.argv[1] == "preview":+ preview(atlas, sys.argv[2])+++if __name__ == "__main__":+ main()diff --git a/GeneralsMD/Code/Tools/rank_insignia_usa.py b/GeneralsMD/Code/Tools/rank_insignia_usa.pynew file mode 100644index 000000000..477dc1398--- /dev/null+++ b/GeneralsMD/Code/Tools/rank_insignia_usa.py@@ -0,0 +1,364 @@+"""Every rank of the United States Army as a small game icon, for a rank system with more steps than+the three veterancy levels: enlisted E-1 to E-9 with Specialist and the E-8 and E-9 variants,+warrant officers W-1 to W-5, officers O-1 to O-10, and General of the Army.++Same look as rank_insignia.py: no plate, a black edge round every mark so it reads on sand and+grass, metal lit from the top. Enlisted chevrons are gold stripes on a black patch cut to their+shape, the Army's dress pattern. The game draws these twelve to fourteen pixels high beside the+health bar, so each mark is fitted to fill its 64-pixel cell and cut to what survives that: flat+fat stripes, the E-8 and E-9 devices in silver beside the stripes, a solid eagle, veinless leaves,+solid black squares on taller warrant bars, and one ringed gold star for General of the Army.++ python Tools/rank_insignia_usa.py+ writes Data/Art/Textures/ReforgedRanksUSA.tga, an 8 by 4 atlas of 64-pixel cells, and+ Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini that names each cell.+ python Tools/rank_insignia_usa.py preview <png>+ also writes a labelled sheet, every icon at 64, 16 and 12 pixels on sand and on grass.++Drawn big, fitted, outlined at eight times size and brought down, which is the antialiasing."""+import math+import os+import sys++from PIL import Image, ImageChops, ImageDraw, ImageFilter, ImageFont++from rank_insignia_cells import ink_entries++HERE = os.path.dirname(os.path.abspath(__file__))+NAME = "ReforgedRanksUSA"+CELL = 64+COLUMNS, ROWS = 8, 4+SCALE = 8 # outline and fit happen at CELL * SCALE+UNIT = 16 # design pixels per design unit; designs live in -32..32 units+OUTLINE = 3 # shipped pixels of black edge+MARGIN = 1+GOLD = ((255, 232, 120), (196, 134, 24))+SILVER = ((252, 252, 252), (138, 146, 160))+TEXTURE_PATH = os.path.join(HERE, "..", "Data", "Art", "Textures", NAME + ".tga")+INI_PATH = os.path.join(HERE, "..", "Data", "INI", "MappedImages", "HandCreated", NAME + ".ini")+INI_HEADER = """; Every rank of the United States Army, one mapped image per rank in one atlas. Written by+; Tools/rank_insignia_usa.py with the texture it names; do not edit by hand. Mapped images are not+; in the multiplayer INI checksum.+"""+INI_ENTRY = """+; %s, %s+MappedImage %s+ Texture = %s.tga+ TextureWidth = %d+ TextureHeight = %d+ Coords = Left:%d Top:%d Right:%d Bottom:%d+ Status = NONE+End+"""+++def canvas():+ return Image.new("L", (64 * UNIT, 64 * UNIT), 0)+++def px(points):+ """Design units to design pixels."""+ return [((x + 32) * UNIT, (y + 32) * UNIT) for x, y in points]+++def box(x0, y0, x1, y1):+ return tuple(v for point in px([(x0, y0), (x1, y1)]) for v in point)+++STAR_WAIST = 0.48 # inner radius over outer; the true 0.382 thins to a speck at twelve pixels+++def star(draw, cx, cy, r, fill=255):+ points = []+ for i in range(10):+ angle = math.radians(-90 + 36 * i)+ reach = r if i % 2 == 0 else r * STAR_WAIST+ points.append((cx + reach * math.cos(angle), cy + reach * math.sin(angle)))+ draw.polygon(px(points), fill=fill)+++def eagle(draw, cx, cy, s, fill=255):+ """A displayed eagle, wings raised, head turned to its right (the viewer's left)."""+ def at(points):+ return px([(cx + x * s, cy + y * s) for x, y in points])+ # solid wings and no beak: at twelve pixels the feathers and the turned head were a smudge+ for side in (-1, 1):+ wing = [(3, -3), (22, -14), (22, -2), (14, 2), (5, 6)]+ draw.polygon(at([(x * side, y) for x, y in wing]), fill=fill)+ draw.ellipse(box(cx - 5.5 * s, cy - 5 * s, cx + 5.5 * s, cy + 10 * s), fill=fill)+ draw.ellipse(box(cx - 4 * s, cy - 13 * s, cx + 4 * s, cy - 4 * s), fill=fill)+ draw.polygon(at([(-5, 8), (5, 8), (8, 15), (-8, 15)]), fill=fill) # tail+++# Enlisted stripes, flat and fat so a rocker is a pixel and a half at fourteen high: half width, drop+# of a chevron arm, chevron thickness and pitch (the three chevrons read as one block with hairline+# cuts, since every sergeant has three), the gap under them, rocker thickness, pitch and sag.+W, D, T, PITCH = 21, 6, 4, 5.5+ROCKER_GAP, ROCKER_T, ROCKER_PITCH, SAG = 2.5, 6.5, 10, 4+DEVICE_GAP = 2.5 # between the stripes and the device beside them+DEVICE_SHIFT = 10 # how far the stripes move left when a device sits beside them+DEVICE_RIGHT = 31.5+++def chevron(apex):+ return [(-W, apex + D), (0, apex), (W, apex + D), (W, apex + D + T), (0, apex + T), (-W, apex + D + T)]+++def curve(end_y, steps=24):+ return [(-W + 2 * W * i / steps, end_y + SAG * (1 - ((-W + 2 * W * i / steps) / W) ** 2))+ for i in range(steps + 1)]+++def stripes(chevrons, rockers, device=None):+ """Gold chevrons and rockers on their black patch; the device that tells E-8 and E-9 apart goes+ beside them, full height, since the gap between was two pixels."""+ gold, back = canvas(), canvas()+ g, b = ImageDraw.Draw(gold), ImageDraw.Draw(back)+ top = -30+ for k in range(chevrons):+ g.polygon(px(chevron(top + PITCH * k)), fill=255)+ low = top + PITCH * (chevrons - 1)+ first_rocker = low + D + T + ROCKER_GAP+ for j in range(rockers):+ end_y = first_rocker + ROCKER_PITCH * j+ g.polygon(px(curve(end_y) + curve(end_y + ROCKER_T)[::-1]), fill=255)+ if rockers:+ bottom = curve(first_rocker + ROCKER_PITCH * (rockers - 1) + ROCKER_T)[::-1]+ floor = first_rocker + ROCKER_PITCH * (rockers - 1) + ROCKER_T + SAG+ else:+ bottom = [(W, low + D + T), (0, low + T), (-W, low + D + T)]+ floor = low + D + T+ b.polygon(px([(-W, top + D), (0, top), (W, top + D)] + bottom), fill=255)+ if device:+ # the design space ends at 32 units, so the stripes move left to make room+ shift = -DEVICE_SHIFT * UNIT+ gold, back = ImageChops.offset(gold, shift, 0), ImageChops.offset(back, shift, 0)+ silver = canvas()+ device(ImageDraw.Draw(silver), W + DEVICE_GAP - DEVICE_SHIFT, top, floor)+ return gold, back, GOLD, silver # silver, so the small device parts from the gold stripes+ return gold, back, GOLD+++def lozenge(draw, left, top, bottom):+ half_w = (DEVICE_RIGHT - left) / 2+ cx, cy, half_h = left + half_w, (top + bottom) / 2, half_w * 1.7+ draw.polygon(px([(cx, cy - half_h), (cx + half_w, cy), (cx, cy + half_h), (cx - half_w, cy)]), fill=255)+++def sgm_star(draw, left, top, bottom):+ r = (DEVICE_RIGHT - left) / 2 / 0.951+ star(draw, (left + DEVICE_RIGHT) / 2, (top + bottom) / 2 + 1, r)+++def csm_wreath(draw, left, top, bottom):+ r = (DEVICE_RIGHT - left) / 2+ cx, cy = left + r, (top + bottom) / 2+ draw.ellipse(box(cx - r, cy - r, cx + r, cy + r), outline=255, width=round(3 * UNIT))+ star(draw, cx, cy + 0.5, r * 0.6)+++def sma_stars(draw, left, top, bottom):+ r = (DEVICE_RIGHT - left) / 2 / 0.951+ for cy in (top + r + 2, bottom - r):+ star(draw, (left + DEVICE_RIGHT) / 2, cy, r)+++def specialist():+ """The Specialist's eagle on a patch with a pointed top and a round bottom, gold edged."""+ gold, back = canvas(), canvas()+ bottom = [(x * 22 / W, 6 + 13 * (1 - (x / W) ** 2)) for x, _ in curve(0)][::-1]+ outer = [(0, -22), (22, -8), (22, 6)] + bottom + [(-22, 6), (-22, -8)]+ inner = [(x * 0.85, y * 0.85 - 0.3) for x, y in outer]+ ImageDraw.Draw(back).polygon(px(outer), fill=255)+ g = ImageDraw.Draw(gold)+ g.polygon(px(outer), fill=255)+ g.polygon(px(inner), fill=0)+ eagle(g, 0, -0.5, 0.7)+ return gold, back, GOLD+++def bar(metal, holes=0, line=False):+ """A lieutenant's or warrant officer's bar; warrant bars carry black squares or a black line,+ solid black on the patch rather than holes the edge half filled in."""+ gold, back = canvas(), canvas()+ g = ImageDraw.Draw(gold)+ outline = box(-25, -9, 25, 9)+ g.rounded_rectangle(outline, radius=3 * UNIT, fill=255)+ ImageDraw.Draw(back).rounded_rectangle(outline, radius=3 * UNIT, fill=255)+ pitch, size = 11.5, 8+ for i in range(holes):+ x = (i - (holes - 1) / 2) * pitch+ g.rectangle(box(x - size / 2, -size / 2, x + size / 2, size / 2), fill=0)+ if line:+ g.rectangle(box(-20, -2.5, 20, 2.5), fill=0)+ return gold, back, metal+++def captain():+ """Two silver bars joined at the ends, laid flat like the lieutenants' bars."""+ gold = canvas()+ g = ImageDraw.Draw(gold)+ for y in (-7, 7):+ g.rounded_rectangle(box(-20, y - 4.5, 20, y + 4.5), radius=2 * UNIT, fill=255)+ for x in (-14, 14):+ g.rectangle(box(x - 1.8, -3, x + 1.8, 3), fill=255)+ return gold, gold, SILVER+++def oak_leaf(metal):+ gold = canvas()+ g = ImageDraw.Draw(gold)+ # squat and lobed, no midrib: the slim leaf with its vein came down to a dot+ g.ellipse(box(-12, -20, 12, 16), fill=255)+ for x, y, r in ((9, -14, 6), (13, -5, 7.5), (14, 5, 7.5), (11, 13, 6)):+ for side in (-1, 1):+ g.ellipse(box(side * x - r, y - r, side * x + r, y + r), fill=255)+ g.ellipse(box(-6, -25, 6, -14), fill=255)+ g.polygon(px([(-3, 16), (3, 16), (4, 25), (-4, 25)]), fill=255) # stem+ return gold, gold, metal+++def colonel():+ gold = canvas()+ eagle(ImageDraw.Draw(gold), 0, 0, 1.4)+ return gold, gold, SILVER+++def stars(count):+ gold = canvas()+ g = ImageDraw.Draw(gold)+ for i in range(count):+ star(g, (i - (count - 1) / 2) * 15, 0, 8.2)+ return gold, gold, SILVER+++def general_of_the_army():+ """One big gold star in a thick ring: the real five-star circle came down to a grey disc."""+ gold = canvas()+ g = ImageDraw.Draw(gold)+ g.ellipse(box(-20, -20, 20, 20), outline=255, width=round(5 * UNIT))+ star(g, 0, 1.5, 13)+ return gold, gold, GOLD+++def empty():+ """A Private (E-1) wears no insignia."""+ return canvas(), canvas(), GOLD+++# image name, grade, title, design; the atlas fills row by row in this order+RANKS = [+ ("RankUSA_E1", "E-1", "Private (PV1)", empty),+ ("RankUSA_E2", "E-2", "Private (PV2)", lambda: stripes(1, 0)),+ ("RankUSA_E3", "E-3", "Private First Class", lambda: stripes(1, 1)),+ ("RankUSA_E4", "E-4", "Specialist", specialist),+ ("RankUSA_E4_CPL", "E-4", "Corporal", lambda: stripes(2, 0)),+ ("RankUSA_E5", "E-5", "Sergeant", lambda: stripes(3, 0)),+ ("RankUSA_E6", "E-6", "Staff Sergeant", lambda: stripes(3, 1)),+ ("RankUSA_E7", "E-7", "Sergeant First Class", lambda: stripes(3, 2)),+ ("RankUSA_E8", "E-8", "Master Sergeant", lambda: stripes(3, 3)),+ ("RankUSA_E8_1SG", "E-8", "First Sergeant", lambda: stripes(3, 3, lozenge)),+ ("RankUSA_E9", "E-9", "Sergeant Major", lambda: stripes(3, 3, sgm_star)),+ ("RankUSA_E9_CSM", "E-9", "Command Sergeant Major", lambda: stripes(3, 3, csm_wreath)),+ ("RankUSA_E9_SMA", "E-9", "Sergeant Major of the Army", lambda: stripes(3, 3, sma_stars)),+ ("RankUSA_W1", "W-1", "Warrant Officer 1", lambda: bar(SILVER, 1)),+ ("RankUSA_W2", "W-2", "Chief Warrant Officer 2", lambda: bar(SILVER, 2)),+ ("RankUSA_W3", "W-3", "Chief Warrant Officer 3", lambda: bar(SILVER, 3)),+ ("RankUSA_W4", "W-4", "Chief Warrant Officer 4", lambda: bar(SILVER, 4)),+ ("RankUSA_W5", "W-5", "Chief Warrant Officer 5", lambda: bar(SILVER, line=True)),+ ("RankUSA_O1", "O-1", "Second Lieutenant", lambda: bar(GOLD)),+ ("RankUSA_O2", "O-2", "First Lieutenant", lambda: bar(SILVER)),+ ("RankUSA_O3", "O-3", "Captain", captain),+ ("RankUSA_O4", "O-4", "Major", lambda: oak_leaf(GOLD)),+ ("RankUSA_O5", "O-5", "Lieutenant Colonel", lambda: oak_leaf(SILVER)),+ ("RankUSA_O6", "O-6", "Colonel", colonel),+ ("RankUSA_O7", "O-7", "Brigadier General", lambda: stars(1)),+ ("RankUSA_O8", "O-8", "Major General", lambda: stars(2)),+ ("RankUSA_O9", "O-9", "Lieutenant General", lambda: stars(3)),+ ("RankUSA_O10", "O-10", "General", lambda: stars(4)),+ ("RankUSA_O11_GA", "O-11", "General of the Army", general_of_the_army),+]+++def icon(design):+ """One 64-pixel cell: the design fitted to the cell, lit, edged in black."""+ gold, back, colours, *device = design()+ silver = device[0] if device else canvas()+ size = CELL * SCALE+ union = ImageChops.lighter(ImageChops.lighter(gold, back), silver)+ bbox = union.getbbox()+ if bbox is None:+ return Image.new("RGBA", (CELL, CELL), (0, 0, 0, 0))+ room = (CELL - 2 * (OUTLINE + MARGIN)) * SCALE+ fit = room / max(bbox[2] - bbox[0], bbox[3] - bbox[1])+ w, h = round((bbox[2] - bbox[0]) * fit), round((bbox[3] - bbox[1]) * fit)+ left, upper = (size - w) // 2, (size - h) // 2+ shapes = []+ for layer in (gold, silver, union):+ placed = Image.new("L", (size, size), 0)+ placed.paste(layer.crop(bbox).resize((w, h), Image.LANCZOS), (left, upper))+ shapes.append(placed)+ gold, silver, union = shapes++ def lit(top, bottom):+ metal = Image.new("RGB", (size, size))+ draw = ImageDraw.Draw(metal)+ for y in range(size):+ share = min(1.0, max(0.0, (y - upper) / h))+ draw.line((0, y, size, y), fill=tuple(round(a + (b - a) * share) for a, b in zip(top, bottom)))+ return metal++ # the black edge: a blur thresholded about two sigmas out, so OUTLINE pixels wide+ alpha = union.filter(ImageFilter.GaussianBlur(OUTLINE * SCALE / 2)).point(lambda v: 255 if v >= 6 else 0)+ art = Image.composite(lit(*colours), Image.new("RGB", (size, size), (0, 0, 0)), gold)+ art = Image.composite(lit(*SILVER), art, silver)+ art.putalpha(ImageChops.lighter(alpha, union))+ return art.resize((CELL, CELL), Image.LANCZOS)+++def preview(atlas, path):+ """Each icon at 64, 16 and 12 pixels, on sand and on grass, with its grade and title."""+ tile_w, tile_h, columns = 330, 84, 3+ rows = (len(RANKS) + columns - 1) // columns+ sheet = Image.new("RGB", (tile_w * columns, tile_h * rows), (40, 40, 44))+ font = ImageFont.load_default(13)+ bold = ImageFont.load_default(15)+ draw = ImageDraw.Draw(sheet)+ for index, (name, grade, title, _) in enumerate(RANKS):+ x, y = (index % columns) * tile_w, (index // columns) * tile_h+ cell = atlas.crop(((index % COLUMNS) * CELL, (index // COLUMNS) * CELL,+ (index % COLUMNS + 1) * CELL, (index // COLUMNS + 1) * CELL))+ for ground, gx in (((196, 172, 120), x + 4), ((78, 104, 52), x + 74)):+ draw.rectangle((gx, y + 4, gx + 66, y + tile_h - 5), fill=ground)+ sheet.paste(cell, (x + 5, y + 10), cell)+ for size, sy in ((16, y + 14), (12, y + 50)):+ small = cell.resize((size, size), Image.LANCZOS)+ for gx in (x + 76, x + 112):+ sheet.paste(small, (gx + (16 - size) // 2, sy), small)+ draw.text((x + 148, y + 12), grade + " " + name, fill=(255, 255, 255), font=bold)+ draw.text((x + 148, y + 36), title, fill=(210, 210, 210), font=font)+ os.makedirs(os.path.dirname(path), exist_ok=True)+ sheet.save(path)+ print(path)+++def main():+ atlas = Image.new("RGBA", (CELL * COLUMNS, CELL * ROWS), (0, 0, 0, 0))+ ini_text = INI_HEADER+ for index, (name, grade, title, design) in enumerate(RANKS):+ x, y = (index % COLUMNS) * CELL, (index // COLUMNS) * CELL+ atlas.paste(icon(design), (x, y))+ ini_text += INI_ENTRY % (grade, title, name, NAME, atlas.width, atlas.height, x, y, x + CELL, y + CELL)+ # E-6 to E-9 (chevrons over rockers), the leaves, the eagle and the ringed star draw 14 high+ ini_text = ink_entries(atlas, ini_text, "America", tall=list(range(6, 13)) + [21, 22, 23, 28])+ atlas.save(TEXTURE_PATH)+ print(TEXTURE_PATH)+ with open(INI_PATH, "w", newline="\r\n") as ini:+ ini.write(ini_text)+ print(INI_PATH)+ if len(sys.argv) == 3 and sys.argv[1] == "preview":+ preview(atlas, sys.argv[2])+++if __name__ == "__main__":+ main()diff --git a/Tools/Balance/vetduel.py b/Tools/Balance/vetduel.pyindex 8af3d339e..73757a6c0 100644--- a/Tools/Balance/vetduel.py+++ b/Tools/Balance/vetduel.py@@ -1,13 +1,16 @@-"""A ranked army against a bigger regular one; run it once with each veterancy table and compare.+"""A ranked army against a bigger regular one; run it once with each rank ladder 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.+against infantry, at each experience point, from both start points and on two seeds. A point is N+same-class kills of experience (the scenario's `rank ... xp N`, docs/plans/RANK-LADDER.md's+experience duels), auras off. The regular army's money is the ranked army's times three quarters of+the ladder's stat worth at that point (rate of fire x damage x health, 1 + 1.4 sqrt(N / 120)), so a+fight is close when the grade gives what the curve says and a change to the split moves it. Every+side should agree within 0.1 at the same point.The answer per fight is the ranked army's health left as a fraction of its own at the start, minusthe 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).+averages it per side and point 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> ...]@@ -34,7 +37,7 @@ SPACING = 25HANDICAP = 0.75 # the regular army's money as a share of an even fight'sSEEDS = (1, 2)-RANKS = {"veteran": 1.2 * 1.1 * 1.2, "elite": 1.4 * 1.2 * 1.3, "heroic": 1.6 * 1.3 * 1.5}+RANKS = {"xp%d" % kills: 1 + 1.4 * (kills / 120) ** 0.5 for kills in (2, 5, 10, 20, 30, 45, 60, 80, 100, 120)}UNITS = { # side: (tank, its price, infantry, its price)"USA": ("AmericaTankCrusader", 900, "AmericaInfantryRanger", 225),"China": ("ChinaTankBattleMaster", 800, "ChinaInfantryRedguard", 300),@@ -54,7 +57,7 @@ def run_one(exe: str, tag: str, index: int, pair: tuple, rank: str, swapped: boolines = ["%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 rank 0 %s xp %s" % (RANK_FRAME, siege.selector(ranked), rank[2:]),"%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),]