OSDN Git Service

3a12604f7eac4eeba5fa8f8bd17680e0c0d95a03
[hengband/hengband.git] / src / mutation / mutation-processor.c
1 #include "mutation/mutation-processor.h"
2 #include "io/targeting.h"
3 #include "monster-floor/monster-generator.h"
4 #include "monster/monster-status.h"
5 #include "monster-floor/place-monster-types.h"
6 #include "mutation/mutation.h"
7 #include "object/lite-processor.h"
8 #include "object/object-hook.h"
9 #include "player/player-damage.h"
10 #include "player/player-effects.h"
11 #include "player/player-move.h"
12 #include "spell-kind/spells-floor.h"
13 #include "spell-realm/spells-hex.h"
14 #include "spell-kind/spells-launcher.h"
15 #include "spell-kind/spells-lite.h"
16 #include "spell-kind/spells-sight.h"
17 #include "spell/spells-summon.h"
18 #include "spell-kind/spells-teleport.h"
19 #include "spell/spells-type.h"
20 #include "spell/spells3.h"
21 #include "store/store-owners.h"
22 #include "store/store-util.h"
23 #include "store/store.h"
24
25 /*!
26  * @brief 10ゲームターンが進行するごとに突然変異の発動判定を行う処理
27  * / Handle mutation effects once every 10 game turns
28  * @return なし
29  */
30 void process_world_aux_mutation(player_type* creature_ptr)
31 {
32     if (!creature_ptr->muta2)
33         return;
34     if (creature_ptr->phase_out)
35         return;
36     if (creature_ptr->wild_mode)
37         return;
38
39     if ((creature_ptr->muta2 & MUT2_BERS_RAGE) && one_in_(3000)) {
40         disturb(creature_ptr, FALSE, TRUE);
41         msg_print(_("ウガァァア!", "RAAAAGHH!"));
42         msg_print(_("激怒の発作に襲われた!", "You feel a fit of rage coming over you!"));
43         (void)set_shero(creature_ptr, 10 + randint1(creature_ptr->lev), FALSE);
44         (void)set_afraid(creature_ptr, 0);
45     }
46
47     if ((creature_ptr->muta2 & MUT2_COWARDICE) && (randint1(3000) == 13)) {
48         if (!creature_ptr->resist_fear) {
49             disturb(creature_ptr, FALSE, TRUE);
50             msg_print(_("とても暗い... とても恐い!", "It's so dark... so scary!"));
51             set_afraid(creature_ptr, creature_ptr->afraid + 13 + randint1(26));
52         }
53     }
54
55     if ((creature_ptr->muta2 & MUT2_RTELEPORT) && (randint1(5000) == 88)) {
56         if (!creature_ptr->resist_nexus && !(creature_ptr->muta1 & MUT1_VTELEPORT) && !creature_ptr->anti_tele) {
57             disturb(creature_ptr, FALSE, TRUE);
58             msg_print(_("あなたの位置は突然ひじょうに不確定になった...", "Your position suddenly seems very uncertain..."));
59             msg_print(NULL);
60             teleport_player(creature_ptr, 40, TELEPORT_PASSIVE);
61         }
62     }
63
64     if ((creature_ptr->muta2 & MUT2_ALCOHOL) && (randint1(6400) == 321)) {
65         if (!creature_ptr->resist_conf && !creature_ptr->resist_chaos) {
66             disturb(creature_ptr, FALSE, TRUE);
67             creature_ptr->redraw |= PR_EXTRA;
68             msg_print(_("いひきがもーろーとひてきたきがふる...ヒック!", "You feel a SSSCHtupor cOmINg over yOu... *HIC*!"));
69         }
70
71         if (!creature_ptr->resist_conf) {
72             (void)set_confused(creature_ptr, creature_ptr->confused + randint0(20) + 15);
73         }
74
75         if (!creature_ptr->resist_chaos) {
76             if (one_in_(20)) {
77                 msg_print(NULL);
78                 if (one_in_(3))
79                     lose_all_info(creature_ptr);
80                 else
81                     wiz_dark(creature_ptr);
82                 (void)teleport_player_aux(creature_ptr, 100, FALSE, TELEPORT_NONMAGICAL | TELEPORT_PASSIVE);
83                 wiz_dark(creature_ptr);
84                 msg_print(_("あなたは見知らぬ場所で目が醒めた...頭が痛い。", "You wake up somewhere with a sore head..."));
85                 msg_print(_("何も覚えていない。どうやってここに来たかも分からない!", "You can't remember a thing or how you got here!"));
86             } else {
87                 if (one_in_(3)) {
88                     msg_print(_("き~れいなちょおちょらとんれいる~", "Thishcischs GooDSChtuff!"));
89                     (void)set_image(creature_ptr, creature_ptr->image + randint0(150) + 150);
90                 }
91             }
92         }
93     }
94
95     if ((creature_ptr->muta2 & MUT2_HALLU) && (randint1(6400) == 42)) {
96         if (!creature_ptr->resist_chaos) {
97             disturb(creature_ptr, FALSE, TRUE);
98             creature_ptr->redraw |= PR_EXTRA;
99             (void)set_image(creature_ptr, creature_ptr->image + randint0(50) + 20);
100         }
101     }
102
103     if ((creature_ptr->muta2 & MUT2_FLATULENT) && (randint1(3000) == 13)) {
104         disturb(creature_ptr, FALSE, TRUE);
105         msg_print(_("ブゥーーッ!おっと。", "BRRAAAP! Oops."));
106         msg_print(NULL);
107         fire_ball(creature_ptr, GF_POIS, 0, creature_ptr->lev, 3);
108     }
109
110     if ((creature_ptr->muta2 & MUT2_PROD_MANA) && !creature_ptr->anti_magic && one_in_(9000)) {
111         int dire = 0;
112         disturb(creature_ptr, FALSE, TRUE);
113         msg_print(_("魔法のエネルギーが突然あなたの中に流れ込んできた!エネルギーを解放しなければならない!",
114             "Magical energy flows through you! You must release it!"));
115
116         flush();
117         msg_print(NULL);
118         (void)get_hack_dir(creature_ptr, &dire);
119         fire_ball(creature_ptr, GF_MANA, dire, creature_ptr->lev * 2, 3);
120     }
121
122     if ((creature_ptr->muta2 & MUT2_ATT_DEMON) && !creature_ptr->anti_magic && (randint1(6666) == 666)) {
123         bool pet = one_in_(6);
124         BIT_FLAGS mode = PM_ALLOW_GROUP;
125
126         if (pet)
127             mode |= PM_FORCE_PET;
128         else
129             mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
130
131         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_DEMON, mode)) {
132             msg_print(_("あなたはデーモンを引き寄せた!", "You have attracted a demon!"));
133             disturb(creature_ptr, FALSE, TRUE);
134         }
135     }
136
137     if ((creature_ptr->muta2 & MUT2_SPEED_FLUX) && one_in_(6000)) {
138         disturb(creature_ptr, FALSE, TRUE);
139         if (one_in_(2)) {
140             msg_print(_("精力的でなくなった気がする。", "You feel less energetic."));
141
142             if (creature_ptr->fast > 0) {
143                 set_fast(creature_ptr, 0, TRUE);
144             } else {
145                 set_slow(creature_ptr, randint1(30) + 10, FALSE);
146             }
147         } else {
148             msg_print(_("精力的になった気がする。", "You feel more energetic."));
149
150             if (creature_ptr->slow > 0) {
151                 set_slow(creature_ptr, 0, TRUE);
152             } else {
153                 set_fast(creature_ptr, randint1(30) + 10, FALSE);
154             }
155         }
156         msg_print(NULL);
157     }
158     if ((creature_ptr->muta2 & MUT2_BANISH_ALL) && one_in_(9000)) {
159         disturb(creature_ptr, FALSE, TRUE);
160         msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
161
162         banish_monsters(creature_ptr, 100);
163         if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->town_num) {
164             int n;
165             do {
166                 n = randint0(MAX_STORES);
167             } while ((n == STORE_HOME) || (n == STORE_MUSEUM));
168
169             msg_print(_("店の主人が丘に向かって走っている!", "You see one of the shopkeepers running for the hills!"));
170             store_shuffle(creature_ptr, n);
171         }
172         msg_print(NULL);
173     }
174
175     if ((creature_ptr->muta2 & MUT2_EAT_LIGHT) && one_in_(3000)) {
176         object_type* o_ptr;
177
178         msg_print(_("影につつまれた。", "A shadow passes over you."));
179         msg_print(NULL);
180
181         if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) {
182             hp_player(creature_ptr, 10);
183         }
184
185         o_ptr = &creature_ptr->inventory_list[INVEN_LITE];
186
187         if (o_ptr->tval == TV_LITE) {
188             if (!object_is_fixed_artifact(o_ptr) && (o_ptr->xtra4 > 0)) {
189                 hp_player(creature_ptr, o_ptr->xtra4 / 20);
190                 o_ptr->xtra4 /= 2;
191                 msg_print(_("光源からエネルギーを吸収した!", "You absorb energy from your light!"));
192                 notice_lite_change(creature_ptr, o_ptr);
193             }
194         }
195
196         /*
197                  * Unlite the area (radius 10) around player and
198                  * do 50 points damage to every affected monster
199                  */
200         unlite_area(creature_ptr, 50, 10);
201     }
202
203     if ((creature_ptr->muta2 & MUT2_ATT_ANIMAL) && !creature_ptr->anti_magic && one_in_(7000)) {
204         bool pet = one_in_(3);
205         BIT_FLAGS mode = PM_ALLOW_GROUP;
206
207         if (pet)
208             mode |= PM_FORCE_PET;
209         else
210             mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
211
212         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_ANIMAL, mode)) {
213             msg_print(_("動物を引き寄せた!", "You have attracted an animal!"));
214             disturb(creature_ptr, FALSE, TRUE);
215         }
216     }
217
218     if ((creature_ptr->muta2 & MUT2_RAW_CHAOS) && !creature_ptr->anti_magic && one_in_(8000)) {
219         disturb(creature_ptr, FALSE, TRUE);
220         msg_print(_("周りの空間が歪んでいる気がする!", "You feel the world warping around you!"));
221
222         msg_print(NULL);
223         fire_ball(creature_ptr, GF_CHAOS, 0, creature_ptr->lev, 8);
224     }
225
226     if ((creature_ptr->muta2 & MUT2_NORMALITY) && one_in_(5000)) {
227         if (!lose_mutation(creature_ptr, 0))
228             msg_print(_("奇妙なくらい普通になった気がする。", "You feel oddly normal."));
229     }
230
231     if ((creature_ptr->muta2 & MUT2_WRAITH) && !creature_ptr->anti_magic && one_in_(3000)) {
232         disturb(creature_ptr, FALSE, TRUE);
233         msg_print(_("非物質化した!", "You feel insubstantial!"));
234
235         msg_print(NULL);
236         set_wraith_form(creature_ptr, randint1(creature_ptr->lev / 2) + (creature_ptr->lev / 2), FALSE);
237     }
238
239     if ((creature_ptr->muta2 & MUT2_POLY_WOUND) && one_in_(3000)) {
240         do_poly_wounds(creature_ptr);
241     }
242
243     if ((creature_ptr->muta2 & MUT2_WASTING) && one_in_(3000)) {
244         int which_stat = randint0(A_MAX);
245         int sustained = FALSE;
246
247         switch (which_stat) {
248         case A_STR:
249             if (creature_ptr->sustain_str)
250                 sustained = TRUE;
251             break;
252         case A_INT:
253             if (creature_ptr->sustain_int)
254                 sustained = TRUE;
255             break;
256         case A_WIS:
257             if (creature_ptr->sustain_wis)
258                 sustained = TRUE;
259             break;
260         case A_DEX:
261             if (creature_ptr->sustain_dex)
262                 sustained = TRUE;
263             break;
264         case A_CON:
265             if (creature_ptr->sustain_con)
266                 sustained = TRUE;
267             break;
268         case A_CHR:
269             if (creature_ptr->sustain_chr)
270                 sustained = TRUE;
271             break;
272         default:
273             msg_print(_("不正な状態!", "Invalid stat chosen!"));
274             sustained = TRUE;
275         }
276
277         if (!sustained) {
278             disturb(creature_ptr, FALSE, TRUE);
279             msg_print(_("自分が衰弱していくのが分かる!", "You can feel yourself wasting away!"));
280             msg_print(NULL);
281             (void)dec_stat(creature_ptr, which_stat, randint1(6) + 6, one_in_(3));
282         }
283     }
284
285     if ((creature_ptr->muta2 & MUT2_ATT_DRAGON) && !creature_ptr->anti_magic && one_in_(3000)) {
286         bool pet = one_in_(5);
287         BIT_FLAGS mode = PM_ALLOW_GROUP;
288
289         if (pet)
290             mode |= PM_FORCE_PET;
291         else
292             mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
293
294         if (summon_specific(creature_ptr, (pet ? -1 : 0), creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, SUMMON_DRAGON, mode)) {
295             msg_print(_("ドラゴンを引き寄せた!", "You have attracted a dragon!"));
296             disturb(creature_ptr, FALSE, TRUE);
297         }
298     }
299
300     if ((creature_ptr->muta2 & MUT2_WEIRD_MIND) && !creature_ptr->anti_magic && one_in_(3000)) {
301         if (creature_ptr->tim_esp > 0) {
302             msg_print(_("精神にもやがかかった!", "Your mind feels cloudy!"));
303             set_tim_esp(creature_ptr, 0, TRUE);
304         } else {
305             msg_print(_("精神が広がった!", "Your mind expands!"));
306             set_tim_esp(creature_ptr, creature_ptr->lev, FALSE);
307         }
308     }
309
310     if ((creature_ptr->muta2 & MUT2_NAUSEA) && !creature_ptr->slow_digest && one_in_(9000)) {
311         disturb(creature_ptr, FALSE, TRUE);
312         msg_print(_("胃が痙攣し、食事を失った!", "Your stomach roils, and you lose your lunch!"));
313         msg_print(NULL);
314         set_food(creature_ptr, PY_FOOD_WEAK);
315         if (music_singing_any(creature_ptr))
316             stop_singing(creature_ptr);
317         if (hex_spelling_any(creature_ptr))
318             stop_hex_spell_all(creature_ptr);
319     }
320
321     if ((creature_ptr->muta2 & MUT2_WALK_SHAD) && !creature_ptr->anti_magic && one_in_(12000) && !creature_ptr->current_floor_ptr->inside_arena) {
322         reserve_alter_reality(creature_ptr);
323     }
324
325     if ((creature_ptr->muta2 & MUT2_WARNING) && one_in_(1000)) {
326         int danger_amount = 0;
327         for (MONSTER_IDX monster = 0; monster < creature_ptr->current_floor_ptr->m_max; monster++) {
328             monster_type* m_ptr = &creature_ptr->current_floor_ptr->m_list[monster];
329             monster_race* r_ptr = &r_info[m_ptr->r_idx];
330             if (!monster_is_valid(m_ptr))
331                 continue;
332
333             if (r_ptr->level >= creature_ptr->lev) {
334                 danger_amount += r_ptr->level - creature_ptr->lev + 1;
335             }
336         }
337
338         if (danger_amount > 100)
339             msg_print(_("非常に恐ろしい気がする!", "You feel utterly terrified!"));
340         else if (danger_amount > 50)
341             msg_print(_("恐ろしい気がする!", "You feel terrified!"));
342         else if (danger_amount > 20)
343             msg_print(_("非常に心配な気がする!", "You feel very worried!"));
344         else if (danger_amount > 10)
345             msg_print(_("心配な気がする!", "You feel paranoid!"));
346         else if (danger_amount > 5)
347             msg_print(_("ほとんど安全な気がする。", "You feel almost safe."));
348         else
349             msg_print(_("寂しい気がする。", "You feel lonely."));
350     }
351
352     if ((creature_ptr->muta2 & MUT2_INVULN) && !creature_ptr->anti_magic && one_in_(5000)) {
353         disturb(creature_ptr, FALSE, TRUE);
354         msg_print(_("無敵な気がする!", "You feel invincible!"));
355         msg_print(NULL);
356         (void)set_invuln(creature_ptr, randint1(8) + 8, FALSE);
357     }
358
359     if ((creature_ptr->muta2 & MUT2_SP_TO_HP) && one_in_(2000)) {
360         MANA_POINT wounds = (MANA_POINT)(creature_ptr->mhp - creature_ptr->chp);
361
362         if (wounds > 0) {
363             HIT_POINT healing = creature_ptr->csp;
364             if (healing > wounds)
365                 healing = wounds;
366
367             hp_player(creature_ptr, healing);
368             creature_ptr->csp -= healing;
369             creature_ptr->redraw |= (PR_HP | PR_MANA);
370         }
371     }
372
373     if ((creature_ptr->muta2 & MUT2_HP_TO_SP) && !creature_ptr->anti_magic && one_in_(4000)) {
374         HIT_POINT wounds = (HIT_POINT)(creature_ptr->msp - creature_ptr->csp);
375
376         if (wounds > 0) {
377             HIT_POINT healing = creature_ptr->chp;
378             if (healing > wounds)
379                 healing = wounds;
380
381             creature_ptr->csp += healing;
382             creature_ptr->redraw |= (PR_HP | PR_MANA);
383             take_hit(creature_ptr, DAMAGE_LOSELIFE, healing, _("頭に昇った血", "blood rushing to the head"), -1);
384         }
385     }
386
387     if ((creature_ptr->muta2 & MUT2_DISARM) && one_in_(10000)) {
388         disturb(creature_ptr, FALSE, TRUE);
389         msg_print(_("足がもつれて転んだ!", "You trip over your own feet!"));
390         take_hit(creature_ptr, DAMAGE_NOESCAPE, randint1(creature_ptr->wt / 6), _("転倒", "tripping"), -1);
391         drop_weapons(creature_ptr);
392     }
393 }