View Full Version : "RandomPercent" parameter
tai4ji2x
06-15-2007, 14:19
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.
BozosLiveHere
06-15-2007, 19:17
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! :)
tai4ji2x
06-16-2007, 03:27
ok, i think i understand, but let me just check to be sure.
if a trait or ancillary trigger says:
...
Condition ...
and RandomPercent <= 5
...
Affects GoodCommander 1 Chance 10
what exactly happens?
(... denotes clipped text)
similarly, if triggering an event in a script, such as this one in EB:
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
what does the RandomPercent do here?
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.
tai4ji2x
06-16-2007, 13:44
thanks aradan :) so RandomPercent < 99 would mean 99 times out of 100, the condition returns "true"?
can you do...
and RandomPercent < 99
and RandomPercent > 50
?
or (assuming the system would even accept that) is that just a redundant way to do
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 have
and RandomPercent <= 99
Assuming 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, this
and RandomPercent < 99
and RandomPercent > 50
will be satisfied, while this
and RandomPercent > 51
will not. Or if the value is 100, then the double one won't be satisfied and the single one will.
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.
Dol Guldur
06-16-2007, 14:51
I believe the term is traiters ;)
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
tai4ji2x
06-16-2007, 20:58
I believe the term is traiters ;)
hyuk hyuk hyuk :whip: :wink:
seriously though... anyone here know what the purpose is when it comes to trait/ancillaries? :inquisitive:
BozosLiveHere
06-17-2007, 19:47
As Aradan wrote, using RandomPercent in traits/ancillaries allows you to have non-integer probabilities for triggers, as in this piece here:
;------------------------------------------
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
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:
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
Or you can save some bytes writing it like this:
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
tai4ji2x
06-20-2007, 03:59
As Aradan wrote, using RandomPercent in traits/ancillaries allows you to have non-integer probabilities for triggers, as in this piece here:
;------------------------------------------
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
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% ?
thanks so much, bozoslivehere :2thumbsup:
BozosLiveHere
06-20-2007, 19:04
Yup.
Quinn Inuit
03-14-2008, 22:49
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?
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
vBulletin® v3.7.1, Copyright ©2000-2025, Jelsoft Enterprises Ltd.