OSDN Git Service

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