Page 3 of 4 FirstFirst 1234 LastLast
Results 41 to 60 of 63

Thread: what´s better? use many "if" condition or use many monitors? (which process less information)

  1. #41

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Magnificent! Actually, this is exactly what I was searching for
    Quote Originally Posted by Withwnar View Post
    Any number of other factions and settlements can be added, wherever it says ";other settlements...", including having a different GS for different factions in the same settlement.

    One downside is that if a siege lasts more than 5 turns then the GS will be reapplied to that settlement, adding further units. There might be a way around that, though I haven't seen other garrison scripts avoid this either.

    The real benefit is the lack of monitors. Other than (once) during the slave turn - which will happen every turn - nothing happens until somebody actually attacks somebody else's settlement (or fort). Compared to a script that has one monitor for each GS settlement, checking its besieged status and other things, this is very lean. And even the monitor that is doing all of the heavy lifting - the last monitor - is mostly just IF statements.
    What you call downside, someone else can call "a feature that makes the human player to not exploit prolonged sieges" or "fresh reinforcements arrive ".

    Edit: Here is a version without the "downside":
    Code:
    declare_counter gs_turns_byzantium_Nicaea
    declare_counter Nicaea_siege
    declare_counter gs_turns_byzantium_Caffa
    declare_counter Caffa_siege
    ;other settlements...
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
    ;     and not TargetFactionIsLocal ; not absolutely necessary, but may help
    
     if I_SettlementOwner Nicaea = byzantium
        and I_IsFactionAIControlled byzantium
        and I_CompareCounter gs_turns_byzantium_Nicaea <= 0
        and not I_SettlementUnderSiege Nicaea
    
        set_counter Nicaea_siege 1
     end_if
    
     if I_SettlementOwner Caffa = byzantium
        and I_IsFactionAIControlled byzantium
        and I_CompareCounter gs_turns_byzantium_Caffa <= 0
        and not I_SettlementUnderSiege Caffa
    
        set_counter Caffa_siege 1
     end_if
    
     ;other settlements...
    
         ;campaign_wait 0.1
        inc_event_counter gs_create_now 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
      inc_counter gs_turns_byzantium_Nicaea -1
      inc_counter gs_turns_byzantium_Caffa -1
      ;other settlements...
    
      inc_event_counter gs_create_now 1
    end_monitor
    
    
    monitor_event EventCounter EventCounterType gs_create_now
    ;  and EventCounter > 0
      
     campaign_wait 0.1
    
     if I_CompareCounter Nicaea_siege = 1
        if I_SettlementUnderSiege Nicaea
        and I_CompareCounter gs_turns_byzantium_Nicaea <= 0
    
             console_command create_unit Nicaea "Contaratoi" 1 0 0 0
            ;other units...
            set_counter gs_turns_byzantium_Nicaea 5
        end_if
    
        set_counter Nicaea_siege 0
     end_if
    
     if I_CompareCounter Caffa_siege = 1
        if I_SettlementUnderSiege Caffa
        and I_CompareCounter gs_turns_byzantium_Caffa <= 0
    
             console_command create_unit Caffa "Contaratoi" 1 0 0 0
            ;other units...
            set_counter gs_turns_byzantium_Caffa 5
        end_if
    
        set_counter Caffa_siege 0
     end_if
    
    ;other settlements...
    end_monitor
    Now, to explain how it works: Nicaea, Caffa are settlements. Let's say that the TC_INSTIGATE_SIEGE refers to Nicaea (that is, our "target_settlement" is Nicaea). Then, in the Transgression monitor, Nicaea is not yet under siege. In the EventCounter monitor, Nicaea is under siege, so we do the create_units. If Nicaea was already under siege when the transgression takes place, then when the script reaches the EventCounter monitor, Nicaea_siege = 0, so no garrison reinforcements for Nicaea . Also, even if somehow script had been blocked due to the "campaign_wait", our garrison_reinf will "arrive at the next execution of the EventCounter monitor; for this case, it might be useful to repeat in the EventCounter monitor the "I_SettlementOwner" or any other of the conditions of the first monitor.
    Last edited by gsthoed; September 18, 2014 at 02:42 AM. Reason: Solution to the "downside".

  2. #42

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    I 've updated my previous post, with a tweak that I believe makes Withwnar's previous post's GS not to add further units if a siege lasts more than 5 turns.

  3. #43
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Good stuff. However, it introduces a new downside: if Nicaea's turn counter is, say, 2 when a siege happens then they won't get the garrison 2 turns later while that siege is still under way. i.e. Another siege of the same settlement before the previous siege's timer has run down will block the garrison spawn. Again, that's either a "downside" or a "feature" depending on point of view. It could be argued that a garrison appearing midway through a siege (my way) is also a downside.

    "inc_event_counter gs_create_now 1" instead of setting it 1 and 0. That's cleaner.

    Code:
    ;     and not TargetFactionIsLocal ; not absolutely necessary, but may help
    I agree. It will avoid triggering the last monitor unnecessarily assuming that garrisons aren't created for the player faction (as they aren't in this script).

    ~~~

    Meanwhile I have been doing some testing, to investigate the possibility of two sieges happening within that 0.1 campaign _wait...

    I spawned two AI armies and made them lay siege to two AI settlements in quick succession. I spawned them first (facing them south) and positioned them on the north adjacent tile of the settlement in question. i.e. The game does not need to walk them anywhere or turn them around in any way. Then made them lay siege in as close to the same time as possible:

    Code:
    siege_settlement dale_attackers1, Grasgard, maintain		
    siege_settlement rohan_attackers2, Athrad_Angren, maintain
    i.e. No other script in between these two actions. "Follow AI Movement" was off and both of these settlements were in my fog of war.

    I added a "log always" to the Transgression monitor, removed its campaign_wait and set_event_counter so that it was only logging, then checked the log to see when they each fired. The test was repeated three times.

    Result: about 0.6 seconds between the two Transgression firings.

    I'm not sure that it proves anything because this might be less on a faster machine, possibly less than 0.1 for all I know.

    To verify this...

    Quote Originally Posted by Withwnar View Post
    ... The wait lets the game continue and in that time a second assault could take place; the Transgression monitor won't fire that second time because it's currently still in progress with the first one (I assume). So the last monitor won't execute for the second assault and won't create a garrison for that second assault's settlement.
    ...I put the campaign_wait back in and made it 1.0 - longer than my 0.6 result. Sure enough, the Transgression monitor only fired once.

    I then tried moving that campaign_wait to the EventCounter monitor instead (removed from the Transgression one) and added a "log always" to there as well ... as expected this time the Transgression monitor fired twice but the EventCounter monitor fired only once.

    So either way, wherever the campaign_wait is, the garrison-spawning script won't fire on a second siege if that siege is happening too fast - faster than 0.1 seconds since the first siege.

    And so the question becomes: what is the fastest that two sieges can happen in a row on any machine? And even if it could happen within 0.1 seconds, how often would it happen?

    At the end of the day I don't think that it's all that critical anyway. Worst case scenario is that:
    1) some garrisons may not appear for AI attacks until the slave turn
    2) some garrisons may not appear for AI attacks at all if the AI uses a direct assault (no siege: artillery or gates opened by spies). Hmm, actually that one might be "critical" but how often does the AI do this?

    For player attacks: no problem. There's no way that the player can launch two sieges within 0.1 seconds.

  4. #44

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    hallo sorry too thunder this thread but i was testing the garrisson script from Withwnar from post 40 here,made it a little bit difference,i tested this in a new campaign with england and when i besiege Paris the capital of france there is no units spawned in the city,i show mine log and script,as the error says somethings it does not regonise a unit type and say the settlement is already full garrisson,when it is not?
    Code:
    
    
    declare_counter gs_turns_egypt_Trondhelm 
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_now 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Trondhelm -1
      set_event_counter gs_create_now 1
    end_monitor
    
    
    monitor_event EventCounter EventCounterType gs_create_now
      and EventCounter > 0
      
      if I_SettlementUnderSiege Trondhelm
        and I_SettlementOwner Trondhelm norway
        and I_IsFactionAIControlled norway
        and I_CompareCounter gs_turns_egypt_Trondhelm <= 0
        create_unit Trondhelm, nor_noble_axemen, num 4, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_karlar, num 2, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_shieldwallmen, num 3, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_rekka, num 4, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_Langbogmenn, num 2, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_hr_norsk, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Trondhelm 5 
      end_if
    
    
      set_event_counter gs_create_now 0
      
    end_monitor 
    
    
    ;Nuremburg
    declare_counter gs_turns_egypt_Nuremburg
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowy 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Nuremburg -1
      set_event_counter gs_create_nowy 1
    end_monitor
    
    
    monitor_event EventCounter EventCounterType gs_create_nowy
      and EventCounter > 0
      
      if I_SettlementUnderSiege Nuremburg
        and I_SettlementOwner Nuremburg hre
        and I_IsFactionAIControlled hre
        and I_CompareCounter gs_turns_egypt_Nuremburg <= 0
        console_command create_unit Nuremburg, Gothic Knights, num 2, exp 2, arm 1, wep 0
       console_command create_unit Nuremburg, Armored Sergeants, num 2, exp 2, arm 1, wep 0
       console_command create_unit Nuremburg, Zweihander, num 4, exp 2, arm 1, wep 0
       console_command create_unit Nuremburg, Crossbow Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Nuremburg, Forlorn Hope, num 5, exp 2, arm 1, wep 0
       console_command create_unit Nuremburg, Town Militia, num 1, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Nuremburg 5 
      end_if
    
    
      set_event_counter gs_create_nowy 0
      
    end_monitor
    
    
    ;;;;;;;;;; paris
    declare_counter gs_turns_egypt_Paris
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyy 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Paris -1
      set_event_counter gs_create_nowyy 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyy
      and EventCounter > 0
      
      if I_SettlementUnderSiege Paris
        and I_SettlementOwner Paris france
        and I_IsFactionAIControlled france
        and I_CompareCounter gs_turns_egypt_Paris <= 0
         console_command create_unit Paris, Armored Sergeants, num 4, exp 2, arm 1, wep 0
       console_command create_unit Paris, Armored Sergeants, num 2, exp 2, arm 1, wep 0
       console_command create_unit Paris, Noble Knights, num 4, exp 2, arm 1, wep 0
       console_command create_unit Paris, Crossbowmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Paris, Chevaliers Du Languedoc, num 4, exp 2, arm 1, wep 0
        console_command create_unit Paris, Town Militia, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Paris 5 
      end_if
    
    
      set_event_counter gs_create_nowyy 0 
      
    end_monitor
    
    
    ;;;;;;;;;; Marrakesh
    declare_counter gs_turns_egypt_Marrakesh
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyyt 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Marrakesh -1
      set_event_counter gs_create_nowyyt 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyyt
      and EventCounter > 0
      
      if I_SettlementUnderSiege Marrakesh
        and I_SettlementOwner Marrakesh moors
        and I_IsFactionAIControlled moors
        and I_CompareCounter gs_turns_egypt_Marrakesh <= 0
        	console_command create_unit Marrakesh, Jihad Warriors, num 3, exp 2, arm 1, wep 0
      	console_command create_unit Marrakesh, Desert Archers, num 2, exp 2, arm 1, wep 0
      	console_command create_unit Marrakesh, Granadine Jinetes, num 2, exp 2, arm 1, wep 0
      	console_command create_unit Marrakesh, Maghreb Spearmen, num 2, exp 2, arm 1, wep 0
       	console_command create_unit Marrakesh, Maghreb Spearmen, num 2, exp 2, arm 1, wep 0
       	console_command create_unit Marrakesh, Frontier Junds, num 4, exp 2, arm 1, wep 0
       	console_command create_unit Marrakesh, Dismounted Christian Guard, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Marrakesh 5 
      end_if
    
    
      set_event_counter gs_create_nowyyt 0
      
    end_monitor
    
    
    ;;;;;;;;;; Cairo
    declare_counter gs_turns_egypt_Cairo
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytt 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Cairo -1
      set_event_counter gs_create_nowyytt 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytt
      and EventCounter > 0
      
      if I_SettlementUnderSiege Cairo
        and I_SettlementOwner Cairo egypt
        and I_IsFactionAIControlled egypt
        and I_CompareCounter gs_turns_egypt_Cairo <= 0
        	console_command create_unit Cairo, ME Peasant Crossbowmen, num 3, exp 2, arm 1, wep 0
       console_command create_unit Cairo, Hashishim, num 3, exp 2, arm 1, wep 0
       console_command create_unit Cairo, Arab_Cavalry, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cairo, Mamluk Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cairo, Royal Mamluks, num 3, exp 2, arm 1, wep 0
       console_command create_unit Cairo, ME Peasant Archers, num 3, exp 2, arm 1, wep 0
       console_command create_unit Cairo, ME Town Militia, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Cairo 5 
      end_if
    
    
      set_event_counter gs_create_nowyytt 0
      
    end_monitor
    
    
    ;;;;;;;;;; Novgorod
    declare_counter gs_turns_egypt_Novgorod
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytz 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Novgorod -1
      set_event_counter gs_create_nowyytz 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytz
      and EventCounter > 0
      
      if I_SettlementUnderSiege Novgorod
        and I_SettlementOwner Novgorod russia
        and I_IsFactionAIControlled russia
        and I_CompareCounter gs_turns_egypt_Novgorod <= 0
       console_command create_unit Novgorod, nov_militia_senior_axe2, num 2, exp 2, arm 1, wep 0
       console_command create_unit Novgorod, nov_militia_senior_axe2, num 2, exp 2, arm 1, wep 0
       console_command create_unit Novgorod, rus_ushkuiniki_sp, num 2, exp 2, arm 1, wep 0
       console_command create_unit Novgorod, rus_nov_chud_jav_sw, num 2, exp 2, arm 1, wep 0
       console_command create_unit Novgorod, nov_boyar_cav_sp_sw, num 2, exp 2, arm 1, wep 0
       console_command create_unit Novgorod, rus_nov_militia_junior_a, num 5, exp 2, arm 1, wep 0	
        set_counter gs_turns_egypt_Novgorod 5 
      end_if
    
    
      set_event_counter gs_create_nowyytz 0
      
    end_monitor
    
    
    ;;;;;;;;;; Cracow
    declare_counter gs_turns_egypt_Cracow
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytza 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Cracow -1
      set_event_counter gs_create_nowyytza 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytza
      and EventCounter > 0
      
      if I_SettlementUnderSiege Cracow
        and I_SettlementOwner Cracow poland
        and I_IsFactionAIControlled poland
        and I_CompareCounter gs_turns_egypt_Cracow <= 0
      console_command create_unit Cracow, EE Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cracow, EE Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cracow, EE Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cracow, Archer Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cracow, Archer Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Cracow, Archer Militia, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Cracow 5 
      end_if
    
    
      set_event_counter gs_create_nowyytza 0
      
    end_monitor
    
    
    ;;;;;;;;;; Iconium
    declare_counter gs_turns_egypt_Iconium
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytk 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Iconium -1
      set_event_counter gs_create_nowyytk 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytk
      and EventCounter > 0
      
      if I_SettlementUnderSiege Iconium
        and I_SettlementOwner Iconium turks
        and I_IsFactionAIControlled turks
        and I_CompareCounter gs_turns_egypt_Iconium <= 0
      console_command create_unit Iconium, Turkomans, num 4, exp 2, arm 1, wep 0
       console_command create_unit Iconium, Azap Javelinmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Iconium, Turkish Archers, num 4, exp 2, arm 1, wep 0
       console_command create_unit Iconium, Turkish Ghulam, num 2, exp 2, arm 1, wep 0
       console_command create_unit Iconium, Seljuk Swordsmen, num 4, exp 2, arm 1, wep 0
       console_command create_unit Iconium, Jihad Warriors, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Iconium 5 
      end_if
    
    
      set_event_counter gs_create_nowyytk 0
      
    end_monitor
    
    
    ;;;;;;;;;; Muscat
    declare_counter gs_turns_egypt_Muscat
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkz 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Muscat -1
      set_event_counter gs_create_nowyytkz 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkz
      and EventCounter > 0
      
      if I_SettlementUnderSiege Muscat
        and I_SettlementOwner Muscat bulgaria
        and I_IsFactionAIControlled bulgaria
        and I_CompareCounter gs_turns_egypt_Muscat <= 0
      console_command create_unit Muscat, Arab Lancers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Muscat, Desert Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Muscat, Nabhani Warriors, num 4, exp 2, arm 1, wep 0
       console_command create_unit Muscat, Azd, num 2, exp 2, arm 1, wep 0
       console_command create_unit Muscat, Oman Archers, num 3, exp 2, arm 1, wep 0
       console_command create_unit Muscat, Dismounted Sheikhs Javelineers, num 3, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Muscat 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkz 0
      
    end_monitor
    
    
    ;;;;;;;;;; Venice
    declare_counter gs_turns_egypt_Venice
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzy 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Venice -1
      set_event_counter gs_create_nowyytkzy 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzy
      and EventCounter > 0
      
      if I_SettlementUnderSiege Venice
        and I_SettlementOwner Venice venice
        and I_IsFactionAIControlled venice
        and I_CompareCounter gs_turns_egypt_Venice <= 0
      console_command create_unit Venice, Italian Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Venice, Italian Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Venice, Italian Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Venice, Armored Sergeants, num 2, exp 2, arm 1, wep 0
       console_command create_unit Venice, Venetian Heavy Infantry, num 4, exp 2, arm 1, wep 0
       console_command create_unit Venice, Venetian Archers, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Venice 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzy 0
      
    end_monitor
    
    
    ;;;;;;;;;; Palermo
    declare_counter gs_turns_egypt_Palermo
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyq 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Palermo -1
      set_event_counter gs_create_nowyytkzyq 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyq
      and EventCounter > 0
      
      if I_SettlementUnderSiege Palermo
        and I_SettlementOwner Palermo sicily
        and I_IsFactionAIControlled sicily
        and I_CompareCounter gs_turns_egypt_Palermo <= 0
     console_command create_unit Palermo, Norman Knights, num 3, exp 2, arm 1, wep 0
       console_command create_unit Palermo, Sicilian Muslim Archers, num 3, exp 2, arm 1, wep 0
       console_command create_unit Palermo, Italian Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Palermo, Dismounted Norman Knights, num 2, exp 2, arm 1, wep 0
       console_command create_unit Palermo, Dismounted Norman Knights, num 4, exp 2, arm 1, wep 0
       console_command create_unit Palermo, Pavise Crossbow Militia, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Palermo 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyq 0
      
    end_monitor
    
    
    ;;;;;;;;;; Ras
    declare_counter gs_turns_egypt_Ras
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqq 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Ras -1
      set_event_counter gs_create_nowyytkzyqq 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqq
      and EventCounter > 0
      
      if I_SettlementUnderSiege Ras
        and I_SettlementOwner Ras saxons
        and I_IsFactionAIControlled saxons
        and I_CompareCounter gs_turns_egypt_Ras <= 0
       console_command create_unit Ras, Gradska Straza, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ras, Gradska Straza, num 3, exp 2, arm 1, wep 0
       console_command create_unit Ras, Dismounted Tsar Knights, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ras, Dismounted Tsar Knights, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ras, Balkan Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ras, Balkan Archers, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Ras 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqq 0
      
    end_monitor
    
    
    ;;;;;;;;;; Ezstergom
    declare_counter gs_turns_egypt_Ezstergom
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqf 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Ezstergom -1
      set_event_counter gs_create_nowyytkzyqqf 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqf
      and EventCounter > 0
      
      if I_SettlementUnderSiege Ezstergom
        and I_SettlementOwner Ezstergom hungary
        and I_IsFactionAIControlled hungary
        and I_CompareCounter gs_turns_egypt_Ezstergom <= 0
       console_command create_unit Ezstergom, EE Spear Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ezstergom, EE Spear Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ezstergom, Crossbowmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ezstergom, Crossbowmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ezstergom, Pavise Spearmen, num 3, exp 2, arm 1, wep 0
       console_command create_unit Ezstergom, Pavise Spearmen, num 3, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Ezstergom 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqf 0
      
    end_monitor
    
    
    ;;;;;;;;;; Constantinople
    declare_counter gs_turns_egypt_Constantinople
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqs 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Constantinople -1
      set_event_counter gs_create_nowyytkzyqqs 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqs
      and EventCounter > 0
      
      if I_SettlementUnderSiege Constantinople
        and I_SettlementOwner Constantinople byzantium
        and I_IsFactionAIControlled byzantium
        and I_CompareCounter gs_turns_egypt_Constantinople <= 0
       console_command create_unit Constantinople, Contaratoi, num 4, exp 2, arm 1, wep 0
       console_command create_unit Constantinople, Contaratoi, num 2, exp 2, arm 1, wep 0
       console_command create_unit Constantinople, Contaratoi, num 2, exp 2, arm 1, wep 0
       console_command create_unit Constantinople, Toxotae, num 4, exp 2, arm 1, wep 0
       console_command create_unit Constantinople, Toxotae, num 2, exp 2, arm 1, wep 0
        console_command create_unit Constantinople, Toxotae, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Constantinople 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqs 0
      
    end_monitor
    
    
    ;;;;;;;;;; Leon
    declare_counter gs_turns_egypt_Leon
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqa 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Leon -1
      set_event_counter gs_create_nowyytkzyqqa 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqa
      and EventCounter > 0
      
      if I_SettlementUnderSiege Leon
        and I_SettlementOwner Leon spain
        and I_IsFactionAIControlled spain
        and I_CompareCounter gs_turns_egypt_Leon <= 0
       console_command create_unit Leon, Almughavars, num 4, exp 2, arm 1, wep 0
       console_command create_unit Leon, Swordsmen Militia, num 4, exp 2, arm 1, wep 0
       console_command create_unit Leon, Javelinmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Leon, Javelinmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Leon, Knights of Calatrava, num 2, exp 2, arm 1, wep 0
       console_command create_unit Leon, Spear Militia, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Leon 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqa 0
      
    end_monitor
    
    
    ;;;;;;;;;; Vilnius
    declare_counter gs_turns_egypt_Vilnius
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqd 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Vilnius -1
      set_event_counter gs_create_nowyytkzyqqd 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqd
      and EventCounter > 0
      
      if I_SettlementUnderSiege Vilnius
        and I_SettlementOwner Vilnius lithuania
        and I_IsFactionAIControlled lithuania
        and I_CompareCounter gs_turns_egypt_Vilnius <= 0
       console_command  create_unit Vilnius, Conquistadores, num 2, exp 2, arm 1, wep 0
       console_command create_unit Vilnius, Native Mercenaries, num 2, exp 2, arm 1, wep 0
       console_command create_unit Vilnius, Aztec Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Vilnius, Jaguar Warriors, num 4, exp 2, arm 1, wep 0
        console_command create_unit Vilnius, Aztec Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Vilnius, Eagle Warriors, num 3, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Vilnius 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqd 0
      
    end_monitor
    
    
    ;;;;;;;;;; Sis
    declare_counter gs_turns_egypt_Sis
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqg 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Sis -1
      set_event_counter gs_create_nowyytkzyqqg 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqg
      and EventCounter > 0
      
      if I_SettlementUnderSiege Sis
        and I_SettlementOwner Sis timurids
        and I_IsFactionAIControlled timurids
        and I_CompareCounter gs_turns_egypt_Sis <= 0
       console_command create_unit Sis, Azat, num 4, exp 2, arm 1, wep 0
       console_command create_unit Sis, Dismounted Nakharar Knights, num 3, exp 2, arm 1, wep 0
       console_command create_unit Sis, Levy Cilician, num 2, exp 2, arm 1, wep 0
       console_command create_unit Sis, Levy Cilician, num 2, exp 2, arm 1, wep 0
       console_command create_unit Sis, Caucasian Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Sis, Caucasian Archers, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Sis 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqg 0
      
    end_monitor
    
    
    ;;;;;;;;;; Jerusalem
    declare_counter gs_turns_egypt_Jerusalem
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqp 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Jerusalem -1
      set_event_counter gs_create_nowyytkzyqqp 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqp
      and EventCounter > 0
      
      if I_SettlementUnderSiege Jerusalem
        and I_SettlementOwner Jerusalem antioch
        and I_IsFactionAIControlled antioch
        and I_CompareCounter gs_turns_egypt_Jerusalem <= 0
      console_command create_unit Jerusalem, Edessan Squires, num 3, exp 2, arm 1, wep 0
       console_command create_unit Jerusalem, Edessan Squires, num 3, exp 2, arm 1, wep 0
       console_command create_unit Jerusalem, Dismounted Knights Hospitaller, num 2, exp 2, arm 1, wep 0
       console_command create_unit Jerusalem, Dismounted Knights Hospitaller, num 3, exp 2, arm 1, wep 0
       console_command create_unit Jerusalem, Dismounted Knights Of Jerusalem, num 2, exp 2, arm 1, wep 0
       console_command create_unit Jerusalem, Dismounted Knights Of Jerusalem, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Jerusalem 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqp 0
      
    end_monitor
    
    
    ;;;;;;;;;; Kutais
    declare_counter gs_turns_egypt_Kutais
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqm 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Kutais -1
      set_event_counter gs_create_nowyytkzyqqm 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqm
      and EventCounter > 0
      
      if I_SettlementUnderSiege Kutais
        and I_SettlementOwner Kutais georgia
        and I_IsFactionAIControlled georgia
        and I_CompareCounter gs_turns_egypt_Kutais <= 0
      console_command create_unit Kutais, Kartlian, num 2, exp 2, arm 1, wep 0
       console_command create_unit Kutais, Tadzreuli, num 3, exp 2, arm 1, wep 0
       console_command create_unit Kutais, Khevsur Warriors, num 4, exp 2, arm 1, wep 0
       console_command create_unit Kutais, k_spear, num 3, exp 2, arm 1, wep 0
       console_command create_unit Kutais, Monaspa Archers, num 4, exp 2, arm 1, wep 0
       console_command create_unit Kutais, Caucasian Archers, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Kutais 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqm 0
      
    end_monitor
    
    
    
    
    ;;;;;;;;;; Teshkent
    declare_counter gs_turns_egypt_Teshkent
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqx 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Teshkent -1
      set_event_counter gs_create_nowyytkzyqqx 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqx
      and EventCounter > 0
      
      if I_SettlementUnderSiege Teshkent
        and I_SettlementOwner Teshkent milan
        and I_IsFactionAIControlled milan
        and I_CompareCounter gs_turns_egypt_Teshkent <= 0
      console_command create_unit Teshkent, Khitan Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Teshkent, Khitan Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Teshkent, Khitan Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Teshkent, Khitan Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Teshkent, Liao Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Teshkent, Liao Spearmen, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Teshkent 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqx 0
      
    end_monitor
    
    
    ;;;;;;;;;; Naimen
    declare_counter gs_turns_egypt_Naimen
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxx 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Naimen -1
      set_event_counter gs_create_nowyytkzyqqxx 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxx
      and EventCounter > 0
      
      if I_SettlementUnderSiege Naimen
        and I_SettlementOwner Naimen mongols
        and I_IsFactionAIControlled mongols
        and I_CompareCounter gs_turns_egypt_Naimen <= 0
      console_command create_unit Naimen, mon_horchi_inf, num 4, exp 2, arm 1, wep 0
       console_command create_unit Naimen, mon_habutu_inf, num 2, exp 2, arm 1, wep 0
       console_command create_unit Naimen, mon_torhaguti_inf, num 4, exp 2, arm 1, wep 0
       console_command create_unit Naimen, mon_horchi_cav, num 2, exp 2, arm 1, wep 0
       console_command create_unit Naimen, mon_hoshuchi, num 3, exp 2, arm 1, wep 0
       console_command create_unit Naimen, mon_horchi_cav, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Naimen 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxx 0
      
    end_monitor
    
    
    ;;;;;;;;;; Arhus
    declare_counter gs_turns_egypt_Arhus
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxc 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Arhus -1
      set_event_counter gs_create_nowyytkzyqqxc 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxc
      and EventCounter > 0
      
      if I_SettlementUnderSiege Arhus
        and I_SettlementOwner Arhus denmark
        and I_IsFactionAIControlled denmark
        and I_CompareCounter gs_turns_egypt_Arhus <= 0
      console_command create_unit Arhus, Norse Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Arhus, Norse Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Arhus, Norse Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Arhus, Norse Axemen, num 4, exp 2, arm 1, wep 0
       console_command create_unit Arhus, Norse Axemen, num 4, exp 2, arm 1, wep 0
       console_command create_unit Arhus, Norse Swordsmen, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Arhus 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxc 0
      
    end_monitor
    
    
    ;;;;;;;;;; Ghazni
    declare_counter gs_turns_egypt_Ghazni
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxj 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Ghazni -1
      set_event_counter gs_create_nowyytkzyqqxj 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxj
      and EventCounter > 0
      
      if I_SettlementUnderSiege Ghazni
        and I_SettlementOwner Ghazni ghazni
        and I_IsFactionAIControlled ghazni
        and I_CompareCounter gs_turns_egypt_Ghazni <= 0
     console_command create_unit Ghazni, Ghazis, num 3, exp 2, arm 1, wep 0
       console_command create_unit Ghazni, Ghazis, num 4, exp 2, arm 1, wep 0
       console_command create_unit Ghazni, Ghaznavid Bowmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ghazni, Ghaznavid Bowmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Ghazni, Ghaznavid Bowmen, num 4, exp 2, arm 1, wep 0
       console_command create_unit Ghazni, Pashtun Militia, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Ghazni 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxj 0
      
    end_monitor
    
    
    ;;;;;;;;;; Urgench
    declare_counter gs_turns_egypt_Urgench
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxb 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Urgench -1
      set_event_counter gs_create_nowyytkzyqqxb 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxb
      and EventCounter > 0
      
      if I_SettlementUnderSiege Urgench
        and I_SettlementOwner Urgench wales
        and I_IsFactionAIControlled wales
        and I_CompareCounter gs_turns_egypt_Urgench <= 0
      console_command create_unit Urgench, Daylami, num 4, exp 2, arm 1, wep 0
       console_command create_unit Urgench, Tajik Spearmen, num 2, exp 2, arm 1, wep 0
       console_command create_unit Urgench, Tajik Spearmen, num 3, exp 2, arm 1, wep 0
       console_command create_unit Urgench, Persian Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Urgench, Persian Archers, num 2, exp 2, arm 1, wep 0
       console_command create_unit Urgench, Persian Archers, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Urgench 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxb 0
      
    end_monitor
    
    
    ;;;;;;;;;; Anhilvara
    declare_counter gs_turns_egypt_Anhilvara
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxe 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Anhilvara -1
      set_event_counter gs_create_nowyytkzyqqxe 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxe
      and EventCounter > 0
      
      if I_SettlementUnderSiege Anhilvara
        and I_SettlementOwner Anhilvara aztecs
        and I_IsFactionAIControlled aztecs
        and I_CompareCounter gs_turns_egypt_Anhilvara <= 0
      console_command create_unit Anhilvara, Mak_Spearmen, num 2, exp 2, arm 1, wep 0
      console_command create_unit Anhilvara, Mak_Spearmen, num 2, exp 2, arm 1, wep 0
      console_command create_unit Anhilvara, Makuria Nobles, num 2, exp 2, arm 1, wep 0
      console_command create_unit Anhilvara, Makuria Nobles, num 2, exp 2, arm 1, wep 0
      console_command create_unit Anhilvara, Mak Peasants, num 2, exp 2, arm 1, wep 0
       console_command create_unit Anhilvara, Dongola Swordsmen, num 2, exp 2, arm 1, wep 0
        console_command create_unit Anhilvara, Makuria Nobles, num 4, exp 2, arm 1, wep 0
        console_command create_unit Anhilvara, Dongola Swordsmen, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Anhilvara 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxe 0
      
    end_monitor
    
    
    ;;;;;;;;;; Caffa
    declare_counter gs_turns_egypt_Caffa
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxo 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Caffa -1
      set_event_counter gs_create_nowyytkzyqqxo 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxo
      and EventCounter > 0
      
      if I_SettlementUnderSiege Caffa
        and I_SettlementOwner Caffa portugal
        and I_IsFactionAIControlled portugal
        and I_CompareCounter gs_turns_egypt_Caffa <= 0
      console_command create_unit Caffa, cum_alan_axe, num 3, exp 2, arm 1, wep 0
       console_command create_unit Caffa, cum_alan_axe, num 2, exp 2, arm 1, wep 0
       console_command create_unit Caffa, cum_alan_axe, num 2, exp 2, arm 1, wep 0
       console_command create_unit Caffa, cum_druz_bek_a_sw, num 4, exp 2, arm 1, wep 0
       console_command create_unit Caffa, cum_cheled_sw, num 2, exp 2, arm 1, wep 0
       console_command create_unit Caffa, cum_cheled_sw, num 3, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Caffa 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxo 0
      
    end_monitor
    
    
    ;;;;;;;;;; London
    declare_counter gs_turns_egypt_London
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxr 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_London -1
      set_event_counter gs_create_nowyytkzyqqxr 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxr
      and EventCounter > 0
      
      if I_SettlementUnderSiege London
        and I_SettlementOwner London england
        and I_IsFactionAIControlled england
        and I_CompareCounter gs_turns_egypt_London <= 0
       console_command create_unit London, Heavy Billmen, num 5, exp 2, arm 1, wep 0
      console_command create_unit London, Dismounted Longbowmen, num 4, exp 2, arm 1, wep 0
      console_command create_unit London, Dismounted Longbowmen, num 2, exp 2, arm 1, wep 0
      console_command create_unit London, Dismounted Longbowmen, num 2, exp 2, arm 1, wep 0
      console_command create_unit London, Bill Militia, num 4, exp 2, arm 1, wep 0
       console_command create_unit London, Bill Militia, num 2, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_London 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxr 0
      
    end_monitor
    
    
    ;;;;;;;;;; Rome
    declare_counter gs_turns_egypt_Rome
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxu 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Rome -1
      set_event_counter gs_create_nowyytkzyqqxu 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxu
      and EventCounter > 0
      
      if I_SettlementUnderSiege Rome
        and I_SettlementOwner Rome papal_states
        and I_IsFactionAIControlled papal_states
        and I_CompareCounter gs_turns_egypt_Rome <= 0
       console_command create_unit Rome, Italian MAA, num 4, exp 2, arm 1, wep 0
       console_command create_unit Rome, Italian MAA, num 2, exp 2, arm 1, wep 0
       console_command create_unit Rome, Italian MAA, num 2, exp 2, arm 1, wep 0
       console_command create_unit Rome, Italian Militia, num 2, exp 2, arm 1, wep 0
       console_command create_unit Rome, Dismounted Italian MAA, num 4, exp 2, arm 1, wep 0
       console_command create_unit Rome, Dismounted Italian MAA, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Rome 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxu 0
      
    end_monitor
    
    
    ;;;;;;;;;; Stockholm
    declare_counter gs_turns_egypt_Stockholm
    
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_nowyytkzyqqxir 1
    end_monitor
    
    
    monitor_event FactionTurnStart FactionType slave
    
    
      inc_counter gs_turns_egypt_Stockholm -1
      set_event_counter gs_create_nowyytkzyqqxir 1
    end_monitor
    
    
    
    
    monitor_event EventCounter EventCounterType gs_create_nowyytkzyqqxir
      and EventCounter > 0
      
      if I_SettlementUnderSiege Stockholm
        and I_SettlementOwner Stockholm teutonic_order
        and I_IsFactionAIControlled teutonic_order
        and I_CompareCounter gs_turns_egypt_Stockholm <= 0
       console_command create_unit Stockholm, Bondesoldater, num 4, exp 2, arm 1, wep 0
       console_command create_unit Stockholm, Bondesoldater, num 2, exp 2, arm 1, wep 0
       console_command create_unit Stockholm, Bondesoldater, num 2, exp 2, arm 1, wep 0
       console_command create_unit Stockholm, Swedish_Crossbowmen, num 4, exp 2, arm 1, wep 0
       console_command create_unit Stockholm, Bagskyttar, num 2, exp 2, arm 1, wep 0
       console_command create_unit Stockholm, Bagskyttar, num 4, exp 2, arm 1, wep 0
        set_counter gs_turns_egypt_Stockholm 5 
      end_if
    
    
      set_event_counter gs_create_nowyytkzyqqxir 0
      
    end_monitor
    log;
    Spoiler Alert, click show to read: 
    12:22:56.522 [game.script.exec] [trace] exec <set_event_counter> at line 43938 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt12:22:56.523 [game.script.exec] [trace] exec <if> at line 43954 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.523 [game.script.exec] [trace] exec <set_event_counter> at line 43963 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.524 [game.script.timer.strat] [trace] Strat timer finished 0.10, line number 43971
    12:22:56.524 [game.script.exec] [trace] exec <set_event_counter> at line 43972 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.524 [game.script.exec] [trace] exec <if> at line 43988 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.525 [game.script.exec] [trace] exec <set_event_counter> at line 43997 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.525 [game.script.timer.strat] [trace] Strat timer finished 0.10, line number 44005
    12:22:56.526 [game.script.exec] [trace] exec <set_event_counter> at line 44006 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.526 [game.script.exec] [trace] exec <if> at line 44023 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.526 [game.script.exec] [trace] exec <console_command> at line 44023 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.527 [game.script] [error] Script execution error for <console_command>, at line 44023, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Armored Sergeants, num 4, exp 2, arm 1, wep 0
    err: unit type not recognised


    12:22:56.527 [game.script.exec] [trace] exec <console_command> at line 44024 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.527 [game.script] [error] Script execution error for <console_command>, at line 44024, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Armored Sergeants, num 2, exp 2, arm 1, wep 0
    err: unit type not recognised


    12:22:56.527 [game.script.exec] [trace] exec <console_command> at line 44025 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.527 [game.script] [error] Script execution error for <console_command>, at line 44025, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Noble Knights, num 4, exp 2, arm 1, wep 0
    err: unit type not recognised


    12:22:56.528 [game.script.exec] [trace] exec <console_command> at line 44026 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.528 [game.script] [error] Script execution error for <console_command>, at line 44026, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Crossbowmen, num 2, exp 2, arm 1, wep 0
    err: cannot add unit(s) because the garrison already contains the maximum number of units


    12:22:56.528 [game.script.exec] [trace] exec <console_command> at line 44027 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.528 [game.script] [error] Script execution error for <console_command>, at line 44027, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Chevaliers Du Languedoc, num 4, exp 2, arm 1, wep 0
    err: unit type not recognised


    12:22:56.528 [game.script.exec] [trace] exec <console_command> at line 44028 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.528 [game.script] [error] Script execution error for <console_command>, at line 44028, in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt:
    create_unit Paris, Town Militia, num 2, exp 2, arm 1, wep 0
    err: unit type not recognised


    12:22:56.528 [game.script.exec] [trace] exec <set_counter> at line 44029 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.528 [game.script.counter] [trace] counter <gs_turns_egypt_Paris> = 5
    12:22:56.528 [game.script.exec] [trace] exec <set_event_counter> at line 44032 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.529 [game.script.timer.strat] [trace] Strat timer finished 0.10, line number 44040
    12:22:56.529 [game.script.exec] [trace] exec <set_event_counter> at line 44041 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.529 [game.script.exec] [trace] exec <if> at line 44058 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.529 [game.script.exec] [trace] exec <set_event_counter> at line 44068 in mods/FA/data/world/maps/campaign/imperial_campaign/campaign_script.txt
    12:22:56.529 [game.script.timer.strat] [trace] Strat timer finished 0.10, line number 44076

  5. #45

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    1) You can do all this work in only three monitor, if follow exactly the instructions given by Withwnar. Your script adds a rather significant delay to your game, as from each of these Transgression monitors a campaign_wait 0.1 is issued
    2) You haven't typed the correct form of the "console_command create_units"; it's not the same as without the console_command.
    Code:
    console_command create_unit Paris "Armored Sergeants" 4 2 1 0
    Last edited by gsthoed; September 07, 2014 at 06:16 AM.

  6. #46

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    thank you gsthoed i did not see that,but about the you can do all in one monitor seems good but will it not have a chance that the event_counter gs_create_now will conflict ,as this one will chance it's counter if one of the 30 faction capitals are under besiege,so better make a new event_counter for every (30) capitals of the factions?

  7. #47
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Yes, each needs it own counter:

    Quote Originally Posted by Post 40
    One counter for each faction+settlement combination that requires a garrison script
    EDIT: Yours would look like this...

    Code:
    declare_counter gs_turns_norway_Trondhelm
    declare_counter gs_turns_egypt_Nuremburg
    declare_counter gs_turns_france_Paris
    ;other settlements...
    
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      campaign_wait 0.1
      set_event_counter gs_create_now 1
    end_monitor
    
    monitor_event FactionTurnStart FactionType slave
    
      inc_counter gs_turns_norway_Trondhelm -1
      inc_counter gs_turns_egypt_Nuremburg -1
      inc_counter gs_turns_france_Paris -1
      ;other settlements...
    
      set_event_counter gs_create_now 1
    end_monitor
    
    monitor_event EventCounter EventCounterType gs_create_now
      and EventCounter > 0
      
      if I_SettlementUnderSiege Trondhelm
        and I_SettlementOwner Trondhelm norway
        and I_IsFactionAIControlled norway
        and I_CompareCounter gs_turns_norway_Trondhelm <= 0
        ;units go here: use the "console_command create_unit" syntax
        set_counter gs_turns_norway_Trondhelm 5    
      end_if
      
      if I_SettlementUnderSiege Nuremburg
        and I_SettlementOwner Nuremburg egypt
        and I_IsFactionAIControlled egypt
        and I_CompareCounter gs_turns_egypt_Nuremburg <= 0
        ;units go here: use the "console_command create_unit" syntax
        set_counter gs_turns_egypt_Nuremburg 5    
      end_if
      
      if I_SettlementUnderSiege Paris
        and I_SettlementOwner Paris france
        and I_IsFactionAIControlled france
        and I_CompareCounter gs_turns_france_Paris <= 0
        ;units go here: use the "console_command create_unit" syntax
        set_counter gs_turns_france_Paris 5    
      end_if
    
      ;other settlements...
    
      set_event_counter gs_create_now 0
      
    end_monitor
    ...and so on for the other faction+settlement combinations. (I only did your first three.)

    And use the "console_command create_unit" way of creating units - as gsthoed said - otherwise it can interfere with spawning and recruiting units in that settlement, as mentioned earlier in this thread (post 32 & 33).
    Last edited by Withwnar; September 07, 2014 at 07:34 AM.

  8. #48

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    The "Transgression" monitor should contain exactly two lines (except if you follow my last approach) : the campaign wait and the set_event_counter. In the EventCounter monitor you can add the check for every capital. From what Withwnar reports about repeated sieges, I doubt too that the process can stuck, but if, by any chance, there is this conflict, the reinforcements will "arrrive" at the next instigation of a siege or at first FactionTurnStart of the slave faction (depends on which one comes first). Second, Withwnar's script demands approximately 0.1 seconds between two siege instigations; your script demands this 0.1 second +30·0.001sec, so it has higher chances for this conflict.
    Also, if you are interested for the real capitals of each faction and you use any spawnpool faction, check this tutorial:

    I am covered from your analysis, Withwnar, about the TC_INSTIGATE_SIEGE transgression and its use for garrison script. I believe you should put it in separate tutorial, as it deserves it (and to move discussions for garrison scripts to another thread ).
    Also, the downside you refer in my last script is what you refer in your previous post "Typically garrison scripts have a cooldown period so that a garrison won't spawn until at least X turns since the last time it did in that settlement"

    EDIT: I see it took me too long to write this post..
    Last edited by gsthoed; September 07, 2014 at 08:07 AM. Reason: Fixed wrong calculation of delay time

  9. #49

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Quote Originally Posted by Withwnar View Post
    I then tried moving that campaign_wait to the EventCounter monitor instead (removed from the Transgression one) and added a "log always" to there as well ... as expected this time the Transgression monitor fired twice but the EventCounter monitor fired only once.
    Due to this notice, I 've fixed post #41 script

  10. #50
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    I got a question - if I have monitor with many ifs, which should fire its effect once during campain, and then I have no need of it, may I terminate it like this

    monitor_event FactionTurnStart FactionIsLocal

    if I_EventCounter abc_event = 1
    .. or some other conditions, when no effect fires
    end_if

    if I_EventCounter abc_event = 2
    ... or some other conditions, when effect fires
    terminate_monitor
    end_if
    end_monitor

    I expect this way I will terminate this entire monitor after it fires necessary effect after some conditions.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  11. #51

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    With that particular monitor it will fire at the beginning of the game and terminate, that would only be useful if the 'if' events only correspond to what faction the player controls in a single player game. For any other situation you'll want to put the terminate_monitor inside each possible 'if' event, to get the results your looking for.

  12. #52
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    It will only terminate when "abc_event = 2" which is what he wants. Your script is correct, bitterhowl.

    terminate_monitor instantly stops and kills the monitor.

    I often use them at the beginning of monitors, in IFs, in situations where the monitor is no longer needed (or never was). For example, a monitor that is only required when england is not an AI faction...

    Code:
    monitor_event FactionTurnStart FactionType england
    
      if I_IsFactionAIControlled england
        terminate_monitor
      end_if
      
      ;...a bunch of script ... it can safely assume that england is the player...
    
    end_monitor
    It is equivalent to - but cleaner than, in my opinion - this...

    Code:
    monitor_event FactionTurnStart FactionType england
    
      if not I_IsFactionAIControlled england
        ;...a bunch of script ... it can safely assume that england is the player...
      end_if
    
      if I_IsFactionAIControlled england
        terminate_monitor
      end_if
      
    end_monitor
    Common practice is to just do this...

    Code:
    monitor_event FactionTurnStart FactionType england
      and not I_IsFactionAIControlled england
      
      ;...a bunch of script ... it can safely assume that england is the player...
    
    end_monitor
    ...but it will never terminate if the player is not england, meaning that at the start of each faction's turn, for the entire campaign, this monitor is checking the faction type and whether it is AI controlled for absolutely no reason. No doubt this adds no noticeable lag so not worth worrying about ... but all of those tiny lags add up to a noticeable one eventually.

  13. #53
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Well, at this moment I got 2 situations. First is about some scenario events, when some armies invade and move using random counters to 3-4 random targets. Like this
    Spoiler Alert, click show to read: 
    if not I_IsFactionAIControlled milan
    and I_TurnNumber = 5
    and I_SettlementOwner The_Arbor = hre
    and RandomPercent = 50
    generate_random_counter arbor_base1 0 1
    if I_EventCounter arbor_base1 = 0
    and not I_SettlementOwner Three_Towers = hre
    and not I_SettlementUnderSiege Three_Towers
    spawn_army
    faction hre
    character random_name, named character, x 19, y 22, label hre2
    traits GoodCommander 1 , GoodAmbusher 1 , Brave 3
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Dismounted Huscarls exp 4 armour 0 weapon_lvl 0
    unit Dismounted Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    end
    siege_settlement hre2, Three_Towers, maintain
    end_if
    if I_EventCounter arbor_base1 = 1
    and not I_SettlementOwner Sun_House = hre
    and not I_SettlementUnderSiege Sun_House
    spawn_army
    faction hre
    character random_name, named character, x 29, y 16, label hre2a
    traits GoodCommander 1 , GoodAmbusher 1 , Brave 3 , Hatescatholic 2
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Norse Axemen exp 4 armour 0 weapon_lvl 0
    unit Dismounted Huscarls exp 4 armour 0 weapon_lvl 0
    unit Dismounted Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit English Huscarls exp 1 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    unit Viking Raiders exp 2 armour 1 weapon_lvl 0
    end
    siege_settlement hre2a, Sun_House, maintain
    end_if
    end_if
    if I_TurnNumber = 6
    and I_EventCounter arbor_base1 = 1
    and I_CharacterExists hre2a
    and I_SettlementUnderSiege Sun_House
    siege_settlement hre2a, Sun_House, attack
    end_if
    if I_TurnNumber = 6
    and I_EventCounter arbor_base1 = 0
    and I_CharacterExists hre2
    and I_SettlementUnderSiege Three_Towers
    siege_settlement hre2, Three_Towers, attack
    end_if
    So, after 6-th turn I have no need in this monitor, how to terminate it correctly?
    Second situation is about assimilation script, when player capture settlement he can't recruit elite units from the begining if he doesn't own the whole geographical region (some key settlements in it). So, when he once conquer the region if he lose 1-2 key settlements he shoudn't lose recruit ability, because nobility and people of region are already on his side. It looks like this
    Spoiler Alert, click show to read: 
    monitor_event FactionTurnStart not FactionIsLocal
    set_event_counter has_stormlands 1
    end_monitor

    monitor_event FactionTurnEnd FactionType slave
    and I_EventCounter no_stormsend = 1
    set_event_counter has_stormlands 0
    end_monitor


    monitor_event FactionTurnStart FactionIsLocal
    if not I_IsFactionAIControlled spain
    and not I_SettlementOwner Storms_End = spain
    and not I_SettlementOwner Griffins_Roost = spain
    and not I_SettlementOwner Felwood = spain
    set_event_counter no_stormsend = 1
    end_if
    if not I_IsFactionAIControlled spain
    and I_SettlementOwner Storms_End = spain
    and I_SettlementOwner Griffins_Roost = spain
    and I_SettlementOwner Felwood = spain
    set_event_counter no_stormsend = 0
    end_if
    end_monitor

    monitor_event SettlementSelected SettlementIsLocal
    if not I_IsFactionAIControlled spain
    and not I_SettlementOwner Storms_End = spain
    and not I_SettlementOwner Griffins_Roost = spain
    and not I_SettlementOwner Felwood = spain
    set_event_counter no_stormsend = 1
    end_if
    if not I_IsFactionAIControlled spain
    and I_SettlementOwner Storms_End = spain
    and I_SettlementOwner Griffins_Roost = spain
    and I_SettlementOwner Felwood = spain
    set_event_counter no_stormsend = 0
    end_if
    end_monitor

    monitor_event FactionTurnStart FactionIsLocal
    if I_EventCounter no_stormsend = 0
    set_event_counter has_stormlands 1
    end_if
    end_monitor
    So, when event_counter "has_stormlands = 1" units are avaliable. For AI they're avaliable all the time, for this matter I had to include second event_counter "no_stormsend" to indicate to retorn first counter to 0 at player's turn. I need to set it to 1 when player has all 3 settlements, and then it should have value 1 during the end of campaign. Where should I set terminate_monitor in that case?

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  14. #54
    Withwnar's Avatar Script To The Waist
    Join Date
    Oct 2008
    Location
    Earth
    Posts
    6,329

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    1) Either a) in both of those last two IFs, b) add another IF below them: "if turn = 6 then terminate", or c) an IF at the start: "if turn > 6 then terminate"

    2) In short I would add another counter that is set to 1 only when the player has reached the goal, then add an IF to the start of all of those monitors saying "if goal_reached_counter = 1 then terminate". Maybe you could use no_stormsend for that purpose but, being an event counter, I don't know if you're using it in other files.

    Anyway, I think that your script could be simplified a lot which also simplifies the terminate_monitor question...

    Code:
    declare_counter stormlands_done
    
    monitor_event FactionTurnStart not FactionIsLocal
      
      if I_CompareCounter stormlands_done = 1
        terminate_monitor
      end_if
      
      set_event_counter has_stormlands 1
      
    end_monitor
    
    monitor_event FactionTurnEnd FactionType slave
      
      if I_CompareCounter stormlands_done = 1
        terminate_monitor
      end_if
      
      set_event_counter has_stormlands 0
      
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
      
      if not I_IsFactionAIControlled spain
        and I_SettlementOwner Storms_End = spain
        and I_SettlementOwner Griffins_Roost = spain
        and I_SettlementOwner Felwood = spain
        
        set_event_counter has_stormlands 1
        set_counter stormlands_done 1
        terminate_monitor
      end_if
      
    end_monitor
    
    monitor_event SettlementSelected SettlementIsLocal
      
      if not I_IsFactionAIControlled spain
        and I_SettlementOwner Storms_End = spain
        and I_SettlementOwner Griffins_Roost = spain
        and I_SettlementOwner Felwood = spain
        
        set_event_counter has_stormlands 1
        set_counter stormlands_done 1
        terminate_monitor
      end_if
      
    end_monitor
    I'm assuming that no_stormsend was not being used by any other part of the script / other files.

    The third and fourth monitors (yours and mine) trouble me. In hotseat where spain and (e.g.) england are both player factions those monitors will also fire during england's turn, setting has_stormlands to 0 or 1 during their turn. I don't know if that's an issue but as this seems to be aimed at player spain only I would add a "and FactionType spain" condition to both of those monitors.

    P.S. Please use the [code][/code] tags (# button in advanced editor) instead of spoilers for script/code. It keeps the indentation intact which is much easier to read.

  15. #55
    bitterhowl's Avatar Campidoctor
    Join Date
    Feb 2011
    Location
    Russian Feodality
    Posts
    1,695

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Thanks for assistance!

    As for first situation I have a large nested ifs script of AI behavior, so it seems to use your a) variant.

    As for second, I need to script all factions, not only spain for assimilating. And I asked users, they want no hotseat but only single campain, so I began to do it in that way.

    My sister, do you still recall the blue Hasan and Khalkhin-Gol?
    Russian warship is winning. Proofs needed? Go find yourself!

  16. #56

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Hello everyone, sorry to necropost but I'm working on the SSHIP scripts and trying to keep them clean and lights, following all the advice in this thread. I just have two questions:

    1) we keep track of every faction turn with this:
    Code:
        monitor_event PreFactionTurnStart FactionType venice
            set_event_counter faction_turn_venice 1
            set_event_counter faction_turn_catholic 1
            set_event_counter faction_turn_southern_european 1
            log always Turn Start venice    ==============================================================
        end_monitor
    
        monitor_event FactionTurnEnd FactionType venice
            set_event_counter faction_turn_venice 0
            set_event_counter faction_turn_catholic 0
            set_event_counter faction_turn_southern_european 0    
            log always --- Turn End venice
        end_monitor
    Would it be better to use "monitor_event I_event_counter faction_turn_venice" instead of "monitor_event FactionTurnStart FactionType venice?
    If I understand correctly the first version would be tested only 2 times (when faction_turn_venice is set to 1 and when it's set to 0), where the second version would be tested at each faction start.
    But of course we don't have any record exported with the first version, so I would not work with all conditions.

    2) what is the impact of other files like EDA and EDCT? They're full of tests happening for every characters. Are monitor that much slower than WhenToTest condition, or is it not worth it to go beyond a certain point in optimizing campaign_script?

    For exemple I'm thinking of refactoring the previous FactionTurnEnd to this version, allowing to have only one monitor and multiple ifs
    Code:
        monitor_event FactionTurnEnd TrueCondition
    
            ; here stuff that has to be done for any faction
    
            if I_EventCounter faction_turn_FACTION = 1        ; to finish a specific faction turn
                set_event_counter faction_turn_FACTION 0
                set_event_counter faction_turn_RELIGION 0
                set_event_counter faction_turn_CULTURE 0    
                log always --- Turn End FACTION
            end_if
            
            ; duplicate for all factions.
        end_monitor
    thanks in advance for any hindsight!
    Last edited by Belovèse; January 23, 2021 at 08:43 AM.
    Belovèse's Toolbox: export text files to spreadsheet, detailed unit stats
    Stainless Steel Historical Improvement Project (SSHIP) team member.
    Mini-mods: diplomacy and relation/reputation - detailled unit stats

  17. #57

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    1) Pretty sure the performance impact of "monitor_event EventCounter" is higher because it has to check for a counter name each time any event_counter is changed. The difference is probably minimal, but if we are talking optimization, your version might be better.

    2) EDA & EDCT can definitely have an impact on turn times the same way the campaign_script does. It becomes very noticeable after adding a lot of new traits/ancs, especially later on in a campaign when there are more characters.



    You could just do it like this instead of a FactionTurnEnd monitor for each faction:

    Code:
    monitor_event PreFactionTurnStart
        set_event_counter faction_turn_FACTION 0
        set_event_counter faction_turn_RELIGION 0
        set_event_counter faction_turn_CULTURE 0
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType venice
        set_event_counter faction_turn_venice 1
        set_event_counter faction_turn_catholic 1
        set_event_counter faction_turn_southern_european 1
    end_monitor
    
    monitor_event PreFactionTurnStart FactionType milan
        set_event_counter faction_turn_milan 1
        set_event_counter faction_turn_catholic 1
        set_event_counter faction_turn_southern_european 1
    end_monitor
    
    ;etc.

  18. #58

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    thank you, I think I'll go with setting all faction_turn event counter at prefactionturnstart as you suggest.

    About "monitor_event EventCounter", did someone extensively test how it works?
    Belovèse's Toolbox: export text files to spreadsheet, detailed unit stats
    Stainless Steel Historical Improvement Project (SSHIP) team member.
    Mini-mods: diplomacy and relation/reputation - detailled unit stats

  19. #59

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    Make a google search for "monitor_event EventCounter site:twcenter.net", there are lots of different applications for this event.

  20. #60
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician took an arrow to the knee spy of the council

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,149
    Blog Entries
    36

    Default Re: what´s better? use many "if" condition or use many monitors? (which process less information)

    You have a logic issue I think - the event counters you are referencing (and wanting to put into IF loops) need to be created first. I am not sure but I think SSHIP already has those faction monitors and there simply is no way to 'clean them up' as it requires a monitor for each faction.

    The primary purpose of the faction monitors is to provide event counters, eg faction_turn_start_[faction] which then can be used to reduce monitor counts when referencing factions and their 'exports'. The log entries are useful for bug hunting.
    You can create more event counters within those monitors, but you will not be able to merge the monitors as desired.

    As to the 'monitor_event EventCounter' use - needs to be tested if TrueCondition can work, but I can't see why not. Caveat: afaik (more testing) the monitor will only 'fire' if the state of the event counter changes, it doesn't check for the 'static' value of the state, something to be kept in mind.
    Code:
        monitor_event EventCounter EventCounterType TrueCondition
            if I_EventCounter sample_counter = 0    default state (value) of counter
                do stuff
            end_if
            if I_EventCounter sample_counter = 1    other state (value) of counter
                do other stuff
            end_if
            if I_EventCounter sample_counter = 2    other state (value) of counter
                do other stuff
            end_if
        end_monitor
    Last edited by Gigantus; January 24, 2021 at 08:21 PM.










Page 3 of 4 FirstFirst 1234 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •