Larian Banner: Baldur's Gate Patch 9
Previous Thread
Next Thread
Print Thread
Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
I love the random possibilities of the script (getRandomWeight is amazing), but I am perplexed by the random in Osiris.
What is modulo, how does it work ?
Like if I enter a modulo of 7, what result will I get ?


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere
Joined: Sep 2017
G
stranger
Offline
stranger
G
Joined: Sep 2017
If you call "Random(7, _random)" from my understanding you should get a random number from 0 to 6. You can test this with (for example):

Code
IF
CharacterUsedItem(_char, ITEMGUID_UNIQUE_TUT_LowerDeck_Morticia_000_92dec286-f7ae-436a-939a-b83cdec31973)
AND
Random(7, _random)
AND
IntegertoString(_random, _string) // larian, why is this lower case? Going by the naming convention shouldn't this be IntegerToString ? ;P
THEN
DisplayText(_char, _string);


which displays a new random number on top of the character every time you use the Skull (Morticia).

Joined: Sep 2015
A
addict
Offline
addict
A
Joined: Sep 2015
Quote
If you call "Random(7, _random)" from my understanding you should get a random number from 0 to 6.

Indeed. You can work with chances this way:

IF
...
AND
Random(10,_Number)
AND
_Number == 1
THEN
...

That should be a 10% chance to execute the THEN-part.

44% would be:

...
Random(100,_Number) //the engine returns an integer between 0 and 99
AND
_Number < 44 //0-43 (so 44 integers out of 100 are a win)
THEN
...

Less intuitive than randomization in object scripts, but useful.


Last edited by Abraxas*; 20/10/17 12:12 PM. Reason: Addition

My mods for DOS 1 EE: FasterAnimations - QuietDay - Samaritan
Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
Thanks a lot, this is far than enough to be, indeed, very usefull.


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere
Joined: Sep 2017
Location: Finland
journeyman
Offline
journeyman
Joined: Sep 2017
Location: Finland
Going to answer your question concerning modulo.

Modulo works with division in that it returns the remainder and not the quotient. It's also a very good way to check if a number is divisible by another number. If the result is any number other than 0, it's not divisible.

If you were to do this: 3 % 2, it will return 1. Standard mode for calculators don't allow the % sign to be used for modulo. Calculators in scientific mode will have a Mod button. So can do 3 Mod 2 as well.

In programming(at least for JS) you can use %.

Last edited by Rasikko; 20/10/17 02:04 PM.
Joined: Jun 2013
addict
OP Offline
addict
Joined: Jun 2013
Thanks Rasikko, I searched modulo on the net, and found what you are talking about. But it made no real sense in an Osiris randomness way.


Un chemin de 1000 lieues commence par un premier pas.

Project:
Steam workshop Frontiere

Link Copied to Clipboard
Powered by UBB.threads™ PHP Forum Software 7.7.5