Good idea orclover. To expand on Spice Master's idea...
Code:
declare_counter trained_unit_cat
monitor_event UnitTrained TrueCondition
set_counter trained_unit_cat 0
end_monitor
monitor_event UnitTrained UnitCategory infantry
set_counter trained_unit_cat 1
end_monitor
monitor_event UnitTrained UnitCategory cavalry
set_counter trained_unit_cat 2
end_monitor
monitor_event UnitTrained UnitCategory siege
set_counter trained_unit_cat 3
end_monitor
;settlement monitors...
monitor_event UnitTrained SettlementName Bree
and FactionIsLocal
if I_CompareCounter trained_unit_cat = 1
console_command add_population Bree -150
end_if
if I_CompareCounter trained_unit_cat = 2
console_command add_population Bree -75
end_if
if I_CompareCounter trained_unit_cat = 3
console_command add_population Bree -50
end_if
end_monitor
monitor_event UnitTrained SettlementName Staddle
and FactionIsLocal
if I_CompareCounter trained_unit_cat = 1
console_command add_population Staddle -150
end_if
if I_CompareCounter trained_unit_cat = 2
console_command add_population Staddle -75
end_if
if I_CompareCounter trained_unit_cat = 3
console_command add_population Staddle -50
end_if
end_monitor
...and all other settlements...
This way only one monitor per settlement is needed.
Does TrainedUnitClass work with UnitDisbanded? Its name implies that it would work with UnitTrained only. It might just be poorly named but it might be worth testing that TrainedUnitClass is actually working on the unit in question and not the most-recently-trained unit.
Not sure why you need both the Class and Type conditions here.
UnitDisbanded does not export settlement. Or region. There's no way to know where the unit is being disbanded, so no way to know where to add population.
Sadly, there is no way to test the population size. It never drops below a certain number anyway, even via add_population. Can't remember what it is - around 400?
P.S. There should not be a comma after console_command.