OSDN Git Service

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