Results 1 to 9 of 9

Thread: Is there a limit for RandomPercentage rows or counters or why does this not work?

Hybrid View

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

    Default Is there a limit for RandomPercentage rows or counters or why does this not work?

    Hi guys,

    I'd appreciate some help. I'm trying to add some features to the search and rescure mission. I started a new thread, since this may contain some more general advice to people.

    In the basic mission the main character Rumo is captured if he is killed in a battle against an enemy general (he doesn't really die though). He may also get captured if he loses a certain percentage of bodyguard in a battle and if he is unlucky enough.

    Now I'm adding a feature where Rumo can be captured by 3 other factions without even entering battle. It describes a situation in which one or more of these factions have sent a special party to capture him. But for some reason I don't get the thing to work.

    Here's what I try to do: every now and then one of these 3 factions "decides" to try to capture Rumo and the "chase is on". After a certain number of turns, the chase is ended and goes off. The player gets a warning whenever a chase by a faction is started and ended.

    But for some reason the script (see below) does not function properly. As soon as I'm in turn 3 of the game, I get an announcement that the Goths have started a chase. And already next turn they have ended the chase, although the likelihood for these changes is not in accordance with that (as defined by the RandomPercent). Then afterwards I get messages of chase starts or ends from any of the 3 factions, in a seemingly irregular order. But something every turn, although it all should happen much less frequently.

    It is almost as if the RandomPercent would not count at all here and that any of those conditions would always be regarded as "true". Can anyone explain why this is happening? Could it be that I have used RandomPercentage too many times in the script? I'm using it currently 15 times in total in the background script. Or can there be too many counters? Now I'm using 7.

    Faction names, city names, advice threads should all be ok in other files.

    Code:
    ; Chase is on
    
    declare_counter chaseison_huns          ; 2 = new (chase just started), 1 = old (chase not new), 3 = chase about to end
    set_counter chaseison_huns 0
    
    declare_counter chaseison_roxolani
    set_counter chaseison_roxolani 0
    
    declare_counter chaseison_goths
    set_counter chaseison_goths 0
    
    ; Start chase
    
    monitor_event FactionTurnEnd huns
         and I_TurnNumber > 1
    ;     and DiplomaticStanceFromFaction sarmatians > Hostile
         and I_CompareCounter chaseison_huns = 0
         and I_CompareCounter captive = 0
         and RandomPercent < 10
              set_counter chaseison_huns 2
    end_monitor          
    
    monitor_event FactionTurnEnd roxolani
         and I_TurnNumber > 1
    ;     and DiplomaticStanceFromFaction sarmatians > Hostile
         and I_CompareCounter chaseison_roxolani = 0
         and I_CompareCounter captive = 0
         and RandomPercent < 10
              set_counter chaseison_roxolani 2
    end_monitor          
    
    monitor_event FactionTurnEnd goths
         and I_TurnNumber > 1
    ;     and DiplomaticStanceFromFaction sarmatians > Hostile
         and I_CompareCounter chaseison_goths = 0
         and I_CompareCounter captive = 0
         and RandomPercent < 10
              set_counter chaseison_goths 2
    end_monitor          
    
    ; Notify the player of change in chase status (overlapping messages possible, I think only the last in row will show)
    
    ; Start
    
    monitor_event SettlementTurnStart SettlementName Sarmatium
          if I_CompareCounter chaseison_huns = 2
          advance_advice_thread PromptThreadChaseisonhuns 1
            set_counter chaseison_huns 1
          end_if
          if I_CompareCounter chaseison_roxolani = 2
          advance_advice_thread PromptThreadChaseisonroxolani 1
            set_counter chaseison_roxolani 1
          end_if
          if I_CompareCounter chaseison_goths = 2
          advance_advice_thread PromptThreadChaseisongoths 1
            set_counter chaseison_goths 1
          end_if
    end_monitor
    
    ; End chase (two types for each faction)
    
    monitor_event FactionTurnStart huns
              
              if I_CompareCounter captive = 0
              and I_CompareCounter chaseison_huns = 1
              and RandomPercent < 5
                   set_counter chaseison_huns 3
              end_if     
              
              if I_CompareCounter captive > 2
                   set_counter chaseison_huns 3
              end_if     
    end_monitor          
    
    monitor_event FactionTurnStart roxolani
              
              if I_CompareCounter captive = 0
              and I_CompareCounter chaseison_roxolani = 1
              and RandomPercent < 5
                   set_counter chaseison_roxolani 3
              end_if     
              
              if I_CompareCounter captive > 2
                   set_counter chaseison_roxolani 3
              end_if     
    end_monitor          
    
    monitor_event FactionTurnStart goths
              
              if I_CompareCounter captive = 0
              and I_CompareCounter chaseison_goths = 1
              and RandomPercent < 5
                   set_counter chaseison_goths 3
              end_if     
              
              if I_CompareCounter captive > 2
                   set_counter chaseison_goths 3
              end_if     
    end_monitor          
    
    ; Notify player of chase change
    
    ; End
    
    monitor_event SettlementTurnStart SettlementName Sarmatium
            and I_CompareCounter chaseison_huns = 3
              advance_advice_thread PromptThreadChaseendhuns 1
            set_counter chaseison_huns 0
    end_monitor
    
    monitor_event SettlementTurnStart SettlementName Sarmatium
            and I_CompareCounter chaseison_roxolani = 3
              advance_advice_thread PromptThreadChaseendroxolani 1
            set_counter chaseison_roxolani 0
    end_monitor
    
    monitor_event SettlementTurnStart SettlementName Sarmatium
            and I_CompareCounter chaseison_goths = 3
              advance_advice_thread PromptThreadChaseendgoths 1
            set_counter chaseison_goths 0
    end_monitor

  2. #2
    HouseOfHam's Avatar Primicerius
    Join Date
    Apr 2007
    Location
    Minnesota, USA
    Posts
    3,030

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Bugs:

    You must have a condition on each monitor_event line immediately following the event id. Faction id by itself is not a valid condition, i.e. it should be "FactionType huns" rather than just "huns."

    What I've observed in the past is that when the RTW scripting engine runs into a syntax error where it expects a condition, it defaults that line to true.

    Questions:

    This may be silly, but do you declare the captive counter in your script?

    When would captive be > 2? I don't see any logic that sets it.

    Suggestions:

    Try implementing it for just 1 faction first.
    RTR website/SVN admin

    - Settlement coordinate locator -for RTW/M2TW
    - EDB Validator v1.2.8 (Oct 16, 2012) - for RTW/M2TW
    - RTW scripting tutorials
    - n-turns per year script generator

  3. #3

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Indeed, the FactionType is missing in all those monitors, how could I miss it! Well, I thought that I have become blind to some mistake and thank you very much for pointing it out!!!

    I won't have a chance to test it immediately, but will report back tomorrow.

    Captive counter is declared ok and these are the possible values:

    0 = free, 1 = just rescued, 2 = just captured by general, 3 = captured by general, 4 = captured into a city

    That condition is there since there is no point to have a chase on when he is already captured.

  4. #4
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Run it through my script editor, it would have caught the missing condition bit.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  5. #5

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Quote Originally Posted by Squid View Post
    Run it through my script editor, it would have caught the missing condition bit.
    Thanks, I actually did run it through the editor (v 1.3), but it did not warn about anything. That is why I was so puzzled with this.

    Now I've tested it and it seems to work ok when I add FactionType to the three FactionTurnStarts and three FactionTurnEnds.

    I'm just still a bit puzzled since I got one time an actual advisor message (when starting a battle), although those should not appear (suspend_unscripted_advice true). If I remove this piece of code (visible in the first message), the rest of the script works without any advisor messages. I wonder if this was just some weird coincidence, or if there is still some bug in the code above...

  6. #6
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Do you mean ATVTW v1.3? If so that is horribly outdated and doesn't catch many many bugs, but it doesn't check scripts the way you want, it just looks at trait and ancillary related lines of the script. I was referring to TW Script Editor, which checks scripts in significantly more detail, though there's still a lot of work to do.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  7. #7

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Quote Originally Posted by Squid View Post
    Do you mean ATVTW v1.3?
    My mistake. I have downloaded and intalled at some point "PatricianS script validator v 1.3". Now I installed yours, and it seems great, thanks!
    After having added those FactionTypes, it only gives errors stating that some of the settlement names I'm using are invalid. This is strange as those are written in exactly same fashion in data\text\barbarian_invasion_regions_and_settlement_names.txt. Could it be that I'm just missing quotes (")? I thought that those are not needed for settlement names in scripts. Am using BI 1.6.

  8. #8
    Squid's Avatar Opifex
    Patrician Artifex Technical Staff

    Join Date
    Feb 2007
    Location
    Frozen waste lands of the north
    Posts
    17,751
    Blog Entries
    3

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    Settlement names are known issue with my programs as there's disagreement about which names are used internal or external. Currently I compare to only internal.
    Under the patronage of Roman_Man#3, Patron of Ishan
    Click for my tools and tutorials
    "Two things are infinite: the universe and human stupidity; and I'm not sure about the universe." -----Albert Einstein

  9. #9

    Default Re: Is there a limit for RandomPercentage rows or counters or why does this not work?

    OK, that explains it. I'm using external.

Posting Permissions

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