irandom_range keeps giving me the same number over and over again.

D

Divecko

Guest
Howdy, I'm new to game maker and I've hit a bit of a snag. I'm working on a text based rpg adventure and i want the initial stats for the character to be randomly rolled, however every time I restart the game the same stats are always there. so like health is always 17 and strength is always 5. I plan on adding a button that allows you to reroll the stats as much as you want but i want the first set to be random too.
here is what i have for my code:

create:
global.constitution = irandom_range(3,18)
global.strength = irandom_range(3,18)
global.dexterity = irandom_range(3,18)
global.charisma = irandom_range(3,18)
global.knowledge = irandom_range(3,18)

draw GUI:
draw_set_font(fnt_maintext)
draw_text(95,184, "Health: [ ]")
draw_text(237,184, global.constitution)
draw_text(95,234, "Strength: [ ]")
draw_text(269,234, global.strength)
draw_text(95,284, "Dexterity: [ ]")
draw_text(283,284, global.dexterity)
draw_text(95,334, "Charisma: [ ]")
draw_text(269,334, global.knowledge)
draw_text(95,384, "Knowledge: [ ]")
draw_text(283,384, global.knowledge)
 

Perseus

Not Medusa
Forum Staff
Moderator
You need to call randomize() at the start of your game.
The Manual entry on random functions said:
NOTE: When using the random functions, GameMaker Studio 2 maintains the same random seed every time you start the game. This makes debugging much easier as you are guaranteed that the random functions will always return the same value, however should you not wish this to happen, you must first set a new random seed at the very start of the game, either using randomise or random_set_seed.
 
Top