OSDN Git Service

Vanillaにならって、キャラクターの状態を表わすグローバル変数の多くを
[hengband/hengband.git] / src / spells3.c
index a23d666..789741d 100644 (file)
@@ -3861,8 +3861,8 @@ strcpy(name, "(Ƚ
 
                        /* Forgotten */
                        else if ((j < 1) ?
-                               ((spell_forgotten1 & (1L << i))) :
-                               ((spell_forgotten2 & (1L << (i % 32)))))
+                               ((p_ptr->spell_forgotten1 & (1L << i))) :
+                               ((p_ptr->spell_forgotten2 & (1L << (i % 32)))))
                        {
                                /* Forgotten */
                                a = TERM_ORANGE;
@@ -3870,8 +3870,8 @@ strcpy(name, "(Ƚ
 
                        /* Unknown */
                        else if (!((j < 1) ?
-                               (spell_learned1 & (1L << i)) :
-                               (spell_learned2 & (1L << (i % 32)))))
+                               (p_ptr->spell_learned1 & (1L << i)) :
+                               (p_ptr->spell_learned2 & (1L << (i % 32)))))
                        {
                                /* Unknown */
                                a = TERM_RED;
@@ -3879,8 +3879,8 @@ strcpy(name, "(Ƚ
 
                        /* Untried */
                        else if (!((j < 1) ?
-                               (spell_worked1 & (1L << i)) :
-                               (spell_worked2 & (1L << (i % 32)))))
+                               (p_ptr->spell_worked1 & (1L << i)) :
+                               (p_ptr->spell_worked2 & (1L << (i % 32)))))
                        {
                                /* Untried */
                                a = TERM_YELLOW;
@@ -3903,6 +3903,18 @@ strcpy(name, "(Ƚ
 }
 
 
+/*
+ * Returns experience of a spell
+ */
+s16b experience_of_spell(int spell, int realm)
+{
+       if (p_ptr->pclass == CLASS_SORCERER) return 1600;
+       else if (p_ptr->pclass == CLASS_RED_MAGE) return 1200;
+       else if (realm+1 == p_ptr->realm1) return p_ptr->spell_exp[spell];
+       else if (realm+1 == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
+       else return 0;
+}
+
 
 /*
  * Returns spell chance of failure for spell -RAK-
@@ -3940,18 +3952,14 @@ s16b spell_chance(int spell, int realm)
        chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
 
        if (p_ptr->riding)
-               chance += (MAX(r_info[m_list[p_ptr->riding].r_idx].level-skill_exp[GINOU_RIDING]/100-10,0));
-
-       if (p_ptr->pclass == CLASS_SORCERER)
-               shouhimana = s_ptr->smana*2200 + 2399;
-       else if (p_ptr->pclass == CLASS_RED_MAGE)
-               shouhimana = s_ptr->smana*2600 + 2399;
-       else if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
-               shouhimana = (s_ptr->smana*(3800-spell_exp[((p_ptr->realm1 == realm+1) ? spell: spell+32)])+2399);
-       else shouhimana = s_ptr->smana*3800;
-       if(p_ptr->dec_mana)
-               shouhimana *= 3;
+               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, realm)) + 2399;
+
+       if(p_ptr->dec_mana) shouhimana *= 3;
        else shouhimana *= 4;
+
        shouhimana /= 9600;
        if(shouhimana < 1) shouhimana = 1;
 
@@ -4001,8 +4009,9 @@ s16b spell_chance(int spell, int realm)
 
        if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
        {
-               if(spell_exp[((p_ptr->realm1 == realm+1) ? spell: spell+32)]>1399) chance--;
-               if(spell_exp[((p_ptr->realm1 == realm+1) ? spell: spell+32)]>1599) chance--;
+               s16b exp = experience_of_spell(spell, realm);
+               if(exp > 1399) chance--;
+               if(exp > 1599) chance--;
        }
        if(p_ptr->dec_mana) chance--;
        if (p_ptr->heavy_spell) chance += 5;
@@ -4039,8 +4048,8 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
 
        /* Spell is forgotten */
        if ((realm == p_ptr->realm2 - 1) ?
-           (spell_forgotten2 & (1L << spell)) :
-           (spell_forgotten1 & (1L << spell)))
+           (p_ptr->spell_forgotten2 & (1L << spell)) :
+           (p_ptr->spell_forgotten1 & (1L << spell)))
        {
                /* Never okay */
                return (FALSE);
@@ -4051,8 +4060,8 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
 
        /* Spell is learned */
        if ((realm == p_ptr->realm2 - 1) ?
-           (spell_learned2 & (1L << spell)) :
-           (spell_learned1 & (1L << spell)))
+           (p_ptr->spell_learned2 & (1L << spell)) :
+           (p_ptr->spell_learned1 & (1L << spell)))
        {
                /* Always true */
                return (!study_pray);
@@ -4412,7 +4421,7 @@ void print_spells(int target_spell, byte *spells, int num, int y, int x, int rea
        bool max = FALSE;
 
 
-       if (((realm < 0) || (realm > MAX_REALM - 1)) && wizard)
+       if (((realm < 0) || (realm > MAX_REALM - 1)) && p_ptr->wizard)
 #ifdef JP
 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
 #else
@@ -4467,36 +4476,34 @@ put_str(buf, y, x + 29);
                        shouhimana = s_ptr->smana;
                else
                {
-                       if (p_ptr->pclass == CLASS_SORCERER)
-                               shouhimana = s_ptr->smana*2200 + 2399;
-                       else if (p_ptr->pclass == CLASS_RED_MAGE)
-                               shouhimana = s_ptr->smana*2600 + 2399;
-                       else if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
-                               shouhimana = (s_ptr->smana*(3800-spell_exp[(spell+increment)])+2399);
-                       else
-                               shouhimana = s_ptr->smana*3800+2399;
-                       if(p_ptr->dec_mana)
-                               shouhimana *= 3;
+                       s16b exp = experience_of_spell(spell, 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;
-               }
 
-               if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0;
-               else if (spell_exp[spell+increment]<900) shougou = 0;
-               else if (spell_exp[spell+increment]<1200) shougou = 1;
-               else if (spell_exp[spell+increment]<1400) shougou = 2;
-               else if (spell_exp[spell+increment]<1600) shougou = 3;
-               else shougou = 4;
-               max = FALSE;
-               if (!increment && (shougou == 4)) max = TRUE;
-               else if ((increment == 32) && (shougou == 3)) max = TRUE;
-               else if (s_ptr->slevel >= 99) max = TRUE;
-               else if (p_ptr->pclass == CLASS_RED_MAGE) max = TRUE;
-
-               strncpy(ryakuji,shougou_moji[shougou],4);
-               ryakuji[3] = ']';
-               ryakuji[4] = '\0';
+                       if ((increment == 64) || (s_ptr->slevel >= 99)) shougou = 0;
+                       else if (exp < 900) shougou = 0;
+                       else if (exp < 1200) shougou = 1;
+                       else if (exp < 1400) shougou = 2;
+                       else if (exp < 1600) shougou = 3;
+                       else shougou = 4;
+
+                       max = FALSE;
+                       if (!increment && (shougou == 4)) max = TRUE;
+                       else if ((increment == 32) && (shougou == 3)) max = TRUE;
+                       else if (s_ptr->slevel >= 99) max = TRUE;
+                       else if (p_ptr->pclass == CLASS_RED_MAGE) max = TRUE;
+
+                       strncpy(ryakuji,shougou_moji[shougou],4);
+                       ryakuji[3] = ']';
+                       ryakuji[4] = '\0';
+               }
 
                if (use_menu && target_spell)
                {
@@ -4569,8 +4576,8 @@ comment = " ̤
                        line_attr = TERM_L_BLUE;
                }
                else if ((realm + 1 == p_ptr->realm1) ?
-                   ((spell_forgotten1 & (1L << spell))) :
-                   ((spell_forgotten2 & (1L << spell))))
+                   ((p_ptr->spell_forgotten1 & (1L << spell))) :
+                   ((p_ptr->spell_forgotten2 & (1L << spell))))
                {
 #ifdef JP
 comment = " ËºµÑ";
@@ -4581,8 +4588,8 @@ comment = " ˺
                        line_attr = TERM_YELLOW;
                }
                else if (!((realm + 1 == p_ptr->realm1) ?
-                   (spell_learned1 & (1L << spell)) :
-                   (spell_learned2 & (1L << spell))))
+                   (p_ptr->spell_learned1 & (1L << spell)) :
+                   (p_ptr->spell_learned2 & (1L << spell))))
                {
 #ifdef JP
 comment = " Ì¤ÃÎ";
@@ -4593,8 +4600,8 @@ comment = " ̤
                        line_attr = TERM_L_BLUE;
                }
                else if (!((realm + 1 == p_ptr->realm1) ?
-                   (spell_worked1 & (1L << spell)) :
-                   (spell_worked2 & (1L << spell))))
+                   (p_ptr->spell_worked1 & (1L << spell)) :
+                   (p_ptr->spell_worked2 & (1L << spell))))
                {
 #ifdef JP
 comment = " Ì¤·Ð¸³";