OSDN Git Service

消費魔力減少フラグと (領域魔法であれば) 魔法熟練度から導かれる消費魔力計算を
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 3 May 2003 07:09:00 +0000 (07:09 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 3 May 2003 07:09:00 +0000 (07:09 +0000)
1関数にまとめた.

src/cmd5.c
src/dungeon.c
src/externs.h
src/mspells3.c
src/spells3.c

index c084160..bcbb7dc 100644 (file)
@@ -59,7 +59,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        int         spell = -1;
        int         num = 0;
        int         ask = TRUE;
-       int         shouhimana;
+       int         need_mana;
        byte        spells[64];
        bool        flag, redraw, okay;
        char        choice;
@@ -280,19 +280,14 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                                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 */
@@ -300,11 +295,11 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        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
 
@@ -4709,7 +4704,7 @@ void do_cmd_cast(void)
        int     chance;
        int     increment = 0;
        int     use_realm;
-       int     shouhimana;
+       int     need_mana;
        bool cast;
 
        cptr prayer;
@@ -4850,15 +4845,10 @@ s = "
        }
 
        /* 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();
 
@@ -5089,32 +5079,32 @@ msg_print("An infernal sound echoed.");
                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)
@@ -5147,16 +5137,16 @@ msg_print("An infernal sound echoed.");
        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;
index c987c6b..51504bc 100644 (file)
@@ -1450,38 +1450,35 @@ static void recharged_notice(object_type *o_ptr)
 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;
@@ -1503,14 +1500,14 @@ static void check_music(void)
                        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]);
 }
index e6d1fd8..305e762 100644 (file)
@@ -1101,6 +1101,7 @@ extern bool pulish_shield(void);
 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);
index 849965c..d286ae0 100644 (file)
@@ -560,7 +560,7 @@ put_str("MP 
                                /* 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;
@@ -584,16 +584,12 @@ put_str("MP 
                                        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 */
@@ -629,7 +625,7 @@ put_str("MP 
 
                                        /* 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);
                                }
@@ -1989,7 +1985,7 @@ bool do_cmd_cast_learned(void)
        int             plev = p_ptr->lev;
        monster_power   spell;
        bool            cast;
-       int             shouhimana;
+       int             need_mana;
 
 
        /* not if confused */
@@ -2009,15 +2005,10 @@ msg_print("
 
        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
@@ -2056,9 +2047,9 @@ if (!get_check("
        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 */
@@ -2105,14 +2096,14 @@ msg_print("
        }
 
        /* 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;
index 1a75e9f..9683e6e 100644 (file)
@@ -3906,13 +3906,40 @@ s16b experience_of_spell(int spell, int use_realm)
 
 
 /*
+ * 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;
 
 
@@ -3944,18 +3971,12 @@ s16b spell_chance(int spell, int use_realm)
                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;
@@ -4404,7 +4425,7 @@ void print_spells(int target_spell, byte *spells, int num, int y, int x, int use
        char            info[80];
        char            out_val[160];
        byte            line_attr;
-       int             shouhimana;
+       int             need_mana;
        char            ryakuji[5];
        char            buf[256];
        bool max = FALSE;
@@ -4462,19 +4483,13 @@ put_str(buf, y, x + 29);
                }
 
                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;
@@ -4606,14 +4621,14 @@ comment = " ̤
                {
                        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);
        }