OSDN Git Service

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