OSDN Git Service

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