OSDN Git Service

[Refactor] #1511 「プレーヤー」表記を全て「プレイヤー」に変更した (日本語版のみ、ほぼDoxygenコメント)
[hengbandforosx/hengbandosx.git] / src / monster-attack / monster-attack-status.cpp
1 /*!
2  * @brief プレイヤーのステータス (麻痺等)に影響を与えるモンスターの打撃処理
3  * @date 2020/05/31
4  * @author Hourier
5  */
6
7 #include "monster-attack/monster-attack-status.h"
8 #include "core/player-update-types.h"
9 #include "mind/mind-mirror-master.h"
10 #include "monster-attack/monster-attack-util.h"
11 #include "monster-race/monster-race.h"
12 #include "monster-race/race-indice-types.h"
13 #include "player/player-status-flags.h"
14 #include "status/bad-status-setter.h"
15 #include "status/base-status.h"
16 #include "status/experience.h"
17 #include "system/monster-race-definition.h"
18 #include "system/monster-type-definition.h"
19 #include "system/player-type-definition.h"
20 #include "view/display-messages.h"
21
22 void process_blind_attack(player_type *player_ptr, monap_type *monap_ptr)
23 {
24     if (has_resist_blind(player_ptr) || check_multishadow(player_ptr)) {
25         return;
26     }
27
28     auto is_dio = monap_ptr->m_ptr->r_idx == MON_DIO;
29     auto dio_msg = _("どうだッ!この血の目潰しはッ!", "How is it! This blood-blinding!");
30     if (is_dio && player_ptr->prace == player_race_type::SKELETON) {
31         msg_print(dio_msg);
32         msg_print(_("しかし、あなたには元々目はなかった!", "However, you don't have eyes!"));
33         return;
34     }
35
36     if (!set_blind(player_ptr, player_ptr->blind + 10 + randint1(monap_ptr->rlev))) {
37         return;
38     }
39
40     if (is_dio) {
41         msg_print(dio_msg);
42     }
43
44     monap_ptr->obvious = true;
45 }
46
47 void process_terrify_attack(player_type *player_ptr, monap_type *monap_ptr)
48 {
49     if (check_multishadow(player_ptr)) {
50         return;
51     }
52
53     auto *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
54     if (has_resist_fear(player_ptr)) {
55         msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
56         monap_ptr->obvious = true;
57         return;
58     }
59
60     if (randint0(100 + r_ptr->level / 2) < player_ptr->skill_sav) {
61         msg_print(_("しかし恐怖に侵されなかった!", "You stand your ground!"));
62         monap_ptr->obvious = true;
63         return;
64     }
65
66     if (set_afraid(player_ptr, player_ptr->afraid + 3 + randint1(monap_ptr->rlev))) {
67         monap_ptr->obvious = true;
68     }
69 }
70
71 void process_paralyze_attack(player_type *player_ptr, monap_type *monap_ptr)
72 {
73     if (check_multishadow(player_ptr)) {
74         return;
75     }
76
77     auto *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
78     if (player_ptr->free_act) {
79         msg_print(_("しかし効果がなかった!", "You are unaffected!"));
80         monap_ptr->obvious = true;
81         return;
82     }
83
84     if (randint0(100 + r_ptr->level / 2) < player_ptr->skill_sav) {
85         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
86         monap_ptr->obvious = true;
87         return;
88     }
89
90     if (!player_ptr->paralyzed && set_paralyzed(player_ptr, 3 + randint1(monap_ptr->rlev))) {
91         monap_ptr->obvious = true;
92     }
93 }
94
95 void process_lose_all_attack(player_type *player_ptr, monap_type *monap_ptr)
96 {
97     if (do_dec_stat(player_ptr, A_STR)) {
98         monap_ptr->obvious = true;
99     }
100
101     if (do_dec_stat(player_ptr, A_DEX)) {
102         monap_ptr->obvious = true;
103     }
104
105     if (do_dec_stat(player_ptr, A_CON)) {
106         monap_ptr->obvious = true;
107     }
108
109     if (do_dec_stat(player_ptr, A_INT)) {
110         monap_ptr->obvious = true;
111     }
112
113     if (do_dec_stat(player_ptr, A_WIS)) {
114         monap_ptr->obvious = true;
115     }
116
117     if (do_dec_stat(player_ptr, A_CHR)) {
118         monap_ptr->obvious = true;
119     }
120 }
121
122 void process_stun_attack(player_type *player_ptr, monap_type *monap_ptr)
123 {
124     if (has_resist_sound(player_ptr) || check_multishadow(player_ptr)) {
125         return;
126     }
127
128     auto *r_ptr = &r_info[monap_ptr->m_ptr->r_idx];
129     if (set_stun(player_ptr, player_ptr->stun + 10 + randint1(r_ptr->level / 4)))
130         monap_ptr->obvious = true;
131 }
132
133 /*!
134  * @brief 時間逆転攻撃による能力低下
135  * @param player_ptr プレイヤーへの参照ポインタ
136  * @monap_ptr モンスターからモンスターへの直接攻撃構造体への参照ポインタ
137  */
138 static void describe_disability(player_type *player_ptr, monap_type *monap_ptr)
139 {
140     int stat = randint0(6);
141     switch (stat) {
142     case A_STR:
143         monap_ptr->act = _("強く", "strong");
144         break;
145     case A_INT:
146         monap_ptr->act = _("聡明で", "bright");
147         break;
148     case A_WIS:
149         monap_ptr->act = _("賢明で", "wise");
150         break;
151     case A_DEX:
152         monap_ptr->act = _("器用で", "agile");
153         break;
154     case A_CON:
155         monap_ptr->act = _("健康で", "hale");
156         break;
157     case A_CHR:
158         monap_ptr->act = _("美しく", "beautiful");
159         break;
160     }
161
162     msg_format(_("あなたは以前ほど%sなくなってしまった...。", "You're not as %s as you used to be..."), monap_ptr->act);
163     player_ptr->stat_cur[stat] = (player_ptr->stat_cur[stat] * 3) / 4;
164     if (player_ptr->stat_cur[stat] < 3) {
165         player_ptr->stat_cur[stat] = 3;
166     }
167 }
168
169 void process_monster_attack_time(player_type *player_ptr, monap_type *monap_ptr)
170 {
171     if (has_resist_time(player_ptr) || check_multishadow(player_ptr)) {
172         return;
173     }
174
175     switch (randint1(10)) {
176     case 1:
177     case 2:
178     case 3:
179     case 4:
180     case 5:
181         if (player_ptr->prace == player_race_type::ANDROID) {
182             break;
183         }
184
185         msg_print(_("人生が逆戻りした気がする。", "You feel like a chunk of the past has been ripped away."));
186         lose_exp(player_ptr, 100 + (player_ptr->exp / 100) * MON_DRAIN_LIFE);
187         break;
188     case 6:
189     case 7:
190     case 8:
191     case 9:
192         describe_disability(player_ptr, monap_ptr);
193         player_ptr->update |= (PU_BONUS);
194         break;
195     case 10:
196         msg_print(_("あなたは以前ほど力強くなくなってしまった...。", "You're not as powerful as you used to be..."));
197         for (auto i = 0; i < A_MAX; i++) {
198             player_ptr->stat_cur[i] = (player_ptr->stat_cur[i] * 7) / 8;
199             if (player_ptr->stat_cur[i] < 3) {
200                 player_ptr->stat_cur[i] = 3;
201             }
202         }
203
204         player_ptr->update |= PU_BONUS;
205         break;
206     }
207 }