OSDN Git Service

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