Page 1 of 3 123 LastLast
Results 1 to 20 of 43

Thread: Campaign script won't run after adding simple entry to it, no error in logs

Hybrid View

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

    Default Campaign script won't run after adding simple entry to it, no error in logs

    Another really strange one.
    Again, no error in the logs at all.

    This exists for every faction:

    Code:
    monitor_event PreFactionTurnStart FactionType spain
     and IsFactionAIControlled
    
    
     increment_kings_purse spain 5000 
     
    terminate_monitor
    end_monitor

    Very simple stuff right?

    I added three new factions, and as soon as I add this:
    Code:
    monitor_event PreFactionTurnStart FactionType ooom
     and IsFactionAIControlled
    
    
     increment_kings_purse ooom 5000 
     
    terminate_monitor
    end_monitor
    or for any of the other two new factions, the campaign script simply doesn't run anymore.
    No errors, no CTD. Just doesn't run.

    HOWEVER... if I simply change that spain (both of them) in the original entry to any of the new factions, it works.
    Great.

    Then when I try to copy and paste in the original entry for spain, it stops working again.
    What am I missing?

    Using notepad++

  2. #2

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    On a gut feeling I just made the desired additions using regular notepad, and it works.
    What gives?

    Anyone know notepad++ well enough to know if there's some setting creating an issue all of a sudden?

    Or something I can use instead of notepad++ that won't create an issue with the campaign_script?

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    I'd be looking at this: http://www.twcenter.net/forums/showt...2#post13984052

    By the way, you could do that all in one monitor...

    Code:
    monitor_event PreFactionTurnStart
    
      if I_IsFactionAIControlled spain
        increment_kings_purse spain 5000
      end_if
      if I_IsFactionAIControlled ooom
        increment_kings_purse ooom 5000
      end_if
      ;other factions...
     
    terminate_monitor
    end_monitor

  4. #4

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Perfect. Bookmarked!

    Quote Originally Posted by Withwnar View Post
    By the way, you could do that all in one monitor...
    Is it better to?
    It's what I inherited...

    Thanks again!!

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Quote Originally Posted by euskingc View Post
    Is it better to?
    With your script the monitor of each player faction* will never get through the "and IsFactionAIControlled" condition --> will never reach the terminate_monitor --> will never die. They will fire every turn for the whole campaign, checking (and failing) those conditions. Not that they will do anything, and probably won't add any noticeable lag. So effectively harmless but in general it's good practice to avoid that kind of thing - never-terminating useless monitors - if possible.

    * Only one faction so only one monitor, but will be multiple - maybe even most/all - in hotseat.

  6. #6

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Just to be sure I understand this 100% correctly, by each player faction you mean each human-controlled faction?
    Meaning that if this script exists for all factions as it is right now, it will terminate for all of them, EXCEPT the human controlled one(s)?


    I.e. if I'm playing as spain, all the other monitors will run and terminate but the spain one will keep failing the condition and keep running every turn forever.



    If we're on the same page, then yeah, I really probably should clean it up. I can think of a handful of other places I might want to check too..


    Thanks boss

  7. #7

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    For example...
    Code:
    monitor_event FactionTurnStart FactionReligion catholic
     and not IsFactionAIControlled
     historic_event gamestart_evil
    terminate_monitor
    end_monitor


    Looking at this historic event... does that mean that this will fire (and fail) every single turn for every catholic AI faction for the whole game?

    And would this:


    Code:
    monitor_event FactionTurnStart
    
    
      if not I_IsFactionAIControlled england
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled france
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled hre
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled ooom
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled portugal
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled spain
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled umbar
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled venice
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled khand
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled sicily
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled milan
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled scotland
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled turks
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled moors
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled saxons
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled egypt
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled mongols
     historic_event gamestart_good
      end_if
     
    terminate_monitor
    end_monitor

    be preferable to this:


    Code:
    monitor_event FactionTurnStart not FactionReligion catholic
     and not IsFactionAIControlled
     historic_event gamestart_good
    terminate_monitor
    end_monitor
    
    
    monitor_event FactionTurnStart FactionReligion catholic
     and not IsFactionAIControlled
     historic_event gamestart_evil
    terminate_monitor
    end_monitor

    And if it is better, is there a way to run the historic_event based off of religion rather than faction as I've done?
    Last edited by euskingc; March 12, 2016 at 08:39 AM.

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Quote Originally Posted by euskingc View Post
    Just to be sure I understand this 100% correctly, by each player faction you mean each human-controlled faction?
    Meaning that if this script exists for all factions as it is right now, it will terminate for all of them, EXCEPT the human controlled one(s)?


    I.e. if I'm playing as spain, all the other monitors will run and terminate but the spain one will keep failing the condition and keep running every turn forever.
    Yes, exactly.

    Quote Originally Posted by euskingc View Post
    For example...
    Code:
    monitor_event FactionTurnStart FactionReligion catholic
     and not IsFactionAIControlled
     historic_event gamestart_evil
    terminate_monitor
    end_monitor
    Looking at this historic event... does that mean that this will fire (and fail) every single turn for every catholic AI faction for the whole game?
    Yes. Actually, it will fire at the start of every faction's turn for the whole game. First checking if they're catholic and then, for those that pass that test, checking if they're not AI. I'm sure that such checks are very fast but still... you could easily end up with hundreds of useless monitors; the more there are the higher the chances of lag being noticeable. monitor_conditions definitely does cause lag and it doesn't take many of them for it to be noticeable (not that you're using that here, just sayin').

    By the way, note that my script says "if I_IsFactionAIControlled". Only some condition types can be used with "if". Most only work as direct conditions on the monitor_events.

    As for your example I would do this (for TATW)...

    Code:
    monitor_event FactionTurnStart
    
      historic_event gamestart_evil factions { england, hre, portugal, france, spain, venice, }
      historic_event gamestart_good factions { sicily, turks, milan, egypt, mongols, scotland, moors, }
    
    terminate_monitor
    end_monitor
    ...and take out the other monitor that shows the gamestart_good message.

    Pretty sure that religions can't be used in historic_event's "factions" list, otherwise you could just say "historic_event gamestart_evil factions { catholic, }" for the evil one.

    All evil players will see the "evil" message and all good will see "good". Whereas, by the way, the original script...

    Code:
    monitor_event FactionTurnStart not FactionReligion catholic
    	and not IsFactionAIControlled
    	historic_event gamestart_good
    terminate_monitor
    end_monitor
    
    monitor_event FactionTurnStart FactionReligion catholic
    	and not IsFactionAIControlled
    	historic_event gamestart_evil
    terminate_monitor
    end_monitor
    ...has an issue in hotseat: if there are both catholic and non-catholic players then all factions will see both messages (by turn 2 if not both in turn 1).

    EDIT: missed your edit there...

    Code:
    monitor_event FactionTurnStart
    
    
      if not I_IsFactionAIControlled england
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled france
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled hre
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled ooom
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled portugal
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled spain
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled umbar
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled venice
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled khand
     historic_event gamestart_evil
      end_if
      if not I_IsFactionAIControlled sicily
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled milan
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled scotland
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled turks
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled moors
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled saxons
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled egypt
     historic_event gamestart_good
      end_if
      if not I_IsFactionAIControlled mongols
     historic_event gamestart_good
      end_if
     
    terminate_monitor
    end_monitor
    No. In hotseat that would be sending out multiple welcome messages. e.g. If every faction is a player in a hotseat then every one of those IFs will be true.

    NOTE: my script was for vanilla TATW. You have some extra factions in yours.
    Last edited by Withwnar; March 12, 2016 at 09:13 AM.

  9. #9

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Code:
    monitor_event FactionTurnStart
    
    
      historic_event gamestart_evil factions { england, hre, portugal, france, spain, venice, }
      historic_event gamestart_good factions { sicily, turks, milan, egypt, mongols, scotland, moors, }
    
    
    terminate_monitor
    end_monitor
    That's absolutely beautiful.

    Pretty sure that religions can't be used in historic_event's "factions" list, otherwise you could just say "historic_event gamestart_evil factions { catholic, }" for the evil one.
    By the way, note that my script says "if I_IsFactionAIControlled". Only some condition types can be used with "if".
    I tried several different ways to get it to go... "if"s within "if"s, combinations of "if"s and "and"s (not that I was sure that escape the problem even if it did work)... as well as tried several different conditions. I couldn't get any of them to go (except for what I finally posted), but what do I know yet.

    Is there a list somewhere of what conditions can be used with "if"?

    Whereas, by the way, the original script...
    ... has an issue in hotseat:
    I was wondering that when I was rewriting it, and if that might now be avoided the way I had put it...

    No. In hotseat that would be sending out multiple welcome messages. e.g. If every faction is a player in a hotseat then every one of those IFs will be true.
    Right haha. That's even worse.

    Out of purely academic interest, would this alleviate that problem,

    Code:
      if not I_IsFactionAIControlled england
     historic_event gamestart_evil factions { england, }
      end_if
      if not I_IsFactionAIControlled france
     historic_event gamestart_evil factions { france, }
      end_if
      if not I_IsFactionAIControlled hre
     historic_event gamestart_evil factions { hre, }
      end_if
    etc.
    EDIT: (although I do recognize it's totally redundant)

    and would there be another way to limit the messages to the appropriate factions, by .. I don't know, changing the event moitored or adding a condition or some such thing?

    Practically speaking I've of course already decided to adopt your model... I was actually hoping for something more concise like that.
    So thanks.
    =)
    Last edited by euskingc; March 12, 2016 at 09:41 AM.

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Is there a list somewhere of what conditions can be used with "if"?
    Any condition that has no "trigger requirements" in the Docudemons. That includes all I_xxx ones, RandomPercent, and some others. Very few I'm afraid.

    (although I do recognize it's totally redundant)
    It is, yes. No point in doing that.

    and would there be another way to limit the messages to the appropriate factions
    Conditions and events can only affect IF and WHEN it's seen, not WHO by. historic_events...factions{} is the only way. I wish there was another way because the other method of sending historic event messages (add_events...historic) has a nifty "location" parameter that adds a zoom button to the scroll. Unfortunately that method has no such factions{} control, so if you want a zoom button then every player is going to see that message*.

    * In hotseat. Of course you can say something like...

    Code:
    if not I_IsFactionAIControlled england ;(or, alternatively: I_IsLocalFaction england)
      ;show historic event message by either method
    end_if
    ...which is fine for non-hotseat because there's only one player. And the message is only shown at all in that example if the player is england. Thus: only an england player will ever see that message. Hotseat is the killer. There comes a time when a scripter can do nothing but admit defeat, that things won't work exactly as planned in hotseat. TATW was not designed for hotseat and I can fully understand why.

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Just to clarify this...

    Quote Originally Posted by Me
    Only some condition types can be used with "if". Most only work as direct conditions on the monitor_events.
    More correctly: most have so-called "trigger requirements", meaning they require a context* that is provided by an event. Therefore: most conditions can only be used as event conditions. Which does mean monitor_events but also events from WhenToTest in triggers for traits, ancs, guilds & faction standings.

    * Such as character_record, faction, and so on. Things that events export.

  12. #12

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Sigh.


    All right =)


    Well, at least now I have a clearer understanding of what can and cannot be done, and how.
    It'll come in handy the next few days.

  13. #13

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    That's even clearer.


    Not sure if I should start a new thread for it but since we're on the topic of the workings of the campaign_script I'll ask...


    I'm looking at the garrison script for TATW and it's all completely clear except for one part I just can't quite figure out what it's doing. I'm sure you're familiar with it but here it is basically, for one city:
    Spoiler Alert, click show to read: 

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

    First off there's two comments I just don't quite believe: "Ensures AI Owned Settlements Are Local On Turn Start and Turn End" and "Ensures Player Owned Settlements Are Local On Turn Start and Turn End"
    To me what I'm seeing is it's simply preventing human factions from receiving the benefits of the garrison script. Please correct me if I'm wrong.
    Do they not simply mean "verifies whether settlements are Local on turn start and turn end"?



    The part I just can't wrap my head around is this:


    Code:
     while I_CompareCounter PT < 1
       create_unit Belfalas, Gondor Spearmen Mercs, num 1, exp 0, arm 0, wep 0
       create_unit Belfalas, Gondor Archers Mercs, num 2, exp 0, arm 0, wep 0
       create_unit Belfalas, Gondor Infantry Mercs, num 1, exp 0, arm 0, wep 0
       create_unit Belfalas, Dismounted Kofm Mercs, num 2, exp 0, arm 0, wep 0
      inc_counter PT 1

    looking up above, PT is set to zero any time:
    1)just before the human turn starts
    2)anytime the player opens the siege scroll (not sure if this means every time or only at the initial besieging)
    3)anytime an AI turn is about to start


    And since it's almost always 0, and the only place it ever increases is if it is 0 and there's a siege.
    So what I'm seeing is, assuming all other conditions are in play, while PT is less than 1 (essentially 0 since nothing ever lowers it below that), it create these units, and increases PT by 1.
    But then it isn't zero anymore. So what happens to the units? I'd wonder if they'd just create then magically uncreate themselves, in the same instant, but that isn't what we observe in the game.


    It isn't clear to me what the comment "Set Max Unit Spawn Limit" means either... and how that relates to PT.


    It doesn't seem that they ever uncreate themselves after the siege ends, or anything else happens to them in game.
    So why use 'while' to create the units and why use this PT at all?

  14. #14

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    It doesn't seem like the Belfalas_Defense counter is being used for anything either.
    If I had to guess... I'd guess the script was originally written quite differently, and then somebody modified it so that it would act differently... and rather than completely rewriting it just made ad-hoc changes that worked but left some redundancies?

    With the Belfalas_Siege counter, more units shouldn't spawn unless five turns have passed.

  15. #15

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Spoiler Alert, click show to read: 

    Code:
    ;Unique Counters per Settlement
    declare_counter Sart_Siege
    
    
    declare_counter Sart_Local
    
    
    ;===============================================================
    ;============ Ensures Player Owned Settlements =================
    ;========== Are Local On Turn Start and Turn End ===============
    ;===============================================================
    
    
    monitor_event SettlementTurnStart SettlementIsLocal
     and SettlementName Sart
     set_counter Sart_Local 1
    end_monitor
    
    
    ;############################################################
    monitor_event SettlementTurnEnd SettlementIsLocal
     and SettlementName Sart
     set_counter Sart_Local 1
    end_monitor
    
    
    ;===============================================================
    ;============== Ensures AI Owned Settlements ===================
    ;========== Are Local On Turn Start and Turn End ===============
    ;===============================================================
    
    
    monitor_event SettlementTurnStart not SettlementIsLocal
     and SettlementName Sart
     set_counter Sart_Local 0
    end_monitor
    
    
    ;#############################################################
    monitor_event SettlementTurnEnd not SettlementIsLocal
     and SettlementName Sart
     set_counter Sart_Local 0
    end_monitor
    
    
    ;===============================================================
    ;================= Decrease Siege Counter ======================
    ;========== Ensures Additional Spawns Don't Spawn ==============
    ;===============================================================
    
    
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    inc_counter Sart_Siege -1
    end_monitor
    
    
    ;=======================================================
    ;=================== Spawn Units =======================
    ;=============== For Player vs AI ONLY==================
    ;=======================================================
    
    
    monitor_event ButtonPressed ButtonPressed siege_maintain_button
    
    
     if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
     and I_CompareCounter Sart_Siege < 1
     and I_CompareCounter Sart_Local = 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
      set_counter Sart_Siege 5
     end_if
    end_monitor
    
    
    ;=======================================================
    ;=================== Spawn Units2 =======================
    ;=======================================================
    
    
    monitor_event ButtonPressed ButtonPressed siege_assault_button
    
    
    if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
     and I_CompareCounter Sart_Siege < 1
     and I_CompareCounter Sart_Local = 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
      set_counter Sart_Siege 5
    end_if
    
    
    end_monitor
    
    
    ;=======================================================
    ;=================== Spawn Units =======================
    ;================ For AI vs AI ONLY=====================
    ;=======================================================
    
    
    monitor_event FactionTurnStart IsFactionAIControlled
    
    
    if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
     and I_CompareCounter Sart_Siege < 1
     and I_CompareCounter Sart_Local = 0
       create_unit Sart, Snaga Band, num 3, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 3, exp 0, arm 0, wep 0
      set_counter Sart_Siege 2
    end_if
    
    
    end_monitor


    I just added this in for a new settlement, and it seems to work exactly the same as the originals do... is there some hidden difference I'm not seeing that means I should follow the original paradigm?

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    If I had to guess... I'd guess the script was originally written quite differently, and then somebody modified it so that it would act differently... and rather than completely rewriting it just made ad-hoc changes that worked but left some redundancies?
    That was my guess too. There is much unused or redundant logic in that script.

    Your script seems fine except for this (which the original has too)...
    Code:
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    inc_counter Sart_Siege -1
    end_monitor
    That is supposed to be counting how many turns since the most recent GS was spawned here. The name suggests it is counting how long it has been under siege for, but that's just a cosmetic code naming thing. The problem is hotseat: there are multiple players so in one turn that monitor is going to fire many times, likely taking the counter down to below 1, indicating that this settlement is ready for another GS after that turn end. If every faction is a player then fine: GS doesn't apply to faction settlements anyway. But if some are AI then that script is broken. A better way would be to change that into a "FactionType slave" condition; it will now only fire once per turn end, and every turn end because slave can never die.

    The script can also be simplified further. Because each monitor that does the spawning is checking the settlement ownership, it could also check if that owner faction is a player. This completely removes the need for the xxx_Local counter and the four monitors that set it.

    Code:
    if I_SettlementUnderSiege Sart
      and I_SettlementOwner Sart = ooom
      and I_IsFactionAIControlled ooom
      and I_CompareCounter Sart_Siege < 1
      and I_CompareCounter Sart_Local = 0
    EDIT: while on the subject, this is worth a read: http://www.twcenter.net/forums/showt...1#post14076281 It carries on for a few more posts after that, refined a bit. By the looks of it it doesn't provide AI-vs-AI GS, but that can be added. I'm using this approach in a TATW submod and have had no issues with it yet.
    Last edited by Withwnar; March 12, 2016 at 11:20 PM.

  17. #17

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    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.

    I haven't implemented your recommendations yet but...


    Code:
    monitor_event PreFactionTurnStart not IsFactionAIControlled
    inc_counter Sart_Siege -1
     if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
    inc_counter Sart_Siege 1
     end_if
    end_monitor
    
    
    ....
    ...
    
    
    
    monitor_event ButtonPressed ButtonPressed siege_maintain_button
    
    
    
     if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
     and I_CompareCounter Sart_Siege < 1
     and I_CompareCounter Sart_Local = 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 1, exp 0, arm 0, wep 0
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
      set_counter Sart_Siege 4
     end_if
    end_monitor

    This seems to work, or any combination of math you find fitting (if for example you don't want the GS to reset to four turns AFTER the end of the siege, but rather some compromise in between, you could make the siege counter changes, say, -3, 2, and 12... taking into account the maximum possible length of a siege, and I don't know what that is. Another way might be to just ensure that while a siege is ongoing the counter never goes below that critical number where the spawn occurs, but at best you still have to wait a turn after a long siege before you get the next GS).


    I suppose if you wanted to get really fancy you could make it in stages, too, no? Like, if we follow the logic that after a year a settlement is more or less recovered, but after six months it's half recovered, after nine months it's mostly recovered... Depending on what you wanted a second counter could be used (to avoid spawning during siegetime and yet still not have to wait the full cooldown time from the end of the siege for it to reset completely, depending on the math), or far more simply (with your recommendations as well):


    Code:
    monitor_event PreFactionTurnStart FactionType slave
    inc_counter Sart_Siege -1
     if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
    inc_counter Sart_Siege 1
     end_if
    end_monitor
    
    
    monitor_event ButtonPressed ButtonPressed siege_maintain_button
     and I_SettlementOwner Sart = ooom
     and I_IsFactionAIControlled ooom
    
    
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 3
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
     end_if
     
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 2
       create_unit Sart, Snaga Skirmishers, num 2, exp 0, arm 0, wep 0
     end_if
    
    
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 1
       create_unit Sart, Snaga Archers, num 2, exp 0, arm 0, wep 0
     end_if
    
    
     if I_SettlementUnderSiege Sart
      set_counter Sart_Siege 4
     end_if
     
    end_monitor
    
    
    
    monitor_event ButtonPressed ButtonPressed siege_assault_button
     and I_SettlementOwner Sart = ooom
     and I_IsFactionAIControlled ooom
    
    
    
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 3
       create_unit Sart, Snaga Band, num 2, exp 0, arm 0, wep 0
      set_counter Sart_Siege 4
     end_if
     
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 2
       create_unit Sart, Snaga Skirmishers, num 2, exp 0, arm 0, wep 0
     end_if
    
    
     if I_SettlementUnderSiege Sart
     and I_CompareCounter Sart_Siege < 1
       create_unit Sart, Snaga Archers, num 2, exp 0, arm 0, wep 0
     end_if
    
    
     if I_SettlementUnderSiege Sart
      set_counter Sart_Siege 4
     end_if
    
    
    end_monitor

    Maybe you guys already discussed this. I haven't actually finished reading your link yet, just got sidetracked with testing this idea as soon as I saw what you said.



    A better way would be to change that into a "FactionType slave" condition
    The script can also be simplified further. Because each monitor that does the spawning is checking the settlement ownership, it could also check if that owner faction is a player. This completely removes the need for the xxx_Local counter and the four monitors that set it.

    Beautiful =)



    Alright. Back to the reading material =)
    Last edited by euskingc; March 13, 2016 at 09:07 AM.

  18. #18

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    I'll check out the link!
    Last edited by euskingc; March 13, 2016 at 09:31 AM.

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

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    Seems fair enough. I don't have a problem with GS re-happening during a siege because a siege depletes soldiers. The partial recovery thing looks good.

    Code:
    monitor_event PreFactionTurnStart FactionType slave
    inc_counter Sart_Siege -1
     if I_SettlementUnderSiege Sart
     and I_SettlementOwner Sart = ooom
    inc_counter Sart_Siege 1
     end_if
    end_monitor
    Not sure about that red line. Seems to me that the counter should stop if it's under siege, regardless of who owns it.

  20. #20

    Default Re: Campaign script won't run after adding simple entry to it, no error in logs

    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.

    I like it. It cuts the actual meat of the script from 3 to 2 monitors also, in my case.
    What would happen if you removed the line campaign_wait 0.1?
    I mean, what is its purpose?

Page 1 of 3 123 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
  •