OSDN Git Service

モンスターの状態変化処理を標準ターンで行う際に, 処理の必要のある状態
[hengband/hengband.git] / src / effects.c
1 /* File: effects.c */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  */
10
11 /* Purpose: effects of various "objects" */
12
13 #include "angband.h"
14
15 void set_action(int typ)
16 {
17         int prev_typ = p_ptr->action;
18
19         if (typ == prev_typ)
20         {
21                 return;
22         }
23         else
24         {
25                 switch (prev_typ)
26                 {
27                         case ACTION_SEARCH:
28                         {
29 #ifdef JP
30                                 msg_print("õº÷¤ò¤ä¤á¤¿¡£");
31 #else
32                                 msg_print("You no longer walk carefully.");
33 #endif
34                                 p_ptr->redraw |= (PR_SPEED);
35                                 break;
36                         }
37                         case ACTION_REST:
38                         {
39                                 resting = 0;
40                                 break;
41                         }
42                         case ACTION_LEARN:
43                         {
44 #ifdef JP
45                                 msg_print("³Ø½¬¤ò¤ä¤á¤¿¡£");
46 #else
47                                 msg_print("You stop Learning");
48 #endif
49                                 new_mane = FALSE;
50                                 break;
51                         }
52                         case ACTION_KAMAE:
53                         {
54 #ifdef JP
55                                 msg_print("¹½¤¨¤ò¤È¤¤¤¿¡£");
56 #else
57                                 msg_print("You stop assuming the posture.");
58 #endif
59                                 p_ptr->special_defense &= ~(KAMAE_MASK);
60                                 break;
61                         }
62                         case ACTION_KATA:
63                         {
64 #ifdef JP
65                                 msg_print("·¿¤òÊø¤·¤¿¡£");
66 #else
67                                 msg_print("You stop assuming the posture.");
68 #endif
69                                 p_ptr->special_defense &= ~(KATA_MASK);
70                                 p_ptr->update |= (PU_MONSTERS);
71                                 p_ptr->redraw |= (PR_STATUS);
72                                 break;
73                         }
74                         case ACTION_SING:
75                         {
76 #ifdef JP
77                                 msg_print("²Î¤¦¤Î¤ò¤ä¤á¤¿¡£");
78 #else
79                                 msg_print("You stop singing.");
80 #endif
81                                 break;
82                         }
83                         case ACTION_HAYAGAKE:
84                         {
85 #ifdef JP
86                                 msg_print("­¤¬½Å¤¯¤Ê¤Ã¤¿¡£");
87 #else
88                                 msg_print("You are no longer walking extremely fast.");
89 #endif
90                                 break;
91                         }
92                 }
93         }
94
95         p_ptr->action = typ;
96
97         /* If we are requested other action, stop singing */
98         if (prev_typ == ACTION_SING) stop_singing();
99
100         switch (p_ptr->action)
101         {
102                 case ACTION_SEARCH:
103                 {
104 #ifdef JP
105                         msg_print("Ãí°Õ¿¼¤¯Ê⤭»Ï¤á¤¿¡£");
106 #else
107                         msg_print("You begin to walk carefully.");
108 #endif
109                         p_ptr->redraw |= (PR_SPEED);
110                         break;
111                 }
112                 case ACTION_LEARN:
113                 {
114 #ifdef JP
115                         msg_print("³Ø½¬¤ò»Ï¤á¤¿¡£");
116 #else
117                         msg_print("You begin Learning");
118 #endif
119                         break;
120                 }
121                 case ACTION_FISH:
122                 {
123 #ifdef JP
124                         msg_print("¿åÌ̤˻å¤ò¿â¤é¤·¤¿¡¥¡¥¡¥");
125 #else
126                         msg_print("You begin fishing...");
127 #endif
128                         break;
129                 }
130                 case ACTION_HAYAGAKE:
131                 {
132 #ifdef JP
133                         msg_print("­¤¬±©¤Î¤è¤¦¤Ë·Ú¤¯¤Ê¤Ã¤¿¡£");
134 #else
135                         msg_print("You begin to walk extremely fast.");
136 #endif
137                         break;
138                 }
139                 default:
140                 {
141                         break;
142                 }
143         }
144
145         /* Recalculate bonuses */
146         p_ptr->update |= (PU_BONUS);
147
148         /* Redraw the state */
149         p_ptr->redraw |= (PR_STATE);
150 }
151
152 /* reset timed flags */
153 void reset_tim_flags(void)
154 {
155         p_ptr->fast = 0;            /* Timed -- Fast */
156         p_ptr->lightspeed = 0;
157         p_ptr->slow = 0;            /* Timed -- Slow */
158         p_ptr->blind = 0;           /* Timed -- Blindness */
159         p_ptr->paralyzed = 0;       /* Timed -- Paralysis */
160         p_ptr->confused = 0;        /* Timed -- Confusion */
161         p_ptr->afraid = 0;          /* Timed -- Fear */
162         p_ptr->image = 0;           /* Timed -- Hallucination */
163         p_ptr->poisoned = 0;        /* Timed -- Poisoned */
164         p_ptr->cut = 0;             /* Timed -- Cut */
165         p_ptr->stun = 0;            /* Timed -- Stun */
166
167         p_ptr->protevil = 0;        /* Timed -- Protection */
168         p_ptr->invuln = 0;          /* Timed -- Invulnerable */
169         p_ptr->ult_res = 0;
170         p_ptr->hero = 0;            /* Timed -- Heroism */
171         p_ptr->shero = 0;           /* Timed -- Super Heroism */
172         p_ptr->shield = 0;          /* Timed -- Shield Spell */
173         p_ptr->blessed = 0;         /* Timed -- Blessed */
174         p_ptr->tim_invis = 0;       /* Timed -- Invisibility */
175         p_ptr->tim_infra = 0;       /* Timed -- Infra Vision */
176         p_ptr->tim_regen = 0;       /* Timed -- Regeneration */
177         p_ptr->tim_stealth = 0;     /* Timed -- Stealth */
178         p_ptr->tim_esp = 0;
179         p_ptr->wraith_form = 0;     /* Timed -- Wraith Form */
180         p_ptr->tim_levitation = 0;
181         p_ptr->tim_sh_touki = 0;
182         p_ptr->tim_sh_fire = 0;
183         p_ptr->tim_sh_holy = 0;
184         p_ptr->tim_eyeeye = 0;
185         p_ptr->resist_magic = 0;
186         p_ptr->tsuyoshi = 0;
187         p_ptr->kabenuke = 0;
188         p_ptr->tim_res_nether = 0;
189         p_ptr->tim_res_time = 0;
190         p_ptr->tim_mimic = 0;
191         p_ptr->mimic_form = 0;
192         p_ptr->tim_reflect = 0;
193         p_ptr->multishadow = 0;
194         p_ptr->dustrobe = 0;
195         p_ptr->action = ACTION_NONE;
196
197
198         p_ptr->oppose_acid = 0;     /* Timed -- oppose acid */
199         p_ptr->oppose_elec = 0;     /* Timed -- oppose lightning */
200         p_ptr->oppose_fire = 0;     /* Timed -- oppose heat */
201         p_ptr->oppose_cold = 0;     /* Timed -- oppose cold */
202         p_ptr->oppose_pois = 0;     /* Timed -- oppose poison */
203
204         p_ptr->word_recall = 0;
205         p_ptr->alter_reality = 0;
206         p_ptr->sutemi = FALSE;
207         p_ptr->counter = FALSE;
208         p_ptr->ele_attack = 0;
209         p_ptr->ele_immune = 0;
210         p_ptr->special_attack = 0L;
211         p_ptr->special_defense = 0L;
212
213         while(p_ptr->energy_need < 0) p_ptr->energy_need += ENERGY_NEED();
214         world_player = FALSE;
215
216         if (prace_is_(RACE_DEMON) && (p_ptr->lev > 44)) p_ptr->oppose_fire = 1;
217         if ((p_ptr->pclass == CLASS_NINJA) && (p_ptr->lev > 44)) p_ptr->oppose_pois = 1;
218         if (p_ptr->pclass == CLASS_BERSERKER) p_ptr->shero = 1;
219
220         if (p_ptr->riding)
221         {
222                 monster_type *m_ptr = &m_list[p_ptr->riding];
223                 bool need_mproc_remove = FALSE;
224
225                 if (m_ptr->fast)
226                 {
227                         m_ptr->fast = 0;
228                         need_mproc_remove = TRUE;
229                 }
230                 if (m_ptr->slow)
231                 {
232                         m_ptr->slow = 0;
233                         need_mproc_remove = TRUE;
234                 }
235                 if (m_ptr->invulner)
236                 {
237                         m_ptr->invulner = 0;
238                         need_mproc_remove = TRUE;
239                 }
240
241                 if (need_mproc_remove && !need_mproc(m_ptr)) mproc_remove(m_ptr->mproc_idx);
242         }
243
244         if (p_ptr->pclass == CLASS_BARD)
245         {
246                 p_ptr->magic_num1[0] = 0;
247                 p_ptr->magic_num2[0] = 0;
248         }
249 }
250
251
252 /*
253  * Set "p_ptr->tim_mimic", and "p_ptr->mimic_form",
254  * notice observable changes
255  */
256 bool set_mimic(int v, int p, bool do_dec)
257 {
258         bool notice = FALSE;
259
260         /* Hack -- Force good values */
261         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
262
263         if (p_ptr->is_dead) return FALSE;
264
265         /* Open */
266         if (v)
267         {
268                 if (p_ptr->tim_mimic && (p_ptr->mimic_form == p) && !do_dec)
269                 {
270                         if (p_ptr->tim_mimic > v) return FALSE;
271                 }
272                 else if ((!p_ptr->tim_mimic) || (p_ptr->mimic_form != p))
273                 {
274 #ifdef JP
275                         msg_print("¼«Ê¬¤ÎÂΤ¬ÊѤï¤Ã¤Æ¤æ¤¯¤Î¤ò´¶¤¸¤¿¡£");
276 #else
277                         msg_print("You feel that your body changes.");
278 #endif
279                         p_ptr->mimic_form=p;
280                         notice = TRUE;
281                 }
282         }
283
284         /* Shut */
285         else
286         {
287                 if (p_ptr->tim_mimic)
288                 {
289 #ifdef JP
290                         msg_print("ÊѿȤ¬²ò¤±¤¿¡£");
291 #else
292                         msg_print("You are no longer transformed.");
293 #endif
294                         if (p_ptr->mimic_form == MIMIC_DEMON) set_oppose_fire(0, TRUE);
295                         p_ptr->mimic_form=0;
296                         notice = TRUE;
297                         p = 0;
298                 }
299         }
300
301         /* Use the value */
302         p_ptr->tim_mimic = v;
303
304         /* Nothing to notice */
305         if (!notice)
306                 return (FALSE);
307
308         /* Disturb */
309         if (disturb_state)
310                 disturb(0, 0);
311
312         /* Redraw title */
313         p_ptr->redraw |= (PR_BASIC | PR_STATUS);
314
315         /* Recalculate bonuses */
316         p_ptr->update |= (PU_BONUS | PU_HP);
317
318         handle_stuff();
319
320         /* Result */
321         return (TRUE);
322 }
323
324 /*
325  * Set "p_ptr->blind", notice observable changes
326  *
327  * Note the use of "PU_UN_LITE" and "PU_UN_VIEW", which is needed to
328  * memorize any terrain features which suddenly become "visible".
329  * Note that blindness is currently the only thing which can affect
330  * "player_can_see_bold()".
331  */
332 bool set_blind(int v)
333 {
334         bool notice = FALSE;
335
336         /* Hack -- Force good values */
337         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
338
339         if (p_ptr->is_dead) return FALSE;
340
341         /* Open */
342         if (v)
343         {
344                 if (!p_ptr->blind)
345                 {
346                         if (p_ptr->prace == RACE_ANDROID)
347                         {
348 #ifdef JP
349 msg_print("¥»¥ó¥µ¡¼¤ò¤ä¤é¤ì¤¿¡ª");
350 #else
351                                 msg_print("You are blind!");
352 #endif
353                         }
354                         else
355                         {
356 #ifdef JP
357 msg_print("Ìܤ¬¸«¤¨¤Ê¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
358 #else
359                                 msg_print("You are blind!");
360 #endif
361                         }
362
363                         notice = TRUE;
364                         chg_virtue(V_ENLIGHTEN, -1);
365                 }
366         }
367
368         /* Shut */
369         else
370         {
371                 if (p_ptr->blind)
372                 {
373                         if (p_ptr->prace == RACE_ANDROID)
374                         {
375 #ifdef JP
376 msg_print("¥»¥ó¥µ¡¼¤¬Éüµì¤·¤¿¡£");
377 #else
378                                 msg_print("You can see again.");
379 #endif
380                         }
381                         else
382                         {
383 #ifdef JP
384 msg_print("¤ä¤Ã¤ÈÌܤ¬¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
385 #else
386                                 msg_print("You can see again.");
387 #endif
388                         }
389
390                         notice = TRUE;
391                 }
392         }
393
394         /* Use the value */
395         p_ptr->blind = v;
396
397         /* Redraw status bar */
398         p_ptr->redraw |= (PR_STATUS);
399
400         /* Nothing to notice */
401         if (!notice) return (FALSE);
402
403         /* Disturb */
404         if (disturb_state) disturb(0, 0);
405
406         /* Fully update the visuals */
407         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE | PU_VIEW | PU_LITE | PU_MONSTERS | PU_MON_LITE);
408
409         /* Redraw map */
410         p_ptr->redraw |= (PR_MAP);
411
412         /* Window stuff */
413         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
414
415         /* Handle stuff */
416         handle_stuff();
417
418         /* Result */
419         return (TRUE);
420 }
421
422
423 /*
424  * Set "p_ptr->confused", notice observable changes
425  */
426 bool set_confused(int v)
427 {
428         bool notice = FALSE;
429
430         /* Hack -- Force good values */
431         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
432
433         if (p_ptr->is_dead) return FALSE;
434
435         /* Open */
436         if (v)
437         {
438                 if (!p_ptr->confused)
439                 {
440 #ifdef JP
441 msg_print("¤¢¤Ê¤¿¤Ïº®Í𤷤¿¡ª");
442 #else
443                         msg_print("You are confused!");
444 #endif
445
446                         if (p_ptr->action == ACTION_LEARN)
447                         {
448 #ifdef JP
449                                 msg_print("³Ø½¬¤¬Â³¤±¤é¤ì¤Ê¤¤¡ª");
450 #else
451                                 msg_print("You cannot continue Learning!");
452 #endif
453                                 new_mane = FALSE;
454
455                                 p_ptr->redraw |= (PR_STATE);
456                                 p_ptr->action = ACTION_NONE;
457                         }
458                         if (p_ptr->action == ACTION_KAMAE)
459                         {
460 #ifdef JP
461                                 msg_print("¹½¤¨¤¬¤È¤±¤¿¡£");
462 #else
463                                 msg_print("Your posture gets loose.");
464 #endif
465                                 p_ptr->special_defense &= ~(KAMAE_MASK);
466                                 p_ptr->update |= (PU_BONUS);
467                                 p_ptr->redraw |= (PR_STATE);
468                                 p_ptr->action = ACTION_NONE;
469                         }
470                         else if (p_ptr->action == ACTION_KATA)
471                         {
472 #ifdef JP
473                                 msg_print("·¿¤¬Êø¤ì¤¿¡£");
474 #else
475                                 msg_print("Your posture gets loose.");
476 #endif
477                                 p_ptr->special_defense &= ~(KATA_MASK);
478                                 p_ptr->update |= (PU_BONUS);
479                                 p_ptr->update |= (PU_MONSTERS);
480                                 p_ptr->redraw |= (PR_STATE);
481                                 p_ptr->redraw |= (PR_STATUS);
482                                 p_ptr->action = ACTION_NONE;
483                         }
484
485                         notice = TRUE;
486                         p_ptr->counter = FALSE;
487                         chg_virtue(V_HARMONY, -1);
488                 }
489         }
490
491         /* Shut */
492         else
493         {
494                 if (p_ptr->confused)
495                 {
496 #ifdef JP
497 msg_print("¤ä¤Ã¤Èº®Í𤬤ª¤µ¤Þ¤Ã¤¿¡£");
498 #else
499                         msg_print("You feel less confused now.");
500 #endif
501
502                         p_ptr->special_attack &= ~(ATTACK_SUIKEN);
503                         notice = TRUE;
504                 }
505         }
506
507         /* Use the value */
508         p_ptr->confused = v;
509
510         /* Redraw status bar */
511         p_ptr->redraw |= (PR_STATUS);
512
513         /* Nothing to notice */
514         if (!notice) return (FALSE);
515
516         /* Disturb */
517         if (disturb_state) disturb(0, 0);
518
519         /* Handle stuff */
520         handle_stuff();
521
522         /* Result */
523         return (TRUE);
524 }
525
526
527 /*
528  * Set "p_ptr->poisoned", notice observable changes
529  */
530 bool set_poisoned(int v)
531 {
532         bool notice = FALSE;
533
534         /* Hack -- Force good values */
535         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
536
537         if (p_ptr->is_dead) return FALSE;
538
539         /* Open */
540         if (v)
541         {
542                 if (!p_ptr->poisoned)
543                 {
544 #ifdef JP
545 msg_print("ÆǤ˿¯¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡ª");
546 #else
547                         msg_print("You are poisoned!");
548 #endif
549
550                         notice = TRUE;
551                 }
552         }
553
554         /* Shut */
555         else
556         {
557                 if (p_ptr->poisoned)
558                 {
559 #ifdef JP
560 msg_print("¤ä¤Ã¤ÈÆǤÎÄˤߤ¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
561 #else
562                         msg_print("You are no longer poisoned.");
563 #endif
564
565                         notice = TRUE;
566                 }
567         }
568
569         /* Use the value */
570         p_ptr->poisoned = v;
571
572         /* Redraw status bar */
573         p_ptr->redraw |= (PR_STATUS);
574
575         /* Nothing to notice */
576         if (!notice) return (FALSE);
577
578         /* Disturb */
579         if (disturb_state) disturb(0, 0);
580
581         /* Handle stuff */
582         handle_stuff();
583
584         /* Result */
585         return (TRUE);
586 }
587
588
589 /*
590  * Set "p_ptr->afraid", notice observable changes
591  */
592 bool set_afraid(int v)
593 {
594         bool notice = FALSE;
595
596         /* Hack -- Force good values */
597         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
598
599         if (p_ptr->is_dead) return FALSE;
600
601         /* Open */
602         if (v)
603         {
604                 if (!p_ptr->afraid)
605                 {
606 #ifdef JP
607 msg_print("²¿¤â¤«¤â¶²¤¯¤Ê¤Ã¤Æ¤­¤¿¡ª");
608 #else
609                         msg_print("You are terrified!");
610 #endif
611
612                         if (p_ptr->special_defense & KATA_MASK)
613                         {
614 #ifdef JP
615                                 msg_print("·¿¤¬Êø¤ì¤¿¡£");
616 #else
617                                 msg_print("Your posture gets loose.");
618 #endif
619                                 p_ptr->special_defense &= ~(KATA_MASK);
620                                 p_ptr->update |= (PU_BONUS);
621                                 p_ptr->update |= (PU_MONSTERS);
622                                 p_ptr->redraw |= (PR_STATE);
623                                 p_ptr->redraw |= (PR_STATUS);
624                                 p_ptr->action = ACTION_NONE;
625                         }
626
627                         notice = TRUE;
628                         p_ptr->counter = FALSE;
629                         chg_virtue(V_VALOUR, -1);
630                 }
631         }
632
633         /* Shut */
634         else
635         {
636                 if (p_ptr->afraid)
637                 {
638 #ifdef JP
639 msg_print("¤ä¤Ã¤È¶²Éݤò¿¶¤êʧ¤Ã¤¿¡£");
640 #else
641                         msg_print("You feel bolder now.");
642 #endif
643
644                         notice = TRUE;
645                 }
646         }
647
648         /* Use the value */
649         p_ptr->afraid = v;
650
651         /* Redraw status bar */
652         p_ptr->redraw |= (PR_STATUS);
653
654         /* Nothing to notice */
655         if (!notice) return (FALSE);
656
657         /* Disturb */
658         if (disturb_state) disturb(0, 0);
659
660         /* Handle stuff */
661         handle_stuff();
662
663         /* Result */
664         return (TRUE);
665 }
666
667
668 /*
669  * Set "p_ptr->paralyzed", notice observable changes
670  */
671 bool set_paralyzed(int v)
672 {
673         bool notice = FALSE;
674
675         /* Hack -- Force good values */
676         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
677
678         if (p_ptr->is_dead) return FALSE;
679
680         /* Open */
681         if (v)
682         {
683                 if (!p_ptr->paralyzed)
684                 {
685 #ifdef JP
686 msg_print("ÂΤ¬Ëãá㤷¤Æ¤·¤Þ¤Ã¤¿¡ª");
687 #else
688                         msg_print("You are paralyzed!");
689 #endif
690
691                         p_ptr->counter = FALSE;
692                         notice = TRUE;
693                 }
694         }
695
696         /* Shut */
697         else
698         {
699                 if (p_ptr->paralyzed)
700                 {
701 #ifdef JP
702 msg_print("¤ä¤Ã¤ÈÆ°¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
703 #else
704                         msg_print("You can move again.");
705 #endif
706
707                         notice = TRUE;
708                 }
709         }
710
711         /* Use the value */
712         p_ptr->paralyzed = v;
713
714         /* Redraw status bar */
715         p_ptr->redraw |= (PR_STATUS);
716
717         /* Nothing to notice */
718         if (!notice) return (FALSE);
719
720         /* Disturb */
721         if (disturb_state) disturb(0, 0);
722
723         /* Redraw the state */
724         p_ptr->redraw |= (PR_STATE);
725
726         /* Handle stuff */
727         handle_stuff();
728
729         /* Result */
730         return (TRUE);
731 }
732
733
734 /*
735  * Set "p_ptr->image", notice observable changes
736  *
737  * Note that we must redraw the map when hallucination changes.
738  */
739 bool set_image(int v)
740 {
741         bool notice = FALSE;
742
743         /* Hack -- Force good values */
744         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
745
746         if (p_ptr->is_dead) return FALSE;
747
748
749         /* Open */
750         if (v)
751         {
752                 set_tsuyoshi(0, TRUE);
753                 if (!p_ptr->image)
754                 {
755 #ifdef JP
756 msg_print("¥ï¡¼¥ª¡ª²¿¤â¤«¤âÆú¿§¤Ë¸«¤¨¤ë¡ª");
757 #else
758                         msg_print("Oh, wow! Everything looks so cosmic now!");
759 #endif
760
761                         p_ptr->counter = FALSE;
762                         notice = TRUE;
763                 }
764         }
765
766         /* Shut */
767         else
768         {
769                 if (p_ptr->image)
770                 {
771 #ifdef JP
772 msg_print("¤ä¤Ã¤È¤Ï¤Ã¤­¤ê¤Èʪ¤¬¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
773 #else
774                         msg_print("You can see clearly again.");
775 #endif
776
777                         notice = TRUE;
778                 }
779         }
780
781         /* Use the value */
782         p_ptr->image = v;
783
784         /* Redraw status bar */
785         p_ptr->redraw |= (PR_STATUS);
786
787         /* Nothing to notice */
788         if (!notice) return (FALSE);
789
790         /* Disturb */
791         if (disturb_state) disturb(0, 0);
792
793         /* Redraw map */
794         p_ptr->redraw |= (PR_MAP);
795
796         /* Update monsters */
797         p_ptr->update |= (PU_MONSTERS);
798
799         /* Window stuff */
800         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
801
802         /* Handle stuff */
803         handle_stuff();
804
805         /* Result */
806         return (TRUE);
807 }
808
809
810 /*
811  * Set "p_ptr->fast", notice observable changes
812  */
813 bool set_fast(int v, bool do_dec)
814 {
815         bool notice = FALSE;
816
817         /* Hack -- Force good values */
818         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
819
820         if (p_ptr->is_dead) return FALSE;
821
822         /* Open */
823         if (v)
824         {
825                 if (p_ptr->fast && !do_dec)
826                 {
827                         if (p_ptr->fast > v) return FALSE;
828                 }
829                 else if (!IS_FAST() && !p_ptr->lightspeed)
830                 {
831 #ifdef JP
832 msg_print("ÁÇÁ᤯ư¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
833 #else
834                         msg_print("You feel yourself moving much faster!");
835 #endif
836
837                         notice = TRUE;
838                         chg_virtue(V_PATIENCE, -1);
839                         chg_virtue(V_DILIGENCE, 1);
840                 }
841         }
842
843         /* Shut */
844         else
845         {
846                 if (p_ptr->fast && !p_ptr->lightspeed && !music_singing(MUSIC_SPEED) && !music_singing(MUSIC_SHERO))
847                 {
848 #ifdef JP
849 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
850 #else
851                         msg_print("You feel yourself slow down.");
852 #endif
853
854                         notice = TRUE;
855                 }
856         }
857
858         /* Use the value */
859         p_ptr->fast = v;
860
861         /* Nothing to notice */
862         if (!notice) return (FALSE);
863
864         /* Disturb */
865         if (disturb_state) disturb(0, 0);
866
867         /* Recalculate bonuses */
868         p_ptr->update |= (PU_BONUS);
869
870         /* Handle stuff */
871         handle_stuff();
872
873         /* Result */
874         return (TRUE);
875 }
876
877
878 /*
879  * Set "p_ptr->lightspeed", notice observable changes
880  */
881 bool set_lightspeed(int v, bool do_dec)
882 {
883         bool notice = FALSE;
884
885         /* Hack -- Force good values */
886         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
887
888         if (p_ptr->is_dead) return FALSE;
889
890         /* Open */
891         if (v)
892         {
893                 if (p_ptr->lightspeed && !do_dec)
894                 {
895                         if (p_ptr->lightspeed > v) return FALSE;
896                 }
897                 else if (!p_ptr->lightspeed)
898                 {
899 #ifdef JP
900 msg_print("Èó¾ï¤ËÁÇÁ᤯ư¤±¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª");
901 #else
902                         msg_print("You feel yourself moving extremely faster!");
903 #endif
904
905                         notice = TRUE;
906                         chg_virtue(V_PATIENCE, -1);
907                         chg_virtue(V_DILIGENCE, 1);
908                 }
909         }
910
911         /* Shut */
912         else
913         {
914                 if (p_ptr->lightspeed)
915                 {
916 #ifdef JP
917 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
918 #else
919                         msg_print("You feel yourself slow down.");
920 #endif
921
922                         notice = TRUE;
923                 }
924         }
925
926         /* Use the value */
927         p_ptr->lightspeed = v;
928
929         /* Nothing to notice */
930         if (!notice) return (FALSE);
931
932         /* Disturb */
933         if (disturb_state) disturb(0, 0);
934
935         /* Recalculate bonuses */
936         p_ptr->update |= (PU_BONUS);
937
938         /* Handle stuff */
939         handle_stuff();
940
941         /* Result */
942         return (TRUE);
943 }
944
945
946 /*
947  * Set "p_ptr->slow", notice observable changes
948  */
949 bool set_slow(int v, bool do_dec)
950 {
951         bool notice = FALSE;
952
953         /* Hack -- Force good values */
954         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
955
956         if (p_ptr->is_dead) return FALSE;
957
958         /* Open */
959         if (v)
960         {
961                 if (p_ptr->slow && !do_dec)
962                 {
963                         if (p_ptr->slow > v) return FALSE;
964                 }
965                 else if (!p_ptr->slow)
966                 {
967 #ifdef JP
968 msg_print("ÂΤÎÆ°¤­¤¬ÃÙ¤¯¤Ê¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
969 #else
970                         msg_print("You feel yourself moving slower!");
971 #endif
972
973                         notice = TRUE;
974                 }
975         }
976
977         /* Shut */
978         else
979         {
980                 if (p_ptr->slow)
981                 {
982 #ifdef JP
983 msg_print("Æ°¤­¤ÎÃÙ¤µ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
984 #else
985                         msg_print("You feel yourself speed up.");
986 #endif
987
988                         notice = TRUE;
989                 }
990         }
991
992         /* Use the value */
993         p_ptr->slow = v;
994
995         /* Nothing to notice */
996         if (!notice) return (FALSE);
997
998         /* Disturb */
999         if (disturb_state) disturb(0, 0);
1000
1001         /* Recalculate bonuses */
1002         p_ptr->update |= (PU_BONUS);
1003
1004         /* Handle stuff */
1005         handle_stuff();
1006
1007         /* Result */
1008         return (TRUE);
1009 }
1010
1011
1012 /*
1013  * Set "p_ptr->shield", notice observable changes
1014  */
1015 bool set_shield(int v, bool do_dec)
1016 {
1017         bool notice = FALSE;
1018
1019         /* Hack -- Force good values */
1020         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1021
1022         if (p_ptr->is_dead) return FALSE;
1023
1024         /* Open */
1025         if (v)
1026         {
1027                 if (p_ptr->shield && !do_dec)
1028                 {
1029                         if (p_ptr->shield > v) return FALSE;
1030                 }
1031                 else if (!p_ptr->shield)
1032                 {
1033 #ifdef JP
1034 msg_print("È©¤¬ÀФˤʤä¿¡£");
1035 #else
1036                         msg_print("Your skin turns to stone.");
1037 #endif
1038
1039                         notice = TRUE;
1040                 }
1041         }
1042
1043         /* Shut */
1044         else
1045         {
1046                 if (p_ptr->shield)
1047                 {
1048 #ifdef JP
1049 msg_print("È©¤¬¸µ¤ËÌá¤Ã¤¿¡£");
1050 #else
1051                         msg_print("Your skin returns to normal.");
1052 #endif
1053
1054                         notice = TRUE;
1055                 }
1056         }
1057
1058         /* Use the value */
1059         p_ptr->shield = v;
1060
1061         /* Redraw status bar */
1062         p_ptr->redraw |= (PR_STATUS);
1063
1064         /* Nothing to notice */
1065         if (!notice) return (FALSE);
1066
1067         /* Disturb */
1068         if (disturb_state) disturb(0, 0);
1069
1070         /* Recalculate bonuses */
1071         p_ptr->update |= (PU_BONUS);
1072
1073         /* Handle stuff */
1074         handle_stuff();
1075
1076         /* Result */
1077         return (TRUE);
1078 }
1079
1080
1081
1082 /*
1083  * Set "p_ptr->tsubureru", notice observable changes
1084  */
1085 bool set_tsubureru(int v, bool do_dec)
1086 {
1087         bool notice = FALSE;
1088
1089         /* Hack -- Force good values */
1090         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1091
1092         if (p_ptr->is_dead) return FALSE;
1093
1094         /* Open */
1095         if (v)
1096         {
1097                 if (p_ptr->tsubureru && !do_dec)
1098                 {
1099                         if (p_ptr->tsubureru > v) return FALSE;
1100                 }
1101                 else if (!p_ptr->tsubureru)
1102                 {
1103 #ifdef JP
1104 msg_print("²£¤Ë¿­¤Ó¤¿¡£");
1105 #else
1106                         msg_print("Your body expands horizontally.");
1107 #endif
1108
1109                         notice = TRUE;
1110                 }
1111         }
1112
1113         /* Shut */
1114         else
1115         {
1116                 if (p_ptr->tsubureru)
1117                 {
1118 #ifdef JP
1119 msg_print("¤â¤¦²£¤Ë¿­¤Ó¤Æ¤¤¤Ê¤¤¡£");
1120 #else
1121                         msg_print("Your body returns to normal.");
1122 #endif
1123
1124                         notice = TRUE;
1125                 }
1126         }
1127
1128         /* Use the value */
1129         p_ptr->tsubureru = v;
1130
1131         /* Redraw status bar */
1132         p_ptr->redraw |= (PR_STATUS);
1133
1134         /* Nothing to notice */
1135         if (!notice) return (FALSE);
1136
1137         /* Disturb */
1138         if (disturb_state) disturb(0, 0);
1139
1140         /* Recalculate bonuses */
1141         p_ptr->update |= (PU_BONUS);
1142
1143         /* Handle stuff */
1144         handle_stuff();
1145
1146         /* Result */
1147         return (TRUE);
1148 }
1149
1150
1151
1152 /*
1153  * Set "p_ptr->magicdef", notice observable changes
1154  */
1155 bool set_magicdef(int v, bool do_dec)
1156 {
1157         bool notice = FALSE;
1158
1159         /* Hack -- Force good values */
1160         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1161
1162         if (p_ptr->is_dead) return FALSE;
1163
1164         /* Open */
1165         if (v)
1166         {
1167                 if (p_ptr->magicdef && !do_dec)
1168                 {
1169                         if (p_ptr->magicdef > v) return FALSE;
1170                 }
1171                 else if (!p_ptr->magicdef)
1172                 {
1173 #ifdef JP
1174                         msg_print("ËâË¡¤ÎËɸæÎϤ¬Áý¤·¤¿¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1175 #else
1176                         msg_print("You feel more resistant to magic.");
1177 #endif
1178
1179                         notice = TRUE;
1180                 }
1181         }
1182
1183         /* Shut */
1184         else
1185         {
1186                 if (p_ptr->magicdef)
1187                 {
1188 #ifdef JP
1189                         msg_print("ËâË¡¤ÎËɸæÎϤ¬¸µ¤ËÌá¤Ã¤¿¡£");
1190 #else
1191                         msg_print("You feel less resistant to magic.");
1192 #endif
1193
1194                         notice = TRUE;
1195                 }
1196         }
1197
1198         /* Use the value */
1199         p_ptr->magicdef = v;
1200
1201         /* Redraw status bar */
1202         p_ptr->redraw |= (PR_STATUS);
1203
1204         /* Nothing to notice */
1205         if (!notice) return (FALSE);
1206
1207         /* Disturb */
1208         if (disturb_state) disturb(0, 0);
1209
1210         /* Recalculate bonuses */
1211         p_ptr->update |= (PU_BONUS);
1212
1213         /* Handle stuff */
1214         handle_stuff();
1215
1216         /* Result */
1217         return (TRUE);
1218 }
1219
1220
1221
1222 /*
1223  * Set "p_ptr->blessed", notice observable changes
1224  */
1225 bool set_blessed(int v, bool do_dec)
1226 {
1227         bool notice = FALSE;
1228
1229         /* Hack -- Force good values */
1230         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1231
1232         if (p_ptr->is_dead) return FALSE;
1233
1234         /* Open */
1235         if (v)
1236         {
1237                 if (p_ptr->blessed && !do_dec)
1238                 {
1239                         if (p_ptr->blessed > v) return FALSE;
1240                 }
1241                 else if (!IS_BLESSED())
1242                 {
1243 #ifdef JP
1244 msg_print("¹â·é¤Êµ¤Ê¬¤Ë¤Ê¤Ã¤¿¡ª");
1245 #else
1246                         msg_print("You feel righteous!");
1247 #endif
1248
1249                         notice = TRUE;
1250                 }
1251         }
1252
1253         /* Shut */
1254         else
1255         {
1256                 if (p_ptr->blessed && !music_singing(MUSIC_BLESS))
1257                 {
1258 #ifdef JP
1259 msg_print("¹â·é¤Êµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
1260 #else
1261                         msg_print("The prayer has expired.");
1262 #endif
1263
1264                         notice = TRUE;
1265                 }
1266         }
1267
1268         /* Use the value */
1269         p_ptr->blessed = v;
1270
1271         /* Redraw status bar */
1272         p_ptr->redraw |= (PR_STATUS);
1273
1274         /* Nothing to notice */
1275         if (!notice) return (FALSE);
1276
1277         /* Disturb */
1278         if (disturb_state) disturb(0, 0);
1279
1280         /* Recalculate bonuses */
1281         p_ptr->update |= (PU_BONUS);
1282
1283         /* Handle stuff */
1284         handle_stuff();
1285
1286         /* Result */
1287         return (TRUE);
1288 }
1289
1290
1291 /*
1292  * Set "p_ptr->hero", notice observable changes
1293  */
1294 bool set_hero(int v, bool do_dec)
1295 {
1296         bool notice = FALSE;
1297
1298         /* Hack -- Force good values */
1299         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1300
1301         if (p_ptr->is_dead) return FALSE;
1302
1303         /* Open */
1304         if (v)
1305         {
1306                 if (p_ptr->hero && !do_dec)
1307                 {
1308                         if (p_ptr->hero > v) return FALSE;
1309                 }
1310                 else if (!IS_HERO())
1311                 {
1312 #ifdef JP
1313 msg_print("¥Ò¡¼¥í¡¼¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1314 #else
1315                         msg_print("You feel like a hero!");
1316 #endif
1317
1318                         notice = TRUE;
1319                 }
1320         }
1321
1322         /* Shut */
1323         else
1324         {
1325                 if (p_ptr->hero && !music_singing(MUSIC_HERO) && !music_singing(MUSIC_SHERO))
1326                 {
1327 #ifdef JP
1328 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
1329 #else
1330                         msg_print("The heroism wears off.");
1331 #endif
1332
1333                         notice = TRUE;
1334                 }
1335         }
1336
1337         /* Use the value */
1338         p_ptr->hero = v;
1339
1340         /* Redraw status bar */
1341         p_ptr->redraw |= (PR_STATUS);
1342
1343         /* Nothing to notice */
1344         if (!notice) return (FALSE);
1345
1346         /* Disturb */
1347         if (disturb_state) disturb(0, 0);
1348
1349         /* Recalculate bonuses */
1350         p_ptr->update |= (PU_BONUS);
1351
1352         /* Recalculate hitpoints */
1353         p_ptr->update |= (PU_HP);
1354
1355         /* Handle stuff */
1356         handle_stuff();
1357
1358         /* Result */
1359         return (TRUE);
1360 }
1361
1362
1363 /*
1364  * Set "p_ptr->shero", notice observable changes
1365  */
1366 bool set_shero(int v, bool do_dec)
1367 {
1368         bool notice = FALSE;
1369
1370         /* Hack -- Force good values */
1371         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1372
1373         if (p_ptr->is_dead) return FALSE;
1374
1375         if (p_ptr->pclass == CLASS_BERSERKER) v = 1;
1376         /* Open */
1377         if (v)
1378         {
1379                 if (p_ptr->shero && !do_dec)
1380                 {
1381                         if (p_ptr->shero > v) return FALSE;
1382                 }
1383                 else if (!p_ptr->shero)
1384                 {
1385 #ifdef JP
1386 msg_print("»¦Ù¤¥Þ¥·¡¼¥ó¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1387 #else
1388                         msg_print("You feel like a killing machine!");
1389 #endif
1390
1391                         notice = TRUE;
1392                 }
1393         }
1394
1395         /* Shut */
1396         else
1397         {
1398                 if (p_ptr->shero)
1399                 {
1400 #ifdef JP
1401 msg_print("ÌîÈڤʵ¤»ý¤Á¤¬¾Ã¤¨¼º¤»¤¿¡£");
1402 #else
1403                         msg_print("You feel less Berserk.");
1404 #endif
1405
1406                         notice = TRUE;
1407                 }
1408         }
1409
1410         /* Use the value */
1411         p_ptr->shero = v;
1412
1413         /* Redraw status bar */
1414         p_ptr->redraw |= (PR_STATUS);
1415
1416         /* Nothing to notice */
1417         if (!notice) return (FALSE);
1418
1419         /* Disturb */
1420         if (disturb_state) disturb(0, 0);
1421
1422         /* Recalculate bonuses */
1423         p_ptr->update |= (PU_BONUS);
1424
1425         /* Recalculate hitpoints */
1426         p_ptr->update |= (PU_HP);
1427
1428         /* Handle stuff */
1429         handle_stuff();
1430
1431         /* Result */
1432         return (TRUE);
1433 }
1434
1435
1436 /*
1437  * Set "p_ptr->protevil", notice observable changes
1438  */
1439 bool set_protevil(int v, bool do_dec)
1440 {
1441         bool notice = FALSE;
1442
1443         /* Hack -- Force good values */
1444         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1445
1446         if (p_ptr->is_dead) return FALSE;
1447
1448         /* Open */
1449         if (v)
1450         {
1451                 if (p_ptr->protevil && !do_dec)
1452                 {
1453                         if (p_ptr->protevil > v) return FALSE;
1454                 }
1455                 else if (!p_ptr->protevil)
1456                 {
1457 #ifdef JP
1458 msg_print("¼Ù°­¤Ê¤ë¸ºß¤«¤é¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Ê´¶¤¸¤¬¤¹¤ë¡ª");
1459 #else
1460                         msg_print("You feel safe from evil!");
1461 #endif
1462
1463                         notice = TRUE;
1464                 }
1465         }
1466
1467         /* Shut */
1468         else
1469         {
1470                 if (p_ptr->protevil)
1471                 {
1472 #ifdef JP
1473 msg_print("¼Ù°­¤Ê¤ë¸ºß¤«¤é¼é¤é¤ì¤Æ¤¤¤ë´¶¤¸¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1474 #else
1475                         msg_print("You no longer feel safe from evil.");
1476 #endif
1477
1478                         notice = TRUE;
1479                 }
1480         }
1481
1482         /* Use the value */
1483         p_ptr->protevil = v;
1484
1485         /* Redraw status bar */
1486         p_ptr->redraw |= (PR_STATUS);
1487
1488         /* Nothing to notice */
1489         if (!notice) return (FALSE);
1490
1491         /* Disturb */
1492         if (disturb_state) disturb(0, 0);
1493
1494         /* Handle stuff */
1495         handle_stuff();
1496
1497         /* Result */
1498         return (TRUE);
1499 }
1500
1501 /*
1502  * Set "p_ptr->wraith_form", notice observable changes
1503  */
1504 bool set_wraith_form(int v, bool do_dec)
1505 {
1506         bool notice = FALSE;
1507
1508         /* Hack -- Force good values */
1509         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1510
1511         if (p_ptr->is_dead) return FALSE;
1512
1513         /* Open */
1514         if (v)
1515         {
1516                 if (p_ptr->wraith_form && !do_dec)
1517                 {
1518                         if (p_ptr->wraith_form > v) return FALSE;
1519                 }
1520                 else if (!p_ptr->wraith_form)
1521                 {
1522 #ifdef JP
1523 msg_print("ʪ¼Á³¦¤òÎ¥¤ì¤ÆÍ©µ´¤Î¤è¤¦¤Ê¸ºß¤Ë¤Ê¤Ã¤¿¡ª");
1524 #else
1525                         msg_print("You leave the physical world and turn into a wraith-being!");
1526 #endif
1527
1528                         notice = TRUE;
1529
1530                         chg_virtue(V_UNLIFE, 3);
1531                         chg_virtue(V_HONOUR, -2);
1532                         chg_virtue(V_SACRIFICE, -2);
1533                         chg_virtue(V_VALOUR, -5);
1534
1535                         /* Redraw map */
1536                         p_ptr->redraw |= (PR_MAP);
1537
1538                         /* Update monsters */
1539                         p_ptr->update |= (PU_MONSTERS);
1540
1541                         /* Window stuff */
1542                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1543                 }
1544         }
1545
1546         /* Shut */
1547         else
1548         {
1549                 if (p_ptr->wraith_form)
1550                 {
1551 #ifdef JP
1552 msg_print("ÉÔÆ©ÌÀ¤Ë¤Ê¤Ã¤¿´¶¤¸¤¬¤¹¤ë¡£");
1553 #else
1554                         msg_print("You feel opaque.");
1555 #endif
1556
1557                         notice = TRUE;
1558
1559                         /* Redraw map */
1560                         p_ptr->redraw |= (PR_MAP);
1561
1562                         /* Update monsters */
1563                         p_ptr->update |= (PU_MONSTERS);
1564
1565                         /* Window stuff */
1566                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1567                 }
1568         }
1569
1570         /* Use the value */
1571         p_ptr->wraith_form = v;
1572
1573         /* Redraw status bar */
1574         p_ptr->redraw |= (PR_STATUS);
1575
1576         /* Nothing to notice */
1577         if (!notice) return (FALSE);
1578
1579         /* Disturb */
1580         if (disturb_state) disturb(0, 0);
1581
1582         /* Recalculate bonuses */
1583         p_ptr->update |= (PU_BONUS);
1584
1585         /* Handle stuff */
1586         handle_stuff();
1587
1588         /* Result */
1589         return (TRUE);
1590
1591 }
1592
1593
1594 /*
1595  * Set "p_ptr->invuln", notice observable changes
1596  */
1597 bool set_invuln(int v, bool do_dec)
1598 {
1599         bool notice = FALSE;
1600
1601         /* Hack -- Force good values */
1602         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1603
1604         if (p_ptr->is_dead) return FALSE;
1605
1606         /* Open */
1607         if (v)
1608         {
1609                 if (p_ptr->invuln && !do_dec)
1610                 {
1611                         if (p_ptr->invuln > v) return FALSE;
1612                 }
1613                 else if (!IS_INVULN())
1614                 {
1615 #ifdef JP
1616 msg_print("̵Ũ¤À¡ª");
1617 #else
1618                         msg_print("Invulnerability!");
1619 #endif
1620
1621                         notice = TRUE;
1622
1623                         chg_virtue(V_UNLIFE, -2);
1624                         chg_virtue(V_HONOUR, -2);
1625                         chg_virtue(V_SACRIFICE, -3);
1626                         chg_virtue(V_VALOUR, -5);
1627
1628                         /* Redraw map */
1629                         p_ptr->redraw |= (PR_MAP);
1630
1631                         /* Update monsters */
1632                         p_ptr->update |= (PU_MONSTERS);
1633
1634                         /* Window stuff */
1635                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1636                 }
1637         }
1638
1639         /* Shut */
1640         else
1641         {
1642                 if (p_ptr->invuln && !music_singing(MUSIC_INVULN))
1643                 {
1644 #ifdef JP
1645 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
1646 #else
1647                         msg_print("The invulnerability wears off.");
1648 #endif
1649
1650                         notice = TRUE;
1651
1652                         /* Redraw map */
1653                         p_ptr->redraw |= (PR_MAP);
1654
1655                         /* Update monsters */
1656                         p_ptr->update |= (PU_MONSTERS);
1657
1658                         /* Window stuff */
1659                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1660
1661                         p_ptr->energy_need += ENERGY_NEED();
1662                 }
1663         }
1664
1665         /* Use the value */
1666         p_ptr->invuln = v;
1667
1668         /* Redraw status bar */
1669         p_ptr->redraw |= (PR_STATUS);
1670
1671         /* Nothing to notice */
1672         if (!notice) return (FALSE);
1673
1674         /* Disturb */
1675         if (disturb_state) disturb(0, 0);
1676
1677         /* Recalculate bonuses */
1678         p_ptr->update |= (PU_BONUS);
1679
1680         /* Handle stuff */
1681         handle_stuff();
1682
1683         /* Result */
1684         return (TRUE);
1685 }
1686
1687
1688 /*
1689  * Set "p_ptr->tim_esp", notice observable changes
1690  */
1691 bool set_tim_esp(int v, bool do_dec)
1692 {
1693         bool notice = FALSE;
1694
1695         /* Hack -- Force good values */
1696         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1697
1698         if (p_ptr->is_dead) return FALSE;
1699
1700         /* Open */
1701         if (v)
1702         {
1703                 if (p_ptr->tim_esp && !do_dec)
1704                 {
1705                         if (p_ptr->tim_esp > v) return FALSE;
1706                 }
1707                 else if (!IS_TIM_ESP())
1708                 {
1709 #ifdef JP
1710 msg_print("°Õ¼±¤¬¹­¤¬¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1711 #else
1712                         msg_print("You feel your consciousness expand!");
1713 #endif
1714
1715                         notice = TRUE;
1716                 }
1717         }
1718
1719         /* Shut */
1720         else
1721         {
1722                 if (p_ptr->tim_esp && !music_singing(MUSIC_MIND))
1723                 {
1724 #ifdef JP
1725 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
1726 #else
1727                         msg_print("Your consciousness contracts again.");
1728 #endif
1729
1730                         notice = TRUE;
1731                 }
1732         }
1733
1734         /* Use the value */
1735         p_ptr->tim_esp = v;
1736
1737         /* Redraw status bar */
1738         p_ptr->redraw |= (PR_STATUS);
1739
1740         /* Nothing to notice */
1741         if (!notice) return (FALSE);
1742
1743         /* Disturb */
1744         if (disturb_state) disturb(0, 0);
1745
1746         /* Recalculate bonuses */
1747         p_ptr->update |= (PU_BONUS);
1748
1749         /* Update the monsters */
1750         p_ptr->update |= (PU_MONSTERS);
1751
1752         /* Handle stuff */
1753         handle_stuff();
1754
1755         /* Result */
1756         return (TRUE);
1757 }
1758
1759
1760 /*
1761  * Set "p_ptr->tim_invis", notice observable changes
1762  */
1763 bool set_tim_invis(int v, bool do_dec)
1764 {
1765         bool notice = FALSE;
1766
1767         /* Hack -- Force good values */
1768         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1769
1770         if (p_ptr->is_dead) return FALSE;
1771
1772         /* Open */
1773         if (v)
1774         {
1775                 if (p_ptr->tim_invis && !do_dec)
1776                 {
1777                         if (p_ptr->tim_invis > v) return FALSE;
1778                 }
1779                 else if (!p_ptr->tim_invis)
1780                 {
1781 #ifdef JP
1782 msg_print("Ìܤ¬Èó¾ï¤ËÉÒ´¶¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡ª");
1783 #else
1784                         msg_print("Your eyes feel very sensitive!");
1785 #endif
1786
1787                         notice = TRUE;
1788                 }
1789         }
1790
1791         /* Shut */
1792         else
1793         {
1794                 if (p_ptr->tim_invis)
1795                 {
1796 #ifdef JP
1797 msg_print("ÌܤÎÉÒ´¶¤µ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
1798 #else
1799                         msg_print("Your eyes feel less sensitive.");
1800 #endif
1801
1802                         notice = TRUE;
1803                 }
1804         }
1805
1806         /* Use the value */
1807         p_ptr->tim_invis = v;
1808
1809         /* Redraw status bar */
1810         p_ptr->redraw |= (PR_STATUS);
1811
1812         /* Nothing to notice */
1813         if (!notice) return (FALSE);
1814
1815         /* Disturb */
1816         if (disturb_state) disturb(0, 0);
1817
1818         /* Recalculate bonuses */
1819         p_ptr->update |= (PU_BONUS);
1820
1821         /* Update the monsters */
1822         p_ptr->update |= (PU_MONSTERS);
1823
1824         /* Handle stuff */
1825         handle_stuff();
1826
1827         /* Result */
1828         return (TRUE);
1829 }
1830
1831
1832 /*
1833  * Set "p_ptr->tim_infra", notice observable changes
1834  */
1835 bool set_tim_infra(int v, bool do_dec)
1836 {
1837         bool notice = FALSE;
1838
1839         /* Hack -- Force good values */
1840         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1841
1842         if (p_ptr->is_dead) return FALSE;
1843
1844         /* Open */
1845         if (v)
1846         {
1847                 if (p_ptr->tim_infra && !do_dec)
1848                 {
1849                         if (p_ptr->tim_infra > v) return FALSE;
1850                 }
1851                 else if (!p_ptr->tim_infra)
1852                 {
1853 #ifdef JP
1854 msg_print("Ìܤ¬¥é¥ó¥é¥ó¤Èµ±¤­»Ï¤á¤¿¡ª");
1855 #else
1856                         msg_print("Your eyes begin to tingle!");
1857 #endif
1858
1859                         notice = TRUE;
1860                 }
1861         }
1862
1863         /* Shut */
1864         else
1865         {
1866                 if (p_ptr->tim_infra)
1867                 {
1868 #ifdef JP
1869 msg_print("Ìܤ層­¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1870 #else
1871                         msg_print("Your eyes stop tingling.");
1872 #endif
1873
1874                         notice = TRUE;
1875                 }
1876         }
1877
1878         /* Use the value */
1879         p_ptr->tim_infra = v;
1880
1881         /* Redraw status bar */
1882         p_ptr->redraw |= (PR_STATUS);
1883
1884         /* Nothing to notice */
1885         if (!notice) return (FALSE);
1886
1887         /* Disturb */
1888         if (disturb_state) disturb(0, 0);
1889
1890         /* Recalculate bonuses */
1891         p_ptr->update |= (PU_BONUS);
1892
1893         /* Update the monsters */
1894         p_ptr->update |= (PU_MONSTERS);
1895
1896         /* Handle stuff */
1897         handle_stuff();
1898
1899         /* Result */
1900         return (TRUE);
1901 }
1902
1903
1904 /*
1905  * Set "p_ptr->tim_regen", notice observable changes
1906  */
1907 bool set_tim_regen(int v, bool do_dec)
1908 {
1909         bool notice = FALSE;
1910
1911         /* Hack -- Force good values */
1912         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1913
1914         if (p_ptr->is_dead) return FALSE;
1915
1916         /* Open */
1917         if (v)
1918         {
1919                 if (p_ptr->tim_regen && !do_dec)
1920                 {
1921                         if (p_ptr->tim_regen > v) return FALSE;
1922                 }
1923                 else if (!p_ptr->tim_regen)
1924                 {
1925 #ifdef JP
1926 msg_print("²óÉüÎϤ¬¾å¤¬¤Ã¤¿¡ª");
1927 #else
1928                         msg_print("You feel yourself regenerating quickly!");
1929 #endif
1930
1931                         notice = TRUE;
1932                 }
1933         }
1934
1935         /* Shut */
1936         else
1937         {
1938                 if (p_ptr->tim_regen)
1939                 {
1940 #ifdef JP
1941 msg_print("ÁÇÁ᤯²óÉü¤¹¤ë´¶¤¸¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
1942 #else
1943                         msg_print("You feel yourself regenerating slowly.");
1944 #endif
1945
1946                         notice = TRUE;
1947                 }
1948         }
1949
1950         /* Use the value */
1951         p_ptr->tim_regen = v;
1952
1953         /* Redraw status bar */
1954         p_ptr->redraw |= (PR_STATUS);
1955
1956         /* Nothing to notice */
1957         if (!notice) return (FALSE);
1958
1959         /* Disturb */
1960         if (disturb_state) disturb(0, 0);
1961
1962         /* Recalculate bonuses */
1963         p_ptr->update |= (PU_BONUS);
1964
1965         /* Handle stuff */
1966         handle_stuff();
1967
1968         /* Result */
1969         return (TRUE);
1970 }
1971
1972
1973 /*
1974  * Set "p_ptr->tim_stealth", notice observable changes
1975  */
1976 bool set_tim_stealth(int v, bool do_dec)
1977 {
1978         bool notice = FALSE;
1979
1980         /* Hack -- Force good values */
1981         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
1982
1983         if (p_ptr->is_dead) return FALSE;
1984
1985         /* Open */
1986         if (v)
1987         {
1988                 if (p_ptr->tim_stealth && !do_dec)
1989                 {
1990                         if (p_ptr->tim_stealth > v) return FALSE;
1991                 }
1992                 else if (!IS_TIM_STEALTH())
1993                 {
1994 #ifdef JP
1995 msg_print("­²»¤¬¾®¤µ¤¯¤Ê¤Ã¤¿¡ª");
1996 #else
1997                         msg_print("You begin to walk silently!");
1998 #endif
1999
2000                         notice = TRUE;
2001                 }
2002         }
2003
2004         /* Shut */
2005         else
2006         {
2007                 if (p_ptr->tim_stealth && !music_singing(MUSIC_STEALTH))
2008                 {
2009 #ifdef JP
2010 msg_print("­²»¤¬Â礭¤¯¤Ê¤Ã¤¿¡£");
2011 #else
2012                         msg_print("You no longer walk silently.");
2013 #endif
2014
2015                         notice = TRUE;
2016                 }
2017         }
2018
2019         /* Use the value */
2020         p_ptr->tim_stealth = v;
2021
2022         /* Redraw status bar */
2023         p_ptr->redraw |= (PR_STATUS);
2024
2025         /* Nothing to notice */
2026         if (!notice) return (FALSE);
2027
2028         /* Disturb */
2029         if (disturb_state) disturb(0, 0);
2030
2031         /* Recalculate bonuses */
2032         p_ptr->update |= (PU_BONUS);
2033
2034         /* Handle stuff */
2035         handle_stuff();
2036
2037         /* Result */
2038         return (TRUE);
2039 }
2040
2041
2042 bool set_superstealth(bool set)
2043 {
2044         bool notice = FALSE;
2045
2046         if (p_ptr->is_dead) return FALSE;
2047
2048         /* Open */
2049         if (set)
2050         {
2051                 if (!(p_ptr->special_defense & NINJA_S_STEALTH))
2052                 {
2053                         if (cave[py][px].info & CAVE_MNLT)
2054                         {
2055 #ifdef JP
2056                                 msg_print("Ũ¤ÎÌܤ«¤éÇö¤¤±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡£");
2057 #else
2058                                 msg_print("You are mantled in weak shadow from ordinary eyes.");
2059 #endif
2060                                 p_ptr->monlite = p_ptr->old_monlite = TRUE;
2061                         }
2062                         else
2063                         {
2064 #ifdef JP
2065                                 msg_print("Ũ¤ÎÌܤ«¤é±Æ¤ÎÃæ¤Ëʤ¤¤±£¤µ¤ì¤¿¡ª");
2066 #else
2067                                 msg_print("You are mantled in shadow from ordinary eyes!");
2068 #endif
2069                                 p_ptr->monlite = p_ptr->old_monlite = FALSE;
2070                         }
2071
2072                         notice = TRUE;
2073
2074                         /* Use the value */
2075                         p_ptr->special_defense |= NINJA_S_STEALTH;
2076                 }
2077         }
2078
2079         /* Shut */
2080         else
2081         {
2082                 if (p_ptr->special_defense & NINJA_S_STEALTH)
2083                 {
2084 #ifdef JP
2085                         msg_print("ºÆ¤ÓŨ¤ÎÌܤˤµ¤é¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
2086 #else
2087                         msg_print("You are exposed to common sight once more.");
2088 #endif
2089
2090                         notice = TRUE;
2091
2092                         /* Use the value */
2093                         p_ptr->special_defense &= ~(NINJA_S_STEALTH);
2094                 }
2095         }
2096
2097         /* Nothing to notice */
2098         if (!notice) return (FALSE);
2099
2100         /* Redraw status bar */
2101         p_ptr->redraw |= (PR_STATUS);
2102
2103         /* Disturb */
2104         if (disturb_state) disturb(0, 0);
2105
2106         /* Result */
2107         return (TRUE);
2108 }
2109
2110
2111 /*
2112  * Set "p_ptr->tim_levitation", notice observable changes
2113  */
2114 bool set_tim_levitation(int v, bool do_dec)
2115 {
2116         bool notice = FALSE;
2117
2118         /* Hack -- Force good values */
2119         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2120
2121         if (p_ptr->is_dead) return FALSE;
2122
2123         /* Open */
2124         if (v)
2125         {
2126                 if (p_ptr->tim_levitation && !do_dec)
2127                 {
2128                         if (p_ptr->tim_levitation > v) return FALSE;
2129                 }
2130                 else if (!p_ptr->tim_levitation)
2131                 {
2132 #ifdef JP
2133 msg_print("ÂΤ¬Ãè¤ËÉ⤭»Ï¤á¤¿¡£");
2134 #else
2135                         msg_print("You begin to fly!");
2136 #endif
2137
2138                         notice = TRUE;
2139                 }
2140         }
2141
2142         /* Shut */
2143         else
2144         {
2145                 if (p_ptr->tim_levitation)
2146                 {
2147 #ifdef JP
2148 msg_print("¤â¤¦Ãè¤ËÉ⤫¤Ù¤Ê¤¯¤Ê¤Ã¤¿¡£");
2149 #else
2150                         msg_print("You stop flying.");
2151 #endif
2152
2153                         notice = TRUE;
2154                 }
2155         }
2156
2157         /* Use the value */
2158         p_ptr->tim_levitation = v;
2159
2160         /* Redraw status bar */
2161         p_ptr->redraw |= (PR_STATUS);
2162
2163         /* Nothing to notice */
2164         if (!notice) return (FALSE);
2165
2166         /* Disturb */
2167         if (disturb_state) disturb(0, 0);
2168
2169         /* Recalculate bonuses */
2170         p_ptr->update |= (PU_BONUS);
2171
2172         /* Handle stuff */
2173         handle_stuff();
2174
2175         /* Result */
2176         return (TRUE);
2177 }
2178
2179
2180 /*
2181  * Set "p_ptr->tim_sh_touki", notice observable changes
2182  */
2183 bool set_tim_sh_touki(int v, bool do_dec)
2184 {
2185         bool notice = FALSE;
2186
2187         /* Hack -- Force good values */
2188         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2189
2190         if (p_ptr->is_dead) return FALSE;
2191
2192         /* Open */
2193         if (v)
2194         {
2195                 if (p_ptr->tim_sh_touki && !do_dec)
2196                 {
2197                         if (p_ptr->tim_sh_touki > v) return FALSE;
2198                 }
2199                 else if (!p_ptr->tim_sh_touki)
2200                 {
2201 #ifdef JP
2202 msg_print("ÂΤ¬Æ®µ¤¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2203 #else
2204                         msg_print("You have enveloped by the aura of the Force!");
2205 #endif
2206
2207                         notice = TRUE;
2208                 }
2209         }
2210
2211         /* Shut */
2212         else
2213         {
2214                 if (p_ptr->tim_sh_touki)
2215                 {
2216 #ifdef JP
2217 msg_print("Æ®µ¤¤¬¾Ã¤¨¤¿¡£");
2218 #else
2219                         msg_print("Aura of the Force disappeared.");
2220 #endif
2221
2222                         notice = TRUE;
2223                 }
2224         }
2225
2226         /* Use the value */
2227         p_ptr->tim_sh_touki = v;
2228
2229         /* Redraw status bar */
2230         p_ptr->redraw |= (PR_STATUS);
2231
2232         /* Nothing to notice */
2233         if (!notice) return (FALSE);
2234
2235         /* Disturb */
2236         if (disturb_state) disturb(0, 0);
2237
2238         /* Handle stuff */
2239         handle_stuff();
2240
2241         /* Result */
2242         return (TRUE);
2243 }
2244
2245
2246 /*
2247  * Set "p_ptr->tim_sh_fire", notice observable changes
2248  */
2249 bool set_tim_sh_fire(int v, bool do_dec)
2250 {
2251         bool notice = FALSE;
2252
2253         /* Hack -- Force good values */
2254         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2255
2256         if (p_ptr->is_dead) return FALSE;
2257
2258         /* Open */
2259         if (v)
2260         {
2261                 if (p_ptr->tim_sh_fire && !do_dec)
2262                 {
2263                         if (p_ptr->tim_sh_fire > v) return FALSE;
2264                 }
2265                 else if (!p_ptr->tim_sh_fire)
2266                 {
2267 #ifdef JP
2268 msg_print("ÂΤ¬±ê¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2269 #else
2270                         msg_print("You have enveloped by fiery aura!");
2271 #endif
2272
2273                         notice = TRUE;
2274                 }
2275         }
2276
2277         /* Shut */
2278         else
2279         {
2280                 if (p_ptr->tim_sh_fire)
2281                 {
2282 #ifdef JP
2283 msg_print("±ê¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2284 #else
2285                         msg_print("Fiery aura disappeared.");
2286 #endif
2287
2288                         notice = TRUE;
2289                 }
2290         }
2291
2292         /* Use the value */
2293         p_ptr->tim_sh_fire = v;
2294
2295         /* Redraw status bar */
2296         p_ptr->redraw |= (PR_STATUS);
2297
2298         /* Nothing to notice */
2299         if (!notice) return (FALSE);
2300
2301         /* Disturb */
2302         if (disturb_state) disturb(0, 0);
2303
2304         /* Recalculate bonuses */
2305         p_ptr->update |= (PU_BONUS);
2306
2307         /* Handle stuff */
2308         handle_stuff();
2309
2310         /* Result */
2311         return (TRUE);
2312 }
2313
2314
2315 /*
2316  * Set "p_ptr->tim_sh_holy", notice observable changes
2317  */
2318 bool set_tim_sh_holy(int v, bool do_dec)
2319 {
2320         bool notice = FALSE;
2321
2322         /* Hack -- Force good values */
2323         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2324
2325         if (p_ptr->is_dead) return FALSE;
2326
2327         /* Open */
2328         if (v)
2329         {
2330                 if (p_ptr->tim_sh_holy && !do_dec)
2331                 {
2332                         if (p_ptr->tim_sh_holy > v) return FALSE;
2333                 }
2334                 else if (!p_ptr->tim_sh_holy)
2335                 {
2336 #ifdef JP
2337 msg_print("ÂΤ¬À»¤Ê¤ë¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2338 #else
2339                         msg_print("You have enveloped by holy aura!");
2340 #endif
2341
2342                         notice = TRUE;
2343                 }
2344         }
2345
2346         /* Shut */
2347         else
2348         {
2349                 if (p_ptr->tim_sh_holy)
2350                 {
2351 #ifdef JP
2352 msg_print("À»¤Ê¤ë¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2353 #else
2354                         msg_print("Holy aura disappeared.");
2355 #endif
2356
2357                         notice = TRUE;
2358                 }
2359         }
2360
2361         /* Use the value */
2362         p_ptr->tim_sh_holy = v;
2363
2364         /* Redraw status bar */
2365         p_ptr->redraw |= (PR_STATUS);
2366
2367         /* Nothing to notice */
2368         if (!notice) return (FALSE);
2369
2370         /* Disturb */
2371         if (disturb_state) disturb(0, 0);
2372
2373         /* Recalculate bonuses */
2374         p_ptr->update |= (PU_BONUS);
2375
2376         /* Handle stuff */
2377         handle_stuff();
2378
2379         /* Result */
2380         return (TRUE);
2381 }
2382
2383
2384
2385 /*
2386  * Set "p_ptr->tim_eyeeye", notice observable changes
2387  */
2388 bool set_tim_eyeeye(int v, bool do_dec)
2389 {
2390         bool notice = FALSE;
2391
2392         /* Hack -- Force good values */
2393         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2394
2395         if (p_ptr->is_dead) return FALSE;
2396
2397         /* Open */
2398         if (v)
2399         {
2400                 if (p_ptr->tim_eyeeye && !do_dec)
2401                 {
2402                         if (p_ptr->tim_eyeeye > v) return FALSE;
2403                 }
2404                 else if (!p_ptr->tim_eyeeye)
2405                 {
2406 #ifdef JP
2407 msg_print("Ë¡¤Î¼é¤ê¼ê¤Ë¤Ê¤Ã¤¿µ¤¤¬¤·¤¿¡ª");
2408 #else
2409                         msg_print("You feel like a keeper of commandments!");
2410 #endif
2411
2412                         notice = TRUE;
2413                 }
2414         }
2415
2416         /* Shut */
2417         else
2418         {
2419                 if (p_ptr->tim_eyeeye)
2420                 {
2421 #ifdef JP
2422 msg_print("Ĩȳ¤ò¼¹¹Ô¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2423 #else
2424                         msg_print("You no longer feel like a keeper.");
2425 #endif
2426
2427                         notice = TRUE;
2428                 }
2429         }
2430
2431         /* Use the value */
2432         p_ptr->tim_eyeeye = v;
2433
2434         /* Redraw status bar */
2435         p_ptr->redraw |= (PR_STATUS);
2436
2437         /* Nothing to notice */
2438         if (!notice) return (FALSE);
2439
2440         /* Disturb */
2441         if (disturb_state) disturb(0, 0);
2442
2443         /* Recalculate bonuses */
2444         p_ptr->update |= (PU_BONUS);
2445
2446         /* Handle stuff */
2447         handle_stuff();
2448
2449         /* Result */
2450         return (TRUE);
2451 }
2452
2453
2454
2455 /*
2456  * Set "p_ptr->resist_magic", notice observable changes
2457  */
2458 bool set_resist_magic(int v, bool do_dec)
2459 {
2460         bool notice = FALSE;
2461
2462         /* Hack -- Force good values */
2463         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2464
2465         if (p_ptr->is_dead) return FALSE;
2466
2467         /* Open */
2468         if (v)
2469         {
2470                 if (p_ptr->resist_magic && !do_dec)
2471                 {
2472                         if (p_ptr->resist_magic > v) return FALSE;
2473                 }
2474                 else if (!p_ptr->resist_magic)
2475                 {
2476 #ifdef JP
2477 msg_print("ËâË¡¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿¡£");
2478 #else
2479                         msg_print("You have been protected from magic!");
2480 #endif
2481
2482                         notice = TRUE;
2483                 }
2484         }
2485
2486         /* Shut */
2487         else
2488         {
2489                 if (p_ptr->resist_magic)
2490                 {
2491 #ifdef JP
2492 msg_print("ËâË¡¤Ë¼å¤¯¤Ê¤Ã¤¿¡£");
2493 #else
2494 msg_print("You are no longer protected from magic.");
2495 #endif
2496
2497                         notice = TRUE;
2498                 }
2499         }
2500
2501         /* Use the value */
2502         p_ptr->resist_magic = v;
2503
2504         /* Redraw status bar */
2505         p_ptr->redraw |= (PR_STATUS);
2506
2507         /* Nothing to notice */
2508         if (!notice) return (FALSE);
2509
2510         /* Disturb */
2511         if (disturb_state) disturb(0, 0);
2512
2513         /* Recalculate bonuses */
2514         p_ptr->update |= (PU_BONUS);
2515
2516         /* Handle stuff */
2517         handle_stuff();
2518
2519         /* Result */
2520         return (TRUE);
2521 }
2522
2523
2524 /*
2525  * Set "p_ptr->tim_reflect", notice observable changes
2526  */
2527 bool set_tim_reflect(int v, bool do_dec)
2528 {
2529         bool notice = FALSE;
2530
2531         /* Hack -- Force good values */
2532         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2533
2534         if (p_ptr->is_dead) return FALSE;
2535
2536         /* Open */
2537         if (v)
2538         {
2539                 if (p_ptr->tim_reflect && !do_dec)
2540                 {
2541                         if (p_ptr->tim_reflect > v) return FALSE;
2542                 }
2543                 else if (!p_ptr->tim_reflect)
2544                 {
2545 #ifdef JP
2546 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ë¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£");
2547 #else
2548                         msg_print("Your body becames smooth.");
2549 #endif
2550
2551                         notice = TRUE;
2552                 }
2553         }
2554
2555         /* Shut */
2556         else
2557         {
2558                 if (p_ptr->tim_reflect)
2559                 {
2560 #ifdef JP
2561 msg_print("ÂΤÎɽÌ̤¬³ê¤«¤Ç¤Ê¤¯¤Ê¤Ã¤¿¡£");
2562 #else
2563                         msg_print("Your body is no longer smooth.");
2564 #endif
2565
2566                         notice = TRUE;
2567                 }
2568         }
2569
2570         /* Use the value */
2571         p_ptr->tim_reflect = v;
2572
2573         /* Redraw status bar */
2574         p_ptr->redraw |= (PR_STATUS);
2575
2576         /* Nothing to notice */
2577         if (!notice) return (FALSE);
2578
2579         /* Disturb */
2580         if (disturb_state) disturb(0, 0);
2581
2582         /* Recalculate bonuses */
2583         p_ptr->update |= (PU_BONUS);
2584
2585         /* Handle stuff */
2586         handle_stuff();
2587
2588         /* Result */
2589         return (TRUE);
2590 }
2591
2592
2593 /*
2594  * Set "p_ptr->multishadow", notice observable changes
2595  */
2596 bool set_multishadow(int v, bool do_dec)
2597 {
2598         bool notice = FALSE;
2599
2600         /* Hack -- Force good values */
2601         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2602
2603         if (p_ptr->is_dead) return FALSE;
2604
2605         /* Open */
2606         if (v)
2607         {
2608                 if (p_ptr->multishadow && !do_dec)
2609                 {
2610                         if (p_ptr->multishadow > v) return FALSE;
2611                 }
2612                 else if (!p_ptr->multishadow)
2613                 {
2614 #ifdef JP
2615 msg_print("¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¸¸±Æ¤¬À¸¤Þ¤ì¤¿¡£");
2616 #else
2617                         msg_print("Your Shadow enveloped you.");
2618 #endif
2619
2620                         notice = TRUE;
2621                 }
2622         }
2623
2624         /* Shut */
2625         else
2626         {
2627                 if (p_ptr->multishadow)
2628                 {
2629 #ifdef JP
2630 msg_print("¸¸±Æ¤¬¾Ã¤¨¤¿¡£");
2631 #else
2632                         msg_print("Your Shadow disappears.");
2633 #endif
2634
2635                         notice = TRUE;
2636                 }
2637         }
2638
2639         /* Use the value */
2640         p_ptr->multishadow = v;
2641
2642         /* Redraw status bar */
2643         p_ptr->redraw |= (PR_STATUS);
2644
2645         /* Nothing to notice */
2646         if (!notice) return (FALSE);
2647
2648         /* Disturb */
2649         if (disturb_state) disturb(0, 0);
2650
2651         /* Recalculate bonuses */
2652         p_ptr->update |= (PU_BONUS);
2653
2654         /* Handle stuff */
2655         handle_stuff();
2656
2657         /* Result */
2658         return (TRUE);
2659 }
2660
2661
2662 /*
2663  * Set "p_ptr->dustrobe", notice observable changes
2664  */
2665 bool set_dustrobe(int v, bool do_dec)
2666 {
2667         bool notice = FALSE;
2668
2669         /* Hack -- Force good values */
2670         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2671
2672         if (p_ptr->is_dead) return FALSE;
2673
2674         /* Open */
2675         if (v)
2676         {
2677                 if (p_ptr->dustrobe && !do_dec)
2678                 {
2679                         if (p_ptr->dustrobe > v) return FALSE;
2680                 }
2681                 else if (!p_ptr->dustrobe)
2682                 {
2683 #ifdef JP
2684 msg_print("ÂΤ¬¶À¤Î¥ª¡¼¥é¤Çʤ¤ï¤ì¤¿¡£");
2685 #else
2686                         msg_print("You were enveloped by mirror shards.");
2687 #endif
2688
2689                         notice = TRUE;
2690                 }
2691         }
2692
2693         /* Shut */
2694         else
2695         {
2696                 if (p_ptr->dustrobe)
2697                 {
2698 #ifdef JP
2699 msg_print("¶À¤Î¥ª¡¼¥é¤¬¾Ã¤¨¤¿¡£");
2700 #else
2701                         msg_print("The mirror shards disappear.");
2702 #endif
2703
2704                         notice = TRUE;
2705                 }
2706         }
2707
2708         /* Use the value */
2709         p_ptr->dustrobe = v;
2710
2711         /* Redraw status bar */
2712         p_ptr->redraw |= (PR_STATUS);
2713
2714         /* Nothing to notice */
2715         if (!notice) return (FALSE);
2716
2717         /* Disturb */
2718         if (disturb_state) disturb(0, 0);
2719
2720         /* Recalculate bonuses */
2721         p_ptr->update |= (PU_BONUS);
2722
2723         /* Handle stuff */
2724         handle_stuff();
2725
2726         /* Result */
2727         return (TRUE);
2728 }
2729
2730
2731 /*
2732  * Set "p_ptr->tim_regen", notice observable changes
2733  */
2734 bool set_kabenuke(int v, bool do_dec)
2735 {
2736         bool notice = FALSE;
2737
2738         /* Hack -- Force good values */
2739         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2740
2741         if (p_ptr->is_dead) return FALSE;
2742
2743         /* Open */
2744         if (v)
2745         {
2746                 if (p_ptr->kabenuke && !do_dec)
2747                 {
2748                         if (p_ptr->kabenuke > v) return FALSE;
2749                 }
2750                 else if (!p_ptr->kabenuke)
2751                 {
2752 #ifdef JP
2753 msg_print("ÂΤ¬È¾Êª¼Á¤Î¾õÂ֤ˤʤä¿¡£");
2754 #else
2755                         msg_print("You became ethereal form.");
2756 #endif
2757
2758                         notice = TRUE;
2759                 }
2760         }
2761
2762         /* Shut */
2763         else
2764         {
2765                 if (p_ptr->kabenuke)
2766                 {
2767 #ifdef JP
2768 msg_print("ÂΤ¬Êª¼Á²½¤·¤¿¡£");
2769 #else
2770                         msg_print("You are no longer in an ethereal form.");
2771 #endif
2772
2773                         notice = TRUE;
2774                 }
2775         }
2776
2777         /* Use the value */
2778         p_ptr->kabenuke = v;
2779
2780         /* Redraw status bar */
2781         p_ptr->redraw |= (PR_STATUS);
2782
2783         /* Nothing to notice */
2784         if (!notice) return (FALSE);
2785
2786         /* Disturb */
2787         if (disturb_state) disturb(0, 0);
2788
2789         /* Recalculate bonuses */
2790         p_ptr->update |= (PU_BONUS);
2791
2792         /* Handle stuff */
2793         handle_stuff();
2794
2795         /* Result */
2796         return (TRUE);
2797 }
2798
2799
2800 bool set_tsuyoshi(int v, bool do_dec)
2801 {
2802         bool notice = FALSE;
2803
2804         /* Hack -- Force good values */
2805         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2806
2807         if (p_ptr->is_dead) return FALSE;
2808
2809         /* Open */
2810         if (v)
2811         {
2812                 if (p_ptr->tsuyoshi && !do_dec)
2813                 {
2814                         if (p_ptr->tsuyoshi > v) return FALSE;
2815                 }
2816                 else if (!p_ptr->tsuyoshi)
2817                 {
2818 #ifdef JP
2819 msg_print("¡Ö¥ª¥¯¥ì·»¤µ¤ó¡ª¡×");
2820 #else
2821                         msg_print("Brother OKURE!");
2822 #endif
2823
2824                         notice = TRUE;
2825                         chg_virtue(V_VITALITY, 2);
2826                 }
2827         }
2828
2829         /* Shut */
2830         else
2831         {
2832                 if (p_ptr->tsuyoshi)
2833                 {
2834 #ifdef JP
2835 msg_print("ÆùÂΤ¬µÞ®¤Ë¤·¤Ü¤ó¤Ç¤¤¤Ã¤¿¡£");
2836 #else
2837                         msg_print("Your body had quickly shriveled.");
2838 #endif
2839
2840                         (void)dec_stat(A_CON, 20, TRUE);
2841                         (void)dec_stat(A_STR, 20, TRUE);
2842
2843                         notice = TRUE;
2844                         chg_virtue(V_VITALITY, -3);
2845                 }
2846         }
2847
2848         /* Use the value */
2849         p_ptr->tsuyoshi = v;
2850
2851         /* Redraw status bar */
2852         p_ptr->redraw |= (PR_STATUS);
2853
2854         /* Nothing to notice */
2855         if (!notice) return (FALSE);
2856
2857         /* Disturb */
2858         if (disturb_state) disturb(0, 0);
2859
2860         /* Recalculate bonuses */
2861         p_ptr->update |= (PU_BONUS);
2862
2863         /* Recalculate hitpoints */
2864         p_ptr->update |= (PU_HP);
2865
2866         /* Handle stuff */
2867         handle_stuff();
2868
2869         /* Result */
2870         return (TRUE);
2871 }
2872
2873
2874 /*
2875  * Set a temporary elemental brand.  Clear all other brands.  Print status 
2876  * messages. -LM-
2877  */
2878 bool set_ele_attack(u32b attack_type, int v)
2879 {
2880         /* Hack -- Force good values */
2881         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2882
2883         /* Clear all elemental attacks (only one is allowed at a time). */
2884         if ((p_ptr->special_attack & (ATTACK_ACID)) && (attack_type != ATTACK_ACID))
2885         {
2886                 p_ptr->special_attack &= ~(ATTACK_ACID);
2887 #ifdef JP
2888                 msg_print("»À¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2889 #else
2890                 msg_print("Your temporary acidic brand fades away.");
2891 #endif
2892         }
2893         if ((p_ptr->special_attack & (ATTACK_ELEC)) && (attack_type != ATTACK_ELEC))
2894         {
2895                 p_ptr->special_attack &= ~(ATTACK_ELEC);
2896 #ifdef JP
2897                 msg_print("ÅÅ·â¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2898 #else
2899                 msg_print("Your temporary electrical brand fades away.");
2900 #endif
2901         }
2902         if ((p_ptr->special_attack & (ATTACK_FIRE)) && (attack_type != ATTACK_FIRE))
2903         {
2904                 p_ptr->special_attack &= ~(ATTACK_FIRE);
2905 #ifdef JP
2906                 msg_print("²Ð±ê¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2907 #else
2908                 msg_print("Your temporary fiery brand fades away.");
2909 #endif
2910         }
2911         if ((p_ptr->special_attack & (ATTACK_COLD)) && (attack_type != ATTACK_COLD))
2912         {
2913                 p_ptr->special_attack &= ~(ATTACK_COLD);
2914 #ifdef JP
2915                 msg_print("Î䵤¤Ç¹¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2916 #else
2917                 msg_print("Your temporary frost brand fades away.");
2918 #endif
2919         }
2920         if ((p_ptr->special_attack & (ATTACK_POIS)) && (attack_type != ATTACK_POIS))
2921         {
2922                 p_ptr->special_attack &= ~(ATTACK_POIS);
2923 #ifdef JP
2924                 msg_print("ÆǤǹ¶·â¤Ç¤­¤Ê¤¯¤Ê¤Ã¤¿¡£");
2925 #else
2926                 msg_print("Your temporary poison brand fades away.");
2927 #endif
2928         }
2929
2930         if ((v) && (attack_type))
2931         {
2932                 /* Set attack type. */
2933                 p_ptr->special_attack |= (attack_type);
2934
2935                 /* Set duration. */
2936                 p_ptr->ele_attack = v;
2937
2938                 /* Message. */
2939 #ifdef JP
2940                 msg_format("%s¤Ç¹¶·â¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡ª",
2941                              ((attack_type == ATTACK_ACID) ? "»À" :
2942                               ((attack_type == ATTACK_ELEC) ? "ÅÅ·â" :
2943                                ((attack_type == ATTACK_FIRE) ? "²Ð±ê" : 
2944                                 ((attack_type == ATTACK_COLD) ? "Î䵤" : 
2945                                  ((attack_type == ATTACK_POIS) ? "ÆÇ" : 
2946                                         "(¤Ê¤·)"))))));
2947 #else
2948                 msg_format("For a while, the blows you deal will %s",
2949                              ((attack_type == ATTACK_ACID) ? "melt with acid!" :
2950                               ((attack_type == ATTACK_ELEC) ? "shock your foes!" :
2951                                ((attack_type == ATTACK_FIRE) ? "burn with fire!" : 
2952                                 ((attack_type == ATTACK_COLD) ? "chill to the bone!" : 
2953                                  ((attack_type == ATTACK_POIS) ? "poison your enemies!" : 
2954                                         "do nothing special."))))));
2955 #endif
2956         }
2957
2958         /* Disturb */
2959         if (disturb_state) disturb(0, 0);
2960
2961         /* Redraw status bar */
2962         p_ptr->redraw |= (PR_STATUS);
2963
2964         p_ptr->update |= (PU_BONUS);
2965
2966         /* Handle stuff */
2967         handle_stuff();
2968
2969         return (TRUE);
2970 }
2971
2972
2973 /*
2974  * Set a temporary elemental brand.  Clear all other brands.  Print status 
2975  * messages. -LM-
2976  */
2977 bool set_ele_immune(u32b immune_type, int v)
2978 {
2979         /* Hack -- Force good values */
2980         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
2981
2982         /* Clear all elemental attacks (only one is allowed at a time). */
2983         if ((p_ptr->special_defense & (DEFENSE_ACID)) && (immune_type != DEFENSE_ACID))
2984         {
2985                 p_ptr->special_defense &= ~(DEFENSE_ACID);
2986 #ifdef JP
2987                 msg_print("»À¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2988 #else
2989                 msg_print("You are no longer immune to acid.");
2990 #endif
2991         }
2992         if ((p_ptr->special_defense & (DEFENSE_ELEC)) && (immune_type != DEFENSE_ELEC))
2993         {
2994                 p_ptr->special_defense &= ~(DEFENSE_ELEC);
2995 #ifdef JP
2996                 msg_print("ÅÅ·â¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
2997 #else
2998                 msg_print("You are no longer immune to electricity.");
2999 #endif
3000         }
3001         if ((p_ptr->special_defense & (DEFENSE_FIRE)) && (immune_type != DEFENSE_FIRE))
3002         {
3003                 p_ptr->special_defense &= ~(DEFENSE_FIRE);
3004 #ifdef JP
3005                 msg_print("²Ð±ê¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
3006 #else
3007                 msg_print("You are no longer immune to fire.");
3008 #endif
3009         }
3010         if ((p_ptr->special_defense & (DEFENSE_COLD)) && (immune_type != DEFENSE_COLD))
3011         {
3012                 p_ptr->special_defense &= ~(DEFENSE_COLD);
3013 #ifdef JP
3014                 msg_print("Î䵤¤Î¹¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
3015 #else
3016                 msg_print("You are no longer immune to cold.");
3017 #endif
3018         }
3019         if ((p_ptr->special_defense & (DEFENSE_POIS)) && (immune_type != DEFENSE_POIS))
3020         {
3021                 p_ptr->special_defense &= ~(DEFENSE_POIS);
3022 #ifdef JP
3023                 msg_print("ÆǤι¶·â¤Ç½ý¤Ä¤±¤é¤ì¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£¡£");
3024 #else
3025                 msg_print("You are no longer immune to poison.");
3026 #endif
3027         }
3028
3029         if ((v) && (immune_type))
3030         {
3031                 /* Set attack type. */
3032                 p_ptr->special_defense |= (immune_type);
3033
3034                 /* Set duration. */
3035                 p_ptr->ele_immune = v;
3036
3037                 /* Message. */
3038 #ifdef JP
3039                 msg_format("%s¤Î¹¶·â¤ò¼õ¤±¤Ä¤±¤Ê¤¯¤Ê¤Ã¤¿¡ª",
3040                              ((immune_type == DEFENSE_ACID) ? "»À" :
3041                               ((immune_type == DEFENSE_ELEC) ? "ÅÅ·â" :
3042                                ((immune_type == DEFENSE_FIRE) ? "²Ð±ê" : 
3043                                 ((immune_type == DEFENSE_COLD) ? "Î䵤" : 
3044                                  ((immune_type == DEFENSE_POIS) ? "ÆÇ" : 
3045                                         "(¤Ê¤·)"))))));
3046 #else
3047                 msg_format("For a while, You are immune to %s",
3048                              ((immune_type == DEFENSE_ACID) ? "acid!" :
3049                               ((immune_type == DEFENSE_ELEC) ? "electricity!" :
3050                                ((immune_type == DEFENSE_FIRE) ? "fire!" : 
3051                                 ((immune_type == DEFENSE_COLD) ? "cold!" : 
3052                                  ((immune_type == DEFENSE_POIS) ? "poison!" : 
3053                                         "do nothing special."))))));
3054 #endif
3055         }
3056
3057         /* Disturb */
3058         if (disturb_state) disturb(0, 0);
3059
3060         /* Redraw status bar */
3061         p_ptr->redraw |= (PR_STATUS);
3062
3063         p_ptr->update |= (PU_BONUS);
3064
3065         /* Handle stuff */
3066         handle_stuff();
3067
3068         return (TRUE);
3069 }
3070
3071
3072 /*
3073  * Set "p_ptr->oppose_acid", notice observable changes
3074  */
3075 bool set_oppose_acid(int v, bool do_dec)
3076 {
3077         bool notice = FALSE;
3078
3079         /* Hack -- Force good values */
3080         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3081
3082         if (p_ptr->is_dead) return FALSE;
3083
3084         /* Open */
3085         if (v)
3086         {
3087                 if (p_ptr->oppose_acid && !do_dec)
3088                 {
3089                         if (p_ptr->oppose_acid > v) return FALSE;
3090                 }
3091                 else if (!IS_OPPOSE_ACID())
3092                 {
3093 #ifdef JP
3094 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3095 #else
3096                         msg_print("You feel resistant to acid!");
3097 #endif
3098
3099                         notice = TRUE;
3100                 }
3101         }
3102
3103         /* Shut */
3104         else
3105         {
3106                 if (p_ptr->oppose_acid && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
3107                 {
3108 #ifdef JP
3109 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3110 #else
3111                         msg_print("You feel less resistant to acid.");
3112 #endif
3113
3114                         notice = TRUE;
3115                 }
3116         }
3117
3118         /* Use the value */
3119         p_ptr->oppose_acid = v;
3120
3121         /* Nothing to notice */
3122         if (!notice) return (FALSE);
3123
3124         /* Redraw status bar */
3125         p_ptr->redraw |= (PR_STATUS);
3126
3127         /* Disturb */
3128         if (disturb_state) disturb(0, 0);
3129
3130         /* Handle stuff */
3131         handle_stuff();
3132
3133         /* Result */
3134         return (TRUE);
3135 }
3136
3137
3138 /*
3139  * Set "p_ptr->oppose_elec", notice observable changes
3140  */
3141 bool set_oppose_elec(int v, bool do_dec)
3142 {
3143         bool notice = FALSE;
3144
3145         /* Hack -- Force good values */
3146         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3147
3148         if (p_ptr->is_dead) return FALSE;
3149
3150         /* Open */
3151         if (v)
3152         {
3153                 if (p_ptr->oppose_elec && !do_dec)
3154                 {
3155                         if (p_ptr->oppose_elec > v) return FALSE;
3156                 }
3157                 else if (!IS_OPPOSE_ELEC())
3158                 {
3159 #ifdef JP
3160 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3161 #else
3162                         msg_print("You feel resistant to electricity!");
3163 #endif
3164
3165                         notice = TRUE;
3166                 }
3167         }
3168
3169         /* Shut */
3170         else
3171         {
3172                 if (p_ptr->oppose_elec && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
3173                 {
3174 #ifdef JP
3175 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3176 #else
3177                         msg_print("You feel less resistant to electricity.");
3178 #endif
3179
3180                         notice = TRUE;
3181                 }
3182         }
3183
3184         /* Use the value */
3185         p_ptr->oppose_elec = v;
3186
3187         /* Nothing to notice */
3188         if (!notice) return (FALSE);
3189
3190         /* Redraw status bar */
3191         p_ptr->redraw |= (PR_STATUS);
3192
3193         /* Disturb */
3194         if (disturb_state) disturb(0, 0);
3195
3196         /* Handle stuff */
3197         handle_stuff();
3198
3199         /* Result */
3200         return (TRUE);
3201 }
3202
3203
3204 /*
3205  * Set "p_ptr->oppose_fire", notice observable changes
3206  */
3207 bool set_oppose_fire(int v, bool do_dec)
3208 {
3209         bool notice = FALSE;
3210
3211         /* Hack -- Force good values */
3212         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3213
3214         if (p_ptr->is_dead) return FALSE;
3215
3216         if ((prace_is_(RACE_DEMON) && (p_ptr->lev > 44)) || (p_ptr->mimic_form == MIMIC_DEMON)) v = 1;
3217         /* Open */
3218         if (v)
3219         {
3220                 if (p_ptr->oppose_fire && !do_dec)
3221                 {
3222                         if (p_ptr->oppose_fire > v) return FALSE;
3223                 }
3224                 else if (!IS_OPPOSE_FIRE())
3225                 {
3226 #ifdef JP
3227 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3228 #else
3229                         msg_print("You feel resistant to fire!");
3230 #endif
3231
3232                         notice = TRUE;
3233                 }
3234         }
3235
3236         /* Shut */
3237         else
3238         {
3239                 if (p_ptr->oppose_fire && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
3240                 {
3241 #ifdef JP
3242 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3243 #else
3244                         msg_print("You feel less resistant to fire.");
3245 #endif
3246
3247                         notice = TRUE;
3248                 }
3249         }
3250
3251         /* Use the value */
3252         p_ptr->oppose_fire = v;
3253
3254         /* Nothing to notice */
3255         if (!notice) return (FALSE);
3256
3257         /* Redraw status bar */
3258         p_ptr->redraw |= (PR_STATUS);
3259
3260         /* Disturb */
3261         if (disturb_state) disturb(0, 0);
3262
3263         /* Handle stuff */
3264         handle_stuff();
3265
3266         /* Result */
3267         return (TRUE);
3268 }
3269
3270
3271 /*
3272  * Set "p_ptr->oppose_cold", notice observable changes
3273  */
3274 bool set_oppose_cold(int v, bool do_dec)
3275 {
3276         bool notice = FALSE;
3277
3278         /* Hack -- Force good values */
3279         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3280
3281         if (p_ptr->is_dead) return FALSE;
3282
3283         /* Open */
3284         if (v)
3285         {
3286                 if (p_ptr->oppose_cold && !do_dec)
3287                 {
3288                         if (p_ptr->oppose_cold > v) return FALSE;
3289                 }
3290                 else if (!IS_OPPOSE_COLD())
3291                 {
3292 #ifdef JP
3293 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3294 #else
3295                         msg_print("You feel resistant to cold!");
3296 #endif
3297
3298                         notice = TRUE;
3299                 }
3300         }
3301
3302         /* Shut */
3303         else
3304         {
3305                 if (p_ptr->oppose_cold && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
3306                 {
3307 #ifdef JP
3308 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3309 #else
3310                         msg_print("You feel less resistant to cold.");
3311 #endif
3312
3313                         notice = TRUE;
3314                 }
3315         }
3316
3317         /* Use the value */
3318         p_ptr->oppose_cold = v;
3319
3320         /* Nothing to notice */
3321         if (!notice) return (FALSE);
3322
3323         /* Redraw status bar */
3324         p_ptr->redraw |= (PR_STATUS);
3325
3326         /* Disturb */
3327         if (disturb_state) disturb(0, 0);
3328
3329         /* Handle stuff */
3330         handle_stuff();
3331
3332         /* Result */
3333         return (TRUE);
3334 }
3335
3336
3337 /*
3338  * Set "p_ptr->oppose_pois", notice observable changes
3339  */
3340 bool set_oppose_pois(int v, bool do_dec)
3341 {
3342         bool notice = FALSE;
3343
3344         /* Hack -- Force good values */
3345         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3346
3347         if ((p_ptr->pclass == CLASS_NINJA) && (p_ptr->lev > 44)) v = 1;
3348         if (p_ptr->is_dead) return FALSE;
3349
3350         /* Open */
3351         if (v)
3352         {
3353                 if (p_ptr->oppose_pois && !do_dec)
3354                 {
3355                         if (p_ptr->oppose_pois > v) return FALSE;
3356                 }
3357                 else if (!IS_OPPOSE_POIS())
3358                 {
3359 #ifdef JP
3360 msg_print("ÆǤؤÎÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
3361 #else
3362                         msg_print("You feel resistant to poison!");
3363 #endif
3364
3365                         notice = TRUE;
3366                 }
3367         }
3368
3369         /* Shut */
3370         else
3371         {
3372                 if (p_ptr->oppose_pois && !music_singing(MUSIC_RESIST) && !(p_ptr->special_defense & KATA_MUSOU))
3373                 {
3374 #ifdef JP
3375 msg_print("ÆǤؤÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3376 #else
3377                         msg_print("You feel less resistant to poison.");
3378 #endif
3379
3380                         notice = TRUE;
3381                 }
3382         }
3383
3384         /* Use the value */
3385         p_ptr->oppose_pois = v;
3386
3387         /* Nothing to notice */
3388         if (!notice) return (FALSE);
3389
3390         /* Redraw status bar */
3391         p_ptr->redraw |= (PR_STATUS);
3392
3393         /* Disturb */
3394         if (disturb_state) disturb(0, 0);
3395
3396         /* Handle stuff */
3397         handle_stuff();
3398
3399         /* Result */
3400         return (TRUE);
3401 }
3402
3403
3404 /*
3405  * Set "p_ptr->stun", notice observable changes
3406  *
3407  * Note the special code to only notice "range" changes.
3408  */
3409 bool set_stun(int v)
3410 {
3411         int old_aux, new_aux;
3412         bool notice = FALSE;
3413
3414
3415         /* Hack -- Force good values */
3416         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3417
3418         if (p_ptr->is_dead) return FALSE;
3419
3420         if (prace_is_(RACE_GOLEM) || ((p_ptr->pclass == CLASS_BERSERKER) && (p_ptr->lev > 34))) v = 0;
3421
3422         /* Knocked out */
3423         if (p_ptr->stun > 100)
3424         {
3425                 old_aux = 3;
3426         }
3427
3428         /* Heavy stun */
3429         else if (p_ptr->stun > 50)
3430         {
3431                 old_aux = 2;
3432         }
3433
3434         /* Stun */
3435         else if (p_ptr->stun > 0)
3436         {
3437                 old_aux = 1;
3438         }
3439
3440         /* None */
3441         else
3442         {
3443                 old_aux = 0;
3444         }
3445
3446         /* Knocked out */
3447         if (v > 100)
3448         {
3449                 new_aux = 3;
3450         }
3451
3452         /* Heavy stun */
3453         else if (v > 50)
3454         {
3455                 new_aux = 2;
3456         }
3457
3458         /* Stun */
3459         else if (v > 0)
3460         {
3461                 new_aux = 1;
3462         }
3463
3464         /* None */
3465         else
3466         {
3467                 new_aux = 0;
3468         }
3469
3470         /* Increase cut */
3471         if (new_aux > old_aux)
3472         {
3473                 /* Describe the state */
3474                 switch (new_aux)
3475                 {
3476                         /* Stun */
3477                         case 1:
3478 #ifdef JP
3479 msg_print("°Õ¼±¤¬¤â¤¦¤í¤¦¤È¤·¤Æ¤­¤¿¡£");
3480 #else
3481                         msg_print("You have been stunned.");
3482 #endif
3483
3484                         break;
3485
3486                         /* Heavy stun */
3487                         case 2:
3488 #ifdef JP
3489 msg_print("°Õ¼±¤¬¤Ò¤É¤¯¤â¤¦¤í¤¦¤È¤·¤Æ¤­¤¿¡£");
3490 #else
3491                         msg_print("You have been heavily stunned.");
3492 #endif
3493
3494                         break;
3495
3496                         /* Knocked out */
3497                         case 3:
3498 #ifdef JP
3499 msg_print("Ƭ¤¬¥¯¥é¥¯¥é¤·¤Æ°Õ¼±¤¬±ó¤Î¤¤¤Æ¤­¤¿¡£");
3500 #else
3501                         msg_print("You have been knocked out.");
3502 #endif
3503
3504                         break;
3505                 }
3506
3507                 if (randint1(1000) < v || one_in_(16))
3508                 {
3509 #ifdef JP
3510 msg_print("³ä¤ì¤ë¤è¤¦¤ÊƬÄˤ¬¤¹¤ë¡£");
3511 #else
3512                         msg_print("A vicious blow hits your head.");
3513 #endif
3514
3515                         if (one_in_(3))
3516                         {
3517                                 if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
3518                                 if (!p_ptr->sustain_wis) (void)do_dec_stat(A_WIS);
3519                         }
3520                         else if (one_in_(2))
3521                         {
3522                                 if (!p_ptr->sustain_int) (void)do_dec_stat(A_INT);
3523                         }
3524                         else
3525                         {
3526                                 if (!p_ptr->sustain_wis) (void)do_dec_stat(A_WIS);
3527                         }
3528                 }
3529                 if (p_ptr->special_defense & KATA_MASK)
3530                 {
3531 #ifdef JP
3532                         msg_print("·¿¤¬Êø¤ì¤¿¡£");
3533 #else
3534                         msg_print("Your posture gets loose.");
3535 #endif
3536                         p_ptr->special_defense &= ~(KATA_MASK);
3537                         p_ptr->update |= (PU_BONUS);
3538                         p_ptr->update |= (PU_MONSTERS);
3539                         p_ptr->redraw |= (PR_STATE);
3540                         p_ptr->redraw |= (PR_STATUS);
3541                         p_ptr->action = ACTION_NONE;
3542                 }
3543
3544                 /* Notice */
3545                 notice = TRUE;
3546         }
3547
3548         /* Decrease cut */
3549         else if (new_aux < old_aux)
3550         {
3551                 /* Describe the state */
3552                 switch (new_aux)
3553                 {
3554                         /* None */
3555                         case 0:
3556 #ifdef JP
3557 msg_print("¤ä¤Ã¤ÈÛ¯Û°¾õÂÖ¤«¤é²óÉü¤·¤¿¡£");
3558 #else
3559                         msg_print("You are no longer stunned.");
3560 #endif
3561
3562                         if (disturb_state) disturb(0, 0);
3563                         break;
3564                 }
3565
3566                 /* Notice */
3567                 notice = TRUE;
3568         }
3569
3570         /* Use the value */
3571         p_ptr->stun = v;
3572
3573         /* No change */
3574         if (!notice) return (FALSE);
3575
3576         /* Disturb */
3577         if (disturb_state) disturb(0, 0);
3578
3579         /* Recalculate bonuses */
3580         p_ptr->update |= (PU_BONUS);
3581
3582         /* Redraw the "stun" */
3583         p_ptr->redraw |= (PR_STUN);
3584
3585         /* Handle stuff */
3586         handle_stuff();
3587
3588         /* Result */
3589         return (TRUE);
3590 }
3591
3592
3593 /*
3594  * Set "p_ptr->cut", notice observable changes
3595  *
3596  * Note the special code to only notice "range" changes.
3597  */
3598 bool set_cut(int v)
3599 {
3600         int old_aux, new_aux;
3601         bool notice = FALSE;
3602
3603         /* Hack -- Force good values */
3604         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
3605
3606         if (p_ptr->is_dead) return FALSE;
3607
3608         if ((p_ptr->prace == RACE_GOLEM ||
3609             p_ptr->prace == RACE_SKELETON ||
3610             p_ptr->prace == RACE_SPECTRE ||
3611                 (p_ptr->prace == RACE_ZOMBIE && p_ptr->lev > 11)) &&
3612             !p_ptr->mimic_form)
3613                 v = 0;
3614
3615         /* Mortal wound */
3616         if (p_ptr->cut > 1000)
3617         {
3618                 old_aux = 7;
3619         }
3620
3621         /* Deep gash */
3622         else if (p_ptr->cut > 200)
3623         {
3624                 old_aux = 6;
3625         }
3626
3627         /* Severe cut */
3628         else if (p_ptr->cut > 100)
3629         {
3630                 old_aux = 5;
3631         }
3632
3633         /* Nasty cut */
3634         else if (p_ptr->cut > 50)
3635         {
3636                 old_aux = 4;
3637         }
3638
3639         /* Bad cut */
3640         else if (p_ptr->cut > 25)
3641         {
3642                 old_aux = 3;
3643         }
3644
3645         /* Light cut */
3646         else if (p_ptr->cut > 10)
3647         {
3648                 old_aux = 2;
3649         }
3650
3651         /* Graze */
3652         else if (p_ptr->cut > 0)
3653         {
3654                 old_aux = 1;
3655         }
3656
3657         /* None */
3658         else
3659         {
3660                 old_aux = 0;
3661         }
3662
3663         /* Mortal wound */
3664         if (v > 1000)
3665         {
3666                 new_aux = 7;
3667         }
3668
3669         /* Deep gash */
3670         else if (v > 200)
3671         {
3672                 new_aux = 6;
3673         }
3674
3675         /* Severe cut */
3676         else if (v > 100)
3677         {
3678                 new_aux = 5;
3679         }
3680
3681         /* Nasty cut */
3682         else if (v > 50)
3683         {
3684                 new_aux = 4;
3685         }
3686
3687         /* Bad cut */
3688         else if (v > 25)
3689         {
3690                 new_aux = 3;
3691         }
3692
3693         /* Light cut */
3694         else if (v > 10)
3695         {
3696                 new_aux = 2;
3697         }
3698
3699         /* Graze */
3700         else if (v > 0)
3701         {
3702                 new_aux = 1;
3703         }
3704
3705         /* None */
3706         else
3707         {
3708                 new_aux = 0;
3709         }
3710
3711         /* Increase cut */
3712         if (new_aux > old_aux)
3713         {
3714                 /* Describe the state */
3715                 switch (new_aux)
3716                 {
3717                         /* Graze */
3718                         case 1:
3719 #ifdef JP
3720 msg_print("¤«¤¹¤ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3721 #else
3722                         msg_print("You have been given a graze.");
3723 #endif
3724
3725                         break;
3726
3727                         /* Light cut */
3728                         case 2:
3729 #ifdef JP
3730 msg_print("·Ú¤¤½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3731 #else
3732                         msg_print("You have been given a light cut.");
3733 #endif
3734
3735                         break;
3736
3737                         /* Bad cut */
3738                         case 3:
3739 #ifdef JP
3740 msg_print("¤Ò¤É¤¤½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3741 #else
3742                         msg_print("You have been given a bad cut.");
3743 #endif
3744
3745                         break;
3746
3747                         /* Nasty cut */
3748                         case 4:
3749 #ifdef JP
3750 msg_print("ÂçÊѤʽý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3751 #else
3752                         msg_print("You have been given a nasty cut.");
3753 #endif
3754
3755                         break;
3756
3757                         /* Severe cut */
3758                         case 5:
3759 #ifdef JP
3760 msg_print("½ÅÂç¤Ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3761 #else
3762                         msg_print("You have been given a severe cut.");
3763 #endif
3764
3765                         break;
3766
3767                         /* Deep gash */
3768                         case 6:
3769 #ifdef JP
3770 msg_print("¤Ò¤É¤¤¿¼¼ê¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3771 #else
3772                         msg_print("You have been given a deep gash.");
3773 #endif
3774
3775                         break;
3776
3777                         /* Mortal wound */
3778                         case 7:
3779 #ifdef JP
3780 msg_print("Ã×̿Ū¤Ê½ý¤òÉé¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3781 #else
3782                         msg_print("You have been given a mortal wound.");
3783 #endif
3784
3785                         break;
3786                 }
3787
3788                 /* Notice */
3789                 notice = TRUE;
3790
3791                 if (randint1(1000) < v || one_in_(16))
3792                 {
3793                         if (!p_ptr->sustain_chr)
3794                         {
3795 #ifdef JP
3796 msg_print("¤Ò¤É¤¤½ýÀפ¬»Ä¤Ã¤Æ¤·¤Þ¤Ã¤¿¡£");
3797 #else
3798                                 msg_print("You have been horribly scarred.");
3799 #endif
3800
3801
3802                                 do_dec_stat(A_CHR);
3803                         }
3804                 }
3805         }
3806
3807         /* Decrease cut */
3808         else if (new_aux < old_aux)
3809         {
3810                 /* Describe the state */
3811                 switch (new_aux)
3812                 {
3813                         /* None */
3814                         case 0:
3815 #ifdef JP
3816 msg_format("¤ä¤Ã¤È%s¡£", p_ptr->prace == RACE_ANDROID ? "²ø²æ¤¬Ä¾¤Ã¤¿" : "½Ð·ì¤¬»ß¤Þ¤Ã¤¿");
3817 #else
3818                         msg_print("You are no longer bleeding.");
3819 #endif
3820
3821                         if (disturb_state) disturb(0, 0);
3822                         break;
3823                 }
3824
3825                 /* Notice */
3826                 notice = TRUE;
3827         }
3828
3829         /* Use the value */
3830         p_ptr->cut = v;
3831
3832         /* No change */
3833         if (!notice) return (FALSE);
3834
3835         /* Disturb */
3836         if (disturb_state) disturb(0, 0);
3837
3838         /* Recalculate bonuses */
3839         p_ptr->update |= (PU_BONUS);
3840
3841         /* Redraw the "cut" */
3842         p_ptr->redraw |= (PR_CUT);
3843
3844         /* Handle stuff */
3845         handle_stuff();
3846
3847         /* Result */
3848         return (TRUE);
3849 }
3850
3851
3852 /*
3853  * Set "p_ptr->food", notice observable changes
3854  *
3855  * The "p_ptr->food" variable can get as large as 20000, allowing the
3856  * addition of the most "filling" item, Elvish Waybread, which adds
3857  * 7500 food units, without overflowing the 32767 maximum limit.
3858  *
3859  * Perhaps we should disturb the player with various messages,
3860  * especially messages about hunger status changes.  XXX XXX XXX
3861  *
3862  * Digestion of food is handled in "dungeon.c", in which, normally,
3863  * the player digests about 20 food units per 100 game turns, more
3864  * when "fast", more when "regenerating", less with "slow digestion",
3865  * but when the player is "gorged", he digests 100 food units per 10
3866  * game turns, or a full 1000 food units per 100 game turns.
3867  *
3868  * Note that the player's speed is reduced by 10 units while gorged,
3869  * so if the player eats a single food ration (5000 food units) when
3870  * full (15000 food units), he will be gorged for (5000/100)*10 = 500
3871  * game turns, or 500/(100/5) = 25 player turns (if nothing else is
3872  * affecting the player speed).
3873  */
3874 bool set_food(int v)
3875 {
3876         int old_aux, new_aux;
3877
3878         bool notice = FALSE;
3879
3880         /* Hack -- Force good values */
3881         v = (v > 20000) ? 20000 : (v < 0) ? 0 : v;
3882
3883         /* Fainting / Starving */
3884         if (p_ptr->food < PY_FOOD_FAINT)
3885         {
3886                 old_aux = 0;
3887         }
3888
3889         /* Weak */
3890         else if (p_ptr->food < PY_FOOD_WEAK)
3891         {
3892                 old_aux = 1;
3893         }
3894
3895         /* Hungry */
3896         else if (p_ptr->food < PY_FOOD_ALERT)
3897         {
3898                 old_aux = 2;
3899         }
3900
3901         /* Normal */
3902         else if (p_ptr->food < PY_FOOD_FULL)
3903         {
3904                 old_aux = 3;
3905         }
3906
3907         /* Full */
3908         else if (p_ptr->food < PY_FOOD_MAX)
3909         {
3910                 old_aux = 4;
3911         }
3912
3913         /* Gorged */
3914         else
3915         {
3916                 old_aux = 5;
3917         }
3918
3919         /* Fainting / Starving */
3920         if (v < PY_FOOD_FAINT)
3921         {
3922                 new_aux = 0;
3923         }
3924
3925         /* Weak */
3926         else if (v < PY_FOOD_WEAK)
3927         {
3928                 new_aux = 1;
3929         }
3930
3931         /* Hungry */
3932         else if (v < PY_FOOD_ALERT)
3933         {
3934                 new_aux = 2;
3935         }
3936
3937         /* Normal */
3938         else if (v < PY_FOOD_FULL)
3939         {
3940                 new_aux = 3;
3941         }
3942
3943         /* Full */
3944         else if (v < PY_FOOD_MAX)
3945         {
3946                 new_aux = 4;
3947         }
3948
3949         /* Gorged */
3950         else
3951         {
3952                 new_aux = 5;
3953         }
3954
3955         if (old_aux < 1 && new_aux > 0)
3956                 chg_virtue(V_PATIENCE, 2);
3957         else if (old_aux < 3 && (old_aux != new_aux))
3958                 chg_virtue(V_PATIENCE, 1);
3959         if (old_aux == 2)
3960                 chg_virtue(V_TEMPERANCE, 1);
3961         if (old_aux == 0)
3962                 chg_virtue(V_TEMPERANCE, -1);
3963
3964         /* Food increase */
3965         if (new_aux > old_aux)
3966         {
3967                 /* Describe the state */
3968                 switch (new_aux)
3969                 {
3970                         /* Weak */
3971                         case 1:
3972 #ifdef JP
3973 msg_print("¤Þ¤À¶õÊ¢¤ÇÅݤ줽¤¦¤À¡£");
3974 #else
3975                         msg_print("You are still weak.");
3976 #endif
3977
3978                         break;
3979
3980                         /* Hungry */
3981                         case 2:
3982 #ifdef JP
3983 msg_print("¤Þ¤À¶õÊ¢¤À¡£");
3984 #else
3985                         msg_print("You are still hungry.");
3986 #endif
3987
3988                         break;
3989
3990                         /* Normal */
3991                         case 3:
3992 #ifdef JP
3993 msg_print("¶õÊ¢´¶¤¬¤ª¤µ¤Þ¤Ã¤¿¡£");
3994 #else
3995                         msg_print("You are no longer hungry.");
3996 #endif
3997
3998                         break;
3999
4000                         /* Full */
4001                         case 4:
4002 #ifdef JP
4003 msg_print("ËþÊ¢¤À¡ª");
4004 #else
4005                         msg_print("You are full!");
4006 #endif
4007
4008                         break;
4009
4010                         /* Bloated */
4011                         case 5:
4012 #ifdef JP
4013 msg_print("¿©¤Ù²á¤®¤À¡ª");
4014 #else
4015                         msg_print("You have gorged yourself!");
4016 #endif
4017                         chg_virtue(V_HARMONY, -1);
4018                         chg_virtue(V_PATIENCE, -1);
4019                         chg_virtue(V_TEMPERANCE, -2);
4020
4021                         break;
4022                 }
4023
4024                 /* Change */
4025                 notice = TRUE;
4026         }
4027
4028         /* Food decrease */
4029         else if (new_aux < old_aux)
4030         {
4031                 /* Describe the state */
4032                 switch (new_aux)
4033                 {
4034                         /* Fainting / Starving */
4035                         case 0:
4036 #ifdef JP
4037 msg_print("¤¢¤Þ¤ê¤Ë¤â¶õÊ¢¤Çµ¤¤ò¼º¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
4038 #else
4039                         msg_print("You are getting faint from hunger!");
4040 #endif
4041
4042                         break;
4043
4044                         /* Weak */
4045                         case 1:
4046 #ifdef JP
4047 msg_print("¤ªÊ¢¤¬¶õ¤¤¤ÆÅݤ줽¤¦¤À¡£");
4048 #else
4049                         msg_print("You are getting weak from hunger!");
4050 #endif
4051
4052                         break;
4053
4054                         /* Hungry */
4055                         case 2:
4056 #ifdef JP
4057 msg_print("¤ªÊ¢¤¬¶õ¤¤¤Æ¤­¤¿¡£");
4058 #else
4059                         msg_print("You are getting hungry.");
4060 #endif
4061
4062                         break;
4063
4064                         /* Normal */
4065                         case 3:
4066 #ifdef JP
4067 msg_print("ËþÊ¢´¶¤¬¤Ê¤¯¤Ê¤Ã¤¿¡£");
4068 #else
4069                         msg_print("You are no longer full.");
4070 #endif
4071
4072                         break;
4073
4074                         /* Full */
4075                         case 4:
4076 #ifdef JP
4077 msg_print("¤ä¤Ã¤È¤ªÊ¢¤¬¤­¤Ä¤¯¤Ê¤¯¤Ê¤Ã¤¿¡£");
4078 #else
4079                         msg_print("You are no longer gorged.");
4080 #endif
4081
4082                         break;
4083                 }
4084
4085                 if (p_ptr->wild_mode && (new_aux < 2))
4086                 {
4087                         change_wild_mode();
4088                 }
4089
4090                 /* Change */
4091                 notice = TRUE;
4092         }
4093
4094         /* Use the value */
4095         p_ptr->food = v;
4096
4097         /* Nothing to notice */
4098         if (!notice) return (FALSE);
4099
4100         /* Disturb */
4101         if (disturb_state) disturb(0, 0);
4102
4103         /* Recalculate bonuses */
4104         p_ptr->update |= (PU_BONUS);
4105
4106         /* Redraw hunger */
4107         p_ptr->redraw |= (PR_HUNGER);
4108
4109         /* Handle stuff */
4110         handle_stuff();
4111
4112         /* Result */
4113         return (TRUE);
4114 }
4115
4116 /*
4117  * Increases a stat by one randomized level             -RAK-
4118  *
4119  * Note that this function (used by stat potions) now restores
4120  * the stat BEFORE increasing it.
4121  */
4122 bool inc_stat(int stat)
4123 {
4124         int value, gain;
4125
4126         /* Then augment the current/max stat */
4127         value = p_ptr->stat_cur[stat];
4128
4129         /* Cannot go above 18/100 */
4130         if (value < p_ptr->stat_max_max[stat])
4131         {
4132                 /* Gain one (sometimes two) points */
4133                 if (value < 18)
4134                 {
4135                         gain = ((randint0(100) < 75) ? 1 : 2);
4136                         value += gain;
4137                 }
4138
4139                 /* Gain 1/6 to 1/3 of distance to 18/100 */
4140                 else if (value < (p_ptr->stat_max_max[stat]-2))
4141                 {
4142                         /* Approximate gain value */
4143                         gain = (((p_ptr->stat_max_max[stat]) - value) / 2 + 3) / 2;
4144
4145                         /* Paranoia */
4146                         if (gain < 1) gain = 1;
4147
4148                         /* Apply the bonus */
4149                         value += randint1(gain) + gain / 2;
4150
4151                         /* Maximal value */
4152                         if (value > (p_ptr->stat_max_max[stat]-1)) value = p_ptr->stat_max_max[stat]-1;
4153                 }
4154
4155                 /* Gain one point at a time */
4156                 else
4157                 {
4158                         value++;
4159                 }
4160
4161                 /* Save the new value */
4162                 p_ptr->stat_cur[stat] = value;
4163
4164                 /* Bring up the maximum too */
4165                 if (value > p_ptr->stat_max[stat])
4166                 {
4167                         p_ptr->stat_max[stat] = value;
4168                 }
4169
4170                 /* Recalculate bonuses */
4171                 p_ptr->update |= (PU_BONUS);
4172
4173                 /* Success */
4174                 return (TRUE);
4175         }
4176
4177         /* Nothing to gain */
4178         return (FALSE);
4179 }
4180
4181
4182
4183 /*
4184  * Decreases a stat by an amount indended to vary from 0 to 100 percent.
4185  *
4186  * Amount could be a little higher in extreme cases to mangle very high
4187  * stats from massive assaults.  -CWS
4188  *
4189  * Note that "permanent" means that the *given* amount is permanent,
4190  * not that the new value becomes permanent.  This may not work exactly
4191  * as expected, due to "weirdness" in the algorithm, but in general,
4192  * if your stat is already drained, the "max" value will not drop all
4193  * the way down to the "cur" value.
4194  */
4195 bool dec_stat(int stat, int amount, int permanent)
4196 {
4197         int cur, max, loss, same, res = FALSE;
4198
4199
4200         /* Acquire current value */
4201         cur = p_ptr->stat_cur[stat];
4202         max = p_ptr->stat_max[stat];
4203
4204         /* Note when the values are identical */
4205         same = (cur == max);
4206
4207         /* Damage "current" value */
4208         if (cur > 3)
4209         {
4210                 /* Handle "low" values */
4211                 if (cur <= 18)
4212                 {
4213                         if (amount > 90) cur--;
4214                         if (amount > 50) cur--;
4215                         if (amount > 20) cur--;
4216                         cur--;
4217                 }
4218
4219                 /* Handle "high" values */
4220                 else
4221                 {
4222                         /* Hack -- Decrement by a random amount between one-quarter */
4223                         /* and one-half of the stat bonus times the percentage, with a */
4224                         /* minimum damage of half the percentage. -CWS */
4225                         loss = (((cur-18) / 2 + 1) / 2 + 1);
4226
4227                         /* Paranoia */
4228                         if (loss < 1) loss = 1;
4229
4230                         /* Randomize the loss */
4231                         loss = ((randint1(loss) + loss) * amount) / 100;
4232
4233                         /* Maximal loss */
4234                         if (loss < amount/2) loss = amount/2;
4235
4236                         /* Lose some points */
4237                         cur = cur - loss;
4238
4239                         /* Hack -- Only reduce stat to 17 sometimes */
4240                         if (cur < 18) cur = (amount <= 20) ? 18 : 17;
4241                 }
4242
4243                 /* Prevent illegal values */
4244                 if (cur < 3) cur = 3;
4245
4246                 /* Something happened */
4247                 if (cur != p_ptr->stat_cur[stat]) res = TRUE;
4248         }
4249
4250         /* Damage "max" value */
4251         if (permanent && (max > 3))
4252         {
4253                 chg_virtue(V_SACRIFICE, 1);
4254                 if (stat == A_WIS || stat == A_INT)
4255                         chg_virtue(V_ENLIGHTEN, -2);
4256
4257                 /* Handle "low" values */
4258                 if (max <= 18)
4259                 {
4260                         if (amount > 90) max--;
4261                         if (amount > 50) max--;
4262                         if (amount > 20) max--;
4263                         max--;
4264                 }
4265
4266                 /* Handle "high" values */
4267                 else
4268                 {
4269                         /* Hack -- Decrement by a random amount between one-quarter */
4270                         /* and one-half of the stat bonus times the percentage, with a */
4271                         /* minimum damage of half the percentage. -CWS */
4272                         loss = (((max-18) / 2 + 1) / 2 + 1);
4273                         loss = ((randint1(loss) + loss) * amount) / 100;
4274                         if (loss < amount/2) loss = amount/2;
4275
4276                         /* Lose some points */
4277                         max = max - loss;
4278
4279                         /* Hack -- Only reduce stat to 17 sometimes */
4280                         if (max < 18) max = (amount <= 20) ? 18 : 17;
4281                 }
4282
4283                 /* Hack -- keep it clean */
4284                 if (same || (max < cur)) max = cur;
4285
4286                 /* Something happened */
4287                 if (max != p_ptr->stat_max[stat]) res = TRUE;
4288         }
4289
4290         /* Apply changes */
4291         if (res)
4292         {
4293                 /* Actually set the stat to its new value. */
4294                 p_ptr->stat_cur[stat] = cur;
4295                 p_ptr->stat_max[stat] = max;
4296
4297                 /* Redisplay the stats later */
4298                 p_ptr->redraw |= (PR_STATS);
4299
4300                 /* Recalculate bonuses */
4301                 p_ptr->update |= (PU_BONUS);
4302         }
4303
4304         /* Done */
4305         return (res);
4306 }
4307
4308
4309 /*
4310  * Restore a stat.  Return TRUE only if this actually makes a difference.
4311  */
4312 bool res_stat(int stat)
4313 {
4314         /* Restore if needed */
4315         if (p_ptr->stat_cur[stat] != p_ptr->stat_max[stat])
4316         {
4317                 /* Restore */
4318                 p_ptr->stat_cur[stat] = p_ptr->stat_max[stat];
4319
4320                 /* Recalculate bonuses */
4321                 p_ptr->update |= (PU_BONUS);
4322
4323                 /* Redisplay the stats later */
4324                 p_ptr->redraw |= (PR_STATS);
4325
4326                 /* Success */
4327                 return (TRUE);
4328         }
4329
4330         /* Nothing to restore */
4331         return (FALSE);
4332 }
4333
4334
4335 /*
4336  * Increase players hit points, notice effects
4337  */
4338 bool hp_player(int num)
4339 {
4340         int vir;
4341         vir = virtue_number(V_VITALITY);
4342         if (vir)
4343         {
4344                 num = num * (p_ptr->virtues[vir - 1] + 1250) / 1250;
4345         }
4346         /* Healing needed */
4347         if (p_ptr->chp < p_ptr->mhp)
4348         {
4349                 if ((num > 0) && (p_ptr->chp < (p_ptr->mhp/3)))
4350                         chg_virtue(V_TEMPERANCE, 1);
4351                 /* Gain hitpoints */
4352                 p_ptr->chp += num;
4353
4354                 /* Enforce maximum */
4355                 if (p_ptr->chp >= p_ptr->mhp)
4356                 {
4357                         p_ptr->chp = p_ptr->mhp;
4358                         p_ptr->chp_frac = 0;
4359                 }
4360
4361                 /* Redraw */
4362                 p_ptr->redraw |= (PR_HP);
4363
4364                 /* Window stuff */
4365                 p_ptr->window |= (PW_PLAYER);
4366
4367                 /* Heal 0-4 */
4368                 if (num < 5)
4369                 {
4370 #ifdef JP
4371 msg_print("¾¯¤·µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4372 #else
4373                         msg_print("You feel a little better.");
4374 #endif
4375
4376                 }
4377
4378                 /* Heal 5-14 */
4379                 else if (num < 15)
4380                 {
4381 #ifdef JP
4382 msg_print("µ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4383 #else
4384                         msg_print("You feel better.");
4385 #endif
4386
4387                 }
4388
4389                 /* Heal 15-34 */
4390                 else if (num < 35)
4391                 {
4392 #ifdef JP
4393 msg_print("¤È¤Æ¤âµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4394 #else
4395                         msg_print("You feel much better.");
4396 #endif
4397
4398                 }
4399
4400                 /* Heal 35+ */
4401                 else
4402                 {
4403 #ifdef JP
4404 msg_print("¤Ò¤¸¤ç¤¦¤Ëµ¤Ê¬¤¬Îɤ¯¤Ê¤Ã¤¿¡£");
4405 #else
4406                         msg_print("You feel very good.");
4407 #endif
4408
4409                 }
4410
4411                 /* Notice */
4412                 return (TRUE);
4413         }
4414
4415         /* Ignore */
4416         return (FALSE);
4417 }
4418
4419
4420 /*
4421  * Array of stat "descriptions"
4422  */
4423 static cptr desc_stat_pos[] =
4424 {
4425 #ifdef JP
4426 "¶¯¤¯",
4427 #else
4428         "strong",
4429 #endif
4430
4431 #ifdef JP
4432 "ÃÎŪ¤Ë",
4433 #else
4434         "smart",
4435 #endif
4436
4437 #ifdef JP
4438 "¸­¤¯",
4439 #else
4440         "wise",
4441 #endif
4442
4443 #ifdef JP
4444 "´ïÍѤË",
4445 #else
4446         "dextrous",
4447 #endif
4448
4449 #ifdef JP
4450 "·ò¹¯¤Ë",
4451 #else
4452         "healthy",
4453 #endif
4454
4455 #ifdef JP
4456 "Èþ¤·¤¯"
4457 #else
4458         "cute"
4459 #endif
4460
4461 };
4462
4463
4464 /*
4465  * Array of stat "descriptions"
4466  */
4467 static cptr desc_stat_neg[] =
4468 {
4469 #ifdef JP
4470 "¼å¤¯",
4471 "̵ÃΤË",
4472 "¶ò¤«¤Ë",
4473 "ÉÔ´ïÍѤË",
4474 "ÉÔ·ò¹¯¤Ë",
4475 "½¹¤¯"
4476 #else
4477         "weak",
4478         "stupid",
4479         "naive",
4480         "clumsy",
4481         "sickly",
4482         "ugly"
4483 #endif
4484
4485 };
4486
4487
4488 /*
4489  * Lose a "point"
4490  */
4491 bool do_dec_stat(int stat)
4492 {
4493         bool sust = FALSE;
4494
4495         /* Access the "sustain" */
4496         switch (stat)
4497         {
4498                 case A_STR: if (p_ptr->sustain_str) sust = TRUE; break;
4499                 case A_INT: if (p_ptr->sustain_int) sust = TRUE; break;
4500                 case A_WIS: if (p_ptr->sustain_wis) sust = TRUE; break;
4501                 case A_DEX: if (p_ptr->sustain_dex) sust = TRUE; break;
4502                 case A_CON: if (p_ptr->sustain_con) sust = TRUE; break;
4503                 case A_CHR: if (p_ptr->sustain_chr) sust = TRUE; break;
4504         }
4505
4506         /* Sustain */
4507         if (sust && (!ironman_nightmare || randint0(13)))
4508         {
4509                 /* Message */
4510 #ifdef JP
4511 msg_format("%s¤Ê¤Ã¤¿µ¤¤¬¤·¤¿¤¬¡¢¤¹¤°¤Ë¸µ¤ËÌá¤Ã¤¿¡£",
4512 #else
4513                 msg_format("You feel %s for a moment, but the feeling passes.",
4514 #endif
4515
4516                                 desc_stat_neg[stat]);
4517
4518                 /* Notice effect */
4519                 return (TRUE);
4520         }
4521
4522         /* Attempt to reduce the stat */
4523         if (dec_stat(stat, 10, (ironman_nightmare && !randint0(13))))
4524         {
4525                 /* Message */
4526 #ifdef JP
4527 msg_format("¤Ò¤É¤¯%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_neg[stat]);
4528 #else
4529                 msg_format("You feel very %s.", desc_stat_neg[stat]);
4530 #endif
4531
4532
4533                 /* Notice effect */
4534                 return (TRUE);
4535         }
4536
4537         /* Nothing obvious */
4538         return (FALSE);
4539 }
4540
4541
4542 /*
4543  * Restore lost "points" in a stat
4544  */
4545 bool do_res_stat(int stat)
4546 {
4547         /* Attempt to increase */
4548         if (res_stat(stat))
4549         {
4550                 /* Message */
4551 #ifdef JP
4552 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4553 #else
4554                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4555 #endif
4556
4557
4558                 /* Notice */
4559                 return (TRUE);
4560         }
4561
4562         /* Nothing obvious */
4563         return (FALSE);
4564 }
4565
4566
4567 /*
4568  * Gain a "point" in a stat
4569  */
4570 bool do_inc_stat(int stat)
4571 {
4572         bool res;
4573
4574         /* Restore strength */
4575         res = res_stat(stat);
4576
4577         /* Attempt to increase */
4578         if (inc_stat(stat))
4579         {
4580                 if (stat == A_WIS)
4581                 {
4582                         chg_virtue(V_ENLIGHTEN, 1);
4583                         chg_virtue(V_FAITH, 1);
4584                 }
4585                 else if (stat == A_INT)
4586                 {
4587                         chg_virtue(V_KNOWLEDGE, 1);
4588                         chg_virtue(V_ENLIGHTEN, 1);
4589                 }
4590                 else if (stat == A_CON)
4591                         chg_virtue(V_VITALITY, 1);
4592
4593                 /* Message */
4594 #ifdef JP
4595 msg_format("¥ï¡¼¥ª¡ª¤È¤Æ¤â%s¤Ê¤Ã¤¿¡ª", desc_stat_pos[stat]);
4596 #else
4597                 msg_format("Wow!  You feel very %s!", desc_stat_pos[stat]);
4598 #endif
4599
4600
4601                 /* Notice */
4602                 return (TRUE);
4603         }
4604
4605         /* Restoration worked */
4606         if (res)
4607         {
4608                 /* Message */
4609 #ifdef JP
4610 msg_format("¸µÄ̤ê¤Ë%s¤Ê¤Ã¤¿µ¤¤¬¤¹¤ë¡£", desc_stat_pos[stat]);
4611 #else
4612                 msg_format("You feel less %s.", desc_stat_neg[stat]);
4613 #endif
4614
4615
4616                 /* Notice */
4617                 return (TRUE);
4618         }
4619
4620         /* Nothing obvious */
4621         return (FALSE);
4622 }
4623
4624
4625 /*
4626  * Restores any drained experience
4627  */
4628 bool restore_level(void)
4629 {
4630         /* Restore experience */
4631         if (p_ptr->exp < p_ptr->max_exp)
4632         {
4633                 /* Message */
4634 #ifdef JP
4635 msg_print("À¸Ì¿ÎϤ¬Ìá¤Ã¤Æ¤­¤¿µ¤¤¬¤¹¤ë¡£");
4636 #else
4637                 msg_print("You feel your life energies returning.");
4638 #endif
4639
4640
4641                 /* Restore the experience */
4642                 p_ptr->exp = p_ptr->max_exp;
4643
4644                 /* Check the experience */
4645                 check_experience();
4646
4647                 /* Did something */
4648                 return (TRUE);
4649         }
4650
4651         /* No effect */
4652         return (FALSE);
4653 }
4654
4655
4656 /*
4657  * Forget everything
4658  */
4659 bool lose_all_info(void)
4660 {
4661         int i;
4662
4663         chg_virtue(V_KNOWLEDGE, -5);
4664         chg_virtue(V_ENLIGHTEN, -5);
4665
4666         /* Forget info about objects */
4667         for (i = 0; i < INVEN_TOTAL; i++)
4668         {
4669                 object_type *o_ptr = &inventory[i];
4670
4671                 /* Skip non-objects */
4672                 if (!o_ptr->k_idx) continue;
4673
4674                 /* Allow "protection" by the MENTAL flag */
4675                 if (o_ptr->ident & (IDENT_MENTAL)) continue;
4676
4677                 /* Remove "default inscriptions" */
4678                 o_ptr->feeling = FEEL_NONE;
4679
4680                 /* Hack -- Clear the "empty" flag */
4681                 o_ptr->ident &= ~(IDENT_EMPTY);
4682
4683                 /* Hack -- Clear the "known" flag */
4684                 o_ptr->ident &= ~(IDENT_KNOWN);
4685
4686                 /* Hack -- Clear the "felt" flag */
4687                 o_ptr->ident &= ~(IDENT_SENSE);
4688         }
4689
4690         /* Recalculate bonuses */
4691         p_ptr->update |= (PU_BONUS);
4692
4693         /* Combine / Reorder the pack (later) */
4694         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
4695
4696         /* Window stuff */
4697         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
4698
4699         /* Mega-Hack -- Forget the map */
4700         wiz_dark();
4701
4702         /* It worked */
4703         return (TRUE);
4704 }
4705
4706
4707 void do_poly_wounds(void)
4708 {
4709         /* Changed to always provide at least _some_ healing */
4710         s16b wounds = p_ptr->cut;
4711         s16b hit_p = (p_ptr->mhp - p_ptr->chp);
4712         s16b change = damroll(p_ptr->lev, 5);
4713         bool Nasty_effect = one_in_(5);
4714
4715         if (!(wounds || hit_p || Nasty_effect)) return;
4716
4717 #ifdef JP
4718 msg_print("½ý¤¬¤è¤ê·Ú¤¤¤â¤Î¤ËÊѲ½¤·¤¿¡£");
4719 #else
4720         msg_print("Your wounds are polymorphed into less serious ones.");
4721 #endif
4722
4723         hp_player(change);
4724         if (Nasty_effect)
4725         {
4726 #ifdef JP
4727 msg_print("¿·¤¿¤Ê½ý¤¬¤Ç¤­¤¿¡ª");
4728 take_hit(DAMAGE_LOSELIFE, change / 2, "ÊѲ½¤·¤¿½ý", -1);
4729 #else
4730                 msg_print("A new wound was created!");
4731                 take_hit(DAMAGE_LOSELIFE, change / 2, "a polymorphed wound", -1);
4732 #endif
4733
4734                 set_cut(change);
4735         }
4736         else
4737         {
4738                 set_cut(p_ptr->cut - (change / 2));
4739         }
4740 }
4741
4742
4743 /*
4744  * Change player race
4745  */
4746 void change_race(int new_race, cptr effect_msg)
4747 {
4748         cptr title = race_info[new_race].title;
4749         int  old_race = p_ptr->prace;
4750
4751 #ifdef JP
4752         msg_format("¤¢¤Ê¤¿¤Ï%s%s¤ËÊѲ½¤·¤¿¡ª", effect_msg, title);
4753 #else
4754         msg_format("You turn into %s %s%s!", (!effect_msg[0] && is_a_vowel(title[0]) ? "an" : "a"), effect_msg, title);
4755 #endif
4756
4757         chg_virtue(V_CHANCE, 2);
4758
4759         if (p_ptr->prace < 32)
4760         {
4761                 p_ptr->old_race1 |= 1L << p_ptr->prace;
4762         }
4763         else
4764         {
4765                 p_ptr->old_race2 |= 1L << (p_ptr->prace-32);
4766         }
4767         p_ptr->prace = new_race;
4768         rp_ptr = &race_info[p_ptr->prace];
4769
4770         /* Experience factor */
4771         p_ptr->expfact = rp_ptr->r_exp + cp_ptr->c_exp;
4772
4773         /*
4774          * The speed bonus of Klackons and Sprites are disabled
4775          * and the experience penalty is decreased.
4776          */
4777         if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER) || (p_ptr->pclass == CLASS_NINJA)) && ((p_ptr->prace == RACE_KLACKON) || (p_ptr->prace == RACE_SPRITE)))
4778                 p_ptr->expfact -= 15;
4779
4780         /* Get character's height and weight */
4781         get_height_weight();
4782
4783         /* Hitdice */
4784         if (p_ptr->pclass == CLASS_SORCERER)
4785                 p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
4786         else
4787                 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
4788
4789         do_cmd_rerate(FALSE);
4790
4791         /* The experience level may be modified */
4792         check_experience();
4793
4794         p_ptr->redraw |= (PR_BASIC);
4795
4796         p_ptr->update |= (PU_BONUS);
4797
4798         handle_stuff();
4799
4800         /* Load an autopick preference file */
4801         if (old_race != p_ptr->prace) autopick_load_pref(FALSE);
4802
4803         /* Player's graphic tile may change */
4804         lite_spot(py, px);
4805 }
4806
4807
4808 void do_poly_self(void)
4809 {
4810         int power = p_ptr->lev;
4811
4812 #ifdef JP
4813 msg_print("¤¢¤Ê¤¿¤ÏÊѲ½¤Îˬ¤ì¤ò´¶¤¸¤¿...");
4814 #else
4815         msg_print("You feel a change coming over you...");
4816 #endif
4817
4818         chg_virtue(V_CHANCE, 1);
4819
4820         if ((power > randint0(20)) && one_in_(3) && (p_ptr->prace != RACE_ANDROID))
4821         {
4822                 char effect_msg[80] = "";
4823                 int new_race, expfact, goalexpfact;
4824
4825                 /* Some form of racial polymorph... */
4826                 power -= 10;
4827
4828                 if ((power > randint0(5)) && one_in_(4))
4829                 {
4830                         /* sex change */
4831                         power -= 2;
4832
4833                         if (p_ptr->psex == SEX_MALE)
4834                         {
4835                                 p_ptr->psex = SEX_FEMALE;
4836                                 sp_ptr = &sex_info[p_ptr->psex];
4837 #ifdef JP
4838 sprintf(effect_msg, "½÷À­¤Î");
4839 #else
4840                                 sprintf(effect_msg, "female ");
4841 #endif
4842
4843                         }
4844                         else
4845                         {
4846                                 p_ptr->psex = SEX_MALE;
4847                                 sp_ptr = &sex_info[p_ptr->psex];
4848 #ifdef JP
4849 sprintf(effect_msg, "ÃËÀ­¤Î");
4850 #else
4851                                 sprintf(effect_msg, "male ");
4852 #endif
4853
4854                         }
4855                 }
4856
4857                 if ((power > randint0(30)) && one_in_(5))
4858                 {
4859                         int tmp = 0;
4860
4861                         /* Harmful deformity */
4862                         power -= 15;
4863
4864                         while (tmp < 6)
4865                         {
4866                                 if (one_in_(2))
4867                                 {
4868                                         (void)dec_stat(tmp, randint1(6) + 6, one_in_(3));
4869                                         power -= 1;
4870                                 }
4871                                 tmp++;
4872                         }
4873
4874                         /* Deformities are discriminated against! */
4875                         (void)dec_stat(A_CHR, randint1(6), TRUE);
4876
4877                         if (effect_msg[0])
4878                         {
4879                                 char tmp_msg[10];
4880 #ifdef JP
4881                                 sprintf(tmp_msg,"%s",effect_msg);
4882                                 sprintf(effect_msg,"´ñ·Á¤Î%s",tmp_msg);
4883 #else
4884                                 sprintf(tmp_msg,"%s ",effect_msg);
4885                                 sprintf(effect_msg,"deformed %s ",tmp_msg);
4886 #endif
4887
4888                         }
4889                         else
4890                         {
4891 #ifdef JP
4892                                 sprintf(effect_msg,"´ñ·Á¤Î");
4893 #else
4894                                 sprintf(effect_msg,"deformed ");
4895 #endif
4896
4897                         }
4898                 }
4899
4900                 while ((power > randint0(20)) && one_in_(10))
4901                 {
4902                         /* Polymorph into a less mutated form */
4903                         power -= 10;
4904
4905                         if (!lose_mutation(0))
4906 #ifdef JP
4907 msg_print("´ñ̯¤Ê¤¯¤é¤¤ÉáÄ̤ˤʤ俵¤¤¬¤¹¤ë¡£");
4908 #else
4909                                 msg_print("You feel oddly normal.");
4910 #endif
4911
4912                 }
4913
4914                 /*
4915                  * Restrict the race choices by exp penalty so
4916                  * weak polymorph always means weak race
4917                  */
4918                 if (power < 0)
4919                         goalexpfact = 100;
4920                 else
4921                         goalexpfact = 100 + 3 * randint0(power);
4922
4923                 do
4924                 {
4925                         new_race = randint0(MAX_RACES);
4926                         expfact = race_info[new_race].r_exp;
4927                 }
4928                 while (((new_race == p_ptr->prace) && (expfact > goalexpfact)) || (new_race == RACE_ANDROID));
4929
4930                 change_race(new_race, effect_msg);
4931         }
4932
4933         if ((power > randint0(30)) && one_in_(6))
4934         {
4935                 int tmp = 0;
4936
4937                 /* Abomination! */
4938                 power -= 20;
4939
4940 #ifdef JP
4941 msg_format("%s¤Î¹½À®¤¬ÊѲ½¤·¤¿¡ª", p_ptr->prace == RACE_ANDROID ? "µ¡³£" : "Æâ¡");
4942 #else
4943                 msg_print("Your internal organs are rearranged!");
4944 #endif
4945
4946                 while (tmp < 6)
4947                 {
4948                         (void)dec_stat(tmp, randint1(6) + 6, one_in_(3));
4949                         tmp++;
4950                 }
4951                 if (one_in_(6))
4952                 {
4953 #ifdef JP
4954                         msg_print("¸½ºß¤Î»Ñ¤ÇÀ¸¤­¤Æ¤¤¤¯¤Î¤Ïº¤Æñ¤Ê¤è¤¦¤À¡ª");
4955                         take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "Ã×̿Ū¤ÊÆÍÁ³ÊÑ°Û", -1);
4956 #else
4957                         msg_print("You find living difficult in your present form!");
4958                         take_hit(DAMAGE_LOSELIFE, damroll(randint1(10), p_ptr->lev), "a lethal mutation", -1);
4959 #endif
4960
4961                         power -= 10;
4962                 }
4963         }
4964
4965         if ((power > randint0(20)) && one_in_(4))
4966         {
4967                 power -= 10;
4968
4969                 get_max_stats();
4970                 do_cmd_rerate(FALSE);
4971         }
4972
4973         while ((power > randint0(15)) && one_in_(3))
4974         {
4975                 power -= 7;
4976                 (void)gain_random_mutation(0);
4977         }
4978
4979         if (power > randint0(5))
4980         {
4981                 power -= 5;
4982                 do_poly_wounds();
4983         }
4984
4985         /* Note: earlier deductions may have left power < 0 already. */
4986         while (power > 0)
4987         {
4988                 mutate_player();
4989                 power--;
4990         }
4991 }
4992
4993
4994 /*
4995  * Decreases players hit points and sets death flag if necessary
4996  *
4997  * XXX XXX XXX Invulnerability needs to be changed into a "shield"
4998  *
4999  * XXX XXX XXX Hack -- this function allows the user to save (or quit)
5000  * the game when he dies, since the "You die." message is shown before
5001  * setting the player to "dead".
5002  */
5003
5004 int take_hit(int damage_type, int damage, cptr hit_from, int monspell)
5005 {
5006         int old_chp = p_ptr->chp;
5007
5008         char death_message[1024];
5009         char tmp[80];
5010
5011         int warning = (p_ptr->mhp * hitpoint_warn / 10);
5012
5013         /* Paranoia */
5014         if (p_ptr->is_dead) return 0;
5015
5016         if (p_ptr->sutemi) damage *= 2;
5017         if (p_ptr->special_defense & KATA_IAI) damage += (damage + 4) / 5;
5018
5019         if (easy_band) damage = (damage+1)/2;
5020
5021         if (damage_type != DAMAGE_USELIFE)
5022         {
5023                 /* Disturb */
5024                 disturb(1, 0);
5025                 if (auto_more)
5026                 {
5027                         now_damaged = TRUE;
5028                 }
5029         }
5030
5031         if (monspell >= 0) learn_spell(monspell);
5032
5033         /* Mega-Hack -- Apply "invulnerability" */
5034         if ((damage_type != DAMAGE_USELIFE) && (damage_type != DAMAGE_LOSELIFE))
5035         {
5036                 if (IS_INVULN() && (damage < 9000))
5037                 {
5038                         if (damage_type == DAMAGE_FORCE)
5039                         {
5040 #ifdef JP
5041                                 msg_print("¥Ð¥ê¥¢¤¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5042 #else
5043                                 msg_print("The attack cuts your shield of invulnerability open!");
5044 #endif
5045                         }
5046                         else if (one_in_(PENETRATE_INVULNERABILITY))
5047                         {
5048 #ifdef JP
5049                                 msg_print("̵Ũ¤Î¥Ð¥ê¥¢¤òÇˤäƹ¶·â¤µ¤ì¤¿¡ª");
5050 #else
5051                                 msg_print("The attack penetrates your shield of invulnerability!");
5052 #endif
5053                         }
5054                         else
5055                         {
5056                                 return 0;
5057                         }
5058                 }
5059
5060                 /* Multishadow effects is determined by turn */
5061                 if (p_ptr->multishadow && (turn & 1))
5062                 {
5063                         if (damage_type == DAMAGE_FORCE)
5064                         {
5065 #ifdef JP
5066                                 msg_print("¸¸±Æ¤â¤í¤È¤âÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5067 #else
5068                                 msg_print("The attack hits Shadow together with you!");
5069 #endif
5070                         }
5071                         else if (damage_type == DAMAGE_ATTACK)
5072                         {
5073 #ifdef JP
5074                                 msg_print("¹¶·â¤Ï¸¸±Æ¤ËÌ¿Ã椷¡¢¤¢¤Ê¤¿¤Ë¤ÏÆϤ«¤Ê¤«¤Ã¤¿¡£");
5075 #else
5076                                 msg_print("The attack hits Shadow, you are unharmed!");
5077 #endif
5078                                 return 0;
5079                         }
5080                 }
5081
5082                 if (p_ptr->wraith_form)
5083                 {
5084                         if (damage_type == DAMAGE_FORCE)
5085                         {
5086 #ifdef JP
5087                                 msg_print("Ⱦʪ¼Á¤ÎÂΤ¬ÀÚ¤êÎö¤«¤ì¤¿¡ª");
5088 #else
5089                                 msg_print("The attack cuts through your ethereal body!");
5090 #endif
5091                         }
5092                         else
5093                         {
5094                                 damage /= 2;
5095                                 if ((damage == 0) && one_in_(2)) damage = 1;
5096                         }
5097                 }
5098
5099                 if (p_ptr->special_defense & KATA_MUSOU)
5100                 {
5101                         damage /= 2;
5102                         if ((damage == 0) && one_in_(2)) damage = 1;
5103                 }
5104         } /* not if LOSELIFE USELIFE */
5105
5106         /* Hurt the player */
5107         p_ptr->chp -= damage;
5108         if(damage_type == DAMAGE_GENO && p_ptr->chp < 0)
5109         {
5110                 damage += p_ptr->chp;
5111                 p_ptr->chp = 0;
5112         }
5113
5114         /* Display the hitpoints */
5115         p_ptr->redraw |= (PR_HP);
5116
5117         /* Window stuff */
5118         p_ptr->window |= (PW_PLAYER);
5119
5120         handle_stuff();
5121
5122         if (damage_type != DAMAGE_GENO && p_ptr->chp == 0)
5123         {
5124                 chg_virtue(V_SACRIFICE, 1);
5125                 chg_virtue(V_CHANCE, 2);
5126         }
5127
5128         /* Dead player */
5129         if (p_ptr->chp < 0)
5130         {
5131                 char buf[10];
5132                 bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE);
5133
5134 #ifdef JP       /* »à¤ó¤À»þ¤Ë¶¯À©½ªÎ»¤·¤Æ»à¤ò²óÈò¤Ç¤­¤Ê¤¯¤·¤Æ¤ß¤¿ by Habu */
5135                 if (!cheat_save)
5136                         if(!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
5137 #endif
5138
5139                 /* Sound */
5140                 sound(SOUND_DEATH);
5141
5142                 chg_virtue(V_SACRIFICE, 10);
5143
5144                 /* Leaving */
5145                 p_ptr->leaving = TRUE;
5146
5147                 /* Note death */
5148                 p_ptr->is_dead = TRUE;
5149
5150                 if (p_ptr->inside_arena)
5151                 {
5152                         cptr m_name = r_name+r_info[arena_info[p_ptr->arena_number].r_idx].name;
5153 #ifdef JP
5154                         msg_format("¤¢¤Ê¤¿¤Ï%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£", m_name);
5155 #else
5156                         msg_format("You are beaten by %s.", m_name);
5157 #endif
5158                         msg_print(NULL);
5159                         if (record_arena) do_cmd_write_nikki(NIKKI_ARENA, -1 - p_ptr->arena_number, m_name);
5160                 }
5161                 else
5162                 {
5163                         int q_idx = quest_number(dun_level);
5164
5165 #ifdef WORLD_SCORE
5166                         /* Make screen dump */
5167                         screen_dump = make_screen_dump();
5168 #endif
5169
5170                         /* Note cause of death */
5171 #ifdef JP
5172                         sprintf(p_ptr->died_from, "%s%s%s", !p_ptr->paralyzed ? "" : p_ptr->free_act ? "ĦÁü¾õÂÖ¤Ç":"Ëãáã¾õÂÖ¤Ç", p_ptr->image ? "¸¸³Ð¤ËÏĤó¤À" : "", hit_from);
5173 #else
5174                         sprintf(p_ptr->died_from, "%s%s", hit_from, !p_ptr->paralyzed ? "" : " while helpless");
5175 #endif
5176
5177                         /* No longer a winner */
5178                         p_ptr->total_winner = FALSE;
5179
5180                         if (p_ptr->inside_arena)
5181 #ifdef JP
5182                                 strcpy(buf,"¥¢¥ê¡¼¥Ê");
5183 #else
5184                                 strcpy(buf,"in the Arena");
5185 #endif
5186                         else if (!dun_level)
5187 #ifdef JP
5188                                 strcpy(buf,"ÃϾå");
5189 #else
5190                                 strcpy(buf,"on the surface");
5191 #endif
5192                         else if (q_idx && (is_fixed_quest_idx(q_idx) &&
5193                                  !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
5194 #ifdef JP
5195                                 strcpy(buf,"¥¯¥¨¥¹¥È");
5196 #else
5197                                 strcpy(buf,"in a quest");
5198 #endif
5199                         else
5200 #ifdef JP
5201                                 sprintf(buf,"%d³¬", dun_level);
5202 #else
5203                                 sprintf(buf,"level %d", dun_level);
5204 #endif
5205 #ifdef JP
5206                         sprintf(tmp,"%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£",buf, p_ptr->died_from);
5207 #else
5208                         sprintf(tmp,"killed by %s %s.", p_ptr->died_from, buf);
5209 #endif
5210                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5211 #ifdef JP
5212                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5213 #else
5214                         do_cmd_write_nikki(NIKKI_GAMESTART, 1, "--------   Game  Over   --------");
5215 #endif
5216                         do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5217
5218                         flush();
5219
5220 #ifdef JP
5221 if (get_check_strict("²èÌ̤òÊݸ¤·¤Þ¤¹¤«¡©", CHECK_NO_HISTORY))
5222 #else
5223                         if (get_check_strict("Dump the screen? ", CHECK_NO_HISTORY))
5224 #endif
5225
5226                         {
5227                                 do_cmd_save_screen();
5228                         }
5229
5230                         flush();
5231
5232                         /* Initialize "last message" buffer */
5233                         if (p_ptr->last_message) string_free(p_ptr->last_message);
5234                         p_ptr->last_message = NULL;
5235
5236                         /* Hack -- Note death */
5237                         if (!last_words)
5238                         {
5239 #ifdef JP
5240 msg_format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë");
5241 #else
5242                                 msg_print(android ? "You are broken." : "You die.");
5243 #endif
5244
5245                                 msg_print(NULL);
5246                         }
5247                         else
5248                         {
5249                                 if (streq(p_ptr->died_from, "Seppuku"))
5250                                 {
5251 #ifdef JP
5252                                   get_rnd_line("seppuku_j.txt", 0, death_message);
5253 #else
5254                                         get_rnd_line("seppuku.txt", 0, death_message);
5255 #endif
5256                                 }
5257                                 else
5258                                 {
5259 #ifdef JP
5260 get_rnd_line("death_j.txt", 0, death_message);
5261 #else
5262                                         get_rnd_line("death.txt", 0, death_message);
5263 #endif
5264                                 }
5265 #ifdef JP
5266                                 while (!get_string(streq(p_ptr->died_from, "Seppuku") ? "¼­À¤¤Î¶ç: " : "ÃÇËöËâ¤Î¶«¤Ó: ", death_message, 1024)) ;
5267 #else
5268                                 while (!get_string("Last word: ", death_message, 1024)) ;
5269 #endif
5270                                 if (death_message[0] == '\0')
5271                                 {
5272 #ifdef JP
5273                                         strcpy(death_message, format("¤¢¤Ê¤¿¤Ï%s¤Þ¤·¤¿¡£", android ? "²õ¤ì" : "»à¤Ë"));
5274 #else
5275                                         strcpy(death_message, android ? "You are broken." : "You die.");
5276 #endif
5277                                 }
5278                                 else p_ptr->last_message = string_make(death_message);
5279
5280                                 if (streq(p_ptr->died_from, "Seppuku"))
5281                                 {
5282 #ifdef JP
5283                                   int i, len;
5284                                   int w = Term->wid;
5285                                   int h = Term->hgt;
5286                                   int msg_pos_x[9] = {  5,  7,  9, 12,  14,  17,  19,  21, 23};
5287                                   int msg_pos_y[9] = {  3,  4,  5,  4,   5,   4,   5,   6,  4};
5288                                   cptr str;
5289                                   char* str2;
5290
5291                                   Term_clear();
5292
5293                                   /* ºù»¶¤ë */
5294                                   for (i = 0; i < 40; i++) 
5295                                     Term_putstr(randint0(w / 2) * 2, randint0(h), 2, TERM_VIOLET, "¦Ô");
5296
5297                                   str = death_message;
5298                                   if (strncmp(str, "¡Ö", 2) == 0) str += 2;
5299
5300                                   str2 = my_strstr(str, "¡×");
5301                                   if (str2 != NULL) *str2 = '\0';
5302
5303                                   i = 0;
5304                                   while (i < 9)
5305                                   {
5306                                     str2 = my_strstr(str, " ");
5307                                     if (str2 == NULL) len = strlen(str);
5308                                     else len = str2 - str;
5309
5310                                     if (len != 0)
5311                                     {
5312                                       Term_putstr_v(w * 3 / 4 - 2 - msg_pos_x[i] * 2, msg_pos_y[i], len,
5313                                                   TERM_WHITE, str);
5314                                       if (str2 == NULL) break;
5315                                       i++;
5316                                     }
5317                                     str = str2 + 1;
5318                                     if (*str == 0) break;
5319                                   }
5320
5321                                   /* Hide cursor */
5322                                   Term_putstr(w-1, h-1, 1, TERM_WHITE, " ");
5323
5324                                   flush();
5325 #ifdef WORLD_SCORE
5326                                   /* Make screen dump */
5327                                   screen_dump = make_screen_dump();
5328 #endif
5329
5330                                   /* Wait a key press */
5331                                   (void)inkey();
5332 #else
5333                                         msg_print(death_message);
5334 #endif
5335                                 }
5336                                 else
5337                                         msg_print(death_message);
5338                         }
5339                 }
5340
5341                 /* Dead */
5342                 return damage;
5343         }
5344
5345         /* Hitpoint warning */
5346         if (p_ptr->chp < warning)
5347         {
5348                 /* Hack -- bell on first notice */
5349                 if (old_chp > warning) bell();
5350
5351                 sound(SOUND_WARN);
5352
5353                 if (record_danger && (old_chp > warning))
5354                 {
5355                         if (p_ptr->image && damage_type == DAMAGE_ATTACK)
5356 #ifdef JP
5357                                 hit_from = "²¿¤«";
5358 #else
5359                                 hit_from = "something";
5360 #endif
5361
5362 #ifdef JP
5363                         sprintf(tmp,"%s¤Ë¤è¤Ã¤Æ¥Ô¥ó¥Á¤Ë´Ù¤¤¤Ã¤¿¡£",hit_from);
5364 #else
5365                         sprintf(tmp,"A critical situation because of %s.",hit_from);
5366 #endif
5367                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
5368                 }
5369
5370                 if (auto_more)
5371                 {
5372                         /* stop auto_more even if DAMAGE_USELIFE */
5373                         now_damaged = TRUE;
5374                 }
5375
5376                 /* Message */
5377 #ifdef JP
5378 msg_print("*** ·Ù¹ð:Äã¥Ò¥Ã¥È¡¦¥Ý¥¤¥ó¥È¡ª ***");
5379 #else
5380                 msg_print("*** LOW HITPOINT WARNING! ***");
5381 #endif
5382
5383                 msg_print(NULL);
5384                 flush();
5385         }
5386         if (p_ptr->wild_mode && !p_ptr->leaving && (p_ptr->chp < MAX(warning, p_ptr->mhp/5)))
5387         {
5388                 change_wild_mode();
5389         }
5390         return damage;
5391 }
5392
5393
5394 /*
5395  * Gain experience
5396  */
5397 void gain_exp_64(s32b amount, u32b amount_frac)
5398 {
5399         if (p_ptr->is_dead) return;
5400
5401         if (p_ptr->prace == RACE_ANDROID) return;
5402
5403         /* Gain some experience */
5404         s64b_add(&(p_ptr->exp), &(p_ptr->exp_frac), amount, amount_frac);
5405
5406         /* Slowly recover from experience drainage */
5407         if (p_ptr->exp < p_ptr->max_exp)
5408         {
5409                 /* Gain max experience (20%) (was 10%) */
5410                 p_ptr->max_exp += amount / 5;
5411         }
5412
5413         /* Check Experience */
5414         check_experience();
5415 }
5416
5417
5418 /*
5419  * Gain experience
5420  */
5421 void gain_exp(s32b amount)
5422 {
5423         gain_exp_64(amount, 0L);
5424 }
5425
5426
5427 void calc_android_exp(void)
5428 {
5429         int i;
5430         u32b total_exp = 0;
5431         if (p_ptr->is_dead) return;
5432
5433         if (p_ptr->prace != RACE_ANDROID) return;
5434
5435         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
5436         {
5437                 object_type *o_ptr = &inventory[i];
5438                 object_type forge;
5439                 object_type *q_ptr = &forge;
5440                 u32b value, exp;
5441                 int level = MAX(k_info[o_ptr->k_idx].level - 8, 1);
5442
5443                 if ((i == INVEN_RIGHT) || (i == INVEN_LEFT) || (i == INVEN_NECK) || (i == INVEN_LITE)) continue;
5444                 if (!o_ptr->k_idx) continue;
5445
5446                 /* Wipe the object */
5447                 object_wipe(q_ptr);
5448
5449                 object_copy(q_ptr, o_ptr);
5450                 q_ptr->discount = 0;
5451                 q_ptr->curse_flags = 0L;
5452
5453                 if (object_is_fixed_artifact(o_ptr))
5454                 {
5455                         level = (level + MAX(a_info[o_ptr->name1].level - 8, 5)) / 2;
5456                         level += MIN(20, a_info[o_ptr->name1].rarity/(a_info[o_ptr->name1].gen_flags & TRG_INSTA_ART ? 10 : 3));
5457                 }
5458                 else if (object_is_ego(o_ptr))
5459                 {
5460                         level += MAX(3, (e_info[o_ptr->name2].rating - 5)/2);
5461                 }
5462                 else if (o_ptr->art_name)
5463                 {
5464                         s32b total_flags = flag_cost(o_ptr, o_ptr->pval);
5465                         int fake_level;
5466
5467                         if (!object_is_weapon_ammo(o_ptr))
5468                         {
5469                                 /* For armors */
5470                                 if (total_flags < 15000) fake_level = 10;
5471                                 else if (total_flags < 35000) fake_level = 25;
5472                                 else fake_level = 40;
5473                         }
5474                         else
5475                         {
5476                                 /* For weapons */
5477                                 if (total_flags < 20000) fake_level = 10;
5478                                 else if (total_flags < 45000) fake_level = 25;
5479                                 else fake_level = 40;
5480                         }
5481
5482                         level = MAX(level, (level + MAX(fake_level - 8, 5)) / 2 + 3);
5483                 }
5484
5485                 value = object_value_real(q_ptr);
5486
5487                 if (value <= 0) continue;
5488                 if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI) && (p_ptr->pseikaku != SEIKAKU_SEXY)) value /= 32;
5489                 if (value > 5000000L) value = 5000000L;
5490                 if ((o_ptr->tval == TV_DRAG_ARMOR) || (o_ptr->tval == TV_CARD)) level /= 2;
5491
5492                 if (object_is_artifact(o_ptr) || object_is_ego(o_ptr) ||
5493                     (o_ptr->tval == TV_DRAG_ARMOR) ||
5494                     ((o_ptr->tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM)) ||
5495                     ((o_ptr->tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD)) ||
5496                     ((o_ptr->tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES)) ||
5497                     ((o_ptr->tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE)) ||
5498                     ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DIAMOND_EDGE)))
5499                 {
5500                         if (level > 65) level = 35 + (level - 65) / 5;
5501                         else if (level > 35) level = 25 + (level - 35) / 3;
5502                         else if (level > 15) level = 15 + (level - 15) / 2;
5503                         exp = MIN(100000L, value) * level * level / 2;
5504                         if (value > 100000L)
5505                                 exp += (value - 100000L) * level * level / 8;
5506                 }
5507                 else
5508                 {
5509                         exp = MIN(100000L, value) * level;
5510                         if (value > 100000L)
5511                                 exp += (value - 100000L) * level / 4;
5512                 }
5513                 if ((((i == INVEN_RARM) || (i == INVEN_LARM)) && (buki_motteruka(i))) || (i == INVEN_BOW)) total_exp += exp / 48;
5514                 else total_exp += exp / 16;
5515                 if (i == INVEN_BODY) total_exp += exp / 32;
5516         }
5517         p_ptr->exp = p_ptr->max_exp = total_exp;
5518
5519         /* Check Experience */
5520         check_experience();
5521 }
5522
5523
5524 /*
5525  * Lose experience
5526  */
5527 void lose_exp(s32b amount)
5528 {
5529         if (p_ptr->prace == RACE_ANDROID) return;
5530
5531         /* Never drop below zero experience */
5532         if (amount > p_ptr->exp) amount = p_ptr->exp;
5533
5534         /* Lose some experience */
5535         p_ptr->exp -= amount;
5536
5537         /* Check Experience */
5538         check_experience();
5539 }
5540
5541
5542 /*
5543  * Drain experience
5544  * If resisted to draining, return FALSE
5545  */
5546 bool drain_exp(s32b drain, s32b slip, int hold_life_prob)
5547 {
5548         /* Androids and their mimics are never drained */
5549         if (p_ptr->prace == RACE_ANDROID) return FALSE;
5550
5551         if (p_ptr->hold_life && (randint0(100) < hold_life_prob))
5552         {
5553                 /* Hold experience */
5554 #ifdef JP
5555                 msg_print("¤·¤«¤·¼«¸Ê¤ÎÀ¸Ì¿ÎϤò¼é¤ê¤­¤Ã¤¿¡ª");
5556 #else
5557                 msg_print("You keep hold of your life force!");
5558 #endif
5559                 return FALSE;
5560         }
5561
5562         /* Hold experience failed */
5563         if (p_ptr->hold_life)
5564         {
5565 #ifdef JP
5566                 msg_print("À¸Ì¿ÎϤò¾¯¤·µÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
5567 #else
5568                 msg_print("You feel your life slipping away!");
5569 #endif
5570                 lose_exp(slip);
5571         }
5572         else
5573         {
5574 #ifdef JP
5575                 msg_print("À¸Ì¿ÎϤ¬ÂΤ«¤éµÛ¤¤¼è¤é¤ì¤¿µ¤¤¬¤¹¤ë¡ª");
5576 #else
5577                 msg_print("You feel your life draining away!");
5578 #endif
5579                 lose_exp(drain);
5580         }
5581
5582         return TRUE;
5583 }
5584
5585
5586 bool set_ultimate_res(int v, bool do_dec)
5587 {
5588         bool notice = FALSE;
5589
5590         /* Hack -- Force good values */
5591         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5592
5593         if (p_ptr->is_dead) return FALSE;
5594
5595         /* Open */
5596         if (v)
5597         {
5598                 if (p_ptr->ult_res && !do_dec)
5599                 {
5600                         if (p_ptr->ult_res > v) return FALSE;
5601                 }
5602                 else if (!p_ptr->ult_res)
5603                 {
5604 #ifdef JP
5605 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5606 #else
5607                         msg_print("You feel resistant!");
5608 #endif
5609
5610                         notice = TRUE;
5611                 }
5612         }
5613
5614         /* Shut */
5615         else
5616         {
5617                 if (p_ptr->ult_res)
5618                 {
5619 #ifdef JP
5620 msg_print("¤¢¤é¤æ¤ë¤³¤È¤ËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5621 #else
5622                         msg_print("You feel less resistant");
5623 #endif
5624
5625                         notice = TRUE;
5626                 }
5627         }
5628
5629         /* Use the value */
5630         p_ptr->ult_res = v;
5631
5632         /* Redraw status bar */
5633         p_ptr->redraw |= (PR_STATUS);
5634
5635         /* Nothing to notice */
5636         if (!notice) return (FALSE);
5637
5638         /* Disturb */
5639         if (disturb_state) disturb(0, 0);
5640
5641         /* Recalculate bonuses */
5642         p_ptr->update |= (PU_BONUS);
5643
5644         /* Handle stuff */
5645         handle_stuff();
5646
5647         /* Result */
5648         return (TRUE);
5649 }
5650
5651 bool set_tim_res_nether(int v, bool do_dec)
5652 {
5653         bool notice = FALSE;
5654
5655         /* Hack -- Force good values */
5656         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5657
5658         if (p_ptr->is_dead) return FALSE;
5659
5660         /* Open */
5661         if (v)
5662         {
5663                 if (p_ptr->tim_res_nether && !do_dec)
5664                 {
5665                         if (p_ptr->tim_res_nether > v) return FALSE;
5666                 }
5667                 else if (!p_ptr->tim_res_nether)
5668                 {
5669 #ifdef JP
5670 msg_print("ÃϹö¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5671 #else
5672                         msg_print("You feel nether resistant!");
5673 #endif
5674
5675                         notice = TRUE;
5676                 }
5677         }
5678
5679         /* Shut */
5680         else
5681         {
5682                 if (p_ptr->tim_res_nether)
5683                 {
5684 #ifdef JP
5685 msg_print("ÃϹö¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5686 #else
5687                         msg_print("You feel less nether resistant");
5688 #endif
5689
5690                         notice = TRUE;
5691                 }
5692         }
5693
5694         /* Use the value */
5695         p_ptr->tim_res_nether = v;
5696
5697         /* Redraw status bar */
5698         p_ptr->redraw |= (PR_STATUS);
5699
5700         /* Nothing to notice */
5701         if (!notice) return (FALSE);
5702
5703         /* Disturb */
5704         if (disturb_state) disturb(0, 0);
5705
5706         /* Recalculate bonuses */
5707         p_ptr->update |= (PU_BONUS);
5708
5709         /* Handle stuff */
5710         handle_stuff();
5711
5712         /* Result */
5713         return (TRUE);
5714 }
5715
5716 bool set_tim_res_time(int v, bool do_dec)
5717 {
5718         bool notice = FALSE;
5719
5720         /* Hack -- Force good values */
5721         v = (v > 10000) ? 10000 : (v < 0) ? 0 : v;
5722
5723         if (p_ptr->is_dead) return FALSE;
5724
5725         /* Open */
5726         if (v)
5727         {
5728                 if (p_ptr->tim_res_time && !do_dec)
5729                 {
5730                         if (p_ptr->tim_res_time > v) return FALSE;
5731                 }
5732                 else if (!p_ptr->tim_res_time)
5733                 {
5734 #ifdef JP
5735 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ·¤ÆÂÑÀ­¤¬¤Ä¤¤¤¿µ¤¤¬¤¹¤ë¡ª");
5736 #else
5737                         msg_print("You feel time resistant!");
5738 #endif
5739
5740                         notice = TRUE;
5741                 }
5742         }
5743
5744         /* Shut */
5745         else
5746         {
5747                 if (p_ptr->tim_res_time)
5748                 {
5749 #ifdef JP
5750 msg_print("»þ´ÖµÕž¤ÎÎϤËÂФ¹¤ëÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
5751 #else
5752                         msg_print("You feel less time resistant");
5753 #endif
5754
5755                         notice = TRUE;
5756                 }
5757         }
5758
5759         /* Use the value */
5760         p_ptr->tim_res_time = v;
5761
5762         /* Redraw status bar */
5763         p_ptr->redraw |= (PR_STATUS);
5764
5765         /* Nothing to notice */
5766         if (!notice) return (FALSE);
5767
5768         /* Disturb */
5769         if (disturb_state) disturb(0, 0);
5770
5771         /* Recalculate bonuses */
5772         p_ptr->update |= (PU_BONUS);
5773
5774         /* Handle stuff */
5775         handle_stuff();
5776
5777         /* Result */
5778         return (TRUE);
5779 }
5780
5781
5782 /*
5783  * Choose a warrior-mage elemental attack. -LM-
5784  */
5785 bool choose_ele_attack(void)
5786 {
5787         int num;
5788
5789         char choice;
5790
5791         if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
5792         {
5793 #ifdef JP
5794                 msg_format("Éð´ï¤ò»ý¤¿¤Ê¤¤¤ÈËâË¡·õ¤Ï»È¤¨¤Ê¤¤¡£");
5795 #else
5796                 msg_format("You cannot use temporary branding with no weapon.");
5797 #endif
5798                 return FALSE;
5799         }
5800
5801         /* Save screen */
5802         screen_save();
5803
5804         num = (p_ptr->lev - 20) / 5;
5805
5806 #ifdef JP
5807                       c_prt(TERM_RED,    "        a) ¾Æ´þ", 2, 14);
5808 #else
5809                       c_prt(TERM_RED,    "        a) Fire Brand", 2, 14);
5810 #endif
5811
5812 #ifdef JP
5813         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Åà·ë", 3, 14);
5814 #else
5815         if (num >= 2) c_prt(TERM_L_WHITE,"        b) Cold Brand", 3, 14);
5816 #endif
5817         else prt("", 3, 14);
5818
5819 #ifdef JP
5820         if (num >= 3) c_prt(TERM_GREEN,  "        c) ÆÇ»¦", 4, 14);
5821 #else
5822         if (num >= 3) c_prt(TERM_GREEN,  "        c) Poison Brand", 4, 14);
5823 #endif
5824         else prt("", 4, 14);
5825
5826 #ifdef JP
5827         if (num >= 4) c_prt(TERM_L_DARK, "        d) Íϲò", 5, 14);
5828 #else
5829         if (num >= 4) c_prt(TERM_L_DARK, "        d) Acid Brand", 5, 14);
5830 #endif
5831         else prt("", 5, 14);
5832
5833 #ifdef JP
5834         if (num >= 5) c_prt(TERM_BLUE,   "        e) ÅÅ·â", 6, 14);
5835 #else
5836         if (num >= 5) c_prt(TERM_BLUE,   "        e) Elec Brand", 6, 14);
5837 #endif
5838         else prt("", 6, 14);
5839
5840         prt("", 7, 14);
5841         prt("", 8, 14);
5842         prt("", 9, 14);
5843
5844         prt("", 1, 0);
5845 #ifdef JP
5846         prt("        ¤É¤Î¸µÁǹ¶·â¤ò¤·¤Þ¤¹¤«¡©", 1, 14);
5847 #else
5848         prt("        Choose a temporary elemental brand ", 1, 14);
5849 #endif
5850
5851         choice = inkey();
5852
5853         if ((choice == 'a') || (choice == 'A')) 
5854                 set_ele_attack(ATTACK_FIRE, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5855         else if (((choice == 'b') || (choice == 'B')) && (num >= 2))
5856                 set_ele_attack(ATTACK_COLD, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5857         else if (((choice == 'c') || (choice == 'C')) && (num >= 3))
5858                 set_ele_attack(ATTACK_POIS, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5859         else if (((choice == 'd') || (choice == 'D')) && (num >= 4))
5860                 set_ele_attack(ATTACK_ACID, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5861         else if (((choice == 'e') || (choice == 'E')) && (num >= 5))
5862                 set_ele_attack(ATTACK_ELEC, p_ptr->lev/2 + randint1(p_ptr->lev/2));
5863         else
5864         {
5865 #ifdef JP
5866                 msg_print("ËâË¡·õ¤ò»È¤¦¤Î¤ò¤ä¤á¤¿¡£");
5867 #else
5868                 msg_print("You cancel the temporary branding.");
5869 #endif
5870                 screen_load();
5871                 return FALSE;
5872         }
5873         /* Load screen */
5874         screen_load();
5875         return TRUE;
5876 }
5877
5878
5879 /*
5880  * Choose a elemental immune. -LM-
5881  */
5882 bool choose_ele_immune(int turn)
5883 {
5884         char choice;
5885
5886         /* Save screen */
5887         screen_save();
5888
5889 #ifdef JP
5890         c_prt(TERM_RED,    "        a) ²Ð±ê", 2, 14);
5891 #else
5892         c_prt(TERM_RED,    "        a) Immune Fire", 2, 14);
5893 #endif
5894
5895 #ifdef JP
5896         c_prt(TERM_L_WHITE,"        b) Î䵤", 3, 14);
5897 #else
5898         c_prt(TERM_L_WHITE,"        b) Immune Cold", 3, 14);
5899 #endif
5900
5901 #ifdef JP
5902         c_prt(TERM_L_DARK, "        c) »À", 4, 14);
5903 #else
5904         c_prt(TERM_L_DARK, "        c) Immune Acid", 4, 14);
5905 #endif
5906
5907 #ifdef JP
5908         c_prt(TERM_BLUE,   "        d) ÅÅ·â", 5, 14);
5909 #else
5910         c_prt(TERM_BLUE,   "        d) Immune Elec", 5, 14);
5911 #endif
5912
5913
5914         prt("", 6, 14);
5915         prt("", 7, 14);
5916         prt("", 8, 14);
5917         prt("", 9, 14);
5918
5919         prt("", 1, 0);
5920 #ifdef JP
5921         prt("        ¤É¤Î¸µÁǤÎÌȱ֤ò¤Ä¤±¤Þ¤¹¤«¡©", 1, 14);
5922 #else
5923         prt("        Choose a temporary elemental immune ", 1, 14);
5924 #endif
5925
5926         choice = inkey();
5927
5928         if ((choice == 'a') || (choice == 'A')) 
5929                 set_ele_immune(DEFENSE_FIRE, turn);
5930         else if ((choice == 'b') || (choice == 'B'))
5931                 set_ele_immune(DEFENSE_COLD, turn);
5932         else if ((choice == 'c') || (choice == 'C'))
5933                 set_ele_immune(DEFENSE_ACID, turn);
5934         else if ((choice == 'd') || (choice == 'D'))
5935                 set_ele_immune(DEFENSE_ELEC, turn);
5936         else
5937         {
5938 #ifdef JP
5939                 msg_print("Ìȱ֤òÉÕ¤±¤ë¤Î¤ò¤ä¤á¤¿¡£");
5940 #else
5941                 msg_print("You cancel the temporary immune.");
5942 #endif
5943                 screen_load();
5944                 return FALSE;
5945         }
5946         /* Load screen */
5947         screen_load();
5948         return TRUE;
5949 }