OSDN Git Service

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