*/
static s16b stat_limit[6];
-static s16b chara_limit[6];
+static struct {
+ s16b agemin, agemax;
+ s16b htmin, htmax;
+ s16b wtmin, wtmax;
+ s16b scmin, scmax;
+} chara_limit;
/*
* Autoroll matches
/*
- * Computes character's age, height, and weight
- * by henkma
+ * Get character's height and weight
*/
-static void get_ahw(void)
+void get_height_weight(void)
{
- int h_percent; /* ¿ÈŤ¬Ê¿¶Ñ¤Ë¤¯¤é¤Ù¤Æ¤É¤Î¤¯¤é¤¤°ã¤¦¤«. */
+ int h_percent; /* ¿ÈŤ¬Ê¿¶Ñ¤Ë¤¯¤é¤Ù¤Æ¤É¤Î¤¯¤é¤¤°ã¤¦¤«. */
-
- /* Calculate the age */
- p_ptr->age = rp_ptr->b_age + randint1(rp_ptr->m_age);
-
- /* Calculate the height/weight for males */
- if (p_ptr->psex == SEX_MALE)
+ /* Calculate the height/weight for males */
+ if (p_ptr->psex == SEX_MALE)
{
- p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
- , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
+ p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
+ h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
+ p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
+ , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
}
- /* Calculate the height/weight for females */
- else if (p_ptr->psex == SEX_FEMALE)
+ /* Calculate the height/weight for females */
+ else if (p_ptr->psex == SEX_FEMALE)
{
- p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
- , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
+ p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
+ h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
+ p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
+ , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
}
}
+
+/*
+ * Computes character's age, height, and weight
+ * by henkma
+ */
+static void get_ahw(void)
+{
+ /* Get character's age */
+ p_ptr->age = rp_ptr->b_age + randint1(rp_ptr->m_age);
+
+ /* Get character's height and weight */
+ get_height_weight();
+}
+
+
/*
* Get the player's starting money
*/
#ifdef ALLOW_AUTOROLLER
static bool get_chara_limits(void)
{
+#define MAXITEMS 8
+
int i, j, m, cs, os;
- int mval[6], cval[6];
+ int mval[MAXITEMS], cval[MAXITEMS];
int max_percent, min_percent;
char c;
char buf[80], cur[80];
- char param[3][80] = {
+ cptr itemname[] = {
#ifdef JP
+ "ǯÎð",
"¿ÈĹ(¥¤¥ó¥Á)",
"ÂνÅ(¥Ý¥ó¥É)",
"¼Ò²ñŪÃÏ°Ì"
#else
+ "age",
"height",
"weight",
"social class"
#endif
/* Output the maximum stats */
- for (i = 0; i < 6; i++)
+ for (i = 0; i < MAXITEMS; i++)
{
/* Obtain the "maximal" stat */
switch (i)
{
- case 0: /* Minimum height */
+ case 0: /* Minimum age */
+ m = rp_ptr->b_age + 1;
+ break;
+ case 1: /* Maximum age */
+ m = rp_ptr->b_age + rp_ptr->m_age;
+ break;
+
+ case 2: /* Minimum height */
if (p_ptr->psex == SEX_MALE) m = rp_ptr->m_b_ht-rp_ptr->m_m_ht*4+1;
else m = rp_ptr->f_b_ht-rp_ptr->f_m_ht*4+1;
break;
- case 1: /* Maximum height */
+ case 3: /* Maximum height */
if (p_ptr->psex == SEX_MALE) m = rp_ptr->m_b_ht+rp_ptr->m_m_ht*4-1;
else m = rp_ptr->f_b_ht+rp_ptr->f_m_ht*4-1;
break;
- case 2: /* Minimum weight */
+ case 4: /* Minimum weight */
if (p_ptr->psex == SEX_MALE) m = (rp_ptr->m_b_wt * min_percent / 100) - (rp_ptr->m_m_wt * min_percent / 75) +1;
else m = (rp_ptr->f_b_wt * min_percent / 100) - (rp_ptr->f_m_wt * min_percent / 75) +1;
break;
- case 3: /* Maximum weight */
+ case 5: /* Maximum weight */
if (p_ptr->psex == SEX_MALE) m = (rp_ptr->m_b_wt * max_percent / 100) + (rp_ptr->m_m_wt * max_percent / 75) -1;
else m = (rp_ptr->f_b_wt * max_percent / 100) + (rp_ptr->f_m_wt * max_percent / 75) -1;
break;
- case 4: /* Minimum social class */
+ case 6: /* Minimum social class */
m = 1;
break;
- case 5: /* Maximum social class */
+ case 7: /* Maximum social class */
m = 100;
break;
default:
cval[i] = m;
}
- for (i = 0; i < 3; i++)
+ for (i = 0; i < 4; i++)
{
/* Prepare a prompt */
- sprintf(buf, "%-12s (%3d - %3d)", param[i], mval[i*2], mval[i*2+1]);
+ sprintf(buf, "%-12s (%3d - %3d)", itemname[i], mval[i*2], mval[i*2+1]);
/* Dump the prompt */
put_str(buf, 14 + i, 20);
/* Get a minimum stat */
cs = 0;
- os = 6;
+ os = MAXITEMS;
while (TRUE)
{
/* Move Cursol */
if (cs != os)
{
- if(os == 6)
- {
#ifdef JP
- c_put_str(TERM_WHITE, "·èÄꤹ¤ë", 18, 35);
+ const char accept[] = "·èÄꤹ¤ë";
#else
- c_put_str(TERM_WHITE, "Accept", 18, 35);
+ const char accept[] = "Accept";
#endif
+ if(os == MAXITEMS)
+ {
+ c_put_str(TERM_WHITE, accept, 19, 35);
}
- else if(os < 6)
+ else
+ {
c_put_str(TERM_WHITE, cur, 14 + os/2, 45 + 8 * (os%2));
+ }
- if(cs == 6)
+ if(cs == MAXITEMS)
{
-#ifdef JP
- c_put_str(TERM_YELLOW, "·èÄꤹ¤ë", 18, 35);
-#else
- c_put_str(TERM_YELLOW, "Accept", 18, 35);
-#endif
+ c_put_str(TERM_YELLOW, accept, 19, 35);
}
else
{
case ' ':
case '\r':
case '\n':
- if(cs == 6) break;
+ if(cs == MAXITEMS) break;
cs++;
c = '6';
break;
break;
case '2':
case 'j':
- if (cs < 6) cs += 2;
- if (cs > 6) cs = 6;
+ if (cs < MAXITEMS) cs += 2;
+ if (cs > MAXITEMS) cs = MAXITEMS;
break;
case '4':
case 'h':
break;
case '6':
case 'l':
- if (cs < 6) cs++;
+ if (cs < MAXITEMS) cs++;
break;
case '-':
case '<':
- if (cs != 6)
+ if (cs != MAXITEMS)
{
if(cs%2)
{
break;
case '+':
case '>':
- if (cs != 6)
+ if (cs != MAXITEMS)
{
if(cs%2)
{
}
break;
case 'm':
- if(cs != 6)
+ if(cs != MAXITEMS)
{
if(cs%2)
{
}
break;
case 'n':
- if(cs != 6)
+ if(cs != MAXITEMS)
{
if(cs%2)
{
bell();
break;
}
- if(c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == 6))break;
+ if(c == ESCAPE || ((c == ' ' || c == '\r' || c == '\n') && cs == MAXITEMS))break;
}
/* Input the minimum stats */
- for (i = 0; i < 6; i++)
- {
- /* Save the minimum stat */
- chara_limit[i] = (cval[i] > 0) ? cval[i] : 0;
- }
+ chara_limit.agemin = cval[0];
+ chara_limit.agemax = cval[1];
+ chara_limit.htmin = cval[2];
+ chara_limit.htmax = cval[3];
+ chara_limit.wtmin = cval[4];
+ chara_limit.wtmax = cval[5];
+ chara_limit.scmin = cval[6];
+ chara_limit.scmax = cval[7];
+
return TRUE;
}
#endif
-static char histpref_buf[240];
+#define HISTPREF_LIMIT 1024
+static char *histpref_buf = NULL;
+/*
+ * Hook function for reading the histpref.prf file.
+ */
void add_history_from_pref_line(cptr t)
{
- int limit = (sizeof histpref_buf) - 1;
- int i;
-
- for (i = strlen(histpref_buf); *t && (i < limit); t++)
- {
-#ifdef JP
- if (iskanji(*t) || isprint(*t))
-#else
- if (isprint(*t))
-#endif
- {
-#ifdef JP
- if (iskanji(*t))
- {
- if (i + 1 >= limit) break;
- histpref_buf[i++] = *(t++);
- }
-#endif
- histpref_buf[i++] = *t;
- }
- }
+ /* Do nothing if the buffer is not ready */
+ if (!histpref_buf) return;
- /* Terminate */
- histpref_buf[(i < limit) ? i : limit] = '\0';
+ my_strcat(histpref_buf, t, HISTPREF_LIMIT);
}
int i, j, n;
char *s, *t;
char temp[64 * 4];
+ char histbuf[HISTPREF_LIMIT];
#ifdef JP
if (!get_check("À¸¤¤Î©¤ÁÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return FALSE;
if (!get_check("Load background history preference file? ")) return FALSE;
#endif
- /* Init buffer */
- histpref_buf[0] = '\0';
+ /* Prepare the buffer */
+ histbuf[0] = '\0';
+ histpref_buf = histbuf;
#ifdef JP
sprintf(buf, "histedit-%s.prf", player_name);
#endif
msg_print(NULL);
- /* Terminate buffer */
- histpref_buf[0] = '\0';
+ /* Kill the buffer */
+ histpref_buf = NULL;
+
return FALSE;
}
}
}
- /* Turn 0 to space */
+ /* Fill the remaining spaces */
for (i = 0; i < 4; i++)
{
for (j = 0; p_ptr->history[i][j]; j++) /* loop */;
p_ptr->history[i][59] = '\0';
}
- /* Terminate buffer */
- histpref_buf[0] = '\0';
+ /* Kill the buffer */
+ histpref_buf = NULL;
return TRUE;
}
if (autochara)
{
- if ((p_ptr->ht < chara_limit[0]) || (p_ptr->ht > chara_limit[1])) accept = FALSE;
- if ((p_ptr->wt < chara_limit[2]) || (p_ptr->wt > chara_limit[3])) accept = FALSE;
- if ((p_ptr->sc < chara_limit[4]) || (p_ptr->sc > chara_limit[5])) accept = FALSE;
+ if ((p_ptr->age < chara_limit.agemin) || (p_ptr->age > chara_limit.agemax)) accept = FALSE;
+ if ((p_ptr->ht < chara_limit.htmin) || (p_ptr->ht > chara_limit.htmax)) accept = FALSE;
+ if ((p_ptr->wt < chara_limit.wtmin) || (p_ptr->wt > chara_limit.wtmax)) accept = FALSE;
+ if ((p_ptr->sc < chara_limit.scmin) || (p_ptr->sc > chara_limit.scmax)) accept = FALSE;
}
if (accept) break;
}
o_ptr->ident |= (IDENT_SENSE);
}
+ /* The Stone Mask make the player turn into a vampire! */
if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
{
- int h_percent;
- if (p_ptr->prace < 32)
- {
- p_ptr->old_race1 |= 1L << p_ptr->prace;
- }
- else
- {
- p_ptr->old_race2 |= 1L << (p_ptr->prace-32);
- }
- p_ptr->prace = RACE_VAMPIRE;
-#ifdef JP
- msg_format("¤¢¤Ê¤¿¤ÏµÛ·ìµ´¤ËÊѲ½¤·¤¿¡ª");
-#else
- msg_format("You polymorphed into a vampire!");
-#endif
-
- rp_ptr = &race_info[p_ptr->prace];
-
- /* Experience factor */
- p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
-
- /* Calculate the height/weight for males */
- if (p_ptr->psex == SEX_MALE)
- {
- p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
- , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
- }
-
- /* Calculate the height/weight for females */
- else if (p_ptr->psex == SEX_FEMALE)
- {
- p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
- , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
- }
-
- check_experience();
-
- /* Hitdice */
- if (p_ptr->pclass == CLASS_SORCERER)
- p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
- else
- p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-
- do_cmd_rerate(FALSE);
-
- p_ptr->redraw |= (PR_BASIC);
-
- p_ptr->update |= (PU_BONUS);
-
- handle_stuff();
- lite_spot(py, px);
+ /* Turn into a vampire */
+ change_race(RACE_VAMPIRE, "");
}
/* Recalculate bonuses */
}
+/*
+ * Change player race
+ */
+void change_race(int new_race, cptr effect_msg)
+{
+ cptr title = race_info[new_race].title;
+
+#ifdef JP
+ msg_format("¤¢¤Ê¤¿¤Ï%s%s¤ËÊѲ½¤·¤¿¡ª", effect_msg, title);
+#else
+ msg_format("You turn into %s %s%s!", (!effect_msg[0] && is_a_vowel(title[0]) ? "an" : "a"), effect_msg, title);
+#endif
+
+ chg_virtue(V_CHANCE, 2);
+
+ if (p_ptr->prace < 32)
+ {
+ p_ptr->old_race1 |= 1L << p_ptr->prace;
+ }
+ else
+ {
+ p_ptr->old_race2 |= 1L << (p_ptr->prace-32);
+ }
+ p_ptr->prace = new_race;
+ rp_ptr = &race_info[p_ptr->prace];
+
+ /* Experience factor */
+ p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
+
+ /*
+ * The speed bonus of Klackons and Sprites are disabled
+ * and the experience penalty is decreased.
+ */
+ if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && ((p_ptr->prace == RACE_KLACKON) || (p_ptr->prace == RACE_SPRITE)))
+ p_ptr->expfact -= 15;
+
+ /* Get character's height and weight */
+ get_height_weight();
+
+ /* Hitdice */
+ if (p_ptr->pclass == CLASS_SORCERER)
+ p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
+ else
+ p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
+
+ do_cmd_rerate(FALSE);
+
+ /* The experience level may be modified */
+ check_experience();
+
+ p_ptr->redraw |= (PR_BASIC);
+
+ p_ptr->update |= (PU_BONUS);
+
+ handle_stuff();
+
+ /* Player's graphic tile may change */
+ lite_spot(py, px);
+}
+
+
void do_poly_self(void)
{
int power = p_ptr->lev;
if ((power > randint0(20)) && one_in_(3) && (p_ptr->prace != RACE_ANDROID))
{
char effect_msg[80] = "";
- int new_race, expfact, goalexpfact, h_percent;
+ int new_race, expfact, goalexpfact;
/* Some form of racial polymorph... */
power -= 10;
}
while (((new_race == p_ptr->prace) && (expfact > goalexpfact)) || (new_race == RACE_ANDROID));
-#ifdef JP
- msg_format("¤¢¤Ê¤¿¤Ï%s%s¤ËÊѲ½¤·¤¿¡ª", effect_msg,
- race_info[new_race].title);
-#else
- if (effect_msg[0])
- {
- msg_format("You turn into a%s %s!",
- ((new_race == RACE_AMBERITE || new_race == RACE_ELF
- || new_race == RACE_IMP) ? "n" : ""),
- race_info[new_race].title);
- }
- else
- {
- msg_format("You turn into a %s%s!", effect_msg,
- race_info[new_race].title);
- }
-#endif
-
- chg_virtue(V_CHANCE, 2);
-
- if (p_ptr->prace < 32)
- {
- p_ptr->old_race1 |= 1L << p_ptr->prace;
- }
- else
- {
- p_ptr->old_race2 |= 1L << (p_ptr->prace-32);
- }
- p_ptr->prace = new_race;
- rp_ptr = &race_info[p_ptr->prace];
-
- /* Experience factor */
- p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
-
- if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && ((p_ptr->prace == RACE_KLACKON) || (p_ptr->prace == RACE_SPRITE)))
- p_ptr->expfact -= 15;
-
-
- /* Calculate the height/weight for males */
- if (p_ptr->psex == SEX_MALE)
- {
- p_ptr->ht = randnor(rp_ptr->m_b_ht, rp_ptr->m_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->m_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->m_b_wt) * h_percent /100
- , (int)(rp_ptr->m_m_wt) * h_percent / 300 );
- }
-
- /* Calculate the height/weight for females */
- else if (p_ptr->psex == SEX_FEMALE)
- {
- p_ptr->ht = randnor(rp_ptr->f_b_ht, rp_ptr->f_m_ht);
- h_percent = (int)(p_ptr->ht) * 100 / (int)(rp_ptr->f_b_ht);
- p_ptr->wt = randnor((int)(rp_ptr->f_b_wt) * h_percent /100
- , (int)(rp_ptr->f_m_wt) * h_percent / 300 );
- }
-
- check_experience();
-
- /* Hitdice */
- if (p_ptr->pclass == CLASS_SORCERER)
- p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
- else
- p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
-
- do_cmd_rerate(FALSE);
-
- p_ptr->redraw |= (PR_BASIC);
-
- p_ptr->update |= (PU_BONUS);
-
- handle_stuff();
- lite_spot(py, px);
+ change_race(new_race, effect_msg);
}
if ((power > randint0(30)) && one_in_(6))