I'm in need of a way to allow the user to select 1 of 3 man and min values and then find a random number between those two intervals. Here is the UDF i am using.
Code:
int DamageCalculator(int dmgmax, int dmgmin){
int array[5];
int j;
int damagetotal;
int N = (dmgmax - dmgmin) + 1;
srand( (unsigned)time( NULL ) );
for (int i = 0; i < 5; i++) {
j = (int) N * rand() / (RAND_MAX +1.0);
array[i]=j;
}
damagetotal = (array[2] + dmgmin);
return damagetotal;
}
Then I call it using a simple if else if statement:
Code:
if (skillselected = 1){
dmgdealt = (DamageCalculator(dmgmax1, dmgmin1) ;
}
else if (skillselected = 2){
dmgdealt = (DamageCalculator2(dmgmax2, dmgmin2) ;
}
else if (skillselected = 3){
dmgdealt = (DamageCalculator2(dmgmax3, dmgmin3);
}
After everything is put it and called, it doesnt matter which "skillselected' equals, all three will use the same interval to produce a random number.