Hi,
I am wondering which units get free upkeep, it seems like only county spearmen and han volunteers get it now.
Hi,
I am wondering which units get free upkeep, it seems like only county spearmen and han volunteers get it now.
you can check it in EDU export descr unit.
and look at the atribute. "free_upkeep_unit"
i would like to see a garrison of town milita appear when a city gets attacked, not just one or 2 but a couple based on the size of the population of the city
:\ i wish there is a professional unit that guards the city. militia just seem so inefficient when you consider the population and importance of the city.
Garrison scripts are a pain in the butt. To avoid it becoming 'free stacks' for the AI and bankrupting him further a considerable load of code is required. We did that in 1648, only for a few cities of 'endangered' factions and even that was pretty long.
The spawning is a piece of cake:
The monitor terminates after a set number of rounds - if they still need garrisons then, then they might as well perish.Code:declare_counter Aschaffenburg_siege declare_counter Mainz_siege declare_counter Erfurt_siege declare_counter Heiligenstadt_siege ;--- Garnison einziehen --- monitor_event GeneralAssaultsResidence TargetFactionType egypt and IsTargetRegionOneOf Erzbistum_Mainz and I_SettlementUnderSiege Aschaffenburg if I_TurnNumber < 100 create_unit Aschaffenburg, BuergerwehrG, num 4, exp 0, arm 0, wep 0 create_unit Aschaffenburg, GrenadiereG, num 1, exp 0, arm 0, wep 0 create_unit Aschaffenburg, MusketiereG, num 2, exp 0, arm 0, wep 0 create_unit Aschaffenburg, PikeniereG, num 3, exp 0, arm 0, wep 0 set_counter Aschaffenburg_siege 1 end_if if I_TurnNumber > 99 terminate_monitor end_if end_monitor monitor_event GeneralAssaultsResidence TargetFactionType egypt and IsTargetRegionOneOf Stadt_Mainz and I_SettlementUnderSiege Mainz if I_TurnNumber < 50 create_unit Mainz, BuergerwehrG, num 4, exp 0, arm 0, wep 0 create_unit Mainz, GrenadiereG, num 1, exp 0, arm 0, wep 0 create_unit Mainz, MusketiereG, num 2, exp 0, arm 0, wep 0 create_unit Mainz, PikeniereG, num 3, exp 0, arm 0, wep 0 set_counter Mainz_siege 1 end_if if I_TurnNumber > 49 terminate_monitor end_if end_monitor monitor_event GeneralAssaultsResidence TargetFactionType egypt and IsTargetRegionOneOf Stadt_Erfurt and I_SettlementUnderSiege Erfurt if I_TurnNumber < 50 create_unit Erfurt, BuergerwehrG, num 4, exp 0, arm 0, wep 0 create_unit Erfurt, GrenadiereG, num 1, exp 0, arm 0, wep 0 create_unit Erfurt, MusketiereG, num 2, exp 0, arm 0, wep 0 create_unit Erfurt, PikeniereG, num 3, exp 0, arm 0, wep 0 set_counter Erfurt_siege 1 end_if if I_TurnNumber > 49 terminate_monitor end_if end_monitor monitor_event GeneralAssaultsResidence TargetFactionType egypt and IsTargetRegionOneOf Eichsfeld and I_SettlementUnderSiege Heiligenstadt if I_TurnNumber < 50 create_unit Heiligenstadt, BuergerwehrG, num 4, exp 0, arm 0, wep 0 create_unit Heiligenstadt, GrenadiereG, num 1, exp 0, arm 0, wep 0 create_unit Heiligenstadt, MusketiereG, num 2, exp 0, arm 0, wep 0 create_unit Heiligenstadt, PikeniereG, num 3, exp 0, arm 0, wep 0 set_counter Heiligenstadt_siege 1 end_if if I_TurnNumber > 49 terminate_monitor end_if end_monitor
Then you check if there is no siege for any of the cities that get a garrison (notice all the set_counter lines?):
Last not least you remove the garison troops if none of the settlements of a faction are under siege anymore:Code:;--- Belagerung ist vorbei --- monitor_event FactionTurnEnd not FactionIsLocal if I_SettlementOwner Aschaffenburg = egypt and not I_SettlementUnderSiege Aschaffenburg and I_TurnNumber < 101 set_counter Aschaffenburg_siege 0 end_if if I_SettlementOwner Mainz = egypt and not I_SettlementUnderSiege Mainz and I_TurnNumber < 51 set_counter Mainz_siege 0 end_if if I_SettlementOwner Erfurt = egypt and not I_SettlementUnderSiege Erfurt and I_TurnNumber < 50 set_counter Erfurt_siege 0 end_if if I_SettlementOwner Heiligenstadt = egypt and not I_SettlementUnderSiege Heiligenstadt and I_TurnNumber < 51 set_counter Heiligenstadt_siege 0 end_if end_monitor
The units are not available for regular game play (copies of regular units, suffix G = garrison) as they have a custom attribute that allows them to be disbanded in the last monitor.Code:;--- Garnison ausmustern --- monitor_event FactionTurnStart FactionType egypt and not FactionIsLocal if I_CompareCounter Mainz_siege < 1 and I_CompareCounter Aschaffenburg_siege < 1 and I_CompareCounter Erfurt_siege < 1 and I_CompareCounter Heiligenstadt_siege < 1 destroy_units egypt garnison end_if if I_TurnNumber > 100 terminate_monitor end_if end_monitor
This whole is only for 4 settlements of one faction - you do the math how this will look for all settlements. There would be no problem with processing as this will be two basics monitors plus one for each faction involved - nothing to be bothered about.
Testing for the settlement level and spawning accordingly will require more monitors...
Evidence indicates that garrisons were nothing but local militia, used to police settlements and maintain order. Military commanders had their own personal retinues, or buqu, that accompanied them wherever they went, while regular army units (as part of specific army groups) were stationed outside of cities in encampments or forts. Important imperial officials and offices could also have their own private armies of personal guards, such as the Feathered Forest. But, as said, there were no professional organized units that guarded cities or served as a garrison. The closest thing was the Northern Army, which only guarded the imperial capital of Luo Yang in the Later Han, but they were essentially disbanded by the time our mod starts.
Member of the Imperial House of Hader - Under the Benevolent Patronage of y2day
A Wolf Among Sheep: A Rise of Three Kingdoms AAR