Results 1 to 19 of 19

Thread: increasing counters

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default increasing counters

    I created a trait that has 6 levels!

    If a general has this trait and is inside a settlement I want count it up depending on what level ithe trait has! The trait will be removed after this part works... hopefully
    The game recognises the character having the trait beeing inside that settlement!
    The problem seems to be something with the blue part!

    If I remove that blue stuff the fow is toggled!
    "toggle_fow" is just beeing used so I can see if it works... it does not!
    It seems not to recognise the counter or its number... perhaps there is nothing added...
    I do not even know how I can see the counters number ingame!

    What did I do wrong?
    I did red some tutorials... perhaps not good enough


    Code:
    declare_counter mycounter
    set_counter mycounter 0
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram    
        
        and Trait new_trait = 2
        
        inc_counter mycounter 1          
    
    terminate_monitor
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram    
        
        and Trait new_trait = 3
        
        inc_counter mycounter 2        
    
    terminate_monitor
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram    
        
        and Trait new_trait = 4
        
        inc_counter mycounter 3        
    
    terminate_monitor
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram    
        
        and Trait new_trait = 5
        
        inc_counter mycounter 4        
    
    terminate_monitor
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram    
        
        and Trait new_trait = 6
        
        inc_counter mycounter 5        
    
    terminate_monitor
    end_monitor
    
    monitor_event SettlementTurnStart SettlementName Mt-Gram
        
        if I_CompareCounter mycounter > 0
            console_command toggle_fow
        end_if        
    
    terminate_monitor
    end_monitor
    Edit: If I change the green "inc_counter" to "set_counter" it does not work either... My tests have been all made with the last trait level!
    Last edited by Lazy; January 15, 2012 at 06:25 AM.
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

  2. #2

    Default Re: increasing counters

    Do you need to set the mycounter to 0 after declaring it? I thought when the counter is declared it already starts at 0.

  3. #3
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default Re: increasing counters

    Yeah you are right! I red that out a few minutes ago... but it makes no difference I think as both numbers are eual... I cannot check this here... but I remember that in the "previous" version that was missing and I had the same effect... NONE =>
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

  4. #4

    Default Re: increasing counters

    Try using a definite number for the I_CompareCounter.
    For example I_CompareCounter = 6
    Also there is no need for the 'end_if'

  5. #5
    Emperor of Hell's Avatar SPA-NED 1-5
    Join Date
    Jul 2011
    Location
    Netherlands
    Posts
    5,747

    Default Re: increasing counters

    No you do need end_if
    The problem is the set_counter 0 at the top BTW. that will always, at any moment set the counter to 0, so that's why your script doesn't work. just remove it
    Sorry for my bad spelling/grammar btw, using an itouch is kinda hard xD

  6. #6

    Default Re: increasing counters

    Quote Originally Posted by killersmurf View Post
    No you do need end_if
    The problem is the set_counter 0 at the top BTW. that will always, at any moment set the counter to 0, so that's why your script doesn't work. just remove it
    Sorry for my bad spelling/grammar btw, using an itouch is kinda hard xD
    Just out of curiosity, why do you need it? Why not just 'end'?

  7. #7

  8. #8
    Byg's Avatar Read The Manual
    Patrician

    Join Date
    Nov 2005
    Posts
    4,569

    Default Re: increasing counters

    There is no such condition as CharacterTurnEndInSettlement afaik.

    The set counter at the start is not wrong. Surely this will just set the counter to 0 when the campaign first runs and then it will not trigger again. However it is unnecessary.
    Last edited by Byg; January 15, 2012 at 03:13 PM.

    NEW BGR V 20150324! . . . . . . . .. . . .BGRIV_E

  9. #9
    Emperor of Hell's Avatar SPA-NED 1-5
    Join Date
    Jul 2011
    Location
    Netherlands
    Posts
    5,747

    Default Re: increasing counters

    CharacterTurnEndInSettlement is in the docudemons.

  10. #10
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default Re: increasing counters

    This conditions is weird... I found it in some place... but I caues only errors in the following stuff... It never worked!
    Checking the settlement in the following line works better/easier!

    However... thanks for the help!
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

  11. #11
    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: increasing counters

    I'm pretty sure that the order things are evaluated in are: PreFaction -> Faction -> Settlement -> Character, so you're character counter changes would have no effect on the settlement event.
    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

  12. #12
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default Re: increasing counters

    Quote Originally Posted by Squid View Post
    I'm pretty sure that the order things are evaluated in are: PreFaction -> Faction -> Settlement -> Character, so you're character counter changes would have no effect on the settlement event.
    That could be it!
    Thank for telling there is an order...
    This script made me so angry I left my house because I was so angry...
    Perhaps saved my keyboard from a beatup...
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

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

    Default Re: increasing counters

    Quote Originally Posted by Squid View Post
    I'm pretty sure that the order things are evaluated in are: PreFaction -> Faction -> Settlement -> Character, so you're character counter changes would have no effect on the settlement event.
    The order is PreFaction -> Character -> Settlement -> Faction

    CharacterTurnEndInSettlement should fire at the end of the turn and SettlementTurnStart will fire at the start of the following turn. For the player this is all during the same turn end (turn end, other factions, turn start) but for the AI you won't see it until the turn after.

    Maybe CharacterTurnEndInSettlement doesn't work. You could try this instead...

    Code:
    monitor_event CharacterTurnEnd EndedInSettlement
      and SettlementName Mt-Gram    
      and Trait new_trait = 2
        
        inc_counter mycounter 1          
    
    terminate_monitor
    end_monitor
    I do not even know how I can see the counters number ingame!
    In game is not possible. There is the "log_counter" command that will write a counter's value to the log. It doesn't work for event counters, only 'real' counters.
    Last edited by Withwnar; January 17, 2012 at 09:59 AM.

  14. #14
    /|\/|\/|\/|\/|\/|\/
    Join Date
    Jun 2005
    Posts
    10,770

    Default Re: increasing counters

    Use trace and counter changes are logged anyway.

    And the order is PFTS CTS STS FTS.

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

    Default Re: increasing counters

    Quote Originally Posted by Taiji View Post
    And the order is PFTS CTS STS FTS.
    So it is. (Post edited.)

  16. #16

    Default Re: increasing counters

    Uhm,

    Code:
    monitor_event SettlementTurnStart SettlementName Mt-Gram
        
        if I_CompareCounter mycounter > 0
            console_command toggle_fow
        end_if        
    
    terminate_monitor
    end_monitor
    This monitor terminates the moment your campaign starts ( during the turn start procedures of turn 0 )

    CharacterTurnEndInSettlement sounds like something that happens during the end of the turn 0 procedures...

    Aka your test monitor terminates before any of your other monitors trigger, remove the terminate monitor and see or it does anything.

  17. #17
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default Re: increasing counters

    I hit my head against the keayboard a few times...
    suddenly it worked like this:

    Code:
    declare_counter my_event0
    declare_counter my_event1
    declare_counter my_event2
    declare_counter my_event3
    declare_counter my_event4
    declare_counter my_counter
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        and I_EventCounter my_event0 1
        and Trait my_trait = 2
            inc_counter my_counter 1
        
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        and I_EventCounter my_event0 1
        and Trait my_trait = 3
            inc_counter my_counter 2
        
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        and I_EventCounter my_event0 1
        and Trait my_trait = 4
            inc_counter my_counter 3
        
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        and I_EventCounter my_event0 1
        and Trait my_trait = 5
            inc_counter my_counter 4
        
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        and I_EventCounter my_event0 1
        and Trait my_trait = 6
            inc_counter my_counter 5
            
    end_monitor
    
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram
    
        and Trait my_trait = 6
        set_event_counter my_event0 1
    
    end_monitor
    
    monitor_conditions I_EventCounter my_event0 1
        if I_CompareCounter my_counter > 4
        set_event_counter my_event1 1
        end_if
    
        if I_CompareCounter my_counter > 9
        set_event_counter my_event2 1
        end_if
    
        if I_CompareCounter my_counter > 14
        set_event_counter my_event3 1
        end_if
    
        if I_CompareCounter my_counter > 19
        set_event_counter my_event4 1
        end_if
    end_monitor


    The order problem was solved by simply changing the order in the campaign_script.txt
    "terminate_editor"... I cannot remember putting it there... after I removed it stuff got easier!

    I will add a factionislocal or something to this "monitor_condition "later to prevent it from firing so often... even if it does not really matter...


    But I have a new question... I want to decrease the monitor_events to decrease turn time but
    the "if" thing does not work here:

    Code:
    monitor_event CharacterTurnEndInSettlement SettlementName Mt-Gram 
    
        if I_EventCounter my_event0 1
          and Trait my_trait = 2
          inc_counter my_counter 1
        end_if
    
       if I_EventCounter my_event0 1
           and Trait my_trait = 3
           inc_counter my_counter 2
         end_if
    
    end_monitor
    The log file tells me that I cannot check traits... one of the posted conditions is "<>"
    There should be written something between the brickets...
    I will take some time until I find out why this is happening... perhaps someone knows it?

    Could the reason be that in desc_character_traits stuff is beeing changed after (?!) the campaign_script?
    Last edited by Squid; January 18, 2012 at 10:55 AM. Reason: Totally unnecessary image removed
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

  18. #18

    Default Re: increasing counters

    You can't, the "my_trait" can't be used in an if statement as it requires a condition export from an event.

    You could change the monitor_conditions, by a monitor_event FactionTurnStart that way it will only run 1 time per turn. Also monitor_conditions tend to slow the game down if you use too many.
    Last edited by ilmrik; January 17, 2012 at 10:44 AM.

  19. #19
    Lazy's Avatar Biarchus
    Join Date
    Jul 2011
    Location
    Aachen
    Posts
    661

    Default Re: increasing counters

    Thank you!
    I will try that out first!
    Quote Originally Posted by SirWarts View Post
    ...the woman trampled didn't look impenetrable. So they ran through her.

Posting Permissions

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