OSDN Git Service

376a8dac8a5cf4bf2f4b08b0182f84f84aa61275
[hengbandforosx/hengbandosx.git] / src / spell / spells-status.cpp
1 /*!
2  * @brief スピード等のステータスに影響のある魔法の処理
3  * @date 2019/01/22
4  * @author deskull
5  */
6
7 #include "spell/spells-status.h"
8 #include "avatar/avatar.h"
9 #include "cmd-action/cmd-spell.h"
10 #include "cmd-item/cmd-magiceat.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "core/stuff-handler.h"
14 #include "core/window-redrawer.h"
15 #include "effect/attribute-types.h"
16 #include "effect/effect-characteristics.h"
17 #include "flavor/flavor-describer.h"
18 #include "flavor/object-flavor-types.h"
19 #include "floor/cave.h"
20 #include "floor/floor-object.h"
21 #include "floor/geometry.h"
22 #include "grid/feature-flag-types.h"
23 #include "hpmp/hp-mp-processor.h"
24 #include "inventory/inventory-object.h"
25 #include "inventory/inventory-slot-types.h"
26 #include "main/sound-definitions-table.h"
27 #include "main/sound-of-music.h"
28 #include "mind/mind-force-trainer.h"
29 #include "monster/monster-describer.h"
30 #include "object/object-kind-hook.h"
31 #include "player-base/player-class.h"
32 #include "player-info/class-info.h"
33 #include "player-info/magic-eater-data-type.h"
34 #include "player-status/player-energy.h"
35 #include "player/attack-defense-types.h"
36 #include "spell-kind/spells-launcher.h"
37 #include "spell-kind/spells-teleport.h"
38 #include "spell-kind/spells-world.h"
39 #include "status/action-setter.h"
40 #include "status/bad-status-setter.h"
41 #include "status/base-status.h"
42 #include "status/body-improvement.h"
43 #include "status/buff-setter.h"
44 #include "status/experience.h"
45 #include "status/shape-changer.h"
46 #include "status/sight-setter.h"
47 #include "system/baseitem-info.h"
48 #include "system/floor-type-definition.h"
49 #include "system/grid-type-definition.h"
50 #include "system/item-entity.h"
51 #include "system/monster-entity.h"
52 #include "system/player-type-definition.h"
53 #include "system/redrawing-flags-updater.h"
54 #include "target/target-getter.h"
55 #include "timed-effect/player-acceleration.h"
56 #include "timed-effect/player-cut.h"
57 #include "timed-effect/timed-effects.h"
58 #include "util/bit-flags-calculator.h"
59 #include "view/display-messages.h"
60
61 /*!
62  * @brief モンスター回復処理
63  * @param player_ptr プレイヤーへの参照ポインタ
64  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
65  * @param dam 威力
66  * @return 作用が実際にあった場合TRUEを返す
67  */
68 bool heal_monster(PlayerType *player_ptr, DIRECTION dir, int dam)
69 {
70     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
71     return project_hook(player_ptr, AttributeType::OLD_HEAL, dir, dam, flg);
72 }
73
74 /*!
75  * @brief モンスター加速処理
76  * @param player_ptr プレイヤーへの参照ポインタ
77  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
78  * @param power 効力
79  * @return 作用が実際にあった場合TRUEを返す
80  */
81 bool speed_monster(PlayerType *player_ptr, DIRECTION dir, int power)
82 {
83     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
84     return project_hook(player_ptr, AttributeType::OLD_SPEED, dir, power, flg);
85 }
86
87 /*!
88  * @brief モンスター減速処理
89  * @param player_ptr プレイヤーへの参照ポインタ
90  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
91  * @param power 効力
92  * @return 作用が実際にあった場合TRUEを返す
93  */
94 bool slow_monster(PlayerType *player_ptr, DIRECTION dir, int power)
95 {
96     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
97     return project_hook(player_ptr, AttributeType::OLD_SLOW, dir, power, flg);
98 }
99
100 /*!
101  * @brief モンスター催眠処理
102  * @param player_ptr プレイヤーへの参照ポインタ
103  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
104  * @param power 効力
105  * @return 作用が実際にあった場合TRUEを返す
106  */
107 bool sleep_monster(PlayerType *player_ptr, DIRECTION dir, int power)
108 {
109     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
110     return project_hook(player_ptr, AttributeType::OLD_SLEEP, dir, power, flg);
111 }
112
113 /*!
114  * @brief モンスター拘束(STASIS)処理
115  * @param player_ptr プレイヤーへの参照ポインタ
116  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
117  * @return 作用が実際にあった場合TRUEを返す
118  * @details 威力はプレイヤーレベル*2に固定
119  */
120 bool stasis_monster(PlayerType *player_ptr, DIRECTION dir)
121 {
122     return fire_ball_hide(player_ptr, AttributeType::STASIS, dir, player_ptr->lev * 2, 0);
123 }
124
125 /*!
126  * @brief 邪悪なモンスター拘束(STASIS)処理
127  * @param player_ptr プレイヤーへの参照ポインタ
128  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
129  * @return 作用が実際にあった場合TRUEを返す
130  * @details 威力はプレイヤーレベル*2に固定
131  */
132 bool stasis_evil(PlayerType *player_ptr, DIRECTION dir)
133 {
134     return fire_ball_hide(player_ptr, AttributeType::STASIS_EVIL, dir, player_ptr->lev * 2, 0);
135 }
136
137 /*!
138  * @brief モンスター混乱処理
139  * @param player_ptr プレイヤーへの参照ポインタ
140  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
141  * @param plev プレイヤーレベル(=効力)
142  * @return 作用が実際にあった場合TRUEを返す
143  */
144 bool confuse_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
145 {
146     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
147     return project_hook(player_ptr, AttributeType::OLD_CONF, dir, plev, flg);
148 }
149
150 /*!
151  * @brief モンスター朦朧処理
152  * @param player_ptr プレイヤーへの参照ポインタ
153  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
154  * @param plev プレイヤーレベル(=効力)
155  * @return 作用が実際にあった場合TRUEを返す
156  */
157 bool stun_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
158 {
159     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
160     return project_hook(player_ptr, AttributeType::STUN, dir, plev, flg);
161 }
162
163 /*!
164  * @brief チェンジモンスター処理
165  * @param player_ptr プレイヤーへの参照ポインタ
166  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
167  * @param power 効力
168  * @return 作用が実際にあった場合TRUEを返す
169  */
170 bool poly_monster(PlayerType *player_ptr, DIRECTION dir, int power)
171 {
172     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
173     bool tester = (project_hook(player_ptr, AttributeType::OLD_POLY, dir, power, flg));
174     if (tester) {
175         chg_virtue(player_ptr, Virtue::CHANCE, 1);
176     }
177     return tester;
178 }
179
180 /*!
181  * @brief クローンモンスター処理
182  * @param player_ptr プレイヤーへの参照ポインタ
183  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
184  * @return 作用が実際にあった場合TRUEを返す
185  */
186 bool clone_monster(PlayerType *player_ptr, DIRECTION dir)
187 {
188     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
189     return project_hook(player_ptr, AttributeType::OLD_CLONE, dir, 0, flg);
190 }
191
192 /*!
193  * @brief モンスター恐慌処理
194  * @param player_ptr プレイヤーへの参照ポインタ
195  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
196  * @param plev プレイヤーレベル(=効力)
197  * @return 作用が実際にあった場合TRUEを返す
198  */
199 bool fear_monster(PlayerType *player_ptr, DIRECTION dir, PLAYER_LEVEL plev)
200 {
201     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
202     return project_hook(player_ptr, AttributeType::TURN_ALL, dir, plev, flg);
203 }
204
205 bool time_walk(PlayerType *player_ptr)
206 {
207     if (player_ptr->timewalk) {
208         msg_print(_("既に時は止まっている。", "Time is already stopped."));
209         return false;
210     }
211
212     player_ptr->timewalk = true;
213     msg_print(_("「時よ!」", "You yell 'Time!'"));
214     //  msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
215     msg_print(nullptr);
216
217     player_ptr->energy_need -= 1000 + (100 + player_ptr->csp - 50) * TURNS_PER_TICK / 10;
218     auto &rfu = RedrawingFlagsUpdater::get_instance();
219     player_ptr->redraw |= (PR_MAP);
220     rfu.set_flag(StatusRedrawingFlag::MONSTER_STATUSES);
221     player_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
222     handle_stuff(player_ptr);
223     return true;
224 }
225
226 /*!
227  * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
228  * @param player_ptr プレイヤーへの参照ポインタ
229  * @param options スペル共通オプション
230  */
231 void roll_hitdice(PlayerType *player_ptr, spell_operation options)
232 {
233     int min_value = player_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (player_ptr->hitdie + 1)) * 3 / 8;
234     int max_value = player_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (player_ptr->hitdie + 1)) * 5 / 8;
235
236     /* Rerate */
237     while (true) {
238         /* Pre-calculate level 1 hitdice */
239         player_ptr->player_hp[0] = (int)player_ptr->hitdie;
240
241         for (int i = 1; i < 4; i++) {
242             player_ptr->player_hp[0] += randint1(player_ptr->hitdie);
243         }
244
245         /* Roll the hitpoint values */
246         for (int i = 1; i < PY_MAX_LEVEL; i++) {
247             player_ptr->player_hp[i] = player_ptr->player_hp[i - 1] + randint1(player_ptr->hitdie);
248         }
249
250         /* Require "valid" hitpoints at highest level */
251         if ((player_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) && (player_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) {
252             break;
253         }
254     }
255
256     player_ptr->knowledge &= ~(KNOW_HPRATE);
257
258     auto percent = (player_ptr->player_hp[PY_MAX_LEVEL - 1] * 200) / (2 * player_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (player_ptr->hitdie + 1)));
259     auto &rfu = RedrawingFlagsUpdater::get_instance();
260     rfu.set_flag(StatusRedrawingFlag::HP);
261     player_ptr->redraw |= (PR_HP);
262     player_ptr->window_flags |= (PW_PLAYER);
263
264     if (!(options & SPOP_NO_UPDATE)) {
265         handle_stuff(player_ptr);
266     }
267
268     if (!(options & SPOP_DISPLAY_MES)) {
269         return;
270     }
271
272     if (options & SPOP_DEBUG) {
273         msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
274         player_ptr->knowledge |= KNOW_HPRATE;
275         return;
276     }
277
278     msg_print(_("体力ランクが変わった。", "Life rate has changed."));
279 }
280
281 bool life_stream(PlayerType *player_ptr, bool message, bool virtue_change)
282 {
283     if (virtue_change) {
284         chg_virtue(player_ptr, Virtue::VITALITY, 1);
285         chg_virtue(player_ptr, Virtue::UNLIFE, -5);
286     }
287
288     if (message) {
289         msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
290     }
291
292     restore_level(player_ptr);
293     BadStatusSetter bss(player_ptr);
294     (void)bss.set_poison(0);
295     (void)bss.set_blindness(0);
296     (void)bss.set_confusion(0);
297     (void)bss.hallucination(0);
298     (void)bss.set_stun(0);
299     (void)bss.set_cut(0);
300     (void)bss.set_paralysis(0);
301     (void)restore_all_status(player_ptr);
302     (void)set_shero(player_ptr, 0, true);
303     handle_stuff(player_ptr);
304     hp_player(player_ptr, 5000);
305
306     return true;
307 }
308
309 bool heroism(PlayerType *player_ptr, int base)
310 {
311     auto ident = false;
312     if (BadStatusSetter(player_ptr).set_fear(0)) {
313         ident = true;
314     }
315
316     if (set_hero(player_ptr, player_ptr->hero + randint1(base) + base, false)) {
317         ident = true;
318     }
319
320     if (hp_player(player_ptr, 10)) {
321         ident = true;
322     }
323
324     return ident;
325 }
326
327 bool berserk(PlayerType *player_ptr, int base)
328 {
329     auto ident = false;
330     if (BadStatusSetter(player_ptr).set_fear(0)) {
331         ident = true;
332     }
333
334     if (set_shero(player_ptr, player_ptr->shero + randint1(base) + base, false)) {
335         ident = true;
336     }
337
338     if (hp_player(player_ptr, 30)) {
339         ident = true;
340     }
341
342     return ident;
343 }
344
345 bool cure_light_wounds(PlayerType *player_ptr, DICE_NUMBER dice, DICE_SID sides)
346 {
347     auto ident = false;
348     if (hp_player(player_ptr, damroll(dice, sides))) {
349         ident = true;
350     }
351
352     BadStatusSetter bss(player_ptr);
353     if (bss.set_blindness(0)) {
354         ident = true;
355     }
356
357     if (bss.mod_cut(-10)) {
358         ident = true;
359     }
360
361     if (set_shero(player_ptr, 0, true)) {
362         ident = true;
363     }
364
365     return ident;
366 }
367
368 bool cure_serious_wounds(PlayerType *player_ptr, DICE_NUMBER dice, DICE_SID sides)
369 {
370     auto ident = false;
371     if (hp_player(player_ptr, damroll(dice, sides))) {
372         ident = true;
373     }
374
375     BadStatusSetter bss(player_ptr);
376     if (bss.set_blindness(0)) {
377         ident = true;
378     }
379
380     if (bss.set_confusion(0)) {
381         ident = true;
382     }
383
384     if (bss.set_cut((player_ptr->effects()->cut()->current() / 2) - 50)) {
385         ident = true;
386     }
387
388     if (set_shero(player_ptr, 0, true)) {
389         ident = true;
390     }
391
392     return ident;
393 }
394
395 bool cure_critical_wounds(PlayerType *player_ptr, int pow)
396 {
397     auto ident = false;
398     if (hp_player(player_ptr, pow)) {
399         ident = true;
400     }
401
402     BadStatusSetter bss(player_ptr);
403     if (bss.set_blindness(0)) {
404         ident = true;
405     }
406
407     if (bss.set_confusion(0)) {
408         ident = true;
409     }
410
411     if (bss.set_poison(0)) {
412         ident = true;
413     }
414
415     if (bss.set_stun(0)) {
416         ident = true;
417     }
418
419     if (bss.set_cut(0)) {
420         ident = true;
421     }
422
423     if (set_shero(player_ptr, 0, true)) {
424         ident = true;
425     }
426
427     return ident;
428 }
429
430 bool true_healing(PlayerType *player_ptr, int pow)
431 {
432     auto ident = false;
433     if (hp_player(player_ptr, pow)) {
434         ident = true;
435     }
436
437     BadStatusSetter bss(player_ptr);
438     if (bss.set_blindness(0)) {
439         ident = true;
440     }
441
442     if (bss.set_confusion(0)) {
443         ident = true;
444     }
445
446     if (bss.set_poison(0)) {
447         ident = true;
448     }
449
450     if (bss.set_stun(0)) {
451         ident = true;
452     }
453
454     if (bss.set_cut(0)) {
455         ident = true;
456     }
457
458     if (bss.hallucination(0)) {
459         ident = true;
460     }
461
462     return ident;
463 }
464
465 bool restore_mana(PlayerType *player_ptr, bool magic_eater)
466 {
467     if (PlayerClass(player_ptr).equals(PlayerClassType::MAGIC_EATER) && magic_eater) {
468         // 魔力復活による、魔道具術師の取り込んだ魔法の回復量
469         // 取り込み数が10回未満: 3 回分回復
470         // 取り込み数が10回以上: 取り込み回数/3 回分回復
471         auto magic_eater_data = PlayerClass(player_ptr).get_specific_data<magic_eater_data_type>();
472         for (auto tval : { ItemKindType::STAFF, ItemKindType::WAND }) {
473             for (auto &item : magic_eater_data->get_item_group(tval)) {
474                 item.charge += (item.count < 10) ? EATER_CHARGE * 3 : item.count * EATER_CHARGE / 3;
475                 item.charge = std::min(item.charge, item.count * EATER_CHARGE);
476             }
477         }
478
479         auto sval = 0;
480         for (auto &item : magic_eater_data->get_item_group(ItemKindType::ROD)) {
481             const auto bi_id = lookup_baseitem_id({ ItemKindType::ROD, sval });
482             item.charge -= ((item.count < 10) ? EATER_ROD_CHARGE * 3 : item.count * EATER_ROD_CHARGE / 3) * baseitems_info[bi_id].pval;
483             item.charge = std::max(item.charge, 0);
484             ++sval;
485         }
486
487         msg_print(_("頭がハッキリとした。", "You feel your head clear."));
488         player_ptr->window_flags |= (PW_PLAYER);
489         return true;
490     }
491
492     if (player_ptr->csp >= player_ptr->msp) {
493         return false;
494     }
495
496     player_ptr->csp = player_ptr->msp;
497     player_ptr->csp_frac = 0;
498     msg_print(_("頭がハッキリとした。", "You feel your head clear."));
499     player_ptr->redraw |= (PR_MP);
500     player_ptr->window_flags |= (PW_PLAYER);
501     player_ptr->window_flags |= (PW_SPELL);
502     return true;
503 }
504
505 bool restore_all_status(PlayerType *player_ptr)
506 {
507     bool ident = false;
508     if (do_res_stat(player_ptr, A_STR)) {
509         ident = true;
510     }
511     if (do_res_stat(player_ptr, A_INT)) {
512         ident = true;
513     }
514     if (do_res_stat(player_ptr, A_WIS)) {
515         ident = true;
516     }
517     if (do_res_stat(player_ptr, A_DEX)) {
518         ident = true;
519     }
520     if (do_res_stat(player_ptr, A_CON)) {
521         ident = true;
522     }
523     if (do_res_stat(player_ptr, A_CHR)) {
524         ident = true;
525     }
526     return ident;
527 }
528
529 bool fishing(PlayerType *player_ptr)
530 {
531     DIRECTION dir;
532     if (!get_direction(player_ptr, &dir, false, false)) {
533         return false;
534     }
535     POSITION y = player_ptr->y + ddy[dir];
536     POSITION x = player_ptr->x + ddx[dir];
537     player_ptr->fishing_dir = dir;
538     auto *floor_ptr = player_ptr->current_floor_ptr;
539     if (!cave_has_flag_bold(floor_ptr, y, x, TerrainCharacteristics::WATER)) {
540         msg_print(_("そこは水辺ではない。", "You can't fish here."));
541         return false;
542     }
543
544     if (floor_ptr->grid_array[y][x].m_idx) {
545         const auto m_name = monster_desc(player_ptr, &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx], 0);
546         msg_format(_("%sが邪魔だ!", "%s^ is standing in your way."), m_name.data());
547         PlayerEnergy(player_ptr).reset_player_turn();
548         return false;
549     }
550
551     set_action(player_ptr, ACTION_FISH);
552     player_ptr->redraw |= (PR_ACTION);
553     return true;
554 }
555
556 /*!
557  * @brief 装備を脱ぎ捨てて小宇宙を燃やす
558  * @param player_ptr プレイヤー情報への参照ポインタ
559  * @param o_ptr_ptr 脱ぐ装備品への参照ポインタのポインタ
560  * @return 脱いだらTRUE、脱がなかったらFALSE
561  * @details
562  * 脱いで落とした装備にtimeoutを設定するために装備品のアドレスを返す。
563  */
564 bool cosmic_cast_off(PlayerType *player_ptr, ItemEntity **o_ptr_ptr)
565 {
566     auto *o_ptr = (*o_ptr_ptr);
567
568     /* Cast off activated item */
569     INVENTORY_IDX slot;
570     for (slot = INVEN_MAIN_HAND; slot <= INVEN_FEET; slot++) {
571         if (o_ptr == &player_ptr->inventory_list[slot]) {
572             break;
573         }
574     }
575
576     if (slot > INVEN_FEET) {
577         return false;
578     }
579
580     ItemEntity forge;
581     (&forge)->copy_from(o_ptr);
582     inven_item_increase(player_ptr, slot, (0 - o_ptr->number));
583     inven_item_optimize(player_ptr, slot);
584
585     OBJECT_IDX old_o_idx = drop_near(player_ptr, &forge, 0, player_ptr->y, player_ptr->x);
586     *o_ptr_ptr = &player_ptr->current_floor_ptr->o_list[old_o_idx];
587
588     const auto item_name = describe_flavor(player_ptr, &forge, OD_NAME_ONLY);
589     msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), item_name.data());
590     sound(SOUND_TAKE_OFF);
591
592     /* Get effects */
593     msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
594     TIME_EFFECT t = 20 + randint1(20);
595     BadStatusSetter bss(player_ptr);
596     (void)bss.mod_blindness(t);
597     (void)bss.set_fear(0);
598     (void)set_tim_esp(player_ptr, player_ptr->tim_esp + t, false);
599     (void)set_tim_regen(player_ptr, player_ptr->tim_regen + t, false);
600     (void)set_hero(player_ptr, player_ptr->hero + t, false);
601     (void)set_blessed(player_ptr, player_ptr->blessed + t, false);
602     (void)mod_acceleration(player_ptr, t, false);
603     (void)set_shero(player_ptr, player_ptr->shero + t, false);
604     if (PlayerClass(player_ptr).equals(PlayerClassType::FORCETRAINER)) {
605         set_current_ki(player_ptr, true, player_ptr->lev * 5 + 190);
606         msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
607     }
608
609     return true;
610 }
611
612 /*!
613  * @brief プレイヤーの因果混乱処理 / Apply Nexus
614  * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
615  */
616 void apply_nexus(MonsterEntity *m_ptr, PlayerType *player_ptr)
617 {
618     switch (randint1(7)) {
619     case 1:
620     case 2:
621     case 3: {
622         teleport_player(player_ptr, 200, TELEPORT_PASSIVE);
623         break;
624     }
625
626     case 4:
627     case 5: {
628         teleport_player_to(player_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
629         break;
630     }
631
632     case 6: {
633         if (randint0(100) < player_ptr->skill_sav) {
634             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
635             break;
636         }
637
638         teleport_level(player_ptr, 0);
639         break;
640     }
641
642     case 7: {
643         if (randint0(100) < player_ptr->skill_sav) {
644             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
645             break;
646         }
647
648         msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
649         status_shuffle(player_ptr);
650         break;
651     }
652     }
653 }
654
655 /*!
656  * @brief プレイヤーのステータスシャッフル処理
657  * @param player_ptr プレイヤーへの参照ポインタ
658  */
659 void status_shuffle(PlayerType *player_ptr)
660 {
661     /* Pick a pair of stats */
662     int i = randint0(A_MAX);
663     int j;
664
665     //!< @todo ここのループは一体何をしている?
666     for (j = i; j == i; j = randint0(A_MAX)) { /* loop */
667         ;
668     }
669
670     BASE_STATUS max1 = player_ptr->stat_max[i];
671     BASE_STATUS cur1 = player_ptr->stat_cur[i];
672     BASE_STATUS max2 = player_ptr->stat_max[j];
673     BASE_STATUS cur2 = player_ptr->stat_cur[j];
674
675     player_ptr->stat_max[i] = max2;
676     player_ptr->stat_cur[i] = cur2;
677     player_ptr->stat_max[j] = max1;
678     player_ptr->stat_cur[j] = cur1;
679
680     for (int k = 0; k < A_MAX; k++) {
681         if (player_ptr->stat_max[k] > player_ptr->stat_max_max[k]) {
682             player_ptr->stat_max[k] = player_ptr->stat_max_max[k];
683         }
684         if (player_ptr->stat_cur[k] > player_ptr->stat_max_max[k]) {
685             player_ptr->stat_cur[k] = player_ptr->stat_max_max[k];
686         }
687     }
688
689     RedrawingFlagsUpdater::get_instance().set_flag(StatusRedrawingFlag::BONUS);
690 }