OSDN Git Service

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