1関数にまとめた.
int spell = -1;
int num = 0;
int ask = TRUE;
- int shouhimana;
+ int need_mana;
byte spells[64];
bool flag, redraw, okay;
char choice;
s_ptr = &mp_ptr->info[use_realm - 1][spell];
}
+ /* Extract mana consumption rate */
if (use_realm == REALM_HISSATSU)
{
- shouhimana = s_ptr->smana;
+ need_mana = s_ptr->smana;
}
else
{
- /* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
- if(p_ptr->dec_mana)
- shouhimana *= 3;
- else shouhimana *= 4;
- shouhimana /= 9600;
- if(shouhimana < 1) shouhimana = 1;
+ need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
}
/* Prompt */
jverb1( prompt, jverb_buf );
/* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
(void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
- spell_names[technic2magic(use_realm)-1][spell], shouhimana,
+ spell_names[technic2magic(use_realm)-1][spell], need_mana,
spell_chance(spell, use_realm),jverb_buf);
#else
(void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
- prompt, spell_names[technic2magic(use_realm)-1][spell], shouhimana,
+ prompt, spell_names[technic2magic(use_realm)-1][spell], need_mana,
spell_chance(spell, use_realm));
#endif
int chance;
int increment = 0;
int use_realm;
- int shouhimana;
+ int need_mana;
bool cast;
cptr prayer;
}
/* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, realm)) + 2399;
- if(p_ptr->dec_mana)
- shouhimana *= 3;
- else shouhimana *= 4;
- shouhimana /= 9600;
- if(shouhimana < 1) shouhimana = 1;
+ need_mana = mod_need_mana(s_ptr->smana, spell, realm);
/* Verify "dangerous" spells */
- if (shouhimana > p_ptr->csp)
+ if (need_mana > p_ptr->csp)
{
if (flush_failure) flush();
switch (realm)
{
case REALM_LIFE:
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_TEMPERANCE, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_COMPASSION, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_VITALITY, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_DILIGENCE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
break;
case REALM_DEATH:
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_UNLIFE, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, -1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, -1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_VITALITY, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
break;
case REALM_DAEMON:
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, -1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, -1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HONOUR, -1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_TEMPERANCE, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
break;
case REALM_CRUSADE:
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_FAITH, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_JUSTICE, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_SACRIFICE, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HONOUR, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
break;
case REALM_NATURE:
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_NATURE, 1);
- if (randint1(100 + p_ptr->lev) < shouhimana) chg_virtue(V_HARMONY, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
+ if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
break;
}
if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
energy_use = 100;
/* Sufficient mana */
- if (shouhimana <= p_ptr->csp)
+ if (need_mana <= p_ptr->csp)
{
/* Use some mana */
- p_ptr->csp -= shouhimana;
+ p_ptr->csp -= need_mana;
}
/* Over-exert the player */
else
{
- int oops = shouhimana;
+ int oops = need_mana;
/* No mana left */
p_ptr->csp = 0;
static void check_music(void)
{
magic_type *s_ptr;
- u32b shouhimana;
+ int spell;
+ u32b need_mana;
/* Music singed by player */
if(p_ptr->pclass != CLASS_BARD) return;
if(!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
- s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][p_ptr->magic_num2[0]];
+ spell = p_ptr->magic_num2[0];
+ s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
- shouhimana = (s_ptr->smana*(3800-p_ptr->spell_exp[p_ptr->magic_num2[0]])+2399);
- if(p_ptr->dec_mana)
- shouhimana *= 3;
- else shouhimana *= 4;
- shouhimana /= 9600;
- if(shouhimana < 1) shouhimana = 1;
- shouhimana *= 0x8000;
- if (((u16b)(p_ptr->csp) < (shouhimana / 0x10000)) || (p_ptr->anti_magic))
+ need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
+ need_mana *= 0x8000;
+ if (((u16b)(p_ptr->csp) < (need_mana / 0x10000)) || (p_ptr->anti_magic))
{
stop_singing();
return;
}
else
{
- p_ptr->csp -= (u16b) (shouhimana / 0x10000);
- shouhimana = (shouhimana & 0xffff);
- if (p_ptr->csp_frac < shouhimana)
+ p_ptr->csp -= (u16b) (need_mana / 0x10000);
+ need_mana = (need_mana & 0xffff);
+ if (p_ptr->csp_frac < need_mana)
{
p_ptr->csp--;
- p_ptr->csp_frac += (u16b)(0x10000L - shouhimana);
+ p_ptr->csp_frac += (u16b)(0x10000L - need_mana);
}
else
{
- p_ptr->csp_frac -= (u16b)shouhimana;
+ p_ptr->csp_frac -= (u16b)need_mana;
}
p_ptr->redraw |= PR_MANA;
p_ptr->redraw |= (PR_STATUS);
}
}
- if (p_ptr->spell_exp[p_ptr->magic_num2[0]] < 900)
- p_ptr->spell_exp[p_ptr->magic_num2[0]]+=5;
- else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1200)
- {if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;}
- else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1400)
- {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;}
- else if(p_ptr->spell_exp[p_ptr->magic_num2[0]] < 1600)
- {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[p_ptr->magic_num2[0]]+=1;}
+ if (p_ptr->spell_exp[spell] < 900)
+ p_ptr->spell_exp[spell]+=5;
+ else if(p_ptr->spell_exp[spell] < 1200)
+ {if (one_in_(2) && (dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) p_ptr->spell_exp[spell]+=1;}
+ else if(p_ptr->spell_exp[spell] < 1400)
+ {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) p_ptr->spell_exp[spell]+=1;}
+ else if(p_ptr->spell_exp[spell] < 1600)
+ {if (one_in_(5) && ((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell]+=1;}
gere_music(p_ptr->magic_num1[0]);
}
extern bool potion_smash_effect(int who, int y, int x, int k_idx);
extern void display_spell_list(void);
extern s16b experience_of_spell(int spell, int realm);
+extern int mod_need_mana(int need_mana, int spell, int realm);
extern s16b spell_chance(int spell,int realm);
extern bool spell_okay(int spell, bool learned, bool study_pray, int realm);
extern void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm);
/* Dump the spells */
for (i = 0; i < num; i++)
{
- int shouhimana;
+ int need_mana;
prt("", y + i + 1, x);
if (!p_ptr->magic_num2[spellnum[i]]) continue;
else if (p_ptr->easy_spell) chance-=3;
else if (p_ptr->dec_mana) chance-=2;
- shouhimana = monster_powers[spellnum[i]].smana;
- if (p_ptr->dec_mana)
- {
- shouhimana = (shouhimana + 1) * 3 / 4;
- }
+ need_mana = mod_need_mana(monster_powers[spellnum[i]].smana, 0, REALM_NONE);
/* Not enough mana to cast */
- if (shouhimana > p_ptr->csp)
+ if (need_mana > p_ptr->csp)
{
- chance += 5 * (shouhimana - p_ptr->csp);
+ chance += 5 * (need_mana - p_ptr->csp);
}
/* Extract the minimum failure rate */
/* Dump the spell --(-- */
strcat(psi_desc, format(" %-26s %3d %3d%%%s",
- spell.name, shouhimana,
+ spell.name, need_mana,
chance, comment));
prt(psi_desc, y + i + 1, x);
}
int plev = p_ptr->lev;
monster_power spell;
bool cast;
- int shouhimana;
+ int need_mana;
/* not if confused */
spell = monster_powers[n];
- shouhimana = spell.smana;
-
- if (p_ptr->dec_mana)
- {
- shouhimana = (shouhimana + 1) * 3 / 4;
- }
+ need_mana = mod_need_mana(spell.smana, 0, REALM_NONE);
/* Verify "dangerous" spells */
- if (shouhimana > p_ptr->csp)
+ if (need_mana > p_ptr->csp)
{
/* Warning */
#ifdef JP
else if (p_ptr->dec_mana) chance-=2;
/* Not enough mana to cast */
- if (shouhimana > p_ptr->csp)
+ if (need_mana > p_ptr->csp)
{
- chance += 5 * (shouhimana - p_ptr->csp);
+ chance += 5 * (need_mana - p_ptr->csp);
}
/* Extract the minimum failure rate */
}
/* Sufficient mana */
- if (shouhimana <= p_ptr->csp)
+ if (need_mana <= p_ptr->csp)
{
/* Use some mana */
- p_ptr->csp -= shouhimana;
+ p_ptr->csp -= need_mana;
}
else
{
- int oops = shouhimana;
+ int oops = need_mana;
/* No mana left */
p_ptr->csp = 0;
/*
+ * Modify mana consumption rate using spell exp and p_ptr->dec_mana
+ */
+int mod_need_mana(int need_mana, int spell, int realm)
+{
+ /* Realm magic */
+ if ((realm > REALM_NONE) && (realm <= MAX_REALM))
+ {
+ need_mana = need_mana * (3800 - experience_of_spell(spell, realm)) + 2399;
+
+ if (p_ptr->dec_mana) need_mana *= 3;
+ else need_mana *= 4;
+
+ need_mana /= 9600;
+ if (need_mana < 1) need_mana = 1;
+ }
+
+ /* Non-realm magic */
+ else
+ {
+ if (p_ptr->dec_mana) need_mana = (need_mana + 1) * 3 / 4;
+ }
+
+ return need_mana;
+}
+
+
+/*
* Returns spell chance of failure for spell -RAK-
*/
s16b spell_chance(int spell, int use_realm)
{
int chance, minfail;
magic_type *s_ptr;
- int shouhimana;
+ int need_mana;
int penalty = (mp_ptr->spell_stat == A_WIS) ? 10 : 4;
chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-p_ptr->skill_exp[GINOU_RIDING]/100-10,0));
/* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
-
- if(p_ptr->dec_mana) shouhimana *= 3;
- else shouhimana *= 4;
-
- shouhimana /= 9600;
- if(shouhimana < 1) shouhimana = 1;
+ need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
/* Not enough mana to cast */
- if (shouhimana > p_ptr->csp)
+ if (need_mana > p_ptr->csp)
{
- chance += 5 * (shouhimana - p_ptr->csp);
+ chance += 5 * (need_mana - p_ptr->csp);
}
chance += p_ptr->to_m_chance;
char info[80];
char out_val[160];
byte line_attr;
- int shouhimana;
+ int need_mana;
char ryakuji[5];
char buf[256];
bool max = FALSE;
}
if (use_realm == REALM_HISSATSU)
- shouhimana = s_ptr->smana;
+ need_mana = s_ptr->smana;
else
{
s16b exp = experience_of_spell(spell, use_realm);
/* Extract mana consumption rate */
- shouhimana = s_ptr->smana*(3800 - exp) + 2399;
-
- if(p_ptr->dec_mana) shouhimana *= 3;
- else shouhimana *= 4;
-
- shouhimana /= 9600;
- if(shouhimana < 1) shouhimana = 1;
+ need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0;
else if (exp < 900) shougou = 0;
{
strcat(out_val, format("%-25s %2d %4d",
spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
- s_ptr->slevel, shouhimana));
+ s_ptr->slevel, need_mana));
}
else
{
strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
(max ? '!' : ' '), ryakuji,
- s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
+ s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
}
c_prt(line_attr, out_val, y + i + 1, x);
}