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