OSDN Git Service

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