OSDN Git Service

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