OSDN Git Service

[Refactor] #3286 Removed player-redraw-types.h
[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->who > 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     player_ptr->window_flags |= (PW_PLAYER | PW_SPELL);
46
47     if ((ep_ptr->who <= 0) || (ep_ptr->m_ptr->hp >= ep_ptr->m_ptr->maxhp)) {
48         ep_ptr->dam = 0;
49         return;
50     }
51
52     ep_ptr->m_ptr->hp += ep_ptr->dam;
53     if (ep_ptr->m_ptr->hp > ep_ptr->m_ptr->maxhp) {
54         ep_ptr->m_ptr->hp = ep_ptr->m_ptr->maxhp;
55     }
56
57     if (player_ptr->health_who == ep_ptr->who) {
58         rfu.set_flag(MainWindowRedrawingFlag::HEALTH);
59     }
60     if (player_ptr->riding == ep_ptr->who) {
61         rfu.set_flag(MainWindowRedrawingFlag::UHEALTH);
62     }
63
64     if (ep_ptr->m_ptr->ml) {
65         msg_format(_("%s^は気分が良さそうだ。", "%s^ appears healthier."), ep_ptr->m_name);
66     }
67
68     ep_ptr->dam = 0;
69 }
70
71 void effect_player_mind_blast(PlayerType *player_ptr, EffectPlayerType *ep_ptr)
72 {
73     if ((randint0(100 + ep_ptr->rlev / 2) < std::max<short>(5, player_ptr->skill_sav)) && !check_multishadow(player_ptr)) {
74         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
75         return;
76     }
77
78     if (check_multishadow(player_ptr)) {
79         ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
80         return;
81     }
82
83     msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psionic energy."));
84     BadStatusSetter bss(player_ptr);
85     if (!has_resist_conf(player_ptr)) {
86         (void)bss.mod_confusion(randint0(4) + 4);
87     }
88
89     if (!has_resist_chaos(player_ptr) && one_in_(3)) {
90         (void)bss.mod_hallucination(randint0(250) + 150);
91     }
92
93     player_ptr->csp -= 50;
94     if (player_ptr->csp < 0) {
95         player_ptr->csp = 0;
96         player_ptr->csp_frac = 0;
97     }
98
99     RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::MP);
100     ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
101 }
102
103 void effect_player_brain_smash(PlayerType *player_ptr, EffectPlayerType *ep_ptr)
104 {
105     if ((randint0(100 + ep_ptr->rlev / 2) < std::max<short>(5, player_ptr->skill_sav)) && !check_multishadow(player_ptr)) {
106         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
107         return;
108     }
109
110     if (!check_multishadow(player_ptr)) {
111         msg_print(_("霊的エネルギーで精神が攻撃された。", "Your mind is blasted by psionic energy."));
112         player_ptr->csp -= 100;
113         if (player_ptr->csp < 0) {
114             player_ptr->csp = 0;
115             player_ptr->csp_frac = 0;
116         }
117
118         RedrawingFlagsUpdater::get_instance().set_flag(MainWindowRedrawingFlag::MP);
119     }
120
121     ep_ptr->get_damage = take_hit(player_ptr, DAMAGE_ATTACK, ep_ptr->dam, ep_ptr->killer);
122     if (check_multishadow(player_ptr)) {
123         return;
124     }
125
126     BadStatusSetter bss(player_ptr);
127     if (!has_resist_blind(player_ptr)) {
128         (void)bss.mod_blindness(8 + randint0(8));
129     }
130
131     if (!has_resist_conf(player_ptr)) {
132         (void)bss.mod_confusion(randint0(4) + 4);
133     }
134
135     if (!player_ptr->free_act) {
136         (void)bss.mod_paralysis(randint0(4) + 4);
137     }
138
139     (void)bss.mod_deceleration(randint0(4) + 4, false);
140
141     while (randint0(100 + ep_ptr->rlev / 2) > (std::max<short>(5, player_ptr->skill_sav))) {
142         (void)do_dec_stat(player_ptr, A_INT);
143     }
144     while (randint0(100 + ep_ptr->rlev / 2) > (std::max<short>(5, player_ptr->skill_sav))) {
145         (void)do_dec_stat(player_ptr, A_WIS);
146     }
147
148     if (!has_resist_chaos(player_ptr)) {
149         (void)bss.mod_hallucination(randint0(250) + 150);
150     }
151 }