How make random numbers at birth to refer to?

A place to post your add ons and ideas for them

Moderator: Moderator

Post Reply
Message
Author
sajberhippien
Halfling
Posts: 114
Joined: Thu Jan 14, 2016 11:10 am

How make random numbers at birth to refer to?

#1 Post 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.

HousePet
Perspiring Physicist
Posts: 6215
Joined: Sun Sep 09, 2012 7:43 am

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

#2 Post 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.
My feedback meter decays into coding. Give me feedback and I make mods.

Snarvid
Spiderkin
Posts: 592
Joined: Mon Mar 28, 2011 12:42 pm

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

#3 Post 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.

Zizzo
Sher'Tul Godslayer
Posts: 2524
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

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

#4 Post 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.
"Blessed are the yeeks, for they shall inherit Arda..."

Post Reply