OSDN Git Service

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