OSDN Git Service

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