ID:145901
 
Code:
        RollStats()
src.weight = rand(120,250)
src.height = rand(48,79)
src.age = rand(15,28)


Problem description: Well, I figured that people would eventually catch on to how I generated certain portions of the game, so I decided to add a random stat generater. You will be given no option to reroll but I still think people will relog to get better stats, but meh, what can I do about this?

When you start a game, you are given stats. I want those stats to be within the range I have set. For the weight, I want it to be no less then 120 pounds and no more then 250 pounds, and so on. However, with this peice of code, I get negative stats and such, which in this case won't do at all. Any help is greatly appreciated.

Problem Answer: It apparently wasn't my use of rand() that was wrong, another proc the game uses just decides to work when it wants too, thus messing up certain calculations.

Your using it correctly, but there must be other factors that are changed your answer.

According to the DM Reference:

Format:
rand(L=0,H) or rand()

Returns:
A random integer between L and H inclusive; or a random number from 0 up to 1 if L and H are omitted.

Args:
L: A number for the lower-bound.
H: A number for the upper-bound.

So I don't know whats wrong.
Plagu3r wrote:
You will be given no option to reroll but I still think people will relog to get better stats, but meh, what can I do about this?

Save a person's rolls in a file. If he relogs, load the values from the file rather than rolling new ones. That way, he'd need to use a new key every time he wanted to reroll. If you want to keep players from using multiple keys to reroll stats, put a savefile on his computer and save his known list of keys to it. Check for a savefile when he logs in again, and if the savefile contains a key for which stats have already been rolled, simply load those stats. That way, a person would have to delete a save file and make a new key every single time he wanted to reroll his stats. Finally, make it so that only BYOND Members can roll stats in the first place. Non-Members just get the lowest possible rolls. That way, a cheater would have to make a new key, delete a savefile, and pay $15 to BYOND every time he wanted to reroll!
In response to Crzylme
Piratehead, thats a good idea. I think I might actually do that. I think I'll allow BYOND Memebers the chance to reroll, but not for non-members. I'll check it out and see if I can do anything with it.