No scripting logic exists that deal with how much experience chevrons a unit has. Which means we have to replicate our own. Fortunately, just enough scripting features were introduced in Remastered to allow for us to not only manage how much "fake experience" a unit has, but also integrate it with other scripting to create a Discharged Veterans System.
Keep in mind that as of writing this, I haven't actually playtested the scripts. Every scripting code you see here is purely theoretical and I'll edit this post once I've tested it or once someone else does.
campaign_script.txt
Code:
monitor_event PostBattle TrueCondition ;;; Do armies lead by captains also count?
and FactionIsLocal
for_each unit in character ;;; Does PostBattle correctly export "character" data?
declare_counter experience
retrieve_counter unit_experience unit experience ;;; Does "unit" store labels the same way "faction" and "settlement" does?
inc_counter experience 1
store_counter experience unit unit_experience
end_for
end_monitor
This is all it takes to have every single unit in an army count the numbers of battles fought. Note that you can remove FactionIsLocal if you want to script stuff for the AI. Also note the ;;; comments because there's a lot of unanswered questions. Anyways, what can we do now that every single unit counts experience? Well, for these veteran units, let's do what so many polities of antiquity did and settle them into veteran colonies!
campaign_script.txt
Code:
monitor_event FactionTurnStart TrueCondition
and FactionIsLocal
and FactionType thrace ;;; EB1 Epeiros
for_each settlement in faction
if not HasResource epeirosthessaliancolony
and SettlementBuildingExists >= epirote_mercenary_colony
declare_counter thessalian_veterancy
retrieve_counter settlement_thessalian_veterancy settlement thessalian_veterancy
for_each unit in settlement
if UnitType thessalian merc
declare_counter experience
retrieve_counter unit_experience unit experience
counter_operation thessalian_veterancy = thessalian_veterancy + experience ;; Is a = a + b allowed or do we need a third variable c to get a = b + c?
end_if
end_for
store_counter thessalian_veterancy settlement settlement_thessalian_veterancy
if I_CompareCounter thessalian_veterancy >= 32
add_hidden_resource local epeirosthessaliancolony
end_if
end_if
end_for
end_monitor
Every turn, this script will check a settlement for Thessalian Mercenary Cavalry and their experience. Their experience will be added to the settlement's veterancy counter. More experienced Thessalians will contribute more veterancy per turn. Once it exceeds 32, add a hidden resource that enables the recruitment of non-Mercenary Thessalian Cavalry.
What does this mean for gameplay? Well, the player will be incentivized to fight battles using units whose experience will be used in scripts like these. More veteran units are extremely valuable because they increase the veterancy of whichever settlement's colony building they reside in. Also, it creates immersion because the player will truly feel like he is honorably discharging veterans across various settlements to increase his empire's stability.
History wise, the Roman veteran colonies are the most well-known application of this script. However another one is how the Ptolemies settled tons of Greek mercenaries in Egypt between 310 BC and 270 BC. Yet more lesser-known ones are the Seleucids and Ptolemies settling veterans in the southern coast of Anatolia, and the Epirotes settling mercenaries in the territories of which they've executed the local elites. The Epirote example in fact inspired me to try to make this mechanic. Thank you Pyrrhus for being a terrible administrator.
Again, as of writing this, the script is untested so do not just copy and paste it into your mod. I'll try to test it later on and then edit this post.