Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

feat(gameengine): turkiye as experimental, with its own rank ladder

Olcay Seyganac4151162e5e
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d787e3b7..b056ccf1e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -131,9 +131,9 @@ found and fixed — EA's own, not port damage.**
- Guns fire at their 2003 rate again. After a shot the game goes back to aiming for a step before it can fire again, which at 30 steps put a 100 millisecond Quad Cannon on a shot every 0.133 seconds; at 60 the same loop fired it every 0.100, a third faster. Shot delays and reloads are rounded to the old step and a gun's next shot is held to the old rhythm, so every weapon fires on the frames it did in 2003. A turret with no turning speed in its data rose twice as fast as it should, aircraft weighed their thrust against gravity at half strength, and a unit hit on the step before still counted as untouched for stealth. All three keep EA's timing now.
- Mod guns shoot straight again. Shockwave Chaos and other mods give their machine guns and autocannons a shell that arcs 300 high but flies so fast that the 30-step game only ever put it at the muzzle and on the target. At 60 steps the shell stopped partway up that arc, so in Chaos a Humvee's autocannon round went 200 into the air before coming down on a tank 100 away. A shell now passes through the points it passed through in 2003 and flies straight between them, so mod rounds hit straight and the original game's shells fly the same arcs. A shell fired point blank, close enough to arrive in one step, used to fly to the corner of the map and explode there, a bug since 2003; it hits its target now.
-## Turkiye joins the fight
+## Turkiye joins the fight, as an experiment
-- Turkiye is a fourth side in the skirmish and multiplayer lobbies, with an army of its own: Mehmetcik riflemen, Sungur missile teams and Maroon Berets from the Barracks; the Altay tank, the Kirpi carrier, Korkut air defense, Firtina howitzers and Sakarya rocket launchers from the Factory; Bayraktar and Akinci drones, the Gokbey helicopter and the Kizilelma fighter from the Airfield. Every name and tooltip reads in English and in Turkish.
+- Turkiye is a fourth side in the skirmish and multiplayer lobbies, listed as Turkiye (Experimental), Türkiye (Deneysel) in Turkish. The label is there because the side is not finished: its powers and abilities are still being worked on and will change. It has an army of its own: Mehmetcik riflemen, Sungur missile teams and Maroon Berets from the Barracks; the Altay tank, the Kirpi carrier, Korkut air defense, Firtina howitzers and Sakarya rocket launchers from the Factory; Bayraktar and Akinci drones, the Gokbey helicopter and the Kizilelma fighter from the Airfield. Every name and tooltip reads in English and in Turkish.
- Turkiye kills from range and cannot see for itself. The Firtina throws a shell 600 and sees 100, so it waits until a spotter team, a Cobra scout, a drone or a cheap Radar Tower finds the target, then fires on its own. Force it to shell ground nobody can see and the shots go wide, about half of them off a barracks-sized target. Extended Range and Precision Guidance at the Factory push the guns further and tighten the blind spread.
- Combat Engineers build the base in place of a dozer. They are infantry, so they can be shot and run over. The Barracks' Mine Kit lets them bury mines, and the Factory's Armor Pack toughens the Kirpi and the Altay.
- Turkiye's first rank buys its own power, a Minefield a cargo plane sows wherever you point, beside the Spy Drone and Fuel Resupply, which keeps the drones over the target longer. Rank 3 offers a loitering munition that dives on whatever it is pointed at, Electronic Blinding, which shuts every enemy radar in the area off for 30 seconds, and paratroopers. The top rank buys the Swarm Strike: ten munitions over a wide circle, each on a different target and the most expensive first, so a column of tanks loses its tanks and the riflemen walking beside them are left standing. Leaflet Drop and the Spectre gunship are still American borrowings.
@@ -143,6 +143,7 @@ found and fixed — EA's own, not port damage.**
- Thermal Vision at the Barracks lets the spotter team and the Cobra see out to 550 and through stealth. The Airfield sells Fuel Cells, which double how long a Bayraktar or an Akinci stays over the target, and Swarm Software, which sends each Bayraktar munition at the most expensive target in reach rather than the nearest one.
- Turkish units move at their own speeds. The engineer, the spotter team and the Kirpi are slow, and the Korkut keeps up with the tanks.
- A Turkish computer player fires its powers, the Minefield included, as soon as they are ready, and pulls its spotter teams back out of the enemy's reach while keeping the enemy in sight.
+- Turkish units climb the Turkish Land Forces' own ladder: 21 promotions from Er through Onbaşı, Çavuş, Uzman Çavuş and six astsubay grades to Teğmen, Yüzbaşı, Albay, the four generals and Mareşal at the top. The names read in Turkish in every language, and each grade wears its own insignia: chevrons for the enlisted men, gold bars for the astsubays, stars for the officers, the oak wreath under a field officer's stars and the crescent and star over a general's. The climb costs what it costs everyone else, a unit turns Veteran at Uzman Çavuş, Elite at Teğmen and Heroic at Albay, and the bonuses follow America's split, since the army still fights in American bodies. The Maroon Beret starts as an Albay, as Burton starts as a Colonel. Before this a Turkish unit wore EA's three chevrons.
- The units still borrow American and other sides' models, voices and cameos.
- The computer plays Turkiye too. A Turkish AI puts up a full base with radar towers and air defense sites, sends supply trucks, fields the new army, artillery included, and attacks.
diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifest
index e0127964f..4e751ba8d 100644
--- a/GeneralsMD/Code/BuildFingerprint.manifest
+++ b/GeneralsMD/Code/BuildFingerprint.manifest
@@ -34,6 +34,7 @@ Data/Art/Textures/ReforgedRankBar.tga
Data/Art/Textures/ReforgedRankSkull.tga
Data/Art/Textures/ReforgedRanksChina.tga
Data/Art/Textures/ReforgedRanksGLA.tga
+Data/Art/Textures/ReforgedRanksTurkiye.tga
Data/Art/Textures/ReforgedRanksUSA.tga
Data/Art/Textures/ReforgedSignalAttack.tga
Data/Art/Textures/ReforgedSignalDefend.tga
@@ -186,6 +187,7 @@ Data/INI/MappedImages/HandCreated/ReforgedLobbySpot.ini
Data/INI/MappedImages/HandCreated/ReforgedRankInsignia.ini
Data/INI/MappedImages/HandCreated/ReforgedRanksChina.ini
Data/INI/MappedImages/HandCreated/ReforgedRanksGLA.ini
+Data/INI/MappedImages/HandCreated/ReforgedRanksTurkiye.ini
Data/INI/MappedImages/HandCreated/ReforgedRanksUSA.ini
Data/INI/ObjectCreationListReforged.ini
Data/INI/ParticleSystemReforged.ini
@@ -4058,6 +4060,7 @@ Tools/rank_insignia.py
Tools/rank_insignia_cells.py
Tools/rank_insignia_china.py
Tools/rank_insignia_gla.py
+Tools/rank_insignia_turkiye.py
Tools/rank_insignia_usa.py
Tools/record-dx11-shaders.ps1
Tools/replay-check.sh
diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksTurkiye.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksTurkiye.tga
new file mode 100644
index 000000000..13fe88ed5
Binary files /dev/null and b/GeneralsMD/Code/Data/Art/Textures/ReforgedRanksTurkiye.tga differ
diff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.str
index 6ca2cf75a..c391c2995 100644
--- a/GeneralsMD/Code/Data/German/Generals.str
+++ b/GeneralsMD/Code/Data/German/Generals.str
@@ -15344,3 +15344,11 @@ END
GUI:LobbyRecordClose
"SCHLIESSEN"
END
+
+INI:FactionTurkiye
+"Türkiye (Experimentell)"
+END
+
+SIDE:Turkiye
+"Türkiye (Experimentell)"
+END
diff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
index 64bd9bfbb..623382153 100644
--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini
+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini
@@ -1812,9 +1812,9 @@ End
; ---- the rank ladder ------------------------------------------------------------------------------
;
; 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
+; China (Private to General), 20 for GLA (Recruit to Supreme Liberator), 21 for Turkiye (Er to
+; Maresal). Grade 0 is unranked on every side, with no insignia and no bonus; America's E-1 and
+; Turkiye's Er wear 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.
@@ -1835,21 +1835,22 @@ End
; America: rate of fire and health, range to 107%.
; China: health, and ranked men in a horde fire 10% faster.
; GLA: rate of fire, speed to 114%, self repair to 2% a second.
+; Turkiye: America's split, since it fights with America's units for now.
Veterancy
- ; 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%
+ ; America China GLA Turkiye
+ Grades = 28 19 20 21
+ Top = 120 120 120 120
+ VeteranPin = 4 4 4 4 ; E-4 Corporal, Sergeant, Raider, Uzman Cavus
+ ElitePin = 13 10 10 11 ; W-1 Warrant Officer, Second Lieutenant, Raid Captain, Tegmen
+ HeroicPin = 22 15 15 16 ; O-5 Lieutenant Colonel, Colonel, Warlord, Albay
+ HeroStart = 23 15 15 16 ; O-6 Colonel (Burton), Colonel, Warlord, Albay (the Maroon Beret)
+ RateOfFire = 142% 130% 148% 142%
+ Damage = 119% 119% 114% 119%
+ Health = 142% 155% 142% 142%
+ Range = 107% 100% 100% 107%
+ Speed = 100% 100% 114% 100%
+ SelfRepair = 0% 0% 2% 0%
WorthGain = 1.4
CrateGrades = 3
SelfRepairDelay = 5000
diff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksTurkiye.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksTurkiye.ini
new file mode 100644
index 000000000..789b7b670
--- /dev/null
+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedRanksTurkiye.ini
@@ -0,0 +1,185 @@
+; Turkiye's rank marks, one per Turkish Land Forces rank, all in one texture. Written by
+; Tools/rank_insignia_turkiye.py with the texture it names; do not edit by hand. Mapped images are
+; not in the multiplayer INI checksum.
+
+
+
+MappedImage RankTurkiye_2
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:144 Top:21 Right:176 Bottom:43
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_3
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:208 Top:16 Right:240 Bottom:48
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_4
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:272 Top:11 Right:304 Bottom:53
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_5
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:340 Top:27 Right:364 Bottom:37
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_6
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:404 Top:23 Right:428 Bottom:41
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_7
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:468 Top:18 Right:492 Bottom:46
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_8
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:20 Top:81 Right:44 Bottom:110
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_9
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:84 Top:77 Right:108 Bottom:114
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_10
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:148 Top:72 Right:172 Bottom:119
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_11
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:214 Top:85 Right:234 Bottom:105
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_12
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:269 Top:85 Right:307 Bottom:105
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_13
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:333 Top:77 Right:371 Bottom:113
+ Status = NONE
+ DisplayHeight = 12
+End
+
+MappedImage RankTurkiye_14
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:401 Top:76 Right:431 Bottom:104
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_15
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:461 Top:76 Right:499 Bottom:104
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_16
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:13 Top:132 Right:51 Bottom:175
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_17
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:77 Top:135 Right:115 Bottom:177
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_18
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:141 Top:135 Right:179 Bottom:177
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_19
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:205 Top:135 Right:243 Bottom:177
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_20
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:264 Top:135 Right:312 Bottom:177
+ Status = NONE
+ DisplayHeight = 14
+End
+
+MappedImage RankTurkiye_21
+ Texture = ReforgedRanksTurkiye.tga
+ TextureWidth = 512
+ TextureHeight = 192
+ Coords = Left:328 Top:136 Right:376 Bottom:184
+ Status = NONE
+ DisplayHeight = 14
+End
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index bf88993a2..fd8989c77 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -2474,14 +2474,103 @@ RANK:GLA20
"Supreme Liberator"
END
+// Turkiye's ladder, the Turkish Land Forces' ranks under their Turkish names in every language
+RANK:Turkiye0
+"Unranked"
+END
+
+RANK:Turkiye1
+"Er"
+END
+
+RANK:Turkiye2
+"Onbaşı"
+END
+
+RANK:Turkiye3
+"Çavuş"
+END
+
+RANK:Turkiye4
+"Uzman Çavuş"
+END
+
+RANK:Turkiye5
+"Astsubay Çavuş"
+END
+
+RANK:Turkiye6
+"Astsubay Kıdemli Çavuş"
+END
+
+RANK:Turkiye7
+"Astsubay Üstçavuş"
+END
+
+RANK:Turkiye8
+"Astsubay Kıdemli Üstçavuş"
+END
+
+RANK:Turkiye9
+"Astsubay Başçavuş"
+END
+
+RANK:Turkiye10
+"Astsubay Kıdemli Başçavuş"
+END
+
+RANK:Turkiye11
+"Teğmen"
+END
+
+RANK:Turkiye12
+"Üsteğmen"
+END
+
+RANK:Turkiye13
+"Yüzbaşı"
+END
+
+RANK:Turkiye14
+"Binbaşı"
+END
+
+RANK:Turkiye15
+"Yarbay"
+END
+
+RANK:Turkiye16
+"Albay"
+END
+
+RANK:Turkiye17
+"Tuğgeneral"
+END
+
+RANK:Turkiye18
+"Tümgeneral"
+END
+
+RANK:Turkiye19
+"Korgeneral"
+END
+
+RANK:Turkiye20
+"Orgeneral"
+END
+
+RANK:Turkiye21
+"Mareşal"
+END
+
// The Turkiye faction (PlayerTemplateReforged.ini, TurkiyeReforged.ini). Units, buildings, buttons, upgrades.
INI:FactionTurkiye
-"Turkiye"
+"Turkiye (Experimental)"
END
SIDE:Turkiye
-"Turkiye"
+"Turkiye (Experimental)"
END
TOOLTIP:BioStrategyLong_Turkiye
diff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.str
index a973980bf..b69c95cea 100644
--- a/GeneralsMD/Code/Data/Turkish/Generals.str
+++ b/GeneralsMD/Code/Data/Turkish/Generals.str
@@ -16858,12 +16858,16 @@ RANK:GLA20
"Yüce Kurtarıcı"
END
+RANK:Turkiye0
+"Rütbesiz"
+END
+
INI:FactionTurkiye
-"Türkiye"
+"Türkiye (Deneysel)"
END
SIDE:Turkiye
-"Türkiye"
+"Türkiye (Deneysel)"
END
TOOLTIP:BioStrategyLong_Turkiye
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 1976d95ab..73e66a171 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -57,18 +57,19 @@ enum AIDebugOptions : Int;
// PUBLIC /////////////////////////////////////////////////////////////////////////////////////////
-/// the three sides whose ranks carry their own bonuses (m_veterancyWeaponBonus and the rest)
+/// the sides whose ranks carry their own bonuses (m_veterancyWeaponBonus and the rest)
enum VeterancySide
{
VETERANCY_SIDE_NONE = -1,
VETERANCY_SIDE_AMERICA,
VETERANCY_SIDE_CHINA,
VETERANCY_SIDE_GLA,
+ VETERANCY_SIDE_TURKIYE,
VETERANCY_SIDE_COUNT
};
-/// America, China, GLA: the side in each rank insignia's image name and each rank's label
+/// America, China, GLA, Turkiye: 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
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 1da0ede30..e77747cf3 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -93,9 +93,9 @@ static void parseVeterancyWeaponBonus( INI *ini, void *, void *store, const void
(*table)->parseWeaponBonusSet( ini );
}
-const char *const TheVeterancySideNames[VETERANCY_SIDE_COUNT] = { "America", "China", "GLA" };
+const char *const TheVeterancySideNames[VETERANCY_SIDE_COUNT] = { "America", "China", "GLA", "Turkiye" };
-// A ladder line holds one value per side, America, China and GLA, written into the same RankLadder
+// A ladder line holds one value per side, America, China, GLA and Turkiye, 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 )
{
@@ -1528,6 +1528,8 @@ GlobalData::~GlobalData( void )
return VETERANCY_SIDE_CHINA;
if( side.startsWith( "GLA" ) )
return VETERANCY_SIDE_GLA;
+ if( side.startsWith( "Turkiye" ) )
+ return VETERANCY_SIDE_TURKIYE;
return VETERANCY_SIDE_NONE;
}
diff --git a/GeneralsMD/Code/Tools/rank_insignia_turkiye.py b/GeneralsMD/Code/Tools/rank_insignia_turkiye.py
new file mode 100644
index 000000000..1c4b810f0
--- /dev/null
+++ b/GeneralsMD/Code/Tools/rank_insignia_turkiye.py
@@ -0,0 +1,283 @@
+"""Rank marks for Turkiye, one for every rank of the Turkish Land Forces the ladder climbs, from Er to
+Mareşal.
+
+Each mark is the sign on the shoulder board without the board, cut down for twelve to fourteen
+pixels high. The Er wears nothing, as he does in the army. Onbaşı and Çavuş wear one and two
+silver chevrons pointing down, the Uzman Çavuş three. The astsubay grades wear gold bars, one to
+three, and the three senior ones put a star over one to three bars. Company officers wear one to
+three stars; field officers the same stars over the oak wreath; generals the crescent and star
+(ay yıldız) over the wreath with one to four stars above it, and the Mareşal the crescent and star
+inside a closed wreath. The astsubay shapes are simplified: the army's own boards mix stripe widths
+that blur together at game size, so the count of bars and the star carry the order instead. A dark
+red edge and no background, so they read over sand and grass the way the other sides' marks do.
+
+ python Tools/rank_insignia_turkiye.py
+ writes Data/Art/Textures/ReforgedRanksTurkiye.tga, one 64-pixel cell per rank, and the
+ ReforgedRanksTurkiye.ini that names each cell RankTurkiye_<grade>.
+
+ python Tools/rank_insignia_turkiye.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, ImageChops, 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 = 3
+OUTLINE = 21 # a MaxFilter size, odd: the dark edge round every mark, 10 drawn pixels
+EDGE = (48, 4, 6)
+GOLD_TOP = (255, 226, 110)
+GOLD_BOTTOM = (200, 128, 20)
+SILVER_TOP = (252, 252, 252)
+SILVER_BOTTOM = (138, 146, 160)
+NAME = "ReforgedRanksTurkiye"
+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 = """; Turkiye's rank marks, one per Turkish Land Forces rank, all in one texture. Written by
+; Tools/rank_insignia_turkiye.py with the texture it names; do not edit by hand. Mapped images are
+; not in the multiplayer INI checksum.
+"""
+INI_ENTRY = """
+MappedImage RankTurkiye_%d
+ Texture = %s.tga
+ TextureWidth = %d
+ TextureHeight = %d
+ Coords = Left:%d Top:%d Right:%d Bottom:%d
+ Status = NONE
+End
+"""
+
+CHEVRON = 6.5
+GAP = 3.0
+RISE = 12.0
+CHEVRON_HALF_WIDTH = 14
+BAR = 6.0
+BAR_GAP = 3.0
+BAR_HALF_WIDTH = 10 # a lone bar comes out as long for its height as America's gold bar
+
+# grade, name, mark; grade 0 is unranked on every side and the Er wears nothing, so both cells stay empty
+RANKS = (
+ (0, "Rütbesiz", ("none",)),
+ (1, "Er", ("none",)),
+ (2, "Onbaşı", ("chevrons", 1)),
+ (3, "Çavuş", ("chevrons", 2)),
+ (4, "Uzman Çavuş", ("chevrons", 3)),
+ (5, "Astsubay Çavuş", ("bars", 1, 0)),
+ (6, "Astsubay Kıdemli Çavuş", ("bars", 2, 0)),
+ (7, "Astsubay Üstçavuş", ("bars", 3, 0)),
+ (8, "Astsubay Kıdemli Üstçavuş", ("bars", 1, 1)),
+ (9, "Astsubay Başçavuş", ("bars", 2, 1)),
+ (10, "Astsubay Kıdemli Başçavuş", ("bars", 3, 1)),
+ (11, "Teğmen", ("officer", 1, False)),
+ (12, "Üsteğmen", ("officer", 2, False)),
+ (13, "Yüzbaşı", ("officer", 3, False)),
+ (14, "Binbaşı", ("officer", 1, True)),
+ (15, "Yarbay", ("officer", 2, True)),
+ (16, "Albay", ("officer", 3, True)),
+ (17, "Tuğgeneral", ("general", 1)),
+ (18, "Tümgeneral", ("general", 2)),
+ (19, "Korgeneral", ("general", 3)),
+ (20, "Orgeneral", ("general", 4)),
+ (21, "Mareşal", ("marshal",)),
+)
+
+
+def scaled(points):
+ """Points in shipped pixels, in drawn pixels."""
+ return [(x * SCALE, y * SCALE) for x, y in points]
+
+
+def star_points(cx, cy, radius, turn=-90):
+ points = []
+ for i in range(10):
+ r = radius if i % 2 == 0 else radius * 0.5
+ angle = math.radians(turn + 36 * i)
+ points.append((cx + r * math.cos(angle), cy + r * math.sin(angle)))
+ return scaled(points)
+
+
+def star(draw, cx, cy, radius, fill=255):
+ """A five-pointed star, point up."""
+ draw.polygon(star_points(cx, cy, radius), fill=fill)
+
+
+def stars(draw, count, cy, radius, pitch):
+ """count stars in a tight cluster centred across the cell on cy: two side by side, three in a
+ triangle, four two over two, so no mark runs much wider than its height. Returns the cluster's
+ half width and its bottom."""
+ layout = {1: [(0, 0)],
+ 2: [(-0.5, 0), (0.5, 0)],
+ 3: [(0, -0.45), (-0.5, 0.45), (0.5, 0.45)],
+ 4: [(-0.5, -0.5), (0.5, -0.5), (-0.5, 0.5), (0.5, 0.5)]}[count]
+ for x, y in layout:
+ star(draw, 32 + x * pitch, cy + y * pitch, radius)
+ half_width = max(x for x, _ in layout) * pitch + radius * 0.95
+ return half_width, cy + max(y for _, y in layout) * pitch + radius * 0.81
+
+
+def chevron_down(draw, cx, top, half_width):
+ """A chevron pointing down, its arms' tops on top."""
+ draw.polygon(scaled([(cx - half_width, top), (cx, top + RISE), (cx + half_width, top),
+ (cx + half_width, top + CHEVRON), (cx, top + RISE + CHEVRON),
+ (cx - half_width, top + CHEVRON)]), fill=255)
+
+
+def wreath(draw, cx, cy, half, drop, closed=False):
+ """The oak wreath: a thick arc cupping what stands on it, with a leaf notch every few degrees
+ so it reads as leaves and not a ring when the cell is enlarged. Closed for the Mareşal."""
+ box = scaled([(cx - half, cy - drop), (cx + half, cy + drop)])
+ start, end = (0, 360) if closed else (20, 160)
+ draw.arc(box, start=start, end=end, fill=255, width=round(4.5 * SCALE))
+ step = 24 if closed else 28
+ for angle in range(start + step // 2, end, step):
+ rad = math.radians(angle)
+ x = cx + half * math.cos(rad)
+ y = cy + drop * math.sin(rad)
+ draw.ellipse(scaled([(x - 1.1, y - 1.1), (x + 1.1, y + 1.1)]), fill=0)
+
+
+def crescent_star(shape, cx, cy, radius):
+ """The crescent and star of the flag, opening to the right, drawn into shape."""
+ size = shape.size
+ moon = Image.new("L", size, 0)
+ draw = ImageDraw.Draw(moon)
+ draw.ellipse(scaled([(cx - radius, cy - radius), (cx + radius, cy + radius)]), fill=255)
+ inner = radius * 0.8
+ shift = radius * 0.4
+ bite = Image.new("L", size, 0)
+ ImageDraw.Draw(bite).ellipse(scaled([(cx + shift - inner, cy - inner), (cx + shift + inner, cy + inner)]),
+ fill=255)
+ moon = ImageChops.subtract(moon, bite)
+ shape.paste(255, (0, 0), moon)
+ # the flag's star stands just outside the crescent's opening, one point toward the moon
+ ImageDraw.Draw(shape).polygon(star_points(cx + radius * 0.75, cy, radius * 0.45, turn=180), 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 = kind[1]
+ height = count * CHEVRON + (count - 1) * GAP + RISE
+ top = (CELL - height) / 2
+ for i in range(count):
+ chevron_down(draw, 32, top + i * (CHEVRON + GAP), CHEVRON_HALF_WIDTH)
+ elif kind[0] == "bars":
+ _, count, star_count = kind
+ star_height = 18 if star_count else 0
+ height = star_height + count * BAR + (count - 1) * BAR_GAP
+ top = (CELL - height) / 2
+ if star_count:
+ star(draw, 32, top + 7, 8)
+ for i in range(count):
+ y = top + star_height + i * (BAR + BAR_GAP)
+ draw.rectangle(scaled([(32 - BAR_HALF_WIDTH, y), (32 + BAR_HALF_WIDTH, y + BAR)]), fill=255)
+ elif kind[0] == "officer":
+ _, count, field = kind
+ if field:
+ half, bottom = stars(draw, count, 22, 8.5, 16)
+ wreath(draw, 32, 22, max(half, 12) + 2, bottom - 22 + 9)
+ else:
+ stars(draw, count, 32, 9, 17)
+ elif kind[0] == "general":
+ count = kind[1]
+ # the stars in one row over the emblem, the emblem cupped by the wreath
+ pitch = 11
+ for i in range(count):
+ star(draw, 32 + (i - (count - 1) / 2) * pitch, 14, 5.5)
+ crescent_star(shape, 30, 34, 10)
+ wreath(draw, 32, 34, 18, 13)
+ elif kind[0] == "marshal":
+ crescent_star(shape, 30, 32, 12)
+ wreath(draw, 32, 32, 22, 22, closed=True)
+ 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[0] == "chevrons" 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, (grade, _, kind) in enumerate(RANKS):
+ assert grade == index, "the atlas holds the ladder in order"
+ art = finish(mark(kind), kind)
+ x, y = cell_origin(index)
+ atlas.paste(art, (x, y))
+ cells.append(art)
+ ini_text += INI_ENTRY % (grade, NAME, atlas.width, atlas.height, x, y, x + CELL, y + CELL)
+ return atlas, cells, ini_text
+
+
+def preview(cells, path):
+ """Every mark at 14 and 64 pixels on sand and on grass, with its grade and name, two columns."""
+ font = ImageFont.truetype("arial.ttf", 15)
+ small_font = ImageFont.truetype("arial.ttf", 12)
+ row_h, column_w = 76, 560
+ rows = (len(RANKS) + 1) // 2
+ sheet = Image.new("RGB", (2 * column_w + 10, 40 + row_h * rows), (30, 32, 34))
+ draw = ImageDraw.Draw(sheet)
+ draw.text((10, 10), "Turkiye ranks RankTurkiye_<grade> (14 px game size and 64 px cell, on sand and grass)",
+ font=font, fill=(230, 230, 230))
+ for i, ((grade, name, _), art) in enumerate(zip(RANKS, cells)):
+ left0 = 10 + (i // rows) * column_w
+ top = 40 + (i % rows) * row_h
+ for j, ground in enumerate(((196, 170, 112), (78, 106, 48))):
+ left = left0 + j * 120
+ draw.rectangle((left, top, left + 112, top + row_h - 6), fill=ground)
+ # the game crops a cell to its ink and draws it 12 or 14 high (rank_insignia_cells.py)
+ box = art.getchannel("A").point(lambda v: 255 if v >= 16 else 0).getbbox()
+ if box:
+ ink = art.crop(box)
+ small = ink.resize((max(1, round(ink.width * 14 / ink.height)), 14), Image.LANCZOS)
+ sheet.paste(small, (left + 6, top + 28), small)
+ sheet.paste(art, (left + 40, top + 3), art)
+ draw.text((left0 + 250, top + 10), "%d %s" % (grade, name), font=font, fill=(240, 240, 240))
+ draw.text((left0 + 250, top + 36), "RankTurkiye_%d" % grade, 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()
+ # three chevrons, the starred and stacked bars, the field officers, generals and the Mareşal draw 14 high
+ ini_text = ink_entries(atlas, ini_text, "Turkiye", tall=[4, 7] + list(range(8, 11)) + list(range(14, 22)))
+ assert "RankTurkiye_0\n" not in ini_text and "RankTurkiye_1\n" not in ini_text, "grade 0 and the Er wear nothing"
+ 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()