Page 1 of 1

How make random numbers at birth to refer to?

Posted: Wed Jul 12, 2017 12:40 pm
by sajberhippien
Fiddling about with a mod, one thing I don't know how to do elegantly is making certain effects only happen to randomly chosen characters, determined at birth (much like the stock of stores).

Basically, what I want to do is to have numbers be randomly generated on birth, and then check them later in, for example, the PC's chat with another character.

I prefer to alter as few files (and as unimportant files) as possible, so I was wondering if there's some simple way to do this. Is there a general "seed number" used by shops and similar that I can refer to? Ideally it should be something invisible to the player.

Thankful for any help.

Re: How make random numbers at birth to refer to?

Posted: Thu Jul 13, 2017 12:41 am
by HousePet
Hrm, need a bit more information about what you want to achieve here.
Is this for all characters or just specific race/class ones?

If its for all characters, you should be able to store a randomised number on the game state (game.state?) from the addons Load hook.
If its for specific race/classes, you could use the code that Alchemist uses to setup some extra things after the character has been created.
Alternatively, you could try looking at the code that makes certain dungeons have a chance of appearing.

Re: How make random numbers at birth to refer to?

Posted: Thu Jul 13, 2017 1:49 am
by Snarvid
Qog's essentials or wheel of fate have some RNG tricks, can you steal those?

Where did the additional item slots used by Demonologists and Tinkers come from, and could you stick something invisible in the off-neck slot that IIRC nothing uses?

I know nothing about coding, just spitballing.

Re: How make random numbers at birth to refer to?

Posted: Thu Jul 13, 2017 3:23 am
by Zizzo
sajberhippien wrote:Basically, what I want to do is to have numbers be randomly generated on birth, and then check them later in, for example, the PC's chat with another character.
[sound F/X: source diving] Well, to generate the numbers on birth, it looks like you could superload mod.class.Player and add an :on_birth_done() method for that [cf. mod.class.Game:newGame()]. Where to store those numbers would depend on whence you need access to them; for a chat, for instance, the player gets passed in, so you could stow them there.