Results 1 to 6 of 6

Thread: Random Percent

Hybrid View

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

    Default Random Percent

    Hello all.
    I have problem with Random Percent
    Spoiler Alert, click show to read: 

    declare_counter farms

    monitor_event FactionTurnStart FactionIsLocal
    historic_event field_farm true
    terminate_monitor
    end_monitor

    monitor_conditions I_EventCounter field_farm_accepted = 1
    console_command add_money -3000
    set_counter farms 1
    set_event_counter field_farm_accepted = 0
    end_monitor

    monitor_conditions I_EventCounter field_farm_declined = 1
    set_event_counter field_farm_declined = 0
    end_monitor

    monitor_event FactionTurnStart FactionIsLocal
    and I_CompareCounter farms = 1

    if I_CompareCounter farms = 1
    and RandomPercent <= 20
    and RandomPercent >= 0
    historic_event field_VeryBad
    console_command add_money -7641
    set_counter farms 2
    end_if

    if I_CompareCounter farms = 1
    and RandomPercent <= 40
    and RandomPercent >= 20
    historic_event field_Bad
    console_command add_money -3245
    set_counter farms 2
    end_if

    if I_CompareCounter farms = 1
    and RandomPercent <= 60
    and RandomPercent >= 40
    historic_event field_normal
    set_counter farms 2
    end_if

    if I_CompareCounter farms = 1
    and RandomPercent <= 80
    and RandomPercent >= 60
    historic_event field_good
    console_command add_money 9255
    set_counter farms 2
    end_if

    if I_CompareCounter farms = 1
    and RandomPercent <= 100
    and RandomPercent >= 80
    historic_event field_Verygood
    console_command add_money 14214
    set_counter farms 2
    end_if
    end_monitor

    But there is such chance that can not drop out not 1 events. Why?, help

  2. #2

    Icon1 Re: Random Percent

    OPASEH: I am not 100% sure what your question is, but if you use ‘RandomPercent’ in that way there is a possibility that more than one of those historical events will fire.

    If you use ‘generate_random_counter’ in place of ‘RandomPercent’ your script should work as you intend:
    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_event FactionTurnStart FactionIsLocal
    historic_event field_farm true
    terminate_monitor
    end_monitor
    
    monitor_conditions I_EventCounter field_farm_accepted = 1
    console_command add_money -3000
    terminate_monitor
    end_monitor
    
    monitor_event FactionTurnStart FactionIsLocal
    and I_TurnNumber > 0
    and I_EventCounter field_farm_accepted = 1
    generate_random_counter farming_income 1 10
    
    if I_EventCounter farming_income <= 2
    and I_EventCounter farming_income >= 1
    historic_event field_VeryBad
    console_command add_money -764
    end_if
    
    if I_EventCounter farming_income >= 3
    and I_EventCounter farming_income <= 4
    and RandomPercent >= 20
    historic_event field_Bad
    console_command add_money -3245
    end_if
    
    if I_EventCounter farming_income >= 5
    and I_EventCounter farming_income <= 6
    historic_event field_normal
    end_if
    
    if I_EventCounter farming_income >= 7
    and I_EventCounter farming_income <= 8
    historic_event field_good
    console_command add_money 9255
    end_if
    
    if I_EventCounter farming_income >= 9
    and I_EventCounter farming_income <= 10
    historic_event field_Verygood
    console_command add_money 14214
    end_if
    set_event_counter farming_income 0
    end_monitor

  3. #3
    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: Random Percent

    You should know that everytime you use RandomPercent it generates a new random number. So yes the way you have set it up none of the events need to fire, similarly more than one of the events can fire as well.
    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

  4. #4

    Default Re: Random Percent

    Oh,thx.
    1)But your script make lower my treasure at -3000 EVERY SECOND=)))))))))))))))
    2)It work at once,but i dont want it.
    And i so stupid,plz look at this.Not terminate monitor
    Spoiler Alert, click show to read: 

    declare_counter farms


    monitor_event FactionTurnStart FactionIsLocal
    and FactionBuildingExists >= c_mines
    and RandomPercent < 15
    and I_TurnNumber > 15
    and not I_HotseatEnabled
    historic_event field_farm true
    end_monitor

    monitor_conditions I_EventCounter field_farm_accepted = 1
    console_command add_money -3000
    set_counter farms 1
    set_event_counter field_farm_accepted = 0
    end_monitor

    monitor_conditions I_EventCounter field_farm_declined = 1
    set_event_counter field_farm_declined = 0
    end_monitor


    monitor_event FactionTurnStart FactionIsLocal
    and I_CompareCounter farms = 1

    generate_random_counter farming_income 1 10

    if I_EventCounter farming_income <= 2
    and I_EventCounter farming_income >= 1
    historic_event field_VeryBad
    console_command add_money -7641
    end_if

    if I_EventCounter farming_income >= 3
    and I_EventCounter farming_income <= 4
    and RandomPercent >= 20
    historic_event field_Bad
    console_command add_money -3245
    end_if

    if I_EventCounter farming_income >= 5
    and I_EventCounter farming_income <= 6
    historic_event field_normal
    end_if

    if I_EventCounter farming_income >= 7
    and I_EventCounter farming_income <= 8
    historic_event field_good
    console_command add_money 9255
    end_if

    if I_EventCounter farming_income >= 9
    and I_EventCounter farming_income <= 10
    historic_event field_Verygood
    console_command add_money 14214
    end_if
    set_event_counter farming_income 0
    end_monitor
    Last edited by OPASEH; December 10, 2011 at 10:18 PM.

  5. #5

    Icon1 Re: Random Percent

    OPASEH: Try this:
    Spoiler Alert, click show to read: 
    Code:
    monitor_event FactionTurnStart FactionIsLocal
    and FactionBuildingExists >= c_mines
    and RandomPercent < 15
    and I_TurnNumber > 15
    and not I_HotseatEnabled
    historic_event field_farm true
    end_monitor 
    
    monitor_conditions I_EventCounter field_farm_accepted = 1
    console_command add_money -3000
    
    generate_random_counter farming_income 1 10
    
    if I_EventCounter farming_income <= 2
    and I_EventCounter farming_income >= 1
    historic_event field_VeryBad
    console_command add_money -7641
    end_if
    
    if I_EventCounter farming_income >= 3
    and I_EventCounter farming_income <= 4
    historic_event field_Bad
    console_command add_money -3245
    end_if
    
    if I_EventCounter farming_income >= 5
    and I_EventCounter farming_income <= 6
    historic_event field_normal
    end_if
    
    if I_EventCounter farming_income >= 7
    and I_EventCounter farming_income <= 8
    historic_event field_good
    console_command add_money 9255
    end_if
    
    if I_EventCounter farming_income >= 9
    and I_EventCounter farming_income <= 10
    historic_event field_Verygood
    console_command add_money 14214
    end_if
    set_event_counter farming_income 0
    set_event_counter field_farm_accepted = 0
    end_monitor
    
    monitor_conditions I_EventCounter field_farm_declined = 1
    set_event_counter field_farm_declined = 0
    end_monitor

  6. #6

    Default Re: Random Percent

    Thx.IT work.GOOD=)

Posting Permissions

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