Results 1 to 12 of 12

Thread: I_EventCounter vs. I_CompareCounter

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default I_EventCounter vs. I_CompareCounter

    Does anyone know when to properly use each of these two?

    One would think that I_CompareCounter should be used for all but event_counters. But no, there are several undocumented features here, such as for example generate_random_counter having to be used with I_EventCounter exclusively.

    Also, you must not declare and set the counter which you'll use with generate_random_counter, or that won't work either.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  2. #2
    gracul's Avatar 404 Not Found
    Artifex

    Join Date
    Dec 2007
    Location
    Poland
    Posts
    2,009

    Default Re: I_EventCounter vs. I_CompareCounter

    event_counter works between files, plain counters are campaign script only things.
    event_counters are initialized with a 0 which can cause some EDB trouble (use 'not event_counter xxx 1' instead of 'event_counter 0')

  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: I_EventCounter vs. I_CompareCounter

    I_CompareCounter does just that: comparing a previously set counter (set_counter)
    I_EventCounter is related to an actual event (eg world_is_round) and checks for it's status

    Generate_Random_Counter should be easy understood, it says GENERATE (ergo you can't declare it - else you would use random_counter_inc), but I fail to understand why you should not be able to change the counter or check it in the regular way once it is created. Principally it should work the same way as "set_counter" - creating a counter.










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

    Default Re: I_EventCounter vs. I_CompareCounter

    I_CompareCounter is for counters and I_EventCounter is for event counters. Couldn't be simpler.

    Is this the question you mean to ask: "What is the difference between event counters and counters?"

    I use them all the time and yet I don't think I have the full answer.

    But I can tell you that you don't declare event counters, hence your experience with generate_random_counter, an event counter generator.

    And like Gracul mentioned, event counters can be tracked in files other than campaign_script.
    Last edited by Taiji; February 01, 2011 at 09:31 AM.

  5. #5
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: I_EventCounter vs. I_CompareCounter

    generate_random_counter could work differently:

    You could declare a counter, set it to 0, and then assign random values to it via generate_random_counter. I don't see why that's not plausible. In fact since the engine expects use to use regular counters for pretty much all scripting needs, to suddenly work with event_counters in this one instance is a bit out of the ordinary. Would've been nice to have it documented, that's all.


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

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

    Default Re: I_EventCounter vs. I_CompareCounter

    generate_random_counter is actually documented very clearly in the docudemons, so I'm really not sure what you mean.

    ---------------------------------------------------
    Identifier: generate_random_counter
    Parameters: event_counter name, min_value, max_value
    Description: Sets the specified counter to a random value between min and max inclusive.
    Sample use: generate_random_counter RandomCounter 10 20
    Class: GENERATE_RANDOM_COUNTER
    Implemented: Yes
    Author: Mark
    ---------------------------------------------------

    If you don't actually want an event counter then you just declare a counter and use random_counter_inc.

    ---------------------------------------------------
    Identifier: random_counter_inc
    Parameters: event_counter name, min_value, max_value
    Description: Increments the specified counter by a random value between min and max inclusive.
    Sample use: random_counter_inc RandomCounter 10 20
    Class: RANDOM_COUNTER_INC
    Implemented: Yes
    Author: Mark
    ---------------------------------------------------

    Which we can see is not well described since it also works for counters. The first one is fine, the second one needs adjusting. That's my opinion, and this looks better to me:

    ---------------------------------------------------
    Identifier: random_counter_inc
    Parameters: event_counter/counter name, min_value, max_value
    Description: Increments the specified counter by a random value between min and max inclusive.
    Sample use: random_counter_inc RandomCounter 10 20
    Class: RANDOM_COUNTER_INC
    Implemented: Yes
    Author: Mark
    ---------------------------------------------------
    Last edited by Taiji; February 01, 2011 at 11:33 AM.

  7. #7
    Opifex
    Join Date
    Feb 2005
    Location
    New York, USA
    Posts
    15,154

    Default Re: I_EventCounter vs. I_CompareCounter

    Quote Originally Posted by Taiji View Post
    generate_random_counter is actually documented very clearly in the docudemons, so I'm really not sure what you mean.

    ---------------------------------------------------
    Identifier: generate_random_counter
    Parameters: event_counter name, min_value, max_value
    Description: Sets the specified counter to a random value between min and max inclusive.
    Sample use: generate_random_counter RandomCounter 10 20
    Class: GENERATE_RANDOM_COUNTER
    Implemented: Yes
    Author: Mark
    ---------------------------------------------------
    Where there is it said that the counters it generates are event_counters?

    Or that the counter neither must not, nor cannot, be actually first declared previous to this line? That this command spontaneously generates event-countrs, and event-counters only, whose presence is unknown, are declared nowhere, etc etc?


    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

  8. #8

    Default Re: I_EventCounter vs. I_CompareCounter

    N00B question: if I want to modify a Random Counter (i.e. a Random Generated Counter is then increased if FactionLeader has enough authority to increase odds of a good event) using inc_event_counter or random_counter_inc?
    A well informed opinion is a well formed opinion.

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

    Default Re: I_EventCounter vs. I_CompareCounter

    random_counter_inc if you want a randomly chosen number between 2 values, inc_event_counter if you want to increment it by a set amount, and set_event_counter if you want to set it to a certain amount.

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

    Default Re: I_EventCounter vs. I_CompareCounter

    One reason why counters are awesome is that they are logged. Just had to mention it in case anyone isn't using this feature. Scripting without using them would make it very hard to work out why scripts fail. With counters we can see exactly which process completed successfully, etc. before a CTD occurs.

  11. #11
    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: I_EventCounter vs. I_CompareCounter

    Couldn't agree more.
    I usually have some counters firing at the beginning and end of a faction's turn.

    Code:
    declare_counter reichs_fraktion
    declare_counter katholisch
    ;--- Schweden ---
        declare_counter england_turn
        monitor_event PreFactionTurnStart FactionType england
            set_counter england_turn 1
          set_counter reichs_fraktion 0
          set_counter katholisch 0
        end_monitor
        monitor_event FactionTurnEnd FactionType england
            set_counter england_turn 0
        end_monitor
        declare_counter england_dead
        monitor_event LeaderDestroyedFaction FactionType england
            set_counter england_dead 1
        terminate_monitor
        end_monitor










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

    Default Re: I_EventCounter vs. I_CompareCounter

    Quote Originally Posted by SigniferOne View Post
    Where there is it said that the counters it generates are event_counters?
    In red there, you have to name an event_counter, that's the parameter. Like I already went to some length to explain to you, to me it's random_counter_inc's description that's not quite correct.

    Quote Originally Posted by SigniferOne View Post
    Or that the counter neither must not, nor cannot, be actually first declared previous to this line? That this command spontaneously generates event-countrs, and event-counters only, whose presence is unknown, are declared nowhere, etc etc?
    We don't declare event counters, simply learned through looking at scripts - I think it's plain to see what is declared and what isn't in vanilla. And really I don't see why anyone would want to declare an event counter if they'd not learned that it was necessary. It's not like there is an obvious reason for needing to declare counters beyond the fact that the log and examples tell us to.
    Last edited by Taiji; February 10, 2011 at 02:09 AM.

Posting Permissions

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