Code:
;#################### Garrison Script Version 3.0 #####################
declare_counter PT
;Unique Counters per Settlement
declare_counter Belfalas_Siege
declare_counter Belfalas_Defense
declare_counter Belfalas_Local
;===============================================================
;============ Ensures Player Owned Settlements =================
;========== Are Local On Turn Start and Turn End ===============
;===============================================================
monitor_event SettlementTurnStart SettlementIsLocal
and SettlementName Belfalas
set_counter Belfalas_Local 1
end_monitor
;############################################################
monitor_event SettlementTurnEnd SettlementIsLocal
and SettlementName Belfalas
set_counter Belfalas_Local 1
end_monitor
;===============================================================
;============== Ensures AI Owned Settlements ===================
;========== Are Local On Turn Start and Turn End ===============
;===============================================================
monitor_event SettlementTurnStart not SettlementIsLocal
and SettlementName Belfalas
set_counter Belfalas_Local 0
end_monitor
;#############################################################
monitor_event SettlementTurnEnd not SettlementIsLocal
and SettlementName Belfalas
set_counter Belfalas_Local 0
end_monitor
;===============================================================
;================= Decrease Siege Counter ======================
;========== Ensures Additional Spawns Don't Spawn ==============
;===============================================================
monitor_event PreFactionTurnStart not IsFactionAIControlled
inc_counter Belfalas_Siege -1
set_counter PT 0
end_monitor
;=======================================================
;============ Set Max Unit Spawn Limit =================
;=======================================================
;For Player vs AI
monitor_event ScrollOpened ScrollOpened siege_scroll
set_counter PT 0
end_monitor
;For AI vs AI
monitor_event PreFactionTurnStart IsFactionAIControlled
set_counter PT 0
end_monitor
;=======================================================
;=================== Spawn Units =======================
;=============== For Player vs AI ONLY==================
;=======================================================
monitor_event ButtonPressed ButtonPressed siege_maintain_button
if I_SettlementUnderSiege Belfalas
and I_SettlementOwner Belfalas = sicily
and I_CompareCounter Belfalas_Siege < 1
and I_CompareCounter Belfalas_Local = 0
while I_CompareCounter PT < 1
create_unit Belfalas, Gondor Spearmen Mercs, num 1, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Archers Mercs, num 2, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Infantry Mercs, num 1, exp 0, arm 0, wep 0
create_unit Belfalas, Dismounted Kofm Mercs, num 2, exp 0, arm 0, wep 0
inc_counter PT 1
set_counter Belfalas_Siege 5
end_while
end_if
end_monitor
;=======================================================
;=================== Spawn Units2 =======================
;=======================================================
monitor_event ButtonPressed ButtonPressed siege_assault_button
if I_SettlementUnderSiege Belfalas
and I_SettlementOwner Belfalas = sicily
and I_CompareCounter Belfalas_Siege < 1
and I_CompareCounter Belfalas_Local = 0
while I_CompareCounter PT < 1
create_unit Belfalas, Gondor Spearmen Mercs, num 1, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Archers Mercs, num 2, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Infantry Mercs, num 1, exp 0, arm 0, wep 0
create_unit Belfalas, Dismounted Kofm Mercs, num 2, exp 0, arm 0, wep 0
inc_counter PT 1
set_counter Belfalas_Siege 5
end_while
end_if
end_monitor
;=======================================================
;=================== Spawn Units =======================
;================ For AI vs AI ONLY=====================
;=======================================================
monitor_event FactionTurnStart IsFactionAIControlled
if I_SettlementUnderSiege Belfalas
and I_SettlementOwner Belfalas = sicily
and I_CompareCounter Belfalas_Siege < 1
and I_CompareCounter Belfalas_Local = 0
while I_CompareCounter PT < 1
create_unit Belfalas, Gondor Spearmen Mercs, num 3, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Archers Mercs, num 2, exp 0, arm 0, wep 0
create_unit Belfalas, Gondor Infantry Mercs, num 2, exp 0, arm 0, wep 0
create_unit Belfalas, Dismounted Kofm Mercs, num 3, exp 0, arm 0, wep 0
inc_counter PT 1
set_counter Belfalas_Siege 2
end_while
end_if
end_monitor