OSDN Git Service

Merge pull request #936 from shimitei/feature/#916_fix_sound_on_off
[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 "cmd-action/cmd-spell.h"
9 #include "cmd-item/cmd-magiceat.h"
10 #include "core/hp-mp-processor.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/effect-characteristics.h"
16 #include "flavor/flavor-describer.h"
17 #include "flavor/object-flavor-types.h"
18 #include "floor/cave.h"
19 #include "floor/floor-object.h"
20 #include "floor/geometry.h"
21 #include "grid/feature-flag-types.h"
22 #include "grid/grid.h"
23 #include "inventory/inventory-object.h"
24 #include "inventory/inventory-slot-types.h"
25 #include "mind/mind-force-trainer.h"
26 #include "monster/monster-describer.h"
27 #include "object/object-generator.h"
28 #include "object/object-kind-hook.h"
29 #include "object/object-kind.h"
30 #include "player/attack-defense-types.h"
31 #include "player-info/avatar.h"
32 #include "player/player-class.h"
33 #include "player/player-status.h"
34 #include "spell-kind/spells-launcher.h"
35 #include "spell-kind/spells-teleport.h"
36 #include "spell-kind/spells-world.h"
37 #include "spell/spell-types.h"
38 #include "status/action-setter.h"
39 #include "status/bad-status-setter.h"
40 #include "status/base-status.h"
41 #include "status/body-improvement.h"
42 #include "status/buff-setter.h"
43 #include "status/experience.h"
44 #include "status/shape-changer.h"
45 #include "status/sight-setter.h"
46 #include "system/floor-type-definition.h"
47 #include "system/monster-type-definition.h"
48 #include "system/object-type-definition.h"
49 #include "system/player-type-definition.h"
50 #include "target/target-getter.h"
51 #include "util/bit-flags-calculator.h"
52 #include "view/display-messages.h"
53
54 /*!
55  * @brief モンスター回復処理
56  * @param caster_ptr プレーヤーへの参照ポインタ
57  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
58  * @param dam 威力
59  * @return 作用が実際にあった場合TRUEを返す
60  */
61 bool heal_monster(player_type *caster_ptr, DIRECTION dir, HIT_POINT dam)
62 {
63     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
64     return (project_hook(caster_ptr, GF_OLD_HEAL, dir, dam, flg));
65 }
66
67 /*!
68  * @brief モンスター加速処理
69  * @param caster_ptr プレーヤーへの参照ポインタ
70  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
71  * @param power 効力
72  * @return 作用が実際にあった場合TRUEを返す
73  */
74 bool speed_monster(player_type *caster_ptr, DIRECTION dir, int power)
75 {
76     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
77     return (project_hook(caster_ptr, GF_OLD_SPEED, dir, power, flg));
78 }
79
80 /*!
81  * @brief モンスター減速処理
82  * @param caster_ptr プレーヤーへの参照ポインタ
83  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
84  * @param power 効力
85  * @return 作用が実際にあった場合TRUEを返す
86  */
87 bool slow_monster(player_type *caster_ptr, DIRECTION dir, int power)
88 {
89     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
90     return (project_hook(caster_ptr, GF_OLD_SLOW, dir, power, flg));
91 }
92
93 /*!
94  * @brief モンスター催眠処理
95  * @param caster_ptr プレーヤーへの参照ポインタ
96  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
97  * @param power 効力
98  * @return 作用が実際にあった場合TRUEを返す
99  */
100 bool sleep_monster(player_type *caster_ptr, DIRECTION dir, int power)
101 {
102     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
103     return (project_hook(caster_ptr, GF_OLD_SLEEP, dir, power, flg));
104 }
105
106 /*!
107  * @brief モンスター拘束(STASIS)処理
108  * @param caster_ptr プレーヤーへの参照ポインタ
109  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
110  * @return 作用が実際にあった場合TRUEを返す
111  * @details 威力はプレイヤーレベル*2に固定
112  */
113 bool stasis_monster(player_type *caster_ptr, DIRECTION dir) { return (fire_ball_hide(caster_ptr, GF_STASIS, dir, caster_ptr->lev * 2, 0)); }
114
115 /*!
116  * @brief 邪悪なモンスター拘束(STASIS)処理
117  * @param caster_ptr プレーヤーへの参照ポインタ
118  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
119  * @return 作用が実際にあった場合TRUEを返す
120  * @details 威力はプレイヤーレベル*2に固定
121  */
122 bool stasis_evil(player_type *caster_ptr, DIRECTION dir) { return (fire_ball_hide(caster_ptr, GF_STASIS_EVIL, dir, caster_ptr->lev * 2, 0)); }
123
124 /*!
125  * @brief モンスター混乱処理
126  * @param caster_ptr プレーヤーへの参照ポインタ
127  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
128  * @param plev プレイヤーレベル(=効力)
129  * @return 作用が実際にあった場合TRUEを返す
130  */
131 bool confuse_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
132 {
133     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
134     return (project_hook(caster_ptr, GF_OLD_CONF, dir, plev, flg));
135 }
136
137 /*!
138  * @brief モンスター朦朧処理
139  * @param caster_ptr プレーヤーへの参照ポインタ
140  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
141  * @param plev プレイヤーレベル(=効力)
142  * @return 作用が実際にあった場合TRUEを返す
143  */
144 bool stun_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
145 {
146     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
147     return (project_hook(caster_ptr, GF_STUN, dir, plev, flg));
148 }
149
150 /*!
151  * @brief チェンジモンスター処理
152  * @param caster_ptr プレーヤーへの参照ポインタ
153  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
154  * @param power 効力
155  * @return 作用が実際にあった場合TRUEを返す
156  */
157 bool poly_monster(player_type *caster_ptr, DIRECTION dir, int power)
158 {
159     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
160     bool tester = (project_hook(caster_ptr, GF_OLD_POLY, dir, power, flg));
161     if (tester)
162         chg_virtue(caster_ptr, V_CHANCE, 1);
163     return (tester);
164 }
165
166 /*!
167  * @brief クローンモンスター処理
168  * @param caster_ptr プレーヤーへの参照ポインタ
169  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
170  * @return 作用が実際にあった場合TRUEを返す
171  */
172 bool clone_monster(player_type *caster_ptr, DIRECTION dir)
173 {
174     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
175     return (project_hook(caster_ptr, GF_OLD_CLONE, dir, 0, flg));
176 }
177
178 /*!
179  * @brief モンスター恐慌処理
180  * @param caster_ptr プレーヤーへの参照ポインタ
181  * @param dir 方向(5ならばグローバル変数 target_col/target_row の座標を目標にする)
182  * @param plev プレイヤーレベル(=効力)
183  * @return 作用が実際にあった場合TRUEを返す
184  */
185 bool fear_monster(player_type *caster_ptr, DIRECTION dir, PLAYER_LEVEL plev)
186 {
187     BIT_FLAGS flg = PROJECT_STOP | PROJECT_KILL | PROJECT_REFLECTABLE;
188     return (project_hook(caster_ptr, GF_TURN_ALL, dir, plev, flg));
189 }
190
191 bool time_walk(player_type *creature_ptr)
192 {
193     if (creature_ptr->timewalk) {
194         msg_print(_("既に時は止まっている。", "Time is already stopped."));
195         return FALSE;
196     }
197
198     creature_ptr->timewalk = TRUE;
199     msg_print(_("「時よ!」", "You yell 'Time!'"));
200     //  msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
201     msg_print(NULL);
202
203     creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50) * TURNS_PER_TICK / 10;
204     creature_ptr->redraw |= (PR_MAP);
205     creature_ptr->update |= (PU_MONSTERS);
206     creature_ptr->window_flags |= (PW_OVERHEAD | PW_DUNGEON);
207     handle_stuff(creature_ptr);
208     return TRUE;
209 }
210
211 /*!
212  * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
213  * @param creature_ptr プレーヤーへの参照ポインタ
214  * @param options スペル共通オプション
215  * @return なし
216  */
217 void roll_hitdice(player_type *creature_ptr, spell_operation options)
218 {
219     HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
220     HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
221
222     /* Rerate */
223     while (TRUE) {
224         /* Pre-calculate level 1 hitdice */
225         creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
226
227         for (int i = 1; i < 4; i++) {
228             creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
229         }
230
231         /* Roll the hitpoint values */
232         for (int i = 1; i < PY_MAX_LEVEL; i++) {
233             creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
234         }
235
236         /* Require "valid" hitpoints at highest level */
237         if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) && (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value))
238             break;
239     }
240
241     PERCENTAGE percent
242         = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) / (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
243
244     /* Update and redraw hitpoints */
245     creature_ptr->update |= (PU_HP);
246     creature_ptr->redraw |= (PR_HP);
247     creature_ptr->window_flags |= (PW_PLAYER);
248
249     if (!(options & SPOP_NO_UPDATE))
250         handle_stuff(creature_ptr);
251
252     if (!(options & SPOP_DISPLAY_MES))
253         return;
254
255     if (options & SPOP_DEBUG) {
256         msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
257         creature_ptr->knowledge |= KNOW_HPRATE;
258         return;
259     }
260
261     msg_print(_("体力ランクが変わった。", "Life rate has changed."));
262     creature_ptr->knowledge &= ~(KNOW_HPRATE);
263 }
264
265 bool life_stream(player_type *creature_ptr, bool message, bool virtue_change)
266 {
267     if (virtue_change) {
268         chg_virtue(creature_ptr, V_VITALITY, 1);
269         chg_virtue(creature_ptr, V_UNLIFE, -5);
270     }
271
272     if (message) {
273         msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
274     }
275
276     restore_level(creature_ptr);
277     (void)set_poisoned(creature_ptr, 0);
278     (void)set_blind(creature_ptr, 0);
279     (void)set_confused(creature_ptr, 0);
280     (void)set_image(creature_ptr, 0);
281     (void)set_stun(creature_ptr, 0);
282     (void)set_cut(creature_ptr, 0);
283     (void)set_paralyzed(creature_ptr, 0);
284     (void)restore_all_status(creature_ptr);
285     (void)set_shero(creature_ptr, 0, TRUE);
286     handle_stuff(creature_ptr);
287     hp_player(creature_ptr, 5000);
288
289     return TRUE;
290 }
291
292 bool heroism(player_type *creature_ptr, int base)
293 {
294     bool ident = FALSE;
295     if (set_afraid(creature_ptr, 0))
296         ident = TRUE;
297     if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE))
298         ident = TRUE;
299     if (hp_player(creature_ptr, 10))
300         ident = TRUE;
301     return ident;
302 }
303
304 bool berserk(player_type *creature_ptr, int base)
305 {
306     bool ident = FALSE;
307     if (set_afraid(creature_ptr, 0))
308         ident = TRUE;
309     if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE))
310         ident = TRUE;
311     if (hp_player(creature_ptr, 30))
312         ident = TRUE;
313     return ident;
314 }
315
316 bool cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
317 {
318     bool ident = FALSE;
319     if (hp_player(creature_ptr, damroll(dice, sides)))
320         ident = TRUE;
321     if (set_blind(creature_ptr, 0))
322         ident = TRUE;
323     if (set_cut(creature_ptr, creature_ptr->cut - 10))
324         ident = TRUE;
325     if (set_shero(creature_ptr, 0, TRUE))
326         ident = TRUE;
327     return ident;
328 }
329
330 bool cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
331 {
332     bool ident = FALSE;
333     if (hp_player(creature_ptr, damroll(dice, sides)))
334         ident = TRUE;
335     if (set_blind(creature_ptr, 0))
336         ident = TRUE;
337     if (set_confused(creature_ptr, 0))
338         ident = TRUE;
339     if (set_cut(creature_ptr, (creature_ptr->cut / 2) - 50))
340         ident = TRUE;
341     if (set_shero(creature_ptr, 0, TRUE))
342         ident = TRUE;
343     return ident;
344 }
345
346 bool cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
347 {
348     bool ident = FALSE;
349     if (hp_player(creature_ptr, pow))
350         ident = TRUE;
351     if (set_blind(creature_ptr, 0))
352         ident = TRUE;
353     if (set_confused(creature_ptr, 0))
354         ident = TRUE;
355     if (set_poisoned(creature_ptr, 0))
356         ident = TRUE;
357     if (set_stun(creature_ptr, 0))
358         ident = TRUE;
359     if (set_cut(creature_ptr, 0))
360         ident = TRUE;
361     if (set_shero(creature_ptr, 0, TRUE))
362         ident = TRUE;
363     return ident;
364 }
365
366 bool true_healing(player_type *creature_ptr, HIT_POINT pow)
367 {
368     bool ident = FALSE;
369     if (hp_player(creature_ptr, pow))
370         ident = TRUE;
371     if (set_blind(creature_ptr, 0))
372         ident = TRUE;
373     if (set_confused(creature_ptr, 0))
374         ident = TRUE;
375     if (set_poisoned(creature_ptr, 0))
376         ident = TRUE;
377     if (set_stun(creature_ptr, 0))
378         ident = TRUE;
379     if (set_cut(creature_ptr, 0))
380         ident = TRUE;
381     if (set_image(creature_ptr, 0))
382         ident = TRUE;
383     return ident;
384 }
385
386 bool restore_mana(player_type *creature_ptr, bool magic_eater)
387 {
388     if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater) {
389         int i;
390         for (i = 0; i < EATER_EXT * 2; i++) {
391             creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
392             if (creature_ptr->magic_num1[i] > creature_ptr->magic_num2[i] * EATER_CHARGE)
393                 creature_ptr->magic_num1[i] = creature_ptr->magic_num2[i] * EATER_CHARGE;
394         }
395
396         for (; i < EATER_EXT * 3; i++) {
397             KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
398             creature_ptr->magic_num1[i]
399                 -= ((creature_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3) * k_info[k_idx].pval;
400             if (creature_ptr->magic_num1[i] < 0)
401                 creature_ptr->magic_num1[i] = 0;
402         }
403
404         msg_print(_("頭がハッキリとした。", "You feel your head clear."));
405         creature_ptr->window_flags |= (PW_PLAYER);
406         return TRUE;
407     }
408
409     if (creature_ptr->csp >= creature_ptr->msp)
410         return FALSE;
411
412     creature_ptr->csp = creature_ptr->msp;
413     creature_ptr->csp_frac = 0;
414     msg_print(_("頭がハッキリとした。", "You feel your head clear."));
415     creature_ptr->redraw |= (PR_MANA);
416     creature_ptr->window_flags |= (PW_PLAYER);
417     creature_ptr->window_flags |= (PW_SPELL);
418     return TRUE;
419 }
420
421 bool restore_all_status(player_type *creature_ptr)
422 {
423     bool ident = FALSE;
424     if (do_res_stat(creature_ptr, A_STR))
425         ident = TRUE;
426     if (do_res_stat(creature_ptr, A_INT))
427         ident = TRUE;
428     if (do_res_stat(creature_ptr, A_WIS))
429         ident = TRUE;
430     if (do_res_stat(creature_ptr, A_DEX))
431         ident = TRUE;
432     if (do_res_stat(creature_ptr, A_CON))
433         ident = TRUE;
434     if (do_res_stat(creature_ptr, A_CHR))
435         ident = TRUE;
436     return ident;
437 }
438
439 bool fishing(player_type *creature_ptr)
440 {
441     DIRECTION dir;
442     if (!get_direction(creature_ptr, &dir, FALSE, FALSE))
443         return FALSE;
444     POSITION y = creature_ptr->y + ddy[dir];
445     POSITION x = creature_ptr->x + ddx[dir];
446     creature_ptr->fishing_dir = dir;
447     if (!cave_has_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER)) {
448         msg_print(_("そこは水辺ではない。", "You can't fish here."));
449         return FALSE;
450     }
451
452     if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx) {
453         GAME_TEXT m_name[MAX_NLEN];
454         monster_desc(creature_ptr, m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
455         msg_format(_("%sが邪魔だ!", "%^s is standing in your way."), m_name);
456         free_turn(creature_ptr);
457         return FALSE;
458     }
459
460     set_action(creature_ptr, ACTION_FISH);
461     creature_ptr->redraw |= (PR_STATE);
462     return TRUE;
463 }
464
465 /*!
466  * @brief 装備を脱ぎ捨てて小宇宙を燃やす
467  * @param creature_ptr プレイヤー情報への参照ポインタ
468  * @param o_ptr_ptr 脱ぐ装備品への参照ポインタのポインタ
469  * @return 脱いだらTRUE、脱がなかったらFALSE
470  * @details
471  * 脱いで落とした装備にtimeoutを設定するために装備品のアドレスを返す。
472  */
473 bool cosmic_cast_off(player_type *creature_ptr, object_type **o_ptr_ptr)
474 {
475     object_type *o_ptr = (*o_ptr_ptr);
476
477     /* Cast off activated item */
478     INVENTORY_IDX slot;
479     for (slot = INVEN_MAIN_HAND; slot <= INVEN_FEET; slot++) {
480         if (o_ptr == &creature_ptr->inventory_list[slot])
481             break;
482     }
483
484     if (slot > INVEN_FEET)
485         return FALSE;
486
487     object_type forge;
488     object_copy(&forge, o_ptr);
489     inven_item_increase(creature_ptr, slot, (0 - o_ptr->number));
490     inven_item_optimize(creature_ptr, slot);
491
492     OBJECT_IDX old_o_idx = drop_near(creature_ptr, &forge, 0, creature_ptr->y, creature_ptr->x);
493     *o_ptr_ptr = &creature_ptr->current_floor_ptr->o_list[old_o_idx];
494
495     GAME_TEXT o_name[MAX_NLEN];
496     describe_flavor(creature_ptr, o_name, &forge, OD_NAME_ONLY);
497     msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
498
499     /* Get effects */
500     msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
501     int t = 20 + randint1(20);
502     (void)set_blind(creature_ptr, creature_ptr->blind + t);
503     (void)set_afraid(creature_ptr, 0);
504     (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
505     (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
506     (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
507     (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
508     (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
509     (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
510     if (creature_ptr->pclass == CLASS_FORCETRAINER) {
511         set_current_ki(creature_ptr, TRUE, creature_ptr->lev * 5 + 190);
512         msg_print(_("気が爆発寸前になった。", "Your force absorbs the explosion."));
513     }
514
515     return TRUE;
516 }
517
518 /*!
519  * @brief プレイヤーの因果混乱処理 / Apply Nexus
520  * @param m_ptr 因果混乱をプレイヤーに与えたモンスターの情報参照ポインタ
521  * @return なし
522  */
523 void apply_nexus(monster_type *m_ptr, player_type *target_ptr)
524 {
525     switch (randint1(7)) {
526     case 1:
527     case 2:
528     case 3: {
529         teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
530         break;
531     }
532
533     case 4:
534     case 5: {
535         teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
536         break;
537     }
538
539     case 6: {
540         if (randint0(100) < target_ptr->skill_sav) {
541             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
542             break;
543         }
544
545         teleport_level(target_ptr, 0);
546         break;
547     }
548
549     case 7: {
550         if (randint0(100) < target_ptr->skill_sav) {
551             msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
552             break;
553         }
554
555         msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
556         status_shuffle(target_ptr);
557         break;
558     }
559     }
560 }
561
562 /*!
563  * @brief プレイヤーのステータスシャッフル処理
564  * @param creature_ptr プレーヤーへの参照ポインタ
565  * @return なし
566  */
567 void status_shuffle(player_type *creature_ptr)
568 {
569     /* Pick a pair of stats */
570     int i = randint0(A_MAX);
571     int j;
572
573     //!< @todo ここのループは一体何をしている?
574     for (j = i; j == i; j = randint0(A_MAX)) /* loop */
575         ;
576
577     BASE_STATUS max1 = creature_ptr->stat_max[i];
578     BASE_STATUS cur1 = creature_ptr->stat_cur[i];
579     BASE_STATUS max2 = creature_ptr->stat_max[j];
580     BASE_STATUS cur2 = creature_ptr->stat_cur[j];
581
582     creature_ptr->stat_max[i] = max2;
583     creature_ptr->stat_cur[i] = cur2;
584     creature_ptr->stat_max[j] = max1;
585     creature_ptr->stat_cur[j] = cur1;
586
587     for (int k = 0; k < A_MAX; k++) {
588         if (creature_ptr->stat_max[k] > creature_ptr->stat_max_max[k])
589             creature_ptr->stat_max[k] = creature_ptr->stat_max_max[k];
590         if (creature_ptr->stat_cur[k] > creature_ptr->stat_max_max[k])
591             creature_ptr->stat_cur[k] = creature_ptr->stat_max_max[k];
592     }
593
594     creature_ptr->update |= PU_BONUS;
595 }