OSDN Git Service

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