OSDN Git Service

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