just a quick question, could someone explain how exactly the "RandomPercent" parameter works?
Printable View
just a quick question, could someone explain how exactly the "RandomPercent" parameter works?
I believe: the game uses a random-function to generate a number. Then it compares the number with the one you've given for the RandomPercent. If your number is equal or greater than the generated one, you get the effect you want.
Actually, you provide the logic token yourself. That way, RandomPercent > 99 will return True with a 1% chance, same as RandomPercent < 2 or RandomPercent <= 1.
Yes, I thought that goes without saying, my bad. Thx Bozos! :)
ok, i think i understand, but let me just check to be sure.
if a trait or ancillary trigger says:
what exactly happens?Code:...
Condition ...
and RandomPercent <= 5
...
Affects GoodCommander 1 Chance 10
(... denotes clipped text)
similarly, if triggering an event in a script, such as this one in EB:
what does the RandomPercent do here?Code:monitor_event FactionTurnStart FactionType scythia
...
and I_TurnNumber > 35
and I_TurnNumber < 210
and RandomPercent < 5
and I_LocalFaction scythia
console_command create_building Sulek hinterland_victory
...
end_monitor
thanks in advance :sweatdrop:
If the random number generated by the game is less than 5 (and all other conditions are met), you get the victory-building in Sulek.
thanks aradan :) so RandomPercent < 99 would mean 99 times out of 100, the condition returns "true"?
can you do...
?Code:and RandomPercent < 99
and RandomPercent > 50
or (assuming the system would even accept that) is that just a redundant way to do
?Code:and RandomPercent > 51
but what about traits/ancillaries? first there is a RandomPercent, and then the usual "Chance" #
does that mean that first it rolls dice for RandomPercent to see if it even will or will not execute yet another dice roll with the "Chance" parameter? which makes me wonder... why bother with two dice rolls? :confused:
Basically it will be true 98 times out of 100, since 99 isn't less than 99... In order to have a 99% chance you must haveAssuming that in the case you used two RandomPercent checks the game only trows the dice once, I don't think your logic is correct. Because if the RandomPercent is 51, thisQuote:
and RandomPercent <= 99
will be satisfied, while thisQuote:
and RandomPercent < 99
and RandomPercent > 50
will not. Or if the value is 100, then the double one won't be satisfied and the single one will.Quote:
and RandomPercent > 51
And there is always the chance that if you put two RandomPercent lines, the game actually throws the dice two times, in which case the final probability of your thing happening is prob1 * prob2= final_prob, which will always be less than the min{prob1, prob2} (assuming that we can't have 100% probability.
Generally, I can see no reason to put two RandomPercent lines, even if the game accepts them. It seems redudant and rather complicated.
The usage of both 'chance' and 'RandomPercent' is probably possible in order to allow for probabilities with up to two decimals to be used, as the engine calculates probabilities only with integers... I guess it's a valuable tool for traiters to be able to have probs like 43.76%...
Perhaps one of the highly experienced EB traitors :laugh4: would be of more avail here.
I believe the term is traiters ;)
Quote:
monitor_event ForumTurnStart FactionType palantir
...
and I_PostNumber > 1
and I_PostNumber < 2
and RandomPercent < 100
and LocalForumBrowser noobie
and ProblemNameExists Installation Error
console_command create_angryPost Palantir ReadTheInstructionsProperlyFor_victory
...
end_monitor
hyuk hyuk hyuk :whip: :wink:Quote:
Originally Posted by Dol Guldur
seriously though... anyone here know what the purpose is when it comes to trait/ancillaries? :inquisitive:
As Aradan wrote, using RandomPercent in traits/ancillaries allows you to have non-integer probabilities for triggers, as in this piece here:
You can also use it to save some lines of code: suppose that you want to trigger a certain trait B whenever a character acquires another trait A. You could either write it like this:Code:;------------------------------------------
Trigger harsh_lifestyle1
WhenToTest CharacterTurnEnd
Condition EndedInSettlement
and RemainingMPPercentage = 100
and SettlementBuildingExists = governors_house
and RandomPercent > 50
Affects Austere 1 Chance 2
Affects Pragmatic 1 Chance 2
Affects Stoic 1 Chance 1
Or you can save some bytes writing it like this:Code:Trigger acquire_A
WhenToTest CharacterTurnEnd
Condition IsGeneral
and Trait A < 1
Affects A 1 Chance 20
;-----------------------------------
Trigger acquire_B
WhenToTest CharacterTurnEnd
Condition IsGeneral
and Trait A = 1
and Trait B < 1
Affects B 1 Chance 100
Code:Trigger acquire_A_then_B
WhenToTest CharacterTurnEnd
Condition IsGeneral
and Trait A < 1
and RandomPercent > 80
Affects A 1 Chance 100
Affects B 1 Chance 100
ok, i think i understand the second part. and so following from the logic there, i'm assuming this means that in the above trigger, the possibility of adding one point of "stoic" is thus effectively 0.5% ?Quote:
Originally Posted by BozosLiveHere
thanks so much, bozoslivehere :2thumbsup:
Yup.
Sorry to resurrect an old thread, but it seemed better than starting a related new one. Can I use the RandomPercent parameter to spawn armies like this?
Code:monitor_event FactionTurnStart FactionType scythia
if RandomPercent < 3
spawn_army
faction scythia
character Kudurmabug, general, age 30, , x XXX, y YYY
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
end
end_if
if RandomPercent > 99
spawn_army
faction scythia
character Kudurmabug, general, age 30, , x XXX, y YYY
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
end
end_if
end_monitor
monitor_event FactionTurnStart FactionType scythia
while I_TurnNumber <= 399
end_while
if I_TurnNumber = 400
console_command kill_character "Kudurmabug"
spawn_army
faction scythia
character Kudurmabug, named character, command 0, influence 0, management 0, subterfuge 0, age 40, , x XXX, y YYY
unit barb chieftain cavalry scythian exp 1 armour 1 weapon_lvl 1
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian noble cavalry exp 0 armour 1 weapon_lvl 1
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian horse archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
unit sarmatian archer exp 0 armour 0 weapon_lvl 0
end
console_command give_trait "Kurdurmabug" GoodCommander 3
if I_TurnNumber >= 401
terminate_monitor ; Loaded game.
end_if
end_monitor