version 1.12 | | version 1.13 |
---|
| | |
/* | | /* |
* static char *rcsid_utils_c = | | * static char *rcsid_utils_c = |
* "$Id: utils.c,v 1.12 2003/11/10 05:39:50 mwedel Exp $"; | | * "$Id: utils.c,v 1.13 2004/09/19 16:17:48 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
*/ | | */ |
| | |
int random_roll(int min, int max, object *op, int goodbad) { | | int random_roll(int min, int max, object *op, int goodbad) { |
int omin, diff, luck, base; | | int omin, diff, luck, base, ran; |
| | |
omin = min; | | omin = min; |
diff = max - min + 1; | | diff = max - min + 1; |
| | |
return(min); /* avoids a float exception */ | | return(min); /* avoids a float exception */ |
} | | } |
| | |
| | ran = RANDOM(); |
| | |
if (op->type != PLAYER) | | if (op->type != PLAYER) |
return((RANDOM()%diff)+min); | | return((ran%diff)+min); |
| | |
luck = op->stats.luck; | | luck = op->stats.luck; |
if (RANDOM()%base < MIN(10, abs(luck))) { | | if (RANDOM()%base < MIN(10, abs(luck))) { |
| | |
return(omin); /*check again*/ | | return(omin); /*check again*/ |
((goodbad) ? (min += luck) : (diff)); | | ((goodbad) ? (min += luck) : (diff)); |
| | |
return(MAX(omin, MIN(max, (RANDOM()%diff)+min))); | | return(MAX(omin, MIN(max, (ran%diff)+min))); |
} | | } |
return((RANDOM()%diff)+min); | | return((ran%diff)+min); |
} | | } |
| | |
/* | | /* |
| | |
*/ | | */ |
| | |
int die_roll(int num, int size, object *op, int goodbad) { | | int die_roll(int num, int size, object *op, int goodbad) { |
int min, diff, luck, total, i, gotlucky, base; | | int min, diff, luck, total, i, gotlucky, base, ran; |
| | |
diff = size; | | diff = size; |
min = 1; | | min = 1; |
| | |
if (diff < 1) | | if (diff < 1) |
return(num); /*check again*/ | | return(num); /*check again*/ |
((goodbad) ? (min += luck) : (diff)); | | ((goodbad) ? (min += luck) : (diff)); |
total += MAX(1, MIN(size, (RANDOM()%diff)+min)); | | ran = RANDOM(); |
| | total += MAX(1, MIN(size, (ran%diff)+min)); |
} else { | | } else { |
total += RANDOM()%size+1; | | total += RANDOM()%size+1; |
} | | } |