OSDN Git Service

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