OSDN Git Service

Stop hex spell at the time of start searting
[hengband/hengband.git] / src / effects.c
index eacc0f2..45b3861 100644 (file)
@@ -87,6 +87,16 @@ void set_action(int typ)
 #else
                                msg_print("You are no longer walking extremely fast.");
 #endif
+                               energy_use = 100;
+                               break;
+                       }
+                       case ACTION_SPELL:
+                       {
+#ifdef JP
+                               msg_print("¼öʸ¤Î±Ó¾§¤òÃæÃǤ·¤¿¡£");
+#else
+                               msg_print("You stopped spelling all spells.");
+#endif
                                break;
                        }
                }
@@ -96,6 +106,7 @@ void set_action(int typ)
 
        /* If we are requested other action, stop singing */
        if (prev_typ == ACTION_SING) stop_singing();
+       if (prev_typ == ACTION_SPELL) stop_hex_spell();
 
        switch (p_ptr->action)
        {
@@ -182,6 +193,7 @@ void reset_tim_flags(void)
        p_ptr->tim_sh_fire = 0;
        p_ptr->tim_sh_holy = 0;
        p_ptr->tim_eyeeye = 0;
+       p_ptr->magicdef = 0;
        p_ptr->resist_magic = 0;
        p_ptr->tsuyoshi = 0;
        p_ptr->kabenuke = 0;
@@ -219,23 +231,9 @@ void reset_tim_flags(void)
 
        if (p_ptr->riding)
        {
-               monster_type *m_ptr = &m_list[p_ptr->riding];
-
-               if (m_ptr->fast)
-               {
-                       m_ptr->fast = 0;
-                       mproc_remove(p_ptr->riding, m_ptr->mproc_idx[MPROC_FAST], MPROC_FAST);
-               }
-               if (m_ptr->slow)
-               {
-                       m_ptr->slow = 0;
-                       mproc_remove(p_ptr->riding, m_ptr->mproc_idx[MPROC_SLOW], MPROC_SLOW);
-               }
-               if (m_ptr->invulner)
-               {
-                       m_ptr->invulner = 0;
-                       mproc_remove(p_ptr->riding, m_ptr->mproc_idx[MPROC_INVULNER], MPROC_INVULNER);
-               }
+               (void)set_monster_fast(p_ptr->riding, 0);
+               (void)set_monster_slow(p_ptr->riding, 0);
+               (void)set_monster_invulner(p_ptr->riding, 0, FALSE);
        }
 
        if (p_ptr->pclass == CLASS_BARD)
@@ -246,6 +244,93 @@ void reset_tim_flags(void)
 }
 
 
