OSDN Git Service

[Refactor] #2520 set_fast() をset_acceleration() に改名した
[hengbandforosx/hengbandosx.git] / src / mspell / mspell-dispel.cpp
1 #include "mspell/mspell-dispel.h"
2 #include "blue-magic/blue-magic-checker.h"
3 #include "core/player-redraw-types.h"
4 #include "core/player-update-types.h"
5 #include "core/speed-table.h"
6 #include "core/window-redrawer.h"
7 #include "mind/mind-force-trainer.h"
8 #include "mind/mind-magic-resistance.h"
9 #include "mind/mind-mirror-master.h"
10 #include "monster/monster-info.h"
11 #include "monster/monster-status-setter.h"
12 #include "monster/monster-status.h"
13 #include "mspell/mspell-result.h"
14 #include "mspell/mspell-util.h"
15 #include "player-info/race-info.h"
16 #include "player/attack-defense-types.h"
17 #include "player/player-status.h"
18 #include "realm/realm-song-numbers.h"
19 #include "spell-realm/spells-craft.h"
20 #include "spell-realm/spells-crusade.h"
21 #include "spell-realm/spells-demon.h"
22 #include "spell-realm/spells-hex.h"
23 #include "spell-realm/spells-song.h"
24 #include "status/bad-status-setter.h"
25 #include "status/body-improvement.h"
26 #include "status/buff-setter.h"
27 #include "status/element-resistance.h"
28 #include "status/shape-changer.h"
29 #include "status/sight-setter.h"
30 #include "status/temporary-resistance.h"
31 #include "system/player-type-definition.h"
32 #include "view/display-messages.h"
33
34 /*!
35  * @brief プレイヤーに魔力消去効果を与える。
36  */
37 static void dispel_player(PlayerType *player_ptr)
38 {
39     (void)set_acceleration(player_ptr, 0, true);
40     set_lightspeed(player_ptr, 0, true);
41     (void)BadStatusSetter(player_ptr).slowness(0, true);
42     (void)set_shield(player_ptr, 0, true);
43     (void)set_blessed(player_ptr, 0, true);
44     (void)set_tsuyoshi(player_ptr, 0, true);
45     (void)set_hero(player_ptr, 0, true);
46     (void)set_shero(player_ptr, 0, true);
47     (void)set_protevil(player_ptr, 0, true);
48     (void)set_invuln(player_ptr, 0, true);
49     (void)set_wraith_form(player_ptr, 0, true);
50     (void)set_pass_wall(player_ptr, 0, true);
51     (void)set_tim_res_nether(player_ptr, 0, true);
52     (void)set_tim_res_time(player_ptr, 0, true);
53     (void)set_tim_reflect(player_ptr, 0, true);
54     (void)set_multishadow(player_ptr, 0, true);
55     (void)set_dustrobe(player_ptr, 0, true);
56
57     (void)set_tim_invis(player_ptr, 0, true);
58     (void)set_tim_infra(player_ptr, 0, true);
59     (void)set_tim_esp(player_ptr, 0, true);
60     (void)set_tim_regen(player_ptr, 0, true);
61     (void)set_tim_stealth(player_ptr, 0, true);
62     (void)set_tim_levitation(player_ptr, 0, true);
63     (void)set_tim_sh_force(player_ptr, 0, true);
64     (void)set_tim_sh_fire(player_ptr, 0, true);
65     (void)set_tim_sh_holy(player_ptr, 0, true);
66     (void)set_tim_eyeeye(player_ptr, 0, true);
67     (void)set_magicdef(player_ptr, 0, true);
68     (void)set_resist_magic(player_ptr, 0, true);
69     (void)set_oppose_acid(player_ptr, 0, true);
70     (void)set_oppose_elec(player_ptr, 0, true);
71     (void)set_oppose_fire(player_ptr, 0, true);
72     (void)set_oppose_cold(player_ptr, 0, true);
73     (void)set_oppose_pois(player_ptr, 0, true);
74     (void)set_ultimate_res(player_ptr, 0, true);
75     (void)set_mimic(player_ptr, 0, MimicKindType::NONE, true);
76     (void)set_ele_attack(player_ptr, 0, 0);
77     (void)set_ele_immune(player_ptr, 0, 0);
78
79     if (player_ptr->special_attack & ATTACK_CONFUSE) {
80         player_ptr->special_attack &= ~(ATTACK_CONFUSE);
81         msg_print(_("手の輝きがなくなった。", "Your hands stop glowing."));
82     }
83
84     auto song_interruption = music_singing_any(player_ptr);
85     auto spellhex_interruption = SpellHex(player_ptr).is_spelling_any();
86
87     if (song_interruption || spellhex_interruption) {
88         if (song_interruption) {
89             set_interrupting_song_effect(player_ptr, get_singing_song_effect(player_ptr));
90             set_singing_song_effect(player_ptr, MUSIC_NONE);
91             msg_print(_("歌が途切れた。", "Your singing is interrupted."));
92         }
93         if (spellhex_interruption) {
94             SpellHex(player_ptr).interrupt_spelling();
95             msg_print(_("呪文が途切れた。", "Your casting is interrupted."));
96         }
97
98         player_ptr->action = ACTION_NONE;
99         player_ptr->update |= (PU_BONUS | PU_HP | PU_MONSTERS);
100         player_ptr->redraw |= (PR_MAP | PR_STATUS | PR_STATE);
101         player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
102         player_ptr->energy_need += ENERGY_NEED();
103     }
104 }
105
106 /*!
107  * @brief RF4_DISPELの処理。魔力消去。 /
108  * @param m_idx 呪文を唱えるモンスターID
109  * @param player_ptr プレイヤーへの参照ポインタ
110  * @param t_idx 呪文を受けるモンスターID。プレイヤーの場合はdummyで0とする。
111  * @param target_type プレイヤーを対象とする場合MONSTER_TO_PLAYER、モンスターを対象とする場合MONSTER_TO_MONSTER
112  *
113  * プレイヤーが対象ならラーニング可。
114  */
115 MonsterSpellResult spell_RF4_DISPEL(MONSTER_IDX m_idx, PlayerType *player_ptr, MONSTER_IDX t_idx, int target_type)
116 {
117     auto res = MonsterSpellResult::make_valid();
118     res.learnable = target_type == MONSTER_TO_PLAYER;
119
120     GAME_TEXT m_name[MAX_NLEN], t_name[MAX_NLEN];
121     monster_name(player_ptr, m_idx, m_name);
122     monster_name(player_ptr, t_idx, t_name);
123
124     mspell_cast_msg_blind msg(_("%^sが何かを力強くつぶやいた。", "%^s mumbles powerfully."),
125         _("%^sが魔力消去の呪文を念じた。", "%^s invokes a dispel magic."), _("%^sが%sに対して魔力消去の呪文を念じた。", "%^s invokes a dispel magic at %s."));
126
127     monspell_message(player_ptr, m_idx, t_idx, msg, target_type);
128
129     if (target_type == MONSTER_TO_PLAYER) {
130         dispel_player(player_ptr);
131         if (player_ptr->riding) {
132             dispel_monster_status(player_ptr, player_ptr->riding);
133         }
134
135         if (is_echizen(player_ptr)) {
136             msg_print(_("やりやがったな!", ""));
137         } else if (is_chargeman(player_ptr)) {
138             if (randint0(2) == 0) {
139                 msg_print(_("ジュラル星人め!", ""));
140             } else {
141                 msg_print(_("弱い者いじめは止めるんだ!", ""));
142             }
143         }
144
145         return res;
146     }
147
148     if (target_type == MONSTER_TO_MONSTER) {
149         if (t_idx == player_ptr->riding) {
150             dispel_player(player_ptr);
151         }
152
153         dispel_monster_status(player_ptr, t_idx);
154     }
155
156     return res;
157 }