Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 63

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

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

    I see, and i guess the less IFs i need to execute an action the less the impact on turn time will be regardless if doing this increase the length of the scrip (ei repeating a command several times), right?
    Like for example this script bellow compared to the other in my previous post
    Spoiler Alert, click show to read: 
    Code:
    ;Global
      monitor_event FactionTurnEnd FactionType slave
      and I_CompareCounter faction_emerge_id >= 1
        set_counter ros_po_building 1
        console_command create_building Oslo ros_po_bonus
        ...create building on other settlements never used to re-emerge
        console_command create_building Serdobinskaya ros_po_bonus
    
    ;Scotland
      if I_CompareCounter faction_emerge_id = 1
        ;Non Target settlements
            console_command create_building Venice ros_po_bonus
            ...create building on rest of settlements not candidate for this faction to re-emerge
            console_command create_building Damietta ros_po_bonus
            console_command create_building Rhodes ros_po_bonus
            console_command create_building Nicosia ros_po_bonus
        if I_CompareCounter edinburgh_riot = 0
            console_command create_building Edinburgh ros_po_bonus
        end_if
        ...check if other candidate settlements are rioting
        if I_CompareCounter edinburgh_riot = 1
            console_command create_building Edinburgh ros_target
            if I_CompareCounter military_era = 0
                spawn_army
                faction scotland
                character random_name, named character, age 30, x 59, y 248, family
                traits GoodCommander 4 , Energetic 1 , StrategyChivalry 4, Intelligent 1
                unit   NE Bodyguard        exp 2 armour 0 weapon_lvl 0
                ...units etc
                end
            end_if
            ...repeat for rest of military eras, etc
            if I_SettlementOwner Edinburgh = venice
                faction_emerge scotland venice 2 400.0 0.0 1.2 town true unused_label1 unused_name 30
            end_if
            ...etc, etc check for all factions
            if I_SettlementOwner Edinburgh = slave
                faction_emerge scotland slave 1 400.0 0.0 1.2 town true unused_label1 unused_name 30
            end_if
        end_if
        if I_CompareCounter aberdeen_riot = 1
        ...other settlements etc
        end_if
        historic_event scotland_emerged
        set_counter edinburgh_riot 0
        set_counter aberdeen_riot 0
        set_counter inverness_riot 0
        set_counter scotland_emerge 2
      end_if
    
    
    ;Venice
      if I_CompareCounter faction_emerge_id = 2
        ;Non Target settlements
            console_command create_building Edinburgh ros_po_bonus
            ...create building on rest of settlements not candidate for this faction to re-emerge
            console_command create_building Damietta ros_po_bonus
            console_command create_building Rhodes ros_po_bonus
            console_command create_building Nicosia ros_po_bonus
        if I_CompareCounter venice_riot = 0
            console_command create_building Venice ros_po_bonus
        end_if
        if I_CompareCounter venice_riot = 1
            console_command create_building Venice ros_target
            if I_CompareCounter military_era = 0
                spawn_army
                faction venice
                character random_name, named character, age 30, x 168, y 173, family
                traits GoodCommander 4 , Energetic 1 , StrategyChivalry 4, Intelligent 1
                unit   SE Bodyguard            exp 2 armour 0 weapon_lvl 0
                ...units etc
                end
            end_if
            ...repeat for rest of military eras, etc
            if I_SettlementOwner Venice = scotland
                faction_emerge venice scotland 2 400.0 0.0 1.2 town true unused_label1 unused_name 30
            end_if
            ...etc, etc check for all factions
            if I_SettlementOwner Venice = slave
                faction_emerge venice slave 1 400.0 0.0 1.2 town true unused_label1 unused_name 30
            end_if
        end_if
        historic_event venice_emerged
        set_counter venice_riot 0
        set_counter venice_emerge 2
      end_if
      ...22 more factions
      end_monitor

    green for the series of commands that repeat several times in favor of reducing IFs

  2. #2
    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)

    Generally speaking, yes. But I_CompareCounter is a very fast condition to check; a few extra of those is not going to hurt at all, especially as this whole script won't even be executing very often (I assume). If saving a few IFs results in more duplicated script and decreased readability/maintainability then I wouldn't bother.

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    52,682
    Blog Entries
    35

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

    He he he - more little scripting gems to be squirreled away for use on a rainy day. Thanks.










  4. #4

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

    I have some concerns about how "reload-save" are the while loops. It is expected that when we save the game, while loops are saved too. But what if the game crashes and a while loop is "on" (executing some code, or, if the while loop is just a pauser, the crash takes place in the time space between two two subsequent loops. I can test for the former; I had somewhere a script that causes CTDs on demand and by using an EventCounter monitor we can say if the while loop is on, can't we? But, I cannot imagine how to check for the later.

  5. #5
    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)

    Quote Originally Posted by gsthoed View Post
    ...a script that causes CTDs on demand...I cannot imagine how to check for...
    I know that the point is moot now and I'm not sure that the above is actually what you were asking, but... one way to script a CTD is by calling historic_event with a name that does not exist in historic_events.txt.

    Quote Originally Posted by gsthoed View Post
    I believe we are a little off topic when we discuss about scripted garrison reinforcements, but here it is...
    It was off topic but your solution's while loop brings it back. Well, to the topic of while loops at least which strictly speaking was also off topic.

    Good thinking with the Transgression event. I have never used it myself because I seem to recall that it can only fire once per turn - that is from something I read once but it might have been that certain transgression types can only happen once per turn, e.g. war declared between the same two factions, or maybe it wasn't the Transgression event at all that I'm remembering. Anyway...

    If somebody lays siege to any norway settlement or fort before Trondhelm then that while loop runs forever - checking 20 times per second whether Trondhelm is under siege - until somebody does finally lay siege to Trondhelm. In that respect I suspect that it's no different to the original monitor_conditions script, lag wise, except that it only happens for sections of the campaign lifetime - begins when somebody lays siege to norway and ends when Trondhelm is under siege - instead of all of the time.

    As far as I can see it could be rewritten as just...

    Code:
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
        and TargetFactionType norway
        and I_SettlementOwner Trondhelm = norway
        and I_SettlementUnderSiege Trondhelm
    
        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
    
    end_monitor
    ...or am I missing something? Perhaps that at the time of a TC_INSTIGATE_SIEGE event firing the settlement in question is not yet actually under siege, so I_SettlementUnderSiege doesn't work?

    Either way there is another issue: if norway-owned Trondhelm is under siege when somebody lays siege to any other norway settlement/fort then this monitor will execute again, adding more units to Trondhelm.

    EDIT:
    Quote Originally Posted by Me
    Perhaps that at the time of a TC_INSTIGATE_SIEGE event firing the settlement in question is not yet actually under siege, so I_SettlementUnderSiege doesn't work?
    I just tried it and this is exactly what happens. Unfortunately that kind of thing happens sometimes.

    However, this works...

    Code:
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
      and TargetFactionType norway
      and I_SettlementOwner Trondhelm = norway
    
      campaign_wait 0.1
    
      if I_SettlementUnderSiege Trondhelm
        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
      end_if
    
    end_monitor
    The campaign_wait gives the game some 'time' to realise that Trondhelm is now under siege.
    Last edited by Withwnar; September 06, 2014 at 12:36 AM.

  6. #6

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

    I had prepared a longer post, but now I 'll have to cut that long story short!
    Some quick notes:
    a) About how many times per turn this transgression can happen: I 've never thought of it. I had starting using this event for a differenet type of garrison reinforcents. I'll give it try anyway!
    b) Even when this while loop is "on", I expect lag will be less than the original script that had two monitor_conditions.
    c) I put the I_SettlementOwner "inside" the monitor, because we need to avoid reinforcing the garrison if -when the while loop exits- Trondheim is under control of the slave faction or had been gifted to other faction!

    I had prepared an improved version of my previous post:
    Spoiler Alert, click show to read: 
    Code:
    declare_counter Trondhelm_siege
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
        and TargetFactionType norway
        and I_SettlementOwner Trondhelm = norway
        and I_CompareCounter Trondhelm_siege = 0
        and ! I_SettlementUnderSiege Trondhelm
    
        set_counter Trondhelm_siege 1
    
        while ! I_SettlementUnderSiege Trondhelm
        end_while
    
    if I_SettlementOwner Trondhelm = norway
        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
    end_if
    
     set_counter Trondhelm_siege 0 
    end_monitor


    Your approach seems far better, at least as a base, as we have to improve in order to not fire for sieges against other norwegian settlements/forts when Trondheim is under siege. Some questions about it:
    i) Is this 0.1 seconds long enough to allow the script to take effect?
    ii) Depending on the mod, CPU power etc, 0.1 seconds can be enough time for the AI to instigate two subsequent sieges against Trondheim-ownining Norway. Can this cause malfunctions in the execution of this monitor?
    For these two reasons I generally avoid using "wait" commands when I know what event/condition I expect.

  7. #7

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

    if there is a CTD you will lose everything that was up to the moment and will need to load a previous game save anyway, so why worry about it?

  8. #8

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

    Quote Originally Posted by Melooo182 View Post
    if there is a CTD you will lose everything that was up to the moment and will need to load a previous game save anyway, so why worry about it?
    Because if a while loop is lost, I 'd need a GameReloaded monitor to start it again (unless it was about something that was running only during playing a battle?).

  9. #9

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

    I still don't get it, you'll always need to reload a previous savegame after a CTD, even if the savegame is the autosave from player's turn end or prebattle, those are done before the crash...unless the crash occurs exactly during the save process (which is extremely rare) making that particular savegame useless/corrupted/damaged, needing an even older save to be able to resume the campaign.

    therefore what you lose in a CTD will not matter as you will reload what was going on at the moment of the save and not at the moment of the crash.

    Is there any difference between autosaves and player commanded saves?
    If there is any problem with loops that you should worry about, are those about player commanded save and autosaves, in case they don't work the same.

    BTW is this for RBAI background stuff?

  10. #10

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

    An example of a while loop that is necessary to be restarted if it breaks from a CTD. It is a while loop that has to be run as long as a faction is "alive".
    Other example (which I test for quite a time lately): I have a monitor that triggers a "Yes/No" event. After the historic_event command is issued, I use a pauser until this event is accepted or declined by the player (or, in hotseat, until current faction's turn end -in order to avoid in this while loop keeping running while this player's faction had been destroyed and no answer had been issued).



    EDIT: Now I've got it. I am covered by your answer, Melooo182 !
    Last edited by gsthoed; September 05, 2014 at 10:53 AM.

  11. #11

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

    Code:
    monitor_conditions not I_SettlementUnderSiege Trondhelm                   
    set_counter Trondhelm_siege 0
    end_monitor
    
    
    monitor_conditions I_SettlementUnderSiege Trondhelm          
            and I_CompareCounter Trondhelm_siege = 0
    
    
    if I_SettlementOwner Trondhelm = norway                   
        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_Lángbogmenn, num 2, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_hr_norsk, num 2, exp 2, arm 1, wep 0
    end_if        
    
    
    set_counter Trondhelm_siege 1
    
    
    end_monitor
    can the monitor_conditions here(as it checks too much)be replaced by monitor_event? as this will be better for script?

  12. #12

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

    Quote Originally Posted by stevietheconquer View Post
    Spoiler Alert, click show to read: 
    Code:
    monitor_conditions not I_SettlementUnderSiege Trondhelm                   
    set_counter Trondhelm_siege 0
    end_monitor
    
    
    monitor_conditions I_SettlementUnderSiege Trondhelm          
            and I_CompareCounter Trondhelm_siege = 0
    
    
    if I_SettlementOwner Trondhelm = norway                   
        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_Lángbogmenn, num 2, exp 2, arm 1, wep 0
        create_unit Trondhelm, nor_hr_norsk, num 2, exp 2, arm 1, wep 0
    end_if        
    
    
    set_counter Trondhelm_siege 1
    
    
    end_monitor
    can the monitor_conditions here(as it checks too much)be replaced by monitor_event? as this will be better for script?
    I believe we are a little off topic when we discuss about scripted garrison reinforcements, but here it is

    Code:
    declare_counter Trondhelm_siege
    monitor_event Transgression TransgressionName = TC_INSTIGATE_SIEGE
        and TargetFactionType norway
        and I_SettlementOwner Trondhelm = norway
        and I_CompareCounter Trondhelm_siege = 0
    
       set_counter Trondhelm_siege 1
        while ! I_SettlementUnderSiege Trondhelm
        end_while
    
    if I_SettlementOwner Trondhelm = norway
        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
    end_if
       set_counter Trondhelm_siege 0
     end_monitor
    Last edited by gsthoed; September 05, 2014 at 05:12 PM. Reason: Fix

  13. #13

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

    you could replace it to
    Code:
    monitor_event SettlementTurnStart SettlementName Trondhelm
    and I_SettlementOwner Trondhelm = norway
    and I_SettlementUnderSiege Trondhelm
         create_unit ...
         etc
    end_monitor
    of course this wouldn't trigger until the besieged faction (norway) turn, so if the besieger has any siege engines (catapults etc) could prevent the garrison script to fire.

    simplifying the one you already have:
    Code:
    monitor_condition I_SettlementUnderSiege Trondhelm
         if I_SettlementOwner Trondhelm = norway
              create_unit ...
              etc
         end_if
         if I_SettlementOwner Trondhelm = other faction...
              create_unit ...
              etc
         end_if
    end_monitor
    removing 1 monitor and redundant counters, unless you wanted to use those counter for something else?


    There is also this GeneralAssaultsResidence event but i don't know if would work for this, according to DaemonTools this would work when assaulting the settlement/fort with sieges engines directly without waiting for a turn building other siege equipment.

    Identifier: GeneralAssaultsResidence
    Event: An assault has taken place
    Exports: nc_character_record, character_record, faction, region_id, character_type, target_faction, target_region_id, target_religion
    Class: ET_GENERAL_ASSAULT_RESIDENCE

    However I don't know if this triggers with captains, generals, family members alike or not.
    Oh and also has the drawback that you cannot specify if the assaulted residence is actually the settlement in the region or some fort in the countryside.

  14. #14

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

    the above script is just one script for one faction,the hole script has 30 factions with their capitals(like above script) as garrisson script.

  15. #15

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

    apparently there is also something weird with the create_unit command, like it works only once and never after, so you might want to use the console command version, gsthoed knows more about this.

  16. #16

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

    Quote Originally Posted by Melooo182 View Post
    apparently there is also something weird with the create_unit command, like it works only once and never after, so you might want to use the console command version, gsthoed knows more about this.
    Withwnar knows even better. Here is a relevant post

  17. #17

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

    Quote Originally Posted by Melooo182 View Post
    apparently there is also something weird with the create_unit command, like it works only once and never after, so you might want to use the console command version, gsthoed knows more about this.
    strange i never noticed this one,have too look close in mine campaign then,thanks for this information

  18. #18

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

    thank you i will use this script

  19. #19

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

    have too relook the script then.

  20. #20
    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)

    (I had already written this when I saw your post, gsthoed. I'll respond at the end.)

    Quote Originally Posted by Withwnar View Post
    Either way there is another issue: if norway-owned Trondhelm is under siege when somebody lays siege to any other norway settlement/fort then this monitor will execute again, adding more units to Trondhelm.
    By "either way" I meant both gsthoed's and my solutions, in case that wasn't clear. Furthermore, the original monitor_conditions script (post 29) has a flaw in that every time the siege is lifted and reapplied the garrison will spawn.

    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.

    By using that, gsthoed's idea of Transgression and some other concepts - including some from this thread - I believe that this result solves all issues and does so in a very efficient way...

    Code:
    declare_counter gs_turns_egypt_Imladris
    declare_counter gs_turns_egypt_Mithlond
    ;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_egypt_Imladris -1
      inc_counter gs_turns_egypt_Mithlond -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 Imladris
        and I_SettlementOwner Imladris egypt
        and I_IsFactionAIControlled egypt
        and I_CompareCounter gs_turns_egypt_Imladris <= 0
        console_command create_unit Imladris "Sindar Sword" 1 0 0 0
        ;other units...
        set_counter gs_turns_egypt_Imladris 5    
      end_if
    
      if I_SettlementUnderSiege Mithlond
        and I_SettlementOwner Mithlond egypt
        and I_IsFactionAIControlled egypt
        and I_CompareCounter gs_turns_egypt_Mithlond <= 0
        console_command create_unit Mithlond "Sindar Sword" 1 0 0 0
        ;other units...
        set_counter gs_turns_egypt_Mithlond 5    
      end_if
      
      ;other settlements...
    
      set_event_counter gs_create_now 0
      
    end_monitor
    One counter for each faction+settlement combination that requires a garrison script (GS). In this example only egypt gets a GS and only in two settlements: Imladris and Mithlond. The counter indicates how many turns until the next GS is available in that settlement for that faction.

    The slave monitor does the counting down of the counters. It also triggers the last monitor, as does the Transgression monitor.

    The last monitor is where the GS is applied. It tests each of the faction+settlement combinations in question: if under siege, owned by the relevant faction, under AI control (players do not get GS in this script) and enough turns have elapsed since the last GS spawn there then the units are spawned and the counter is set to 5 (5 turns before this can happen again here).

    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.

    It also means that the GS appears not only for actual sieges (immediately) but for direct assaults (artillery or spy-opened-gate situations) - things that do not always work otherwise (as reported here). This is thanks to Transgression because the TC_INSTIGATE_SIEGE transgression fires when the settlement is initially acted upon by an enemy, prior to the "maintain siege" or "assault" actions being performed.

    ~~~

    a) About how many times per turn this transgression can happen: I 've never thought of it. I had starting using this event for a differenet type of garrison reinforcents. I'll give it try anyway!
    b) Even when this while loop is "on", I expect lag will be less than the original script that had two monitor_conditions.
    c) I put the I_SettlementOwner "inside" the monitor, because we need to avoid reinforcing the garrison if -when the while loop exits- Trondheim is under control of the slave faction or had been gifted to other faction!
    a) It worked fine with quick test on two settlements in the same turn. I expect that this is not an issue. I might have gotten my wires seriously crossed on that one - it was long ago that I read it.
    b) That's true. I forgot that it had two.
    c) Yep, understood. Very important because that loop could be running for a very long time.

    i) Is this 0.1 seconds long enough to allow the script to take effect?
    ii) Depending on the mod, CPU power etc, 0.1 seconds can be enough time for the AI to instigate two subsequent sieges against Trondheim-ownining Norway. Can this cause malfunctions in the execution of this monitor?
    For these two reasons I generally avoid using "wait" commands when I know what event/condition I expect.
    i) I don't know for sure. It was long enough for the machine that I tested it on which is getting old now.
    ii) This is the big question...

    I share your concerns with wait and campaign_wait - they make me nervous. While loops too because they have an implicit 'wait' built in (1/20th of a second).

    From what I've seen, if a monitor is already being executed when something else triggers it to fire again then that second firing does not take place. I have seen this time and again but I don't know if it's always the case. I would say that a second siege upon Trondhelm occurring during the campaign_wait would be harmless. However, it might be possible that by the time that campaign_wait ends Trondhelm is no longer under norway's control - having being captured by a direct assault or even gifted away - in which case trying to spawn norway units there would ... what? ... CTD? Not sure. Your idea of having that additional ownership check after the pause would be prudent here as well.

    This also raises concerns for the campaign_wait I'm using in the above script. Hmm. 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. Not at that time anyway - the slave monitor will create it later. I might have to reconsider the use of Transgression there.

Page 2 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
  •