Suggestion: Random (min int, max int) (SOLVED)

Started by Moox, Mon 14/06/2004 23:01:41

Previous topic - Next topic

Moox

Well I am taking time off from my game to port one of my old basic games into ags . One key feature is a random dungeon generator. I want to have a random forest dungeon, mine dungeon, etc...
To accomplish this their needs to be both a minimum and a maximum so I can set the range between the backgrounds, perhaps 1-20 are forest 20-40 are cave. I need random number between 20-40 for a cave. One possible work around would be something like If int is between 0-20 then redo random. But a script like that could be kinda slow and time consuming to add to every room. Could you add a min range to random please cj

dave y

Random(20) + 20

gives you the same effect

strazer

You can define your own custom function:

Global script

function RandomEx(int min, int max) { return (min + Random(max-min)); }

Script header (so you can use it outside the global script, ie in rooms)

import function RandomEx(int min, int max);

Moox

I didnt know that was possible, thanks

SMF spam blocked by CleanTalk