OSDN Git Service

魔道具術師は「杖」を吸収できないようにする為のHackの副作用で「杖」に
[hengband/hengband.git] / src / spells3.c
index d6cc262..ae1c9c2 100644 (file)
@@ -81,8 +81,8 @@ bool teleport_away(int m_idx, int dis, bool dec_valour)
                        if (!cave_empty_bold(ny, nx)) continue;
 
                        /* Hack -- no teleport onto glyph of warding */
-                       if (cave[ny][nx].feat == FEAT_GLYPH) continue;
-                       if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
+                       if (is_glyph_grid(&cave[ny][nx])) continue;
+                       if (is_explosive_rune_grid(&cave[ny][nx])) continue;
 
                        /* ...nor onto the Pattern */
                        if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
@@ -193,8 +193,8 @@ void teleport_to_player(int m_idx, int power)
                        if (!cave_empty_bold(ny, nx)) continue;
 
                        /* Hack -- no teleport onto glyph of warding */
-                       if (cave[ny][nx].feat == FEAT_GLYPH) continue;
-                       if (cave[ny][nx].feat == FEAT_MINOR_GLYPH) continue;
+                       if (is_glyph_grid(&cave[ny][nx])) continue;
+                       if (is_explosive_rune_grid(&cave[ny][nx])) continue;
 
                        /* ...nor onto the Pattern */
                        if ((cave[ny][nx].feat >= FEAT_PATTERN_START) &&
@@ -521,6 +521,8 @@ msg_print("
  */
 void teleport_player_level(void)
 {
+       bool go_up;
+
        /* No effect in arena or quest */
        if (p_ptr->inside_arena || (p_ptr->inside_quest && !random_quest_number(dun_level)) ||
            (quest_number(dun_level) && (dun_level > 1) && ironman_downward))
@@ -545,6 +547,17 @@ msg_print("
                return;
        }
 
+       /* Choose up or down */
+       if (randint0(100) < 50) go_up = TRUE;
+       else go_up = FALSE;
+
+       if (p_ptr->wizard)
+       {
+               if (get_check("Force to go up? ")) go_up = TRUE;
+               else if (get_check("Force to go down? ")) go_up = FALSE;
+       }
+
+       /* Down only */ 
        if (ironman_downward || (dun_level <= d_info[dungeon_type].mindepth))
        {
 #ifdef JP
@@ -566,15 +579,18 @@ msg_print("
                if (!dun_level)
                {
                        dun_level = d_info[dungeon_type].mindepth;
+                       prepare_change_floor_mode(CFM_RAND_PLACE | CFM_CLEAR_ALL);
                }
                else
                {
-                       dun_level++;
+                       prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
                }
 
                /* Leaving */
                p_ptr->leaving = TRUE;
        }
+
+       /* Up only */
        else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
        {
 #ifdef JP
@@ -588,9 +604,7 @@ msg_print("
 
                if (autosave_l) do_cmd_save_game(TRUE);
 
-               dun_level--;
-
-               if (!dun_level) dungeon_type = 0;
+               prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
                leave_quest_check();
 
@@ -598,7 +612,7 @@ msg_print("
                p_ptr->inside_quest = 0;
                p_ptr->leaving = TRUE;
        }
-       else if (randint0(100) < 50)
+       else if (go_up)
        {
 #ifdef JP
 msg_print("¤¢¤Ê¤¿¤ÏÅ·°æ¤òÆͤ­ÇˤäÆÃè¤ØÉ⤤¤Æ¤¤¤¯¡£");
@@ -611,9 +625,7 @@ msg_print("
 
                if (autosave_l) do_cmd_save_game(TRUE);
 
-               dun_level--;
-
-               if (!dun_level) dungeon_type = 0;
+               prepare_change_floor_mode(CFM_UP | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
                /* Leaving */
                p_ptr->leaving = TRUE;
@@ -626,28 +638,19 @@ msg_print("
                msg_print("You sink through the floor.");
 #endif
 
-               if (!dun_level) dungeon_type = p_ptr->recall_dungeon;
+               /* Never reach this code on the surface */
+               /* if (!dun_level) dungeon_type = p_ptr->recall_dungeon; */
 
                if (record_stair) do_cmd_write_nikki(NIKKI_TELE_LEV, 1, NULL);
 
                if (autosave_l) do_cmd_save_game(TRUE);
 
-               dun_level++;
+               prepare_change_floor_mode(CFM_DOWN | CFM_RAND_PLACE | CFM_RAND_CONNECT);
 
                /* Leaving */
                p_ptr->leaving = TRUE;
        }
 
-       if (!dun_level && dungeon_type)
-       {
-               p_ptr->leaving_dungeon = TRUE;
-               p_ptr->wilderness_y = d_info[dungeon_type].dy;
-               p_ptr->wilderness_x = d_info[dungeon_type].dx;
-               p_ptr->recall_dungeon = dungeon_type;
-       }
-
-       if (!dun_level) dungeon_type = 0;
-
        /* Sound */
        sound(SOUND_TPLEVEL);
 }
@@ -1241,7 +1244,7 @@ act = "
 #ifdef JP
 act = "¤Ï¿Í´Ö¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for human!";
+                       act = "seems to be looking for humans!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_HUMAN;
@@ -1250,7 +1253,7 @@ act = "
 #ifdef JP
 act = "¤ÏÅÅ·â¤Ëʤ¤ï¤ì¤¿¡ª";
 #else
-                       act = "coverd with lightning!";
+                       act = "covered with lightning!";
 #endif
 
                        o_ptr->name2 = EGO_BRAND_ELEC;
@@ -1268,7 +1271,7 @@ act = "
 #ifdef JP
 act = "¤Ï¼Ù°­¤Ê¤ë²øʪ¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for evil monster!";
+                       act = "seems to be looking for evil monsters!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_EVIL;
@@ -1277,7 +1280,7 @@ act = "
 #ifdef JP
 act = "¤Ï°ÛÀ¤³¦¤Î½»¿Í¤ÎÆùÂΤòµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for demon!";
+                       act = "seems to be looking for demons!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_DEMON;
@@ -1286,7 +1289,7 @@ act = "
 #ifdef JP
 act = "¤Ï»Ó¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for undead!";
+                       act = "seems to be looking for undead!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_UNDEAD;
@@ -1295,7 +1298,7 @@ act = "
 #ifdef JP
 act = "¤Ïưʪ¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for animal!";
+                       act = "seems to be looking for animals!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_ANIMAL;
@@ -1304,7 +1307,7 @@ act = "
 #ifdef JP
 act = "¤Ï¥É¥é¥´¥ó¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for dragon!";
+                       act = "seems to be looking for dragons!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_DRAGON;
@@ -1313,7 +1316,7 @@ act = "
 #ifdef JP
 act = "¤Ï¥È¥í¥ë¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for troll!";
+                       act = "seems to be looking for troll!s";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_TROLL;
@@ -1322,7 +1325,7 @@ act = "
 #ifdef JP
 act = "¤Ï¥ª¡¼¥¯¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for orc!";
+                       act = "seems to be looking for orcs!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_ORC;
@@ -1331,7 +1334,7 @@ act = "
 #ifdef JP
 act = "¤Ïµð¿Í¤Î·ì¤òµá¤á¤Æ¤¤¤ë¡ª";
 #else
-                       act = "seems looking for giant!";
+                       act = "seems to be looking for giants!";
 #endif
 
                        o_ptr->name2 = EGO_SLAY_GIANT;
@@ -1621,29 +1624,42 @@ msg_format("%^s
 
 void alter_reality(void)
 {
-       if (!quest_number(dun_level) && dun_level)
+       /* Ironman option */
+       if (p_ptr->inside_arena || ironman_downward)
        {
 #ifdef JP
-msg_print("À¤³¦¤¬ÊѤï¤Ã¤¿¡ª");
+               msg_print("²¿¤âµ¯¤³¤é¤Ê¤«¤Ã¤¿¡£");
 #else
-               msg_print("The world changes!");
+               msg_print("Nothing happens.");
 #endif
+               return;
+       }
 
+       if (!p_ptr->alter_reality)
+       {
+               int turns = randint0(21) + 15;
 
-               if (autosave_l) do_cmd_save_game(TRUE);
+               p_ptr->alter_reality = turns;
+#ifdef JP
+               msg_print("²ó¤ê¤Î·Ê¿§¤¬ÊѤï¤ê»Ï¤á¤¿...");
+#else
+               msg_print("The view around you begins to change...");
+#endif
 
-               /* Leaving */
-               p_ptr->leaving = TRUE;
+               p_ptr->redraw |= (PR_STATUS);
        }
        else
        {
+               p_ptr->alter_reality = 0;
 #ifdef JP
-msg_print("À¤³¦¤¬¾¯¤·¤Î´ÖÊѲ½¤·¤¿¤è¤¦¤À¡£");
+               msg_print("·Ê¿§¤¬¸µ¤ËÌá¤Ã¤¿...");
 #else
-               msg_print("The world seems to change for a moment!");
+               msg_print("The view around you got back...");
 #endif
 
+               p_ptr->redraw |= (PR_STATUS);
        }
+       return;
 }
 
 
@@ -1665,7 +1681,14 @@ msg_print("
        }
 
        /* Create a glyph */
-       cave_set_feat(py, px, FEAT_GLYPH);
+       cave[py][px].info |= CAVE_OBJECT;
+       cave[py][px].mimic = FEAT_GLYPH;
+
+       /* Notice */
+       note_spot(py, px);
+       
+       /* Redraw */
+       lite_spot(py, px);
 
        return TRUE;
 }
@@ -1684,9 +1707,17 @@ msg_print("
                return FALSE;
        }
 
-       /* Create a glyph */
-       cave_set_feat(py, px, FEAT_MIRROR);
+       /* Create a mirror */
+       cave[py][px].info |= CAVE_OBJECT;
+       cave[py][px].mimic = FEAT_MIRROR;
+
+       /* Turn on the light */
+       cave[py][px].info |= CAVE_GLOW;
+
+       /* Notice */
        note_spot(py, px);
+       
+       /* Redraw */
        lite_spot(py, px);
 
        return TRUE;
@@ -1711,7 +1742,14 @@ msg_print("
        }
 
        /* Create a glyph */
-       cave_set_feat(py, px, FEAT_MINOR_GLYPH);
+       cave[py][px].info |= CAVE_OBJECT;
+       cave[py][px].mimic = FEAT_MINOR_GLYPH;
+
+       /* Notice */
+       note_spot(py, px);
+       
+       /* Redraw */
+       lite_spot(py, px);
 
        return TRUE;
 }
@@ -1973,57 +2011,6 @@ msg_format("%s
 }
 
 
-/*
- * Create stairs at the player location
- */
-void stair_creation(void)
-{
-       /* XXX XXX XXX */
-       if (!cave_valid_bold(py, px))
-       {
-#ifdef JP
-msg_print("¾²¾å¤Î¥¢¥¤¥Æ¥à¤¬¼öʸ¤òÄ·¤ÍÊÖ¤·¤¿¡£");
-#else
-               msg_print("The object resists the spell.");
-#endif
-
-               return;
-       }
-
-       /* XXX XXX XXX */
-       delete_object(py, px);
-
-       /* Create a staircase */
-       if (p_ptr->inside_arena || (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST)) || p_ptr->inside_battle || !dun_level)
-       {
-               /* arena or quest */
-#ifdef JP
-msg_print("¸ú²Ì¤¬¤¢¤ê¤Þ¤»¤ó¡ª");
-#else
-               msg_print("There is no effect!");
-#endif
-
-       }
-       else if (ironman_downward)
-       {
-               /* Town/wilderness or Ironman */
-               cave_set_feat(py, px, FEAT_MORE);
-       }
-       else if (quest_number(dun_level) || (dun_level >= d_info[dungeon_type].maxdepth))
-       {
-               /* Quest level */
-               cave_set_feat(py, px, FEAT_LESS);
-       }
-       else if (randint0(100) < 50)
-       {
-               cave_set_feat(py, px, FEAT_MORE);
-       }
-       else
-       {
-               cave_set_feat(py, px, FEAT_LESS);
-       }
-}
-
 
 /*
  * Hook to specify "weapon"
@@ -2451,8 +2438,8 @@ s = "
 msg_format("%s ¤ÏâÁ¤¤¸÷¤òȯ¤·¤¿¡ª",o_name);
 #else
        msg_format("%s %s radiate%s a blinding light!",
-                 ((item >= 0) ? "Your" : "The"), o_name,
-                 ((o_ptr->number > 1) ? "" : "s"));
+                 ((item >= 0) ? "Your" : "The"), o_name,
+                 ((o_ptr->number > 1) ? "" : "s"));
 #endif
 
        if (o_ptr->name1 || o_ptr->art_name)
@@ -2609,7 +2596,7 @@ static bool item_tester_hook_identify_weapon_armour(object_type *o_ptr)
  * This routine does *not* automatically combine objects.
  * Returns TRUE if something was identified, else FALSE.
  */
-bool ident_spell(bool only_equip, bool wait_optimize)
+bool ident_spell(bool only_equip)
 {
        int             item;
        object_type     *o_ptr;
@@ -2695,7 +2682,8 @@ s = "
        /* Auto-inscription/destroy */
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
-       if (!old_known) auto_destroy_item(item, idx, wait_optimize);
+       if (destroy_identify && !old_known)
+               auto_destroy_item(item, idx);
 
        /* Something happened */
        return (TRUE);
@@ -2785,7 +2773,7 @@ static bool item_tester_hook_identify_fully_weapon_armour(object_type *o_ptr)
  * Fully "identify" an object in the inventory  -BEN-
  * This routine returns TRUE if an item was identified.
  */
-bool identify_fully(bool only_equip, bool wait_optimize)
+bool identify_fully(bool only_equip)
 {
        int             item;
        object_type     *o_ptr;
@@ -2872,12 +2860,13 @@ s = "
        }
 
        /* Describe it fully */
-       (void)identify_fully_aux(o_ptr);
+       (void)screen_object(o_ptr, TRUE);
 
        /* Auto-inscription/destroy */
        idx = is_autopick(o_ptr);
        auto_inscribe_item(item, idx);
-       if (!old_known) auto_destroy_item(item, idx, wait_optimize);
+       if (destroy_identify && !old_known)
+               auto_destroy_item(item, idx);
 
        /* Success */
        return (TRUE);
@@ -3257,7 +3246,7 @@ bool bless_weapon(void)
 {
        int             item;
        object_type     *o_ptr;
-       u32b            f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        char            o_name[MAX_NLEN];
        cptr            q, s;
 
@@ -3294,7 +3283,7 @@ s = "
        object_desc(o_name, o_ptr, FALSE, 0);
 
        /* Extract the flags */
-       object_flags(o_ptr, &f1, &f2, &f3);
+       object_flags(o_ptr, flgs);
 
        if (cursed_p(o_ptr))
        {
@@ -3345,7 +3334,7 @@ msg_format("%s 
         * artifact weapon they find. Ego weapons and normal weapons
         * can be blessed automatically.
         */
-       if (f3 & TR3_BLESSED)
+       if (have_flag(flgs, TR_BLESSED))
        {
 #ifdef JP
 msg_format("%s ¤Ï´û¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£",
@@ -3371,7 +3360,7 @@ msg_format("%s
                    ((o_ptr->number > 1) ? "" : "s"));
 #endif
 
-               o_ptr->art_flags3 |= TR3_BLESSED;
+               add_flag(o_ptr->art_flags, TR_BLESSED);
                o_ptr->discount = 99;
        }
        else
@@ -3451,7 +3440,7 @@ bool pulish_shield(void)
 {
        int             item;
        object_type     *o_ptr;
-       u32b            f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        char            o_name[MAX_NLEN];
        cptr            q, s;
 
@@ -3488,7 +3477,7 @@ s = "
        object_desc(o_name, o_ptr, FALSE, 0);
 
        /* Extract the flags */
-       object_flags(o_ptr, &f1, &f2, &f3);
+       object_flags(o_ptr, flgs);
 
        if (o_ptr->k_idx && !artifact_p(o_ptr) && !ego_item_p(o_ptr) &&
            !o_ptr->art_name && !cursed_p(o_ptr) && (o_ptr->sval != SV_SHIELD_OF_DEFLECTION))
@@ -3713,8 +3702,6 @@ void display_spell_list(void)
 {
        int             i, j;
        int             y, x;
-       int             use_realm1 = p_ptr->realm1 - 1;
-       int             use_realm2 = p_ptr->realm2 - 1;
        int             m[9];
        magic_type      *s_ptr;
        char            name[80];
@@ -3724,13 +3711,16 @@ void display_spell_list(void)
        /* Erase window */
        clear_from(0);
 
-       /* Warriors are illiterate */
-       if (!mp_ptr->spell_book) return;
+       /* They have too many spells to list */
        if (p_ptr->pclass == CLASS_SORCERER) return;
        if (p_ptr->pclass == CLASS_RED_MAGE) return;
 
-       /* Mindcrafter spell-list */
-       if ((p_ptr->pclass == CLASS_MINDCRAFTER) || (p_ptr->pclass == CLASS_FORCETRAINER))
+       /* mind.c type classes */
+       if ((p_ptr->pclass == CLASS_MINDCRAFTER) ||
+           (p_ptr->pclass == CLASS_BERSERKER) ||
+           (p_ptr->pclass == CLASS_NINJA) ||
+           (p_ptr->pclass == CLASS_MIRROR_MASTER) ||
+           (p_ptr->pclass == CLASS_FORCETRAINER))
        {
                int             i;
                int             y = 1;
@@ -3742,6 +3732,7 @@ void display_spell_list(void)
                char            comment[80];
                char            psi_desc[80];
                int             use_mind;
+               bool use_hp = FALSE;
 
                /* Display a list of spells */
                prt("", y, x);
@@ -3755,9 +3746,12 @@ put_str("Lv   MP 
 
                switch(p_ptr->pclass)
                {
-                       case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
-                       case CLASS_FORCETRAINER:          use_mind = MIND_KI;break;
-                       default:                use_mind = 0;break;
+               case CLASS_MINDCRAFTER: use_mind = MIND_MINDCRAFTER;break;
+               case CLASS_FORCETRAINER:          use_mind = MIND_KI;break;
+               case CLASS_BERSERKER: use_mind = MIND_BERSERKER; use_hp = TRUE; break;
+               case CLASS_MIRROR_MASTER: use_mind = MIND_MIRROR_MASTER; break;
+               case CLASS_NINJA: use_mind = MIND_NINJUTSU; use_hp = TRUE; break;
+               default:                use_mind = 0;break;
                }
 
                /* Dump the spells */
@@ -3778,11 +3772,23 @@ put_str("Lv   MP 
                        /* Reduce failure rate by INT/WIS adjustment */
                        chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[mp_ptr->spell_stat]] - 1);
 
-                       /* Not enough mana to cast */
-                       if (spell.mana_cost > p_ptr->csp)
+                       if (!use_hp)
                        {
-                               chance += 5 * (spell.mana_cost - p_ptr->csp);
-                               a = TERM_ORANGE;
+                               /* Not enough mana to cast */
+                               if (spell.mana_cost > p_ptr->csp)
+                               {
+                                       chance += 5 * (spell.mana_cost - p_ptr->csp);
+                                       a = TERM_ORANGE;
+                               }
+                       }
+                       else
+                       {
+                               /* Not enough hp to cast */
+                               if (spell.mana_cost > p_ptr->chp)
+                               {
+                                       chance += 100;
+                                       a = TERM_RED;
+                               }
                        }
 
                        /* Extract the minimum failure rate */
@@ -3811,10 +3817,13 @@ put_str("Lv   MP 
                return;
        }
 
+       /* Cannot read spellbooks */
+       if (REALM_NONE == p_ptr->realm1) return;
+
        /* Normal spellcaster with books */
 
        /* Scan books */
-       for (j = 0; j < ((use_realm2 > -1) ? 2 : 1); j++)
+       for (j = 0; j < ((p_ptr->realm2 > REALM_NONE) ? 2 : 1); j++)
        {
                int n = 0;
 
@@ -3833,16 +3842,16 @@ put_str("Lv   MP 
                        byte a = TERM_WHITE;
 
                        /* Access the spell */
-                       if (!is_magic((j < 1) ? use_realm1 : use_realm2))
+                       if (!is_magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2))
                        {
-                               s_ptr = &technic_info[(j < 1) ? use_realm1 : use_realm2 - MIN_TECHNIC][i % 32];
+                               s_ptr = &technic_info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - MIN_TECHNIC][i % 32];
                        }
                        else
                        {
-                               s_ptr = &mp_ptr->info[(j < 1) ? use_realm1 : use_realm2][i % 32];
+                               s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
                        }
 
-                       strcpy(name, spell_names[technic2magic((j < 1) ? use_realm1+1 : use_realm2+1)-1][i % 32]);
+                       strcpy(name, spell_names[technic2magic((j < 1) ? p_ptr->realm1 : p_ptr->realm2)-1][i % 32]);
 
                        /* Illegible */
                        if (s_ptr->slevel >= 99)
@@ -3906,12 +3915,12 @@ strcpy(name, "(Ƚ
 /*
  * Returns experience of a spell
  */
-s16b experience_of_spell(int spell, int realm)
+s16b experience_of_spell(int spell, int use_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 if (use_realm == p_ptr->realm1) return p_ptr->spell_exp[spell];
+       else if (use_realm == p_ptr->realm2) return p_ptr->spell_exp[spell + 32];
        else return 0;
 }
 
@@ -3919,7 +3928,7 @@ s16b experience_of_spell(int spell, int realm)
 /*
  * Returns spell chance of failure for spell -RAK-
  */
-s16b spell_chance(int spell, int realm)
+s16b spell_chance(int spell, int use_realm)
 {
        int             chance, minfail;
        magic_type      *s_ptr;
@@ -3930,16 +3939,16 @@ s16b spell_chance(int spell, int realm)
        /* Paranoia -- must be literate */
        if (!mp_ptr->spell_book) return (100);
 
-       if (realm+1 == REALM_HISSATSU) return 0;
+       if (use_realm == REALM_HISSATSU) return 0;
 
        /* Access the spell */
-       if (!is_magic(realm+1))
+       if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
-               s_ptr = &mp_ptr->info[realm][spell];
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
        }
 
        /* Extract the base spell failure rate */
@@ -3955,7 +3964,7 @@ s16b spell_chance(int spell, int 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, realm)) + 2399;
+       shouhimana = s_ptr->smana*(3800 - experience_of_spell(spell, use_realm)) + 2399;
 
        if(p_ptr->dec_mana) shouhimana *= 3;
        else shouhimana *= 4;
@@ -3970,7 +3979,7 @@ s16b spell_chance(int spell, int realm)
        }
 
        chance += p_ptr->to_m_chance;
-       if (((realm + 1) != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
+       if ((use_realm != p_ptr->realm1) && ((p_ptr->pclass == CLASS_MAGE) || (p_ptr->pclass == CLASS_PRIEST))) chance += 5;
 
        /* Extract the minimum failure rate */
        minfail = adj_mag_fail[p_ptr->stat_ind[mp_ptr->spell_stat]];
@@ -3993,9 +4002,9 @@ s16b spell_chance(int spell, int realm)
        else if (p_ptr->easy_spell) chance-=3;
        else if (p_ptr->dec_mana) chance-=2;
 
-       if ((realm+1 == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
-       if (((realm+1 == REALM_LIFE) || (realm+1 == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
-       if (((realm+1 == REALM_DEATH) || (realm+1 == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
+       if ((use_realm == REALM_NATURE) && ((p_ptr->align > 50) || (p_ptr->align < -50))) chance += penalty;
+       if (((use_realm == REALM_LIFE) || (use_realm == REALM_CRUSADE)) && (p_ptr->align < -20)) chance += penalty;
+       if (((use_realm == REALM_DEATH) || (use_realm == REALM_DAEMON)) && (p_ptr->align > 20)) chance += penalty;
 
        /* Minimum failure rate */
        if (chance < minfail) chance = minfail;
@@ -4007,9 +4016,9 @@ s16b spell_chance(int spell, int realm)
        /* Always a 5 percent chance of working */
        if (chance > 95) chance = 95;
 
-       if ((realm+1 == p_ptr->realm1) || (realm+1 == p_ptr->realm2))
+       if ((use_realm == p_ptr->realm1) || (use_realm == p_ptr->realm2))
        {
-               s16b exp = experience_of_spell(spell, realm);
+               s16b exp = experience_of_spell(spell, use_realm);
                if(exp > 1399) chance--;
                if(exp > 1599) chance--;
        }
@@ -4029,25 +4038,25 @@ s16b spell_chance(int spell, int realm)
  * The spell must be legible, not forgotten, and also, to cast,
  * it must be known, and to study, it must not be known.
  */
-bool spell_okay(int spell, bool learned, bool study_pray, int realm)
+bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
 {
        magic_type *s_ptr;
 
        /* Access the spell */
-       if (!is_magic(realm+1))
+       if (!is_magic(use_realm))
        {
-               s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
        }
        else
        {
-               s_ptr = &mp_ptr->info[realm][spell];
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
        }
 
        /* Spell is illegal */
        if (s_ptr->slevel > p_ptr->lev) return (FALSE);
 
        /* Spell is forgotten */
-       if ((realm == p_ptr->realm2 - 1) ?
+       if ((use_realm == p_ptr->realm2) ?
            (p_ptr->spell_forgotten2 & (1L << spell)) :
            (p_ptr->spell_forgotten1 & (1L << spell)))
        {
@@ -4059,7 +4068,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
        if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
 
        /* Spell is learned */
-       if ((realm == p_ptr->realm2 - 1) ?
+       if ((use_realm == p_ptr->realm2) ?
            (p_ptr->spell_learned2 & (1L << spell)) :
            (p_ptr->spell_learned1 & (1L << spell)))
        {
@@ -4081,7 +4090,7 @@ bool spell_okay(int spell, bool learned, bool study_pray, int realm)
  * The strings in this function were extracted from the code in the
  * functions "do_cmd_cast()" and "do_cmd_pray()" and may be dated.
  */
-static void spell_info(char *p, int spell, int realm)
+static void spell_info(char *p, int spell, int use_realm)
 {
        int plev = p_ptr->lev;
 
@@ -4112,9 +4121,9 @@ static void spell_info(char *p, int spell, int realm)
        strcpy(p, "");
 
        /* Analyze the spell */
-       switch (realm)
+       switch (use_realm)
        {
-       case 0: /* Life */
+       case REALM_LIFE: /* Life */
                switch (spell)
                {
                case  0: sprintf(p, " %s2d10", s_heal); break;
@@ -4134,7 +4143,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 1: /* Sorcery */
+       case REALM_SORCERY: /* Sorcery */
                switch (spell)
                {
                case  1: sprintf(p, " %s10", s_range); break;
@@ -4155,7 +4164,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 2: /* Nature */
+       case REALM_NATURE: /* Nature */
                switch (spell)
                {
 #ifdef JP
@@ -4185,7 +4194,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 3: /* Chaos */
+       case REALM_CHAOS: /* Chaos */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4217,7 +4226,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 4: /* Death */
+       case REALM_DEATH: /* Death */
                switch (spell)
                {
                case  1: sprintf(p, " %s%dd3", s_dam, (3 + ((plev - 1) / 5))); break;
@@ -4244,7 +4253,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 5: /* Trump */
+       case REALM_TRUMP: /* Trump */
                switch (spell)
                {
                case  0: sprintf(p, " %s10", s_range); break;
@@ -4267,7 +4276,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 6: /* Arcane */
+       case REALM_ARCANE: /* Arcane */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd3", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4288,7 +4297,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 7: /* Craft */
+       case REALM_ENCHANT: /* Craft */
                switch (spell)
                {
                case 0: sprintf(p, " %s100+d100", s_dur); break;
@@ -4313,7 +4322,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 8: /* Daemon */
+       case REALM_DAEMON: /* Daemon */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4341,7 +4350,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
                
-       case 9: /* Crusade */
+       case REALM_CRUSADE: /* Crusade */
                switch (spell)
                {
                case  0: sprintf(p, " %s%dd4", s_dam, 3 + ((plev - 1) / 5)); break;
@@ -4380,7 +4389,7 @@ static void spell_info(char *p, int spell, int realm)
                }
                break;
 
-       case 15: /* Music */
+       case REALM_MUSIC: /* Music */
                switch (spell)
                {
                case 2 : sprintf(p, " %s%dd4", s_dam, 4 + ((plev - 1) / 5)); break;
@@ -4396,9 +4405,9 @@ static void spell_info(char *p, int spell, int realm)
                break;
        default:
 #ifdef JP
-               sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", realm);
+               sprintf(p, "̤ÃΤΥ¿¥¤¥×: %d", use_realm);
 #else
-               sprintf(p, "Unknown type: %d.", realm);
+               sprintf(p, "Unknown type: %d.", use_realm);
 #endif
        }
 }
@@ -4407,7 +4416,7 @@ static void spell_info(char *p, int spell, int realm)
 /*
  * Print a list of spells (for browsing or casting or viewing)
  */
-void print_spells(int target_spell, byte *spells, int num, int y, int x, int realm)
+void print_spells(int target_spell, byte *spells, int num, int y, int x, int use_realm)
 {
        int             i, spell, shougou, increment = 64;
        magic_type      *s_ptr;
@@ -4421,7 +4430,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)) && p_ptr->wizard)
+       if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard)
 #ifdef JP
 msg_print("·Ù¹ð¡ª print_spell ¤¬Îΰè¤Ê¤·¤Ë¸Æ¤Ð¤ì¤¿");
 #else
@@ -4431,7 +4440,7 @@ msg_print("
 
        /* Title the list */
        prt("", y, x);
-       if (realm+1 == REALM_HISSATSU)
+       if (use_realm == REALM_HISSATSU)
 #ifdef JP
                strcpy(buf,"  Lv   MP");
 #else
@@ -4453,8 +4462,8 @@ put_str(buf, y, x + 29);
 #endif
 
        if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0;
-       else if ((realm + 1) == p_ptr->realm1) increment = 0;
-       else if ((realm + 1) == p_ptr->realm2) increment = 32;
+       else if (use_realm == p_ptr->realm1) increment = 0;
+       else if (use_realm == p_ptr->realm2) increment = 32;
 
        /* Dump the spells */
        for (i = 0; i < num; i++)
@@ -4463,20 +4472,20 @@ put_str(buf, y, x + 29);
                spell = spells[i];
 
                /* Access the spell */
-               if (!is_magic(realm+1))
+               if (!is_magic(use_realm))
                {
-                       s_ptr = &technic_info[realm - MIN_TECHNIC][spell];
+                       s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
                }
                else
                {
-                       s_ptr = &mp_ptr->info[realm][spell];
+                       s_ptr = &mp_ptr->info[use_realm - 1][spell];
                }
 
-               if (realm+1 == REALM_HISSATSU)
+               if (use_realm == REALM_HISSATSU)
                        shouhimana = s_ptr->smana;
                else
                {
-                       s16b exp = experience_of_spell(spell, realm);
+                       s16b exp = experience_of_spell(spell, use_realm);
 
                        /* Extract mana consumption rate */
                        shouhimana = s_ptr->smana*(3800 - exp) + 2399;
@@ -4533,7 +4542,7 @@ strcat(out_val, format("%-30s", "(Ƚ
                /* XXX XXX Could label spells above the players level */
 
                /* Get extra info */
-               spell_info(info, spell, realm);
+               spell_info(info, spell, use_realm);
 
                /* Use that info */
                comment = info;
@@ -4565,7 +4574,7 @@ comment = " ˺
                                line_attr = TERM_YELLOW;
                        }
                }
-               else if ((realm+1 != p_ptr->realm1) && (realm+1 != p_ptr->realm2))
+               else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2))
                {
 #ifdef JP
 comment = " Ì¤ÃÎ";
@@ -4575,7 +4584,7 @@ comment = " ̤
 
                        line_attr = TERM_L_BLUE;
                }
-               else if ((realm + 1 == p_ptr->realm1) ?
+               else if ((use_realm == p_ptr->realm1) ?
                    ((p_ptr->spell_forgotten1 & (1L << spell))) :
                    ((p_ptr->spell_forgotten2 & (1L << spell))))
                {
@@ -4587,7 +4596,7 @@ comment = " ˺
 
                        line_attr = TERM_YELLOW;
                }
-               else if (!((realm + 1 == p_ptr->realm1) ?
+               else if (!((use_realm == p_ptr->realm1) ?
                    (p_ptr->spell_learned1 & (1L << spell)) :
                    (p_ptr->spell_learned2 & (1L << spell))))
                {
@@ -4599,7 +4608,7 @@ comment = " ̤
 
                        line_attr = TERM_L_BLUE;
                }
-               else if (!((realm + 1 == p_ptr->realm1) ?
+               else if (!((use_realm == p_ptr->realm1) ?
                    (p_ptr->spell_worked1 & (1L << spell)) :
                    (p_ptr->spell_worked2 & (1L << spell))))
                {
@@ -4613,18 +4622,18 @@ comment = " ̤
                }
 
                /* Dump the spell --(-- */
-               if (realm+1 == REALM_HISSATSU)
+               if (use_realm == REALM_HISSATSU)
                {
                        strcat(out_val, format("%-25s %2d %4d",
-                           spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+                           spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
                            s_ptr->slevel, shouhimana));
                }
                else
                {
                        strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%%%s",
-                           spell_names[technic2magic(realm+1)-1][spell], /* realm, spell */
+                           spell_names[technic2magic(use_realm)-1][spell], /* realm, spell */
                            (max ? '!' : ' '), ryakuji,
-                           s_ptr->slevel, shouhimana, spell_chance(spell, realm), comment));
+                           s_ptr->slevel, shouhimana, spell_chance(spell, use_realm), comment));
                }
                c_prt(line_attr, out_val, y + i + 1, x);
        }
@@ -4796,10 +4805,10 @@ bool hates_cold(object_type *o_ptr)
  */
 int set_acid_destroy(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        if (!hates_acid(o_ptr)) return (FALSE);
-       object_flags(o_ptr, &f1, &f2, &f3);
-       if (f3 & TR3_IGNORE_ACID) return (FALSE);
+       object_flags(o_ptr, flgs);
+       if (have_flag(flgs, TR_IGNORE_ACID)) return (FALSE);
        return (TRUE);
 }
 
@@ -4809,10 +4818,10 @@ int set_acid_destroy(object_type *o_ptr)
  */
 int set_elec_destroy(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        if (!hates_elec(o_ptr)) return (FALSE);
-       object_flags(o_ptr, &f1, &f2, &f3);
-       if (f3 & TR3_IGNORE_ELEC) return (FALSE);
+       object_flags(o_ptr, flgs);
+       if (have_flag(flgs, TR_IGNORE_ELEC)) return (FALSE);
        return (TRUE);
 }
 
@@ -4822,10 +4831,10 @@ int set_elec_destroy(object_type *o_ptr)
  */
 int set_fire_destroy(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        if (!hates_fire(o_ptr)) return (FALSE);
-       object_flags(o_ptr, &f1, &f2, &f3);
-       if (f3 & TR3_IGNORE_FIRE) return (FALSE);
+       object_flags(o_ptr, flgs);
+       if (have_flag(flgs, TR_IGNORE_FIRE)) return (FALSE);
        return (TRUE);
 }
 
@@ -4835,10 +4844,10 @@ int set_fire_destroy(object_type *o_ptr)
  */
 int set_cold_destroy(object_type *o_ptr)
 {
-       u32b f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        if (!hates_cold(o_ptr)) return (FALSE);
-       object_flags(o_ptr, &f1, &f2, &f3);
-       if (f3 & TR3_IGNORE_COLD) return (FALSE);
+       object_flags(o_ptr, flgs);
+       if (have_flag(flgs, TR_IGNORE_COLD)) return (FALSE);
        return (TRUE);
 }
 
@@ -4949,7 +4958,7 @@ o_name, index_to_label(i),
 static int minus_ac(void)
 {
        object_type *o_ptr = NULL;
-       u32b        f1, f2, f3;
+       u32b flgs[TR_FLAG_SIZE];
        char        o_name[MAX_NLEN];
 
 
@@ -4978,10 +4987,10 @@ static int minus_ac(void)
        object_desc(o_name, o_ptr, FALSE, 0);
 
        /* Extract the flags */
-       object_flags(o_ptr, &f1, &f2, &f3);
+       object_flags(o_ptr, flgs);
 
        /* Object resists */
-       if (f3 & TR3_IGNORE_ACID)
+       if (have_flag(flgs, TR_IGNORE_ACID))
        {
 #ifdef JP
 msg_format("¤·¤«¤·%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤«¤Ã¤¿¡ª", o_name);
@@ -5020,8 +5029,9 @@ msg_format("%s
 /*
  * Hurt the player with Acid
  */
-void acid_dam(int dam, cptr kb_str, int monspell)
+int acid_dam(int dam, cptr kb_str, int monspell)
 {
+       int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = (p_ptr->oppose_acid  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
 
@@ -5029,7 +5039,7 @@ void acid_dam(int dam, cptr kb_str, int monspell)
        if (p_ptr->immune_acid || (dam <= 0))
        {
                learn_spell(monspell);
-               return;
+               return 0;
        }
 
        /* Vulnerability (Ouch!) */
@@ -5048,19 +5058,21 @@ void acid_dam(int dam, cptr kb_str, int monspell)
        if (minus_ac()) dam = (dam + 1) / 2;
 
        /* Take damage */
-       take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_acid))
                inven_damage(set_acid_destroy, inv);
+       return get_damage;
 }
 
 
 /*
  * Hurt the player with electricity
  */
-void elec_dam(int dam, cptr kb_str, int monspell)
+int elec_dam(int dam, cptr kb_str, int monspell)
 {
+       int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = (p_ptr->oppose_elec  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
 
@@ -5068,7 +5080,7 @@ void elec_dam(int dam, cptr kb_str, int monspell)
        if (p_ptr->immune_elec || (dam <= 0))
        {
                learn_spell(monspell);
-               return;
+               return 0;
        }
 
        /* Vulnerability (Ouch!) */
@@ -5085,19 +5097,22 @@ void elec_dam(int dam, cptr kb_str, int monspell)
                (void)do_dec_stat(A_DEX);
 
        /* Take damage */
-       take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_elec))
                inven_damage(set_elec_destroy, inv);
+
+       return get_damage;
 }
 
 
 /*
  * Hurt the player with Fire
  */
-void fire_dam(int dam, cptr kb_str, int monspell)
+int fire_dam(int dam, cptr kb_str, int monspell)
 {
+       int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = (p_ptr->oppose_fire  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
 
@@ -5105,7 +5120,7 @@ void fire_dam(int dam, cptr kb_str, int monspell)
        if (p_ptr->immune_fire || (dam <= 0))
        {
                learn_spell(monspell);
-               return;
+               return 0;
        }
 
        /* Vulnerability (Ouch!) */
@@ -5122,19 +5137,22 @@ void fire_dam(int dam, cptr kb_str, int monspell)
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
-       take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_fire))
                inven_damage(set_fire_destroy, inv);
+
+       return get_damage;
 }
 
 
 /*
  * Hurt the player with Cold
  */
-void cold_dam(int dam, cptr kb_str, int monspell)
+int cold_dam(int dam, cptr kb_str, int monspell)
 {
+       int get_damage;  
        int inv = (dam < 30) ? 1 : (dam < 60) ? 2 : 3;
        bool double_resist = (p_ptr->oppose_cold  || music_singing(MUSIC_RESIST) || (p_ptr->special_defense & KATA_MUSOU));
 
@@ -5142,7 +5160,7 @@ void cold_dam(int dam, cptr kb_str, int monspell)
        if (p_ptr->immune_cold || (dam <= 0))
        {
                learn_spell(monspell);
-               return;
+               return 0;
        }
 
        /* Vulnerability (Ouch!) */
@@ -5158,11 +5176,13 @@ void cold_dam(int dam, cptr kb_str, int monspell)
                (void)do_dec_stat(A_STR);
 
        /* Take damage */
-       take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
+       get_damage=take_hit(DAMAGE_ATTACK, dam, kb_str, monspell);
 
        /* Inventory damage */
        if (!(double_resist && p_ptr->resist_cold))
                inven_damage(set_cold_destroy, inv);
+
+       return get_damage;
 }
 
 
@@ -5204,7 +5224,7 @@ s = "
        /* Description */
        object_desc(o_name, o_ptr, FALSE, 0);
 
-       o_ptr->art_flags3 |= TR3_IGNORE_ACID;
+       add_flag(o_ptr->art_flags, TR_IGNORE_ACID);
 
        if ((o_ptr->to_a < 0) && !cursed_p(o_ptr))
        {
@@ -5239,6 +5259,7 @@ msg_format("%s
  */
 bool curse_armor(void)
 {
+       int i;
        object_type *o_ptr;
 
        char o_name[MAX_NLEN];
@@ -5263,7 +5284,7 @@ msg_format("%s
 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Ëɶñ", o_name);
 #else
                msg_format("A %s tries to %s, but your %s resists the effects!",
-                          "terrible black aura", "surround your armor", o_name);
+                          "terrible black aura", "surround your armor", o_name);
 #endif
 
        }
@@ -5289,9 +5310,9 @@ msg_format("
                o_ptr->ac = 0;
                o_ptr->dd = 0;
                o_ptr->ds = 0;
-               o_ptr->art_flags1 = 0;
-               o_ptr->art_flags2 = 0;
-               o_ptr->art_flags3 = 0;
+
+               for (i = 0; i < TR_FLAG_SIZE; i++)
+                       o_ptr->art_flags[i] = 0;
 
                /* Curse it */
                o_ptr->curse_flags = TRC_CURSED;
@@ -5318,6 +5339,8 @@ msg_format("
  */
 bool curse_weapon(bool force, int slot)
 {
+       int i;
+
        object_type *o_ptr;
 
        char o_name[MAX_NLEN];
@@ -5342,7 +5365,7 @@ msg_format("%s
 "¶²ÉݤΰŹõ¥ª¡¼¥é", "Éð´ï", o_name);
 #else
                msg_format("A %s tries to %s, but your %s resists the effects!",
-                          "terrible black aura", "surround your weapon", o_name);
+                          "terrible black aura", "surround your weapon", o_name);
 #endif
 
        }
@@ -5368,9 +5391,9 @@ if (!force) msg_format("
                o_ptr->ac = 0;
                o_ptr->dd = 0;
                o_ptr->ds = 0;
-               o_ptr->art_flags1 = 0;
-               o_ptr->art_flags2 = 0;
-               o_ptr->art_flags3 = 0;
+
+               for (i = 0; i < TR_FLAG_SIZE; i++)
+                       o_ptr->art_flags[i] = 0;
 
 
                /* Curse it */
@@ -5546,8 +5569,8 @@ bool polymorph_monster(int y, int x)
                else
                {
                        /* Placing the new monster failed */
-                       place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN));
-                       m_list[hack_m_idx_ii] = back_m;
+                       if (place_monster_aux(0, y, x, old_r_idx, (mode | PM_NO_KAGE | PM_IGNORE_TERRAIN)))
+                               m_list[hack_m_idx_ii] = back_m;
                }
 
                if (targeted) target_who = hack_m_idx_ii;
@@ -5845,8 +5868,8 @@ msg_format("
 #endif
 
                                        /* Reduce rod stack maximum timeout, drain wands. */
-                                       if (o_ptr->tval == TV_ROD) o_ptr->timeout -= k_ptr->pval;
-                                       if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
+                                       if (o_ptr->tval == TV_ROD) o_ptr->timeout = MIN(o_ptr->timeout, k_ptr->pval * (o_ptr->number - 1));
+                                       else if (o_ptr->tval == TV_WAND) o_ptr->pval = o_ptr->pval * (o_ptr->number - 1) / o_ptr->number;
 
                                }
                                else