OSDN Git Service

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