OSDN Git Service

This commit was manufactured by cvs2svn to create tag
[hengbandforosx/hengbandosx.git] / src / effects.c
index 086f41c..a97a2ec 100644 (file)
@@ -1,26 +1,28 @@
 /* File: effects.c */
 
-/* Purpose: effects of various "objects" */
-
 /*
- * 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: effects of various "objects" */
+
 #include "angband.h"
 
 void set_action(int typ)
 {
-       if (typ == p_ptr->action)
+       int prev_typ = p_ptr->action;
+
+       if (typ == prev_typ)
        {
                return;
        }
        else
        {
-               switch(p_ptr->action)
+               switch (prev_typ)
                {
                        case ACTION_SEARCH:
                        {
@@ -92,7 +94,10 @@ void set_action(int typ)
 
        p_ptr->action = typ;
 
-       switch(p_ptr->action)
+       /* If we are requested other action, stop singing */
+       if (prev_typ == ACTION_SING) stop_singing();
+
+       switch (p_ptr->action)
        {
                case ACTION_SEARCH:
                {
@@ -171,6 +176,7 @@ void reset_tim_flags(void)
        p_ptr->tim_regen = 0;       /* Timed -- Regeneration */
        p_ptr->tim_stealth = 0;     /* Timed -- Stealth */
        p_ptr->tim_esp = 0;
+       p_ptr->wraith_form = 0;     /* Timed -- Wraith Form */
        p_ptr->tim_ffall = 0;
        p_ptr->tim_sh_touki = 0;
        p_ptr->tim_sh_fire = 0;
@@ -195,7 +201,8 @@ void reset_tim_flags(void)
        p_ptr->oppose_cold = 0;     /* Timed -- oppose cold */
        p_ptr->oppose_pois = 0;     /* Timed -- oppose poison */
 
-       p_ptr->word_recall = FALSE;
+       p_ptr->word_recall = 0;
+       p_ptr->alter_reality = 0;
        p_ptr->sutemi = FALSE;
        p_ptr->counter = FALSE;
        p_ptr->ele_attack = 0;
@@ -245,14 +252,14 @@ bool set_mimic(int v, int p, bool do_dec)
                {
                        if (p_ptr->tim_mimic > v) return FALSE;
                }
-                else if ((!p_ptr->tim_mimic) || (p_ptr->mimic_form != p))
+               else if ((!p_ptr->tim_mimic) || (p_ptr->mimic_form != p))
                {
 #ifdef JP
-                        msg_print("¼«Ê¬¤ÎÂΤ¬ÊѤï¤Ã¤Æ¤æ¤¯¤Î¤ò´¶¤¸¤¿¡£");
+                       msg_print("¼«Ê¬¤ÎÂΤ¬ÊѤï¤Ã¤Æ¤æ¤¯¤Î¤ò´¶¤¸¤¿¡£");
 #else
-                        msg_print("You feel that your body changes.");
+                       msg_print("You feel that your body changes.");
 #endif
-                        p_ptr->mimic_form=p;
+                       p_ptr->mimic_form=p;
                        notice = TRUE;
                }
        }
@@ -260,22 +267,22 @@ bool set_mimic(int v, int p, bool do_dec)
        /* Shut */
        else
        {
-                if (p_ptr->tim_mimic)
+               if (p_ptr->tim_mimic)
                {
 #ifdef JP
-                        msg_print("ÊѿȤ¬²ò¤±¤¿¡£");
+                       msg_print("ÊѿȤ¬²ò¤±¤¿¡£");
 #else
-                        msg_print("You are no longer transformed.");
+                       msg_print("You are no longer transformed.");
 #endif
                        if (p_ptr->mimic_form == MIMIC_DEMON) set_oppose_fire(0, TRUE);
-                        p_ptr->mimic_form=0;
+                       p_ptr->mimic_form=0;
                        notice = TRUE;
                        p = 0;
                }
        }
 
        /* Use the value */
-        p_ptr->tim_mimic = v;
+       p_ptr->tim_mimic = v;
 
        /* Nothing to notice */
        if (!notice)
@@ -285,11 +292,11 @@ bool set_mimic(int v, int p, bool do_dec)
        if (disturb_state)
                disturb(0, 0);
 
-        /* Redraw title */
-        p_ptr->redraw |= (PR_BASIC | PR_STATUS);
+       /* Redraw title */
+       p_ptr->redraw |= (PR_BASIC | PR_STATUS);
 
        /* Recalculate bonuses */
-        p_ptr->update |= (PU_BONUS | PU_HP);
+       p_ptr->update |= (PU_BONUS | PU_HP);
 
        handle_stuff();
 
@@ -380,7 +387,7 @@ msg_print("
        if (disturb_state) disturb(0, 0);
 
        /* Fully update the visuals */
-       p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_MONSTERS);
+       p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
 
        /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
@@ -419,6 +426,18 @@ msg_print("
                        msg_print("You are confused!");
 #endif
 
+                       if (p_ptr->action == ACTION_LEARN)
+                       {
+#ifdef JP
+                               msg_print("³Ø½¬¤¬Â³¤±¤é¤ì¤Ê¤¤¡ª");
+#else
+                               msg_print("You cannot continue Learning!");
+#endif
+                               new_mane = FALSE;
+
+                               p_ptr->redraw |= (PR_STATE);
+                               p_ptr->action = ACTION_NONE;
+                       }
                        if (p_ptr->action == ACTION_KAMAE)
                        {
 #ifdef JP
@@ -790,7 +809,7 @@ bool set_fast(int v, bool do_dec)
                {
                        if (p_ptr->fast > v) return FALSE;
                }
-               else if (!p_ptr->fast && !p_ptr->lightspeed)
+               else if (!IS_FAST() && !p_ptr->lightspeed)
                {
 #ifdef JP
 msg_print("ÁÇÁ᤯ư¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
@@ -807,7 +826,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->fast && !p_ptr->lightspeed && ((p_ptr->pclass != CLASS_BARD) || ((p_ptr->magic_num1[0] != MUSIC_SPEED) && (p_ptr->magic_num1[0] != MUSIC_SHERO))))
+               if (p_ptr->fast && !p_ptr->lightspeed && !music_singing(MUSIC_SPEED) && !music_singing(MUSIC_SHERO))
                {
 #ifdef JP
 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
@@ -1202,7 +1221,7 @@ bool set_blessed(int v, bool do_dec)
                {
                        if (p_ptr->blessed > v) return FALSE;
                }
-               else if (!p_ptr->blessed)
+               else if (!IS_BLESSED())
                {
 #ifdef JP
 msg_print("¹â·é¤Êµ¤Ê¬¤Ë¤Ê¤Ã¤¿¡ª");
@@ -1217,7 +1236,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->blessed && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_BLESS)))
+               if (p_ptr->blessed && !music_singing(MUSIC_BLESS))
                {
 #ifdef JP
 msg_print("¹â·é¤Êµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
@@ -1271,7 +1290,7 @@ bool set_hero(int v, bool do_dec)
                {
                        if (p_ptr->hero > v) return FALSE;
                }
-               else if (!p_ptr->hero)
+               else if (!IS_HERO())
                {
 #ifdef JP
 msg_print("¥Ò¡¼¥í¡¼¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -1286,7 +1305,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->hero && ((p_ptr->pclass != CLASS_BARD) || ((p_ptr->magic_num1[0] != MUSIC_HERO) && (p_ptr->magic_num1[0] != MUSIC_SHERO))))
+               if (p_ptr->hero && !music_singing(MUSIC_HERO) && !music_singing(MUSIC_SHERO))
                {
 #ifdef JP
 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
@@ -1577,7 +1596,7 @@ bool set_invuln(int v, bool do_dec)
                {
                        if (p_ptr->invuln > v) return FALSE;
                }
-               else if (!p_ptr->invuln)
+               else if (!IS_INVULN())
                {
 #ifdef JP
 msg_print("̵Ũ¤À¡ª");
@@ -1606,7 +1625,7 @@ msg_print("̵Ũ
        /* Shut */
        else
        {
-               if (p_ptr->invuln && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_INVULN)))
+               if (p_ptr->invuln && !music_singing(MUSIC_INVULN))
                {
 #ifdef JP
 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
@@ -1671,7 +1690,7 @@ bool set_tim_esp(int v, bool do_dec)
                {
                        if (p_ptr->tim_esp > v) return FALSE;
                }
-               else if (!p_ptr->tim_esp)
+               else if (!IS_TIM_ESP())
                {
 #ifdef JP
 msg_print("°Õ¼±¤¬¹­¤¬¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -1686,7 +1705,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->tim_esp && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_MIND)))
+               if (p_ptr->tim_esp && !music_singing(MUSIC_MIND))
                {
 #ifdef JP
 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
@@ -1956,7 +1975,7 @@ bool set_tim_stealth(int v, bool do_dec)
                {
                        if (p_ptr->tim_stealth > v) return FALSE;
                }
-               else if (!p_ptr->tim_stealth)
+               else if (!IS_TIM_STEALTH())
                {
 #ifdef JP
 msg_print("­²»¤¬¾®¤µ¤¯¤Ê¤Ã¤¿¡ª");
@@ -1971,7 +1990,7 @@ msg_print("­
        /* Shut */
        else
        {
-               if (p_ptr->tim_stealth && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_STEALTH)))
+               if (p_ptr->tim_stealth && !music_singing(MUSIC_STEALTH))
                {
 #ifdef JP
 msg_print("­²»¤¬Â礭¤¯¤Ê¤Ã¤¿¡£");
@@ -2905,16 +2924,16 @@ bool set_ele_attack(u32b attack_type, int v)
                             ((attack_type == ATTACK_ACID) ? "»À" :
                              ((attack_type == ATTACK_ELEC) ? "ÅÅ·â" :
                               ((attack_type == ATTACK_FIRE) ? "²Ð±ê" : 
-                               ((attack_type == ATTACK_COLD) ? "Î䵤" : 
-                                ((attack_type == ATTACK_POIS) ? "ÆÇ" : 
+                               ((attack_type == ATTACK_COLD) ? "Î䵤" : 
+                                ((attack_type == ATTACK_POIS) ? "ÆÇ" : 
                                        "(¤Ê¤·)"))))));
 #else
                msg_format("For a while, the blows you deal will %s",
                             ((attack_type == ATTACK_ACID) ? "melt with acid!" :
                              ((attack_type == ATTACK_ELEC) ? "shock your foes!" :
                               ((attack_type == ATTACK_FIRE) ? "burn with fire!" : 
-                               ((attack_type == ATTACK_COLD) ? "chill to the bone!" : 
-                                ((attack_type == ATTACK_POIS) ? "poison your enemies!" : 
+                               ((attack_type == ATTACK_COLD) ? "chill to the bone!" : 
+                                ((attack_type == ATTACK_POIS) ? "poison your enemies!" : 
                                        "do nothing special."))))));
 #endif
        }
@@ -3004,16 +3023,16 @@ bool set_ele_immune(u32b immune_type, int v)
                             ((immune_type == DEFENSE_ACID) ? "»À" :
                              ((immune_type == DEFENSE_ELEC) ? "ÅÅ·â" :
                               ((immune_type == DEFENSE_FIRE) ? "²Ð±ê" : 
-                               ((immune_type == DEFENSE_COLD) ? "Î䵤" : 
-                                ((immune_type == DEFENSE_POIS) ? "ÆÇ" : 
+                               ((immune_type == DEFENSE_COLD) ? "Î䵤" : 
+                                ((immune_type == DEFENSE_POIS) ? "ÆÇ" : 
                                        "(¤Ê¤·)"))))));
 #else
                msg_format("For a while, You are immune to %s",
                             ((immune_type == DEFENSE_ACID) ? "acid!" :
                              ((immune_type == DEFENSE_ELEC) ? "electricity!" :
                               ((immune_type == DEFENSE_FIRE) ? "fire!" : 
-                               ((immune_type == DEFENSE_COLD) ? "cold!" : 
-                                ((immune_type == DEFENSE_POIS) ? "poison!" : 
+                               ((immune_type == DEFENSE_COLD) ? "cold!" : 
+                                ((immune_type == DEFENSE_POIS) ? "poison!" : 
                                        "do nothing special."))))));
 #endif
        }
@@ -3052,7 +3071,7 @@ bool set_oppose_acid(int v, bool do_dec)
                {
                        if (p_ptr->oppose_acid > v) return FALSE;
                }
-               else if (!p_ptr->oppose_acid)
+               else if (!IS_OPPOSE_ACID())
                {
 #ifdef JP
 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -3067,7 +3086,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->oppose_acid && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->oppose_acid && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
                {
 #ifdef JP
 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
@@ -3118,7 +3137,7 @@ bool set_oppose_elec(int v, bool do_dec)
                {
                        if (p_ptr->oppose_elec > v) return FALSE;
                }
-               else if (!p_ptr->oppose_elec)
+               else if (!IS_OPPOSE_ELEC())
                {
 #ifdef JP
 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -3133,7 +3152,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->oppose_elec && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->oppose_elec && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
                {
 #ifdef JP
 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
@@ -3185,7 +3204,7 @@ bool set_oppose_fire(int v, bool do_dec)
                {
                        if (p_ptr->oppose_fire > v) return FALSE;
                }
-               else if (!p_ptr->oppose_fire)
+               else if (!IS_OPPOSE_FIRE())
                {
 #ifdef JP
 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -3200,7 +3219,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->oppose_fire && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->oppose_fire && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
                {
 #ifdef JP
 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
@@ -3251,7 +3270,7 @@ bool set_oppose_cold(int v, bool do_dec)
                {
                        if (p_ptr->oppose_cold > v) return FALSE;
                }
-               else if (!p_ptr->oppose_cold)
+               else if (!IS_OPPOSE_COLD())
                {
 #ifdef JP
 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -3266,7 +3285,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->oppose_cold && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->oppose_cold && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
                {
 #ifdef JP
 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
@@ -3318,7 +3337,7 @@ bool set_oppose_pois(int v, bool do_dec)
                {
                        if (p_ptr->oppose_pois > v) return FALSE;
                }
-               else if (!p_ptr->oppose_pois)
+               else if (!IS_OPPOSE_POIS())
                {
 #ifdef JP
 msg_print("ÆǤؤÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
@@ -3333,7 +3352,7 @@ msg_print("
        /* Shut */
        else
        {
-               if (p_ptr->oppose_pois && ((p_ptr->pclass != CLASS_BARD) || (p_ptr->magic_num1[0] != MUSIC_RESIST)) && !(p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->oppose_pois && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
                {
 #ifdef JP
 msg_print("ÆǤؤÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
@@ -4261,6 +4280,9 @@ bool dec_stat(int stat, int amount, int permanent)
                p_ptr->stat_cur[stat] = cur;
                p_ptr->stat_max[stat] = max;
 
+               /* Redisplay the stats later */
+               p_ptr->redraw |= (PR_STATS);
+
                /* Recalculate bonuses */
                p_ptr->update |= (PU_BONUS);
        }
@@ -4284,6 +4306,9 @@ bool res_stat(int stat)
                /* Recalculate bonuses */
                p_ptr->update |= (PU_BONUS);
 
+               /* Redisplay the stats later */
+               p_ptr->redraw |= (PR_STATS);
+
                /* Success */
                return (TRUE);
        }
@@ -4849,7 +4874,7 @@ msg_print("
                }
                else
                {
-                       p_ptr->old_race2 = 1L << (p_ptr->prace-32);
+                       p_ptr->old_race2 |= 1L << (p_ptr->prace-32);
                }
                p_ptr->prace = new_race;
                rp_ptr = &race_info[p_ptr->prace];
@@ -4918,8 +4943,8 @@ msg_format("%s
                if (one_in_(6))
                {
 #ifdef JP
-msg_print("¸½ºß»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
-take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "Ã×̿Ū¤ÊÆÍÁ³ÊÑ°Û", -1);
+                       msg_print("¸½ºß¤Î»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
+                       take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "Ã×̿Ū¤ÊÆÍÁ³ÊÑ°Û", -1);
 #else
                        msg_print("You find living difficult in your present form!");
                        take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "a lethal mutation", -1);
@@ -4999,7 +5024,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
        /* Mega-Hack -- Apply "invulnerability" */
        if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
        {
-               if ((p_ptr->invuln || ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN))) && (damage < 9000))
+               if (IS_INVULN() && (damage < 9000))
                {
                        if (damage_type == DAMAGE_FORCE)
                        {
@@ -5022,7 +5047,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                                return 0;
                        }
                }
+
                /* Multishadow effects is determined by turn */
                if (p_ptr->multishadow && (turn & 1))
                {
@@ -5044,7 +5069,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                                return 0;
                        }
                }
-                   
+
                if (p_ptr->wraith_form)
                {
                        if (damage_type == DAMAGE_FORCE)
@@ -5062,7 +5087,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                        }
                }
 
-               if ((p_ptr->special_defense & KATA_MUSOU))
+               if (p_ptr->special_defense & KATA_MUSOU)
                {
                        damage /= 2;
                        if ((damage == 0) && one_in_(2)) damage = 1;
@@ -5094,11 +5119,10 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
        /* Dead player */
        if (p_ptr->chp < 0)
        {
-               char buf[10];
                bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
 
 #ifdef JP       /* »à¤ó¤À»þ¤Ë¶¯À©½ªÎ»¤·¤Æ»à¤ò²óÈò¤Ç¤­¤Ê¤¯¤·¤Æ¤ß¤¿ by Habu */
-               if (!munchkin_death)
+               if (!cheat_save)
                        if(!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
 #endif
 
@@ -5115,62 +5139,94 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
 
                if (p_ptr->inside_arena)
                {
-                       cptr m_name = r_name+r_info[arena_monsters[p_ptr->arena_number]].name;
+                       cptr m_name = r_name+r_info[arena_info[p_ptr->arena_number].r_idx].name;
 #ifdef JP
                        msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£", m_name);
 #else
                        msg_format("You are beaten by %s.", m_name);
 #endif
                        msg_print(NULL);
-                       if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, 99, m_name);
+                       if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, -1 - p_ptr->arena_number, m_name);
                }
                else
                {
+                       int q_idx = quest_number(dun_level);
+                       bool seppuku = streq(hit_from, "Seppuku");
+                       bool winning_seppuku = p_ptr->total_winner && seppuku;
+
 #ifdef WORLD_SCORE
                        /* Make screen dump */
                        screen_dump = make_screen_dump();
 #endif
 
                        /* Note cause of death */
+                       if (seppuku)
+                       {
+                               strcpy(p_ptr->died_from, hit_from);
 #ifdef JP
-                       sprintf(p_ptr->died_from, "%s%s%s", !p_ptr->paralyzed ? "" : p_ptr->free_act ? "ĦÁü¾õÂÖ¤Ç":"Ëãáã¾õÂÖ¤Ç", p_ptr->image ? "¸¸³Ð¤ËÏĤó¤À" : "", hit_from);
+                               if (!winning_seppuku) strcpy(p_ptr->died_from, "ÀÚÊ¢");
+#endif
+                       }
+                       else
+                       {
+                               char dummy[1024];
+#ifdef JP
+                               sprintf(dummy, "%s%s%s", !p_ptr->paralyzed ? "" : p_ptr->free_act ? "ĦÁü¾õÂÖ¤Ç" : "Ëãáã¾õÂÖ¤Ç", p_ptr->image ? "¸¸³Ð¤ËÏĤó¤À" : "", hit_from);
 #else
-                       sprintf(p_ptr->died_from, "%s%s", hit_from, !p_ptr->paralyzed ? "" : " while helpless");
+                               sprintf(dummy, "%s%s", hit_from, !p_ptr->paralyzed ? "" : " while helpless");
 #endif
+                               my_strcpy(p_ptr->died_from, dummy, sizeof p_ptr->died_from);
+                       }
 
                        /* No longer a winner */
                        p_ptr->total_winner = FALSE;
 
-                       if (p_ptr->inside_arena)
+                       if (winning_seppuku)
+                       {
 #ifdef JP
-                               strcpy(buf,"¥¢¥ê¡¼¥Ê");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¾¡Íø¤Î¸åÀÚÊ¢¤·¤¿¡£");
 #else
-                               strcpy(buf,"in the Arena");
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "did Seppuku after the winning.");
 #endif
-                       else if (!dun_level)
+                       }
+                       else
+                       {
+                               char buf[10];
+
+                               if (p_ptr->inside_arena)
 #ifdef JP
-                               strcpy(buf,"ÃϾå");
+                                       strcpy(buf,"¥¢¥ê¡¼¥Ê");
 #else
-                               strcpy(buf,"on The surface");
+                                       strcpy(buf,"in the Arena");
 #endif
-                       else if (quest_number(dun_level) && ((quest_number(dun_level) < MIN_RANDOM_QUEST) && !(quest_number(dun_level) == QUEST_OBERON || quest_number(dun_level) == QUEST_SERPENT)))
+                               else if (!dun_level)
 #ifdef JP
-                               strcpy(buf,"¥¯¥¨¥¹¥È");
+                                       strcpy(buf,"ÃϾå");
 #else
-                               strcpy(buf,"in a quest");
+                                       strcpy(buf,"on the surface");
 #endif
-                       else
+                               else if (q_idx && (is_fixed_quest_idx(q_idx) &&
+                                        !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
+#ifdef JP
+                                       strcpy(buf,"¥¯¥¨¥¹¥È");
+#else
+                                       strcpy(buf,"in a quest");
+#endif
+                               else
 #ifdef JP
-                               sprintf(buf,"%d³¬", dun_level);
+                                       sprintf(buf,"%d³¬", dun_level);
 #else
-                               sprintf(buf,"level %d", dun_level);
+                                       sprintf(buf,"level %d", dun_level);
 #endif
+
 #ifdef JP
-                       sprintf(tmp,"%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£",buf, p_ptr->died_from);
+                               sprintf(tmp, "%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", buf, p_ptr->died_from);
 #else
-                       sprintf(tmp,"killed by %s %s.", p_ptr->died_from, buf);
+                               sprintf(tmp, "killed by %s %s.", p_ptr->died_from, buf);
 #endif
-                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
+                       }
+
 #ifdef JP
                        do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
 #else
@@ -5181,11 +5237,10 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                        flush();
 
 #ifdef JP
-if (get_check_strict("²èÌ̤òÊݸ¤·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
+                       if (get_check_strict("²èÌ̤òÊݸ¤·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
 #else
                        if (get_check_strict("Dump the screen? ", CHECK_NO_HISTORY))
 #endif
-
                        {
                                do_cmd_save_screen();
                        }
@@ -5196,7 +5251,7 @@ if (get_check_strict("
                        if (!last_words)
                        {
 #ifdef JP
-msg_format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë");
+                               msg_format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë");
 #else
                                msg_print(android ? "You are broken." : "You die.");
 #endif
@@ -5205,10 +5260,10 @@ msg_format("
                        }
                        else
                        {
-                               if (streq(p_ptr->died_from, "Seppuku"))
+                               if (winning_seppuku)
                                {
 #ifdef JP
-                                 get_rnd_line("seppuku_j.txt", 0, death_message);
+                                       get_rnd_line("seppuku_j.txt", 0, death_message);
 #else
                                        get_rnd_line("seppuku.txt", 0, death_message);
 #endif
@@ -5216,13 +5271,13 @@ msg_format("
                                else
                                {
 #ifdef JP
-get_rnd_line("death_j.txt", 0, death_message);
+                                       get_rnd_line("death_j.txt", 0, death_message);
 #else
                                        get_rnd_line("death.txt", 0, death_message);
 #endif
                                }
 #ifdef JP
-                               while (!get_string(streq(p_ptr->died_from, "Seppuku") ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
+                               while (!get_string(winning_seppuku ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
 #else
                                while (!get_string("Last word: ", death_message, 1024)) ;
 #endif
@@ -5234,53 +5289,62 @@ get_rnd_line("death_j.txt", 0, death_message);
                                        strcpy(death_message, android ? "You are broken." : "You die.");
 #endif
                                }
-                               if (streq(p_ptr->died_from, "Seppuku"))
-                               {
+
 #ifdef JP
-                                 int i, len;
-                                 int w = Term->wid;
-                                 int h = Term->hgt;
-                                 int msg_pos_x[9] = {  5,  7,  9, 12,  14,  17,  19,  21, 23};
-                                 int msg_pos_y[9] = {  3,  4,  5,  4,   5,   4,   5,   6,  4};
-                                 cptr str;
-                                 char* str2;
-
-                                 Term_clear();
-
-                                 /* ºù»¶¤ë */
-                                 for (i = 0; i < 40; i++) 
-                                   Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "¦Ô");
-
-                                 str = death_message;
-                                 if (strncmp(str, "¡Ö", 2) == 0) str += 2;
-
-                                 str2 = strstr_j(str, "¡×");
-                                 if (str2 != NULL) str2 = '\0';
-
-                                 i = 0;
-                                 while (i < 9)
-                                 {
-                                   str2 = strstr_j(str, " ");
-                                   if (str2 == NULL) len = strlen(str);
-                                   else len = str2 - str;
-
-                                   if (len != 0)
-                                   {
-                                     Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
-                                                 TERM_WHITE, str);
-                                     if (str2 == NULL) break;
-                                     i++;
-                                   }
-                                   str = str2 + 1;
-                                   if (*str == 0) break;
-                                 }
-                                 flush();
-                                 (void)inkey();
-#else
-                                       msg_print(death_message);
+                               if (winning_seppuku)
+                               {
+                                       int i, len;
+                                       int w = Term->wid;
+                                       int h = Term->hgt;
+                                       int msg_pos_x[9] = {  5,  7,  9, 12,  14,  17,  19,  21, 23};
+                                       int msg_pos_y[9] = {  3,  4,  5,  4,   5,   4,   5,   6,  4};
+                                       cptr str;
+                                       char* str2;
+
+                                       Term_clear();
+
+                                       /* ºù»¶¤ë */
+                                       for (i = 0; i < 40; i++)
+                                               Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "¦Ô");
+
+                                       str = death_message;
+                                       if (strncmp(str, "¡Ö", 2) == 0) str += 2;
+
+                                       str2 = strstr_j(str, "¡×");
+                                       if (str2 != NULL) *str2 = '\0';
+
+                                       i = 0;
+                                       while (i < 9)
+                                       {
+                                               str2 = strstr_j(str, " ");
+                                               if (str2 == NULL) len = strlen(str);
+                                               else len = str2 - str;
+
+                                               if (len != 0)
+                                               {
+                                                       Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
+                                                       TERM_WHITE, str);
+                                                       if (str2 == NULL) break;
+                                                       i++;
+                                               }
+                                               str = str2 + 1;
+                                               if (*str == 0) break;
+                                       }
+
+                                       /* Hide cursor */
+                                       Term_putstr(w-1, h-1, 1, TERM_WHITE, " ");
+
+                                       flush();
+#ifdef WORLD_SCORE
+                                       /* Make screen dump */
+                                       screen_dump = make_screen_dump();
 #endif
+
+                                       /* Wait a key press */
+                                       (void)inkey();
                                }
                                else
+#endif
                                        msg_print(death_message);
                        }
                }
@@ -5307,7 +5371,7 @@ get_rnd_line("death_j.txt", 0, death_message);
 #endif
 
 #ifdef JP
-                       sprintf(tmp,"%s¤Ë¤è¤Ã¤Æ¥Ô¥ó¥Á¤Ë´Ù¤¤¤Ã¤¿¡£",hit_from);
+                       sprintf(tmp,"%s¤Ë¤è¤Ã¤Æ¥Ô¥ó¥Á¤Ë´Ù¤Ã¤¿¡£",hit_from);
 #else
                        sprintf(tmp,"A critical situation because of %s.",hit_from);
 #endif
@@ -5396,7 +5460,33 @@ void calc_android_exp(void)
                        level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
                        level += MIN(20, a_info[o_ptr->name1].rarity/(a_info[o_ptr->name1].gen_flags & TRG_INSTA_ART ? 10 : 3));
                }
-               else if (o_ptr->name2) level += MAX(3, (e_info[o_ptr->name2].rating - 5)/2);
+               else if (o_ptr->name2)
+               {
+                       level += MAX(3, (e_info[o_ptr->name2].rating - 5)/2);
+               }
+               else if (o_ptr->art_name)
+               {
+                       s32b total_flags = flag_cost(o_ptr, o_ptr->pval);
+                       int fake_level;
+
+                       if (o_ptr->tval >= TV_BOOTS)
+                       {
+                               /* For armors */
+                               if (total_flags < 15000) fake_level = 10;
+                               else if (total_flags < 35000) fake_level = 25;
+                               else fake_level = 40;
+                       }
+                       else
+                       {
+                               /* For weapons */
+                               if (total_flags < 20000) fake_level = 10;
+                               else if (total_flags < 45000) fake_level = 25;
+                               else fake_level = 40;
+                       }
+
+                       level = MAX(level, (level + MAX(fake_level - 8, 5)) / 2 + 3);
+               }
+
                value = object_value_real(q_ptr);
 
                if (value <= 0) continue;
@@ -5453,6 +5543,51 @@ void lose_exp(s32b amount)
        check_experience();
 }
 
+
+/*
+ * Drain experience
+ * If resisted to draining, return FALSE
+ */
+bool drain_exp(s32b drain, s32b slip, int hold_life_prob)
+{
+       /* Androids and their mimics are never drained */
+       if (p_ptr->prace == RACE_ANDROID) return FALSE;
+
+       if (p_ptr->hold_life && (randint0(100) < hold_life_prob))
+       {
+               /* Hold experience */
+#ifdef JP
+               msg_print("¤·¤«¤·¼«¸Ê¤ÎÀ¸Ì¿ÎϤò¼é¤ê¤­¤Ã¤¿¡ª");
+#else
+               msg_print("You keep hold of your life force!");
+#endif
+               return FALSE;
+       }
+
+       /* Hold experience failed */
+       if (p_ptr->hold_life)
+       {
+#ifdef JP
+               msg_print("À¸Ì¿ÎϤò¾¯¤·µÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
+#else
+               msg_print("You feel your life slipping away!");
+#endif
+               lose_exp(slip);
+       }
+       else
+       {
+#ifdef JP
+               msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
+#else
+               msg_print("You feel your life draining away!");
+#endif
+               lose_exp(drain);
+       }
+
+       return TRUE;
+}
+
+
 bool set_ultimate_res(int v, bool do_dec)
 {
        bool notice = FALSE;