Results 1 to 13 of 13

Thread: event counter not working?

  1. #1
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default event counter not working?

    Hi. I'm trying to make a script that allows you to recruit a unit only if you have 1/3 of a certain region. I'm using 12 TPY.

    I can track the settlement ownerships and stuff but I'm having problems with the event_counter behaving oddily.

    I have this in a monitor firing at FactionTurnStart:

    if I_CompareCounter north_counter_stark > 5
    set_event_counter north_counter_stark 1
    console_command toggle_fow

    end_if
    and it works, toggling the fow on and off all turns.

    There is no other set_event_counter north_counter_stark in the entire script.

    But if I remove the console_command and add this at the end of the campaign_script:

    monitor_event FactionTurnStart FactionIsLocal
    and I_EventCounter north_counter_stark = 1
    console_command toggle_fow

    end_monitor
    It does not work. I can't understand why

    Needless to say EDB does not allow me to recruit if I put the event_counter condition in.

    Please help me, I run out of ideas

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

  2. #2

    Default Re: event counter not working?

    Shouldn't it be

    monitor_event FactionTurnStart FactionIsLocal
    if I_CompareCounter north_counter_stark =1
    console_command toggle_fow
    end_monitor

    ?

    By starting the line with "and", you're implying that there should be something before the "and", but there isn't. For example, "A and B". You only have "and B".

    Hmm...or since it's a set_event_counter, not a set_counter, you'll probably need

    monitor_event FactionTurnStart FactionIsLocal
    if I_EventCounter north_counter_stark =1
    console_command toggle_fow
    end_monitor

    Or maybe the game doesn't like a counter and an event_counter with the same name and it's getting confused.
    Last edited by k/t; January 06, 2013 at 03:00 PM.

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

    Default Re: event counter not working?

    I don't follow what you're trying to achieve with fow and EDB but in general...

    You can have a counter and event counter with the same name but it's confusing for humans, e.g. difficult to tell at a glance whether I_EventCounter/set_event_counter usages - or their normal counter equivalents - are mistakes or not.

    When you take out the set_event_counter line nothing is ever setting that event counter to 1. Hence the I_EventCounter test evaluates to false. Likewise for the EDB condition: because you took out the set_event_counter, not because you added I_EventCounter.

    I take it that you need a counter to do actual counting (regions?) and another counter as a flag to represent "conditions met" for the EDB and fow. All of your posted script would do that - just don't remove the set_event_counter, and remove the first fow toggle (?). And perhaps rename that event counter to something like "ec_north_stark" to distinguish it from the other counter...

    Code:
    set_event_counter ec_north_stark 0   ;not necessary
    
    monitor_event (whatever)
    
    ...
    
      if I_CompareCounter north_counter_stark > 5
        set_event_counter ec_north_stark 1
      end_if
    
    ...
    
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
      and I_EventCounter ec_north_stark = 1
      console_command toggle_fow
    end_monitor

  4. #4

    Icon1 Re: event counter not working?

    Kiliç Alì: An event counter linked to the ‘export_descr_buildings’ file will have a delay of one turn before it takes effect. You can get around this by setting the event counter at the end of that faction’s turn or, since you know which regions the unit can be recruited in, you could directly place that unit in the recruitment pool for that region or regions:
    Spoiler Alert, click show to read: 
    Code:
    ---------------------------------------------------
    Identifier:         set_recruit_pool
    Parameters:         region_name|region_id value unit_name 
    Description:        Set specified amount of units to the unit pool of the specified type of unit in the specified region.
    Sample use:         set_recruit_pool York_Province 5 temp heavy spearmen
    Class:              SET_RECRUIT_POOL
    Implemented:        Yes
    Author:             Grig
    ---------------------------------------------------
    Identifier:         inc_recruit_pool
    Parameters:         region_name|region_id value unit_name
    Description:        Add specified amount of units to the unit pool of the specified type of unit in the specified region.
    Sample use:         inc_recruit_pool York_Province -2 temp_heavy_spearmen
    Class:              INC_RECRUIT_POOL
    Implemented:        Yes
    Author:             Grig

  5. #5
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: event counter not working?

    Thanks for your time guys
    I take it that you need a counter to do actual counting (regions?) and another counter as a flag to represent "conditions met" for the EDB and fow.
    Yeah that is the case. The counter does actually this and is used later in the victory conditions. It is first reset to 0 at each turn, then increased of 1 for each region the faction has, all in the same monitor.
    Once it reaches the value of 6 then the event_counter should be set. This happens at turn start for each faction. So I have this (10k lines long):

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
    
        set_counter north_counter_stark 0
    ...
            if I_SettlementOwner Winterfell = scotland
                 inc_counter north_counter_stark 1
            end_if
    ...
    end_monitor
    And this:
    Code:
    monitor_event FactionTurnStart FactionIsLocal
    ...
        if I_CompareCounter north_counter_stark > 5
            set_event_counter north_counter_stark 1
        end_if
    ...
    end_monitor
    The toggle_fow in 1st post was just to test if the other conditions were met (and they were since fog was toggled). I removed it as you can see.

    Then the problem must be the set_event_counter part: at the bottom I added this:
    Code:
        monitor_event FactionTurnStart FactionIsLocal
            and I_EventCounter north_counter_stark = 1
                console_command toggle_fow
        end_monitor
    And the fog is not toggled when I pass the turn. Why?
    Is there any way to find the counters and their values in the game log?

    @TNZ Thanks I didn't know this, but It does not work even after some turns
    Also I'm not that fond of the set_recruit_pool solution since EDB is not my field, I prefer to avoid it if possible

    If any of you want to give a closer look, here the entire script. Set language as YAML in Notepad++ for fast reading.

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

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

    Default Re: event counter not working?

    Dunno Kilic, it looks okay to me. Maybe you can't use the same name for a counter and an event counter. I thought you could.

    Stupid question: you do own more than 5 settlements, right?

    I believe that tracing shows counter values when they are set/changed. Don't know about event counters though.

    Maybe try using a historic event as the signal of success instead of toggle_fow, just in case something else happens to be toggling it back off again.

  7. #7
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: event counter not working?

    Thanks With

    The problem is solved but the sloution is absurd.
    I followed your suggestion and named the event_couter north_event_counter_stark, but this was not the problem.

    this line:

    if I_CompareCounter north_counter_stark > 5
    set_event_counter north_event_counter_stark 1
    end_if
    sets the event_counter to 1. It is followed by this one:
    if not I_CompareCounter north_counter_lannister > 5
    set_event_counter north_event_counter_lannister 0
    end_if
    Wich sets the event counter back to 0. WTF!?
    so I changed it to
    if I_CompareCounter north_counter_lannister < 5
    set_event_counter north_event_counter_lannister 0
    end_if
    and the event counter is kept to 1. Double-WTF!?

    Anyway things seems to work fine, even EDB conditions work (despite 1 turn later of course), so yeah, the lesson is:
    always use positive sentences when testing counters with ">" or "<"

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

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

    Default Re: event counter not working?

    Strange. I saw that and it gave me pause but I'm pretty sure that I've used "not I_CompareCounter" before. Maybe not. "not I_EventCounter" definitely works, with "=" at least. Maybe "not" can't be used with < or >. That rings a bell.

    BTW, you would need <= 5, not < 5, otherwise you're not allowing for the situation of owning 5 settlements.

  9. #9
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: event counter not working?

    =< 5 does not work while < 6 does. Pleas don't ask why

    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

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

    Default Re: event counter not working?

    <= not =<

  11. #11
    Kiliç Alì's Avatar Domesticus
    Artifex

    Join Date
    Feb 2011
    Location
    Italy
    Posts
    2,114

    Default Re: event counter not working?


    Member of the Imperial House of Hader, proud client of The only and sole Ferrit

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

    Default Re: event counter not working?

    I know. It's been a long day.

  13. #13

    Default Re: event counter not working?

    So my solutions were all wrong...

    Crap, I still have a lot to learn about scripting.

Posting Permissions

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