OSDN Git Service

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