* system may have problems because the user can't stop the
* autoroller for this number of rolls.
*/
-#define AUTOROLLER_STEP 25L
+#define AUTOROLLER_STEP 5431L
/*
* Define this to cut down processor use while autorolling
*/
-/*#define AUTOROLLER_DELAY*/
+#if 0
+# define AUTOROLLER_DELAY
+#endif
/*
* Maximum number of tries for selection of a proper quest monster
/*
- * Current stats
- */
-static s16b stat_use[6];
-
-/*
* Autoroll limit
*/
static s16b stat_limit[6];
*/
static void get_stats(void)
{
- int i, j;
-
- int bonus;
-
- int dice[18];
-
-
/* Roll and verify some stats */
while (TRUE)
{
+ int i;
+ int sum = 0;
+
/* Roll some dice */
- for (j = i = 0; i < 18; i++)
+ for (i = 0; i < 2; i++)
{
- /* Roll the dice */
- dice[i] = randint1(3 + i % 3);
-
- /* Collect the maximum */
- j += dice[i];
+ s32b tmp = randint0(60*60*60);
+ int val;
+
+ /* Extract 5 + 1d3 + 1d4 + 1d5 */
+ val = 5 + 3;
+ val += tmp % 3; tmp /= 3;
+ val += tmp % 4; tmp /= 4;
+ val += tmp % 5; tmp /= 5;
+
+ /* Save that value */
+ sum += val;
+ p_ptr->stat_cur[3*i] = p_ptr->stat_max[3*i] = val;
+
+ /* Extract 5 + 1d3 + 1d4 + 1d5 */
+ val = 5 + 3;
+ val += tmp % 3; tmp /= 3;
+ val += tmp % 4; tmp /= 4;
+ val += tmp % 5; tmp /= 5;
+
+ /* Save that value */
+ sum += val;
+ p_ptr->stat_cur[3*i+1] = p_ptr->stat_max[3*i+1] = val;
+
+ /* Extract 5 + 1d3 + 1d4 + 1d5 */
+ val = 5 + 3;
+ val += tmp % 3; tmp /= 3;
+ val += tmp % 4; tmp /= 4;
+ val += tmp;
+
+ /* Save that value */
+ sum += val;
+ p_ptr->stat_cur[3*i+2] = p_ptr->stat_max[3*i+2] = val;
}
/* Verify totals */
- if ((j > 42) && (j < 57)) break;
+ if ((sum > 42+5*6) && (sum < 57+5*6)) break;
/* 57 was 54... I hate 'magic numbers' :< TY */
}
-
- /* Acquire the stats */
- for (i = 0; i < 6; i++)
- {
- /* Extract 5 + 1d3 + 1d4 + 1d5 */
- j = 5 + dice[3*i] + dice[3*i+1] + dice[3*i+2];
-
- /* Save that value */
- p_ptr->stat_max[i] = j;
-
- /* Obtain a "bonus" for "race" and "class" and "seikaku"*/
- bonus = rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i];
-
- /* Start fully healed */
- p_ptr->stat_cur[i] = p_ptr->stat_max[i];
-
- /* Efficiency -- Apply the racial/class bonuses */
- /* stat_use[i] = modify_stat_value(p_ptr->stat_max[i], bonus); */
- stat_use[i] = p_ptr->stat_max[i];
- }
}
void get_max_stats(void)
for (i = 0; i < 6; i++)
{
/* Mega-Hack -- reduce gold for high stats */
- if (stat_use[i] >= 18 + 50) gold -= 300;
- else if (stat_use[i] >= 18 + 20) gold -= 200;
- else if (stat_use[i] > 18) gold -= 150;
- else gold -= (stat_use[i] - 8) * 10;
+ if (p_ptr->stat_max[i] >= 18 + 50) gold -= 300;
+ else if (p_ptr->stat_max[i] >= 18 + 20) gold -= 200;
+ else if (p_ptr->stat_max[i] > 18) gold -= 150;
+ else gold -= (p_ptr->stat_max[i] - 8) * 10;
}
/* Minimum 100 gold */
j = rp_ptr->r_adj[i] + cp_ptr->c_adj[i] + ap_ptr->a_adj[i];
/* Obtain the current stat */
- m = adjust_stat(stat_use[i], j, TRUE);
+ m = adjust_stat(p_ptr->stat_max[i], j, TRUE);
/* Put the stat */
cnv_stat(m, buf);
/* Put the percent */
if (stat_match[i])
{
- p = 1000L * stat_match[i] / auto_round;
+ if (stat_match[i] > 1000000L)
+ {
+ /* Prevent overflow */
+ p = stat_match[i] / (auto_round / 1000L);
+ }
+ else
+ {
+ p = 1000L * stat_match[i] / auto_round;
+ }
+
attr = (p < 100) ? TERM_YELLOW : TERM_L_GREEN;
sprintf(buf, "%3d.%d%%", p/10, p%10);
c_put_str(attr, buf, 3+i, col+13);
auto_round++;
/* Hack -- Prevent overflow */
- if (auto_round >= 1000000L)
+ if (auto_round >= 1000000000L)
{
auto_round = 1;
for (i = 0; i < 6; i++)
{
/* This stat is okay */
- if (stat_use[i] >= stat_limit[i])
+ if (p_ptr->stat_max[i] >= stat_limit[i])
{
stat_match[i]++;
}
#ifdef AUTOROLLER_DELAY
/* Delay 1/10 second */
- if (flag) Term_xtra(TERM_XTRA_DELAY, 100);
+ if (flag) Term_xtra(TERM_XTRA_DELAY, 10);
#endif
/* Make sure they see everything */