OSDN Git Service

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