OSDN Git Service

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