OSDN Git Service

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