Results 1 to 9 of 9

Thread: 'generate_random_counter' - counter or event?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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 'generate_random_counter' - counter or event?

    I am slightly puzzled if 'generate_random_counter' creates a counter which I would query with 'I_CompareCounter' or an event to be queried with 'I_EventCounter'.

    My money is on the latter, but I wouldn't mind some comments.










  2. #2

    Icon1 Re: 'generate_random_counter' - counter or event?

    Yes. You should use 'I_EventCounter' with ‘generate_random_counter’:
    Spoiler Alert, click show to read: 
    Code:
    ---------------------------------------------------
    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
    ---------------------------------------------------
    Code:
    	monitor_conditions I_CompareCounter french_invade_england = 1
    		generate_random_counter france_invade 1 3
    		if I_EventCounter france_invade = 1
            spawn_army
                	faction france
                	character    	random_name, admiral, age 21, x 327, y 141, direction N
                	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
            end
    		set_counter invade_kent 1
    		inc_counter kent_invade 1
    ;		historic_event french_fleet_off_kent_coast factions { england, }
    
    
    	end_if
    		if I_EventCounter france_invade = 2
            spawn_army
                	faction france
                	character    	random_name, admiral, age 21, x 316, y 169, direction N
                	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
            end
    		set_counter invade_essex 1
    		inc_counter essex_invade 1
    ;		historic_event french_fleet_off_essex_coast factions { england, }
    	end_if
    		if I_EventCounter france_invade = 3
            spawn_army
                	faction france
                	character    	random_name, admiral, age 21, x 298, y 126, direction N
                	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
               	unit         	cog                	exp 2 armour 0 weapon_lvl 0
            end
    		set_counter invade_pevensey 1
    		inc_counter pevensey_invade 1
    ;		historic_event french_fleet_off_pevensey_coast factions { england, }
    	end_if
    		set_event_counter france_invade 0
    		set_counter french_invade_england 0
    	end_monitor

  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: 'generate_random_counter' - counter or event?

    Thanks for the confirmation










  4. #4

    Default Re: 'generate_random_counter' - counter or event?

    generate_random_counter could be used where ever you like. The counter itself IS the event_counter. It is entirely up to you as to how its used. It is simply called in the script and set to the random value. What that random value does is then left to the rest of the script.
    ...longbows, in skilled hands, could reach further than trebuchets...

  5. #5
    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: 'generate_random_counter' - counter or event?

    How does this look? I used it for percentage as well, found only later the random_percentage command\condition thing.

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal   
        generate_random_counter 3jahre 1 36       
        generate_random_counter prozent 1 100
    end_monitor
    
    monitor_event PreFactionTurnStart FactionIsLocal
        and I_EventCounter 3jahre = 36
    
        if I_EventCounter prozent < 35
            spawn_character    slave, random_name, witch, age 40, x 59, y 240
            spawn_character    slave, random_name, witch, age 40, x 112, y 319
        end_if
        if I_EventCounter prozent > 34
           and I_CompareCounter prozent < 70
            spawn_character    slave, random_name, witch, age 40, x 180, y 254
            spawn_character    slave, random_name, witch, age 40, x 180, y 395
        end_if
        if I_EventCounter prozent > 69
            spawn_character    slave, random_name, witch, age 40, x 438, y 38
            spawn_character    slave, random_name, witch, age 40, x 447, y 72
        end_if
            historic_event hexerei
    end_monitor










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

    Default Re: 'generate_random_counter' - counter or event?

    Maybe something like this is better:

    Code:
    monitor_event FactionTurnStart FactionIsLocal
        generate_random_counter 3jahre 1 36
    if I_EventCounter 3jahre = 36
        generate_random_counter prozent 1 100
        if I_EventCounter prozent < 35
            spawn_character    slave, random_name, witch, age 40, x 59, y 240
            spawn_character    slave, random_name, witch, age 40, x 112, y 319
        end_if
        if I_EventCounter prozent > 34
           and I_CompareCounter prozent < 70
            spawn_character    slave, random_name, witch, age 40, x 180, y 254
            spawn_character    slave, random_name, witch, age 40, x 180, y 395
        end_if
        if I_EventCounter prozent > 69
            spawn_character    slave, random_name, witch, age 40, x 438, y 38
            spawn_character    slave, random_name, witch, age 40, x 447, y 72
        end_if
            historic_event hexerei
    end_if
    end_monitor
    Last edited by Taiji; November 16, 2011 at 12:53 PM.

  7. #7
    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: 'generate_random_counter' - counter or event?

    The stuff was a bit out of context, there are more random counters in the first monitor which are used by about a dozen different monitors:

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal    ; Zufallsnummern benutzt
        generate_random_counter 1jahr 1 12        ; - 12 - 11
        generate_random_counter 2jahre 1 24        ; - 24 - 23 - 22 - 21
        generate_random_counter 3jahre 1 36        ; - 36 - 35 - 34 - 33 - 32 - 31
        generate_random_counter 5jahre 1 60        ; - 60 - 59
        generate_random_counter 6jahre 1 72        ; - 72 - 71
        generate_random_counter 7jahre 1 84        ; - 84
        generate_random_counter 8jahre 1 96        ; - 96
        generate_random_counter prozent 1 100
    
    end_monitor
    Code:
    declare_counter bruch
    monitor_event PreFactionTurnStart FactionIsLocal
        and I_EventCounter 6jahre = 71
    
            historic_event deiche
    
    end_monitor










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

    Default Re: 'generate_random_counter' - counter or event?

    The point I make is that you've no need for a second monitor, since it only differs from the first by a condition that can be used in a if statement. If this is the same in every case, then you wind up with one monitor that contains several if statements.

    Also if buildings and traits are going to be affected by these event counters then you need it to run in PreFactionTurnStart, otherwise I think you'll find FactionTurnStart more efficient.

  9. #9
    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: 'generate_random_counter' - counter or event?

    I kept the random_counter stuff in a separate monitor to better keep track which numbers I have been using (hence the numbers on the right) - one additional monitor shouldn't hurt.
    And yes, all the monitors using it for EDB and traits have PreFactionTurnStart (see post #7) - my bad I omitted the monitor that resets the 'deiche' event after a few rounds:

    Code:
    monitor_event PreFactionTurnStart FactionIsLocal
        if I_EventCounter deiche = 1
            inc_counter bruch 1
        end_if
        if I_CompareCounter bruch = 5
            set_event_counter deiche 0
            set_counter bruch 0
        end_if
    
    end_monitor










Posting Permissions

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