OSDN Git Service

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