OSDN Git Service

9562983a5888085e6aa5ee72ae1f94c5d3f5dd84
[hengbandforosx/hengbandosx.git] / src / effect / effect-player-spirit.cpp
1 #include "effect/effect-player-spirit.h"
2 #include "blue-magic/blue-magic-checker.h"
3 #include "core/window-redrawer.h"
4 #include "effect/effect-player.h"
5 #include "mind/mind-mirror-master.h"
6 #include "player/player-damage.h"
7 #include "player/player-status-flags.h"
8 #include "status/bad-status-setter.h"
9 #include "status/base-status.h"
10 #include "system/monster-entity.h"
11 #include "system/player-type-definition.h"
12 #include "system/redrawing-flags-updater.h"
13 #include "view/display-messages.h"
14 #include "world/world.h"
15
16 void effect_player_drain_mana(PlayerType *player_ptr, EffectPlayerType *ep_ptr)
17 {
18     if (check_multishadow(player_ptr)) {
19         msg_print(_("攻撃は幻影に命中し、あなたには届かなかった。", "The attack hits Shadow, but you are unharmed!"));
20         ep_ptr->dam = 0;
21         return;
22     }
23
24     if (player_ptr->csp == 0) {
25         ep_ptr->dam = 0;
26         return;
27     }
28
29     if (ep_ptr->src_idx > 0) {
30         msg_format(_("%s^に精神エネルギーを吸い取られてしまった!", "%s^ draws psychic energy from you!"), ep_ptr->m_name);
31     } else {
32         msg_print(_("精神エネルギーを吸い取られてしまった!", "Your psychic energy is drained!"));
33     }
34
35     if (ep_ptr->dam >= player_ptr->csp) {
36         ep_ptr->dam = player_ptr->csp;
37         player_ptr->csp = 0;
38         player_ptr->csp_frac = 0;
39     } else {
40         player_ptr->csp -= ep_ptr->dam;
41     }
42
43     auto &rfu = RedrawingFlagsUpdater::get_instance();
44     rfu.set_flag(MainWindowRedrawingFlag::MP);
45     static constexpr auto flags = {
46         SubWindowRedrawingFlag::PLAYER,
47         SubWindowRedrawingFlag::SPELL,
48     };
49     rfu.set_flags(flags);
50
51     if ((ep_ptr->src_idx <= 0) || (ep_ptr->m_ptr->hp >= ep_ptr->m_ptr->maxhp)) {
52         ep_ptr->dam = 0;
53         return;
54     }
55
56     ep_ptr->m_ptr->hp += ep_ptr->dam;
57     if (ep_ptr->m_ptr->hp > ep_ptr->m_ptr->maxhp) {
58         ep_ptr->m_ptr->hp = ep_ptr->m_ptr->maxhp;
59     }
60
61     if (player_ptr->health_who == ep_ptr->src_idx) {
62         rfu.set_flag(MainWindowRedrawingFlag::HEALTH);
63     }
64     if (player_ptr->riding == ep_ptr->src_idx) {
65         rfu.set_flag(MainWindowRedrawingFlag::UHEALTH);
66     }
67
68     if (ep_ptr->m_ptr->ml) {
69         msg_format(_("%s^は気分が良さそうだ。", "%s^ appears healthier."), ep_ptr->m_name);
70     }
71
72     ep_ptr->dam = 0;
73 }
74
75 void effect_player_mind_blast(PlayerType *player_ptr, EffectPlayerType *ep_ptr)
76 {
77     if ((randint0(100 + ep_ptr->rlev / 2) < std::max<short>(5, player_ptr->skill_sav)) && !check_multishadow(player_ptr)) {
78         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
79         return;
80     }
81
82     if (check_multishadow(player_ptr)) {
83         ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
84         return;
85     }
86
87     msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psionic energy."));
88     BadStatusSetter bss(player_ptr);
89     if (!has_resist_conf(player_ptr)) {
90         (void)bss.mod_confusion(randint0(4) + 4);
91     }
92
93     if (!has_resist_chaos(player_ptr) && one_in_(3)) {
94         (void)bss.mod_hallucination(randint0(250) + 150);
95     }
96
97     player_ptr->csp -= 50;
98     if (player_ptr->csp < 0) {
99         player_ptr->csp = 0;
100         player_ptr->csp_frac = 0;
101     }
102
103     RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::MP);
104     ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
105 }
106
107 void effect_player_brain_smash(PlayerType *player_ptr, EffectPlayerType *ep_ptr)
108 {
109     if ((randint0(100 + ep_ptr->rlev / 2) < std::max<short>(5, player_ptr->skill_sav)) && !check_multishadow(player_ptr)) {
110         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
111         return;
112     }
113
114     if (!check_multishadow(player_ptr)) {
115         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psionic energy."));
116         player_ptr->csp -= 100;
117         if (player_ptr->csp < 0) {
118             player_ptr->csp = 0;
119             player_ptr->csp_frac = 0;
120         }
121
122         RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::MP);
123     }
124
125     ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
126     if (check_multishadow(player_ptr)) {
127         return;
128     }
129
130     BadStatusSetter bss(player_ptr);
131     if (!has_resist_blind(player_ptr)) {
132         (void)bss.mod_blindness(8 + randint0(8));
133     }
134
135     if (!has_resist_conf(player_ptr)) {
136         (void)bss.mod_confusion(randint0(4) + 4);
137     }
138
139     if (!player_ptr->free_act) {
140         (void)bss.mod_paralysis(randint0(4) + 4);
141     }
142
143     (void)bss.mod_deceleration(randint0(4) + 4, false);
144
145     while (randint0(100 + ep_ptr->rlev / 2) > (std::max<short>(5, player_ptr->skill_sav))) {
146         (void)do_dec_stat(player_ptr, A_INT);
147     }
148     while (randint0(100 + ep_ptr->rlev / 2) > (std::max<short>(5, player_ptr->skill_sav))) {
149         (void)do_dec_stat(player_ptr, A_WIS);
150     }
151
152     if (!has_resist_chaos(player_ptr)) {
153         (void)bss.mod_hallucination(randint0(250) + 150);
154     }
155 }