Larian Studios
Posted By: Cromcrom Modulo and osiris randomness - 20/10/17 05:19 AM
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 ?
Posted By: GreedyQuestioner Re: Modulo and osiris randomness - 20/10/17 11:11 AM
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).
Posted By: Abraxas* Re: Modulo and osiris randomness - 20/10/17 11:58 AM
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.

Posted By: Cromcrom Re: Modulo and osiris randomness - 20/10/17 12:08 PM
Thanks a lot, this is far than enough to be, indeed, very usefull.
Posted By: Rasikko Re: Modulo and osiris randomness - 20/10/17 01:52 PM
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 %.
Posted By: Cromcrom Re: Modulo and osiris randomness - 21/10/17 07:49 AM
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.
© Larian Studios forums