src\net\sf\odinms\scripting\npc Path
NPCConversationManager.java file input
UsageCode:public static int randomNumber(int min, int max) {
return min + (int)(Math.random() * (max - min));
}
num = cm.randvalue(10 input = One of the numbers 1 to 10)
Printable View
src\net\sf\odinms\scripting\npc Path
NPCConversationManager.java file input
UsageCode:public static int randomNumber(int min, int max) {
return min + (int)(Math.random() * (max - min));
}
num = cm.randvalue(10 input = One of the numbers 1 to 10)
Easier for generating numbers between an interval (e.g. random a pet ID from 50000000 and 50000040)Code:public static int randomNumber(int min, int max) {
return min + (int)(Math.random() * (max - min));
}
Not the real ID's btw =)
-Kerelmans
lol.. Somehow I know you..
nice release
return new Random().nextInt(value);
People are going to get compiling errors if they haven't declared oRandom
Random.nextInt() is supposedly faster. Math.random() calls random.nextdouble() which calls random.next() twice, where as random.nextint() only calls .next() once on average.
Sorry if that was confusing but yeahs, since people are all fuss about performance then might aswell be judgmental on every thing.
Very nice said, but we're talking about 0.1 ms or even less...
Here's some more info about random class if someone was interested:
http://java.sun.com/javase/6/docs/ap...il/Random.html
Funny how some method like this already was in my MapleCharacter.java
PHP Code:private static int rand(int lbound, int ubound) {
return (int) ((Math.random() * (ubound - lbound + 1)) + lbound);
}