OSDN Git Service

カオス魔法 "悪魔召喚" での召喚失敗時の英文が "Greater Demon" になっていたので
[hengband/hengband.git] / src / cmd5.c
1 /* File: cmd5.c */
2
3 /*
4  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
5  *
6  * This software may be copied and distributed for educational, research,
7  * and not for profit purposes provided that this copyright and statement
8  * are included in all such copies.  Other copyrights may also apply.
9  */
10
11 /* Purpose: Spell/Prayer commands */
12
13 #include "angband.h"
14
15 #include "spellstips.h"
16
17 cptr spell_categoly_name(int tval)
18 {
19         switch (tval)
20         {
21 #ifdef JP
22         case TV_HISSATSU_BOOK:
23                 return "ɬ»¦µ»";
24         case TV_LIFE_BOOK:
25                 return "µ§¤ê";
26         case TV_MUSIC_BOOK:
27                 return "²Î";
28         default:
29                 return "¼öʸ";
30 #else
31         case TV_HISSATSU_BOOK:
32                 return "arts";
33         case TV_LIFE_BOOK:
34                 return "prayer";
35         case TV_MUSIC_BOOK:
36                 return "song";
37         default:
38                 return "spell";
39 #endif
40         }
41 }
42
43 /*
44  * Allow user to choose a spell/prayer from the given book.
45  *
46  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
47  * If the user hits escape, returns FALSE, and set '*sn' to -1
48  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
49  *
50  * The "prompt" should be "cast", "recite", or "study"
51  * The "known" should be TRUE for cast/pray, FALSE for study
52  */
53
54 bool select_the_force=FALSE;
55
56 static int get_spell(int *sn, cptr prompt, int sval, bool learned, int use_realm)
57 {
58         int         i;
59         int         spell = -1;
60         int         num = 0;
61         int         ask = TRUE;
62         int         need_mana;
63         byte        spells[64];
64         bool        flag, redraw, okay;
65         char        choice;
66         magic_type  *s_ptr;
67         char        out_val[160];
68         cptr        p;
69 #ifdef JP
70         char jverb_buf[128];
71 #endif
72         int menu_line = (use_menu ? 1 : 0);
73
74 #ifdef ALLOW_REPEAT /* TNB */
75
76         /* Get the spell, if available */
77         if (repeat_pull(sn))
78         {
79                 /* Verify the spell */
80                 if (spell_okay(*sn, learned, FALSE, use_realm))
81                 {
82                         /* Success */
83                         return (TRUE);
84                 }
85         }
86
87 #endif /* ALLOW_REPEAT -- TNB */
88
89         p = spell_categoly_name(mp_ptr->spell_book);
90
91         /* Extract spells */
92         for (spell = 0; spell < 32; spell++)
93         {
94                 /* Check for this spell */
95                 if ((fake_spell_flags[sval] & (1L << spell)))
96                 {
97                         /* Collect this spell */
98                         spells[num++] = spell;
99                 }
100         }
101
102         /* Assume no usable spells */
103         okay = FALSE;
104
105         /* Assume no spells available */
106         (*sn) = -2;
107
108         /* Check for "okay" spells */
109         for (i = 0; i < num; i++)
110         {
111                 /* Look for "okay" spells */
112                 if (spell_okay(spells[i], learned, FALSE, use_realm)) okay = TRUE;
113         }
114
115         /* No "okay" spells */
116         if (!okay) return (FALSE);
117         if (((use_realm) != p_ptr->realm1) && ((use_realm) != p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE)) return FALSE;
118         if (((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) && !is_magic(use_realm)) return FALSE;
119         if ((p_ptr->pclass == CLASS_RED_MAGE) && ((use_realm) != REALM_ARCANE) && (sval > 1)) return FALSE;
120
121         /* Assume cancelled */
122         *sn = (-1);
123
124         /* Nothing chosen yet */
125         flag = FALSE;
126
127         /* No redraw yet */
128         redraw = FALSE;
129
130         /* Show choices */
131         if (show_choices)
132         {
133                 /* Update */
134                 p_ptr->window |= (PW_SPELL);
135
136                 /* Window stuff */
137                 window_stuff();
138         }
139
140         /* Build a prompt (accept all spells) */
141 #ifdef JP
142         jverb1( prompt, jverb_buf );
143         (void) strnfmt(out_val, 78, "(%^s:%c-%c, '*'¤Ç°ìÍ÷, ESC¤ÇÃæÃÇ) ¤É¤Î%s¤ò%^s¤Þ¤¹¤«? ",
144                 p, I2A(0), I2A(num - 1), p, jverb_buf );
145 #else
146         (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) %^s which %s? ",
147                 p, I2A(0), I2A(num - 1), prompt, p);
148 #endif
149
150         /* Get a spell from the user */
151
152         choice = (always_show_list || use_menu) ? ESCAPE:1;
153         while (!flag)
154         {
155                 if( choice==ESCAPE ) choice = ' '; 
156                 else if( !get_com(out_val, &choice, TRUE) )break; 
157
158                 if (use_menu && choice != ' ')
159                 {
160                         switch(choice)
161                         {
162                                 case '0':
163                                 {
164                                         screen_load();
165                                         return (FALSE);
166                                         break;
167                                 }
168
169                                 case '8':
170                                 case 'k':
171                                 case 'K':
172                                 {
173                                         menu_line += (num - 1);
174                                         break;
175                                 }
176
177                                 case '2':
178                                 case 'j':
179                                 case 'J':
180                                 {
181                                         menu_line++;
182                                         break;
183                                 }
184
185                                 case 'x':
186                                 case 'X':
187                                 case '\r':
188                                 case '\n':
189                                 {
190                                         i = menu_line - 1;
191                                         ask = FALSE;
192                                         break;
193                                 }
194                         }
195                         if (menu_line > num) menu_line -= num;
196                         /* Display a list of spells */
197                         print_spells(menu_line, spells, num, 1, 15, use_realm);
198                         if (ask) continue;
199                 }
200                 else
201                 {
202                         /* Request redraw */
203                         if ((choice == ' ') || (choice == '*') || (choice == '?'))
204                         {
205                                 /* Show the list */
206                                 if (!redraw)
207                                 {
208                                         /* Show list */
209                                         redraw = TRUE;
210
211                                         /* Save the screen */
212                                         screen_save();
213
214                                         /* Display a list of spells */
215                                         print_spells(menu_line, spells, num, 1, 15, use_realm);
216                                 }
217
218                                 /* Hide the list */
219                                 else
220                                 {
221                                         if (use_menu) continue;
222
223                                         /* Hide list */
224                                         redraw = FALSE;
225
226                                         /* Restore the screen */
227                                         screen_load();
228                                 }
229
230                                 /* Redo asking */
231                                 continue;
232                         }
233
234
235                         /* Note verify */
236                         ask = (isupper(choice));
237
238                         /* Lowercase */
239                         if (ask) choice = tolower(choice);
240
241                         /* Extract request */
242                         i = (islower(choice) ? A2I(choice) : -1);
243                 }
244
245                 /* Totally Illegal */
246                 if ((i < 0) || (i >= num))
247                 {
248                         bell();
249                         continue;
250                 }
251
252                 /* Save the spell index */
253                 spell = spells[i];
254
255                 /* Require "okay" spells */
256                 if (!spell_okay(spell, learned, FALSE, use_realm))
257                 {
258                         bell();
259 #ifdef JP
260                         msg_format("¤½¤Î%s¤ò%s¤³¤È¤Ï¤Ç¤­¤Þ¤»¤ó¡£", p, prompt);
261 #else
262                         msg_format("You may not %s that %s.", prompt, p);
263 #endif
264
265                         continue;
266                 }
267
268                 /* Verify it */
269                 if (ask)
270                 {
271                         char tmp_val[160];
272
273                         /* Access the spell */
274                         if (!is_magic(use_realm))
275                         {
276                                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
277                         }
278                         else
279                         {
280                                 s_ptr = &mp_ptr->info[use_realm - 1][spell];
281                         }
282
283                         /* Extract mana consumption rate */
284                         if (use_realm == REALM_HISSATSU)
285                         {
286                                 need_mana = s_ptr->smana;
287                         }
288                         else
289                         {
290                                 need_mana = mod_need_mana(s_ptr->smana, spell, use_realm);
291                         }
292
293                         /* Prompt */
294 #ifdef JP
295                         jverb1( prompt, jverb_buf );
296                         /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
297                         (void) strnfmt(tmp_val, 78, "%s(MP%d, ¼ºÇÔΨ%d%%)¤ò%s¤Þ¤¹¤«? ",
298                                 spell_names[technic2magic(use_realm)-1][spell], need_mana,
299                                        spell_chance(spell, use_realm),jverb_buf);
300 #else
301                         (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
302                                 prompt, spell_names[technic2magic(use_realm)-1][spell], need_mana,
303                                 spell_chance(spell, use_realm));
304 #endif
305
306
307                         /* Belay that order */
308                         if (!get_check(tmp_val)) continue;
309                 }
310
311                 /* Stop the loop */
312                 flag = TRUE;
313         }
314
315
316         /* Restore the screen */
317         if (redraw) screen_load();
318
319
320         /* Show choices */
321         if (show_choices)
322         {
323                 /* Update */
324                 p_ptr->window |= (PW_SPELL);
325
326                 /* Window stuff */
327                 window_stuff();
328         }
329
330
331         /* Abort if needed */
332         if (!flag) return (FALSE);
333
334         /* Save the choice */
335         (*sn) = spell;
336
337 #ifdef ALLOW_REPEAT /* TNB */
338
339         repeat_push(*sn);
340
341 #endif /* ALLOW_REPEAT -- TNB */
342
343         /* Success */
344         return (TRUE);
345 }
346
347
348 static bool item_tester_learn_spell(object_type *o_ptr)
349 {
350         s32b choices = realm_choices2[p_ptr->pclass];
351
352         if (p_ptr->pclass == CLASS_PRIEST)
353         {
354                 if (is_good_realm(p_ptr->realm1))
355                 {
356                         choices &= ~(CH_DEATH | CH_DAEMON);
357                 }
358                 else
359                 {
360                         choices &= ~(CH_LIFE | CH_CRUSADE);
361                 }
362         }
363
364         if ((o_ptr->tval < TV_LIFE_BOOK) || (o_ptr->tval > (TV_LIFE_BOOK + MAX_REALM - 1))) return (FALSE);
365         if ((o_ptr->tval == TV_MUSIC_BOOK) && (p_ptr->pclass == CLASS_BARD)) return (TRUE);
366         else if (!is_magic(tval2realm(o_ptr->tval))) return FALSE;
367         if ((REALM1_BOOK == o_ptr->tval) || (REALM2_BOOK == o_ptr->tval)) return (TRUE);
368         if (choices & (0x0001 << (tval2realm(o_ptr->tval) - 1))) return (TRUE);
369         return (FALSE);
370 }
371
372
373 /*
374  * Peruse the spells/prayers in a book
375  *
376  * Note that *all* spells in the book are listed
377  *
378  * Note that browsing is allowed while confused or blind,
379  * and in the dark, primarily to allow browsing in stores.
380  */
381 void do_cmd_browse(void)
382 {
383         int             item, sval, use_realm = 0, j, line;
384         int             spell = -1;
385         int             num = 0;
386         int             increment = 0;
387
388         byte            spells[64];
389         char            temp[62*4];
390
391         object_type     *o_ptr;
392         magic_type      *s_ptr;
393
394         cptr q, s;
395
396         /* Warriors are illiterate */
397         if (!(p_ptr->realm1 || p_ptr->realm2) && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
398         {
399 #ifdef JP
400 msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤­¤Ê¤¤¡ª");
401 #else
402                 msg_print("You cannot read books!");
403 #endif
404
405                 return;
406         }
407
408         if (p_ptr->special_defense & KATA_MUSOU)
409         {
410                 set_action(ACTION_NONE);
411         }
412
413         /* Restrict choices to "useful" books */
414         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
415         else item_tester_hook = item_tester_learn_spell;
416
417         /* Get an item */
418 #ifdef JP
419 q = "¤É¤ÎËܤòÆɤߤޤ¹¤«? ";
420 #else
421         q = "Browse which book? ";
422 #endif
423
424 #ifdef JP
425 s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
426 #else
427         s = "You have no books that you can read.";
428 #endif
429
430         if (p_ptr->pclass == CLASS_FORCETRAINER)
431                 select_the_force = TRUE;
432         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
433             select_the_force = FALSE;
434             return;
435         }
436         select_the_force = FALSE;
437
438         if (item == INVEN_FORCE) { /* the_force */
439             do_cmd_mind_browse();
440             return;
441         } else
442         /* Get the item (in the pack) */
443         if (item >= 0)
444         {
445                 o_ptr = &inventory[item];
446         }
447
448         /* Get the item (on the floor) */
449         else
450         {
451                 o_ptr = &o_list[0 - item];
452         }
453
454         /* Access the item's sval */
455         sval = o_ptr->sval;
456
457         use_realm = tval2realm(o_ptr->tval);
458         if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && is_magic(use_realm))
459         {
460                 if (o_ptr->tval == REALM2_BOOK) increment = 32;
461                 else if (o_ptr->tval != REALM1_BOOK) increment = 64;
462         }
463
464         /* Track the object kind */
465         object_kind_track(o_ptr->k_idx);
466
467         /* Hack -- Handle stuff */
468         handle_stuff();
469
470
471         /* Extract spells */
472         for (spell = 0; spell < 32; spell++)
473         {
474                 /* Check for this spell */
475                 if ((fake_spell_flags[sval] & (1L << spell)))
476                 {
477                         /* Collect this spell */
478                         spells[num++] = spell;
479                 }
480         }
481
482
483         /* Save the screen */
484         screen_save();
485
486         /* Clear the top line */
487         prt("", 0, 0);
488
489         /* Keep browsing spells.  Exit browsing on cancel. */
490         while(TRUE)
491         {
492                 /* Ask for a spell, allow cancel */
493 #ifdef JP
494                 if (!get_spell(&spell, "Æɤà", o_ptr->sval, TRUE, use_realm))
495 #else
496                 if (!get_spell(&spell, "browse", o_ptr->sval, TRUE, use_realm))
497 #endif
498                 {
499                         /* If cancelled, leave immediately. */
500                         if (spell == -1) break;
501
502                         /* Display a list of spells */
503                         print_spells(0, spells, num, 1, 15, use_realm);
504
505                         /* Notify that there's nothing to see, and wait. */
506                         if (use_realm == REALM_HISSATSU)
507 #ifdef JP
508                                 prt("Æɤá¤ëµ»¤¬¤Ê¤¤¡£", 0, 0);
509 #else
510                                 prt("No techniques to browse.", 0, 0);
511 #endif
512                         else
513 #ifdef JP
514                                 prt("Æɤá¤ë¼öʸ¤¬¤Ê¤¤¡£", 0, 0);
515 #else
516                                 prt("No spells to browse.", 0, 0);
517 #endif
518                         (void)inkey();
519                         
520
521                         /* Restore the screen */
522                         screen_load();
523
524                         return;
525                 }                                 
526
527                 /* Clear lines, position cursor  (really should use strlen here) */
528                 Term_erase(14, 14, 255);
529                 Term_erase(14, 13, 255);
530                 Term_erase(14, 12, 255);
531                 Term_erase(14, 11, 255);
532
533                 /* Access the spell */
534                 if (!is_magic(use_realm))
535                 {
536                         s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
537                 }
538                 else
539                 {
540                         s_ptr = &mp_ptr->info[use_realm - 1][spell];
541                 }
542
543                 roff_to_buf(spell_tips[technic2magic(use_realm)-1][spell] ,62, temp, sizeof(temp));
544                 for(j=0, line = 11;temp[j];j+=(1+strlen(&temp[j])))
545                 {
546                         prt(&temp[j], line, 15);
547                         line++;
548                 }
549         }
550
551         /* Restore the screen */
552         screen_load();
553 }
554
555
556 static void change_realm2(int next_realm)
557 {
558         int i, j=0;
559         char tmp[80];
560
561         for (i = 0; i < 64; i++)
562         {
563                 p_ptr->spell_order[j] = p_ptr->spell_order[i];
564                 if(p_ptr->spell_order[i] < 32) j++;
565         }
566         for (; j < 64; j++)
567                 p_ptr->spell_order[j] = 99;
568
569         for (i = 32; i < 64; i++)
570         {
571                 p_ptr->spell_exp[i] = 0;
572         }
573         p_ptr->spell_learned2 = 0L;
574         p_ptr->spell_worked2 = 0L;
575         p_ptr->spell_forgotten2 = 0L;   
576
577 #ifdef JP
578         sprintf(tmp,"ËâË¡¤ÎÎΰè¤ò%s¤«¤é%s¤ËÊѹ¹¤·¤¿¡£", realm_names[p_ptr->realm2], realm_names[next_realm]);
579 #else
580         sprintf(tmp,"change magic realm from %s to %s.", realm_names[p_ptr->realm2], realm_names[next_realm]);
581 #endif
582         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, tmp);
583         p_ptr->old_realm |= 1 << (p_ptr->realm2-1);
584         p_ptr->realm2 = next_realm;
585
586         p_ptr->notice |= (PN_REORDER);
587         p_ptr->update |= (PU_SPELLS);
588         handle_stuff();
589 }
590
591
592 /*
593  * Study a book to gain a new spell/prayer
594  */
595 void do_cmd_study(void)
596 {
597         int     i, item, sval;
598         int     increment = 0;
599         bool    learned = FALSE;
600
601         /* Spells of realm2 will have an increment of +32 */
602         int     spell = -1;
603
604         cptr p = spell_categoly_name(mp_ptr->spell_book);
605
606         object_type *o_ptr;
607
608         cptr q, s;
609
610         if (!p_ptr->realm1)
611         {
612 #ifdef JP
613 msg_print("ËܤòÆɤळ¤È¤¬¤Ç¤­¤Ê¤¤¡ª");
614 #else
615                 msg_print("You cannot read books!");
616 #endif
617
618                 return;
619         }
620
621         if (p_ptr->blind || no_lite())
622         {
623 #ifdef JP
624 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
625 #else
626                 msg_print("You cannot see!");
627 #endif
628
629                 return;
630         }
631
632         if (p_ptr->confused)
633         {
634 #ifdef JP
635 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
636 #else
637                 msg_print("You are too confused!");
638 #endif
639
640                 return;
641         }
642
643         if (!(p_ptr->new_spells))
644         {
645 #ifdef JP
646 msg_format("¿·¤·¤¤%s¤ò³Ð¤¨¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡ª", p);
647 #else
648                 msg_format("You cannot learn any new %ss!", p);
649 #endif
650
651                 return;
652         }
653
654         if (p_ptr->special_defense & KATA_MUSOU)
655         {
656                 set_action(ACTION_NONE);
657         }
658
659         p = spell_categoly_name(mp_ptr->spell_book);
660
661 #ifdef JP
662         if( p_ptr->new_spells < 10 ){
663                 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
664         }else{
665                 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
666         }
667 #else
668         msg_format("You can learn %d new %s%s.", p_ptr->new_spells, p,
669                 (p_ptr->new_spells == 1?"":"s"));
670 #endif
671
672         msg_print(NULL);
673
674
675         /* Restrict choices to "useful" books */
676         if (p_ptr->realm2 == REALM_NONE) item_tester_tval = mp_ptr->spell_book;
677         else item_tester_hook = item_tester_learn_spell;
678
679         /* Get an item */
680 #ifdef JP
681 q = "¤É¤ÎËܤ«¤é³Ø¤Ó¤Þ¤¹¤«? ";
682 #else
683         q = "Study which book? ";
684 #endif
685
686 #ifdef JP
687 s = "Æɤá¤ëËܤ¬¤Ê¤¤¡£";
688 #else
689         s = "You have no books that you can read.";
690 #endif
691
692         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
693
694         /* Get the item (in the pack) */
695         if (item >= 0)
696         {
697                 o_ptr = &inventory[item];
698         }
699
700         /* Get the item (on the floor) */
701         else
702         {
703                 o_ptr = &o_list[0 - item];
704         }
705
706         /* Access the item's sval */
707         sval = o_ptr->sval;
708
709         if (o_ptr->tval == REALM2_BOOK) increment = 32;
710         else if (o_ptr->tval != REALM1_BOOK)
711         {
712 #ifdef JP
713                 if (!get_check("ËÜÅö¤ËËâË¡¤ÎÎΰè¤òÊѹ¹¤·¤Þ¤¹¤«¡©")) return;
714 #else
715                 if (!get_check("Really, change magic realm? ")) return;
716 #endif
717                 change_realm2(tval2realm(o_ptr->tval));
718                 increment = 32;
719         }
720
721         /* Track the object kind */
722         object_kind_track(o_ptr->k_idx);
723
724         /* Hack -- Handle stuff */
725         handle_stuff();
726
727         /* Mage -- Learn a selected spell */
728         if (mp_ptr->spell_book != TV_LIFE_BOOK)
729         {
730                 /* Ask for a spell, allow cancel */
731 #ifdef JP
732                 if (!get_spell(&spell, "³Ø¤Ö", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
733                         && (spell == -1)) return;
734 #else
735                 if (!get_spell(&spell, "study", sval, FALSE, o_ptr->tval - TV_LIFE_BOOK + 1)
736                         && (spell == -1)) return;
737 #endif
738
739         }
740
741         /* Priest -- Learn a random prayer */
742         else
743         {
744                 int k = 0;
745
746                 int gift = -1;
747
748                 /* Extract spells */
749                 for (spell = 0; spell < 32; spell++)
750                 {
751                         /* Check spells in the book */
752                         if ((fake_spell_flags[sval] & (1L << spell)))
753                         {
754                                 /* Skip non "okay" prayers */
755                                 if (!spell_okay(spell, FALSE, TRUE,
756                                         (increment ? p_ptr->realm2 : p_ptr->realm1))) continue;
757
758                                 /* Hack -- Prepare the randomizer */
759                                 k++;
760
761                                 /* Hack -- Apply the randomizer */
762                                 if (one_in_(k)) gift = spell;
763                         }
764                 }
765
766                 /* Accept gift */
767                 spell = gift;
768         }
769
770         /* Nothing to study */
771         if (spell < 0)
772         {
773                 /* Message */
774 #ifdef JP
775 msg_format("¤½¤ÎËܤˤϳؤ֤٤­%s¤¬¤Ê¤¤¡£", p);
776 #else
777                 msg_format("You cannot learn any %ss in that book.", p);
778 #endif
779
780
781                 /* Abort */
782                 return;
783         }
784
785
786         if (increment) spell += increment;
787
788         /* Learn the spell */
789         if (spell < 32)
790         {
791                 if (p_ptr->spell_learned1 & (1L << spell)) learned = TRUE;
792                 else p_ptr->spell_learned1 |= (1L << spell);
793         }
794         else
795         {
796                 if (p_ptr->spell_learned2 & (1L << (spell - 32))) learned = TRUE;
797                 else p_ptr->spell_learned2 |= (1L << (spell - 32));
798         }
799
800         if (learned)
801         {
802                 int max_exp = (spell < 32) ? 1600 : 1400;
803                 int old_exp = p_ptr->spell_exp[spell];
804                 int new_rank = 0;
805                 cptr name = spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell%32];
806
807                 if (old_exp >= max_exp)
808                 {
809 #ifdef JP
810                         msg_format("¤½¤Î%s¤Ï´°Á´¤Ë»È¤¤¤³¤Ê¤»¤ë¤Î¤Ç³Ø¤ÖɬÍפϤʤ¤¡£", spell_categoly_name(mp_ptr->spell_book));
811 #else
812                         msg_format("You don't need to study this %s anymore.", spell_categoly_name(mp_ptr->spell_book));
813 #endif
814                         return;
815                 }
816 #ifdef JP
817                 if (!get_check(format("%s¤Î%s¤ò¤µ¤é¤Ë³Ø¤Ó¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©", name, spell_categoly_name(mp_ptr->spell_book))))
818 #else
819                 if (!get_check(format("You will study a %s of %s again. Are you sure? ", spell_categoly_name(mp_ptr->spell_book), name)))
820 #endif
821                 {
822                         return;
823                 }
824                 else if (old_exp >= 1400)
825                 {
826                         p_ptr->spell_exp[spell] = 1600;
827                         new_rank = 4;
828                 }
829                 else if (old_exp >= 1200)
830                 {
831                         if (spell >= 32) p_ptr->spell_exp[spell] = 1400;
832                         else p_ptr->spell_exp[spell] += 200;
833                         new_rank = 3;
834                 }
835                 else if (old_exp >= 900)
836                 {
837                         p_ptr->spell_exp[spell] = 1200+(old_exp-900)*2/3;
838                         new_rank = 2;
839                 }
840                 else
841                 {
842                         p_ptr->spell_exp[spell] = 900+(old_exp)/3;
843                         new_rank = 1;
844                 }
845 #ifdef JP
846                 msg_format("%s¤Î½ÏÎýÅÙ¤¬%s¤Ë¾å¤¬¤Ã¤¿¡£", name, shougou_moji[new_rank]);
847 #else
848                 msg_format("Your proficiency of %s is now %s rank.", name, shougou_moji[new_rank]);
849 #endif
850         }
851         else
852         {
853                 /* Find the next open entry in "p_ptr->spell_order[]" */
854                 for (i = 0; i < 64; i++)
855                 {
856                         /* Stop at the first empty space */
857                         if (p_ptr->spell_order[i] == 99) break;
858                 }
859
860                 /* Add the spell to the known list */
861                 p_ptr->spell_order[i++] = spell;
862
863                 /* Mention the result */
864 #ifdef JP
865                 /* ±ÑÆüÀÚ¤êÂؤ¨µ¡Ç½¤ËÂбþ */
866                 if (mp_ptr->spell_book == TV_MUSIC_BOOK)
867                 {
868                         msg_format("%s¤ò³Ø¤ó¤À¡£",
869                                     spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell % 32]);
870                 }
871                 else
872                 {
873                         msg_format("%s¤Î%s¤ò³Ø¤ó¤À¡£",
874                                     spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell % 32] ,p);
875                 }
876 #else
877                 msg_format("You have learned the %s of %s.",
878                         p, spell_names[technic2magic(increment ? p_ptr->realm2 : p_ptr->realm1)-1][spell % 32]);
879 #endif
880         }
881
882         /* Take a turn */
883         energy_use = 100;
884
885         if (mp_ptr->spell_book == TV_LIFE_BOOK)
886                 chg_virtue(V_FAITH, 1);
887         else if (mp_ptr->spell_book == TV_DEATH_BOOK)
888                 chg_virtue(V_UNLIFE, 1);
889         else if (mp_ptr->spell_book == TV_NATURE_BOOK)
890                 chg_virtue(V_NATURE, 1);
891         else
892                 chg_virtue(V_KNOWLEDGE, 1);
893
894         /* Sound */
895         sound(SOUND_STUDY);
896
897         /* One less spell available */
898         p_ptr->learned_spells++;
899 #if 0
900         /* Message if needed */
901         if (p_ptr->new_spells)
902         {
903                 /* Message */
904 #ifdef JP
905                         if( p_ptr->new_spells < 10 ){
906                                 msg_format("¤¢¤È %d ¤Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
907                         }else{
908                                 msg_format("¤¢¤È %d ¸Ä¤Î%s¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells, p);
909                         }
910 #else
911                 msg_format("You can learn %d more %s%s.",
912                         p_ptr->new_spells, p,
913                         (p_ptr->new_spells != 1) ? "s" : "");
914 #endif
915
916         }
917 #endif
918
919         /* Update Study */
920         p_ptr->update |= (PU_SPELLS);
921         update_stuff();
922
923         /* Redraw object recall */
924         p_ptr->window |= (PW_OBJECT);
925 }
926
927
928 static void wild_magic(int spell)
929 {
930         int counter = 0;
931         int type = SUMMON_BIZARRE1 + randint0(6);
932
933         if (type < SUMMON_BIZARRE1) type = SUMMON_BIZARRE1;
934         else if (type > SUMMON_BIZARRE6) type = SUMMON_BIZARRE6;
935
936         switch (randint1(spell) + randint1(8) + 1)
937         {
938         case 1:
939         case 2:
940         case 3:
941                 teleport_player(10);
942                 break;
943         case 4:
944         case 5:
945         case 6:
946                 teleport_player(100);
947                 break;
948         case 7:
949         case 8:
950                 teleport_player(200);
951                 break;
952         case 9:
953         case 10:
954         case 11:
955                 unlite_area(10, 3);
956                 break;
957         case 12:
958         case 13:
959         case 14:
960                 lite_area(damroll(2, 3), 2);
961                 break;
962         case 15:
963                 destroy_doors_touch();
964                 break;
965         case 16: case 17:
966                 wall_breaker();
967         case 18:
968                 sleep_monsters_touch();
969                 break;
970         case 19:
971         case 20:
972                 trap_creation(py, px);
973                 break;
974         case 21:
975         case 22:
976                 door_creation();
977                 break;
978         case 23:
979         case 24:
980         case 25:
981                 aggravate_monsters(0);
982                 break;
983         case 26:
984                 earthquake(py, px, 5);
985                 break;
986         case 27:
987         case 28:
988                 (void)gain_random_mutation(0);
989                 break;
990         case 29:
991         case 30:
992                 apply_disenchant(1);
993                 break;
994         case 31:
995                 lose_all_info();
996                 break;
997         case 32:
998                 fire_ball(GF_CHAOS, 0, spell + 5, 1 + (spell / 10));
999                 break;
1000         case 33:
1001                 wall_stone();
1002                 break;
1003         case 34:
1004         case 35:
1005                 while (counter++ < 8)
1006                 {
1007                         (void)summon_specific(0, py, px, (dun_level * 3) / 2, type, (PM_ALLOW_GROUP | PM_NO_PET));
1008                 }
1009                 break;
1010         case 36:
1011         case 37:
1012                 activate_hi_summon(py, px, FALSE);
1013                 break;
1014         case 38:
1015                 (void)summon_cyber(-1, py, px);
1016                 break;
1017         default:
1018                 {
1019                         int count = 0;
1020                         (void)activate_ty_curse(FALSE, &count);
1021                         break;
1022                 }
1023         }
1024
1025         return;
1026 }
1027
1028
1029 static bool cast_life_spell(int spell)
1030 {
1031         int     dir;
1032         int     plev = p_ptr->lev;
1033
1034         switch (spell)
1035         {
1036         case 0: /* Cure Light Wounds */
1037                 (void)hp_player(damroll(2, 10));
1038                 (void)set_cut(p_ptr->cut - 10);
1039                 break;
1040         case 1: /* Bless */
1041                 (void)set_blessed(randint1(12) + 12, FALSE);
1042                 break;
1043         case 2: /* Make Light Wounds */
1044                 if (!get_aim_dir(&dir)) return FALSE;
1045                 fire_ball_hide(GF_WOUNDS, dir, damroll(3 + ((plev - 1) / 5), 4), 0);
1046                 break;
1047         case 3: /* Call Light */
1048                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
1049                 break;
1050         case 4: /* Detect Traps + Secret Doors */
1051                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1052                 (void)detect_doors(DETECT_RAD_DEFAULT);
1053                 (void)detect_stairs(DETECT_RAD_DEFAULT);
1054                 break;
1055         case 5: /* Cure Medium Wounds */
1056                 (void)hp_player(damroll(4, 10));
1057                 (void)set_cut((p_ptr->cut / 2) - 20);
1058                 break;
1059         case 6: /* Cure Poison */
1060                 (void)set_poisoned(0);
1061                 break;
1062         case 7: /* Satisfy Hunger */
1063                 (void)set_food(PY_FOOD_MAX - 1);
1064                 break;
1065         case 8: /* Remove Curse */
1066                 if (remove_curse())
1067                 {
1068 #ifdef JP
1069                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1070 #else
1071                         msg_print("You feel as if someone is watching over you.");
1072 #endif
1073                 }
1074                 break;
1075         case 9: /* Make Medium Wounds */
1076                 if (!get_aim_dir(&dir)) return FALSE;
1077                 fire_ball_hide(GF_WOUNDS, dir, damroll(8 + ((plev - 5) / 4), 8), 0);
1078                 break;
1079         case 10: /* Cure Critical Wounds */
1080                 (void)hp_player(damroll(8, 10));
1081                 (void)set_stun(0);
1082                 (void)set_cut(0);
1083                 break;
1084         case 11:
1085                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
1086                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
1087                 break;
1088         case 12:
1089                 map_area(DETECT_RAD_MAP);
1090                 break;
1091         case 13:
1092                 (void)turn_undead();
1093                 break;
1094         case 14: /* Healing */
1095                 (void)hp_player(300);
1096                 (void)set_stun(0);
1097                 (void)set_cut(0);
1098                 break;
1099         case 15: /* Glyph of Warding */
1100                 warding_glyph();
1101                 break;
1102         case 16: /* Dispel Curse */
1103                 if (remove_all_curse())
1104                 {
1105 #ifdef JP
1106                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1107 #else
1108                         msg_print("You feel as if someone is watching over you.");
1109 #endif
1110                 }
1111                 break;
1112         case 17: /* Perception */
1113                 return ident_spell(FALSE);
1114         case 18: /* Dispel Undead */
1115                 (void)dispel_undead(randint1(plev * 5));
1116                 break;
1117         case 19: /* 'Day of the Dove' */
1118                 charm_monsters(plev * 2);
1119                 break;
1120         case 20: /* Make Critical Wounds */
1121                 if (!get_aim_dir(&dir)) return FALSE;
1122                 fire_ball_hide(GF_WOUNDS, dir, damroll(5+((plev - 5) / 3), 15), 0);
1123                 break;
1124         case 21: /* Word of Recall */
1125                 if (!word_of_recall()) return FALSE;
1126                 break;
1127         case 22: /* Alter Reality */
1128                 alter_reality();
1129                 break;
1130         case 23: /* Warding True */
1131                 warding_glyph();
1132                 glyph_creation();
1133                 break;
1134         case 24:
1135                 num_repro += MAX_REPRO;
1136                 break;
1137         case 25: /* Detection True */
1138                 (void)detect_all(DETECT_RAD_DEFAULT);
1139                 break;
1140         case 26: /* Genocide Undead */
1141                 (void)mass_genocide_undead(plev+50,TRUE);
1142                 break;
1143         case 27: /* Clairvoyance */
1144                 wiz_lite(FALSE);
1145                 break;
1146         case 28: /* Restoration */
1147                 (void)do_res_stat(A_STR);
1148                 (void)do_res_stat(A_INT);
1149                 (void)do_res_stat(A_WIS);
1150                 (void)do_res_stat(A_DEX);
1151                 (void)do_res_stat(A_CON);
1152                 (void)do_res_stat(A_CHR);
1153                 (void)restore_level();
1154                 break;
1155         case 29: /* Healing True */
1156                 (void)hp_player(2000);
1157                 (void)set_stun(0);
1158                 (void)set_cut(0);
1159                 break;
1160         case 30: /* Holy Vision */
1161                 return identify_fully(FALSE);
1162         case 31: /* Ultimate resistance */
1163         {
1164                 int v = randint1(plev/2)+plev/2;
1165                 (void)set_fast(v, FALSE);
1166                 set_oppose_acid(v, FALSE);
1167                 set_oppose_elec(v, FALSE);
1168                 set_oppose_fire(v, FALSE);
1169                 set_oppose_cold(v, FALSE);
1170                 set_oppose_pois(v, FALSE);
1171                 set_ultimate_res(v, FALSE);
1172                 break;
1173         }
1174         default:
1175 #ifdef JP
1176 msg_format("¤¢¤Ê¤¿¤ÏÉÔÌÀ¤Ê¥é¥¤¥Õ¤Î¼öʸ %d ¤ò¾§¤¨¤¿¡£", spell);
1177 #else
1178                 msg_format("You cast an unknown Life spell: %d.", spell);
1179 #endif
1180
1181                 msg_print(NULL);
1182         }
1183
1184         return TRUE;
1185 }
1186
1187
1188
1189 static bool cast_sorcery_spell(int spell)
1190 {
1191         int     dir;
1192         int     plev = p_ptr->lev;
1193
1194         switch (spell)
1195         {
1196         case 0: /* Detect Monsters */
1197                 (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
1198                 break;
1199         case 1: /* Phase Door */
1200                 teleport_player(10);
1201                 break;
1202         case 2: /* Detect Doors and Traps */
1203                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1204                 (void)detect_doors(DETECT_RAD_DEFAULT);
1205                 (void)detect_stairs(DETECT_RAD_DEFAULT);
1206                 break;
1207         case 3: /* Light Area */
1208                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
1209                 break;
1210         case 4: /* Confuse Monster */
1211                 if (!get_aim_dir(&dir)) return FALSE;
1212
1213                 (void)confuse_monster(dir, (plev * 3) / 2);
1214                 break;
1215         case 5: /* Teleport */
1216                 teleport_player(plev * 5);
1217                 break;
1218         case 6: /* Sleep Monster */
1219                 if (!get_aim_dir(&dir)) return FALSE;
1220
1221                 (void)sleep_monster(dir);
1222                 break;
1223         case 7: /* Recharging */
1224                 return recharge(plev * 4);
1225         case 8: /* Magic Mapping */
1226                 map_area(DETECT_RAD_MAP);
1227                 break;
1228         case 9: /* Identify */
1229                 return ident_spell(FALSE);
1230         case 10: /* Slow Monster */
1231                 if (!get_aim_dir(&dir)) return FALSE;
1232
1233                 (void)slow_monster(dir);
1234                 break;
1235         case 11: /* Mass Sleep */
1236                 (void)sleep_monsters();
1237                 break;
1238         case 12: /* Teleport Away */
1239                 if (!get_aim_dir(&dir)) return FALSE;
1240
1241                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
1242                 break;
1243         case 13: /* Haste Self */
1244                 (void)set_fast(randint1(20 + plev) + plev, FALSE);
1245                 break;
1246         case 14: /* Detection True */
1247                 (void)detect_all(DETECT_RAD_DEFAULT);
1248                 break;
1249         case 15: /* Identify True */
1250                 return identify_fully(FALSE);
1251         case 16: /* Detect Objects and Treasure*/
1252                 (void)detect_objects_normal(DETECT_RAD_DEFAULT);
1253                 (void)detect_treasure(DETECT_RAD_DEFAULT);
1254                 (void)detect_objects_gold(DETECT_RAD_DEFAULT);
1255                 break;
1256         case 17: /* Charm Monster */
1257                 if (!get_aim_dir(&dir)) return FALSE;
1258
1259                 (void)charm_monster(dir, plev);
1260                 break;
1261         case 18: /* Sense Minds */
1262                 (void)set_tim_esp(randint1(30) + 25, FALSE);
1263                 break;
1264         case 19: /* Teleport to town */
1265                 return tele_town();
1266                 break;
1267         case 20: /* Self knowledge */
1268                 (void)self_knowledge();
1269                 break;
1270         case 21: /* Teleport Level */
1271 #ifdef JP
1272                 if (!get_check("ËÜÅö¤Ë¾¤Î³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©")) return FALSE;
1273 #else
1274                 if (!get_check("Are you sure? (Teleport Level)")) return FALSE;
1275 #endif
1276                 (void)teleport_player_level();
1277                 break;
1278         case 22: /* Word of Recall */
1279                 if (!word_of_recall()) return FALSE;
1280                 break;
1281         case 23: /* Dimension Door */
1282 #ifdef JP
1283 msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
1284 #else
1285                 msg_print("You open a dimensional gate. Choose a destination.");
1286 #endif
1287
1288                 return dimension_door();
1289         case 24: /* Probing */
1290                 (void)probing();
1291                 break;
1292         case 25: /* Explosive Rune */
1293                 explosive_rune();
1294                 break;
1295         case 26: /* Telekinesis */
1296                 if (!get_aim_dir(&dir)) return FALSE;
1297
1298                 fetch(dir, plev * 15, FALSE);
1299                 break;
1300         case 27: /* Clairvoyance */
1301                 chg_virtue(V_KNOWLEDGE, 1);
1302                 chg_virtue(V_ENLIGHTEN, 1);
1303
1304                 wiz_lite(FALSE);
1305                 if (!(p_ptr->telepathy))
1306                 {
1307                         (void)set_tim_esp(randint1(30) + 25, FALSE);
1308                 }
1309                 break;
1310         case 28: /* Charm Monsters */
1311                 charm_monsters(plev * 2);
1312                 break;
1313         case 29: /* Alchemy */
1314                 return alchemy();
1315         case 30: /* Banish */
1316                 banish_monsters(plev * 4);
1317                 break;
1318         case 31: /* Globe of Invulnerability */
1319                 (void)set_invuln(randint1(4) + 4, FALSE);
1320                 break;
1321         default:
1322 #ifdef JP
1323 msg_format("¤¢¤Ê¤¿¤ÏÉÔÌÀ¤Ê¥½¡¼¥µ¥ê¡¼¤Î¼öʸ %d ¤ò¾§¤¨¤¿¡£", spell);
1324 #else
1325                 msg_format("You cast an unknown Sorcery spell: %d.", spell);
1326 #endif
1327
1328                 msg_print(NULL);
1329         }
1330
1331         return TRUE;
1332 }
1333
1334
1335 static bool cast_nature_spell(int spell)
1336 {
1337         int         dir;
1338         int         beam;
1339         int         plev = p_ptr->lev;
1340         bool    no_trump = FALSE;
1341
1342         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
1343         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
1344         else beam = plev / 2;
1345
1346         switch (spell)
1347         {
1348         case 0: /* Detect Creatures */
1349                 (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
1350                 break;
1351         case 1: /* Lightning Bolt */
1352                 project_length = plev / 6 + 2;
1353                 if (!get_aim_dir(&dir)) return FALSE;
1354
1355                 fire_beam(GF_ELEC, dir,
1356                         damroll(3 + ((plev - 1) / 5), 4));
1357                 break;
1358         case 2: /* Detect Doors & Traps */
1359                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1360                 (void)detect_doors(DETECT_RAD_DEFAULT);
1361                 (void)detect_stairs(DETECT_RAD_DEFAULT);
1362                 break;
1363         case 3: /* Produce Food */
1364         {
1365                 object_type forge, *q_ptr = &forge;
1366
1367 #ifdef JP
1368                 msg_print("¿©ÎÁ¤òÀ¸À®¤·¤¿¡£");
1369 #else
1370                 msg_print("A food ration is produced.");
1371 #endif
1372
1373                 /* Create the food ration */
1374                 object_prep(q_ptr, lookup_kind(TV_FOOD, SV_FOOD_RATION));
1375
1376                 /* Drop the object from heaven */
1377                 (void)drop_near(q_ptr, -1, py, px);
1378                 break;
1379
1380         }
1381         case 4: /* Daylight */
1382                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
1383                 if ((prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) && !p_ptr->resist_lite)
1384                 {
1385 #ifdef JP
1386 msg_print("Æü¤Î¸÷¤¬¤¢¤Ê¤¿¤ÎÆùÂΤò¾Ç¤¬¤·¤¿¡ª");
1387 #else
1388                         msg_print("The daylight scorches your flesh!");
1389 #endif
1390
1391 #ifdef JP
1392 take_hit(DAMAGE_NOESCAPE, damroll(2, 2), "Æü¤Î¸÷", -1);
1393 #else
1394                         take_hit(DAMAGE_NOESCAPE, damroll(2, 2), "daylight", -1);
1395 #endif
1396
1397                 }
1398                 break;
1399         case 5: /* Animal Taming */
1400                 if (!get_aim_dir(&dir)) return FALSE;
1401
1402                 (void)charm_animal(dir, plev);
1403                 break;
1404         case 6: /* Resist Environment */
1405                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
1406                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
1407                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
1408                 break;
1409         case 7: /* Cure Wounds & Poison */
1410                 (void)hp_player(damroll(2, 8));
1411                 (void)set_cut(0);
1412                 (void)set_poisoned(0);
1413                 break;
1414         case 8: /* Stone to Mud */
1415                 if (!get_aim_dir(&dir)) return FALSE;
1416
1417                 (void)wall_to_mud(dir);
1418                 break;
1419         case 9: /* Frost Bolt */
1420                 if (!get_aim_dir(&dir)) return FALSE;
1421                 fire_bolt_or_beam(beam - 10, GF_COLD, dir,
1422                         damroll(3 + ((plev - 5) / 4), 8));
1423                 break;
1424         case 10: /* Nature Awareness -- downgraded */
1425                 map_area(DETECT_RAD_MAP);
1426                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
1427                 (void)detect_doors(DETECT_RAD_DEFAULT);
1428                 (void)detect_stairs(DETECT_RAD_DEFAULT);
1429                 (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
1430                 break;
1431         case 11: /* Fire Bolt */
1432                 if (!get_aim_dir(&dir)) return FALSE;
1433                 fire_bolt_or_beam(beam - 10, GF_FIRE, dir,
1434                         damroll(5 + ((plev - 5) / 4), 8));
1435                 break;
1436         case 12: /* Ray of Sunlight */
1437                 if (!get_aim_dir(&dir)) return FALSE;
1438 #ifdef JP
1439 msg_print("ÂÀÍÛ¸÷Àþ¤¬¸½¤ì¤¿¡£");
1440 #else
1441                 msg_print("A line of sunlight appears.");
1442 #endif
1443
1444                 (void)lite_line(dir);
1445                 break;
1446         case 13: /* Entangle */
1447                 slow_monsters();
1448                 break;
1449         case 14: /* Summon Animals */
1450                 if (!(summon_specific(-1, py, px, plev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET))))
1451                         no_trump = TRUE;
1452                 break;
1453         case 15: /* Herbal Healing */
1454                 (void)hp_player(500);
1455                 (void)set_stun(0);
1456                 (void)set_cut(0);
1457                 (void)set_poisoned(0);
1458                 break;
1459         case 16: /* Stair Building */
1460                 (void)stair_creation();
1461                 break;
1462         case 17: /* Stone Skin */
1463                 (void)set_shield(randint1(20) + 30, FALSE);
1464                 break;
1465         case 18: /* Resistance True */
1466                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
1467                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
1468                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
1469                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
1470                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
1471                 break;
1472         case 19: /* Tree Creation */
1473                 (void)tree_creation();
1474                 break;
1475         case 20: /* Animal Friendship */
1476                 (void)charm_animals(plev * 2);
1477                 break;
1478         case 21: /* Stone Tell */
1479                 return identify_fully(FALSE);
1480         case 22: /* Wall of Stone */
1481                 (void)wall_stone();
1482                 break;
1483         case 23: /* Protection from Corrosion */
1484                 return rustproof();
1485         case 24: /* Earthquake */
1486                 earthquake(py, px, 10);
1487                 break;
1488         case 25: /* Whirlwind Attack */
1489                 {
1490                         int y = 0, x = 0;
1491                         cave_type       *c_ptr;
1492                         monster_type    *m_ptr;
1493
1494                         for (dir = 0; dir < 8; dir++)
1495                         {
1496                                 y = py + ddy_ddd[dir];
1497                                 x = px + ddx_ddd[dir];
1498                                 c_ptr = &cave[y][x];
1499
1500                                 /* Get the monster */
1501                                 m_ptr = &m_list[c_ptr->m_idx];
1502
1503                                 /* Hack -- attack monsters */
1504                                 if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x)))
1505                                         py_attack(y, x, 0);
1506                         }
1507                 }
1508                 break;
1509         case 26: /* Blizzard */
1510                 if (!get_aim_dir(&dir)) return FALSE;
1511
1512                 fire_ball(GF_COLD, dir, 70 + plev * 3 / 2, (plev / 12) + 1);
1513                 break;
1514         case 27: /* Lightning Storm */
1515                 if (!get_aim_dir(&dir)) return FALSE;
1516                 fire_ball(GF_ELEC, dir, 90 + plev * 3 / 2, (plev / 12) + 1);
1517                 break;
1518         case 28: /* Whirlpool */
1519                 if (!get_aim_dir(&dir)) return FALSE;
1520                 fire_ball(GF_WATER, dir, 100 + plev * 3 / 2, (plev / 12) + 1);
1521                 break;
1522         case 29: /* Call Sunlight */
1523                 fire_ball(GF_LITE, 0, 150, 8);
1524                 chg_virtue(V_KNOWLEDGE, 1);
1525                 chg_virtue(V_ENLIGHTEN, 1);
1526                 wiz_lite(FALSE);
1527                 if ((prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) && !p_ptr->resist_lite)
1528                 {
1529 #ifdef JP
1530 msg_print("Æü¸÷¤¬¤¢¤Ê¤¿¤ÎÆùÂΤò¾Ç¤¬¤·¤¿¡ª");
1531 #else
1532                         msg_print("The sunlight scorches your flesh!");
1533 #endif
1534
1535 #ifdef JP
1536 take_hit(DAMAGE_NOESCAPE, 50, "Æü¸÷", -1);
1537 #else
1538                         take_hit(DAMAGE_NOESCAPE, 50, "sunlight", -1);
1539 #endif
1540
1541                 }
1542                 break;
1543         case 30: /* Elemental Branding */
1544                 brand_weapon(randint0(2));
1545                 break;
1546         case 31: /* Nature's Wrath */
1547                 (void)dispel_monsters(plev * 4);
1548                 earthquake(py, px, 20 + (plev / 2));
1549                 project(0, 1 + plev / 12, py, px,
1550                         (100 + plev) * 2, GF_DISINTEGRATE, PROJECT_KILL | PROJECT_ITEM, -1);
1551                 break;
1552         default:
1553 #ifdef JP
1554 msg_format("¤¢¤Ê¤¿¤ÏÉÔÌÀ¤Ê¥Í¥¤¥Á¥ã¡¼¤Î¼öʸ %d ¤ò¾§¤¨¤¿¡£", spell);
1555 #else
1556                 msg_format("You cast an unknown Nature spell: %d.", spell);
1557 #endif
1558
1559                 msg_print(NULL);
1560         }
1561
1562         if (no_trump)
1563 #ifdef JP
1564 msg_print("ưʪ¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
1565 #else
1566                 msg_print("No animals arrive.");
1567 #endif
1568
1569
1570         return TRUE;
1571 }
1572
1573
1574 static bool cast_chaos_spell(int spell)
1575 {
1576         int     dir, i, beam;
1577         int     plev = p_ptr->lev;
1578
1579         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
1580         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
1581         else beam = plev / 2;
1582
1583         switch (spell)
1584         {
1585         case 0: /* Magic Missile */
1586                 if (!get_aim_dir(&dir)) return FALSE;
1587
1588                 fire_bolt_or_beam(beam - 10, GF_MISSILE, dir,
1589                         damroll(3 + ((plev - 1) / 5), 4));
1590                 break;
1591         case 1: /* Trap / Door destruction */
1592                 (void)destroy_doors_touch();
1593                 break;
1594         case 2: /* Flash of Light == Light Area */
1595                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
1596                 break;
1597         case 3: /* Touch of Confusion */
1598                 if (!(p_ptr->special_attack & ATTACK_CONFUSE))
1599                 {
1600 #ifdef JP
1601 msg_print("¤¢¤Ê¤¿¤Î¼ê¤Ï¸÷¤ê»Ï¤á¤¿¡£");
1602 #else
1603                         msg_print("Your hands start glowing.");
1604 #endif
1605
1606                         p_ptr->special_attack |= ATTACK_CONFUSE;
1607                         p_ptr->redraw |= (PR_STATUS);
1608                 }
1609                 break;
1610         case 4: /* Mana Burst */
1611                 if (!get_aim_dir(&dir)) return FALSE;
1612
1613                 fire_ball(GF_MISSILE, dir,
1614                         (damroll(3, 5) + plev +
1615                         (plev / (((p_ptr->pclass == CLASS_MAGE)
1616                         || (p_ptr->pclass == CLASS_HIGH_MAGE)
1617                         || (p_ptr->pclass == CLASS_SORCERER)) ? 2 : 4))),
1618                         ((plev < 30) ? 2 : 3));
1619                         /* Shouldn't actually use GF_MANA, as it will destroy all
1620                          * items on the floor */
1621                 break;
1622         case 5: /* Fire Bolt */
1623                 if (!get_aim_dir(&dir)) return FALSE;
1624
1625                 fire_bolt_or_beam(beam, GF_FIRE, dir,
1626                         damroll(8 + ((plev - 5) / 4), 8));
1627                 break;
1628         case 6: /* Fist of Force ("Fist of Fun") */
1629                 if (!get_aim_dir(&dir)) return FALSE;
1630
1631                 fire_ball(GF_DISINTEGRATE, dir,
1632                         damroll(8 + ((plev - 5) / 4), 8), 0);
1633                 break;
1634         case 7: /* Teleport Self */
1635                 teleport_player(plev * 5);
1636                 break;
1637         case 8: /* Wonder */
1638                 {
1639                 /* This spell should become more useful (more
1640                 controlled) as the player gains experience levels.
1641                 Thus, add 1/5 of the player's level to the die roll.
1642                 This eliminates the worst effects later on, while
1643                 keeping the results quite random.  It also allows
1644                         some potent effects only at high level. */
1645
1646                         int die = randint1(100) + plev / 5;
1647                         int vir = virtue_number(V_CHANCE);
1648                         if (vir)
1649                         {
1650                                 if (p_ptr->virtues[vir - 1] > 0)
1651                                 {
1652                                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
1653                                 }
1654                                 else
1655                                 {
1656                                         while (randint1(400) < (0-p_ptr->virtues[vir - 1])) die--;
1657                                 }
1658                         }
1659
1660                         if (die < 26)
1661                                 chg_virtue(V_CHANCE, 1);
1662
1663                         if (!get_aim_dir(&dir)) return FALSE;
1664                         if (die > 100)
1665 #ifdef JP
1666 msg_print("¤¢¤Ê¤¿¤ÏÎϤ¬¤ß¤Ê¤®¤ë¤Î¤ò´¶¤¸¤¿¡ª");
1667 #else
1668                                 msg_print("You feel a surge of power!");
1669 #endif
1670
1671                         if (die < 8) clone_monster(dir);
1672                         else if (die < 14) speed_monster(dir);
1673                         else if (die < 26) heal_monster(dir, damroll(4, 6));
1674                         else if (die < 31) poly_monster(dir);
1675                         else if (die < 36)
1676                                 fire_bolt_or_beam(beam - 10, GF_MISSILE, dir,
1677                                     damroll(3 + ((plev - 1) / 5), 4));
1678                         else if (die < 41) confuse_monster(dir, plev);
1679                         else if (die < 46) fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
1680                         else if (die < 51) (void)lite_line(dir);
1681                         else if (die < 56)
1682                                 fire_bolt_or_beam(beam - 10, GF_ELEC, dir,
1683                                     damroll(3 + ((plev - 5) / 4), 8));
1684                         else if (die < 61)
1685                                 fire_bolt_or_beam(beam - 10, GF_COLD, dir,
1686                                     damroll(5 + ((plev - 5) / 4), 8));
1687                         else if (die < 66)
1688                                 fire_bolt_or_beam(beam, GF_ACID, dir,
1689                                     damroll(6 + ((plev - 5) / 4), 8));
1690                         else if (die < 71)
1691                                 fire_bolt_or_beam(beam, GF_FIRE, dir,
1692                                     damroll(8 + ((plev - 5) / 4), 8));
1693                         else if (die < 76) drain_life(dir, 75);
1694                         else if (die < 81) fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
1695                         else if (die < 86) fire_ball(GF_ACID, dir, 40 + plev, 2);
1696                         else if (die < 91) fire_ball(GF_ICE, dir, 70 + plev, 3);
1697                         else if (die < 96) fire_ball(GF_FIRE, dir, 80 + plev, 3);
1698                         else if (die < 101) drain_life(dir, 100 + plev);
1699                         else if (die < 104)
1700                         {
1701                                 earthquake(py, px, 12);
1702                         }
1703                         else if (die < 106)
1704                         {
1705                                 destroy_area(py, px, 13+randint0(5));
1706                         }
1707                         else if (die < 108)
1708                         {
1709                                 symbol_genocide(plev+50, TRUE);
1710                         }
1711                         else if (die < 110) dispel_monsters(120);
1712                         else /* RARE */
1713                         {
1714                                 dispel_monsters(150);
1715                                 slow_monsters();
1716                                 sleep_monsters();
1717                                 hp_player(300);
1718                         }
1719                         break;
1720                 }
1721                 break;
1722         case 9: /* Chaos Bolt */
1723                 if (!get_aim_dir(&dir)) return FALSE;
1724
1725                 fire_bolt_or_beam(beam, GF_CHAOS, dir,
1726                         damroll(10 + ((plev - 5) / 4), 8));
1727                 break;
1728         case 10: /* Sonic Boom */
1729 #ifdef JP
1730 msg_print("¥É¡¼¥ó¡ªÉô²°¤¬Íɤ줿¡ª");
1731 #else
1732                 msg_print("BOOM! Shake the room!");
1733 #endif
1734
1735                 project(0, plev / 10 + 2, py, px,
1736                         (60 + plev), GF_SOUND, PROJECT_KILL | PROJECT_ITEM, -1);
1737                 break;
1738         case 11: /* Doom Bolt -- always beam in 2.0.7 or later */
1739                 if (!get_aim_dir(&dir)) return FALSE;
1740
1741                 fire_beam(GF_MANA, dir, damroll(11 + ((plev - 5) / 4), 8));
1742                 break;
1743         case 12: /* Fire Ball */
1744                 if (!get_aim_dir(&dir)) return FALSE;
1745
1746                 fire_ball(GF_FIRE, dir, plev + 55, 2);
1747                 break;
1748         case 13: /* Teleport Other */
1749                 if (!get_aim_dir(&dir)) return FALSE;
1750
1751                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
1752                 break;
1753         case 14: /* Word of Destruction */
1754                 destroy_area(py, px, 13+randint0(5));
1755                 break;
1756         case 15: /* Invoke Logrus */
1757                 if (!get_aim_dir(&dir)) return FALSE;
1758
1759                 fire_ball(GF_CHAOS, dir, plev*2 + 99, plev / 5);
1760                 break;
1761         case 16: /* Polymorph Other */
1762                 if (!get_aim_dir(&dir)) return FALSE;
1763
1764                 (void)poly_monster(dir);
1765                 break;
1766         case 17: /* Chain Lightning */
1767                 for (dir = 0; dir <= 9; dir++)
1768                         fire_beam(GF_ELEC, dir, damroll(5 + (plev / 10), 8));
1769                 break;
1770         case 18: /* Arcane Binding == Charging */
1771                 return recharge(90);
1772         case 19: /* Disintegration */
1773                 if (!get_aim_dir(&dir)) return FALSE;
1774
1775                 fire_ball(GF_DISINTEGRATE, dir, plev + 70, 3 + plev / 40);
1776                 break;
1777         case 20: /* Alter Reality */
1778                 alter_reality();
1779                 break;
1780         case 21: /* Magic Rocket */
1781                 if (!get_aim_dir(&dir)) return FALSE;
1782
1783 #ifdef JP
1784 msg_print("¥í¥±¥Ã¥Èȯ¼Í¡ª");
1785 #else
1786                 msg_print("You launch a rocket!");
1787 #endif
1788
1789                 fire_rocket(GF_ROCKET, dir, 120 + plev*2, 2);
1790                 break;
1791         case 22: /* Chaos Branding */
1792                 brand_weapon(2);
1793                 break;
1794         case 23: /* Summon monster, demon */
1795                 {
1796                         u32b mode = 0L;
1797                         bool pet = !one_in_(3);
1798
1799                         if (pet) mode |= PM_FORCE_PET;
1800                         else mode |= PM_NO_PET;
1801                         if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
1802
1803                         if (summon_specific((pet ? -1 : 0), py, px, (plev * 3) / 2, SUMMON_DEMON, mode))
1804                         {
1805 #ifdef JP
1806 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
1807 #else
1808                                 msg_print("The area fills with a stench of sulphur and brimstone.");
1809 #endif
1810
1811
1812                                 if (pet)
1813 #ifdef JP
1814 msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
1815 #else
1816                                         msg_print("'What is thy bidding... Master?'");
1817 #endif
1818
1819                                 else
1820 #ifdef JP
1821 msg_print("¡ÖÈܤ·¤­¼Ô¤è¡¢²æ¤ÏÆò¤Î²¼Ëͤˤ¢¤é¤º¡ª ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
1822 #else
1823                                         msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
1824 #endif
1825
1826                         }
1827                         break;
1828                 }
1829         case 24: /* Beam of Gravity */
1830                 if (!get_aim_dir(&dir)) return FALSE;
1831
1832                 fire_beam(GF_GRAVITY, dir, damroll(9 + ((plev - 5) / 4), 8));
1833                 break;
1834         case 25: /* Meteor Swarm  */
1835                 {
1836                         int x, y, dx, dy;
1837                         int b = 10 + randint1(10);
1838                         for (i = 0; i < b; i++)
1839                         {
1840                                 int count = 0, d = 0;
1841
1842                                 while (1)
1843                                 {
1844                                         count++;
1845                                         if (count > 20) break;
1846                                         x = px - 8 + randint0(17);
1847                                         y = py - 8 + randint0(17);
1848
1849                                         if (!in_bounds(y,x) || (!cave_floor_bold(y,x) && (cave[y][x].feat != FEAT_TREES)) || !player_has_los_bold(y, x)) continue;
1850
1851                                         dx = (px > x) ? (px - x) : (x - px);
1852                                         dy = (py > y) ? (py - y) : (y - py);
1853
1854                                         /* Approximate distance */
1855                                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
1856                                         if (d < 9) break;
1857                                 }
1858
1859                                 if (count > 20) continue;
1860
1861                                 project(0, 2, y, x, plev * 2, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
1862                         }
1863                 }
1864                 break;
1865         case 26: /* Flame Strike */
1866                 fire_ball(GF_FIRE, 0, 300 + (3 * plev), 8);
1867                 break;
1868         case 27: /* Call Chaos */
1869                 call_chaos();
1870                 break;
1871         case 28: /* Polymorph Self */
1872 #ifdef JP
1873                 if (!get_check("ÊѿȤ·¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©")) return FALSE;
1874 #else
1875                 if (!get_check("You will polymorph yourself. Are you sure? ")) return FALSE;
1876 #endif
1877                 do_poly_self();
1878                 break;
1879         case 29: /* Mana Storm */
1880                 if (!get_aim_dir(&dir)) return FALSE;
1881
1882                 fire_ball(GF_MANA, dir, 300 + (plev * 4), 4);
1883                 break;
1884         case 30: /* Breathe Logrus */
1885                 if (!get_aim_dir(&dir)) return FALSE;
1886
1887                 fire_ball(GF_CHAOS, dir, p_ptr->chp, 2);
1888                 break;
1889         case 31: /* Call the Void */
1890                 call_the_();
1891                 break;
1892         default:
1893 #ifdef JP
1894 msg_format("¤¢¤Ê¤¿¤ÏÉÔÌÀ¤Ê¥«¥ª¥¹¤Î¼öʸ %d ¤ò¾§¤¨¤¿¡£", spell);
1895 #else
1896                 msg_format("You cast an unknown Chaos spell: %d.", spell);
1897 #endif
1898
1899                 msg_print(NULL);
1900         }
1901
1902         return TRUE;
1903 }
1904
1905
1906 static bool cast_death_spell(int spell)
1907 {
1908         int     dir;
1909         int     beam;
1910         int     plev = p_ptr->lev;
1911         int     dummy = 0;
1912
1913         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
1914         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
1915         else beam = plev / 2;
1916
1917         switch (spell)
1918         {
1919         case 0: /* Detect Undead & Demons -> Unlife */
1920                 (void)detect_monsters_nonliving(DETECT_RAD_DEFAULT);
1921                 break;
1922         case 1: /* Malediction */
1923                 if (!get_aim_dir(&dir)) return FALSE;
1924                 /* A radius-0 ball may (1) be aimed at objects etc.,
1925                  * and will affect them; (2) may be aimed at ANY
1926                  * visible monster, unlike a 'bolt' which must travel
1927                  * to the monster. */
1928
1929                 fire_ball(GF_HELL_FIRE, dir,
1930                         damroll(3 + ((plev - 1) / 5), 4), 0);
1931
1932                 if (one_in_(5))
1933                 {   /* Special effect first */
1934                         dummy = randint1(1000);
1935                         if (dummy == 666)
1936                                 fire_ball_hide(GF_DEATH_RAY, dir, plev * 200, 0);
1937                         else if (dummy < 500)
1938                                 fire_ball_hide(GF_TURN_ALL, dir, plev, 0);
1939                         else if (dummy < 800)
1940                                 fire_ball_hide(GF_OLD_CONF, dir, plev, 0);
1941                         else
1942                                 fire_ball_hide(GF_STUN, dir, plev, 0);
1943                 }
1944                 break;
1945         case 2: /* Detect Evil */
1946                 (void)detect_monsters_evil(DETECT_RAD_DEFAULT);
1947                 break;
1948         case 3: /* Stinking Cloud */
1949                 if (!get_aim_dir(&dir)) return FALSE;
1950
1951                 fire_ball(GF_POIS, dir, 10 + (plev / 2), 2);
1952                 break;
1953         case 4: /* Black Sleep */
1954                 if (!get_aim_dir(&dir)) return FALSE;
1955
1956                 (void)sleep_monster(dir);
1957                 break;
1958         case 5: /* Resist Poison */
1959                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
1960                 break;
1961         case 6: /* Horrify */
1962                 if (!get_aim_dir(&dir)) return FALSE;
1963
1964                 (void)fear_monster(dir, plev);
1965                 (void)stun_monster(dir, plev);
1966                 break;
1967         case 7: /* Enslave Undead */
1968                 if (!get_aim_dir(&dir)) return FALSE;
1969
1970                 (void)control_one_undead(dir, plev);
1971                 break;
1972         case 8: /* Orb of Entropy */
1973                 if (!get_aim_dir(&dir)) return FALSE;
1974
1975                 fire_ball(GF_OLD_DRAIN, dir,
1976                         (damroll(3, 6) + plev +
1977                         (plev / (((p_ptr->pclass == CLASS_MAGE) ||
1978                         (p_ptr->pclass == CLASS_HIGH_MAGE) ||
1979                         (p_ptr->pclass == CLASS_SORCERER)) ? 2 : 4))),
1980                         ((plev < 30) ? 2 : 3));
1981                 break;
1982         case 9: /* Nether Bolt */
1983                 if (!get_aim_dir(&dir)) return FALSE;
1984
1985                 fire_bolt_or_beam(beam, GF_NETHER, dir,
1986                     damroll(8 + ((plev - 5) / 4), 8));
1987                 break;
1988         case 10: /* Cloud kill */
1989                 project(0, plev / 10 + 2, py, px,
1990                         (30 + plev) * 2, GF_POIS, PROJECT_KILL | PROJECT_ITEM, -1);
1991                 break;
1992         case 11: /* Genocide One */
1993                 if (!get_aim_dir(&dir)) return FALSE;
1994
1995                 fire_ball_hide(GF_GENOCIDE, dir, plev + 50, 0);
1996                 break;
1997         case 12: /* Poison Branding */
1998                 brand_weapon(3);
1999                 break;
2000         case 13: /* Vampiric Drain */
2001                 if (!get_aim_dir(&dir)) return FALSE;
2002
2003                 dummy = plev * 2 + randint1(plev * 2);   /* Dmg */
2004                 if (drain_life(dir, dummy))
2005                 {
2006                         chg_virtue(V_SACRIFICE, -1);
2007                         chg_virtue(V_VITALITY, -1);
2008
2009                         (void)hp_player(dummy);
2010                         /* Gain nutritional sustenance: 150/hp drained */
2011                         /* A Food ration gives 5000 food points (by contrast) */
2012                         /* Don't ever get more than "Full" this way */
2013                         /* But if we ARE Gorged,  it won't cure us */
2014                         dummy = p_ptr->food + MIN(5000, 100 * dummy);
2015                         if (p_ptr->food < PY_FOOD_MAX)   /* Not gorged already */
2016                                 (void)set_food(dummy >= PY_FOOD_MAX ? PY_FOOD_MAX - 1 : dummy);
2017                 }
2018                 break;
2019         case 14: /* Animate Dead */
2020                 animate_dead(0, py, px);
2021                 break;
2022         case 15: /* Genocide */
2023                 (void)symbol_genocide(plev+50, TRUE);
2024                 break;
2025         case 16: /* Berserk */
2026                 (void)set_shero(randint1(25) + 25, FALSE);
2027                 (void)hp_player(30);
2028                 (void)set_afraid(0);
2029                 break;
2030         case 17: /* Invoke Spirits */
2031                 {
2032                         int die = randint1(100) + plev / 5;
2033                         int vir = virtue_number(V_CHANCE);
2034                         if (vir)
2035                         {
2036                                 if (p_ptr->virtues[vir - 1] > 0)
2037                                 {
2038                                         while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
2039                                 }
2040                                 else
2041                                 {
2042                                         while (randint1(400) < (0-p_ptr->virtues[vir - 1])) die--;
2043                                 }
2044                         }
2045
2046                         if (!get_aim_dir(&dir)) return FALSE;
2047
2048 #ifdef JP
2049 msg_print("¤¢¤Ê¤¿¤Ï»à¼Ô¤¿¤Á¤ÎÎϤò¾·½¸¤·¤¿...");
2050 #else
2051                         msg_print("You call on the power of the dead...");
2052 #endif
2053                         if (die < 26)
2054                                 chg_virtue(V_CHANCE, 1);
2055
2056                         if (die > 100)
2057 #ifdef JP
2058 msg_print("¤¢¤Ê¤¿¤Ï¤ª¤É¤í¤ª¤É¤í¤·¤¤ÎϤΤ¦¤Í¤ê¤ò´¶¤¸¤¿¡ª");
2059 #else
2060                                 msg_print("You feel a surge of eldritch force!");
2061 #endif
2062
2063
2064                         if (die < 8)
2065                         {
2066 #ifdef JP
2067 msg_print("¤Ê¤ó¤Æ¤³¤Ã¤¿¡ª¤¢¤Ê¤¿¤Î¼þ¤ê¤ÎÃÏÌ̤«¤éµà¤Á¤¿¿Í±Æ¤¬Î©¤Á¾å¤¬¤Ã¤Æ¤­¤¿¡ª");
2068 #else
2069                                 msg_print("Oh no! Mouldering forms rise from the earth around you!");
2070 #endif
2071
2072                                 (void)summon_specific(0, py, px, dun_level, SUMMON_UNDEAD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
2073                                 chg_virtue(V_UNLIFE, 1);
2074                         }
2075                         else if (die < 14)
2076                         {
2077 #ifdef JP
2078 msg_print("̾¾õ¤·Æñ¤¤¼Ù°­¤Ê¸ºß¤¬¤¢¤Ê¤¿¤Î¿´¤òÄ̤ê²á¤®¤Æ¹Ô¤Ã¤¿...");
2079 #else
2080                                 msg_print("An unnamable evil brushes against your mind...");
2081 #endif
2082
2083                                 set_afraid(p_ptr->afraid + randint1(4) + 4);
2084                         }
2085                         else if (die < 26)
2086                         {
2087 #ifdef JP
2088 msg_print("¤¢¤Ê¤¿¤ÎƬ¤ËÂçÎ̤ÎÍ©Î¤Á¤ÎÁû¡¹¤·¤¤À¼¤¬²¡¤·´ó¤»¤Æ¤­¤¿...");
2089 #else
2090                                 msg_print("Your head is invaded by a horde of gibbering spectral voices...");
2091 #endif
2092
2093                                 set_confused(p_ptr->confused + randint1(4) + 4);
2094                         }
2095                         else if (die < 31)
2096                         {
2097                                 poly_monster(dir);
2098                         }
2099                         else if (die < 36)
2100                         {
2101                                 fire_bolt_or_beam(beam - 10, GF_MISSILE, dir,
2102                                         damroll(3 + ((plev - 1) / 5), 4));
2103                         }
2104                         else if (die < 41)
2105                         {
2106                                 confuse_monster (dir, plev);
2107                         }
2108                         else if (die < 46)
2109                         {
2110                                 fire_ball(GF_POIS, dir, 20 + (plev / 2), 3);
2111                         }
2112                         else if (die < 51)
2113                         {
2114                                 (void)lite_line(dir);
2115                         }
2116                         else if (die < 56)
2117                         {
2118                                 fire_bolt_or_beam(beam - 10, GF_ELEC, dir,
2119                                         damroll(3+((plev-5)/4),8));
2120                         }
2121                         else if (die < 61)
2122                         {
2123                                 fire_bolt_or_beam(beam - 10, GF_COLD, dir,
2124                                         damroll(5+((plev-5)/4),8));
2125                         }
2126                         else if (die < 66)
2127                         {
2128                                 fire_bolt_or_beam(beam, GF_ACID, dir,
2129                                         damroll(6+((plev-5)/4),8));
2130                         }
2131                         else if (die < 71)
2132                         {
2133                                 fire_bolt_or_beam(beam, GF_FIRE, dir,
2134                                         damroll(8+((plev-5)/4),8));
2135                         }
2136                         else if (die < 76)
2137                         {
2138                                 drain_life(dir, 75);
2139                         }
2140                         else if (die < 81)
2141                         {
2142                                 fire_ball(GF_ELEC, dir, 30 + plev / 2, 2);
2143                         }
2144                         else if (die < 86)
2145                         {
2146                                 fire_ball(GF_ACID, dir, 40 + plev, 2);
2147                         }
2148                         else if (die < 91)
2149                         {
2150                                 fire_ball(GF_ICE, dir, 70 + plev, 3);
2151                         }
2152                         else if (die < 96)
2153                         {
2154                                 fire_ball(GF_FIRE, dir, 80 + plev, 3);
2155                         }
2156                         else if (die < 101)
2157                         {
2158                                 drain_life(dir, 100 + plev);
2159                         }
2160                         else if (die < 104)
2161                         {
2162                                 earthquake(py, px, 12);
2163                         }
2164                         else if (die < 106)
2165                         {
2166                                 destroy_area(py, px, 13+randint0(5));
2167                         }
2168                         else if (die < 108)
2169                         {
2170                                 symbol_genocide(plev+50, TRUE);
2171                         }
2172                         else if (die < 110)
2173                         {
2174                                 dispel_monsters(120);
2175                         }
2176                         else
2177                         { /* RARE */
2178                                 dispel_monsters(150);
2179                                 slow_monsters();
2180                                 sleep_monsters();
2181                                 hp_player(300);
2182                         }
2183
2184                         if (die < 31)
2185 #ifdef JP
2186 msg_print("±¢±µ¤ÊÀ¼¤¬¥¯¥¹¥¯¥¹¾Ð¤¦¡£¡Ö¤â¤¦¤¹¤°¤ª¤Þ¤¨¤Ï²æ¡¹¤ÎÃç´Ö¤Ë¤Ê¤ë¤À¤í¤¦¡£¼å¤­¼Ô¤è¡£¡×");
2187 #else
2188                                 msg_print("Sepulchral voices chuckle. 'Soon you will join us, mortal.'");
2189 #endif
2190
2191                         break;
2192                 }
2193         case 18: /* Dark Bolt */
2194                 if (!get_aim_dir(&dir)) return FALSE;
2195
2196                 fire_bolt_or_beam(beam, GF_DARK, dir,
2197                         damroll(4 + ((plev - 5) / 4), 8));
2198                 break;
2199         case 19: /* Battle Frenzy */
2200                 (void)set_shero(randint1(25) + 25, FALSE);
2201                 (void)hp_player(30);
2202                 (void)set_afraid(0);
2203                 (void)set_fast(randint1(20 + (plev / 2)) + (plev / 2), FALSE);
2204                 break;
2205         case 20: /* Vampiric Branding */
2206                 brand_weapon(4);
2207                 break;
2208         case 21: /* Vampirism True */
2209                 if (!get_aim_dir(&dir)) return FALSE;
2210
2211                 chg_virtue(V_SACRIFICE, -1);
2212                 chg_virtue(V_VITALITY, -1);
2213
2214                 for (dummy = 0; dummy < 3; dummy++)
2215                 {
2216                         if (drain_life(dir, 100))
2217                                 hp_player(100);
2218                 }
2219                 break;
2220         case 22: /* Word of Death */
2221                 (void)dispel_living(randint1(plev * 3));
2222                 break;
2223         case 23: /* Darkness Storm */
2224                 if (!get_aim_dir(&dir)) return FALSE;
2225
2226                 fire_ball(GF_DARK, dir, 100+plev*2, 4);
2227                 break;
2228         case 24: /* Death Ray */
2229                 if (!get_aim_dir(&dir)) return FALSE;
2230
2231                 (void)death_ray(dir, plev);
2232                 break;
2233         case 25: /* Raise the Dead */
2234                 {
2235                         int type;
2236                         bool pet = one_in_(3);
2237                         u32b mode = 0L;
2238
2239                         type = (plev > 47 ? SUMMON_HI_UNDEAD : SUMMON_UNDEAD);
2240
2241                         if (!pet || (pet && (plev > 24) && one_in_(3)))
2242                                 mode |= PM_ALLOW_GROUP;
2243
2244                         if (pet) mode |= PM_FORCE_PET;
2245                         else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
2246
2247                         if (summon_specific((pet ? -1 : 0), py, px, (plev * 3) / 2, type, mode))
2248                         {
2249 #ifdef JP
2250 msg_print("Î䤿¤¤É÷¤¬¤¢¤Ê¤¿¤Î¼þ¤ê¤Ë¿á¤­»Ï¤á¤¿¡£¤½¤ì¤ÏÉåÇÔ½­¤ò±¿¤ó¤Ç¤¤¤ë...");
2251 #else
2252                                 msg_print("Cold winds begin to blow around you, carrying with them the stench of decay...");
2253 #endif
2254
2255
2256                                 if (pet)
2257 #ifdef JP
2258 msg_print("¸Å¤¨¤Î»à¤»¤ë¼Ô¶¦¤¬¤¢¤Ê¤¿¤Ë»Å¤¨¤ë¤¿¤áÅÚ¤«¤éᴤä¿¡ª");
2259 #else
2260                                         msg_print("Ancient, long-dead forms arise from the ground to serve you!");
2261 #endif
2262
2263                                 else
2264 #ifdef JP
2265 msg_print("»à¼Ô¤¬á´¤Ã¤¿¡£Ì²¤ê¤ò˸¤²¤ë¤¢¤Ê¤¿¤òȳ¤¹¤ë¤¿¤á¤Ë¡ª");
2266 #else
2267                                         msg_print("'The dead arise... to punish you for disturbing them!'");
2268 #endif
2269
2270                         chg_virtue(V_UNLIFE, 1);
2271                         }
2272
2273                         break;
2274                 }
2275         case 26: /* Esoteria */
2276                 if (randint1(50) > plev)
2277                         return ident_spell(FALSE);
2278                 else
2279                         return identify_fully(FALSE);
2280                 break;
2281         case 27: /* Mimic vampire */
2282                 (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_VAMPIRE, FALSE);
2283                 break;
2284         case 28: /* Restore Life */
2285                 (void)restore_level();
2286                 break;
2287         case 29: /* Mass Genocide */
2288                 (void)mass_genocide(plev+50, TRUE);
2289                 break;
2290         case 30: /* Hellfire */
2291                 if (!get_aim_dir(&dir)) return FALSE;
2292
2293                 fire_ball(GF_HELL_FIRE, dir, 666, 3);
2294 #ifdef JP
2295 take_hit(DAMAGE_USELIFE, 20 + randint1(30), "ÃϹö¤Î¹å²Ð¤Î¼öʸ¤ò¾§¤¨¤¿ÈèÏ«", -1);
2296 #else
2297                 take_hit(DAMAGE_USELIFE, 20 + randint1(30), "the strain of casting Hellfire", -1);
2298 #endif
2299
2300                 break;
2301         case 31: /* Wraithform */
2302                 set_wraith_form(randint1(plev / 2) + (plev / 2), FALSE);
2303                 break;
2304         default:
2305                 msg_format("You cast an unknown Death spell: %d.", spell);
2306                 msg_print(NULL);
2307         }
2308
2309         return TRUE;
2310 }
2311
2312
2313 static bool cast_trump_spell(int spell, bool success)
2314 {
2315         int     dir;
2316         int     beam;
2317         int     plev = p_ptr->lev;
2318         int     summon_lev = plev * 2 / 3 + randint1(plev/2);
2319         int     dummy = 0;
2320         bool    no_trump = FALSE;
2321         bool    unique_okay = FALSE;
2322
2323
2324         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
2325         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
2326         else beam = plev / 2;
2327
2328         if (summon_lev < 1) summon_lev = 1;
2329         if (!success || (randint1(50+plev) < plev/10)) unique_okay = TRUE;
2330         switch (spell)
2331         {
2332                 case 0: /* Phase Door */
2333                         if (success)
2334                         {
2335                                 teleport_player(10);
2336                         }
2337                         break;
2338                 case 1: /* Trump Spiders */
2339                 {
2340                         bool pet = success; /* (randint1(5) > 2) */
2341                         u32b mode = PM_ALLOW_GROUP;
2342
2343                         if (pet) mode |= PM_FORCE_PET;
2344                         else mode |= PM_NO_PET;
2345
2346 #ifdef JP
2347 msg_print("¤¢¤Ê¤¿¤ÏÃØéá¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2348 #else
2349                         msg_print("You concentrate on the trump of an spider...");
2350 #endif
2351
2352                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_SPIDER, mode))
2353                         {
2354                                 if (!pet)
2355 #ifdef JP
2356 msg_print("¾¤´­¤µ¤ì¤¿ÃØéá¤ÏÅܤäƤ¤¤ë¡ª");
2357 #else
2358                                         msg_print("The summoned spiders get angry!");
2359 #endif
2360                         }
2361                         else
2362                         {
2363                                 no_trump = TRUE;
2364                         }
2365
2366                         break;
2367                 }
2368                 case 2: /* Shuffle */
2369                         if (success)
2370                         {
2371                                 /* A limited power 'wonder' spell */
2372                                 int die = randint1(120);
2373                                 int vir = virtue_number(V_CHANCE);
2374
2375                                 if ((p_ptr->pclass == CLASS_ROGUE) ||
2376                                         (p_ptr->pclass == CLASS_HIGH_MAGE) ||
2377                                         (p_ptr->pclass == CLASS_SORCERER))
2378                                         die = (randint1(110)) + plev / 5;
2379                                 /* Card sharks and high mages get a level bonus */
2380
2381                                 if (vir)
2382                                 {
2383                                         if (p_ptr->virtues[vir - 1] > 0)
2384                                         {
2385                                                 while (randint1(400) < p_ptr->virtues[vir - 1]) die++;
2386                                         }
2387                                         else
2388                                         {
2389                                                 while (randint1(400) < (0-p_ptr->virtues[vir - 1])) die--;
2390                                         }
2391                                 }
2392
2393 #ifdef JP
2394 msg_print("¤¢¤Ê¤¿¤Ï¥«¡¼¥É¤òÀڤäưìËç°ú¤¤¤¿...");
2395 #else
2396                                 msg_print("You shuffle the deck and draw a card...");
2397 #endif
2398
2399                                 if (die < 30)
2400                                         chg_virtue(V_CHANCE, 1);
2401
2402                                 if (die < 7)
2403                                 {
2404 #ifdef JP
2405 msg_print("¤Ê¤ó¤Æ¤³¤Ã¤¿¡ª¡Ô»à¡Õ¤À¡ª");
2406 #else
2407                                         msg_print("Oh no! It's Death!");
2408 #endif
2409
2410                                         for (dummy = 0; dummy < randint1(3); dummy++)
2411                                                 (void)activate_hi_summon(py, px, FALSE);
2412                                 }
2413                                 else if (die < 14)
2414                                 {
2415 #ifdef JP
2416 msg_print("¤Ê¤ó¤Æ¤³¤Ã¤¿¡ª¡Ô°­Ëâ¡Õ¤À¡ª");
2417 #else
2418                                         msg_print("Oh no! It's the Devil!");
2419 #endif
2420
2421                                         (void)summon_specific(0, py, px, dun_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
2422                                 }
2423                                 else if (die < 18)
2424                                 {
2425                                         int count = 0;
2426 #ifdef JP
2427 msg_print("¤Ê¤ó¤Æ¤³¤Ã¤¿¡ª¡ÔÄߤé¤ì¤¿ÃË¡Õ¤À¡ª");
2428 #else
2429                                         msg_print("Oh no! It's the Hanged Man.");
2430 #endif
2431
2432                                         (void)activate_ty_curse(FALSE, &count);
2433                                 }
2434                                 else if (die < 22)
2435                                 {
2436 #ifdef JP
2437 msg_print("¡ÔÉÔĴϤηõ¡Õ¤À¡£");
2438 #else
2439                                         msg_print("It's the swords of discord.");
2440 #endif
2441
2442                                         aggravate_monsters(0);
2443                                 }
2444                                 else if (die < 26)
2445                                 {
2446 #ifdef JP
2447 msg_print("¡Ô¶ò¼Ô¡Õ¤À¡£");
2448 #else
2449                                         msg_print("It's the Fool.");
2450 #endif
2451
2452                                         (void)do_dec_stat(A_INT);
2453                                         (void)do_dec_stat(A_WIS);
2454                                 }
2455                                 else if (die < 30)
2456                                 {
2457 #ifdef JP
2458 msg_print("´ñ̯¤Ê¥â¥ó¥¹¥¿¡¼¤Î³¨¤À¡£");
2459 #else
2460                                         msg_print("It's the picture of a strange monster.");
2461 #endif
2462
2463                                         if (!(summon_specific(0, py, px, (dun_level * 3) / 2, 32 + randint1(6), (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET))))
2464                                                 no_trump = TRUE;
2465                                 }
2466                                 else if (die < 33)
2467                                 {
2468 #ifdef JP
2469 msg_print("¡Ô·î¡Õ¤À¡£");
2470 #else
2471                                         msg_print("It's the Moon.");
2472 #endif
2473
2474                                         unlite_area(10, 3);
2475                                 }
2476                                 else if (die < 38)
2477                                 {
2478 #ifdef JP
2479 msg_print("¡Ô±¿Ì¿¤ÎÎØ¡Õ¤À¡£");
2480 #else
2481                                         msg_print("It's the Wheel of Fortune.");
2482 #endif
2483
2484                                         wild_magic(randint0(32));
2485                                 }
2486                                 else if (die < 40)
2487                                 {
2488 #ifdef JP
2489 msg_print("¥Æ¥ì¥Ý¡¼¥È¡¦¥«¡¼¥É¤À¡£");
2490 #else
2491                                         msg_print("It's a teleport trump card.");
2492 #endif
2493
2494                                         teleport_player(10);
2495                                 }
2496                                 else if (die < 42)
2497                                 {
2498 #ifdef JP
2499 msg_print("¡ÔÀµµÁ¡Õ¤À¡£");
2500 #else
2501                                         msg_print("It's Justice.");
2502 #endif
2503
2504                                         set_blessed(p_ptr->lev, FALSE);
2505                                 }
2506                                 else if (die < 47)
2507                                 {
2508 #ifdef JP
2509 msg_print("¥Æ¥ì¥Ý¡¼¥È¡¦¥«¡¼¥É¤À¡£");
2510 #else
2511                                         msg_print("It's a teleport trump card.");
2512 #endif
2513
2514                                         teleport_player(100);
2515                                 }
2516                                 else if (die < 52)
2517                                 {
2518 #ifdef JP
2519 msg_print("¥Æ¥ì¥Ý¡¼¥È¡¦¥«¡¼¥É¤À¡£");
2520 #else
2521                                         msg_print("It's a teleport trump card.");
2522 #endif
2523
2524                                         teleport_player(200);
2525                                 }
2526                                 else if (die < 60)
2527                                 {
2528 #ifdef JP
2529 msg_print("¡ÔÅã¡Õ¤À¡£");
2530 #else
2531                                         msg_print("It's the Tower.");
2532 #endif
2533
2534                                         wall_breaker();
2535                                 }
2536                                 else if (die < 72)
2537                                 {
2538 #ifdef JP
2539 msg_print("¡ÔÀáÀ©¡Õ¤À¡£");
2540 #else
2541                                         msg_print("It's Temperance.");
2542 #endif
2543
2544                                         sleep_monsters_touch();
2545                                 }
2546                                 else if (die < 80)
2547                                 {
2548 #ifdef JP
2549 msg_print("¡ÔÅã¡Õ¤À¡£");
2550 #else
2551                                         msg_print("It's the Tower.");
2552 #endif
2553
2554                                         earthquake(py, px, 5);
2555                                 }
2556                                 else if (die < 82)
2557                                 {
2558 #ifdef JP
2559 msg_print("ͧ¹¥Åª¤Ê¥â¥ó¥¹¥¿¡¼¤Î³¨¤À¡£");
2560 #else
2561                                         msg_print("It's the picture of a friendly monster.");
2562 #endif
2563
2564                                         if (!(summon_specific(-1, py, px, (dun_level * 3) / 2, SUMMON_BIZARRE1, PM_FORCE_PET)))
2565                                                 no_trump = TRUE;
2566                                 }
2567                                 else if (die < 84)
2568                                 {
2569 #ifdef JP
2570 msg_print("ͧ¹¥Åª¤Ê¥â¥ó¥¹¥¿¡¼¤Î³¨¤À¡£");
2571 #else
2572                                         msg_print("It's the picture of a friendly monster.");
2573 #endif
2574
2575                                         if (!(summon_specific(-1, py, px, (dun_level * 3) / 2, SUMMON_BIZARRE2, PM_FORCE_PET)))
2576                                                 no_trump = TRUE;
2577                                 }
2578                                 else if (die < 86)
2579                                 {
2580 #ifdef JP
2581 msg_print("ͧ¹¥Åª¤Ê¥â¥ó¥¹¥¿¡¼¤Î³¨¤À¡£");
2582 #else
2583                                         msg_print("It's the picture of a friendly monster.");
2584 #endif
2585
2586                                         if (!(summon_specific(-1, py, px, (dun_level * 3) / 2, SUMMON_BIZARRE4, PM_FORCE_PET)))
2587                                                 no_trump = TRUE;
2588                                 }
2589                                 else if (die < 88)
2590                                 {
2591 #ifdef JP
2592 msg_print("ͧ¹¥Åª¤Ê¥â¥ó¥¹¥¿¡¼¤Î³¨¤À¡£");
2593 #else
2594                                         msg_print("It's the picture of a friendly monster.");
2595 #endif
2596
2597                                         if (!(summon_specific(-1, py, px, (dun_level * 3) / 2, SUMMON_BIZARRE5, PM_FORCE_PET)))
2598                                                 no_trump = TRUE;
2599                                 }
2600                                 else if (die < 96)
2601                                 {
2602 #ifdef JP
2603 msg_print("¡ÔÎø¿Í¡Õ¤À¡£");
2604 #else
2605                                         msg_print("It's the Lovers.");
2606 #endif
2607
2608                                         if (get_aim_dir(&dir))
2609                                                 (void)charm_monster(dir, MIN(p_ptr->lev, 20));
2610                                 }
2611                                 else if (die < 101)
2612                                 {
2613 #ifdef JP
2614 msg_print("¡Ô±£¼Ô¡Õ¤À¡£");
2615 #else
2616                                         msg_print("It's the Hermit.");
2617 #endif
2618
2619                                         wall_stone();
2620                                 }
2621                                 else if (die < 111)
2622                                 {
2623 #ifdef JP
2624 msg_print("¡Ô¿³È½¡Õ¤À¡£");
2625 #else
2626                                         msg_print("It's the Judgement.");
2627 #endif
2628
2629                                         do_cmd_rerate(FALSE);
2630                                         if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
2631                                         {
2632 #ifdef JP
2633 msg_print("Á´¤Æ¤ÎÆÍÁ³ÊÑ°Û¤¬¼£¤Ã¤¿¡£");
2634 #else
2635                                                 msg_print("You are cured of all mutations.");
2636 #endif
2637
2638                                                 p_ptr->muta1 = p_ptr->muta2 = p_ptr->muta3 = 0;
2639                                                 p_ptr->update |= PU_BONUS;
2640                                                 handle_stuff();
2641                                         }
2642                                 }
2643                                 else if (die < 120)
2644                                 {
2645 #ifdef JP
2646 msg_print("¡ÔÂÀÍÛ¡Õ¤À¡£");
2647 #else
2648                                         msg_print("It's the Sun.");
2649 #endif
2650
2651                                         chg_virtue(V_KNOWLEDGE, 1);
2652                                         chg_virtue(V_ENLIGHTEN, 1);
2653                                         wiz_lite(FALSE);
2654                                 }
2655                                 else
2656                                 {
2657 #ifdef JP
2658 msg_print("¡ÔÀ¤³¦¡Õ¤À¡£");
2659 #else
2660                                         msg_print("It's the World.");
2661 #endif
2662
2663                                         if (p_ptr->exp < PY_MAX_EXP)
2664                                         {
2665                                                 s32b ee = (p_ptr->exp / 25) + 1;
2666                                                 if (ee > 5000) ee = 5000;
2667 #ifdef JP
2668 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
2669 #else
2670                                                 msg_print("You feel more experienced.");
2671 #endif
2672
2673                                                 gain_exp(ee);
2674                                         }
2675                                 }
2676                         }
2677                         break;
2678                 case 3: /* Reset Recall */
2679                         if (success)
2680                         {
2681                                 if (!reset_recall()) return FALSE;
2682                         }
2683                         break;
2684                 case 4: /* Teleport Self */
2685                         if (success)
2686                         {
2687                                 teleport_player(plev * 4);
2688                         }
2689                         break;
2690                 case 5: /* Trump Spying */
2691                         if (success)
2692                         {
2693                                 (void)set_tim_esp(randint1(30) + 25, FALSE);
2694                         }
2695                         break;
2696                 case 6: /* Teleport Away */
2697                         if (success)
2698                         {
2699                                 if (!get_aim_dir(&dir)) return FALSE;
2700                                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
2701                         }
2702                         break;
2703                 case 7: /* Trump Animals */
2704                 {
2705                         bool pet = success; /* was (randint1(5) > 2) */
2706                         int type = (pet ? SUMMON_ANIMAL_RANGER : SUMMON_ANIMAL);
2707                         u32b mode = 0L;
2708
2709                         if (pet) mode |= PM_FORCE_PET;
2710                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
2711
2712 #ifdef JP
2713 msg_print("¤¢¤Ê¤¿¤Ïưʪ¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2714 #else
2715                         msg_print("You concentrate on the trump of an animal...");
2716 #endif
2717
2718
2719                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, type, mode))
2720                         {
2721                                 if (!pet)
2722 #ifdef JP
2723 msg_print("¾¤´­¤µ¤ì¤¿Æ°Êª¤ÏÅܤäƤ¤¤ë¡ª");
2724 #else
2725                                         msg_print("The summoned animal gets angry!");
2726 #endif
2727
2728                         }
2729                         else
2730                         {
2731                                 no_trump = TRUE;
2732                         }
2733
2734                         break;
2735                 }
2736                 case 8: /* Trump Reach */
2737                         if (success)
2738                         {
2739                                 if (!get_aim_dir(&dir)) return FALSE;
2740                                 fetch(dir, plev * 15, TRUE);
2741                         }
2742                         break;
2743                 case 9: /* Trump Kamikaze */
2744                 {
2745                         int x = px, y = py;
2746                         if (success)
2747                         {
2748                                 if (!target_set(TARGET_KILL)) return FALSE;
2749                                 x = target_col;
2750                                 y = target_row;
2751                         }
2752                         no_trump = TRUE;
2753
2754 #ifdef JP
2755 msg_print("¤¢¤Ê¤¿¤Ï¥«¥ß¥«¥¼¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2756 #else
2757                         msg_print("You concentrate on several trumps at once...");
2758 #endif
2759
2760
2761                         for (dummy = 2 + randint0(plev / 7); dummy > 0; dummy--)
2762                         {
2763                                 bool pet = success; /* was (randint1(10) > 3) */
2764                                 u32b mode = 0L;
2765                                 int type;
2766
2767                                 if (pet) mode |= PM_FORCE_PET;
2768                                 else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
2769
2770                                 if (p_ptr->pclass == CLASS_BEASTMASTER)
2771                                 {
2772                                         type = SUMMON_KAMIKAZE_LIVING;
2773                                 }
2774                                 else
2775                                 {
2776                                         type = SUMMON_KAMIKAZE;
2777                                 }
2778
2779                                 if (summon_specific((pet ? -1 : 0), y, x, summon_lev, type, mode))
2780                                 {
2781                                         if (!pet)
2782 #ifdef JP
2783 msg_print("¾¤´­¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
2784 #else
2785                                                 msg_print("The summoned creatures get angry!");
2786 #endif
2787
2788                                         no_trump = FALSE;
2789                                 }
2790                         }
2791                         break;
2792                 }
2793                 case 10: /* Phantasmal Servant */
2794                         if (success)
2795                         {
2796                                 if (summon_specific(-1, py, px, (summon_lev * 3) / 2, SUMMON_PHANTOM, PM_FORCE_PET))
2797                                 {
2798 #ifdef JP
2799 msg_print("¸æÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¸æ¼ç¿ÍÍÍ¡©");
2800 #else
2801                                         msg_print("'Your wish, master?'");
2802 #endif
2803
2804                                 }
2805                                 else
2806                                 {
2807                                         no_trump = TRUE;
2808                                 }
2809                         }
2810                         break;
2811                 case 11: /* Speed Monster */
2812                         if (success)
2813                         {
2814                                 bool old_target_pet = target_pet;
2815                                 target_pet = TRUE;
2816                                 if (!get_aim_dir(&dir))
2817                                 {
2818                                         target_pet = old_target_pet;
2819                                         return (FALSE);
2820                                 }
2821                                 target_pet = old_target_pet;
2822                                 (void)speed_monster(dir);
2823                         }
2824                         break;
2825                 case 12: /* Teleport Level */
2826                         if (success)
2827                         {
2828 #ifdef JP
2829                                 if (!get_check("ËÜÅö¤Ë¾¤Î³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©")) return FALSE;
2830 #else
2831                                 if (!get_check("Are you sure? (Teleport Level)")) return FALSE;
2832 #endif
2833                                 (void)teleport_player_level();
2834                         }
2835                         break;
2836                 case 13: /* Dimension Door */
2837                         if (success)
2838                         {
2839 #ifdef JP
2840 msg_print("¼¡¸µ¤ÎÈ⤬³«¤¤¤¿¡£ÌÜŪÃϤòÁª¤ó¤Ç²¼¤µ¤¤¡£");
2841 #else
2842                                 msg_print("You open a dimensional gate. Choose a destination.");
2843 #endif
2844
2845                                 return dimension_door();
2846                         }
2847                         break;
2848                 case 14: /* Word of Recall */
2849                         if (success)
2850                         {
2851                                 if (!word_of_recall()) return FALSE;
2852                         }
2853                         break;
2854                 case 15: /* Banish */
2855                         if (success)
2856                         {
2857                                 banish_monsters(plev * 4);
2858                         }
2859                         break;
2860                 case 16: /* Swap Position */
2861                 {
2862                         if (success)
2863                         {
2864                                 project_length = -1;
2865                                 if (!get_aim_dir(&dir))
2866                                 {
2867                                         project_length = 0;
2868                                         return FALSE;
2869                                 }
2870                                 project_length = 0;
2871
2872                                 (void)teleport_swap(dir);
2873                         }
2874                         break;
2875                 }
2876                 case 17: /* Trump Undead */
2877                 {
2878                         bool pet = success; /* (randint1(10) > 3) */
2879                         u32b mode = 0L;
2880
2881                         if (pet) mode |= PM_FORCE_PET;
2882                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
2883
2884 #ifdef JP
2885 msg_print("¤¢¤Ê¤¿¤Ï¥¢¥ó¥Ç¥Ã¥É¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2886 #else
2887                         msg_print("You concentrate on the trump of an undead creature...");
2888 #endif
2889
2890
2891                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_UNDEAD, mode))
2892                         {
2893                                 if (!pet)
2894 #ifdef JP
2895 msg_print("¾¤´­¤µ¤ì¤¿¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
2896 #else
2897                                         msg_print("The summoned undead creature gets angry!");
2898 #endif
2899
2900                         }
2901                         else
2902                         {
2903                                 no_trump = TRUE;
2904                         }
2905
2906                         break;
2907                 }
2908                 case 18: /* Trump Reptiles */
2909                 {
2910                         bool pet = success; /* was (randint1(5) > 2) */
2911                         u32b mode = 0L;
2912
2913                         if (pet) mode |= PM_FORCE_PET;
2914                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
2915
2916 #ifdef JP
2917 msg_print("¤¢¤Ê¤¿¤Ïà¨ÃîÎà¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2918 #else
2919                         msg_print("You concentrate on the trump of a reptile...");
2920 #endif
2921
2922
2923                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HYDRA, mode))
2924                         {
2925                                 if (!pet)
2926 #ifdef JP
2927 msg_print("¾¤´­¤µ¤ì¤¿à¨ÃîÎà¤ÏÅܤäƤ¤¤ë¡ª");
2928 #else
2929                                         msg_print("The summoned reptile gets angry!");
2930 #endif
2931
2932                         }
2933                         else
2934                         {
2935                                 no_trump = TRUE;
2936                         }
2937
2938                         break;
2939                 }
2940                 case 19: /* Trump Monsters */
2941                 {
2942                         no_trump = TRUE;
2943
2944 #ifdef JP
2945 msg_print("¤¢¤Ê¤¿¤Ï¥â¥ó¥¹¥¿¡¼¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2946 #else
2947                         msg_print("You concentrate on several trumps at once...");
2948 #endif
2949
2950
2951                         for (dummy = 0; dummy < 1 + ((plev - 15)/ 10); dummy++)
2952                         {
2953                                 bool pet = success; /* was (randint1(10) > 3) */
2954                                 int type;
2955                                 u32b mode = 0L;
2956
2957                                 if (pet) mode |= PM_FORCE_PET;
2958                                 else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
2959
2960                                 if (unique_okay) mode |= PM_ALLOW_UNIQUE;
2961
2962                                 if (p_ptr->pclass == CLASS_BEASTMASTER)
2963                                 {
2964                                         type = SUMMON_LIVING;
2965                                 }
2966                                 else
2967                                 {
2968                                         type = 0;
2969                                 }
2970
2971                                 if (summon_specific((pet ? -1 : 0), py, px, summon_lev, type, mode))
2972                                 {
2973                                         if (!pet)
2974 #ifdef JP
2975 msg_print("¾¤´­¤µ¤ì¤¿¥â¥ó¥¹¥¿¡¼¤ÏÅܤäƤ¤¤ë¡ª");
2976 #else
2977                                                 msg_print("The summoned creatures get angry!");
2978 #endif
2979
2980                                         no_trump = FALSE;
2981                                 }
2982                         }
2983                         break;
2984                 }
2985                 case 20: /* Trump Hounds */
2986                 {
2987                         bool pet = success; /* was (randint1(5) > 2) */
2988                         u32b mode = PM_ALLOW_GROUP;
2989
2990                         if (pet) mode |= PM_FORCE_PET;
2991                         else mode |= PM_NO_PET;
2992
2993 #ifdef JP
2994 msg_print("¤¢¤Ê¤¿¤Ï¥Ï¥¦¥ó¥É¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
2995 #else
2996                         msg_print("You concentrate on the trump of a hound...");
2997 #endif
2998
2999
3000                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HOUND, mode))
3001                         {
3002                                 if (!pet)
3003 #ifdef JP
3004 msg_print("¾¤´­¤µ¤ì¤¿¥Ï¥¦¥ó¥É¤ÏÅܤäƤ¤¤ë¡ª");
3005 #else
3006                                         msg_print("The summoned hounds get angry!");
3007 #endif
3008
3009                         }
3010                         else
3011                         {
3012                                 no_trump = TRUE;
3013                         }
3014
3015                         break;
3016                 }
3017                 case 21: /* Trump Branding */
3018                         if (success)
3019                         {
3020                                 brand_weapon(5);
3021                         }
3022                         break;
3023                 case 22: /* Living Trump */
3024                         if (success)
3025                         {
3026                                 if (one_in_(7))
3027                                         /* Teleport control */
3028                                         dummy = 12;
3029                                 else
3030                                         /* Random teleportation (uncontrolled) */
3031                                         dummy = 77;
3032                                 /* Gain the mutation */
3033                                 if (gain_random_mutation(dummy))
3034 #ifdef JP
3035 msg_print("¤¢¤Ê¤¿¤ÏÀ¸¤­¤Æ¤¤¤ë¥«¡¼¥É¤ËÊѤï¤Ã¤¿¡£");
3036 #else
3037                                         msg_print("You have turned into a Living Trump.");
3038 #endif
3039
3040                         }
3041                         break;
3042                 case 23: /* Trump Cyberdemon */
3043                 {
3044                         bool pet = success; /* was (randint1(10) > 3) */
3045                         u32b mode = 0L;
3046
3047                         if (pet) mode |= PM_FORCE_PET;
3048                         else mode |= PM_NO_PET;
3049
3050 #ifdef JP
3051 msg_print("¤¢¤Ê¤¿¤Ï¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
3052 #else
3053                         msg_print("You concentrate on the trump of a Cyberdemon...");
3054 #endif
3055
3056
3057                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_CYBER, mode))
3058                         {
3059                                 if (!pet)
3060 #ifdef JP
3061 msg_print("¾¤´­¤µ¤ì¤¿¥µ¥¤¥Ð¡¼¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
3062 #else
3063                                         msg_print("The summoned Cyberdemon gets angry!");
3064 #endif
3065
3066                         }
3067                         else
3068                         {
3069                                         no_trump = TRUE;
3070                         }
3071
3072                         break;
3073                 }
3074                 case 24: /* Trump Divination */
3075                         if (success)
3076                         {
3077                                 (void)detect_all(DETECT_RAD_DEFAULT);
3078                         }
3079                         break;
3080                 case 25: /* Trump Lore */
3081                         if (success)
3082                         {
3083                                 return identify_fully(FALSE);
3084                         }
3085                         break;
3086                 case 26: /* Heal Monster */
3087                         if (success)
3088                         {
3089                                 bool old_target_pet = target_pet;
3090                                 target_pet = TRUE;
3091                                 if (!get_aim_dir(&dir))
3092                                 {
3093                                         target_pet = old_target_pet;
3094                                         return (FALSE);
3095                                 }
3096                                 target_pet = old_target_pet;
3097
3098                                 (void)heal_monster(dir, p_ptr->lev * 10 + 200);
3099                         }
3100                         break;
3101                 case 27: /* Trump Dragon */
3102                 {
3103                         bool pet = success; /* was (randint1(10) > 3) */
3104                         u32b mode = 0L;
3105
3106                         if (pet) mode |= PM_FORCE_PET;
3107                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
3108
3109 #ifdef JP
3110 msg_print("¤¢¤Ê¤¿¤Ï¥É¥é¥´¥ó¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
3111 #else
3112                         msg_print("You concentrate on the trump of a dragon...");
3113 #endif
3114
3115
3116                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DRAGON, mode))
3117                         {
3118                                 if (!pet)
3119 #ifdef JP
3120 msg_print("¾¤´­¤µ¤ì¤¿¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
3121 #else
3122                                         msg_print("The summoned dragon gets angry!");
3123 #endif
3124
3125                         }
3126                         else
3127                         {
3128                                 no_trump = TRUE;
3129                         }
3130
3131                         break;
3132                 }
3133                 case 28: /* Trump Meteor */
3134                         if (success)
3135                         {
3136                                 int x, y, dx, dy, i;
3137                                 int b = 10 + randint1(10);
3138                                 for (i = 0; i < b; i++)
3139                                 {
3140                                         int count = 0, d = 0;
3141
3142                                         while (1)
3143                                         {
3144                                                 count++;
3145                                                 if (count > 20) break;
3146                                                 x = px - 8 + randint0(17);
3147                                                 y = py - 8 + randint0(17);
3148
3149                                                 if (!in_bounds(y,x) || (!cave_floor_bold(y,x) && (cave[y][x].feat != FEAT_TREES)) || !player_has_los_bold(y, x)) continue;
3150
3151                                                 dx = (px > x) ? (px - x) : (x - px);
3152                                                 dy = (py > y) ? (py - y) : (y - py);
3153
3154                                                 /* Approximate distance */
3155                                                 d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
3156                                                 if (d < 9) break;
3157                                         }
3158
3159                                         if (count > 20) continue;
3160
3161                                         project(0, 2, y, x, plev * 2, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
3162                                 }
3163                         }
3164                         break;
3165                 case 29: /* Trump Demon */
3166                 {
3167                         bool pet = success; /* was (randint1(10) > 3) */
3168                         u32b mode = 0L;
3169
3170                         if (pet) mode |= PM_FORCE_PET;
3171                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
3172
3173 #ifdef JP
3174 msg_print("¤¢¤Ê¤¿¤Ï¥Ç¡¼¥â¥ó¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
3175 #else
3176                         msg_print("You concentrate on the trump of a demon...");
3177 #endif
3178
3179
3180                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_DEMON, mode))
3181                         {
3182                                 if (!pet)
3183 #ifdef JP
3184 msg_print("¾¤´­¤µ¤ì¤¿¥Ç¡¼¥â¥ó¤ÏÅܤäƤ¤¤ë¡ª");
3185 #else
3186                                         msg_print("The summoned demon gets angry!");
3187 #endif
3188
3189                         }
3190                         else
3191                         {
3192                                 no_trump = TRUE;
3193                         }
3194
3195                         break;
3196                 }
3197                 case 30: /* Trump Greater Undead */
3198                 {
3199                         bool pet = success; /* was (randint1(10) > 3) */
3200                         u32b mode = 0L;
3201
3202                         if (pet) mode |= PM_FORCE_PET;
3203                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
3204
3205                         if (unique_okay) mode |= PM_ALLOW_UNIQUE;
3206
3207 #ifdef JP
3208 msg_print("¤¢¤Ê¤¿¤Ï¶¯ÎϤʥ¢¥ó¥Ç¥Ã¥É¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
3209 #else
3210                         msg_print("You concentrate on the trump of a greater undead being...");
3211 #endif
3212
3213
3214                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, SUMMON_HI_UNDEAD, mode))
3215                         {
3216                                 if (!pet)
3217 #ifdef JP
3218 msg_print("¾¤´­¤µ¤ì¤¿¾åµé¥¢¥ó¥Ç¥Ã¥É¤ÏÅܤäƤ¤¤ë¡ª");
3219 #else
3220                                         msg_print("The summoned greater undead creature gets angry!");
3221 #endif
3222
3223                         }
3224                         else
3225                         {
3226                                 no_trump = TRUE;
3227                         }
3228
3229                         break;
3230                 }
3231                 case 31: /* Trump Ancient Dragon */
3232                 {
3233                         bool pet = success; /* was (randint1(10) > 3) */
3234                         int type;
3235                         u32b mode = 0L;
3236
3237                         if (pet) mode |= PM_FORCE_PET;
3238                         else mode |= (PM_ALLOW_GROUP | PM_NO_PET);
3239
3240                         if (unique_okay) mode |= PM_ALLOW_UNIQUE;
3241
3242                         if (p_ptr->pclass == CLASS_BEASTMASTER)
3243                         {
3244                                 type = SUMMON_HI_DRAGON_LIVING;
3245                         }
3246                         else
3247                         {
3248                                 type = SUMMON_HI_DRAGON;
3249                         }
3250
3251 #ifdef JP
3252 msg_print("¤¢¤Ê¤¿¤Ï¸ÅÂå¥É¥é¥´¥ó¤Î¥«¡¼¥É¤Ë½¸Ã椹¤ë...");
3253 #else
3254                         msg_print("You concentrate on the trump of an ancient dragon...");
3255 #endif
3256
3257
3258                         if (summon_specific((pet ? -1 : 0), py, px, summon_lev, type, mode))
3259                         {
3260                                 if (!pet)
3261 #ifdef JP
3262 msg_print("¾¤´­¤µ¤ì¤¿¸ÅÂå¥É¥é¥´¥ó¤ÏÅܤäƤ¤¤ë¡ª");
3263 #else
3264                                         msg_print("The summoned ancient dragon gets angry!");
3265 #endif
3266
3267                         }
3268                         else
3269                         {
3270                                 no_trump = TRUE;
3271                         }
3272
3273                         break;
3274                 }
3275                 default:
3276 #ifdef JP
3277 msg_format("̤ÃΤΥ«¡¼¥É¤Î¼öʸ¤Ç¤¹: %d", spell);
3278 #else
3279                         msg_format("You cast an unknown Trump spell: %d.", spell);
3280 #endif
3281
3282                         msg_print(NULL);
3283         }
3284
3285         if (no_trump)
3286         {
3287 #ifdef JP
3288 msg_print("ï¤â¤¢¤Ê¤¿¤Î¥«¡¼¥É¤Î¸Æ¤ÓÀ¼¤ËÅú¤¨¤Ê¤¤¡£");
3289 #else
3290                 msg_print("Nobody answers to your Trump call.");
3291 #endif
3292
3293         }
3294
3295         return TRUE;
3296 }
3297
3298
3299 static bool cast_arcane_spell(int spell)
3300 {
3301         int     dir;
3302         int     beam;
3303         int     plev = p_ptr->lev;
3304         int     dummy = 0;
3305         bool    no_trump = FALSE;
3306
3307         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
3308         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
3309         else beam = plev / 2;
3310
3311         switch (spell)
3312         {
3313         case 0: /* Zap */
3314                 if (!get_aim_dir(&dir)) return FALSE;
3315
3316                 fire_bolt_or_beam(beam - 10, GF_ELEC, dir,
3317                         damroll(3 + ((plev - 1) / 5), 3));
3318                 break;
3319         case 1: /* Wizard Lock */
3320                 if (!get_aim_dir(&dir)) return FALSE;
3321
3322                 (void)wizard_lock(dir);
3323                 break;
3324         case 2: /* Detect Invisibility */
3325                 (void)detect_monsters_invis(DETECT_RAD_DEFAULT);
3326                 break;
3327         case 3: /* Detect Monsters */
3328                 (void)detect_monsters_normal(DETECT_RAD_DEFAULT);
3329                 break;
3330         case 4: /* Blink */
3331                 teleport_player(10);
3332                 break;
3333         case 5: /* Light Area */
3334                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
3335                 break;
3336         case 6: /* Trap & Door Destruction */
3337                 if (!get_aim_dir(&dir)) return FALSE;
3338
3339                 (void)destroy_door(dir);
3340                 break;
3341         case 7: /* Cure Light Wounds */
3342                 (void)hp_player(damroll(2, 8));
3343                 (void)set_cut(p_ptr->cut - 10);
3344                 break;
3345         case 8: /* Detect Doors & Traps */
3346                 (void)detect_traps(DETECT_RAD_DEFAULT, TRUE);
3347                 (void)detect_doors(DETECT_RAD_DEFAULT);
3348                 (void)detect_stairs(DETECT_RAD_DEFAULT);
3349                 break;
3350         case 9: /* Phlogiston */
3351                 phlogiston();
3352                 break;
3353         case 10: /* Detect Treasure */
3354                 (void)detect_treasure(DETECT_RAD_DEFAULT);
3355                 (void)detect_objects_gold(DETECT_RAD_DEFAULT);
3356                 break;
3357         case 11: /* Detect Enchantment */
3358                 (void)detect_objects_magic(DETECT_RAD_DEFAULT);
3359                 break;
3360         case 12: /* Detect Objects */
3361                 (void)detect_objects_normal(DETECT_RAD_DEFAULT);
3362                 break;
3363         case 13: /* Cure Poison */
3364                 (void)set_poisoned(0);
3365                 break;
3366         case 14: /* Resist Cold */
3367                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
3368                 break;
3369         case 15: /* Resist Fire */
3370                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
3371                 break;
3372         case 16: /* Resist Lightning */
3373                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
3374                 break;
3375         case 17: /* Resist Acid */
3376                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
3377                 break;
3378         case 18: /* Cure Medium Wounds */
3379                 (void)hp_player(damroll(4, 8));
3380                 (void)set_cut((p_ptr->cut / 2) - 50);
3381                 break;
3382         case 19: /* Teleport */
3383                 teleport_player(plev * 5);
3384                 break;
3385         case 20: /* Identify */
3386                 return ident_spell(FALSE);
3387         case 21: /* Stone to Mud */
3388                 if (!get_aim_dir(&dir)) return FALSE;
3389
3390                 (void)wall_to_mud(dir);
3391                 break;
3392         case 22: /* Ray of Light */
3393                 if (!get_aim_dir(&dir)) return FALSE;
3394
3395 #ifdef JP
3396 msg_print("¸÷Àþ¤¬Êü¤¿¤ì¤¿¡£");
3397 #else
3398                 msg_print("A line of light appears.");
3399 #endif
3400
3401                 (void)lite_line(dir);
3402                 break;
3403         case 23: /* Satisfy Hunger */
3404                 (void)set_food(PY_FOOD_MAX - 1);
3405                 break;
3406         case 24: /* See Invisible */
3407                 (void)set_tim_invis(randint1(24) + 24, FALSE);
3408                 break;
3409         case 25: /* Conjure Elemental */
3410                 if (!summon_specific(-1, py, px, plev, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_FORCE_PET)))
3411                         no_trump = TRUE;
3412                 break;
3413         case 26: /* Teleport Level */
3414 #ifdef JP
3415                 if (!get_check("ËÜÅö¤Ë¾¤Î³¬¤Ë¥Æ¥ì¥Ý¡¼¥È¤·¤Þ¤¹¤«¡©")) return FALSE;
3416 #else
3417                 if (!get_check("Are you sure? (Teleport Level)")) return FALSE;
3418 #endif
3419                 (void)teleport_player_level();
3420                 break;
3421         case 27: /* Teleport Away */
3422                 if (!get_aim_dir(&dir)) return FALSE;
3423
3424                 (void)fire_beam(GF_AWAY_ALL, dir, plev);
3425                 break;
3426         case 28: /* Elemental Ball */
3427                 if (!get_aim_dir(&dir)) return FALSE;
3428
3429                 switch (randint1(4))
3430                 {
3431                         case 1:  dummy = GF_FIRE;break;
3432                         case 2:  dummy = GF_ELEC;break;
3433                         case 3:  dummy = GF_COLD;break;
3434                         default: dummy = GF_ACID;break;
3435                 }
3436                 fire_ball(dummy, dir, 75 + (plev), 2);
3437                 break;
3438         case 29: /* Detection */
3439                 (void)detect_all(DETECT_RAD_DEFAULT);
3440                 break;
3441         case 30: /* Word of Recall */
3442                 if (!word_of_recall()) return FALSE;
3443                 break;
3444         case 31: /* Clairvoyance */
3445                 chg_virtue(V_KNOWLEDGE, 1);
3446                 chg_virtue(V_ENLIGHTEN, 1);
3447                 wiz_lite(FALSE);
3448                 if (!p_ptr->telepathy)
3449                 {
3450                         (void)set_tim_esp(randint1(30) + 25, FALSE);
3451                 }
3452                 break;
3453         default:
3454                 msg_format("You cast an unknown Arcane spell: %d.", spell);
3455                 msg_print(NULL);
3456         }
3457
3458         if (no_trump)
3459 #ifdef JP
3460 msg_print("¥¨¥ì¥á¥ó¥¿¥ë¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
3461 #else
3462                 msg_print("No Elementals arrive.");
3463 #endif
3464
3465         return TRUE;
3466 }
3467
3468
3469 static bool cast_enchant_spell(int spell)
3470 {
3471         int     plev = p_ptr->lev;
3472         int     dummy = 0;
3473         bool    no_trump = FALSE;
3474
3475         switch (spell)
3476         {
3477         case 0: /* Infravision */
3478                 set_tim_infra(100 + randint1(100), FALSE);
3479                 break;
3480         case 1: /* Regeneration */
3481                 set_tim_regen(80 + randint1(80), FALSE);
3482                 break;
3483         case 2: /* Satisfy Hunger */
3484                 (void)set_food(PY_FOOD_MAX - 1);
3485                 break;
3486         case 3: /* Resist Cold */
3487                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
3488                 break;
3489         case 4: /* Resist Fire */
3490                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
3491                 break;
3492         case 5: /* Heroism */
3493                 (void)set_hero(randint1(25) + 25, FALSE);
3494                 (void)hp_player(10);
3495                 (void)set_afraid(0);
3496                 break;
3497         case 6: /* Resist Lightning */
3498                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
3499                 break;
3500         case 7: /* Resist Acid */
3501                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
3502                 break;
3503         case 8: /* See Invisibility */
3504                 (void)set_tim_invis(randint1(24) + 24, FALSE);
3505                 break;
3506         case 9: /* Remove Curse */
3507                 if (remove_curse())
3508                 {
3509 #ifdef JP
3510                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
3511 #else
3512                         msg_print("You feel as if someone is watching over you.");
3513 #endif
3514                 }
3515                 break;
3516         case 10: /* Resist Poison */
3517                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
3518                 break;
3519         case 11: /* Berserk */
3520                 (void)set_shero(randint1(25) + 25, FALSE);
3521                 (void)hp_player(30);
3522                 (void)set_afraid(0);
3523                 break;
3524         case 12: /* Self Knowledge */
3525                 (void)self_knowledge();
3526                 break;
3527         case 13: /* Protection from Evil */
3528                 (void)set_protevil(randint1(25) + 3 * p_ptr->lev, FALSE);
3529                 break;
3530         case 14: /* Healing */
3531                 set_poisoned(0);
3532                 set_stun(0);
3533                 set_cut(0);
3534                 set_image(0);
3535                 break;
3536         case 15: /* Mana Branding */
3537                 return choose_ele_attack();
3538                 break;
3539         case 16: /* Telepathy */
3540                 (void)set_tim_esp(randint1(30) + 25, FALSE);
3541                 break;
3542         case 17: /* Stone Skin */
3543                 (void)set_shield(randint1(20) + 30, FALSE);
3544                 break;
3545         case 18: /* Resistance */
3546                 (void)set_oppose_acid(randint1(20) + 20, FALSE);
3547                 (void)set_oppose_elec(randint1(20) + 20, FALSE);
3548                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
3549                 (void)set_oppose_cold(randint1(20) + 20, FALSE);
3550                 (void)set_oppose_pois(randint1(20) + 20, FALSE);
3551                 break;
3552         case 19: /* Haste */
3553                 (void)set_fast(randint1(20 + plev) + plev, FALSE);
3554                 break;
3555         case 20: /* Walk through Wall */
3556                 (void)set_kabenuke(randint1(plev/2) + plev/2, FALSE);
3557                 break;
3558         case 21: /* Pulish Shield */
3559                 (void)pulish_shield();
3560                 break;
3561         case 22: /* Create Golem */
3562                 if (summon_specific(-1, py, px, plev, SUMMON_GOLEM, PM_FORCE_PET))
3563                 {
3564 #ifdef JP
3565 msg_print("¥´¡¼¥ì¥à¤òºî¤Ã¤¿¡£");
3566 #else
3567                 msg_print("You make a golem.");
3568 #endif
3569                 }
3570                 else
3571                 {
3572                         no_trump = TRUE;
3573                 }
3574                 break;
3575         case 23: /* Magic armor */
3576                 (void)set_magicdef(randint1(20) + 20, FALSE);
3577                 break;
3578         case 24: /* Remove Enchantment */
3579                 if (!mundane_spell(TRUE)) return FALSE;
3580                 break;
3581         case 25: /* Remove All Curse */
3582                 if (remove_all_curse())
3583                 {
3584 #ifdef JP
3585                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
3586 #else
3587                         msg_print("You feel as if someone is watching over you.");
3588 #endif
3589                 }
3590                 break;
3591         case 26: /* Total Knowledge */
3592                 return identify_fully(FALSE);
3593                 break;
3594         case 27: /* Enchant Weapon */
3595                 return enchant_spell(randint0(4) + 1, randint0(4) + 1, 0);
3596                 break;
3597         case 28: /* Enchant Armor */
3598                 return enchant_spell(0, 0, randint0(3) + 2);
3599                 break;
3600         case 29: /* Brand Weapon */
3601                 brand_weapon(randint0(18));
3602                 break;
3603         case 30: /* Living Trump */
3604                 if (one_in_(7))
3605                         /* Teleport control */
3606                         dummy = 12;
3607                 else
3608                         /* Random teleportation (uncontrolled) */
3609                         dummy = 77;
3610                 /* Gain the mutation */
3611                 if (gain_random_mutation(dummy))
3612 #ifdef JP
3613 msg_print("¤¢¤Ê¤¿¤ÏÀ¸¤­¤Æ¤¤¤ë¥«¡¼¥É¤ËÊѤï¤Ã¤¿¡£");
3614 #else
3615                         msg_print("You have turned into a Living Trump.");
3616 #endif
3617                 break;
3618         case 31: /* Immune */
3619                 return (choose_ele_immune(13 + randint1(13)));
3620                 break;
3621         default:
3622                 msg_format("You cast an unknown Craft spell: %d.", spell);
3623                 msg_print(NULL);
3624         }
3625
3626         if (no_trump)
3627 #ifdef JP
3628 msg_print("¤¦¤Þ¤¯¥´¡¼¥ì¥à¤òºî¤ì¤Ê¤«¤Ã¤¿¡£");
3629 #else
3630                 msg_print("No Golems arrive.");
3631 #endif
3632
3633         return TRUE;
3634 }
3635
3636
3637 /*
3638  * An "item_tester_hook" for offer
3639  */
3640 static bool item_tester_offer(object_type *o_ptr)
3641 {
3642         /* Flasks of oil are okay */
3643         if (o_ptr->tval != TV_CORPSE) return (FALSE);
3644
3645         if (o_ptr->sval != SV_CORPSE) return (FALSE);
3646
3647         if (strchr("pht", r_info[o_ptr->pval].d_char)) return (TRUE);
3648
3649         /* Assume not okay */
3650         return (FALSE);
3651 }
3652
3653
3654 static bool cast_daemon_spell(int spell)
3655 {
3656         int     dir, beam;
3657         int     plev = p_ptr->lev;
3658
3659         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
3660         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
3661         else beam = plev / 2;
3662
3663         switch (spell)
3664         {
3665         case 0: /* Magic Missile */
3666                 if (!get_aim_dir(&dir)) return FALSE;
3667
3668                 fire_bolt_or_beam(beam - 10, GF_MISSILE, dir,
3669                         damroll(3 + ((plev - 1) / 5), 4));
3670                 break;
3671         case 1: /* Detect Undead & Demons -> Unlife */
3672                 (void)detect_monsters_nonliving(DETECT_RAD_DEFAULT);
3673                 break;
3674         case 2: /* Bless */
3675                 (void)set_blessed(randint1(12) + 12, FALSE);
3676                 break;
3677         case 3: /* Resist Fire */
3678                 (void)set_oppose_fire(randint1(20) + 20, FALSE);
3679                 break;
3680         case 4: /* Horrify */
3681                 if (!get_aim_dir(&dir)) return FALSE;
3682
3683                 (void)fear_monster(dir, plev);
3684                 (void)stun_monster(dir, plev);
3685                 break;
3686         case 5: /* Nether Bolt */
3687                 if (!get_aim_dir(&dir)) return FALSE;
3688
3689                 fire_bolt_or_beam(beam, GF_NETHER, dir,
3690                     damroll(6 + ((plev - 5) / 4), 8));
3691                 break;
3692         case 6: /* Summon monster, demon */
3693                 if (!summon_specific(-1, py, px, (plev * 3) / 2, SUMMON_MANES, (PM_ALLOW_GROUP | PM_FORCE_PET)))
3694                 {
3695 #ifdef JP
3696 msg_print("¸ÅÂå¤Î»àÎî¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
3697 #else
3698                         msg_print("No Manes arrive.");
3699 #endif
3700                 }
3701                 break;
3702         case 7: /* Mini Hellfire */
3703                 if (!get_aim_dir(&dir)) return FALSE;
3704
3705                 fire_ball(GF_HELL_FIRE, dir,
3706                         (damroll(3, 6) + plev +
3707                         (plev / (((p_ptr->pclass == CLASS_MAGE) ||
3708                         (p_ptr->pclass == CLASS_HIGH_MAGE) ||
3709                         (p_ptr->pclass == CLASS_SORCERER)) ? 2 : 4))),
3710                         ((plev < 30) ? 2 : 3));
3711                 break;
3712         case 8: /* Enslave Demon */
3713                 if (!get_aim_dir(&dir)) return FALSE;
3714
3715                 (void)control_one_demon(dir, plev);
3716                 break;
3717         case 9: /* Vision */
3718                 map_area(DETECT_RAD_MAP);
3719                 break;
3720         case 10: /* Resist Nether */
3721                 (void)set_tim_res_nether(randint1(20) + 20, FALSE);
3722                 break;
3723         case 11: /* Plasma Bolt */
3724                 if (!get_aim_dir(&dir)) return FALSE;
3725
3726                 fire_bolt_or_beam(beam, GF_PLASMA, dir,
3727                     damroll(11 + ((plev - 5) / 4), 8));
3728                 break;
3729         case 12: /* Fire Ball */
3730                 if (!get_aim_dir(&dir)) return FALSE;
3731
3732                 fire_ball(GF_FIRE, dir, plev + 55, 2);
3733                 break;
3734         case 13: /* Fire Branding */
3735                 brand_weapon(1);
3736                 break;
3737         case 14: /* Nether Ball */
3738                 if (!get_aim_dir(&dir)) return FALSE;
3739
3740                 fire_ball(GF_NETHER, dir, plev*3/2 + 100, plev / 20+2);
3741                 break;
3742         case 15: /* Summon monster, demon */
3743         {
3744                 bool pet = !one_in_(3);
3745                 u32b mode = 0L;
3746
3747                 if (pet) mode |= PM_FORCE_PET;
3748                 else mode |= PM_NO_PET;
3749                 if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
3750
3751                 if (summon_specific((pet ? -1 : 0), py, px, plev*2/3+randint1(plev/2), SUMMON_DEMON, mode))
3752                 {
3753 #ifdef JP
3754 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
3755 #else
3756                         msg_print("The area fills with a stench of sulphur and brimstone.");
3757 #endif
3758
3759
3760                         if (pet)
3761 #ifdef JP
3762 msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
3763 #else
3764                                 msg_print("'What is thy bidding... Master?'");
3765 #endif
3766
3767                         else
3768 #ifdef JP
3769 msg_print("¡ÖÈܤ·¤­¼Ô¤è¡¢²æ¤ÏÆò¤Î²¼Ëͤˤ¢¤é¤º¡ª ¤ªÁ°¤Îº²¤òĺ¤¯¤¾¡ª¡×");
3770 #else
3771                                 msg_print("'NON SERVIAM! Wretch! I shall feast on thy mortal soul!'");
3772 #endif
3773
3774                 }
3775                 else
3776                 {
3777 #ifdef JP
3778 msg_print("°­Ëâ¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
3779 #else
3780                         msg_print("No demons arrive.");
3781 #endif
3782                 }
3783                 break;
3784         }
3785         case 16: /* Telepathy */
3786                 (void)set_tim_esp(randint1(30) + 25, FALSE);
3787                 break;
3788         case 17: /* Demoncloak */
3789         {
3790                 int dur=randint1(20) + 20;
3791                         
3792                 set_oppose_fire(dur, FALSE);
3793                 set_oppose_cold(dur, FALSE);
3794                 set_tim_sh_fire(dur, FALSE);
3795                 set_afraid(0);
3796                 break;
3797         }
3798         case 18: /* Rain of Lava */
3799                 fire_ball(GF_FIRE, 0, (55 + plev)*2, 3);
3800                 fire_ball_hide(GF_LAVA_FLOW, 0, 2+randint1(2), 3);
3801                 break;
3802         case 19: /* Plasma ball */
3803                 if (!get_aim_dir(&dir)) return FALSE;
3804
3805                 fire_ball(GF_PLASMA, dir, plev*3/2 + 80, 2 + plev/40);
3806                 break;
3807         case 20: /* Mimic demon */
3808                 (void)set_mimic(10+plev/2 + randint1(10+plev/2), MIMIC_DEMON, FALSE);
3809                 break;
3810         case 21: /* Nether Wave == Dispel Good */
3811                 (void)dispel_monsters(randint1(plev * 2));
3812                 (void)dispel_good(randint1(plev * 2));
3813                 break;
3814         case 22: /*  */
3815                 if (!get_aim_dir(&dir)) return FALSE;
3816                 fire_ball(GF_NEXUS, dir, 100 + plev*2, 4);
3817                 break;
3818         case 23: /* Hand Doom */
3819                 if (!get_aim_dir(&dir)) return FALSE;
3820 #ifdef JP
3821 else msg_print("<ÇËÌǤμê>¤òÊü¤Ã¤¿¡ª");
3822 #else
3823                 else msg_print("You invoke the Hand of Doom!");
3824 #endif
3825
3826                 fire_ball_hide(GF_HAND_DOOM, dir, plev * 2, 0);
3827                 break;
3828         case 24: /* Heroism */
3829                 (void)set_hero(randint1(25) + 25, FALSE);
3830                 (void)hp_player(10);
3831                 (void)set_afraid(0);
3832                 break;
3833         case 25: /* Tim resist time */
3834                 (void)set_tim_res_time(randint1(20)+20, FALSE);
3835                 break;
3836         case 26: /* Circle of Madness */
3837                 fire_ball(GF_CHAOS, 0, 50+plev, 3+plev/20);
3838                 fire_ball(GF_CONFUSION, 0, 50+plev, 3+plev/20);
3839                 fire_ball(GF_CHARM, 0, 20+plev, 3+plev/20);
3840                 break;
3841         case 27: /* True Discharge Minion */
3842                 discharge_minion();
3843                 break;
3844         case 28: /* Summon Greater Demon */
3845         {
3846                 int item;
3847                 cptr q, s;
3848                 int summon_lev;
3849                 object_type *o_ptr;
3850
3851                 item_tester_hook = item_tester_offer;
3852 #ifdef JP
3853                 q = "¤É¤Î»àÂΤòÊû¤²¤Þ¤¹¤«? ";
3854                 s = "Êû¤²¤é¤ì¤ë»àÂΤò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
3855 #else
3856                 q = "Sacrifice which corpse? ";
3857                 s = "You have nothing to scrifice.";
3858 #endif
3859                 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return FALSE;
3860
3861                 /* Get the item (in the pack) */
3862                 if (item >= 0)
3863                 {
3864                         o_ptr = &inventory[item];
3865                 }
3866
3867                 /* Get the item (on the floor) */
3868                 else
3869                 {
3870                         o_ptr = &o_list[0 - item];
3871                 }
3872
3873                 summon_lev = p_ptr->lev * 2 / 3 + r_info[o_ptr->pval].level;
3874                 if (summon_specific(-1, py, px, summon_lev, SUMMON_HI_DEMON, (PM_ALLOW_GROUP | PM_FORCE_PET)))
3875                 {
3876 #ifdef JP
3877 msg_print("ⲫ¤Î°­½­¤¬½¼Ëþ¤·¤¿¡£");
3878 #else
3879                         msg_print("The area fills with a stench of sulphur and brimstone.");
3880 #endif
3881
3882
3883 #ifdef JP
3884 msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
3885 #else
3886                         msg_print("'What is thy bidding... Master?'");
3887 #endif
3888
3889                         /* Decrease the item (from the pack) */
3890                         if (item >= 0)
3891                         {
3892                                 inven_item_increase(item, -1);
3893                                 inven_item_describe(item);
3894                                 inven_item_optimize(item);
3895                         }
3896
3897                         /* Decrease the item (from the floor) */
3898                         else
3899                         {
3900                                 floor_item_increase(0 - item, -1);
3901                                 floor_item_describe(0 - item);
3902                                 floor_item_optimize(0 - item);
3903                         }
3904                 }
3905                 else
3906                 {
3907 #ifdef JP
3908 msg_print("°­Ëâ¤Ï¸½¤ì¤Ê¤«¤Ã¤¿¡£");
3909 #else
3910                         msg_print("No Greater Demon arrive.");
3911 #endif
3912                 }
3913                 break;
3914         }
3915         case 29: /* Nether Storm */
3916                 if (!get_aim_dir(&dir)) return FALSE;
3917
3918                 fire_ball(GF_NETHER, dir, plev*15, plev / 5);
3919                 break;
3920         case 30: /* Blood curse */
3921         {
3922                 if (!get_aim_dir(&dir)) return FALSE;
3923
3924                 fire_ball_hide(GF_BLOOD_CURSE, dir, 600, 0);
3925 #ifdef JP
3926 take_hit(DAMAGE_USELIFE, 20 + randint1(30), "·ì¤Î¼ö¤¤", -1);
3927 #else
3928                 take_hit(DAMAGE_USELIFE, 20 + randint1(30), "Blood curse", -1);
3929 #endif
3930                 break;
3931         }
3932         case 31: /* Mimic Demon lord */
3933                 (void)set_mimic(15 + randint1(15), MIMIC_DEMON_LORD, FALSE);
3934                 break;
3935         default:
3936                 msg_format("You cast an unknown Daemon spell: %d.", spell);
3937                 msg_print(NULL);
3938         }
3939
3940         return TRUE;
3941 }
3942
3943
3944 static bool cast_crusade_spell(int spell)
3945 {
3946         int     dir;
3947         int     beam;
3948         int     plev = p_ptr->lev;
3949
3950         if (p_ptr->pclass == CLASS_MAGE) beam = plev;
3951         else if (p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER) beam = plev + 10;
3952         else beam = plev / 2;
3953
3954         switch (spell)
3955         {
3956         case 0:
3957                 if (!get_aim_dir(&dir)) return FALSE;
3958
3959                 fire_bolt_or_beam(beam - 10, GF_ELEC, dir,
3960                         damroll(3 + ((plev - 1) / 5), 4));
3961                 break;
3962         case 1:
3963                 (void)detect_monsters_evil(DETECT_RAD_DEFAULT);
3964                 break;
3965         case 2: /* Remove Fear */
3966                 (void)set_afraid(0);
3967                 break;
3968         case 3:
3969                 if (!get_aim_dir(&dir)) return FALSE;
3970
3971                 (void)fear_monster(dir, plev);
3972                 break;
3973         case 4:
3974                 (void)sleep_monsters_touch();
3975                 break;
3976         case 5:
3977                 teleport_player(25+plev/2);
3978                 break;
3979         case 6:
3980                 if (!get_aim_dir(&dir)) return FALSE;
3981                 fire_blast(GF_LITE, dir, 3+((plev-1)/9), 2, 10, 3);
3982                 break;
3983         case 7:
3984                 (void)set_cut(0);
3985                 (void)set_poisoned(0);
3986                 (void)set_stun(0);
3987                 break;
3988         case 8:
3989                 if (!get_aim_dir(&dir)) return FALSE;
3990                 (void)fire_ball(GF_AWAY_EVIL, dir, MAX_SIGHT*5, 0);
3991                 break;
3992         case 9: /* Holy Orb */
3993                 if (!get_aim_dir(&dir)) return FALSE;
3994
3995                 fire_ball(GF_HOLY_FIRE, dir,
3996                           (damroll(3, 6) + plev +
3997                           (plev / ((p_ptr->pclass == CLASS_PRIEST ||
3998                              p_ptr->pclass == CLASS_HIGH_MAGE ||
3999                              p_ptr->pclass == CLASS_SORCERER) ? 2 : 4))),
4000                           ((plev < 30) ? 2 : 3));
4001
4002                 break;
4003         case 10: /* Exorcism */
4004                 (void)dispel_undead(randint1(plev));
4005                 (void)dispel_demons(randint1(plev));
4006                 (void)turn_evil(plev);
4007                 break;
4008         case 11: /* Remove Curse */
4009                 if (remove_curse())
4010                 {
4011 #ifdef JP
4012                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4013 #else
4014                         msg_print("You feel as if someone is watching over you.");
4015 #endif
4016                 }
4017                 break;
4018         case 12: /* Sense Unseen */
4019                 (void)set_tim_invis(randint1(24) + 24, FALSE);
4020                 break;
4021         case 13: /* Protection from Evil */
4022                 (void)set_protevil(randint1(25) + 3 * p_ptr->lev, FALSE);
4023                 break;
4024         case 14:
4025                 if (!get_aim_dir(&dir)) return FALSE;
4026                 (void)fire_bolt(GF_ELEC, dir, plev*5);
4027                 break;
4028         case 15: /* Holy Word */
4029                 (void)dispel_evil(randint1(plev * 6));
4030                 (void)hp_player(100);
4031                 (void)set_afraid(0);
4032                 (void)set_poisoned(0);
4033                 (void)set_stun(0);
4034                 (void)set_cut(0);
4035                 break;
4036         case 16:
4037                 if (!get_aim_dir(&dir)) return FALSE;
4038
4039                 (void)destroy_door(dir);
4040                 break;
4041         case 17:
4042                 if (!get_aim_dir(&dir)) return FALSE;
4043                 (void)stasis_evil(dir);
4044                 break;
4045         case 18:
4046                 set_tim_sh_holy(randint1(20)+20, FALSE);
4047                 break;
4048         case 19: /* Dispel Undead + Demons */
4049                 (void)dispel_undead(randint1(plev * 4));
4050                 (void)dispel_demons(randint1(plev * 4));
4051                 break;
4052         case 20: /* Dispel Evil */
4053                 (void)dispel_evil(randint1(plev * 4));
4054                 break;
4055         case 21:
4056                 brand_weapon(13);
4057                 break;
4058         case 22: /* Star Burst */
4059                 if (!get_aim_dir(&dir)) return FALSE;
4060
4061                 fire_ball(GF_LITE, dir, 100+plev*2, 4);
4062                 break;
4063         case 23: /* Summon monster, angel */
4064                 {
4065                         bool pet = !one_in_(3);
4066                         u32b mode = 0L;
4067
4068                         if (pet) mode |= PM_FORCE_PET;
4069                         else mode |= PM_NO_PET;
4070                         if (!(pet && (plev < 50))) mode |= PM_ALLOW_GROUP;
4071
4072                         if (summon_specific((pet ? -1 : 0), py, px, (plev * 3) / 2, SUMMON_ANGEL, mode))
4073                         {
4074                                 if (pet)
4075 #ifdef JP
4076 msg_print("¡Ö¤´ÍѤǤ´¤¶¤¤¤Þ¤¹¤«¡¢¤´¼ç¿ÍÍÍ¡×");
4077 #else
4078                                         msg_print("'What is thy bidding... Master?'");
4079 #endif
4080
4081                                 else
4082 #ifdef JP
4083 msg_print("¡Ö²æ¤ÏÆò¤Î²¼Ëͤˤ¢¤é¤º¡ª °­¹Ô¼Ô¤è¡¢²ù¤¤²þ¤á¤è¡ª¡×");
4084 #else
4085                                         msg_print("Mortal! Repent of thy impiousness.");
4086 #endif
4087
4088                         }
4089                         break;
4090                 }
4091         case 24: /* Heroism */
4092                 (void)set_hero(randint1(25) + 25, FALSE);
4093                 (void)hp_player(10);
4094                 (void)set_afraid(0);
4095                 break;
4096         case 25: /* Remove All Curse */
4097                 if (remove_all_curse())
4098                 {
4099 #ifdef JP
4100                         msg_print("狼¤Ë¸«¼é¤é¤ì¤Æ¤¤¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
4101 #else
4102                         msg_print("You feel as if someone is watching over you.");
4103 #endif
4104                 }
4105                 break;
4106         case 26: /* Banishment */
4107                 if (banish_evil(100))
4108                 {
4109 #ifdef JP
4110 msg_print("¿ÀÀ»¤ÊÎϤ¬¼Ù°­¤òÂǤÁʧ¤Ã¤¿¡ª");
4111 #else
4112                         msg_print("The holy power banishes evil!");
4113 #endif
4114
4115                 }
4116                 break;
4117         case 27: /* Word of Destruction */
4118                 destroy_area(py, px, 13+randint0(5));
4119                 break;
4120         case 28: /* Eye for an Eye */
4121                 set_tim_eyeeye(randint1(10)+10, FALSE);
4122                 break;
4123         case 29:
4124                 {
4125                         int x, y, tx, ty;
4126                         int nx, ny;
4127                         int dir, i;
4128                         int b = 10 + randint1(10);
4129
4130                         if (!get_aim_dir(&dir)) return FALSE;
4131
4132                         /* Use the given direction */
4133                         tx = px + 99 * ddx[dir];
4134                         ty = py + 99 * ddy[dir];
4135
4136                         /* Hack -- Use an actual "target" */
4137                         if ((dir == 5) && target_okay())
4138                         {
4139                                 tx = target_col;
4140                                 ty = target_row;
4141                         }
4142
4143                         x = px;
4144                         y = py;
4145
4146                         while(1)
4147                         {
4148                                 /* Hack -- Stop at the target */
4149                                 if ((y == ty) && (x == tx)) break;
4150
4151                                 ny = y;
4152                                 nx = x;
4153                                 mmove2(&ny, &nx, py, px, ty, tx);
4154
4155                                 /* Stop at maximum range */
4156                                 if (MAX_SIGHT*2 < distance(py, px, ny, nx)) break;
4157
4158                                 /* Stopped by walls/doors */
4159                                 if (!cave_floor_bold(ny, nx)) break;
4160
4161                                 /* Stopped by monsters */
4162                                 if ((dir != 5) && cave[ny][nx].m_idx != 0) break;
4163
4164                                 /* Save the new location */
4165                                 x = nx;
4166                                 y = ny;
4167                         }
4168                         tx = x;
4169                         ty = y;
4170
4171                         for (i = 0; i < b; i++)
4172                         {
4173                                 int count = 20, d = 0;
4174
4175                                 while (count--)
4176                                 {
4177                                         int dx, dy;
4178
4179                                         x = tx - 5 + randint0(11);
4180                                         y = ty - 5 + randint0(11);
4181
4182                                         dx = (tx > x) ? (tx - x) : (x - tx);
4183                                         dy = (ty > y) ? (ty - y) : (y - ty);
4184
4185                                         /* Approximate distance */
4186                                         d = (dy > dx) ? (dy + (dx >> 1)) : (dx + (dy >> 1));
4187                                         /* Within the radius */
4188                                         if (d < 5) break;
4189                                 }
4190
4191                                 if (count < 0) continue;
4192
4193                                 /* Cannot penetrate perm walls */
4194                                 if (!in_bounds(y,x) ||
4195                                     cave_stop_disintegration(y,x) ||
4196                                     !in_disintegration_range(ty, tx, y, x))
4197                                         continue;
4198
4199                                 project(0, 2, y, x, plev * 3+25, GF_DISINTEGRATE, PROJECT_JUMP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL, -1);
4200                         }
4201                 }
4202                 break;
4203         case 30: /* Divine Intervention */
4204                 project(0, 1, py, px, plev*11, GF_HOLY_FIRE, PROJECT_KILL, -1);
4205                 dispel_monsters(plev * 4);
4206                 slow_monsters();
4207                 stun_monsters(plev * 4);
4208                 confuse_monsters(plev * 4);
4209                 turn_monsters(plev * 4);
4210                 stasis_monsters(plev * 4);
4211                 (void)hp_player(100);
4212                 break;
4213         case 31:
4214         {
4215                 int i;
4216                 (void)crusade();
4217                 for (i = 0; i < 12; i++)
4218                 {
4219                         int attempt = 10;
4220                         int my, mx;
4221
4222                         while (attempt--)
4223                         {
4224                                 scatter(&my, &mx, py, px, 4, 0);
4225
4226                                 /* Require empty grids */
4227                                 if (cave_empty_bold2(my, mx)) break;
4228                         }
4229                         if (attempt < 0) continue;
4230                         summon_specific(-1, my, mx, plev, SUMMON_KNIGHTS, (PM_ALLOW_GROUP | PM_FORCE_PET | PM_HASTE));
4231                 }
4232                 (void)set_hero(randint1(25) + 25, FALSE);
4233                 (void)set_blessed(randint1(25) + 25, FALSE);
4234                 (void)set_fast(randint1(20 + plev) + plev, FALSE);
4235                 (void)set_protevil(randint1(25) + 25, FALSE);
4236                 (void)set_afraid(0);
4237                 break;
4238         }
4239         default:
4240 #ifdef JP
4241 msg_format("¤¢¤Ê¤¿¤ÏÉÔÌÀ¤ÊÇ˼٤μöʸ %d ¤ò¾§¤¨¤¿¡£", spell);
4242 #else
4243                 msg_format("You cast an unknown crusade spell: %d.", spell);
4244 #endif
4245
4246                 msg_print(NULL);
4247         }
4248
4249         return TRUE;
4250 }
4251
4252
4253
4254 void stop_singing(void)
4255 {
4256         if (p_ptr->pclass != CLASS_BARD) return;
4257
4258         if (p_ptr->magic_num1[1])
4259         {
4260                 p_ptr->magic_num1[1] = 0;
4261                 return;
4262         }
4263         if (!p_ptr->magic_num1[0]) return;
4264
4265         set_action(ACTION_NONE);
4266
4267         switch(p_ptr->magic_num1[0])
4268         {
4269                 case MUSIC_BLESS:
4270                         if (!p_ptr->blessed)
4271 #ifdef JP
4272 msg_print("¹â·é¤Êµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
4273 #else
4274                                 msg_print("The prayer has expired.");
4275 #endif
4276                         break;
4277                 case MUSIC_HERO:
4278                         if (!p_ptr->hero)
4279                         {
4280 #ifdef JP
4281 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
4282 #else
4283                                 msg_print("The heroism wears off.");
4284 #endif
4285                                 /* Recalculate hitpoints */
4286                                 p_ptr->update |= (PU_HP);
4287                         }
4288                         break;
4289                 case MUSIC_MIND:
4290                         if (!p_ptr->tim_esp)
4291                         {
4292 #ifdef JP
4293 msg_print("°Õ¼±¤Ï¸µ¤ËÌá¤Ã¤¿¡£");
4294 #else
4295                                 msg_print("Your consciousness contracts again.");
4296 #endif
4297                                 /* Update the monsters */
4298                                 p_ptr->update |= (PU_MONSTERS);
4299                         }
4300                         break;
4301                 case MUSIC_STEALTH:
4302                         if (!p_ptr->tim_stealth)
4303 #ifdef JP
4304 msg_print("»Ñ¤¬¤Ï¤Ã¤­¤ê¤È¸«¤¨¤ë¤è¤¦¤Ë¤Ê¤Ã¤¿¡£");
4305 #else
4306                                 msg_print("You are no longer hided.");
4307 #endif
4308                         break;
4309                 case MUSIC_RESIST:
4310                         if (!p_ptr->oppose_acid)
4311 #ifdef JP
4312 msg_print("»À¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
4313 #else
4314                                 msg_print("You feel less resistant to acid.");
4315 #endif
4316                         if (!p_ptr->oppose_elec)
4317 #ifdef JP
4318 msg_print("ÅÅ·â¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
4319 #else
4320                                 msg_print("You feel less resistant to elec.");
4321 #endif
4322                         if (!p_ptr->oppose_fire)
4323 #ifdef JP
4324 msg_print("²Ð¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
4325 #else
4326                                 msg_print("You feel less resistant to fire.");
4327 #endif
4328                         if (!p_ptr->oppose_cold)
4329 #ifdef JP
4330 msg_print("Î䵤¤Ø¤ÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
4331 #else
4332                                 msg_print("You feel less resistant to cold.");
4333 #endif
4334                         if (!p_ptr->oppose_pois)
4335 #ifdef JP
4336 msg_print("ÆǤؤÎÂÑÀ­¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
4337 #else
4338                                 msg_print("You feel less resistant to pois.");
4339 #endif
4340                         break;
4341                 case MUSIC_SPEED:
4342                         if (!p_ptr->fast)
4343 #ifdef JP
4344 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
4345 #else
4346                                 msg_print("You feel yourself slow down.");
4347 #endif
4348                         break;
4349                 case MUSIC_SHERO:
4350                         if (!p_ptr->hero)
4351                         {
4352 #ifdef JP
4353 msg_print("¥Ò¡¼¥í¡¼¤Îµ¤Ê¬¤¬¾Ã¤¨¼º¤»¤¿¡£");
4354 #else
4355                                 msg_print("The heroism wears off.");
4356 #endif
4357                                 /* Recalculate hitpoints */
4358                                 p_ptr->update |= (PU_HP);
4359                         }
4360
4361                         if (!p_ptr->fast)
4362 #ifdef JP
4363 msg_print("Æ°¤­¤ÎÁÇÁᤵ¤¬¤Ê¤¯¤Ê¤Ã¤¿¤è¤¦¤À¡£");
4364 #else
4365                                 msg_print("You feel yourself slow down.");
4366 #endif
4367                         break;
4368                 case MUSIC_INVULN:
4369                         if (!p_ptr->invuln)
4370                         {
4371 #ifdef JP
4372 msg_print("̵Ũ¤Ç¤Ï¤Ê¤¯¤Ê¤Ã¤¿¡£");
4373 #else
4374                                 msg_print("The invulnerability wears off.");
4375 #endif
4376                                 /* Redraw map */
4377                                 p_ptr->redraw |= (PR_MAP);
4378
4379                                 /* Update monsters */
4380                                 p_ptr->update |= (PU_MONSTERS);
4381
4382                                 /* Window stuff */
4383                                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4384                         }
4385                         break;
4386         }
4387         p_ptr->magic_num1[0] = MUSIC_NONE;
4388         p_ptr->magic_num2[0] = 0;
4389
4390         /* Recalculate bonuses */
4391         p_ptr->update |= (PU_BONUS | PU_HP);
4392
4393         /* Redraw status bar */
4394         p_ptr->redraw |= (PR_STATUS);
4395 }
4396
4397
4398 static bool cast_music_spell(int spell)
4399 {
4400         int     plev = p_ptr->lev;
4401         int dir;
4402
4403         if(p_ptr->magic_num1[0])
4404         {
4405                 stop_singing();
4406         }
4407
4408         p_ptr->magic_num2[0] = spell;
4409
4410         switch (spell)
4411         {
4412         case 0: /* Song of Holding ÃÙÆߤβΠ*/
4413 #ifdef JP
4414                 msg_print("¤æ¤Ã¤¯¤ê¤È¤·¤¿¥á¥í¥Ç¥£¤ò¸ý¤º¤µ¤ß»Ï¤á¤¿¡¥¡¥¡¥");
4415 #else
4416                 msg_print("You start humming a slow, steady melody...");
4417 #endif
4418                 p_ptr->magic_num1[0] = MUSIC_SLOW;
4419                 break;
4420         case 1:  /* Song of Blessing ½ËÊ¡¤Î²Î */
4421 #ifdef JP
4422                 msg_print("¸·¤«¤Ê¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4423 #else
4424                 msg_print("The holy power of the Music of the Ainur enters you...");
4425 #endif
4426                 p_ptr->magic_num1[0] = MUSIC_BLESS;
4427                 break;
4428                 
4429         case 2:  /* Wrecking Note Êø²õ¤Î²»¿§ */
4430                 if (!get_aim_dir(&dir)) return FALSE;
4431                 fire_bolt(GF_SOUND, dir,
4432                           damroll(4 + ((plev - 1) / 5), 4));
4433                 break;
4434         case 3:  /* Stun Pattern Û¯Û°¤ÎÀûΧ */
4435 #ifdef JP
4436                 msg_print("âÁÏǤµ¤»¤ë¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4437 #else
4438                 msg_print("You weave a pattern of sounds to bewilder and daze...");
4439 #endif
4440                 p_ptr->magic_num1[0] = MUSIC_STUN;
4441                 break;
4442         case 4:  /* Flow of life À¸Ì¿¤Îή¤ì */
4443 #ifdef JP
4444                 msg_print("²Î¤òÄ̤·¤ÆÂΤ˳赤¤¬Ìá¤Ã¤Æ¤­¤¿¡¥¡¥¡¥");
4445 #else
4446                 msg_print("Life flows through you as you sing a song of healing...");
4447 #endif
4448                 p_ptr->magic_num1[0] = MUSIC_L_LIFE;
4449                 break;
4450         case 5:  /* Song of the Sun ÂÀÍۤβΠ*/
4451 #ifdef JP
4452                 msg_print("¸÷¤êµ±¤¯²Î¤¬ÊÕ¤ê¤ò¾È¤é¤·¤¿¡£");
4453 #else
4454                 msg_print("Your uplifting song brings brightness to dark places...");
4455 #endif
4456                 (void)lite_area(damroll(2, (plev / 2)), (plev / 10) + 1);
4457                 break;
4458         case 6:  /* Song of fear ¶²ÉݤβΠ*/
4459 #ifdef JP
4460                 msg_print("¤ª¤É¤í¤ª¤É¤í¤·¤¤¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4461 #else
4462                 msg_print("You start weaving a fearful pattern...");
4463 #endif
4464                 p_ptr->magic_num1[0] = MUSIC_FEAR;
4465                 break;
4466         case 7:  /* Heroic Ballad À襤¤Î²Î */
4467 #ifdef JP
4468                 msg_print("·ã¤·¤¤À襤¤Î²Î¤ò²Î¤Ã¤¿¡¥¡¥¡¥");
4469 #else
4470                 msg_print("You start singing a song of intense fighting...");
4471 #endif
4472                 p_ptr->magic_num1[0] = MUSIC_HERO;
4473                 break;
4474         case 8:  /* Clairaudience ÎîŪÃγР*/
4475 #ifdef JP
4476                 msg_print("ÀŤ«¤Ê²»³Ú¤¬´¶³Ð¤ò¸¦¤®À¡¤Þ¤µ¤»¤¿¡¥¡¥¡¥");
4477 #else
4478                 msg_print("Your quiet music sharpens your sense of hearing...");
4479 #endif
4480                 p_ptr->magic_num1[0] = MUSIC_DETECT;
4481                 break;
4482         case 9: /* º²¤Î²Î */
4483 #ifdef JP
4484                 msg_print("Àº¿À¤òDZ¤¸¶Ê¤²¤ë²Î¤ò²Î¤Ã¤¿¡¥¡¥¡¥");
4485 #else
4486                 msg_print("You start singing a song of soul in pain...");
4487 #endif
4488                 p_ptr->magic_num1[0] = MUSIC_PSI;
4489                 break;
4490         case 10:  /* Song of Lore Ãμ±¤Î²Î */
4491 #ifdef JP
4492                 msg_print("¤³¤ÎÀ¤³¦¤ÎÃ챤¬Î®¤ì¹þ¤ó¤Ç¤­¤¿¡¥¡¥¡¥");
4493 #else
4494                 msg_print("You recall the rich lore of the world...");
4495 #endif
4496                 p_ptr->magic_num1[0] = MUSIC_ID;
4497                 break;
4498         case 11:  /* hidding song ±£ÆۤβΠ*/
4499 #ifdef JP
4500                 msg_print("¤¢¤Ê¤¿¤Î»Ñ¤¬·Ê¿§¤Ë¤È¤±¤³¤ó¤Ç¤¤¤Ã¤¿¡¥¡¥¡¥");
4501 #else
4502                 msg_print("Your song carries you beyond the sight of mortal eyes...");
4503 #endif
4504                 p_ptr->magic_num1[0] = MUSIC_STEALTH;
4505                 break;
4506         case 12:  /* Illusion Pattern ¸¸±Æ¤ÎÀûΧ */
4507 #ifdef JP
4508                 msg_print("ÊÕ¤ê°ìÌ̤˸¸±Æ¤¬¸½¤ì¤¿¡¥¡¥¡¥");
4509 #else
4510                 msg_print("You weave a pattern of sounds to beguile and confuse...");
4511 #endif
4512                 p_ptr->magic_num1[0] = MUSIC_CONF;
4513                 break;
4514         case 13:  /* Doomcall (vibration song) ÇËÌǤζ«¤Ó */
4515 #ifdef JP
4516                 msg_print("¹ì²»¤¬¶Á¤¤¤¿¡¥¡¥¡¥");
4517 #else
4518                 msg_print("The fury of the Downfall of Numenor lashes out...");
4519 #endif
4520                 p_ptr->magic_num1[0] = MUSIC_SOUND;
4521                 break;
4522         case 14:  /* Firiel's Song (song of the Undeads) ¥Õ¥£¥ê¥¨¥ë¤Î²Î */
4523 #ifdef JP
4524                 msg_print("À¸Ì¿¤ÈÉü³è¤Î¥Æ¡¼¥Þ¤òÁդǻϤ᤿¡¥¡¥¡¥");
4525 #else
4526                 msg_print("The themes of life and revival are woven into your song...");
4527 #endif
4528                 animate_dead(0, py, px);
4529                 break;
4530         case 15:  /* Fellowship Chant (charming song) Î¹¤ÎÃç´Ö */
4531 #ifdef JP
4532                 msg_print("°Â¤é¤«¤Ê¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4533 #else
4534                 msg_print("You weave a slow, soothing melody of imploration...");
4535 #endif
4536                 p_ptr->magic_num1[0] = MUSIC_CHARM;
4537                 break;
4538         case 16:  /* (wall breaking song) Ê¬²ò²»ÇÈ */
4539 #ifdef JP
4540                 msg_print("Ê´ºÕ¤¹¤ë¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4541 #else
4542                 msg_print("You weave a violent pattern of sounds to break wall.");
4543 #endif
4544                 p_ptr->magic_num1[0] = MUSIC_WALL;
4545                 project(0, 0, py, px,
4546                         0, GF_DISINTEGRATE, PROJECT_KILL | PROJECT_ITEM | PROJECT_HIDE, -1);
4547                 break;
4548         case 17:  /* Finrod's Resistance (song of resistance) ¸µÁÇÂÑÀ­ */
4549 #ifdef JP
4550                 msg_print("¸µÁǤÎÎϤËÂФ¹¤ëǦÂѤβΤò²Î¤Ã¤¿¡£");
4551 #else
4552                 msg_print("You sing a song of perseverance against powers...");
4553 #endif
4554                 p_ptr->magic_num1[0] = MUSIC_RESIST;
4555                 break;
4556         case 18:  /* Hobbit Melodies (song of time) ¥Û¥Ó¥Ã¥È¤Î¥á¥í¥Ç¥£ */
4557 #ifdef JP
4558                 msg_print("·Ú²÷¤Ê²Î¤ò¸ý¤º¤µ¤ß»Ï¤á¤¿¡¥¡¥¡¥");
4559 #else
4560                 msg_print("You start singing joyful pop song...");
4561 #endif
4562                 p_ptr->magic_num1[0] = MUSIC_SPEED;
4563                 break;
4564         case 19:  /* World Contortion ÏĤó¤ÀÀ¤³¦ */
4565 #ifdef JP
4566                 msg_print("²Î¤¬¶õ´Ö¤òÏĤ᤿¡¥¡¥¡¥");
4567 #else
4568                 msg_print("Reality whirls wildly as you sing a dizzying melody...");
4569 #endif
4570                 project(0, plev/15 + 1, py, px, plev * 3 + 1, GF_AWAY_ALL , PROJECT_KILL, -1);
4571                 break;
4572         case 20: /* Â໶¤Î²Î */
4573 #ifdef JP
4574                 msg_print("ÂѤ¨¤é¤ì¤Ê¤¤ÉÔ¶¨Ï²»¤¬Å¨¤òÀÕ¤áΩ¤Æ¤¿¡¥¡¥¡¥");
4575 #else
4576                 msg_print("You cry out in an ear-wracking voice...");
4577 #endif
4578                 p_ptr->magic_num1[0] = MUSIC_DISPEL;
4579                 break;
4580         case 21: /* The Voice of Saruman ¥µ¥ë¥Þ¥ó¤Î´Å¸À */
4581 #ifdef JP
4582                 msg_print("Í¥¤·¤¯¡¢Ì¥ÎÏŪ¤Ê²Î¤ò¸ý¤º¤µ¤ß»Ï¤á¤¿¡¥¡¥¡¥");
4583 #else
4584                 msg_print("You start humming a gentle and attractive song...");
4585 #endif
4586                 p_ptr->magic_num1[0] = MUSIC_SARUMAN;
4587                 break;
4588         case 22:  /* Song of Tempest (song of death) Íò¤Î²»¿§ */
4589                 if (!get_aim_dir(&dir)) return FALSE;
4590                 fire_beam(GF_SOUND, dir,
4591                           damroll(15 + ((plev - 1) / 2), 10));
4592                 break;
4593         case 23:  /* (song of disruption) ¤â¤¦°ì¤Ä¤ÎÀ¤³¦ */
4594 #ifdef JP
4595                 msg_print("¼þ°Ï¤¬ÊѲ½¤·»Ï¤á¤¿¡¥¡¥¡¥");
4596 #else
4597                 msg_print("You sing of the primeval shaping of Middle-earth...");
4598 #endif
4599                 alter_reality();
4600                 break;
4601         case 24:  /* Wrecking Pattern (destruction shriek) Ç˲õ¤ÎÀûΧ */
4602 #ifdef JP
4603                 msg_print("Ç˲õŪ¤Ê²Î¤¬¶Á¤­¤ï¤¿¤Ã¤¿¡¥¡¥¡¥");
4604 #else
4605                 msg_print("You weave a pattern of sounds to contort and shatter...");
4606 #endif
4607                 p_ptr->magic_num1[0] = MUSIC_QUAKE;
4608                 break;
4609         case 25: /* ÄäÂڤβΠ */
4610 #ifdef JP
4611                 msg_print("¤æ¤Ã¤¯¤ê¤È¤·¤¿¥á¥í¥Ç¥£¤òÁդǻϤ᤿¡¥¡¥¡¥");
4612 #else
4613                 msg_print("You weave a very slow pattern which is almost likely to stop...");
4614 #endif
4615                 p_ptr->magic_num1[0] = MUSIC_STASIS;
4616                 break;
4617         case 26: /* ¼é¤ê¤Î²Î */
4618 #ifdef JP
4619                 msg_print("²Î¤¬¿ÀÀ»¤Ê¾ì¤òºî¤ê½Ð¤·¤¿¡¥¡¥¡¥");
4620 #else
4621                 msg_print("The holy power of the Music is creating sacred field...");
4622 #endif
4623                 warding_glyph();
4624                 break;
4625         case 27: /* ±Ñͺ¤Î»í */
4626 #ifdef JP
4627                 msg_print("±Ñͺ¤Î²Î¤ò¸ý¤º¤µ¤ó¤À¡¥¡¥¡¥");
4628 #else
4629                 msg_print("You chant a powerful, heroic call to arms...");
4630 #endif
4631                 p_ptr->magic_num1[0] = MUSIC_SHERO;
4632                 (void)hp_player(10);
4633                 (void)set_afraid(0);
4634                 break;
4635         case 28: /* ¥ä¥ô¥¡¥ó¥Ê¤Î½õ¤± */
4636 #ifdef JP
4637                 msg_print("²Î¤òÄ̤·¤ÆÂΤ˳赤¤¬Ìá¤Ã¤Æ¤­¤¿¡¥¡¥¡¥");
4638 #else
4639                 msg_print("Life flows through you as you sing the song...");
4640 #endif
4641                 p_ptr->magic_num1[0] = MUSIC_H_LIFE;
4642                 break;
4643         case 29: /* ºÆÀ¸¤Î²Î */
4644 #ifdef JP
4645                 msg_print("°Å¹õ¤ÎÃæ¤Ë¸÷¤ÈÈþ¤ò¤Õ¤ê¤Þ¤¤¤¿¡£ÂΤ¬¸µ¤Î³èÎϤò¼è¤êÌᤷ¤¿¡£");
4646 #else
4647                 msg_print("You strewed light and beauty in the dark as you sing. You feel refreshed.");
4648 #endif
4649                 (void)do_res_stat(A_STR);
4650                 (void)do_res_stat(A_INT);
4651                 (void)do_res_stat(A_WIS);
4652                 (void)do_res_stat(A_DEX);
4653                 (void)do_res_stat(A_CON);
4654                 (void)do_res_stat(A_CHR);
4655                 (void)restore_level();
4656                 break;
4657         case 30:  /* shriek of death ¥µ¥¦¥í¥ó¤ÎËâ½Ñ */
4658                 if (!get_aim_dir(&dir)) return FALSE;
4659                 fire_ball(GF_SOUND, dir, damroll(50 + plev, 10), 0);
4660                 break;
4661         case 31:  /* song of liberty ¥Õ¥£¥ó¥´¥ë¥Õ¥£¥ó¤ÎÄ©Àï */
4662 #ifdef JP
4663                 msg_print("¥Õ¥£¥ó¥´¥ë¥Õ¥£¥ó¤Î̽²¦¤Ø¤ÎÄ©Àï¤ò²Î¤Ã¤¿¡¥¡¥¡¥");
4664 #else
4665                 msg_print("You recall the valor of Fingolfin's challenge to the Dark Lord...");
4666 #endif
4667                 p_ptr->magic_num1[0] = MUSIC_INVULN;
4668                 
4669                 /* Redraw map */
4670                 p_ptr->redraw |= (PR_MAP);
4671                 
4672                 /* Update monsters */
4673                 p_ptr->update |= (PU_MONSTERS);
4674                 
4675                 /* Window stuff */
4676                 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4677                 break;
4678         default:
4679 #ifdef JP
4680                 msg_format("̤ÃΤβÎ(%d)¤ò²Î¤Ã¤¿¡£", spell);
4681 #else
4682                 msg_format("You sing an unknown song: %d.", spell);
4683 #endif
4684                 msg_print(NULL);
4685         }
4686
4687         if (p_ptr->magic_num1[0]) set_action(ACTION_SING);
4688
4689         /* Recalculate bonuses */
4690         p_ptr->update |= (PU_BONUS | PU_HP);
4691
4692         /* Redraw status bar */
4693         p_ptr->redraw |= (PR_STATUS);
4694         return TRUE;
4695 }
4696
4697
4698 /*
4699  * Cast a spell
4700  */
4701 void do_cmd_cast(void)
4702 {
4703         int     item, sval, spell, realm;
4704         int     chance;
4705         int     increment = 0;
4706         int     use_realm;
4707         int     need_mana;
4708         bool cast;
4709
4710         cptr prayer;
4711
4712         object_type     *o_ptr;
4713
4714         magic_type      *s_ptr;
4715
4716         cptr q, s;
4717
4718         /* Require spell ability */
4719         if (!p_ptr->realm1 && (p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE))
4720         {
4721 #ifdef JP
4722 msg_print("¼öʸ¤ò¾§¤¨¤é¤ì¤Ê¤¤¡ª");
4723 #else
4724                 msg_print("You cannot cast spells!");
4725 #endif
4726
4727                 return;
4728         }
4729
4730         /* Require lite */
4731         if (p_ptr->blind || no_lite())
4732         {
4733 #ifdef JP
4734 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
4735 #else
4736                 msg_print("You cannot see!");
4737 #endif
4738                 if (p_ptr->pclass == CLASS_FORCETRAINER)
4739                     do_cmd_mind();
4740                 else
4741                         flush();
4742                 return;
4743         }
4744
4745         /* Not when confused */
4746         if (p_ptr->confused)
4747         {
4748 #ifdef JP
4749 msg_print("º®Í𤷤Ƥ¤¤Æ¾§¤¨¤é¤ì¤Ê¤¤¡ª");
4750 #else
4751                 msg_print("You are too confused!");
4752 #endif
4753                 flush();
4754                 return;
4755         }
4756
4757         prayer = spell_categoly_name(mp_ptr->spell_book);
4758
4759         /* Restrict choices to spell books */
4760         item_tester_tval = mp_ptr->spell_book;
4761
4762         /* Get an item */
4763 #ifdef JP
4764 q = "¤É¤Î¼öʸ½ñ¤ò»È¤¤¤Þ¤¹¤«? ";
4765 #else
4766         q = "Use which book? ";
4767 #endif
4768
4769 #ifdef JP
4770 s = "¼öʸ½ñ¤¬¤Ê¤¤¡ª";
4771 #else
4772         s = "You have no spell books!";
4773 #endif
4774
4775         if (p_ptr->pclass == CLASS_FORCETRAINER)
4776                 select_the_force = TRUE;
4777         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))){
4778             select_the_force = FALSE;
4779             return;
4780         }
4781         select_the_force = FALSE;
4782
4783         if (item == INVEN_FORCE) { /* the_force */
4784             do_cmd_mind();
4785             return;
4786         } else
4787         /* Get the item (in the pack) */
4788         if (item >= 0)
4789         {
4790                 o_ptr = &inventory[item];
4791         }
4792
4793         /* Get the item (on the floor) */
4794         else
4795         {
4796                 o_ptr = &o_list[0 - item];
4797         }
4798
4799         /* Access the item's sval */
4800         sval = o_ptr->sval;
4801
4802         if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
4803
4804
4805         /* Track the object kind */
4806         object_kind_track(o_ptr->k_idx);
4807
4808         /* Hack -- Handle stuff */
4809         handle_stuff();
4810
4811         if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE))
4812                 realm = o_ptr->tval - TV_LIFE_BOOK + 1;
4813         else if (increment) realm = p_ptr->realm2;
4814         else realm = p_ptr->realm1;
4815
4816         /* Ask for a spell */
4817 #ifdef JP
4818         if (!get_spell(&spell,  
4819                                 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_MUSIC_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"), 
4820                        sval, TRUE, realm))
4821         {
4822                 if (spell == -2) msg_format("¤½¤ÎËܤˤÏÃΤäƤ¤¤ë%s¤¬¤Ê¤¤¡£", prayer);
4823                 return;
4824         }
4825 #else
4826         if (!get_spell(&spell, ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
4827                 sval, TRUE, realm))
4828         {
4829                 if (spell == -2)
4830                         msg_format("You don't know any %ss in that book.", prayer);
4831                 return;
4832         }
4833 #endif
4834
4835
4836         use_realm = tval2realm(o_ptr->tval);
4837
4838         if (!is_magic(use_realm))
4839         {
4840                 s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
4841         }
4842         else
4843         {
4844                 s_ptr = &mp_ptr->info[realm - 1][spell];
4845         }
4846
4847         /* Extract mana consumption rate */
4848         need_mana = mod_need_mana(s_ptr->smana, spell, realm);
4849
4850         /* Verify "dangerous" spells */
4851         if (need_mana > p_ptr->csp)
4852         {
4853                 if (flush_failure) flush();
4854
4855                 /* Warning */
4856 #ifdef JP
4857 msg_format("¤½¤Î%s¤ò%s¤Î¤Ë½½Ê¬¤Ê¥Þ¥¸¥Ã¥¯¥Ý¥¤¥ó¥È¤¬¤Ê¤¤¡£",prayer,
4858 ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "±Ó¾§¤¹¤ë" : (mp_ptr->spell_book == TV_LIFE_BOOK) ? "²Î¤¦" : "¾§¤¨¤ë"));
4859 #else
4860                 msg_format("You do not have enough mana to %s this %s.",
4861                         ((mp_ptr->spell_book == TV_LIFE_BOOK) ? "recite" : "cast"),
4862                         prayer);
4863 #endif
4864
4865
4866                 if (!over_exert) return;
4867
4868                 /* Verify */
4869 #ifdef JP
4870                 if (!get_check_strict("¤½¤ì¤Ç¤âÄ©À路¤Þ¤¹¤«? ", CHECK_OKAY_CANCEL)) return;
4871 #else
4872                 if (!get_check_strict("Attempt it anyway? ", CHECK_OKAY_CANCEL)) return;
4873 #endif
4874
4875         }
4876
4877
4878         /* Spell failure chance */
4879         chance = spell_chance(spell, use_realm);
4880
4881         /* Failed spell */
4882         if (randint0(100) < chance)
4883         {
4884                 if (flush_failure) flush();
4885
4886 #ifdef JP
4887 msg_format("%s¤ò¤¦¤Þ¤¯¾§¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡ª", prayer);
4888 #else
4889                 msg_format("You failed to get the %s off!", prayer);
4890 #endif
4891
4892                 sound(SOUND_FAIL);
4893
4894                 switch (realm)
4895                 {
4896                 case REALM_LIFE:
4897                         if (randint1(100) < chance) chg_virtue(V_VITALITY, -1);
4898                         break;
4899                 case REALM_DEATH:
4900                         if (randint1(100) < chance) chg_virtue(V_UNLIFE, -1);
4901                         break;
4902                 case REALM_NATURE:
4903                         if (randint1(100) < chance) chg_virtue(V_NATURE, -1);
4904                         break;
4905                 case REALM_DAEMON:
4906                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, 1);
4907                         break;
4908                 case REALM_CRUSADE:
4909                         if (randint1(100) < chance) chg_virtue(V_JUSTICE, -1);
4910                         break;
4911                 default:
4912                         if (randint1(100) < chance) chg_virtue(V_KNOWLEDGE, -1);
4913                         break;
4914                 }
4915
4916                 if (realm == REALM_TRUMP)
4917                 {
4918                         cast_trump_spell(spell, FALSE);
4919                 }
4920                 else if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
4921                 {
4922 #ifdef JP
4923 msg_print("¥«¥ª¥¹Åª¤Ê¸ú²Ì¤òȯÀ¸¤·¤¿¡ª");
4924 #else
4925                         msg_print("You produce a chaotic effect!");
4926 #endif
4927
4928                         wild_magic(spell);
4929                 }
4930                 else if ((o_ptr->tval == TV_DEATH_BOOK) && (randint1(100) < spell))
4931                 {
4932                         if ((sval == 3) && one_in_(2))
4933                         {
4934                                 sanity_blast(0, TRUE);
4935                         }
4936                         else
4937                         {
4938 #ifdef JP
4939                                 msg_print("Äˤ¤¡ª");
4940 #else
4941                                 msg_print("It hurts!");
4942 #endif
4943
4944 #ifdef JP
4945                                 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), "°Å¹õËâË¡¤ÎµÕή", -1);
4946 #else
4947                                 take_hit(DAMAGE_LOSELIFE, damroll(o_ptr->sval + 1, 6), "a miscast Death spell", -1);
4948 #endif
4949
4950                                 if ((spell > 15) && one_in_(6) && !p_ptr->hold_life)
4951                                         lose_exp(spell * 250);
4952                         }
4953                 }
4954                 else if ((o_ptr->tval == TV_MUSIC_BOOK) && (randint1(200) < spell))
4955                 {
4956 #ifdef JP
4957 msg_print("¤¤¤ä¤Ê²»¤¬¶Á¤¤¤¿");
4958 #else
4959 msg_print("An infernal sound echoed.");
4960 #endif
4961
4962                         aggravate_monsters(0);
4963                 }
4964                 if (randint1(100) >= chance)
4965                         chg_virtue(V_CHANCE,-1);
4966         }
4967
4968         /* Process spell */
4969         else
4970         {
4971                 /* Spells.  */
4972                 switch (realm)
4973                 {
4974                 case REALM_LIFE: /* * LIFE * */
4975                         cast = cast_life_spell(spell);
4976                         break;
4977                 case REALM_SORCERY: /* * SORCERY * */
4978                         cast = cast_sorcery_spell(spell);
4979                         break;
4980                 case REALM_NATURE: /* * NATURE * */
4981                         cast = cast_nature_spell(spell);
4982                         break;
4983                 case REALM_CHAOS: /* * CHAOS * */
4984                         cast = cast_chaos_spell(spell);
4985                         break;
4986                 case REALM_DEATH: /* * DEATH * */
4987                         cast = cast_death_spell(spell);
4988                         break;
4989                 case REALM_TRUMP: /* TRUMP */
4990                         cast = cast_trump_spell(spell, TRUE);
4991                         break;
4992                 case REALM_ARCANE: /* ARCANE */
4993                         cast = cast_arcane_spell(spell);
4994                         break;
4995                 case REALM_ENCHANT: /* ENCHANT */
4996                         cast = cast_enchant_spell(spell);
4997                         break;
4998                 case REALM_DAEMON: /* DAEMON */
4999                         cast = cast_daemon_spell(spell);
5000                         break;
5001                 case REALM_CRUSADE: /* CRUSADE */
5002                         cast = cast_crusade_spell(spell);
5003                         break;
5004                 case REALM_MUSIC: /* MUSIC */
5005                         cast = cast_music_spell(spell);
5006                         break;
5007                 default:
5008                         cast = FALSE;
5009                         msg_format("You cast a spell from an unknown realm: realm %d, spell %d.", realm, spell);
5010                         msg_print(NULL);
5011                 }
5012
5013                 /* Canceled spells cost neither a turn nor mana */
5014                 if (!cast) return;
5015
5016                 if (randint1(100) < chance)
5017                         chg_virtue(V_CHANCE,1);
5018
5019                 /* A spell was cast */
5020                 if (!(increment ?
5021                     (p_ptr->spell_worked2 & (1L << spell)) :
5022                     (p_ptr->spell_worked1 & (1L << spell)))
5023                     && (p_ptr->pclass != CLASS_SORCERER)
5024                     && (p_ptr->pclass != CLASS_RED_MAGE))
5025                 {
5026                         int e = s_ptr->sexp;
5027
5028                         /* The spell worked */
5029                         if (realm == p_ptr->realm1)
5030                         {
5031                                 p_ptr->spell_worked1 |= (1L << spell);
5032                         }
5033                         else
5034                         {
5035                                 p_ptr->spell_worked2 |= (1L << spell);
5036                         }
5037
5038                         /* Gain experience */
5039                         gain_exp(e * s_ptr->slevel);
5040
5041                         /* Redraw object recall */
5042                         p_ptr->window |= (PW_OBJECT);
5043
5044                         switch (realm)
5045                         {
5046                         case REALM_LIFE:
5047                                 chg_virtue(V_TEMPERANCE, 1);
5048                                 chg_virtue(V_COMPASSION, 1);
5049                                 chg_virtue(V_VITALITY, 1);
5050                                 chg_virtue(V_DILIGENCE, 1);
5051                                 break;
5052                         case REALM_DEATH:
5053                                 chg_virtue(V_UNLIFE, 1);
5054                                 chg_virtue(V_JUSTICE, -1);
5055                                 chg_virtue(V_FAITH, -1);
5056                                 chg_virtue(V_VITALITY, -1);
5057                                 break;
5058                         case REALM_DAEMON:
5059                                 chg_virtue(V_JUSTICE, -1);
5060                                 chg_virtue(V_FAITH, -1);
5061                                 chg_virtue(V_HONOUR, -1);
5062                                 chg_virtue(V_TEMPERANCE, -1);
5063                                 break;
5064                         case REALM_CRUSADE:
5065                                 chg_virtue(V_FAITH, 1);
5066                                 chg_virtue(V_JUSTICE, 1);
5067                                 chg_virtue(V_SACRIFICE, 1);
5068                                 chg_virtue(V_HONOUR, 1);
5069                                 break;
5070                         case REALM_NATURE:
5071                                 chg_virtue(V_NATURE, 1);
5072                                 chg_virtue(V_HARMONY, 1);
5073                                 break;
5074                         default:
5075                                 chg_virtue(V_KNOWLEDGE, 1);
5076                                 break;
5077                         }
5078                 }
5079                 switch (realm)
5080                 {
5081                 case REALM_LIFE:
5082                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, 1);
5083                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_COMPASSION, 1);
5084                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, 1);
5085                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_DILIGENCE, 1);
5086                         break;
5087                 case REALM_DEATH:
5088                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_UNLIFE, 1);
5089                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
5090                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
5091                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_VITALITY, -1);
5092                         break;
5093                 case REALM_DAEMON:
5094                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, -1);
5095                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, -1);
5096                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, -1);
5097                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_TEMPERANCE, -1);
5098                         break;
5099                 case REALM_CRUSADE:
5100                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_FAITH, 1);
5101                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_JUSTICE, 1);
5102                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_SACRIFICE, 1);
5103                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HONOUR, 1);
5104                         break;
5105                 case REALM_NATURE:
5106                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_NATURE, 1);
5107                         if (randint1(100 + p_ptr->lev) < need_mana) chg_virtue(V_HARMONY, 1);
5108                         break;
5109                 }
5110                 if (mp_ptr->spell_xtra & MAGIC_GAIN_EXP)
5111                 {
5112                         s16b cur_exp = p_ptr->spell_exp[(increment ? 32 : 0)+spell];
5113                         s16b exp_gain = 0;
5114
5115                         if (cur_exp < 900)
5116                                 exp_gain+=60;
5117                         else if(cur_exp < 1200)
5118                         {
5119                                 if ((dun_level > 4) && ((dun_level + 10) > p_ptr->lev))
5120                                         exp_gain = 8;
5121                         }
5122                         else if(cur_exp < 1400)
5123                         {
5124                                 if (((dun_level + 5) > p_ptr->lev) && ((dun_level + 5) > s_ptr->slevel))
5125                                         exp_gain = 2;
5126                         }
5127                         else if((cur_exp < 1600) && !increment)
5128                         {
5129                                 if (((dun_level + 5) > p_ptr->lev) && (dun_level > s_ptr->slevel))
5130                                         exp_gain = 1;
5131                         }
5132                         p_ptr->spell_exp[(increment ? 32 : 0)+spell] += exp_gain;
5133                 }
5134         }
5135
5136         /* Take a turn */
5137         energy_use = 100;
5138
5139         /* Sufficient mana */
5140         if (need_mana <= p_ptr->csp)
5141         {
5142                 /* Use some mana */
5143                 p_ptr->csp -= need_mana;
5144         }
5145
5146         /* Over-exert the player */
5147         else
5148         {
5149                 int oops = need_mana;
5150
5151                 /* No mana left */
5152                 p_ptr->csp = 0;
5153                 p_ptr->csp_frac = 0;
5154
5155                 /* Message */
5156 #ifdef JP
5157 msg_print("Àº¿À¤ò½¸Ã椷¤¹¤®¤Æµ¤¤ò¼º¤Ã¤Æ¤·¤Þ¤Ã¤¿¡ª");
5158 #else
5159                 msg_print("You faint from the effort!");
5160 #endif
5161
5162
5163                 /* Hack -- Bypass free action */
5164                 (void)set_paralyzed(p_ptr->paralyzed + randint1(5 * oops + 1));
5165
5166                 switch (realm)
5167                 {
5168                 case REALM_LIFE:
5169                         chg_virtue(V_VITALITY, -10);
5170                         break;
5171                 case REALM_DEATH:
5172                         chg_virtue(V_UNLIFE, -10);
5173                         break;
5174                 case REALM_DAEMON:
5175                         chg_virtue(V_JUSTICE, 10);
5176                         break;
5177                 case REALM_NATURE:
5178                         chg_virtue(V_NATURE, -10);
5179                         break;
5180                 case REALM_CRUSADE:
5181                         chg_virtue(V_JUSTICE, -10);
5182                         break;
5183                 default:
5184                         chg_virtue(V_KNOWLEDGE, -10);
5185                         break;
5186                 }
5187
5188                 /* Damage CON (possibly permanently) */
5189                 if (randint0(100) < 50)
5190                 {
5191                         bool perm = (randint0(100) < 25);
5192
5193                         /* Message */
5194 #ifdef JP
5195 msg_print("ÂΤò°­¤¯¤·¤Æ¤·¤Þ¤Ã¤¿¡ª");
5196 #else
5197                         msg_print("You have damaged your health!");
5198 #endif
5199
5200
5201                         /* Reduce constitution */
5202                         (void)dec_stat(A_CON, 15 + randint1(10), perm);
5203                 }
5204         }
5205
5206         /* Redraw mana */
5207         p_ptr->redraw |= (PR_MANA);
5208
5209         /* Window stuff */
5210         p_ptr->window |= (PW_PLAYER);
5211         p_ptr->window |= (PW_SPELL);
5212 }
5213
5214
5215 /*
5216  * Pray a prayer -- Unused in Hengband
5217  */
5218 void do_cmd_pray(void)
5219 {
5220         msg_print("Praying is not used in Hengband. Use magic spell casting instead.");
5221 }
5222
5223 static bool ang_sort_comp_pet_dismiss(vptr u, vptr v, int a, int b)
5224 {
5225         u16b *who = (u16b*)(u);
5226
5227         int w1 = who[a];
5228         int w2 = who[b];
5229
5230         monster_type *m_ptr1 = &m_list[w1];
5231         monster_type *m_ptr2 = &m_list[w2];
5232         monster_race *r_ptr1 = &r_info[m_ptr1->r_idx];
5233         monster_race *r_ptr2 = &r_info[m_ptr2->r_idx];
5234
5235         /* Unused */
5236         (void)v;
5237
5238         if (w1 == p_ptr->riding) return TRUE;
5239         if (w2 == p_ptr->riding) return FALSE;
5240
5241         if (m_ptr1->nickname && !m_ptr2->nickname) return TRUE;
5242         if (m_ptr2->nickname && !m_ptr1->nickname) return FALSE;
5243
5244         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return TRUE;
5245         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return FALSE;
5246
5247         if (r_ptr1->level > r_ptr2->level) return TRUE;
5248         if (r_ptr2->level > r_ptr1->level) return FALSE;
5249
5250         if (m_ptr1->hp > m_ptr2->hp) return TRUE;
5251         if (m_ptr2->hp > m_ptr1->hp) return FALSE;
5252         
5253         return w1 <= w2;
5254 }
5255
5256 int calculate_upkeep(void)
5257 {
5258         s32b old_friend_align = friend_align;
5259         int m_idx;
5260         bool have_a_unique = FALSE;
5261
5262         total_friends = 0;
5263         total_friend_levels = 0;
5264         friend_align = 0;
5265
5266         for (m_idx = m_max - 1; m_idx >=1; m_idx--)
5267         {
5268                 monster_type *m_ptr;
5269                 monster_race *r_ptr;
5270                 
5271                 m_ptr = &m_list[m_idx];
5272                 if (!m_ptr->r_idx) continue;
5273                 r_ptr = &r_info[m_ptr->r_idx];
5274
5275                 if (is_pet(m_ptr))
5276                 {
5277                         total_friends++;
5278                         if (r_ptr->flags1 & RF1_UNIQUE)
5279                         {
5280                                 if (p_ptr->pclass == CLASS_CAVALRY)
5281                                 {
5282                                         if (p_ptr->riding == m_idx)
5283                                                 total_friend_levels += (r_ptr->level+5)*2;
5284                                         else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
5285                                                 total_friend_levels += (r_ptr->level+5)*7/2;
5286                                         else
5287                                                 total_friend_levels += (r_ptr->level+5)*10;
5288                                         have_a_unique = TRUE;
5289                                 }
5290                                 else
5291                                         total_friend_levels += (r_ptr->level+5)*10;
5292                         }
5293                         else
5294                                 total_friend_levels += r_ptr->level;
5295                         
5296                         /* Determine pet alignment */
5297                         if (r_ptr->flags3 & RF3_GOOD)
5298                         {
5299                                 friend_align += r_ptr->level;
5300                         }
5301                         else if (r_ptr->flags3 & RF3_EVIL)
5302                         {
5303                                 friend_align -= r_ptr->level;
5304                         }
5305                 }
5306         }
5307         if (old_friend_align != friend_align) p_ptr->update |= (PU_BONUS);
5308         if (total_friends)
5309         {
5310                 int upkeep_factor;
5311                 upkeep_factor = (total_friend_levels - (p_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
5312                 if (upkeep_factor < 0) upkeep_factor = 0;
5313                 if (upkeep_factor > 1000) upkeep_factor = 1000;
5314                 return upkeep_factor;
5315         }
5316         else
5317                 return 0;
5318 }
5319
5320 void do_cmd_pet_dismiss(void)
5321 {
5322         monster_type    *m_ptr;
5323         bool            all_pets = FALSE;
5324         int pet_ctr, i;
5325         int Dismissed = 0;
5326
5327         u16b *who;
5328         u16b dummy_why;
5329         int max_pet = 0;
5330         int cu, cv;
5331
5332         cu = Term->scr->cu;
5333         cv = Term->scr->cv;
5334         Term->scr->cu = 0;
5335         Term->scr->cv = 1;
5336
5337         /* Allocate the "who" array */
5338         C_MAKE(who, max_m_idx, u16b);
5339
5340         /* Process the monsters (backwards) */
5341         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
5342         {
5343                 if (is_pet(&m_list[pet_ctr]))
5344                         who[max_pet++] = pet_ctr;
5345         }
5346
5347         /* Select the sort method */
5348         ang_sort_comp = ang_sort_comp_pet_dismiss;
5349         ang_sort_swap = ang_sort_swap_hook;
5350
5351         ang_sort(who, &dummy_why, max_pet);
5352
5353         /* Process the monsters (backwards) */
5354         for (i = 0; i < max_pet; i++)
5355         {
5356                 bool delete_this;
5357                 char friend_name[80];
5358                 char buf[80];
5359                 bool kakunin;
5360
5361                 /* Access the monster */
5362                 pet_ctr = who[i];
5363                 m_ptr = &m_list[pet_ctr];
5364
5365                 delete_this = FALSE;
5366                 kakunin = ((pet_ctr == p_ptr->riding) || (m_ptr->nickname));
5367                 monster_desc(friend_name, m_ptr, 0x80);
5368                 
5369                 if (!all_pets)
5370                 {
5371                         /* Hack -- health bar for this monster */
5372                         health_track(pet_ctr);
5373                         
5374                         /* Hack -- handle stuff */
5375                         handle_stuff();
5376                         
5377 #ifdef JP
5378                         sprintf(buf, "%s¤òÊü¤·¤Þ¤¹¤«¡© [Yes/No/Unnamed (%dɤ)]", friend_name, max_pet-i);
5379 #else
5380                         sprintf(buf, "Dismiss %s? [Yes/No/Unnamed (%d remain)]", friend_name, max_pet-i);
5381 #endif
5382                         prt(buf, 0, 0);
5383                         
5384                         if (m_ptr->ml)
5385                                 move_cursor_relative(m_ptr->fy, m_ptr->fx);
5386                         
5387                         while (TRUE)
5388                         {
5389                                 char ch = inkey();
5390
5391                                 if (ch == 'Y' || ch == 'y')
5392                                 {
5393                                         delete_this = TRUE;
5394                                         
5395                                         if (kakunin)
5396                                         {
5397 #ifdef JP
5398                                                 sprintf(buf, "ËÜÅö¤Ë¤è¤í¤·¤¤¤Ç¤¹¤«¡© (%s) ", friend_name);
5399 #else
5400                                                 sprintf(buf, "Are you sure? (%s) ", friend_name);
5401 #endif
5402                                                 if (!get_check(buf))
5403                                                         delete_this = FALSE;
5404                                         }
5405                                         break;
5406                                 }
5407                                 
5408                                 if (ch == 'U' || ch == 'u')
5409                                 {
5410                                         all_pets = TRUE;
5411                                         break;
5412                                 }
5413                                 
5414                                 if (ch == ESCAPE || ch == 'N' || ch == 'n')
5415                                         break;
5416                                 
5417                                 bell();
5418                         }
5419                 }
5420                 
5421                 if ((all_pets && !kakunin) || (!all_pets && delete_this))
5422                 {
5423                         if (record_named_pet && m_ptr->nickname)
5424                         {
5425                                 char m_name[80];
5426                                 
5427                                 monster_desc(m_name, m_ptr, 0x08);
5428                                 do_cmd_write_nikki(NIKKI_NAMED_PET, 2, m_name);
5429                         }
5430                         
5431                         if (pet_ctr == p_ptr->riding)
5432                         {
5433 #ifdef JP
5434                                 msg_format("%s¤«¤é¹ß¤ê¤¿¡£", friend_name);
5435 #else
5436                                 msg_format("You have got off %s. ", friend_name);
5437 #endif
5438                                 
5439                                 p_ptr->riding = 0;
5440                                 
5441                                 /* Update the monsters */
5442                                 p_ptr->update |= (PU_BONUS | PU_MONSTERS);
5443                                 p_ptr->redraw |= (PR_EXTRA);
5444                         }
5445
5446                         /* HACK : Add the line to message buffer */
5447 #ifdef JP
5448                         sprintf(buf, "%s ¤òÊü¤·¤¿¡£", friend_name);
5449 #else
5450                         sprintf(buf, "Dismissed %s.", friend_name);
5451 #endif
5452                         message_add(buf);
5453                         p_ptr->window |= (PW_MESSAGE);
5454                         window_stuff();
5455
5456                         delete_monster_idx(pet_ctr);
5457                         Dismissed++;
5458                 }
5459         }
5460         
5461         Term->scr->cu = cu;
5462         Term->scr->cv = cv;
5463         Term_fresh();
5464
5465         C_KILL(who, max_m_idx, u16b);
5466
5467 #ifdef JP
5468         msg_format("%d É¤¤Î¥Ú¥Ã¥È¤òÊü¤·¤Þ¤·¤¿¡£", Dismissed);
5469 #else
5470         msg_format("You have dismissed %d pet%s.", Dismissed,
5471                    (Dismissed == 1 ? "" : "s"));
5472 #endif
5473         if (Dismissed == 0 && all_pets)
5474 #ifdef JP
5475                 msg_print("'U'nnamed ¤Ï¡¢¾èÇϰʳ°¤Î̾Á°¤Î¤Ê¤¤¥Ú¥Ã¥È¤À¤±¤òÁ´¤Æ²òÊü¤·¤Þ¤¹¡£");
5476 #else
5477                 msg_print("'U'nnamed means all your pets except named pets and your mount.");
5478 #endif
5479
5480         p_ptr->update |= (PU_MON_LITE);
5481 }
5482
5483 bool rakuba(int dam, bool force)
5484 {
5485         int i, y, x, oy, ox;
5486         int sn = 0, sy = 0, sx = 0;
5487         char m_name[80];
5488         monster_type *m_ptr = &m_list[p_ptr->riding];
5489         monster_race *r_ptr = &r_info[m_ptr->r_idx];
5490
5491         if (!p_ptr->riding) return FALSE;
5492         if (p_ptr->wild_mode) return FALSE;
5493
5494         if (dam >= 0 || force)
5495         {
5496                 if (!force)
5497                 {
5498                         int level = r_ptr->level;
5499                         if (p_ptr->riding_ryoute) level += 20;
5500                         if ((dam/2 + r_ptr->level) > (p_ptr->skill_exp[GINOU_RIDING]/30+10))
5501                         {
5502                                 if((p_ptr->skill_exp[GINOU_RIDING] < s_info[p_ptr->pclass].s_max[GINOU_RIDING]) && s_info[p_ptr->pclass].s_max[GINOU_RIDING] > 1000)
5503                                 {
5504                                         if (r_ptr->level*100 > (p_ptr->skill_exp[GINOU_RIDING] + 1500))
5505                                                 p_ptr->skill_exp[GINOU_RIDING] += (1+(r_ptr->level - p_ptr->skill_exp[GINOU_RIDING]/100 - 15));
5506                                         else p_ptr->skill_exp[GINOU_RIDING]++;
5507                                 }
5508                         }
5509                         if (randint0(dam/2 + level*2) < (p_ptr->skill_exp[GINOU_RIDING]/30+10))
5510                         {
5511                                 if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3)+30))
5512                                 {
5513                                         return FALSE;
5514                                 }
5515                         }
5516                 }
5517                 /* Check around the player */
5518                 for (i = 0; i < 8; i++)
5519                 {
5520                         cave_type *c_ptr;
5521
5522                         /* Access the location */
5523                         y = py + ddy_ddd[i];
5524                         x = px + ddx_ddd[i];
5525
5526                         c_ptr = &cave[y][x];
5527
5528                         /* Skip non-empty grids */
5529                         if (cave_perma_grid(c_ptr)) continue;
5530                         if (!cave_empty_grid2(c_ptr)) continue;
5531
5532                         if (c_ptr->m_idx) continue;
5533
5534                         /* Count "safe" grids */
5535                         sn++;
5536
5537                         /* Randomize choice */
5538                         if (randint0(sn) > 0) continue;
5539
5540                         /* Save the safe location */
5541                         sy = y; sx = x;
5542                 }
5543                 if (!sn)
5544                 {
5545                         monster_desc(m_name, m_ptr, 0);
5546 #ifdef JP
5547 msg_format("%s¤«¤é¿¶¤êÍî¤È¤µ¤ì¤½¤¦¤Ë¤Ê¤Ã¤Æ¡¢Êɤˤ֤Ĥ«¤Ã¤¿¡£",m_name);
5548                         take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "Êɤؤξ×ÆÍ", -1);
5549 #else
5550                         msg_format("You have nearly fallen from %s, but bumped into wall.",m_name);
5551                         take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "bumping into wall", -1);
5552 #endif
5553                         return FALSE;
5554                 }
5555
5556                 oy = py;
5557                 ox = px;
5558
5559                 py = sy;
5560                 px = sx;
5561
5562                 /* Redraw the old spot */
5563                 lite_spot(oy, ox);
5564
5565                 /* Redraw the new spot */
5566                 lite_spot(py, px);
5567
5568                 /* Check for new panel */
5569                 verify_panel();
5570         }
5571
5572         p_ptr->riding = 0;
5573         p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
5574         p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
5575
5576         calc_bonuses();
5577
5578         p_ptr->update |= (PU_BONUS);
5579
5580         /* Update stuff */
5581         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
5582
5583         /* Update the monsters */
5584         p_ptr->update |= (PU_DISTANCE);
5585
5586         /* Window stuff */
5587         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5588
5589         p_ptr->redraw |= (PR_EXTRA);
5590
5591         /* Update health track of mount */
5592         p_ptr->redraw |= (PR_UHEALTH);
5593
5594         if (p_ptr->ffall && !force)
5595         {
5596                 monster_desc(m_name, m_ptr, 0);
5597 #ifdef JP
5598 msg_format("%s¤«¤éÍî¤Á¤¿¤¬¡¢¶õÃæ¤Ç¤¦¤Þ¤¯ÂÎÀª¤òΩ¤Æľ¤·¤ÆÃåÃϤ·¤¿¡£",m_name);
5599 #else
5600                 msg_format("You are thrown from %s, but make a good landing.",m_name);
5601 #endif
5602                 return FALSE;
5603         }
5604 #ifdef JP
5605         take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "ÍîÇÏ", -1);
5606 #else
5607         take_hit(DAMAGE_NOESCAPE, r_ptr->level+3, "Falling from riding", -1);
5608 #endif
5609
5610         return TRUE;
5611 }
5612
5613 bool do_riding(bool force)
5614 {
5615         int oy, ox, x, y, dir = 0;
5616         cave_type *c_ptr;
5617         monster_type *m_ptr;
5618
5619         if (!get_rep_dir2(&dir)) return FALSE;
5620         y = py + ddy[dir];
5621         x = px + ddx[dir];
5622         c_ptr = &cave[y][x];
5623
5624         if (p_ptr->riding)
5625         {
5626                 /* Skip non-empty grids */
5627                 if (!cave_empty_bold2(y, x) || c_ptr->m_idx)
5628                 {
5629 #ifdef JP
5630 msg_print("¤½¤Á¤é¤Ë¤Ï¹ß¤ê¤é¤ì¤Þ¤»¤ó¡£");
5631 #else
5632                         msg_print("You cannot go to that direction.");
5633 #endif
5634                         return FALSE;
5635                 }
5636                 p_ptr->riding = 0;
5637                 p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
5638                 p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
5639         }
5640         else
5641         {
5642                 if (p_ptr->confused)
5643                 {
5644 #ifdef JP
5645 msg_print("º®Í𤷤Ƥ¤¤Æ¾è¤ì¤Ê¤¤¡ª");
5646 #else
5647                         msg_print("You are too confused!");
5648 #endif
5649                         return FALSE;
5650                 }
5651                 if (!(c_ptr->m_idx))
5652                 {
5653 #ifdef JP
5654 msg_print("¤½¤Î¾ì½ê¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
5655 #else
5656                         msg_print("Here is no pet.");
5657 #endif
5658
5659                         return FALSE;
5660                 }
5661
5662                 m_ptr = &m_list[c_ptr->m_idx];
5663
5664                 if (!is_pet(m_ptr) && !force)
5665                 {
5666 #ifdef JP
5667 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï¥Ú¥Ã¥È¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£");
5668 #else
5669                         msg_print("That monster is not a pet.");
5670 #endif
5671
5672                         return FALSE;
5673                 }
5674                 if (!(r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
5675                 {
5676 #ifdef JP
5677 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ë¤Ï¾è¤ì¤Ê¤µ¤½¤¦¤À¡£");
5678 #else
5679                         msg_print("This monster doesn't seem suitable for riding.");
5680 #endif
5681
5682                         return FALSE;
5683                 }
5684                 if (!(p_ptr->pass_wall) && (c_ptr->feat >= FEAT_RUBBLE) && (c_ptr->feat <= FEAT_PERM_SOLID))
5685                 {
5686 #ifdef JP
5687 msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤ÏÊɤÎÃæ¤Ë¤¤¤ë¡£");
5688 #else
5689                         msg_print("This monster is in the wall.");
5690 #endif
5691
5692                         return FALSE;
5693                 }
5694                 if ((cave[py][px].feat >= FEAT_PATTERN_START) && (cave[py][px].feat <= FEAT_PATTERN_XTRA2) && ((cave[y][x].feat < FEAT_PATTERN_START) || (cave[y][x].feat > FEAT_PATTERN_XTRA2)))
5695                 {
5696 #ifdef JP
5697 msg_print("¥Ñ¥¿¡¼¥ó¤Î¾å¤«¤é¤Ï¾è¤ì¤Þ¤»¤ó¡£");
5698 #else
5699                         msg_print("You cannot ride from on Pattern.");
5700 #endif
5701
5702                         return FALSE;
5703                 }
5704                 if (!m_ptr->ml)
5705                 {
5706 #ifdef JP
5707 msg_print("¤½¤Î¾ì½ê¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
5708 #else
5709                         msg_print("Here is no monster.");
5710 #endif
5711
5712                         return FALSE;
5713                 }
5714                 if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING]/50 + p_ptr->lev/2 +20)))
5715                 {
5716 #ifdef JP
5717 msg_print("¤¦¤Þ¤¯¾è¤ì¤Ê¤«¤Ã¤¿¡£");
5718 #else
5719                         msg_print("You failed to ride.");
5720 #endif
5721
5722                         energy_use = 100;
5723
5724                         return FALSE;
5725                 }
5726                 if (m_ptr->csleep)
5727                 {
5728                         char m_name[80];
5729                         monster_desc(m_name, m_ptr, 0);
5730                         m_ptr->csleep = 0;
5731 #ifdef JP
5732 msg_format("%s¤òµ¯¤³¤·¤¿¡£", m_name);
5733 #else
5734                         msg_format("You have waked %s up.", m_name);
5735 #endif
5736                 }
5737
5738                 p_ptr->riding = c_ptr->m_idx;
5739
5740                 /* Hack -- remove tracked monster */
5741                 if (p_ptr->riding == p_ptr->health_who) health_track(0);
5742         }
5743
5744         /* Save the old location */
5745         oy = py;
5746         ox = px;
5747
5748         /* Move the player to the safe location */
5749         py = y;
5750         px = x;
5751
5752         /* Redraw the old spot */
5753         lite_spot(oy, ox);
5754
5755         /* Redraw the new spot */
5756         lite_spot(py, px);
5757
5758         /* Check for new panel */
5759         verify_panel();
5760
5761         energy_use = 100;
5762
5763         /* Mega-Hack -- Forget the view and lite */
5764         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
5765
5766         /* Update stuff */
5767         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
5768
5769         /* Update the monsters */
5770         p_ptr->update |= (PU_DISTANCE);
5771
5772         /* Update the monsters */
5773         p_ptr->update |= (PU_BONUS);
5774
5775         /* Redraw map */
5776         p_ptr->redraw |= (PR_MAP | PR_EXTRA);
5777
5778         /* Window stuff */
5779         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
5780
5781         p_ptr->redraw |= (PR_UHEALTH);
5782
5783         handle_stuff();
5784         return TRUE;
5785 }
5786
5787 static void do_name_pet(void)
5788 {
5789         monster_type *m_ptr;
5790         char out_val[20];
5791         char m_name[80];
5792         bool old_name = FALSE;
5793         bool old_target_pet = target_pet;
5794
5795         target_pet = TRUE;
5796         if (!target_set(TARGET_KILL))
5797         {
5798                 target_pet = old_target_pet;
5799                 return;
5800         }
5801         target_pet = old_target_pet;
5802
5803         if (cave[target_row][target_col].m_idx)
5804         {
5805                 m_ptr = &m_list[cave[target_row][target_col].m_idx];
5806
5807                 if (!is_pet(m_ptr))
5808                 {
5809                         /* Message */
5810 #ifdef JP
5811                         msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Ï¥Ú¥Ã¥È¤Ç¤Ï¤Ê¤¤¡£");
5812 #else
5813                         msg_format("This monster is not a pet.");
5814 #endif
5815                         return;
5816                 }
5817                 if (r_info[m_ptr->r_idx].flags1 & RF1_UNIQUE)
5818                 {
5819 #ifdef JP
5820                         msg_print("¤½¤Î¥â¥ó¥¹¥¿¡¼¤Î̾Á°¤ÏÊѤ¨¤é¤ì¤Ê¤¤¡ª");
5821 #else
5822                         msg_format("You cannot change name of this monster!");
5823 #endif
5824                         return;
5825                 }
5826                 monster_desc(m_name, m_ptr, 0);
5827
5828                 /* Message */
5829 #ifdef JP
5830                 msg_format("%s¤Ë̾Á°¤ò¤Ä¤±¤ë¡£", m_name);
5831 #else
5832                 msg_format("Name %s.", m_name);
5833 #endif
5834
5835                 msg_print(NULL);
5836
5837                 /* Start with nothing */
5838                 strcpy(out_val, "");
5839
5840                 /* Use old inscription */
5841                 if (m_ptr->nickname)
5842                 {
5843                         /* Start with the old inscription */
5844                         strcpy(out_val, quark_str(m_ptr->nickname));
5845                         old_name = TRUE;
5846                 }
5847
5848                 /* Get a new inscription (possibly empty) */
5849 #ifdef JP
5850                 if (get_string("̾Á°: ", out_val, 15))
5851 #else
5852                 if (get_string("Name: ", out_val, 15))
5853 #endif
5854
5855                 {
5856                         if (out_val[0])
5857                         {
5858                                 /* Save the inscription */
5859                                 m_ptr->nickname = quark_add(out_val);
5860                                 if (record_named_pet)
5861                                 {
5862                                         char m_name[80];
5863
5864                                         monster_desc(m_name, m_ptr, 0x08);
5865                                         do_cmd_write_nikki(NIKKI_NAMED_PET, 0, m_name);
5866                                 }
5867                         }
5868                         else
5869                         {
5870                                 if (record_named_pet && old_name)
5871                                 {
5872                                         char m_name[80];
5873
5874                                         monster_desc(m_name, m_ptr, 0x08);
5875                                         do_cmd_write_nikki(NIKKI_NAMED_PET, 1, m_name);
5876                                 }
5877                                 m_ptr->nickname = 0;
5878                         }
5879                 }
5880         }
5881 }
5882
5883 /*
5884  * Issue a pet command
5885  */
5886 void do_cmd_pet(void)
5887 {
5888         int                     i = 0;
5889         int                     num;
5890         int                     powers[36];
5891         cptr                    power_desc[36];
5892         bool                    flag, redraw;
5893         int                     ask;
5894         char                    choice;
5895         char                    out_val[160];
5896         int                     pets = 0, pet_ctr;
5897         monster_type    *m_ptr;
5898
5899         int mode = 0;
5900
5901         byte y = 1, x = 0;
5902         int ctr = 0;
5903         char buf[160];
5904         char target_buf[160];
5905
5906         num = 0;
5907
5908         /* Calculate pets */
5909         /* Process the monsters (backwards) */
5910         for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
5911         {
5912                 /* Access the monster */
5913                 m_ptr = &m_list[pet_ctr];
5914
5915                 if (is_pet(m_ptr)) pets++;
5916         }
5917
5918 #ifdef JP
5919         power_desc[num] = "¥Ú¥Ã¥È¤òÊü¤¹";
5920 #else
5921         power_desc[num] = "dismiss pets";
5922 #endif
5923
5924         powers[num++] = PET_DISMISS;
5925
5926 #ifdef JP
5927         sprintf(target_buf,"¥Ú¥Ã¥È¤Î¥¿¡¼¥²¥Ã¥È¤ò»ØÄê (¸½ºß¡§%s)",
5928                 (pet_t_m_idx ? r_name + r_info[m_list[pet_t_m_idx].r_idx].name : "»ØÄê¤Ê¤·"));
5929 #else
5930         sprintf(target_buf,"specify a targert of pet (now:%s)",
5931                 (pet_t_m_idx ? r_name + r_info[m_list[pet_t_m_idx].r_idx].name : "nothing"));
5932 #endif
5933         power_desc[num] = target_buf;
5934
5935         powers[num++] = PET_TARGET;
5936
5937 #ifdef JP
5938 power_desc[num] = "¶á¤¯¤Ë¤¤¤í";
5939 #else
5940         power_desc[num] = "stay close";
5941 #endif
5942
5943         if (p_ptr->pet_follow_distance == PET_CLOSE_DIST) mode = num;
5944         powers[num++] = PET_STAY_CLOSE;
5945
5946 #ifdef JP
5947         power_desc[num] = "¤Ä¤¤¤ÆÍ褤";
5948 #else
5949         power_desc[num] = "follow me";
5950 #endif
5951
5952         if (p_ptr->pet_follow_distance == PET_FOLLOW_DIST) mode = num;
5953         powers[num++] = PET_FOLLOW_ME;
5954
5955 #ifdef JP
5956 power_desc[num] = "Ũ¤ò¸«¤Ä¤±¤ÆÅݤ»";
5957 #else
5958         power_desc[num] = "seek and destroy";
5959 #endif
5960
5961         if (p_ptr->pet_follow_distance == PET_DESTROY_DIST) mode = num;
5962         powers[num++] = PET_SEEK_AND_DESTROY;
5963
5964 #ifdef JP
5965 power_desc[num] = "¾¯¤·Î¥¤ì¤Æ¤¤¤í";
5966 #else
5967         power_desc[num] = "give me space";
5968 #endif
5969
5970         if (p_ptr->pet_follow_distance == PET_SPACE_DIST) mode = num;
5971         powers[num++] = PET_ALLOW_SPACE;
5972
5973 #ifdef JP
5974 power_desc[num] = "Î¥¤ì¤Æ¤¤¤í";
5975 #else
5976         power_desc[num] = "stay away";
5977 #endif
5978
5979         if (p_ptr->pet_follow_distance == PET_AWAY_DIST) mode = num;
5980         powers[num++] = PET_STAY_AWAY;
5981
5982         if (p_ptr->pet_extra_flags & PF_OPEN_DOORS)
5983         {
5984 #ifdef JP
5985                 power_desc[num] = "¥É¥¢¤ò³«¤±¤ë (¸½ºß:ON)";
5986 #else
5987                 power_desc[num] = "pets open doors (now On)";
5988 #endif
5989
5990         }
5991         else
5992         {
5993 #ifdef JP
5994                 power_desc[num] = "¥É¥¢¤ò³«¤±¤ë (¸½ºß:OFF)";
5995 #else
5996                 power_desc[num] = "pets open doors (now Off)";
5997 #endif
5998
5999         }
6000         powers[num++] = PET_OPEN_DOORS;
6001
6002         if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
6003         {
6004 #ifdef JP
6005                 power_desc[num] = "¥¢¥¤¥Æ¥à¤ò½¦¤¦ (¸½ºß:ON)";
6006 #else
6007                 power_desc[num] = "pets pick up items (now On)";
6008 #endif
6009
6010         }
6011         else
6012         {
6013 #ifdef JP
6014                 power_desc[num] = "¥¢¥¤¥Æ¥à¤ò½¦¤¦ (¸½ºß:OFF)";
6015 #else
6016                 power_desc[num] = "pets pick up items (now Off)";
6017 #endif
6018
6019         }
6020         powers[num++] = PET_TAKE_ITEMS;
6021
6022         if (p_ptr->pet_extra_flags & PF_TELEPORT)
6023         {
6024 #ifdef JP
6025                 power_desc[num] = "¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦ (¸½ºß:ON)";
6026 #else
6027                 power_desc[num] = "allow teleport (now On)";
6028 #endif
6029
6030         }
6031         else
6032         {
6033 #ifdef JP
6034                 power_desc[num] = "¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
6035 #else
6036                 power_desc[num] = "allow teleport (now Off)";
6037 #endif
6038
6039         }
6040         powers[num++] = PET_TELEPORT;
6041
6042         if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL)
6043         {
6044 #ifdef JP
6045                 power_desc[num] = "¹¶·âËâË¡¤ò»È¤¦ (¸½ºß:ON)";
6046 #else
6047                 power_desc[num] = "allow cast attack spell (now On)";
6048 #endif
6049
6050         }
6051         else
6052         {
6053 #ifdef JP
6054                 power_desc[num] = "¹¶·âËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
6055 #else
6056                 power_desc[num] = "allow cast attack spell (now Off)";
6057 #endif
6058
6059         }
6060         powers[num++] = PET_ATTACK_SPELL;
6061
6062         if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL)
6063         {
6064 #ifdef JP
6065                 power_desc[num] = "¾¤´­ËâË¡¤ò»È¤¦ (¸½ºß:ON)";
6066 #else
6067                 power_desc[num] = "allow cast summon spell (now On)";
6068 #endif
6069
6070         }
6071         else
6072         {
6073 #ifdef JP
6074                 power_desc[num] = "¾¤´­ËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
6075 #else
6076                 power_desc[num] = "allow cast summon spell (now Off)";
6077 #endif
6078
6079         }
6080         powers[num++] = PET_SUMMON_SPELL;
6081
6082         if (p_ptr->pet_extra_flags & PF_BALL_SPELL)
6083         {
6084 #ifdef JP
6085                 power_desc[num] = "¥×¥ì¥¤¥ä¡¼¤ò´¬¤­¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦ (¸½ºß:ON)";
6086 #else
6087                 power_desc[num] = "allow involve player in area spell (now On)";
6088 #endif
6089
6090         }
6091         else
6092         {
6093 #ifdef JP
6094                 power_desc[num] = "¥×¥ì¥¤¥ä¡¼¤ò´¬¤­¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦ (¸½ºß:OFF)";
6095 #else
6096                 power_desc[num] = "allow involve player in area spell (now Off)";
6097 #endif
6098
6099         }
6100         powers[num++] = PET_BALL_SPELL;
6101
6102         if (p_ptr->riding)
6103         {
6104 #ifdef JP
6105                 power_desc[num] = "¥Ú¥Ã¥È¤«¤é¹ß¤ê¤ë";
6106 #else
6107                 power_desc[num] = "get off a pet";
6108 #endif
6109
6110         }
6111         else
6112         {
6113 #ifdef JP
6114                 power_desc[num] = "¥Ú¥Ã¥È¤Ë¾è¤ë";
6115 #else
6116                 power_desc[num] = "ride a pet";
6117 #endif
6118
6119         }
6120         powers[num++] = PET_RIDING;
6121
6122 #ifdef JP
6123         power_desc[num] = "¥Ú¥Ã¥È¤Ë̾Á°¤ò¤Ä¤±¤ë¡£";
6124 #else
6125         power_desc[num] = "name pets";
6126 #endif
6127
6128         powers[num++] = PET_NAME;
6129
6130         if (p_ptr->riding && buki_motteruka(INVEN_RARM) && (empty_hands(FALSE) & 0x00000001) && ((inventory[INVEN_RARM].weight > 99) || (inventory[INVEN_RARM].tval == TV_POLEARM)))
6131         {
6132                 if (p_ptr->pet_extra_flags & PF_RYOUTE)
6133                 {
6134 #ifdef JP
6135                         power_desc[num] = "Éð´ï¤òÊÒ¼ê¤Ç»ý¤Ä";
6136 #else
6137                         power_desc[num] = "use one hand to control a riding pet";
6138 #endif
6139
6140                 }
6141                 else
6142                 {
6143 #ifdef JP
6144                         power_desc[num] = "Éð´ï¤òξ¼ê¤Ç»ý¤Ä";
6145 #else
6146                         power_desc[num] = "use both hands for a weapon.";
6147 #endif
6148
6149                 }
6150
6151                 powers[num++] = PET_RYOUTE;
6152         }
6153
6154         /* Nothing chosen yet */
6155         flag = FALSE;
6156
6157         /* Build a prompt (accept all spells) */
6158         if (num <= 26)
6159         {
6160                 /* Build a prompt (accept all spells) */
6161 #ifdef JP
6162 strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
6163 #else
6164                 strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
6165 #endif
6166
6167                         I2A(0), I2A(num - 1));
6168         }
6169         else
6170         {
6171 #ifdef JP
6172 strnfmt(out_val, 78, "(¥³¥Þ¥ó¥É %c-%c¡¢'*'=°ìÍ÷¡¢ESC=½ªÎ») ¥³¥Þ¥ó¥É¤òÁª¤ó¤Ç¤¯¤À¤µ¤¤:",
6173 #else
6174                 strnfmt(out_val, 78, "(Command %c-%c, *=List, ESC=exit) Select a command: ",
6175 #endif
6176
6177                         I2A(0), '0' + num - 27);
6178         }
6179
6180         /* Show list */
6181         redraw = TRUE;
6182
6183         /* Save the screen */
6184         Term_save();
6185
6186         prt("", y++, x);
6187
6188         while (ctr < num)
6189         {
6190                 prt(format("%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]), y + ctr, x);
6191                 ctr++;
6192         }
6193
6194         if (ctr < 17)
6195         {
6196                 prt("", y + ctr, x);
6197         }
6198         else
6199         {
6200                 prt("", y + 17, x);
6201         }
6202
6203         /* Get a command from the user */
6204         while (!flag && get_com(out_val, &choice, TRUE))
6205         {
6206                 /* Request redraw */
6207                 if ((choice == ' ') || (choice == '*') || (choice == '?'))
6208                 {
6209                         /* Show the list */
6210                         if (!redraw)
6211                         {
6212                                 y = 1;
6213                                 x = 0;
6214                                 ctr = 0;
6215
6216                                 /* Show list */
6217                                 redraw = TRUE;
6218
6219                                 /* Save the screen */
6220                                 Term_save();
6221
6222                                 prt("", y++, x);
6223
6224                                 while (ctr < num)
6225                                 {
6226                                         sprintf(buf, "%s%c) %s", (ctr == mode) ? "*" : " ", I2A(ctr), power_desc[ctr]);
6227                                         prt(buf, y + ctr, x);
6228                                         ctr++;
6229                                 }
6230
6231                                 if (ctr < 17)
6232                                 {
6233                                         prt("", y + ctr, x);
6234                                 }
6235                                 else
6236                                 {
6237                                         prt("", y + 17, x);
6238                                 }
6239                         }
6240
6241                         /* Hide the list */
6242                         else
6243                         {
6244                                 /* Hide list */
6245                                 redraw = FALSE;
6246
6247                                 /* Restore the screen */
6248                                 Term_load();
6249                         }
6250
6251                         /* Redo asking */
6252                         continue;
6253                 }
6254
6255                 if (isalpha(choice))
6256                 {
6257                         /* Note verify */
6258                         ask = (isupper(choice));
6259
6260                         /* Lowercase */
6261                         if (ask) choice = tolower(choice);
6262
6263                         /* Extract request */
6264                         i = (islower(choice) ? A2I(choice) : -1);
6265                 }
6266                 else
6267                 {
6268                         ask = FALSE; /* Can't uppercase digits */
6269
6270                         i = choice - '0' + 26;
6271                 }
6272
6273                 /* Totally Illegal */
6274                 if ((i < 0) || (i >= num))
6275                 {
6276                         bell();
6277                         continue;
6278                 }
6279
6280                 /* Verify it */
6281                 if (ask)
6282                 {
6283                         /* Prompt */
6284 #ifdef JP
6285                         strnfmt(buf, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡© ", power_desc[i]);
6286 #else
6287                         strnfmt(buf, 78, "Use %s? ", power_desc[i]);
6288 #endif
6289
6290
6291                         /* Belay that order */
6292                         if (!get_check(buf)) continue;
6293                 }
6294
6295                 /* Stop the loop */
6296                 flag = TRUE;
6297         }
6298
6299         /* Restore the screen */
6300         if (redraw) Term_load();
6301
6302         /* Abort if needed */
6303         if (!flag)
6304         {
6305                 energy_use = 0;
6306                 return;
6307         }
6308
6309         switch (powers[i])
6310         {
6311                 case PET_DISMISS: /* Dismiss pets */
6312                 {
6313                         if (!pets)
6314                         {
6315 #ifdef JP
6316                                 msg_print("¥Ú¥Ã¥È¤¬¤¤¤Ê¤¤¡ª");
6317 #else
6318                                 msg_print("You have no pets!");
6319 #endif
6320                                 break;
6321                         }
6322                         do_cmd_pet_dismiss();
6323                         (void)calculate_upkeep();
6324                         break;
6325                 }
6326                 case PET_TARGET:
6327                 {
6328                         project_length = -1;
6329                         if (!target_set(TARGET_KILL)) pet_t_m_idx = 0;
6330                         else
6331                         {
6332                                 cave_type *c_ptr = &cave[target_row][target_col];
6333                                 if (c_ptr->m_idx && (m_list[c_ptr->m_idx].ml))
6334                                 {
6335                                         pet_t_m_idx = cave[target_row][target_col].m_idx;
6336                                         p_ptr->pet_follow_distance = PET_DESTROY_DIST;
6337                                 }
6338                                 else pet_t_m_idx = 0;
6339                         }
6340                         project_length = 0;
6341
6342                         break;
6343                 }
6344                 /* Call pets */
6345                 case PET_STAY_CLOSE:
6346                 {
6347                         p_ptr->pet_follow_distance = PET_CLOSE_DIST;
6348                         pet_t_m_idx = 0;
6349                         break;
6350                 }
6351                 /* "Follow Me" */
6352                 case PET_FOLLOW_ME:
6353                 {
6354                         p_ptr->pet_follow_distance = PET_FOLLOW_DIST;
6355                         pet_t_m_idx = 0;
6356                         break;
6357                 }
6358                 /* "Seek and destoy" */
6359                 case PET_SEEK_AND_DESTROY:
6360                 {
6361                         p_ptr->pet_follow_distance = PET_DESTROY_DIST;
6362                         break;
6363                 }
6364                 /* "Give me space" */
6365                 case PET_ALLOW_SPACE:
6366                 {
6367                         p_ptr->pet_follow_distance = PET_SPACE_DIST;
6368                         break;
6369                 }
6370                 /* "Stay away" */
6371                 case PET_STAY_AWAY:
6372                 {
6373                         p_ptr->pet_follow_distance = PET_AWAY_DIST;
6374                         break;
6375                 }
6376                 /* flag - allow pets to open doors */
6377                 case PET_OPEN_DOORS:
6378                 {
6379                         if (p_ptr->pet_extra_flags & PF_OPEN_DOORS) p_ptr->pet_extra_flags &= ~(PF_OPEN_DOORS);
6380                         else p_ptr->pet_extra_flags |= (PF_OPEN_DOORS);
6381                         break;
6382                 }
6383                 /* flag - allow pets to pickup items */
6384                 case PET_TAKE_ITEMS:
6385                 {
6386                         if (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
6387                         {
6388                                 p_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
6389                                 for (pet_ctr = m_max - 1; pet_ctr >= 1; pet_ctr--)
6390                                 {
6391                                         /* Access the monster */
6392                                         m_ptr = &m_list[pet_ctr];
6393
6394                                         if (is_pet(m_ptr))
6395                                         {
6396                                                 monster_drop_carried_objects(m_ptr);
6397                                         }
6398                                 }
6399                         }
6400                         else p_ptr->pet_extra_flags |= (PF_PICKUP_ITEMS);
6401
6402                         break;
6403                 }
6404                 /* flag - allow pets to teleport */
6405                 case PET_TELEPORT:
6406                 {
6407                         if (p_ptr->pet_extra_flags & PF_TELEPORT) p_ptr->pet_extra_flags &= ~(PF_TELEPORT);
6408                         else p_ptr->pet_extra_flags |= (PF_TELEPORT);
6409                         break;
6410                 }
6411                 /* flag - allow pets to cast attack spell */
6412                 case PET_ATTACK_SPELL:
6413                 {
6414                         if (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) p_ptr->pet_extra_flags &= ~(PF_ATTACK_SPELL);
6415                         else p_ptr->pet_extra_flags |= (PF_ATTACK_SPELL);
6416                         break;
6417                 }
6418                 /* flag - allow pets to cast attack spell */
6419                 case PET_SUMMON_SPELL:
6420                 {
6421                         if (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) p_ptr->pet_extra_flags &= ~(PF_SUMMON_SPELL);
6422                         else p_ptr->pet_extra_flags |= (PF_SUMMON_SPELL);
6423                         break;
6424                 }
6425                 /* flag - allow pets to cast attack spell */
6426                 case PET_BALL_SPELL:
6427                 {
6428                         if (p_ptr->pet_extra_flags & PF_BALL_SPELL) p_ptr->pet_extra_flags &= ~(PF_BALL_SPELL);
6429                         else p_ptr->pet_extra_flags |= (PF_BALL_SPELL);
6430                         break;
6431                 }
6432
6433                 case PET_RIDING:
6434                 {
6435                         do_riding(FALSE);
6436                         break;
6437                 }
6438
6439                 case PET_NAME:
6440                 {
6441                         do_name_pet();
6442                         break;
6443                 }
6444
6445                 case PET_RYOUTE:
6446                 {
6447                         if (p_ptr->pet_extra_flags & PF_RYOUTE) p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
6448                         else p_ptr->pet_extra_flags |= (PF_RYOUTE);
6449                         p_ptr->update |= (PU_BONUS);
6450                         handle_stuff();
6451                         break;
6452                 }
6453         }
6454 }