OSDN Git Service

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