Hey guys, was playing around with some more things, and came up with one more step for this tutorial...
The final step, to make this complex and more like a proper siege.
At the end of this we will be able to make this spawned army wait another 2 turns after being spawned then attack, with the entire stack replenished.
First lets check if the spawned character is still alive, if he is alive we check if he succeeded in the attack, if the settlement is not taken we check if he is still sieging or not, if he is not sieging we move him back and tell him to lay siege again.
Code:
monitor_event FactionTurnStart FactionType england
and not I_SettlementOwner London = england
and I_CharacterExists Invade_London
if I_SettlementUnderSiege London
siege_settlement Invade_London, London, maintain
replenish_units Invade_London
end_if
if not I_SettlementUnderSiege London
reposition_character Invade_London, 290, 134
siege_settlement Invade_London, London, maintain
replenish_units Invade_London
end_if
end_monitor
Finally to ensure the army stays and attacks on the second turn we need to use a counter and increment it each turn.
This is the full code using all the features described above;
Code:
declare_counter delayattack001
monitor_event FactionTurnStart FactionType england
and I_SettlementOwner London = france
and not I_CharacterExists Invade_London
spawn_army
faction england
character random_name, named character, family, age 32, x 290, y 134, label Invade_London, direction N
unit NE bodyguard exp 0 armour 1 weapon_lvl 0
unit Levy Spearmen exp 0 armour 1 weapon_lvl 0
unit Levy Spearmen exp 0 armour 1 weapon_lvl 0
unit Levy Spearmen exp 0 armour 1 weapon_lvl 0
sieging
siege_settlement Invade_London, London, maintain
set_counter delayattack001 1
end_monitor
monitor_event FactionTurnStart FactionType england
if not I_SettlementOwner London = england
and I_CharacterExists Invade_London
if I_SettlementUnderSiege London
and I_CompareCounter delayattack001 = 1
siege_settlement Invade_London, London, maintain
replenish_units Invade_London
inc_counter delayattack001 1
end_if
if not I_SettlementUnderSiege London
and I_CompareCounter delayattack001 = 1
reposition_character Invade_London, 290, 134
siege_settlement Invade_London, London, maintain
replenish_units Invade_London
inc_counter delayattack001 1
end_if
if I_SettlementUnderSiege London
and I_CompareCounter delayattack001 > 1
siege_settlement Invade_London, London, attack
replenish_units Invade_London
inc_counter delayattack001 1
end_if
if not I_SettlementUnderSiege London
and I_CompareCounter delayattack001 > 1
reposition_character Invade_London, 290, 134
siege_settlement Invade_London, London, attack
replenish_units Invade_London
inc_counter delayattack001 1
end_if
end_if
if I_SettlementOwner London = england
and I_CompareCounter delayattack001 > 0
set_counter delayattack001 0
end_if
end_monitor