+void dispel_player(void)
+{
+       (void)set_fast(0, TRUE);
+       (void)set_lightspeed(0, TRUE);
+       (void)set_slow(0, TRUE);
+       (void)set_shield(0, TRUE);
+       (void)set_blessed(0, TRUE);
+       (void)set_tsuyoshi(0, TRUE);
+       (void)set_hero(0, TRUE);
+       (void)set_shero(0, TRUE);
+       (void)set_protevil(0, TRUE);
+       (void)set_invuln(0, TRUE);
+       (void)set_wraith_form(0, TRUE);
+       (void)set_kabenuke(0, TRUE);
+       (void)set_tim_res_nether(0, TRUE);
+       (void)set_tim_res_time(0, TRUE);
+       /* by henkma */
+       (void)set_tim_reflect(0,TRUE);
+       (void)set_multishadow(0,TRUE);
+       (void)set_dustrobe(0,TRUE);
+
+       (void)set_tim_invis(0, TRUE);
+       (void)set_tim_infra(0, TRUE);
+       (void)set_tim_esp(0, TRUE);
+       (void)set_tim_regen(0, TRUE);
+       (void)set_tim_stealth(0, TRUE);
+       (void)set_tim_levitation(0, TRUE);
+       (void)set_tim_sh_touki(0, TRUE);
+       (void)set_tim_sh_fire(0, TRUE);
+       (void)set_tim_sh_holy(0, TRUE);
+       (void)set_tim_eyeeye(0, TRUE);
+       (void)set_magicdef(0, TRUE);
+       (void)set_resist_magic(0, TRUE);
+       (void)set_oppose_acid(0, TRUE);
+       (void)set_oppose_elec(0, TRUE);
+       (void)set_oppose_fire(0, TRUE);
+       (void)set_oppose_cold(0, TRUE);
+       (void)set_oppose_pois(0, TRUE);
+       (void)set_ultimate_res(0, TRUE);
+       (void)set_mimic(0, 0, TRUE);
+       (void)set_ele_attack(0, 0);
+       (void)set_ele_immune(0, 0);
+
+       /* Cancel glowing hands */
+       if (p_ptr->special_attack & ATTACK_CONFUSE)
+       {
+               p_ptr->special_attack &= ~(ATTACK_CONFUSE);
+#ifdef JP
+               msg_print("¼ê¤Îµ±¤­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
+#else
+               msg_print("Your hands stop glowing.");
+#endif
+       }
+
+       if (music_singing_any() || hex_spelling_any())
+       {
+#ifdef JP
+               cptr str = (music_singing_any()) ? "²Î" : "¼öʸ";
+#else
+               cptr str = (music_singing_any()) ? "singing" : "spelling";
+#endif
+               p_ptr->magic_num1[1] = p_ptr->magic_num1[0];
+               p_ptr->magic_num1[0] = 0;
+#ifdef JP
+               msg_format("%s¤¬ÅÓÀڤ줿¡£", str);
+#else
+               msg_format("Your %s is interrupted.", str);
+#endif
+               p_ptr->action = ACTION_NONE;
+
+               /* Recalculate bonuses */
+               p_ptr->update |= (PU_BONUS | PU_HP);
+
+               /* Redraw map */
+               p_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
+
+               /* Update monsters */
+               p_ptr->update |= (PU_MONSTERS);
+
+               /* Window stuff */
+               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+
+               p_ptr->energy_need += ENERGY_NEED();
+       }
+}
+
+
 /*
  * Set "p_ptr->tim_mimic", and "p_ptr->mimic_form",
  * notice observable changes
@@ -303,8 +388,7 @@ bool set_mimic(int v, int p, bool do_dec)
                return (FALSE);
 
        /* Disturb */
-       if (disturb_state)
-               disturb(0, 0);
+       if (disturb_state) disturb(0, 1);
 
        /* Redraw title */
        p_ptr->redraw |= (PR_BASIC | PR_STATUS);
@@ -479,6 +563,12 @@ msg_print("
                                p_ptr->action = ACTION_NONE;
                        }
 
+                       /* Sniper */
+                       if (p_ptr->concent) reset_concentration(TRUE);
+
+                       /* Hex */
+                       if (hex_spelling_any()) stop_hex_spell_all();
+
                        notice = TRUE;
                        p_ptr->counter = FALSE;
                        chg_virtue(V_HARMONY, -1);
@@ -685,6 +775,12 @@ msg_print("
                        msg_print("You are paralyzed!");
 #endif
 
+                       /* Sniper */
+                       if (p_ptr->concent) reset_concentration(TRUE);
+
+                       /* Hex */
+                       if (hex_spelling_any()) stop_hex_spell_all();
+
                        p_ptr->counter = FALSE;
                        notice = TRUE;
                }
@@ -755,6 +851,9 @@ msg_print("
                        msg_print("Oh, wow! Everything looks so cosmic now!");
 #endif
 
+                       /* Sniper */
+                       if (p_ptr->concent) reset_concentration(TRUE);
+
                        p_ptr->counter = FALSE;
                        notice = TRUE;
                }
@@ -785,11 +884,14 @@ msg_print("
        if (!notice) return (FALSE);
 
        /* Disturb */
-       if (disturb_state) disturb(0, 0);
+       if (disturb_state) disturb(0, 1);
 
        /* Redraw map */
        p_ptr->redraw |= (PR_MAP);
 
+       /* Update the health bar */
+       p_ptr->redraw |= (PR_HEALTH | PR_UHEALTH);
+
        /* Update monsters */
        p_ptr->update |= (PU_MONSTERS);
 
@@ -884,6 +986,8 @@ bool set_lightspeed(int v, bool do_dec)
 
        if (p_ptr->is_dead) return FALSE;
 
+       if (p_ptr->wild_mode) v = 0;
+
        /* Open */
        if (v)
        {
@@ -3538,6 +3642,12 @@ msg_print("
                        p_ptr->action = ACTION_NONE;
                }
 
+               /* Sniper */
+               if (p_ptr->concent) reset_concentration(TRUE);
+
+               /* Hex */
+               if (hex_spelling_any()) stop_hex_spell_all();
+
                /* Notice */
                notice = TRUE;
        }
@@ -4817,7 +4927,7 @@ msg_print("
        if ((power > randint0(20)) && one_in_(3) && (p_ptr->prace != RACE_ANDROID))
        {
                char effect_msg[80] = "";
-               int new_race, expfact, goalexpfact;
+               int new_race;
 
                /* Some form of racial polymorph... */
                power -= 10;
@@ -4908,21 +5018,11 @@ msg_print("
 
                }
 
-               /*
-                * Restrict the race choices by exp penalty so
-                * weak polymorph always means weak race
-                */
-               if (power < 0)
-                       goalexpfact = 100;
-               else
-                       goalexpfact = 100 + 3 * randint0(power);
-
                do
                {
                        new_race = randint0(MAX_RACES);
-                       expfact = race_info[new_race].r_exp;
                }
-               while (((new_race == p_ptr->prace) && (expfact > goalexpfact)) || (new_race == RACE_ANDROID));
+               while ((new_race == p_ptr->prace) || (new_race == RACE_ANDROID));
 
                change_race(new_race, effect_msg);
        }
@@ -5018,7 +5118,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
        if (damage_type != DAMAGE_USELIFE)
        {
                /* Disturb */
-               disturb(1, 0);
+               disturb(1, 1);
                if (auto_more)
                {
                        now_damaged = TRUE;
@@ -5054,8 +5154,7 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                        }
                }
 
-               /* Multishadow effects is determined by turn */
-               if (p_ptr->multishadow && (turn & 1))
+               if (CHECK_MULTISHADOW())
                {
                        if (damage_type == DAMAGE_FORCE)
                        {
@@ -5114,8 +5213,6 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
        /* Window stuff */
        p_ptr->window |= (PW_PLAYER);
 
-       handle_stuff();
-
        if (damage_type != DAMAGE_GENO && p_ptr->chp == 0)
        {
                chg_virtue(V_SACRIFICE, 1);
@@ -5125,7 +5222,6 @@ 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 */
@@ -5138,6 +5234,8 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
 
                chg_virtue(V_SACRIFICE, 10);
 
+               handle_stuff();
+
                /* Leaving */
                p_ptr->leaving = TRUE;
 
@@ -5158,6 +5256,8 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
                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 */
@@ -5165,46 +5265,73 @@ int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
 #endif
 
                        /* Note cause of death */
+                       if (seppuku)
+                       {
+                               strcpy(p_ptr->died_from, hit_from);
+#ifdef JP
+                               if (!winning_seppuku) strcpy(p_ptr->died_from, "ÀÚÊ¢");
+#endif
+                       }
+                       else
+                       {
+                               char dummy[1024];
 #ifdef JP
-                       sprintf(p_ptr->died_from, "%s%s%s", !p_ptr->paralyzed ? "" : p_ptr->free_act ? "ĦÁü¾õÂÖ¤Ç":"Ëãáã¾õÂÖ¤Ç", p_ptr->image ? "¸¸³Ð¤ËÏĤó¤À" : "", hit_from);
+                               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[20];
+
+                               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 (q_idx && (is_fixed_quest_idx(q_idx) &&
-                                !((q_idx == QUEST_OBERON) || (q_idx == 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
-                               sprintf(buf,"%d³¬", dun_level);
+                                       strcpy(buf,"¥¯¥¨¥¹¥È");
 #else
-                               sprintf(buf,"level %d", dun_level);
+                                       strcpy(buf,"in a quest");
 #endif
+                               else
 #ifdef JP
-                       sprintf(tmp,"%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£",buf, p_ptr->died_from);
+                                       sprintf(buf,"%d³¬", dun_level);
 #else
-                       sprintf(tmp,"killed by %s %s.", p_ptr->died_from, buf);
+                                       sprintf(buf,"level %d", dun_level);
 #endif
-                       do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
+
+#ifdef JP
+                               sprintf(tmp, "%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", buf, p_ptr->died_from);
+#else
+                               sprintf(tmp, "killed by %s %s.", p_ptr->died_from, buf);
+#endif
+                               do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
+                       }
+
 #ifdef JP
                        do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
 #else
@@ -5215,11 +5342,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();
                        }
@@ -5234,7 +5360,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
@@ -5243,10 +5369,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
@@ -5254,16 +5380,26 @@ 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
                                }
+
+                               do
+                               {
+#ifdef JP
+                                       while (!get_string(winning_seppuku ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
+#else
+                                       while (!get_string("Last word: ", death_message, 1024)) ;
+#endif
+                               }
 #ifdef JP
-                               while (!get_string(streq(p_ptr->died_from, "Seppuku") ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
+                               while (winning_seppuku && !get_check_strict("¤è¤í¤·¤¤¤Ç¤¹¤«¡©", CHECK_NO_HISTORY));
 #else
-                               while (!get_string("Last word: ", death_message, 1024)) ;
+                               while (winning_seppuku && !get_check_strict("Are you sure? ", CHECK_NO_HISTORY));
 #endif
+
                                if (death_message[0] == '\0')
                                {
 #ifdef JP
@@ -5274,63 +5410,61 @@ get_rnd_line("death_j.txt", 0, death_message);
                                }
                                else p_ptr->last_message = string_make(death_message);
 
-                               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 = my_strstr(str, "¡×");
-                                 if (str2 != NULL) *str2 = '\0';
-
-                                 i = 0;
-                                 while (i < 9)
-                                 {
-                                   str2 = my_strstr(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();
+                               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 = my_strstr(str, "¡×");
+                                       if (str2 != NULL) *str2 = '\0';
+
+                                       i = 0;
+                                       while (i < 9)
+                                       {
+                                               str2 = my_strstr(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();
+                                       /* Make screen dump */
+                                       screen_dump = make_screen_dump();
 #endif
 
-                                 /* Wait a key press */
-                                 (void)inkey();
-#else
-                                       msg_print(death_message);
-#endif
+                                       /* Wait a key press */
+                                       (void)inkey();
                                }
                                else
+#endif
                                        msg_print(death_message);
                        }
                }
@@ -5339,6 +5473,8 @@ get_rnd_line("death_j.txt", 0, death_message);
                return damage;
        }
 
+       handle_stuff();
+
        /* Hitpoint warning */
        if (p_ptr->chp < warning)
        {
@@ -5357,7 +5493,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