OSDN Git Service

[Refactor] #39077 Moved gf_switch_result from effect-monster-util.h to h-type.h and...
[hengbandforosx/hengbandosx.git] / src / effect / effect-monster-spirit.c
1 #include "effect/effect-monster-spirit.h"
2 #include "core/hp-mp-processor.h"
3 #include "core/player-redraw-types.h"
4 #include "monster-race/monster-race.h"
5 #include "monster-race/race-flags1.h"
6 #include "monster-race/race-flags2.h"
7 #include "monster-race/race-flags3.h"
8 #include "monster-race/race-flags4.h"
9 #include "monster-race/race-flags-ability1.h"
10 #include "monster-race/race-flags-ability2.h"
11 #include "monster/monster-describer.h"
12 #include "monster/monster-status.h"
13 #include "monster/monster-info.h"
14 #include "mspell/mspell-mask-definitions.h"
15 #include "view/display-messages.h"
16
17 switch_result effect_monster_drain_mana(player_type *caster_ptr, effect_monster_type *em_ptr)
18 {
19         if (em_ptr->seen) em_ptr->obvious = TRUE;
20         bool has_mana = ((em_ptr->r_ptr->flags4 & ~(RF4_NOMAGIC_MASK))) != 0;
21         has_mana |= ((em_ptr->r_ptr->a_ability_flags1 & ~(RF5_NOMAGIC_MASK))) != 0;
22         has_mana |= ((em_ptr->r_ptr->a_ability_flags2 & ~(RF6_NOMAGIC_MASK))) != 0;
23         if (!has_mana)
24         {
25                 if (em_ptr->see_s_msg)
26                         msg_format(_("%sには効果がなかった。", "%s is unaffected."), em_ptr->m_name);
27
28                 em_ptr->dam = 0;
29                 return SWITCH_CONTINUE;
30         }
31
32         if (em_ptr->who <= 0)
33         {
34                 msg_format(_("%sから精神エネルギーを吸いとった。", "You draw psychic energy from %s."), em_ptr->m_name);
35                 (void)hp_player(caster_ptr, em_ptr->dam);
36                 em_ptr->dam = 0;
37                 return SWITCH_CONTINUE;
38         }
39
40         if (em_ptr->m_caster_ptr->hp >= em_ptr->m_caster_ptr->maxhp)
41         {
42                 em_ptr->dam = 0;
43                 return SWITCH_CONTINUE;
44         }
45
46         em_ptr->m_caster_ptr->hp += em_ptr->dam;
47         if (em_ptr->m_caster_ptr->hp > em_ptr->m_caster_ptr->maxhp)
48                 em_ptr->m_caster_ptr->hp = em_ptr->m_caster_ptr->maxhp;
49
50         if (caster_ptr->health_who == em_ptr->who)
51                 caster_ptr->redraw |= (PR_HEALTH);
52
53         if (caster_ptr->riding == em_ptr->who)
54                 caster_ptr->redraw |= (PR_UHEALTH);
55
56         if (em_ptr->see_s_msg)
57         {
58                 monster_desc(caster_ptr, em_ptr->killer, em_ptr->m_caster_ptr, 0);
59                 msg_format(_("%^sは気分が良さそうだ。", "%^s appears healthier."), em_ptr->killer);
60         }
61
62         em_ptr->dam = 0;
63         return SWITCH_CONTINUE;
64 }
65
66
67 switch_result effect_monster_mind_blast(player_type *caster_ptr, effect_monster_type *em_ptr)
68 {
69         if (em_ptr->seen) em_ptr->obvious = TRUE;
70         if (!em_ptr->who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), em_ptr->m_name);
71
72         if ((em_ptr->r_ptr->flags1 & RF1_UNIQUE) ||
73                 (em_ptr->r_ptr->flags3 & RF3_NO_CONF) ||
74                 (em_ptr->r_ptr->level > randint1((em_ptr->caster_lev - 10) < 1 ? 1 : (em_ptr->caster_lev - 10)) + 10))
75         {
76                 if (em_ptr->r_ptr->flags3 & (RF3_NO_CONF))
77                 {
78                         if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr)) em_ptr->r_ptr->r_flags3 |= (RF3_NO_CONF);
79                 }
80
81                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
82                 em_ptr->dam = 0;
83         }
84         else if (em_ptr->r_ptr->flags2 & RF2_EMPTY_MIND)
85         {
86                 if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr)) em_ptr->r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
87                 em_ptr->note = _("には完全な耐性がある!", " is immune.");
88                 em_ptr->dam = 0;
89         }
90         else if (em_ptr->r_ptr->flags2 & RF2_WEIRD_MIND)
91         {
92                 if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr)) em_ptr->r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
93                 em_ptr->note = _("には耐性がある。", " resists.");
94                 em_ptr->dam /= 3;
95         }
96         else
97         {
98                 em_ptr->note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
99                 em_ptr->note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
100
101                 if (em_ptr->who > 0) em_ptr->do_conf = randint0(4) + 4;
102                 else em_ptr->do_conf = randint0(8) + 8;
103         }
104
105         return SWITCH_CONTINUE;
106 }
107
108
109 switch_result effect_monster_brain_smash(player_type *caster_ptr, effect_monster_type *em_ptr)
110 {
111         if (em_ptr->seen) em_ptr->obvious = TRUE;
112         if (!em_ptr->who) msg_format(_("%sをじっと睨んだ。", "You gaze intently at %s."), em_ptr->m_name);
113
114         if ((em_ptr->r_ptr->flags1 & RF1_UNIQUE) ||
115                 (em_ptr->r_ptr->flags3 & RF3_NO_CONF) ||
116                 (em_ptr->r_ptr->level > randint1((em_ptr->caster_lev - 10) < 1 ? 1 : (em_ptr->caster_lev - 10)) + 10))
117         {
118                 if (em_ptr->r_ptr->flags3 & (RF3_NO_CONF))
119                 {
120                         if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr))
121                                 em_ptr->r_ptr->r_flags3 |= (RF3_NO_CONF);
122                 }
123
124                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
125                 em_ptr->dam = 0;
126         }
127         else if (em_ptr->r_ptr->flags2 & RF2_EMPTY_MIND)
128         {
129                 if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr))
130                         em_ptr->r_ptr->r_flags2 |= (RF2_EMPTY_MIND);
131
132                 em_ptr->note = _("には完全な耐性がある!", " is immune.");
133                 em_ptr->dam = 0;
134         }
135         else if (em_ptr->r_ptr->flags2 & RF2_WEIRD_MIND)
136         {
137                 if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr))
138                         em_ptr->r_ptr->r_flags2 |= (RF2_WEIRD_MIND);
139
140                 em_ptr->note = _("には耐性がある!", " resists!");
141                 em_ptr->dam /= 3;
142         }
143         else
144         {
145                 em_ptr->note = _("は精神攻撃を食らった。", " is blasted by psionic energy.");
146                 em_ptr->note_dies = _("の精神は崩壊し、肉体は抜け殻となった。", " collapses, a mindless husk.");
147                 if (em_ptr->who > 0)
148                 {
149                         em_ptr->do_conf = randint0(4) + 4;
150                         em_ptr->do_stun = randint0(4) + 4;
151                 }
152                 else
153                 {
154                         em_ptr->do_conf = randint0(8) + 8;
155                         em_ptr->do_stun = randint0(8) + 8;
156                 }
157
158                 (void)set_monster_slow(caster_ptr, em_ptr->g_ptr->m_idx, monster_slow_remaining(em_ptr->m_ptr) + 10);
159         }
160
161         return SWITCH_CONTINUE;
162 }