OSDN Git Service

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