OSDN Git Service

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