OSDN Git Service

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