OSDN Git Service

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