OSDN Git Service

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