OSDN Git Service

Leon氏の勧めに従って、Vanillaのコードと同様に各ソースファイルの頭の
[hengband/hengband.git] / src / cmd5.c
index 59e9e2b..860ff9f 100644 (file)
@@ -1,15 +1,15 @@
 /* File: cmd5.c */
 
-/* Purpose: Spell/Prayer commands */
-
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
+/* Purpose: Spell/Prayer commands */
+
 #include "angband.h"
 
 #include "spellstips.h"
@@ -51,7 +51,6 @@ cptr spell_categoly_name(int tval)
  * The "known" should be TRUE for cast/pray, FALSE for study
  */
 
-bool select_spellbook=FALSE;
 bool select_the_force=FALSE;
 
 static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm)
@@ -68,7 +67,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        char        out_val[160];
        cptr        p;
 #ifdef JP
-        char jverb_buf[128];
+       char jverb_buf[128];
 #endif
        int menu_line = (use_menu ? 1 : 0);
 
@@ -78,7 +77,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        if (repeat_pull(sn))
        {
                /* Verify the spell */
-               if (spell_okay(*sn, learned, FALSE, use_realm - 1))
+               if (spell_okay(*sn, learned, FALSE, use_realm))
                {
                        /* Success */
                        return (TRUE);
@@ -110,7 +109,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
        for (i = 0; i < num; i++)
        {
                /* Look for "okay" spells */
-               if (spell_okay(spells[i], learned, FALSE, use_realm - 1)) okay = TRUE;
+               if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
        }
 
        /* No "okay" spells */
@@ -142,7 +141,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 #ifdef JP
        jverb1( prompt, jverb_buf );
        (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤Î%s¤ò%^s¤Þ¤¹¤«? ",
-               p, I2A(0), I2A(num - 1), p, jverb_buf );
+               p, I2A(0), I2A(num - 1), p, jverb_buf );
 #else
        (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
                p, I2A(0), I2A(num - 1), prompt, p);
@@ -150,9 +149,9 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
 
        /* Get a spell from the user */
 
-        choice = (always_show_list || use_menu) ? ESCAPE:1;
-        while (!flag)
-        {
+       choice = (always_show_list || use_menu) ? ESCAPE:1;
+       while (!flag)
+       {
                if( choice==ESCAPE ) choice = ' '; 
                else if( !get_com(out_val, &choice, TRUE) )break; 
 
@@ -195,7 +194,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        }
                        if (menu_line > num) menu_line -= num;
                        /* Display a list of spells */
-                       print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+                       print_spells(menu_line, spells, num, 1, 15, use_realm);
                        if (ask) continue;
                }
                else
@@ -213,7 +212,7 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                                        screen_save();
 
                                        /* Display a list of spells */
-                                       print_spells(menu_line, spells, num, 1, 15, use_realm - 1);
+                                       print_spells(menu_line, spells, num, 1, 15, use_realm);
                                }
 
                                /* Hide the list */
@@ -254,11 +253,11 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                spell = spells[i];
 
                /* Require "okay" spells */
-               if (!spell_okay(spell, learned, FALSE, use_realm - 1))
+               if (!spell_okay(spell, learned, FALSE, use_realm))
                {
                        bell();
 #ifdef JP
-                        msg_format("¤½¤Î%s¤ò%s¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£", p, prompt);
+                       msg_format("¤½¤Î%s¤ò%s¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£", p, prompt);
 #else
                        msg_format("You may not %s that %s.", prompt, p);
 #endif
@@ -274,11 +273,11 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        /* Access the spell */
                        if (!is_magic(use_realm))
                        {
-                               s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+                               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                        }
                        else
                        {
-                               s_ptr = &mp_ptr->info[use_realm - 1][spell % 32];
+                               s_ptr = &mp_ptr->info[use_realm - 1][spell];
                        }
 
                        if (use_realm == REALM_HISSATSU)
@@ -287,12 +286,8 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        }
                        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
-                                       shouhimana = (s_ptr->smana*(3800-spell_exp[spell])+2399);
+                               /* 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;
@@ -303,14 +298,14 @@ static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm
                        /* Prompt */
 #ifdef JP
                        jverb1( prompt, jverb_buf );
-                        /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
-                        (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
-                                spell_names[technic2magic(use_realm)-1][spell % 32], shouhimana,
-                                      spell_chance(spell, use_realm -1),jverb_buf);
+                       /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
+                       (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
+                               spell_names[technic2magic(use_realm)-1][spell], shouhimana,
+                                      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 % 32], shouhimana,
-                               spell_chance(spell, use_realm - 1));
+                               prompt, spell_names[technic2magic(use_realm)-1][spell], shouhimana,
+                               spell_chance(spell, use_realm));
 #endif
 
 
