OSDN Git Service

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