• We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

unmerged(287474)

Captain
2 Badges
Mar 19, 2011
389
0
  • Crusader Kings II
  • Victoria 2: A House Divided
Trying to make events that happen periodically by chance, kind of like sow dissent or improve relations.

Problem with using these as an example, is they don't fire off periodically while being compared to a random number. Their chance to fire is based on a mean_time_to_happen modifier, meaning they will fire off 100% of the time, only you don't know how long it will take.

The reason this way of doing it is horrible is because the mean time to happen is often SEVEN TO THIRTEEN YEARS.

So what I would like to do is create a temporary (or global, as long as triggers are synchronous) variable to hold a random number. Something like "int rand = random(0,100)".

Next, I've seen plenty of examples of the equal comparison, but don't know how you would perform a greater than '>', less than '<', greater than or equal to '>=', less than or equal to '<=' comparison.

Why? So I can do this:
Code:
#  -comment- pound signs '#' are comments and get stripped out, used for documenting your code.
int rand = random(0,100)
trigger = { # -comment- trigger sections are used to decide if the trigger fires at all. For a periodically recurring chance trigger this might not be the correct place to check if something should happen.
     OR = { # -comment- OR sections return true if ANY of the conditions inside of it are truthy, so if any of these inner AND sections return true, this OR will return true.
          AND = { # -comment- AND sections return true if ALL of the conditions inside of it are truthy.
               # -comment- 10% chance of success if diplomacy is less than 6.
               diplomacy <= 5
               rand <= 10
          }
          AND = {
               # -comment- 20% chance of success if diplomacy is 6 to 9.
               diplomacy >= 6
               diplomacy <= 9
               rand <= 20
          }
          AND = {
               # -comment- 30% chance of success if diplomacy is greater than 9.
               diplomacy >= 10
               rand <= 30
          }
     }
}

If it is possible, but the syntax isn't ideal I don't care, I just want to accomplish a periodically recurring trigger that only fires based on a random number!

Any help would be much appreciated!
 
Also if variables and random numbers are possible, then hopefully integer and/or decimal(ideally) basic arithmetic (add, subtract, multiply, divide) are available as well?
Also floor(), ceiling(), round()?

If these aren't possible, I think these would be wonderful additional features to implement into your scripting language Paradox! (pretty please?)