@@ -437,15 +432,12 @@ s = "
        s = "You have no books that you can read.";
 #endif
 
-        select_spellbook=TRUE;
        if (p_ptr->pclass == CLASS_FORCETRAINER)
                select_the_force = TRUE;
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
-            select_spellbook = FALSE;
            select_the_force = FALSE;
-            return;
-        }
-        select_spellbook = FALSE;
+           return;
+       }
        select_the_force = FALSE;
 
        if (item == 1111) { /* the_force */
@@ -513,7 +505,7 @@ s = "
                        if (spell == -1) break;
 
                        /* Display a list of spells */
-                       print_spells(0, spells, num, 1, 15, use_realm - 1);
+                       print_spells(0, spells, num, 1, 15, use_realm);
 
                        /* Notify that there's nothing to see, and wait. */
                        if (use_realm == REALM_HISSATSU)
@@ -546,14 +538,14 @@ s = "
                /* Access the spell */
                if (!is_magic(use_realm))
                {
-                       s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+                       s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                }
                else
                {
                        s_ptr = &mp_ptr->info[use_realm - 1][spell];
                }
 
-               roff_to_buf( spell_tips[technic2magic(use_realm)-1][spell] ,62,temp);
+               roff_to_buf(spell_tips[technic2magic(use_realm)-1][spell] ,62, temp, sizeof(temp));
                for(j=0, line = 11;temp[j];j+=(1+strlen(&temp[j])))
                {
                        prt(&temp[j], line, 15);
@@ -573,19 +565,19 @@ static void change_realm2(int next_realm)
 
        for (i = 0; i < 64; i++)
        {
-               spell_order[j] = spell_order[i];
-               if(spell_order[i] < 32) j++;
+               p_ptr->spell_order[j] = p_ptr->spell_order[i];
+               if(p_ptr->spell_order[i] < 32) j++;
        }
        for (; j < 64; j++)
-               spell_order[j] = 99;
+               p_ptr->spell_order[j] = 99;
 
        for (i = 32; i < 64; i++)
        {
-               spell_exp[i] = 0;
+               p_ptr->spell_exp[i] = 0;
        }
-       spell_learned2 = 0L;
-       spell_worked2 = 0L;
-       spell_forgotten2 = 0L;  
+       p_ptr->spell_learned2 = 0L;
+       p_ptr->spell_worked2 = 0L;
+       p_ptr->spell_forgotten2 = 0L;   
 
 #ifdef JP
        sprintf(tmp,"ËâË¡¤ÎÎΰè¤ò%s¤«¤é%s¤ËÊѹ¹¤·¤¿¡£", realm_names[p_ptr->realm2], realm_names[next_realm]);
@@ -702,9 +694,7 @@ s = "
        s = "You have no books that you can read.";
 #endif
 
-        select_spellbook=TRUE;
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-        select_spellbook=FALSE;
 
        /* Get the item (in the pack) */
        if (item >= 0)
@@ -744,7 +734,7 @@ s = "
        {
                /* Ask for a spell, allow cancel */
 #ifdef JP
-                if (!get_spell(&spell, "³Ø¤Ö", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
+               if (!get_spell(&spell, "³Ø¤Ö", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
                        && (spell == -1)) return;
 #else
                if (!get_spell(&spell, "study", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
@@ -768,7 +758,7 @@ s = "
                        {
                                /* Skip non "okay" prayers */
                                if (!spell_okay(spell, FALSE, TRUE,
-                                       (increment ? p_ptr->realm2 - 1 : p_ptr->realm1 - 1))) continue;
+                                       (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
 
                                /* Hack -- Prepare the randomizer */
                                k++;
@@ -803,19 +793,19 @@ msg_format("
        /* Learn the spell */
        if (spell < 32)
        {
-               if (spell_learned1 & (1L << spell)) learned = TRUE;
-               else spell_learned1 |= (1L << spell);
+               if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
+               else p_ptr->spell_learned1 |= (1L << spell);
        }
        else
        {
-               if (spell_learned2 & (1L << (spell - 32))) learned = TRUE;
-               else spell_learned2 |= (1L << (spell - 32));
+               if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
+               else p_ptr->spell_learned2 |= (1L << (spell - 32));
        }
 
        if (learned)
        {
                int max_exp = (spell < 32) ? 1600 : 1400;
-               int old_exp = spell_exp[spell];
+               int old_exp = p_ptr->spell_exp[spell];
                int new_rank = 0;
                cptr name = spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell%32];
 
@@ -838,23 +828,23 @@ msg_format("
                }
                else if (old_exp >= 1400)
                {
-                       spell_exp[spell] = 1600;
+                       p_ptr->spell_exp[spell] = 1600;
                        new_rank = 4;
                }
                else if (old_exp >= 1200)
                {
-                       if (spell >= 32) spell_exp[spell] = 1400;
-                       else spell_exp[spell] += 200;
+                       if (spell >= 32) p_ptr->spell_exp[spell] = 1400;
+                       else p_ptr->spell_exp[spell] += 200;
                        new_rank = 3;
                }
                else if (old_exp >= 900)
                {
-                       spell_exp[spell] = 1200+(old_exp-900)*2/3;
+                       p_ptr->spell_exp[spell] = 1200+(old_exp-900)*2/3;
                        new_rank = 2;
                }
                else
                {
-                       spell_exp[spell] = 900+(old_exp)/3;
+                       p_ptr->spell_exp[spell] = 900+(old_exp)/3;
                        new_rank = 1;
                }
 #ifdef JP
@@ -865,27 +855,27 @@ msg_format("
        }
        else
        {
-               /* Find the next open entry in "spell_order[]" */
+               /* Find the next open entry in "p_ptr->spell_order[]" */
                for (i = 0; i < 64; i++)
                {
                        /* Stop at the first empty space */
-                       if (spell_order[i] == 99) break;
+                       if (p_ptr->spell_order[i] == 99) break;
                }
 
                /* Add the spell to the known list */
-               spell_order[i++] = spell;
+               p_ptr->spell_order[i++] = spell;
 
                /* Mention the result */
 #ifdef JP
-               /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
+               /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
                if (mp_ptr->spell_book == TV_MUSIC_BOOK)
                {
-                       msg_format("%s¤ò³Ø¤ó¤À¡£",
+                       msg_format("%s¤ò³Ø¤ó¤À¡£",
                                    spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell % 32]);
                }
                else
                {
-                       msg_format("%s¤Î%s¤ò³Ø¤ó¤À¡£",
+                       msg_format("%s¤Î%s¤ò³Ø¤ó¤À¡£",
                                    spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell % 32] ,p);
                }
 #else
@@ -917,11 +907,11 @@ msg_format("
        {
                /* Message */
 #ifdef JP
-                        if( p_ptr->new_spells < 10 ){
-                                msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
-                        }else{
-                                msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
-                        }
+                       if( p_ptr->new_spells < 10 ){
+                               msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
+                       }else{
+                               msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
+                       }
 #else
                msg_format("You can learn %d more %s%s.",
                        p_ptr->new_spells, p,
@@ -934,6 +924,9 @@ msg_format("
        /* Update Study */
        p_ptr->update |= (PU_SPELLS);
        update_stuff();
+
+       /* Redraw object recall */
+       p_ptr->window |= (PW_OBJECT);
 }
 
 
@@ -1060,7 +1053,7 @@ static bool cast_life_spell(int spell)
                (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
                break;
        case 4: /* Detect Traps + Secret Doors */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -1122,7 +1115,7 @@ static bool cast_life_spell(int spell)
                }
                break;
        case 17: /* Perception */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 18: /* Dispel Undead */
                (void)dispel_undead(randint1(plev * 5));
                break;
@@ -1153,7 +1146,7 @@ static bool cast_life_spell(int spell)
                (void)mass_genocide_undead(plev+50,TRUE);
                break;
        case 27: /* Clairvoyance */
-               wiz_lite(FALSE, FALSE);
+               wiz_lite(FALSE);
                break;
        case 28: /* Restoration */
                (void)do_res_stat(A_STR);
@@ -1170,7 +1163,7 @@ static bool cast_life_spell(int spell)
                (void)set_cut(0);
                break;
        case 30: /* Holy Vision */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 31: /* Ultimate resistance */
        {
                int v = randint1(plev/2)+plev/2;
@@ -1212,7 +1205,7 @@ static bool cast_sorcery_spell(int spell)
                teleport_player(10);
                break;
        case 2: /* Detect Doors and Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -1238,7 +1231,7 @@ static bool cast_sorcery_spell(int spell)
                map_area(DETECT_RAD_MAP);
                break;
        case 9: /* Identify */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 10: /* Slow Monster */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -1259,7 +1252,7 @@ static bool cast_sorcery_spell(int spell)
                (void)detect_all(DETECT_RAD_DEFAULT);
                break;
        case 15: /* Identify True */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 16: /* Detect Objects and Treasure*/
                (void)detect_objects_normal(DETECT_RAD_DEFAULT);
                (void)detect_treasure(DETECT_RAD_DEFAULT);
@@ -1313,7 +1306,7 @@ msg_print("
                chg_virtue(V_KNOWLEDGE, 1);
                chg_virtue(V_ENLIGHTEN, 1);
 
-               wiz_lite(FALSE, FALSE);
+               wiz_lite(FALSE);
                if (!(p_ptr->telepathy))
                {
                        (void)set_tim_esp(randint1(30) + 25, FALSE);
@@ -1368,13 +1361,28 @@ static bool cast_nature_spell(int spell)
                        damroll(3 + ((plev - 1) / 5), 4));
                break;
        case 2: /* Detect Doors & Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
        case 3: /* Produce Food */
-               (void)set_food(PY_FOOD_MAX - 1);
+       {
+               object_type forge, *q_ptr = &forge;
+
+#ifdef JP
+               msg_print("¿©ÎÁ¤òÀ¸À®¤·¤¿¡£");
+#else
+               msg_print("A food ration is produced.");
+#endif
+
+               /* Create the food ration */
+               object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
+
+               /* Drop the object from heaven */
+               (void)drop_near(q_ptr, -1, py, px);
                break;
+
+       }
        case 4: /* Daylight */
                (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
                if ((prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) && !p_ptr->resist_lite)
@@ -1420,7 +1428,7 @@ take_hit(DAMAGE_NOESCAPE, damroll(2, 2), "
                break;
        case 10: /* Nature Awareness -- downgraded */
                map_area(DETECT_RAD_MAP);
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
@@ -1473,7 +1481,7 @@ msg_print("
                (void)charm_animals(plev * 2);
                break;
        case 21: /* Stone Tell */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
        case 22: /* Wall of Stone */
                (void)wall_stone();
                break;
@@ -1520,7 +1528,7 @@ msg_print("
                fire_ball(GF_LITE, 0, 150, 8);
                chg_virtue(V_KNOWLEDGE, 1);
                chg_virtue(V_ENLIGHTEN, 1);
-               wiz_lite(FALSE, FALSE);
+               wiz_lite(FALSE);
                if ((prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) && !p_ptr->resist_lite)
                {
 #ifdef JP
@@ -1699,7 +1707,7 @@ msg_print("
                        }
                        else if (die < 106)
                        {
-                               destroy_area(py, px, 13+randint0(5), TRUE);
+                               destroy_area(py, px, 13+randint0(5));
                        }
                        else if (die < 108)
                        {
@@ -1748,7 +1756,7 @@ msg_print("
                (void)fire_beam(GF_AWAY_ALL, dir, plev);
                break;
        case 14: /* Word of Destruction */
-               destroy_area(py, px, 13+randint0(5), TRUE);
+               destroy_area(py, px, 13+randint0(5));
                break;
        case 15: /* Invoke Logrus */
                if (!get_aim_dir(&dir)) return FALSE;
@@ -2160,7 +2168,7 @@ msg_print("
                        }
                        else if (die < 106)
                        {
-                               destroy_area(py, px, 13+randint0(5), TRUE);
+                               destroy_area(py, px, 13+randint0(5));
                        }
                        else if (die < 108)
                        {
@@ -2271,9 +2279,9 @@ msg_print("
                }
        case 26: /* Esoteria */
                if (randint1(50) > plev)
-                       return ident_spell(FALSE, FALSE);
+                       return ident_spell(FALSE);
                else
-                       return identify_fully(FALSE, FALSE);
+                       return identify_fully(FALSE);
                break;
        case 27: /* Mimic vampire */
                (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_VAMPIRE, FALSE);
@@ -2371,7 +2379,7 @@ msg_print("
 
                                if ((p_ptr->pclass == CLASS_ROGUE) ||
                                        (p_ptr->pclass == CLASS_HIGH_MAGE) ||
-                                       (p_ptr->pclass == CLASS_SORCERER))
+                                       (p_ptr->pclass == CLASS_SORCERER))
                                        die = (randint1(110)) + plev / 5;
                                /* Card sharks and high mages get a level bonus */
 
@@ -2647,7 +2655,7 @@ msg_print("
 
                                        chg_virtue(V_KNOWLEDGE, 1);
                                        chg_virtue(V_ENLIGHTEN, 1);
-                                       wiz_lite(FALSE, FALSE);
+                                       wiz_lite(FALSE);
                                }
                                else
                                {
@@ -3077,7 +3085,7 @@ msg_print("
                case 25: /* Trump Lore */
                        if (success)
                        {
-                               return identify_fully(FALSE, FALSE);
+                               return identify_fully(FALSE);
                        }
                        break;
                case 26: /* Heal Monster */
@@ -3340,7 +3348,7 @@ static bool cast_arcane_spell(int spell)
                (void)set_cut(p_ptr->cut - 10);
                break;
        case 8: /* Detect Doors & Traps */
-               (void)detect_traps(DETECT_RAD_DEFAULT);
+               (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
                (void)detect_doors(DETECT_RAD_DEFAULT);
                (void)detect_stairs(DETECT_RAD_DEFAULT);
                break;
@@ -3380,7 +3388,7 @@ static bool cast_arcane_spell(int spell)
                teleport_player(plev * 5);
                break;
        case 20: /* Identify */
-               return ident_spell(FALSE, FALSE);
+               return ident_spell(FALSE);
        case 21: /* Stone to Mud */
                if (!get_aim_dir(&dir)) return FALSE;
 
@@ -3441,7 +3449,7 @@ msg_print("
        case 31: /* Clairvoyance */
                chg_virtue(V_KNOWLEDGE, 1);
                chg_virtue(V_ENLIGHTEN, 1);
-               wiz_lite(FALSE, FALSE);
+               wiz_lite(FALSE);
                if (!p_ptr->telepathy)
                {
                        (void)set_tim_esp(randint1(30) + 25, FALSE);
@@ -3586,7 +3594,7 @@ msg_print("
                }
                break;
        case 26: /* Total Knowledge */
-               return identify_fully(FALSE, FALSE);
+               return identify_fully(FALSE);
                break;
        case 27: /* Enchant Weapon */
                return enchant_spell(randint0(4) + 1, randint0(4) + 1, 0);
@@ -3817,7 +3825,7 @@ msg_print("
 #ifdef JP
 else msg_print("<ÇËÌǤμê>¤òÊü¤Ã¤¿¡ª");
 #else
-               else msg_print("You invokes the Hand of Doom!");
+               else msg_print("You invoke the Hand of Doom!");
 #endif
 
                fire_ball_hide(GF_HAND_DOOM, dir, plev * 2, 0);
@@ -3971,7 +3979,7 @@ static bool cast_crusade_spell(int spell)
                (void)sleep_monsters_touch();
                break;
        case 5:
-               teleport_player(plev*3);
+               teleport_player(25+plev/2);
                break;
        case 6:
                if (!get_aim_dir(&dir)) return FALSE;
@@ -3990,11 +3998,11 @@ static bool cast_crusade_spell(int spell)
                if (!get_aim_dir(&dir)) return FALSE;
 
                fire_ball(GF_HOLY_FIRE, dir,
-                         (damroll(3, 6) + plev +
-                         (plev / ((p_ptr->pclass == CLASS_PRIEST ||
-                            p_ptr->pclass == CLASS_HIGH_MAGE ||
+                         (damroll(3, 6) + plev +
+                         (plev / ((p_ptr->pclass == CLASS_PRIEST ||
+                            p_ptr->pclass == CLASS_HIGH_MAGE ||
                             p_ptr->pclass == CLASS_SORCERER) ? 2 : 4))),
-                         ((plev < 30) ? 2 : 3));
+                         ((plev < 30) ? 2 : 3));
 
                break;
        case 10: /* Exorcism */
@@ -4112,7 +4120,7 @@ msg_print("
                }
                break;
        case 27: /* Word of Destruction */
-               destroy_area(py, px, 13+randint0(5), TRUE);
+               destroy_area(py, px, 13+randint0(5));
                break;
        case 28: /* Eye for an Eye */
                set_tim_eyeeye(randint1(10)+10, FALSE);
@@ -4224,7 +4232,7 @@ msg_print("
                                if (cave_empty_bold2(my, mx)) break;
                        }
                        if (attempt < 0) continue;
-                       summon_specific(-1, my, mx, plev, SUMMON_KNIGHTS, (PM_ALLOW_GROUP | PM_FORCE_PET));
+                       summon_specific(-1, my, mx, plev, SUMMON_KNIGHTS, (PM_ALLOW_GROUP | PM_FORCE_PET | PM_HASTE));
                }
                (void)set_hero(randint1(25) + 25, FALSE);
                (void)set_blessed(randint1(25) + 25, FALSE);
@@ -4261,18 +4269,18 @@ void stop_singing(void)
 
        set_action(ACTION_NONE);
 
-        switch(p_ptr->magic_num1[0])
-        {
-                case MUSIC_BLESS:
-                        if (!p_ptr->blessed)
+       switch(p_ptr->magic_num1[0])
+       {
+               case MUSIC_BLESS:
+                       if (!p_ptr->blessed)
 #ifdef JP
 msg_print("¹â·é¤Êµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
 #else
                                msg_print("The prayer has expired.");
 #endif
-                        break;
-                case MUSIC_HERO:
-                        if (!p_ptr->hero)
+                       break;
+               case MUSIC_HERO:
+                       if (!p_ptr->hero)
                        {
 #ifdef JP
 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
@@ -4282,9 +4290,9 @@ msg_print("
                                /* Recalculate hitpoints */
                                p_ptr->update |= (PU_HP);
                        }
-                        break;
-                case MUSIC_MIND:
-                        if (!p_ptr->tim_esp)
+                       break;
+               case MUSIC_MIND:
+                       if (!p_ptr->tim_esp)
                        {
 #ifdef JP
 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
@@ -4294,57 +4302,57 @@ msg_print("
                                /* Update the monsters */
                                p_ptr->update |= (PU_MONSTERS);
                        }
-                        break;
-                case MUSIC_STEALTH:
-                        if (!p_ptr->tim_stealth)
+                       break;
+               case MUSIC_STEALTH:
+                       if (!p_ptr->tim_stealth)
 #ifdef JP
 msg_print("»Ñ¤¬¤Ï¤Ã¤­¤ê¤È¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
 #else
                                msg_print("You are no longer hided.");
 #endif
-                        break;
-                case MUSIC_RESIST:
-                        if (!p_ptr->oppose_acid)
+                       break;
+               case MUSIC_RESIST:
+                       if (!p_ptr->oppose_acid)
 #ifdef JP
 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
 #else
                                msg_print("You feel less resistant to acid.");
 #endif
-                        if (!p_ptr->oppose_elec)
+                       if (!p_ptr->oppose_elec)
 #ifdef JP
 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
 #else
                                msg_print("You feel less resistant to elec.");
 #endif
-                        if (!p_ptr->oppose_fire)
+                       if (!p_ptr->oppose_fire)
 #ifdef JP
 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
 #else
                                msg_print("You feel less resistant to fire.");
 #endif
-                        if (!p_ptr->oppose_cold)
+                       if (!p_ptr->oppose_cold)
 #ifdef JP
 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
 #else
                                msg_print("You feel less resistant to cold.");
 #endif
-                        if (!p_ptr->oppose_pois)
+                       if (!p_ptr->oppose_pois)
 #ifdef JP
 msg_print("ÆǤؤÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
 #else
                                msg_print("You feel less resistant to pois.");
 #endif
-                        break;
-                case MUSIC_SPEED:
-                        if (!p_ptr->fast)
+                       break;
+               case MUSIC_SPEED:
+                       if (!p_ptr->fast)
 #ifdef JP
 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
 #else
                                msg_print("You feel yourself slow down.");
 #endif
-                        break;
-                case MUSIC_SHERO:
-                        if (!p_ptr->hero)
+                       break;
+               case MUSIC_SHERO:
+                       if (!p_ptr->hero)
                        {
 #ifdef JP
 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
@@ -4355,15 +4363,15 @@ msg_print("
                                p_ptr->update |= (PU_HP);
                        }
 
-                        if (!p_ptr->fast)
+                       if (!p_ptr->fast)
 #ifdef JP
 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
 #else
                                msg_print("You feel yourself slow down.");
 #endif
-                        break;
-                case MUSIC_INVULN:
-                        if (!p_ptr->invuln)
+                       break;
+               case MUSIC_INVULN:
+                       if (!p_ptr->invuln)
                        {
 #ifdef JP
 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
@@ -4379,8 +4387,8 @@ msg_print("̵Ũ
                                /* Window stuff */
                                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
                        }
-                        break;
-        }
+                       break;
+       }
        p_ptr->magic_num1[0] = MUSIC_NONE;
        p_ptr->magic_num2[0] = 0;
 
@@ -4397,12 +4405,12 @@ static bool cast_music_spell(int spell)
        int     plev = p_ptr->lev;
        int dir;
 
-        if(p_ptr->magic_num1[0])
-        {
-                stop_singing();
-        }
+       if(p_ptr->magic_num1[0])
+       {
+               stop_singing();
+       }
 
-        p_ptr->magic_num2[0] = spell;
+       p_ptr->magic_num2[0] = spell;
 
        switch (spell)
        {
@@ -4769,15 +4777,12 @@ s = "
        s = "You have no spell books!";
 #endif
 
-        select_spellbook=TRUE;
        if (p_ptr->pclass == CLASS_FORCETRAINER)
                select_the_force = TRUE;
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
-            select_spellbook = FALSE;
            select_the_force = FALSE;
-            return;
-        }
-        select_spellbook = FALSE;
+           return;
+       }
        select_the_force = FALSE;
 
        if (item == 1111) { /* the_force */
@@ -4815,13 +4820,13 @@ s = "
 
        /* Ask for a spell */
 #ifdef JP
-        if (!get_spell(&spell,  
-                               ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"), 
+       if (!get_spell(&spell,  
+                               ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"), 
                       sval, TRUE, realm))
-        {
-                if (spell == -2) msg_format("¤½¤ÎËܤˤÏÃΤäƤ¤¤ë%s¤¬¤Ê¤¤¡£", prayer);
-                return;
-        }
+       {
+               if (spell == -2) msg_format("¤½¤ÎËܤˤÏÃΤäƤ¤¤ë%s¤¬¤Ê¤¤¡£", prayer);
+               return;
+       }
 #else
        if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
                sval, TRUE, realm))
@@ -4837,19 +4842,15 @@ s = "
 
        if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[use_realm - MIN_TECHNIC - 1][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
                s_ptr = &mp_ptr->info[realm - 1][spell];
        }
 
-       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
-               shouhimana = (s_ptr->smana*(3800-spell_exp[(increment ? spell+32 : spell)])+2399);
+       /* 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;
@@ -4859,6 +4860,8 @@ s = "
        /* Verify "dangerous" spells */
        if (shouhimana > p_ptr->csp)
        {
+               if (flush_failure) flush();
+
                /* Warning */
 #ifdef JP
 msg_format("¤½¤Î%s¤ò%s¤Î¤Ë½½Ê¬¤Ê¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤¬¤Ê¤¤¡£",prayer,
@@ -4883,7 +4886,7 @@ msg_format("
 
 
        /* Spell failure chance */
-       chance = spell_chance(spell, use_realm - 1);
+       chance = spell_chance(spell, use_realm);
 
        /* Failed spell */
        if (randint0(100) < chance)
@@ -5033,8 +5036,8 @@ msg_print("An infernal sound echoed.");
 
                /* A spell was cast */
                if (!(increment ?
-                   (spell_worked2 & (1L << spell)) :
-                   (spell_worked1 & (1L << spell)))
+                   (p_ptr->spell_worked2 & (1L << spell)) :
+                   (p_ptr->spell_worked1 & (1L << spell)))
                    && (p_ptr->pclass != CLASS_SORCERER)
                    && (p_ptr->pclass != CLASS_RED_MAGE))
                {
@@ -5043,16 +5046,19 @@ msg_print("An infernal sound echoed.");
                        /* The spell worked */
                        if (realm == p_ptr->realm1)
                        {
-                               spell_worked1 |= (1L << spell);
+                               p_ptr->spell_worked1 |= (1L << spell);
                        }
                        else
                        {
-                               spell_worked2 |= (1L << spell);
+                               p_ptr->spell_worked2 |= (1L << spell);
                        }
 
                        /* Gain experience */
                        gain_exp(e * s_ptr->slevel);
 
+                       /* Redraw object recall */
+                       p_ptr->window |= (PW_OBJECT);
+
                        if (realm == REALM_LIFE)
                        {
                                chg_virtue(V_TEMPERANCE, 1);
@@ -5124,14 +5130,27 @@ msg_print("An infernal sound echoed.");
                }
                if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
                {
-                       if (spell_exp[(increment ? 32 : 0)+spell] < 900)
-                               spell_exp[(increment ? 32 : 0)+spell]+=60;
-                       else if(spell_exp[(increment ? 32 : 0)+spell] < 1200)
-                               {if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev)) spell_exp[(increment ? 32 : 0)+spell]+=8;}
-                       else if(spell_exp[(increment ? 32 : 0)+spell] < 1400)
-                               {if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel)) spell_exp[(increment ? 32 : 0)+spell]+=2;}
-                       else if((spell_exp[(increment ? 32 : 0)+spell] < 1600) && !increment)
-                               {if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel)) spell_exp[(increment ? 32 : 0)+spell]+=1;}
+                       s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
+                       s16b exp_gain = 0;
+
+                       if (cur_exp < 900)
+                               exp_gain+=60;
+                       else if(cur_exp < 1200)
+                       {
+                               if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
+                                       exp_gain = 8;
+                       }
+                       else if(cur_exp < 1400)
+                       {
+                               if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
+                                       exp_gain = 2;
+                       }
+                       else if((cur_exp < 1600) && !increment)
+                       {
+                               if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
+                                       exp_gain = 1;
+                       }
+                       p_ptr->spell_exp[(increment ? 32 : 0)+spell] += exp_gain;
                }
        }
 
@@ -5225,6 +5244,9 @@ static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
        monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
        monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
 
+       /* Unused */
+       (void)v;
+
        if (w1 == p_ptr->riding) return TRUE;
        if (w2 == p_ptr->riding) return FALSE;
 
@@ -5435,7 +5457,7 @@ void do_cmd_pet_dismiss(void)
 
                        /* HACK : Add the line to message buffer */
 #ifdef JP
-                       sprintf(buf, "%s ¤òΥ¤·¤¿¡£", friend_name);
+                       sprintf(buf, "%s ¤òÊü¤·¤¿¡£", friend_name);
 #else
                        sprintf(buf, "Dismissed %s.", friend_name);
 #endif
@@ -5461,7 +5483,11 @@ void do_cmd_pet_dismiss(void)
                   (Dismissed == 1 ? "" : "s"));
 #endif
        if (Dismissed == 0 && all_pets)
+#ifdef JP
                msg_print("'U'nnamed ¤Ï¡¢¾èÇϰʳ°¤Î̾Á°¤Î¤Ê¤¤¥Ú¥Ã¥È¤À¤±¤òÁ´¤Æ²òÊü¤·¤Þ¤¹¡£");
+#else
+               msg_print("'U'nnamed means all your pets except named pets and your mount.");
+#endif
 
        p_ptr->update |= (PU_MON_LITE);
 }
@@ -5483,16 +5509,16 @@ bool rakuba(int dam, bool force)
                {
                        int level = r_ptr->level;
                        if (p_ptr->riding_ryoute) level += 20;
-                       if ((dam/2 + r_ptr->level) > (skill_exp[GINOU_RIDING]/30+10))
+                       if ((dam/2 + r_ptr->level) > (p_ptr->skill_exp[GINOU_RIDING]/30+10))
                        {
-                               if((skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && s_info[p_ptr->pclass].s_max[GINOU_RIDING] > 1000)
+                               if((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && s_info[p_ptr->pclass].s_max[GINOU_RIDING] > 1000)
                                {
-                                       if (r_ptr->level*100 > (skill_exp[GINOU_RIDING] + 1500))
-                                               skill_exp[GINOU_RIDING] += (1+(r_ptr->level - skill_exp[GINOU_RIDING]/100 - 15));
-                                       else skill_exp[GINOU_RIDING]++;
+                                       if (r_ptr->level*100 > (p_ptr->skill_exp[GINOU_RIDING] + 1500))
+                                               p_ptr->skill_exp[GINOU_RIDING] += (1+(r_ptr->level - p_ptr->skill_exp[GINOU_RIDING]/100 - 15));
+                                       else p_ptr->skill_exp[GINOU_RIDING]++;
                                }
                        }
-                       if (randint0(dam/2 + level*2) < (skill_exp[GINOU_RIDING]/30+10))
+                       if (randint0(dam/2 + level*2) < (p_ptr->skill_exp[GINOU_RIDING]/30+10))
                        {
                                if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3)+30))
                                {
@@ -5574,6 +5600,9 @@ msg_format("%s
 
        p_ptr->redraw |= (PR_EXTRA);
 
+       /* Update health track of mount */
+       p_ptr->redraw |= (PR_UHEALTH);
+
        if (p_ptr->ffall && !force)
        {
                monster_desc(m_name, m_ptr, 0);
@@ -5589,7 +5618,6 @@ msg_format("%s
 #else
        take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "Falling from riding", -1);
 #endif
-       p_ptr->redraw |= (PR_UHEALTH);
 
        return TRUE;
 }
@@ -5650,7 +5678,7 @@ msg_print("
 #ifdef JP
 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï¥Ú¥Ã¥È¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£");
 #else
-                       msg_print("That monster is no a pet.");
+                       msg_print("That monster is not a pet.");
 #endif
 
                        return FALSE;
@@ -5695,7 +5723,7 @@ msg_print("
 
                        return FALSE;
                }
-               if (r_info[m_ptr->r_idx].level > randint1((skill_exp[GINOU_RIDING]/50 + p_ptr->lev/2 +20)))
+               if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING]/50 + p_ptr->lev/2 +20)))
                {
 #ifdef JP
 msg_print("¤¦¤Þ¤¯¾è¤ì¤Ê¤«¤Ã¤¿¡£");
@@ -5720,6 +5748,9 @@ msg_format("%s
                }
 
                p_ptr->riding = c_ptr->m_idx;
+
+               /* Hack -- remove tracked monster */
+               if (p_ptr->riding == p_ptr->health_who) health_track(0);
        }
 
        /* Save the old location */