OSDN Git Service

[Refactor] #38997 *_monster() にplayer_type *引数を追加 / Added player_type * argument...
[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         creature_ptr->timewalk = TRUE;
215         msg_print(_("「時よ!」", "You yell 'Time!'"));
216 //      msg_print(_("「『ザ・ワールド』!時は止まった!」", "You yell 'The World! Time has stopped!'"));
217         msg_print(NULL);
218
219         creature_ptr->energy_need -= 1000 + (100 + creature_ptr->csp - 50)*TURNS_PER_TICK / 10;
220         creature_ptr->redraw |= (PR_MAP);
221         creature_ptr->update |= (PU_MONSTERS);
222         creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
223         handle_stuff();
224         return TRUE;
225 }
226
227
228 /*!
229  * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
230  * @param options スペル共通オプション
231  * @return なし
232  */
233 void roll_hitdice(player_type *creature_ptr, SPOP_FLAGS options)
234 {
235         PERCENTAGE percent;
236
237         /* Minimum hitpoints at highest level */
238         HIT_POINT min_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 3 / 8;
239
240         /* Maximum hitpoints at highest level */
241         HIT_POINT max_value = creature_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (creature_ptr->hitdie + 1)) * 5 / 8;
242
243         int i;
244
245         /* Rerate */
246         while (1)
247         {
248                 /* Pre-calculate level 1 hitdice */
249                 creature_ptr->player_hp[0] = (HIT_POINT)creature_ptr->hitdie;
250
251                 for (i = 1; i < 4; i++)
252                 {
253                         creature_ptr->player_hp[0] += randint1(creature_ptr->hitdie);
254                 }
255
256                 /* Roll the hitpoint values */
257                 for (i = 1; i < PY_MAX_LEVEL; i++)
258                 {
259                         creature_ptr->player_hp[i] = creature_ptr->player_hp[i - 1] + randint1(creature_ptr->hitdie);
260                 }
261
262                 /* Require "valid" hitpoints at highest level */
263                 if ((creature_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
264                         (creature_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
265         }
266
267         percent = (int)(((long)creature_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
268                 (2 * creature_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (creature_ptr->hitdie + 1))));
269
270         /* Update and redraw hitpoints */
271         creature_ptr->update |= (PU_HP);
272         creature_ptr->redraw |= (PR_HP);
273         creature_ptr->window |= (PW_PLAYER);
274
275         if (!(options & SPOP_NO_UPDATE)) handle_stuff();
276
277         if (options & SPOP_DISPLAY_MES)
278         {
279                 if (options & SPOP_DEBUG)
280                 {
281                         msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
282                         creature_ptr->knowledge |= KNOW_HPRATE;
283                 }
284                 else
285                 {
286                         msg_print(_("体力ランクが変わった。", "Life rate is changed."));
287                         creature_ptr->knowledge &= ~(KNOW_HPRATE);
288                 }
289         }
290 }
291
292
293 bool_hack life_stream(player_type *creature_ptr, bool_hack message, bool_hack virtue_change)
294 {
295         if (virtue_change)
296         {
297                 chg_virtue(creature_ptr, V_VITALITY, 1);
298                 chg_virtue(creature_ptr, V_UNLIFE, -5);
299         }
300         if (message)
301         {
302                 msg_print(_("体中に生命力が満ちあふれてきた!", "You feel life flow through your body!"));
303         }
304         restore_level(creature_ptr);
305         (void)set_poisoned(creature_ptr, 0);
306         (void)set_blind(creature_ptr, 0);
307         (void)set_confused(creature_ptr, 0);
308         (void)set_image(creature_ptr, 0);
309         (void)set_stun(creature_ptr, 0);
310         (void)set_cut(creature_ptr,0);
311         (void)restore_all_status(creature_ptr);
312         (void)set_shero(creature_ptr, 0, TRUE);
313         handle_stuff();
314         hp_player(creature_ptr, 5000);
315
316         return TRUE;
317 }
318
319
320 bool_hack heroism(player_type *creature_ptr, int base)
321 {
322         bool_hack ident = FALSE;
323         if (set_afraid(creature_ptr, 0)) ident = TRUE;
324         if (set_hero(creature_ptr, creature_ptr->hero + randint1(base) + base, FALSE)) ident = TRUE;
325         if (hp_player(creature_ptr, 10)) ident = TRUE;
326         return ident;
327 }
328
329
330 bool_hack berserk(player_type *creature_ptr, int base)
331 {
332         bool_hack ident = FALSE;
333         if (set_afraid(creature_ptr, 0)) ident = TRUE;
334         if (set_shero(creature_ptr, creature_ptr->shero + randint1(base) + base, FALSE)) ident = TRUE;
335         if (hp_player(creature_ptr, 30)) ident = TRUE;
336         return ident;
337 }
338
339
340 bool_hack cure_light_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
341 {
342         bool_hack ident = FALSE;
343         if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
344         if (set_blind(creature_ptr, 0)) ident = TRUE;
345         if (set_cut(creature_ptr,creature_ptr->cut - 10)) ident = TRUE;
346         if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
347         return ident;
348 }
349
350
351 bool_hack cure_serious_wounds(player_type *creature_ptr, DICE_NUMBER dice, DICE_SID sides)
352 {
353         bool_hack ident = FALSE;
354         if (hp_player(creature_ptr, damroll(dice, sides))) ident = TRUE;
355         if (set_blind(creature_ptr, 0)) ident = TRUE;
356         if (set_confused(creature_ptr, 0)) ident = TRUE;
357         if (set_cut(creature_ptr,(creature_ptr->cut / 2) - 50)) ident = TRUE;
358         if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
359         return ident;
360 }
361
362
363 bool_hack cure_critical_wounds(player_type *creature_ptr, HIT_POINT pow)
364 {
365         bool_hack ident = FALSE;
366         if (hp_player(creature_ptr, pow)) ident = TRUE;
367         if (set_blind(creature_ptr, 0)) ident = TRUE;
368         if (set_confused(creature_ptr, 0)) ident = TRUE;
369         if (set_poisoned(creature_ptr, 0)) ident = TRUE;
370         if (set_stun(creature_ptr, 0)) ident = TRUE;
371         if (set_cut(creature_ptr,0)) ident = TRUE;
372         if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE;
373         return ident;
374 }
375
376
377 bool_hack true_healing(player_type *creature_ptr, HIT_POINT pow)
378 {
379         bool_hack ident = FALSE;
380         if (hp_player(creature_ptr, pow)) ident = TRUE;
381         if (set_blind(creature_ptr, 0)) ident = TRUE;
382         if (set_confused(creature_ptr, 0)) ident = TRUE;
383         if (set_poisoned(creature_ptr, 0)) ident = TRUE;
384         if (set_stun(creature_ptr, 0)) ident = TRUE;
385         if (set_cut(creature_ptr,0)) ident = TRUE;
386         if (set_image(creature_ptr, 0)) ident = TRUE;
387         return ident;
388 }
389
390
391 bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater)
392 {
393         bool_hack ident = FALSE;
394
395         if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater)
396         {
397                 int i;
398                 for (i = 0; i < EATER_EXT * 2; i++)
399                 {
400                         creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3;
401                         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;
402                 }
403                 for (; i < EATER_EXT * 3; i++)
404                 {
405                         KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2);
406                         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;
407                         if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0;
408                 }
409                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
410                 creature_ptr->window |= (PW_PLAYER);
411                 ident = TRUE;
412         }
413         else if (creature_ptr->csp < creature_ptr->msp)
414         {
415                 creature_ptr->csp = creature_ptr->msp;
416                 creature_ptr->csp_frac = 0;
417                 msg_print(_("頭がハッキリとした。", "You feel your head clear."));
418                 creature_ptr->redraw |= (PR_MANA);
419                 creature_ptr->window |= (PW_PLAYER);
420                 creature_ptr->window |= (PW_SPELL);
421                 ident = TRUE;
422         }
423
424         return ident;
425 }
426
427
428 bool restore_all_status(player_type *creature_ptr)
429 {
430         bool ident = FALSE;
431         if (do_res_stat(creature_ptr, A_STR)) ident = TRUE;
432         if (do_res_stat(creature_ptr, A_INT)) ident = TRUE;
433         if (do_res_stat(creature_ptr, A_WIS)) ident = TRUE;
434         if (do_res_stat(creature_ptr, A_DEX)) ident = TRUE;
435         if (do_res_stat(creature_ptr, A_CON)) ident = TRUE;
436         if (do_res_stat(creature_ptr, A_CHR)) ident = TRUE;
437         return ident;
438 }
439
440
441 bool fishing(player_type *creature_ptr)
442 {
443         DIRECTION dir;
444         POSITION x, y;
445
446         if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
447         y = creature_ptr->y + ddy[dir];
448         x = creature_ptr->x + ddx[dir];
449         creature_ptr->fishing_dir = dir;
450         if (!cave_have_flag_bold(creature_ptr->current_floor_ptr, y, x, FF_WATER))
451         {
452                 msg_print(_("そこは水辺ではない。", "There is no fishing place."));
453                 return FALSE;
454         }
455         else if (creature_ptr->current_floor_ptr->grid_array[y][x].m_idx)
456         {
457                 GAME_TEXT m_name[MAX_NLEN];
458                 monster_desc(m_name, &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[y][x].m_idx], 0);
459                 msg_format(_("%sが邪魔だ!", "%^s is stand in your way."), m_name);
460                 free_turn(creature_ptr);
461                 return FALSE;
462         }
463         set_action(creature_ptr, ACTION_FISH);
464         creature_ptr->redraw |= (PR_STATE);
465         return TRUE;
466 }
467
468
469 bool cosmic_cast_off(player_type *creature_ptr, object_type *o_ptr)
470 {
471         INVENTORY_IDX inv;
472         int t;
473         OBJECT_IDX o_idx;
474         GAME_TEXT o_name[MAX_NLEN];
475         object_type forge;
476
477         /* Cast off activated item */
478         for (inv = INVEN_RARM; inv <= INVEN_FEET; inv++)
479         {
480                 if (o_ptr == &creature_ptr->inventory_list[inv]) break;
481         }
482         if (inv > INVEN_FEET) return FALSE;
483
484         object_copy(&forge, o_ptr);
485         inven_item_increase(inv, (0 - o_ptr->number));
486         inven_item_optimize(inv);
487         o_idx = drop_near(&forge, 0, creature_ptr->y, creature_ptr->x);
488         o_ptr = &creature_ptr->current_floor_ptr->o_list[o_idx];
489
490         object_desc(o_name, o_ptr, OD_NAME_ONLY);
491         msg_format(_("%sを脱ぎ捨てた。", "You cast off %s."), o_name);
492
493         /* Get effects */
494         msg_print(_("「燃え上がれ俺の小宇宙!」", "You say, 'Burn up my cosmo!"));
495         t = 20 + randint1(20);
496         (void)set_blind(creature_ptr, creature_ptr->blind + t);
497         (void)set_afraid(creature_ptr, 0);
498         (void)set_tim_esp(creature_ptr, creature_ptr->tim_esp + t, FALSE);
499         (void)set_tim_regen(creature_ptr, creature_ptr->tim_regen + t, FALSE);
500         (void)set_hero(creature_ptr, creature_ptr->hero + t, FALSE);
501         (void)set_blessed(creature_ptr, creature_ptr->blessed + t, FALSE);
502         (void)set_fast(creature_ptr, creature_ptr->fast + t, FALSE);
503         (void)set_shero(creature_ptr, creature_ptr->shero + t, FALSE);
504         if (creature_ptr->pclass == CLASS_FORCETRAINER)
505         {
506                 P_PTR_KI = creature_ptr->lev * 5 + 190;
507                 msg_print(_("気が爆発寸前になった。", "Your force are immediatly before explosion."));
508         }
509
510         return TRUE;
511 }
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         {
523         case 1: case 2: case 3:
524         {
525                 teleport_player(target_ptr, 200, TELEPORT_PASSIVE);
526                 break;
527         }
528
529         case 4: case 5:
530         {
531                 teleport_player_to(target_ptr, m_ptr->fy, m_ptr->fx, TELEPORT_PASSIVE);
532                 break;
533         }
534
535         case 6:
536         {
537                 if (randint0(100) < target_ptr->skill_sav)
538                 {
539                         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
540                         break;
541                 }
542                 teleport_level(target_ptr, 0);
543                 break;
544         }
545
546         case 7:
547         {
548                 if (randint0(100) < target_ptr->skill_sav)
549                 {
550                         msg_print(_("しかし効力を跳ね返した!", "You resist the effects!"));
551                         break;
552                 }
553
554                 msg_print(_("体がねじれ始めた...", "Your body starts to scramble..."));
555                 status_shuffle(target_ptr);
556                 break;
557         }
558         }
559 }
560
561 /*!
562  * @brief プレイヤーのステータスシャッフル処理
563  * @return なし
564  */
565 void status_shuffle(player_type *creature_ptr)
566 {
567         BASE_STATUS max1, cur1, max2, cur2;
568         int ii, jj, i;
569
570         /* Pick a pair of stats */
571         ii = randint0(A_MAX);
572         for (jj = ii; jj == ii; jj = randint0(A_MAX)) /* loop */;
573
574         max1 = creature_ptr->stat_max[ii];
575         cur1 = creature_ptr->stat_cur[ii];
576         max2 = creature_ptr->stat_max[jj];
577         cur2 = creature_ptr->stat_cur[jj];
578
579         creature_ptr->stat_max[ii] = max2;
580         creature_ptr->stat_cur[ii] = cur2;
581         creature_ptr->stat_max[jj] = max1;
582         creature_ptr->stat_cur[jj] = cur1;
583
584         for (i = 0; i < A_MAX; i++)
585         {
586                 if (creature_ptr->stat_max[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_max[i] = creature_ptr->stat_max_max[i];
587                 if (creature_ptr->stat_cur[i] > creature_ptr->stat_max_max[i]) creature_ptr->stat_cur[i] = creature_ptr->stat_max_max[i];
588         }
589
590         creature_ptr->update |= (PU_BONUS);
591 }