OSDN Git Service

[Refactor] #40399 angband.h からobject2.hのインクルード を*抹殺*した / *Genocide* inclusion object2...
[hengband/hengband.git] / src / effect / effect-monster-oldies.c
1 #include "system/angband.h"
2 #include "effect/effect-monster-util.h"
3 #include "effect/effect-monster-oldies.h"
4 #include "floor/floor.h"
5 #include "player/avatar.h"
6 #include "monster/monster-status.h"
7
8 // Powerful monsters can resist.
9 gf_switch_result effect_monster_old_poly(effect_monster_type *em_ptr)
10 {
11         if (em_ptr->seen) em_ptr->obvious = TRUE;
12         em_ptr->do_polymorph = TRUE;
13
14         if ((em_ptr->r_ptr->flags1 & RF1_UNIQUE) ||
15                 (em_ptr->r_ptr->flags1 & RF1_QUESTOR) ||
16                 (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10))
17         {
18                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
19                 em_ptr->do_polymorph = FALSE;
20                 em_ptr->obvious = FALSE;
21         }
22
23         em_ptr->dam = 0;
24         return GF_SWITCH_CONTINUE;
25 }
26
27
28 gf_switch_result effect_monster_old_clone(player_type *caster_ptr, effect_monster_type *em_ptr)
29 {
30         if (em_ptr->seen) em_ptr->obvious = TRUE;
31
32         if ((caster_ptr->current_floor_ptr->inside_arena) ||
33                 is_pet(em_ptr->m_ptr) ||
34                 (em_ptr->r_ptr->flags1 & (RF1_UNIQUE | RF1_QUESTOR)) ||
35                 (em_ptr->r_ptr->flags7 & (RF7_NAZGUL | RF7_UNIQUE2)))
36         {
37                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
38                 em_ptr->dam = 0;
39                 return GF_SWITCH_CONTINUE;
40         }
41
42         em_ptr->m_ptr->hp = em_ptr->m_ptr->maxhp;
43         if (multiply_monster(caster_ptr, em_ptr->g_ptr->m_idx, TRUE, 0L))
44                 em_ptr->note = _("が分裂した!", " spawns!");
45
46         em_ptr->dam = 0;
47         return GF_SWITCH_CONTINUE;
48 }
49
50
51 gf_switch_result effect_monster_star_heal(player_type *caster_ptr, effect_monster_type *em_ptr)
52 {
53         if (em_ptr->seen) em_ptr->obvious = TRUE;
54
55         (void)set_monster_csleep(caster_ptr, em_ptr->g_ptr->m_idx, 0);
56
57         if (em_ptr->m_ptr->maxhp < em_ptr->m_ptr->max_maxhp)
58         {
59                 if (em_ptr->seen_msg)
60                         msg_format(_("%^sの強さが戻った。", "%^s recovers %s vitality."), em_ptr->m_name, em_ptr->m_poss);
61                 em_ptr->m_ptr->maxhp = em_ptr->m_ptr->max_maxhp;
62         }
63
64         if (!em_ptr->dam)
65         {
66                 if (caster_ptr->health_who == em_ptr->g_ptr->m_idx)
67                         caster_ptr->redraw |= (PR_HEALTH);
68                 if (caster_ptr->riding == em_ptr->g_ptr->m_idx)
69                         caster_ptr->redraw |= (PR_UHEALTH);
70
71                 return GF_SWITCH_FALSE;
72         }
73
74         return GF_SWITCH_TRUE;
75 }
76
77
78 // who == 0ならばプレーヤーなので、それの判定.
79 static void effect_monster_old_heal_check_player(player_type *caster_ptr, effect_monster_type *em_ptr)
80 {
81         if (em_ptr->who != 0) return;
82
83         chg_virtue(caster_ptr, V_VITALITY, 1);
84         if (em_ptr->r_ptr->flags1 & RF1_UNIQUE)
85                 chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
86
87         if (is_friendly(em_ptr->m_ptr))
88                 chg_virtue(caster_ptr, V_HONOUR, 1);
89         else if (!(em_ptr->r_ptr->flags3 & RF3_EVIL))
90         {
91                 if (em_ptr->r_ptr->flags3 & RF3_GOOD)
92                         chg_virtue(caster_ptr, V_COMPASSION, 2);
93                 else
94                         chg_virtue(caster_ptr, V_COMPASSION, 1);
95         }
96
97         if (em_ptr->r_ptr->flags3 & RF3_ANIMAL)
98                 chg_virtue(caster_ptr, V_NATURE, 1);
99 }
100
101
102 static void effect_monster_old_heal_recovery(player_type *caster_ptr, effect_monster_type *em_ptr)
103 {
104         if (MON_STUNNED(em_ptr->m_ptr))
105         {
106                 if (em_ptr->seen_msg)
107                         msg_format(_("%^sは朦朧状態から立ち直った。", "%^s is no longer stunned."), em_ptr->m_name);
108
109                 (void)set_monster_stunned(caster_ptr, em_ptr->g_ptr->m_idx, 0);
110         }
111
112         if (MON_CONFUSED(em_ptr->m_ptr))
113         {
114                 if (em_ptr->seen_msg)
115                         msg_format(_("%^sは混乱から立ち直った。", "%^s is no longer confused."), em_ptr->m_name);
116
117                 (void)set_monster_confused(caster_ptr, em_ptr->g_ptr->m_idx, 0);
118         }
119
120         if (MON_MONFEAR(em_ptr->m_ptr))
121         {
122                 if (em_ptr->seen_msg)
123                         msg_format(_("%^sは勇気を取り戻した。", "%^s recovers %s courage."), em_ptr->m_name, em_ptr->m_poss);
124
125                 (void)set_monster_monfear(caster_ptr, em_ptr->g_ptr->m_idx, 0);
126         }
127 }
128
129
130 // todo サーペントのHPがマジックナンバー扱いになっている
131 gf_switch_result effect_monster_old_heal(player_type *caster_ptr, effect_monster_type *em_ptr)
132 {
133         if (em_ptr->seen) em_ptr->obvious = TRUE;
134
135         /* Wake up */
136         (void)set_monster_csleep(caster_ptr, em_ptr->g_ptr->m_idx, 0);
137         effect_monster_old_heal_recovery(caster_ptr, em_ptr);
138         if (em_ptr->m_ptr->hp < 30000) em_ptr->m_ptr->hp += em_ptr->dam;
139         if (em_ptr->m_ptr->hp > em_ptr->m_ptr->maxhp) em_ptr->m_ptr->hp = em_ptr->m_ptr->maxhp;
140
141         effect_monster_old_heal_check_player(caster_ptr, em_ptr);
142         if (em_ptr->m_ptr->r_idx == MON_LEPER)
143         {
144                 em_ptr->heal_leper = TRUE;
145                 if (!em_ptr->who) chg_virtue(caster_ptr, V_COMPASSION, 5);
146         }
147
148         if (caster_ptr->health_who == em_ptr->g_ptr->m_idx) caster_ptr->redraw |= (PR_HEALTH);
149         if (caster_ptr->riding == em_ptr->g_ptr->m_idx) caster_ptr->redraw |= (PR_UHEALTH);
150
151         em_ptr->note = _("は体力を回復したようだ。", " looks healthier.");
152         em_ptr->dam = 0;
153         return GF_SWITCH_CONTINUE;
154 }
155
156
157 gf_switch_result effect_monster_old_speed(player_type *caster_ptr, effect_monster_type *em_ptr)
158 {
159         if (em_ptr->seen) em_ptr->obvious = TRUE;
160
161         if (set_monster_fast(caster_ptr, em_ptr->g_ptr->m_idx, MON_FAST(em_ptr->m_ptr) + 100))
162         {
163                 em_ptr->note = _("の動きが速くなった。", " starts moving faster.");
164         }
165
166         if (!em_ptr->who)
167         {
168                 if (em_ptr->r_ptr->flags1 & RF1_UNIQUE)
169                         chg_virtue(caster_ptr, V_INDIVIDUALISM, 1);
170                 if (is_friendly(em_ptr->m_ptr))
171                         chg_virtue(caster_ptr, V_HONOUR, 1);
172         }
173
174         em_ptr->dam = 0;
175         return GF_SWITCH_CONTINUE;
176 }
177
178
179 gf_switch_result effect_monster_old_slow(player_type *caster_ptr, effect_monster_type *em_ptr)
180 {
181         if (em_ptr->seen) em_ptr->obvious = TRUE;
182
183         /* Powerful monsters can resist */
184         if ((em_ptr->r_ptr->flags1 & RF1_UNIQUE) ||
185                 (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10))
186         {
187                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
188                 em_ptr->obvious = FALSE;
189                 em_ptr->dam = 0;
190                 return GF_SWITCH_CONTINUE;
191         }
192
193         if (set_monster_slow(caster_ptr, em_ptr->g_ptr->m_idx, MON_SLOW(em_ptr->m_ptr) + 50))
194                 em_ptr->note = _("の動きが遅くなった。", " starts moving slower.");
195
196         em_ptr->dam = 0;
197         return GF_SWITCH_CONTINUE;
198 }
199
200
201 /*!
202  * todo 「ユニークは (魔法では)常に眠らない」はr_infoの趣旨に反すると思われる
203  * 眠る確率を半分にするとかしておいた方が良さそう
204  */
205 gf_switch_result effect_monster_old_sleep(player_type *caster_ptr, effect_monster_type *em_ptr)
206 {
207         if (em_ptr->seen) em_ptr->obvious = TRUE;
208
209         if ((em_ptr->r_ptr->flags1 & RF1_UNIQUE) ||
210                 (em_ptr->r_ptr->flags3 & RF3_NO_SLEEP) ||
211                 (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10))
212         {
213                 if (em_ptr->r_ptr->flags3 & RF3_NO_SLEEP)
214                 {
215                         if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr)) em_ptr->r_ptr->r_flags3 |= (RF3_NO_SLEEP);
216                 }
217
218                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
219                 em_ptr->obvious = FALSE;
220         }
221         else
222         {
223                 em_ptr->note = _("は眠り込んでしまった!", " falls asleep!");
224                 em_ptr->do_sleep = 500;
225         }
226
227         em_ptr->dam = 0;
228         return GF_SWITCH_CONTINUE;
229 }
230
231
232 /*!
233  * todo 「ユニークは (魔法では)常に混乱しない」はr_infoの趣旨に反すると思われる
234  * 眠る確率を半分にするとかしておいた方が良さそう
235  */
236 gf_switch_result effect_monster_old_conf(player_type *caster_ptr, effect_monster_type *em_ptr)
237 {
238         if (em_ptr->seen) em_ptr->obvious = TRUE;
239
240         em_ptr->do_conf = damroll(3, (em_ptr->dam / 2)) + 1;
241         if ((em_ptr->r_ptr->flags1 & (RF1_UNIQUE)) ||
242                 (em_ptr->r_ptr->flags3 & (RF3_NO_CONF)) ||
243                 (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10))
244         {
245                 if (em_ptr->r_ptr->flags3 & (RF3_NO_CONF))
246                 {
247                         if (is_original_ap_and_seen(caster_ptr, em_ptr->m_ptr)) em_ptr->r_ptr->r_flags3 |= (RF3_NO_CONF);
248                 }
249
250                 em_ptr->do_conf = 0;
251                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
252                 em_ptr->obvious = FALSE;
253         }
254
255         em_ptr->dam = 0;
256         return GF_SWITCH_CONTINUE;
257 }
258
259
260 gf_switch_result effect_monster_stasis(effect_monster_type *em_ptr, bool to_evil)
261 {
262         if (em_ptr->seen) em_ptr->obvious = TRUE;
263
264         int stasis_damage = (em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10);
265         bool has_resistance = (em_ptr->r_ptr->flags1 & RF1_UNIQUE) != 0;
266         has_resistance |= em_ptr->r_ptr->level > randint1(stasis_damage) + 10;
267         if (to_evil) has_resistance |= (em_ptr->r_ptr->flags3 & RF3_EVIL) == 0;
268
269         if (has_resistance)
270         {
271                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
272                 em_ptr->obvious = FALSE;
273         }
274         else
275         {
276                 em_ptr->note = _("は動けなくなった!", " is suspended!");
277                 em_ptr->do_sleep = 500;
278         }
279
280         em_ptr->dam = 0;
281         return GF_SWITCH_CONTINUE;
282 }
283
284
285 gf_switch_result effect_monster_stun(effect_monster_type *em_ptr)
286 {
287         if (em_ptr->seen) em_ptr->obvious = TRUE;
288
289         em_ptr->do_stun = damroll((em_ptr->caster_lev / 20) + 3, (em_ptr->dam)) + 1;
290         if ((em_ptr->r_ptr->flags1 & (RF1_UNIQUE)) ||
291                 (em_ptr->r_ptr->level > randint1((em_ptr->dam - 10) < 1 ? 1 : (em_ptr->dam - 10)) + 10))
292         {
293                 em_ptr->do_stun = 0;
294                 em_ptr->note = _("には効果がなかった。", " is unaffected.");
295                 em_ptr->obvious = FALSE;
296         }
297
298         em_ptr->dam = 0;
299         return GF_SWITCH_CONTINUE;
300 }