OSDN Git Service

鑑定のロッドの使用後に自動破棄があったときのバグ修正。
[hengband/hengband.git] / src / hissatsu.c
1 /* File: mind.c */
2
3 /* Purpose: Mindcrafter code */
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 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
16
17 /*
18  * Allow user to choose a mindcrafter power.
19  *
20  * If a valid spell is chosen, saves it in '*sn' and returns TRUE
21  * If the user hits escape, returns FALSE, and set '*sn' to -1
22  * If there are no legal choices, returns FALSE, and sets '*sn' to -2
23  *
24  * The "prompt" should be "cast", "recite", or "study"
25  * The "known" should be TRUE for cast/pray, FALSE for study
26  *
27  * nb: This function has a (trivial) display bug which will be obvious
28  * when you run it. It's probably easy to fix but I haven't tried,
29  * sorry.
30  */
31 static int get_hissatsu_power(int *sn)
32 {
33         int             i, j = 0;
34         int             num = 0;
35         int             y = 1;
36         int             x = 15;
37         int             plev = p_ptr->lev;
38         int             ask = TRUE;
39         char            choice;
40         char            out_val[160];
41         char sentaku[32];
42 #ifdef JP
43 cptr            p = "ɬ»¦·õ";
44 #else
45         cptr            p = "special attack";
46 #endif
47
48         magic_type spell;
49         bool            flag, redraw;
50         int menu_line = (use_menu ? 1 : 0);
51
52         /* Assume cancelled */
53         *sn = (-1);
54
55 #ifdef ALLOW_REPEAT /* TNB */
56
57         /* Get the spell, if available */
58         if (repeat_pull(sn))
59         {
60                 /* Verify the spell */
61                 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
62                 {
63                         /* Success */
64                         return (TRUE);
65                 }
66         }
67
68 #endif /* ALLOW_REPEAT -- TNB */
69
70         /* Nothing chosen yet */
71         flag = FALSE;
72
73         /* No redraw yet */
74         redraw = FALSE;
75
76         for (i = 0; i < 32; i++)
77         {
78                 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
79                 {
80                         sentaku[num] = i;
81                         num++;
82                 }
83         }
84
85         /* Build a prompt (accept all spells) */
86 #ifdef JP
87 (void) strnfmt(out_val, 78, "(%^s %c-%c, '*'¤Ç°ìÍ÷, ESC) ¤É¤Î%s¤ò»È¤¤¤Þ¤¹¤«¡©",
88 #else
89         (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ",
90 #endif
91         p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num-1], p);
92
93         if (use_menu) screen_save();
94
95         /* Get a spell from the user */
96
97         choice= always_show_list ? ESCAPE:1 ;
98         while (!flag)
99         {
100                 if(choice==ESCAPE) choice = ' '; 
101                 else if( !get_com(out_val, &choice, FALSE) )break;
102
103                 if (use_menu && choice != ' ')
104                 {
105                         switch(choice)
106                         {
107                                 case '0':
108                                 {
109                                         screen_load();
110                                         return (FALSE);
111                                         break;
112                                 }
113
114                                 case '8':
115                                 case 'k':
116                                 case 'K':
117                                 {
118                                         do
119                                         {
120                                                 menu_line += 31;
121                                                 if (menu_line > 32) menu_line -= 32;
122                                         } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
123                                         break;
124                                 }
125
126                                 case '2':
127                                 case 'j':
128                                 case 'J':
129                                 {
130                                         do
131                                         {
132                                                 menu_line++;
133                                                 if (menu_line > 32) menu_line -= 32;
134                                         } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
135                                         break;
136                                 }
137
138                                 case '4':
139                                 case 'h':
140                                 case 'H':
141                                 case '6':
142                                 case 'l':
143                                 case 'L':
144                                 {
145                                         bool reverse = FALSE;
146                                         if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
147                                         if (menu_line > 16)
148                                         {
149                                                 menu_line -= 16;
150                                                 reverse = TRUE;
151                                         }
152                                         else menu_line+=16;
153                                         while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
154                                         {
155                                                 if (reverse)
156                                                 {
157                                                         menu_line--;
158                                                         if (menu_line < 2) reverse = FALSE;
159                                                 }
160                                                 else
161                                                 {
162                                                         menu_line++;
163                                                         if (menu_line > 31) reverse = TRUE;
164                                                 }
165                                         }
166                                         break;
167                                 }
168
169                                 case 'x':
170                                 case 'X':
171                                 case '\r':
172                                 case '\n':
173                                 {
174                                         i = menu_line - 1;
175                                         ask = FALSE;
176                                         break;
177                                 }
178                         }
179                 }
180                 /* Request redraw */
181                 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
182                 {
183                         /* Show the list */
184                         if (!redraw || use_menu)
185                         {
186                                 char psi_desc[80];
187                                 int line;
188
189                                 /* Show list */
190                                 redraw = TRUE;
191
192                                 /* Save the screen */
193                                 if (!use_menu) screen_save();
194
195                                 /* Display a list of spells */
196                                 prt("", y, x);
197 #ifdef JP
198 put_str("̾Á°              Lv  MP      Ì¾Á°              Lv  MP ", y, x + 5);
199 #else
200 put_str("name              Lv  SP      name              Lv  SP ", y, x + 5);
201 #endif
202                                 prt("", y+1, x);
203                                 /* Dump the spells */
204                                 for (i = 0, line = 0; i < 32; i++)
205                                 {
206                                         spell = technic_info[TECHNIC_HISSATSU][i];
207
208                                         if (spell.slevel > PY_MAX_LEVEL) continue;
209                                         line++;
210                                         if (!(p_ptr->spell_learned1 >> i)) break;
211
212                                         /* Access the spell */
213                                         if (spell.slevel > plev)   continue;
214                                         if (!(p_ptr->spell_learned1 & (1L << i))) continue;
215                                         if (use_menu)
216                                         {
217                                                 if (i == (menu_line-1))
218 #ifdef JP
219                                                         strcpy(psi_desc, "  ¡Õ");
220 #else
221                                                         strcpy(psi_desc, "  > ");
222 #endif
223                                                 else strcpy(psi_desc, "    ");
224                                                 
225                                         }
226                                         else
227                                         {
228                                                 char letter;
229                                                 if (line <= 26)
230                                                         letter = I2A(line-1);
231                                                 else
232                                                         letter = '0' + line - 27;
233                                                 sprintf(psi_desc, "  %c)",letter);
234                                         }
235
236                                         /* Dump the spell --(-- */
237                                         strcat(psi_desc, format(" %-18s%2d %3d",
238                                                 spell_names[technic2magic(REALM_HISSATSU)-1][i],
239                                                 spell.slevel, spell.smana));
240                                         prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
241                                         prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
242                                 }
243                         }
244
245                         /* Hide the list */
246                         else
247                         {
248                                 /* Hide list */
249                                 redraw = FALSE;
250
251                                 /* Restore the screen */
252                                 screen_load();
253                         }
254
255                         /* Redo asking */
256                         continue;
257                 }
258
259                 if (!use_menu)
260                 {
261                         if (isalpha(choice))
262                         {
263                                 /* Note verify */
264                                 ask = (isupper(choice));
265
266                                 /* Lowercase */
267                                 if (ask) choice = tolower(choice);
268
269                                 /* Extract request */
270                                 i = (islower(choice) ? A2I(choice) : -1);
271                         }
272                         else
273                         {
274                                 ask = FALSE; /* Can't uppercase digits */
275
276                                 i = choice - '0' + 26;
277                         }
278                 }
279
280                 /* Totally Illegal */
281                 if ((i < 0) || (i >= 32) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
282                 {
283                         bell();
284                         continue;
285                 }
286
287                 j = sentaku[i];
288
289                 /* Verify it */
290                 if (ask)
291                 {
292                         char tmp_val[160];
293
294                         /* Prompt */
295 #ifdef JP
296 (void) strnfmt(tmp_val, 78, "%s¤ò»È¤¤¤Þ¤¹¤«¡©", spell_names[technic2magic(REALM_HISSATSU)-1][j]);
297 #else
298                         (void)strnfmt(tmp_val, 78, "Use %s? ", spell_names[technic2magic(REALM_HISSATSU)-1][j]);
299 #endif
300
301
302                         /* Belay that order */
303                         if (!get_check(tmp_val)) continue;
304                 }
305
306                 /* Stop the loop */
307                 flag = TRUE;
308         }
309
310         /* Restore the screen */
311         if (redraw) screen_load();
312
313         /* Show choices */
314         if (show_choices)
315         {
316                 /* Update */
317                 p_ptr->window |= (PW_SPELL);
318
319                 /* Window stuff */
320                 window_stuff();
321         }
322
323         /* Abort if needed */
324         if (!flag) return (FALSE);
325
326         /* Save the choice */
327         (*sn) = j;
328
329 #ifdef ALLOW_REPEAT /* TNB */
330
331         repeat_push(*sn);
332
333 #endif /* ALLOW_REPEAT -- TNB */
334
335         /* Success */
336         return (TRUE);
337 }
338
339
340 /*
341  * do_cmd_cast calls this function if the player's class
342  * is 'mindcrafter'.
343  */
344 static bool cast_hissatsu_spell(int spell)
345 {
346         int             y, x;
347         int             dir;
348
349
350         /* spell code */
351         switch (spell)
352         {
353         case 0:
354                 project_length = 2;
355                 if (!get_aim_dir(&dir)) return FALSE;
356                 project_hook(GF_ATTACK, dir, HISSATSU_2, PROJECT_STOP | PROJECT_KILL);
357
358                 break;
359         case 1:
360         {
361                 int cdir;
362                 if (!get_rep_dir2(&dir)) return FALSE;
363                 if (dir == 5) return FALSE;
364                 for (cdir = 0;cdir < 8; cdir++)
365                 {
366                         if (cdd[cdir] == dir) break;
367                 }
368                 if (cdir == 8) return FALSE;
369                 y = py + ddy_cdd[cdir];
370                 x = px + ddx_cdd[cdir];
371                 if (cave[y][x].m_idx)
372                         py_attack(y, x, 0);
373                 else
374 #ifdef JP
375                         msg_print("¹¶·â¤Ï¶õ¤òÀڤä¿¡£");
376 #else
377                         msg_print("You attack the empty air.");
378 #endif
379                 y = py + ddy_cdd[(cdir + 7) % 8];
380                 x = px + ddx_cdd[(cdir + 7) % 8];
381                 if (cave[y][x].m_idx)
382                         py_attack(y, x, 0);
383                 else
384 #ifdef JP
385                         msg_print("¹¶·â¤Ï¶õ¤òÀڤä¿¡£");
386 #else
387                         msg_print("You attack the empty air.");
388 #endif
389                 y = py + ddy_cdd[(cdir + 1) % 8];
390                 x = px + ddx_cdd[(cdir + 1) % 8];
391                 if (cave[y][x].m_idx)
392                         py_attack(y, x, 0);
393                 else
394 #ifdef JP
395                         msg_print("¹¶·â¤Ï¶õ¤òÀڤä¿¡£");
396 #else
397                         msg_print("You attack the empty air.");
398 #endif
399
400                 break;
401         }
402         case 2:
403         {
404                 if (!do_cmd_throw_aux(1, TRUE, 0)) return FALSE;
405                 break;
406         }
407         case 3:
408         {
409                 if (!get_rep_dir2(&dir)) return FALSE;
410                 if (dir == 5) return FALSE;
411                 y = py + ddy[dir];
412                 x = px + ddx[dir];
413                 if (cave[y][x].m_idx)
414                         py_attack(y, x, HISSATSU_FIRE);
415                 else
416                 {
417 #ifdef JP
418                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
419 #else
420                         msg_print("There is no monster.");
421 #endif
422                         return FALSE;
423                 }
424                 break;
425         }
426         case 4:
427         {
428                 detect_monsters_mind(DETECT_RAD_DEFAULT);
429                 break;
430         }
431         case 5:
432         {
433                 if (!get_rep_dir2(&dir)) return FALSE;
434                 if (dir == 5) return FALSE;
435                 y = py + ddy[dir];
436                 x = px + ddx[dir];
437                 if (cave[y][x].m_idx)
438                         py_attack(y, x, HISSATSU_MINEUCHI);
439                 else
440                 {
441 #ifdef JP
442                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
443 #else
444                         msg_print("There is no monster.");
445 #endif
446                         return FALSE;
447                 }
448                 break;
449         }
450         case 6:
451         {
452                 if (p_ptr->riding)
453                 {
454 #ifdef JP
455                         msg_print("¾èÇÏÃæ¤Ë¤Ï̵Íý¤À¡£");
456 #else
457                         msg_print("You cannot do it when riding.");
458 #endif
459                         return FALSE;
460                 }
461 #ifdef JP
462                 msg_print("Áê¼ê¤Î¹¶·â¤ËÂФ·¤Æ¿È¹½¤¨¤¿¡£");
463 #else
464                 msg_print("You prepare to counter blow.");
465 #endif
466                 p_ptr->counter = TRUE;
467                 break;
468         }
469         case 7:
470         {
471                 if (p_ptr->riding)
472                 {
473 #ifdef JP
474                         msg_print("¾èÇÏÃæ¤Ë¤Ï̵Íý¤À¡£");
475 #else
476                         msg_print("You cannot do it when riding.");
477 #endif
478                         return FALSE;
479                 }
480
481                 if (!get_rep_dir2(&dir)) return FALSE;
482
483                 if (dir == 5) return FALSE;
484                 y = py + ddy[dir];
485                 x = px + ddx[dir];
486
487                 if (!cave[y][x].m_idx)
488                 {
489 #ifdef JP
490                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
491 #else
492                         msg_print("There is no monster.");
493 #endif
494                         return FALSE;
495                 }
496
497                 py_attack(y, x, 0);
498
499                 if (!player_can_enter(cave[y][x].feat) || is_trap(cave[y][x].feat))
500                         break;
501
502                 y += ddy[dir];
503                 x += ddx[dir];
504
505                 if (player_can_enter(cave[y][x].feat) && !is_trap(cave[y][x].feat) && !cave[y][x].m_idx)
506                 {
507                         int oy, ox;
508
509                         msg_print(NULL);
510
511                         /* Save the old location */
512                         oy = py;
513                         ox = px;
514
515                         /* Move the player */
516                         py = y;
517                         px = x;
518
519                         forget_flow();
520
521                         /* Redraw the old spot */
522                         lite_spot(oy, ox);
523
524                         /* Redraw the new spot */
525                         lite_spot(py, px);
526
527                         /* Check for new panel (redraw map) */
528                         verify_panel();
529
530                         /* Update stuff */
531                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
532
533                         /* Update the monsters */
534                         p_ptr->update |= (PU_DISTANCE);
535
536                         /* Window stuff */
537                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
538
539                         /* Handle stuff XXX XXX XXX */
540                         handle_stuff();
541                 }
542                 break;
543         }
544         case 8:
545         {
546                 if (!get_rep_dir2(&dir)) return FALSE;
547                 if (dir == 5) return FALSE;
548                 y = py + ddy[dir];
549                 x = px + ddx[dir];
550                 if (cave[y][x].m_idx)
551                         py_attack(y, x, HISSATSU_POISON);
552                 else
553                 {
554 #ifdef JP
555                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
556 #else
557                         msg_print("There is no monster.");
558 #endif
559                         return FALSE;
560                 }
561                 break;
562         }
563         case 9:
564         {
565                 if (!get_rep_dir2(&dir)) return FALSE;
566                 if (dir == 5) return FALSE;
567                 y = py + ddy[dir];
568                 x = px + ddx[dir];
569                 if (cave[y][x].m_idx)
570                         py_attack(y, x, HISSATSU_ZANMA);
571                 else
572                 {
573 #ifdef JP
574                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
575 #else
576                         msg_print("There is no monster.");
577 #endif
578                         return FALSE;
579                 }
580                 break;
581         }
582         case 10:
583         {
584                 if (!get_rep_dir2(&dir)) return FALSE;
585                 if (dir == 5) return FALSE;
586                 y = py + ddy[dir];
587                 x = px + ddx[dir];
588                 if (cave[y][x].m_idx)
589                         py_attack(y, x, 0);
590                 else
591                 {
592 #ifdef JP
593                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
594 #else
595                         msg_print("There is no monster.");
596 #endif
597                         return FALSE;
598                 }
599                 if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
600                 {
601                         return TRUE;
602                 }
603                 if (cave[y][x].m_idx)
604                 {
605                         int i;
606                         int ty = y, tx = x;
607                         int oy = y, ox = x;
608                         int m_idx = cave[y][x].m_idx;
609                         monster_type *m_ptr = &m_list[m_idx];
610                         char m_name[80];
611
612                         monster_desc(m_name, m_ptr, 0);
613
614                         for (i = 0; i < 5; i++)
615                         {
616                                 y += ddy[dir];
617                                 x += ddx[dir];
618                                 if (cave_empty_bold(y, x))
619                                 {
620                                         ty = y;
621                                         tx = x;
622                                 }
623                                 else break;
624                         }
625                         if ((ty != oy) || (tx != ox))
626                         {
627 #ifdef JP
628                                 msg_format("%s¤ò¿á¤­Èô¤Ð¤·¤¿¡ª", m_name);
629 #else
630                                 msg_format("You blow %s away!", m_name);
631 #endif
632                                 cave[oy][ox].m_idx = 0;
633                                 cave[ty][tx].m_idx = m_idx;
634                                 m_ptr->fy = ty;
635                                 m_ptr->fx = tx;
636
637                                 update_mon(m_idx, TRUE);
638                                 lite_spot(oy, ox);
639                                 lite_spot(ty, tx);
640                         }
641                 }
642                 break;
643         }
644         case 11:
645         {
646                 if (p_ptr->lev > 44)
647                 {
648                         if (!identify_fully(TRUE)) return FALSE;
649                 }
650                 else
651                 {
652                         if (!ident_spell(TRUE)) return FALSE;
653                 }
654                 break;
655         }
656         case 12:
657         {
658                 if (!get_rep_dir2(&dir)) return FALSE;
659                 if (dir == 5) return FALSE;
660                 y = py + ddy[dir];
661                 x = px + ddx[dir];
662                 if (cave[y][x].m_idx)
663                         py_attack(y, x, HISSATSU_HAGAN);
664
665                 /* Non-walls (etc) */
666                 if (cave_floor_bold(y, x)) break;
667
668                 /* Permanent walls */
669                 if (cave[y][x].feat >= FEAT_PERM_EXTRA) break;
670
671                 if (cave[y][x].feat < FEAT_DOOR_HEAD) break;
672
673                 /* Forget the wall */
674                 cave[y][x].info &= ~(CAVE_MARK);
675
676                 /* Destroy the feature */
677                 cave[y][x].feat = floor_type[randint0(100)];
678
679                 /* Update some things */
680                 p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
681
682                 lite_spot(y, x);
683
684                 break;
685         }
686         case 13:
687         {
688                 if (!get_rep_dir2(&dir)) return FALSE;
689                 if (dir == 5) return FALSE;
690                 y = py + ddy[dir];
691                 x = px + ddx[dir];
692                 if (cave[y][x].m_idx)
693                         py_attack(y, x, HISSATSU_COLD);
694                 else
695                 {
696 #ifdef JP
697                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
698 #else
699                         msg_print("There is no monster.");
700 #endif
701                         return FALSE;
702                 }
703                 break;
704         }
705         case 14:
706         {
707                 if (!get_rep_dir2(&dir)) return FALSE;
708                 if (dir == 5) return FALSE;
709                 y = py + ddy[dir];
710                 x = px + ddx[dir];
711                 if (cave[y][x].m_idx)
712                         py_attack(y, x, HISSATSU_KYUSHO);
713                 else
714                 {
715 #ifdef JP
716                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
717 #else
718                         msg_print("There is no monster.");
719 #endif
720                         return FALSE;
721                 }
722                 break;
723         }
724         case 15:
725         {
726                 if (!get_rep_dir2(&dir)) return FALSE;
727                 if (dir == 5) return FALSE;
728                 y = py + ddy[dir];
729                 x = px + ddx[dir];
730                 if (cave[y][x].m_idx)
731                         py_attack(y, x, HISSATSU_MAJIN);
732                 else
733                 {
734 #ifdef JP
735                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
736 #else
737                         msg_print("There is no monster.");
738 #endif
739                         return FALSE;
740                 }
741                 break;
742         }
743         case 16:
744         {
745                 if (!get_rep_dir2(&dir)) return FALSE;
746                 if (dir == 5) return FALSE;
747                 y = py + ddy[dir];
748                 x = px + ddx[dir];
749                 if (cave[y][x].m_idx)
750                         py_attack(y, x, HISSATSU_SUTEMI);
751                 else
752                 {
753 #ifdef JP
754                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
755 #else
756                         msg_print("There is no monster.");
757 #endif
758                         return FALSE;
759                 }
760                 p_ptr->sutemi = TRUE;
761                 break;
762         }
763         case 17:
764         {
765                 if (!get_rep_dir2(&dir)) return FALSE;
766                 if (dir == 5) return FALSE;
767                 y = py + ddy[dir];
768                 x = px + ddx[dir];
769                 if (cave[y][x].m_idx)
770                         py_attack(y, x, HISSATSU_ELEC);
771                 else
772                 {
773 #ifdef JP
774                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
775 #else
776                         msg_print("There is no monster.");
777 #endif
778                         return FALSE;
779                 }
780                 break;
781         }
782         case 18:
783                 project_length = 5;
784                 if (!get_aim_dir(&dir)) return FALSE;
785                 project_hook(GF_ATTACK, dir, HISSATSU_NYUSIN, PROJECT_STOP | PROJECT_KILL);
786
787                 break;
788         case 19: /* Whirlwind Attack */
789         {
790                 int y = 0, x = 0;
791                 cave_type       *c_ptr;
792                 monster_type    *m_ptr;
793
794                 if (p_ptr->cut < 300)
795                         set_cut(p_ptr->cut + 300);
796                 else
797                         set_cut(p_ptr->cut * 2);
798
799                 for (dir = 0; dir < 8; dir++)
800                 {
801                         y = py + ddy_ddd[dir];
802                         x = px + ddx_ddd[dir];
803                         c_ptr = &cave[y][x];
804
805                         /* Get the monster */
806                         m_ptr = &m_list[c_ptr->m_idx];
807
808                         /* Hack -- attack monsters */
809                         if (c_ptr->m_idx && (m_ptr->ml || cave_floor_bold(y, x)))
810                         {
811                                 if (r_info[m_list[c_ptr->m_idx].r_idx].flags3 & (RF3_DEMON | RF3_UNDEAD | RF3_NONLIVING))
812                                 {
813                                         char m_name[80];
814
815                                         monster_desc(m_name, &m_list[c_ptr->m_idx], 0);
816 #ifdef JP
817                                         msg_format("%s¤Ë¤Ï¸ú²Ì¤¬¤Ê¤¤¡ª", m_name);
818 #else
819                                         msg_format("%s is unharmed!", m_name);
820 #endif
821                                 }
822                                 else py_attack(y, x, HISSATSU_SEKIRYUKA);
823                         }
824                 }
825                 break;
826         }
827         case 20:
828         {
829                 if (!get_rep_dir2(&dir)) return FALSE;
830                 if (dir == 5) return FALSE;
831                 y = py + ddy[dir];
832                 x = px + ddx[dir];
833                 if (cave[y][x].m_idx)
834                         py_attack(y, x, HISSATSU_QUAKE);
835                 else
836                 {
837                         earthquake(py, px, 10);
838                 }
839                 break;
840         }
841         case 21:
842         {
843                 int total_damage = 0, basedam, i;
844                 u32b flgs[TR_FLAG_SIZE];
845                 object_type *o_ptr;
846                 if (!get_aim_dir(&dir)) return FALSE;
847 #ifdef JP
848                 msg_print("Éð´ï¤òÂ礭¤¯¿¶¤ê²¼¤í¤·¤¿¡£");
849 #else
850                 msg_print("You swing your weapon downward.");
851 #endif
852                 for (i = 0; i < 2; i++)
853                 {
854                         int damage;
855
856                         if (!buki_motteruka(INVEN_RARM+i)) break;
857                         o_ptr = &inventory[INVEN_RARM+i];
858                         basedam = (o_ptr->dd * (o_ptr->ds + 1)) * 50;
859                         damage = o_ptr->to_d * 100;
860                         object_flags(o_ptr, flgs);
861                         if ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
862                         {
863                                 /* vorpal blade */
864                                 basedam *= 5;
865                                 basedam /= 3;
866                         }
867                         else if (object_known_p(o_ptr) && (have_flag(flgs, TR_VORPAL)))
868                         {
869                                 /* vorpal flag only */
870                                 basedam *= 11;
871                                 basedam /= 9;
872                         }
873                         damage += basedam;
874                         damage *= p_ptr->num_blow[i];
875                         total_damage += damage / 200;
876                         if (i) total_damage = total_damage*7/10;
877                 }
878                 fire_beam(GF_FORCE, dir, total_damage);
879                 break;
880         }
881         case 22:
882         {
883 #ifdef JP
884                 msg_print("ͺ¶«¤Ó¤ò¤¢¤²¤¿¡ª");
885 #else
886                 msg_print("You roar out!");
887 #endif
888                 project_hack(GF_SOUND, randint1(p_ptr->lev * 3));
889                 aggravate_monsters(0);
890                 break;
891         }
892         case 23:
893         {
894                 int i;
895                 if (!get_rep_dir2(&dir)) return FALSE;
896                 if (dir == 5) return FALSE;
897                 y = py + ddy[dir];
898                 x = px + ddx[dir];
899                 for (i = 0; i < 3; i++)
900                 {
901                         if (cave[y][x].m_idx)
902                                 py_attack(y, x, HISSATSU_3DAN);
903                         else
904                         {
905 #ifdef JP
906                                 msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
907 #else
908                                 msg_print("There is no monster.");
909 #endif
910                                 return FALSE;
911                         }
912                         if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
913                         {
914                                 return TRUE;
915                         }
916                         if (cave[y][x].m_idx)
917                         {
918                                 int oy, ox;
919                                 int ny = y + ddy[dir];
920                                 int nx = x + ddx[dir];
921                                 int m_idx = cave[y][x].m_idx;
922                                 monster_type *m_ptr = &m_list[m_idx];
923                                 if (cave_empty_bold(ny, nx))
924                                 {
925                                         cave[y][x].m_idx = 0;
926                                         cave[ny][nx].m_idx = m_idx;
927                                         m_ptr->fy = ny;
928                                         m_ptr->fx = nx;
929
930                                         update_mon(m_idx, TRUE);
931
932                                         /* Save the old location */
933                                         oy = py;
934                                         ox = px;
935
936                                         /* Move the player */
937                                         py = y;
938                                         px = x;
939
940                                         if (p_ptr->riding)
941                                         {
942                                                 int tmp;
943                                                 tmp = cave[py][px].m_idx;
944                                                 cave[py][px].m_idx = cave[oy][ox].m_idx;
945                                                 cave[oy][ox].m_idx = tmp;
946                                                 m_list[p_ptr->riding].fy = py;
947                                                 m_list[p_ptr->riding].fx = px;
948                                                 update_mon(cave[py][px].m_idx, TRUE);
949                                         }
950
951                                         forget_flow();
952
953                                         /* Redraw the old spot */
954                                         lite_spot(oy, ox);
955
956                                         /* Redraw the new spot */
957                                         lite_spot(py, px);
958
959                                         /* Redraw the new spot */
960                                         lite_spot(ny, nx);
961
962                                         /* Check for new panel (redraw map) */
963                                         verify_panel();
964
965                                         /* Update stuff */
966                                         p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW);
967
968                                         /* Update the monsters */
969                                         p_ptr->update |= (PU_DISTANCE);
970
971                                         /* Window stuff */
972                                         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
973
974                                         /* Handle stuff XXX XXX XXX */
975                                         handle_stuff();
976
977                                         if (i < 2) msg_print(NULL);
978                                         y += ddy[dir];
979                                         x += ddx[dir];
980                                 }
981                         }
982                         else break;
983                 }
984                 break;
985         }
986         case 24:
987         {
988                 if (!get_rep_dir2(&dir)) return FALSE;
989                 if (dir == 5) return FALSE;
990                 y = py + ddy[dir];
991                 x = px + ddx[dir];
992                 if (cave[y][x].m_idx)
993                         py_attack(y, x, HISSATSU_DRAIN);
994                 else
995                 {
996 #ifdef JP
997                                 msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
998 #else
999                                 msg_print("There is no monster.");
1000 #endif
1001                         return FALSE;
1002                 }
1003                 break;
1004         }
1005         case 25:
1006         {
1007 #ifdef JP
1008                 msg_print("Éð´ï¤òÉÔµ¬Â§¤ËÍɤ餷¤¿¡¥¡¥¡¥");
1009 #else
1010                 msg_print("You irregularly wave your weapon...");
1011 #endif
1012                 project_hack(GF_ENGETSU, p_ptr->lev * 4);
1013                 project_hack(GF_ENGETSU, p_ptr->lev * 4);
1014                 project_hack(GF_ENGETSU, p_ptr->lev * 4);
1015                 break;
1016         }
1017         case 26:
1018         {
1019                 bool new = TRUE;
1020                 int count = 0;
1021                 do
1022                 {
1023                         project_length = 5;
1024                         if (!get_aim_dir(&dir)) break;
1025                         if (new)
1026                                 /* Reserve needed mana point */
1027                                 p_ptr->csp -= technic_info[TECHNIC_HISSATSU][26].smana;
1028                         else
1029                                 p_ptr->csp -= 8;
1030                         new = FALSE;
1031                         if (!project_hook(GF_ATTACK, dir, HISSATSU_NYUSIN, PROJECT_STOP | PROJECT_KILL)) break;
1032                         count++;
1033                         command_dir = 0;
1034                         p_ptr->redraw |= PR_MANA;
1035                         handle_stuff();
1036                 } while (p_ptr->csp > 8);
1037                 if (new) return FALSE;
1038
1039                 /* Restore reserved mana */
1040                 p_ptr->csp += technic_info[TECHNIC_HISSATSU][26].smana;
1041
1042                 break;
1043         }
1044         case 27:
1045         {
1046                 if (!tgt_pt(&x, &y)) return FALSE;
1047                 if (!cave_empty_bold(y, x) || (cave[y][x].info & CAVE_ICKY) ||
1048                         (distance(y, x, py, px) > MAX_SIGHT / 2) ||
1049                     !projectable(py, px, y, x))
1050                 {
1051 #ifdef JP
1052                         msg_print("¼ºÇÔ¡ª");
1053 #else
1054                         msg_print("You cannot move to that place!");
1055 #endif
1056                         break;
1057                 }
1058                 if (p_ptr->anti_tele)
1059                 {
1060 #ifdef JP
1061 msg_print("ÉԻ׵ĤÊÎϤ¬¥Æ¥ì¥Ý¡¼¥È¤òËɤ¤¤À¡ª");
1062 #else
1063                         msg_print("A mysterious force prevents you from teleporting!");
1064 #endif
1065
1066                         break;
1067                 }
1068                 project(0, 0, y, x, HISSATSU_ISSEN, GF_ATTACK, PROJECT_BEAM | PROJECT_KILL, -1);
1069                 teleport_player_to(y, x, TRUE);
1070                 break;
1071         }
1072         case 28:
1073         {
1074                 int x, y;
1075
1076                 if (!get_rep_dir(&dir, FALSE)) return FALSE;
1077                 y = py + ddy[dir];
1078                 x = px + ddx[dir];
1079                 if (cave[y][x].m_idx)
1080                 {
1081                         py_attack(y, x, 0);
1082                         if (cave[y][x].m_idx)
1083                         {
1084                                 handle_stuff();
1085                                 py_attack(y, x, 0);
1086                         }
1087                 }
1088                 else
1089                 {
1090 #ifdef JP
1091 msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
1092 #else
1093                         msg_print("You don't see any monster in this direction");
1094 #endif
1095                         return FALSE;
1096                 }
1097                 break;
1098         }
1099         case 29:
1100         {
1101                 int total_damage = 0, basedam, i;
1102                 int y, x;
1103                 u32b flgs[TR_FLAG_SIZE];
1104                 object_type *o_ptr;
1105
1106                 if (!get_rep_dir2(&dir)) return FALSE;
1107                 if (dir == 5) return FALSE;
1108                 y = py + ddy[dir];
1109                 x = px + ddx[dir];
1110                 if (d_info[dungeon_type].flags1 & DF1_NO_MELEE)
1111                 {
1112 #ifdef JP
1113                         msg_print("¤Ê¤¼¤«¹¶·â¤¹¤ë¤³¤È¤¬¤Ç¤­¤Ê¤¤¡£");
1114 #else
1115                         msg_print("Something prevent you from attacking.");
1116 #endif
1117                         return TRUE;
1118                 }
1119 #ifdef JP
1120                 msg_print("Éð´ï¤òÂ礭¤¯¿¶¤ê²¼¤í¤·¤¿¡£");
1121 #else
1122                 msg_print("You swing your weapon downward.");
1123 #endif
1124                 for (i = 0; i < 2; i++)
1125                 {
1126                         int damage;
1127                         if (!buki_motteruka(INVEN_RARM+i)) break;
1128                         o_ptr = &inventory[INVEN_RARM+i];
1129                         basedam = (o_ptr->dd * (o_ptr->ds + 1)) * 50;
1130                         damage = o_ptr->to_d * 100;
1131                         object_flags(o_ptr, flgs);
1132                         if ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD))
1133                         {
1134                                 /* vorpal blade */
1135                                 basedam *= 5;
1136                                 basedam /= 3;
1137                         }
1138                         else if (object_known_p(o_ptr) && (have_flag(flgs, TR_VORPAL)))
1139                         {
1140                                 /* vorpal flag only */
1141                                 basedam *= 11;
1142                                 basedam /= 9;
1143                         }
1144                         damage += basedam;
1145                         damage += p_ptr->to_d[i] * 100;
1146                         damage *= p_ptr->num_blow[i];
1147                         total_damage += (damage / 100);
1148                 }
1149                 project(0, (cave_floor_bold(y, x) ? 5 : 0), y, x, total_damage * 3 / 2, GF_METEOR, PROJECT_KILL | PROJECT_JUMP | PROJECT_ITEM, -1);
1150                 break;
1151         }
1152         case 30:
1153         {
1154                 if (!get_rep_dir2(&dir)) return FALSE;
1155                 if (dir == 5) return FALSE;
1156                 y = py + ddy[dir];
1157                 x = px + ddx[dir];
1158                 if (cave[y][x].m_idx)
1159                         py_attack(y, x, HISSATSU_UNDEAD);
1160                 else
1161                 {
1162 #ifdef JP
1163                         msg_print("¤½¤ÎÊý¸þ¤Ë¤Ï¥â¥ó¥¹¥¿¡¼¤Ï¤¤¤Þ¤»¤ó¡£");
1164 #else
1165                         msg_print("There is no monster.");
1166 #endif
1167                         return FALSE;
1168                 }
1169 #ifdef JP
1170                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "·Ä±Àµ´Ç¦·õ¤ò»È¤Ã¤¿¾×·â", -1);
1171 #else
1172                 take_hit(DAMAGE_NOESCAPE, 100 + randint1(100), "exhaustion on using Keiun-Kininken", -1);
1173 #endif
1174                 break;
1175         }
1176         case 31:
1177         {
1178                 int i;
1179 #ifdef JP
1180 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return FALSE;
1181 #else
1182                 if (!get_check("Do you really want to commit suicide? ")) return FALSE;
1183 #endif
1184                         /* Special Verification for suicide */
1185 #ifdef JP
1186 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
1187 #else
1188                 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
1189 #endif
1190
1191                 flush();
1192                 i = inkey();
1193                 prt("", 0, 0);
1194                 if (i != '@') return FALSE;
1195                 if (p_ptr->total_winner)
1196                 {
1197                         take_hit(DAMAGE_FORCE, 9999, "Seppuku", -1);
1198                         p_ptr->total_winner = TRUE;
1199                 }
1200                 else
1201                 {
1202 #ifdef JP
1203                         msg_print("Éð»ÎÆ»¤È¤Ï¡¢»à¤Ì¤³¤È¤È¸«¤Ä¤±¤¿¤ê¡£");
1204                         take_hit(DAMAGE_FORCE, 9999, "ÀÚÊ¢", -1);
1205 #else
1206                         msg_print("Meaning of Bushi-do is found in the death.");
1207                         take_hit(DAMAGE_FORCE, 9999, "Seppuku", -1);
1208 #endif
1209                 }
1210                 break;
1211         }
1212         default:
1213 #ifdef JP
1214 msg_print("¤Ê¤Ë¡©");
1215 #else
1216                 msg_print("Zap?");
1217 #endif
1218
1219         }
1220
1221         return TRUE;
1222 }
1223
1224
1225 /*
1226  * do_cmd_cast calls this function if the player's class
1227  * is 'mindcrafter'.
1228  */
1229 void do_cmd_hissatsu(void)
1230 {
1231         int             n = 0;
1232         magic_type      spell;
1233         bool            cast;
1234
1235
1236         /* not if confused */
1237         if (p_ptr->confused)
1238         {
1239 #ifdef JP
1240 msg_print("º®Í𤷤Ƥ¤¤Æ½¸Ãæ¤Ç¤­¤Ê¤¤¡ª");
1241 #else
1242                 msg_print("You are too confused!");
1243 #endif
1244
1245                 return;
1246         }
1247         if (!buki_motteruka(INVEN_RARM))
1248         {
1249                 if (flush_failure) flush();
1250 #ifdef JP
1251 msg_print("Éð´ï¤ò»ý¤¿¤Ê¤¤¤Èɬ»¦µ»¤Ï»È¤¨¤Ê¤¤¡ª");
1252 #else
1253                 msg_print("You need to wield a weapon!");
1254 #endif
1255
1256                 return;
1257         }
1258         if (!p_ptr->spell_learned1)
1259         {
1260 #ifdef JP
1261 msg_print("²¿¤âµ»¤òÃΤé¤Ê¤¤¡£");
1262 #else
1263                 msg_print("You don't know any martial arts.");
1264 #endif
1265
1266                 return;
1267         }
1268
1269         if (p_ptr->special_defense & KATA_MASK)
1270         {
1271                 set_action(ACTION_NONE);
1272         }
1273
1274         /* get power */
1275         if (!get_hissatsu_power(&n)) return;
1276
1277         spell = technic_info[TECHNIC_HISSATSU][n];
1278
1279         /* Verify "dangerous" spells */
1280         if (spell.smana > p_ptr->csp)
1281         {
1282                 if (flush_failure) flush();
1283                 /* Warning */
1284 #ifdef JP
1285 msg_print("£Í£Ð¤¬Â­¤ê¤Þ¤»¤ó¡£");
1286 #else
1287                 msg_print("You do not have enough mana to use this power.");
1288 #endif
1289                 msg_print(NULL);
1290                 return;
1291         }
1292
1293         sound(SOUND_ZAP);
1294
1295         /* Cast the spell */
1296         cast = cast_hissatsu_spell(n);
1297
1298         if (!cast) return;
1299
1300         /* Take a turn */
1301         energy_use = 100;
1302
1303         /* Use some mana */
1304         p_ptr->csp -= spell.smana;
1305
1306         /* Limit */
1307         if (p_ptr->csp < 0) p_ptr->csp = 0;
1308
1309         /* Redraw mana */
1310         p_ptr->redraw |= (PR_MANA);
1311
1312         /* Window stuff */
1313         p_ptr->window |= (PW_PLAYER);
1314         p_ptr->window |= (PW_SPELL);
1315 }
1316
1317
1318 void do_cmd_gain_hissatsu(void)
1319 {
1320         int item, i, j;
1321
1322         object_type *o_ptr;
1323         cptr q, s;
1324
1325         bool gain = FALSE;
1326
1327         if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
1328         {
1329                 set_action(ACTION_NONE);
1330         }
1331
1332         if (p_ptr->blind || no_lite())
1333         {
1334 #ifdef JP
1335 msg_print("Ìܤ¬¸«¤¨¤Ê¤¤¡ª");
1336 #else
1337                 msg_print("You cannot see!");
1338 #endif
1339
1340                 return;
1341         }
1342
1343         if (p_ptr->confused)
1344         {
1345 #ifdef JP
1346 msg_print("º®Í𤷤Ƥ¤¤ÆÆɤá¤Ê¤¤¡ª");
1347 #else
1348                 msg_print("You are too confused!");
1349 #endif
1350
1351                 return;
1352         }
1353
1354         if (!(p_ptr->new_spells))
1355         {
1356 #ifdef JP
1357 msg_print("¿·¤·¤¤É¬»¦µ»¤ò³Ð¤¨¤ë¤³¤È¤Ï¤Ç¤­¤Ê¤¤¡ª");
1358 #else
1359                 msg_print("You cannot learn any new special attacks!");
1360 #endif
1361
1362                 return;
1363         }
1364
1365 #ifdef JP
1366         if( p_ptr->new_spells < 10 ){
1367                 msg_format("¤¢¤È %d ¤Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
1368         }else{
1369                 msg_format("¤¢¤È %d ¸Ä¤Îɬ»¦µ»¤ò³Ø¤Ù¤ë¡£", p_ptr->new_spells);
1370         }
1371 #else
1372         msg_format("You can learn %d new special attack%s.", p_ptr->new_spells,
1373                 (p_ptr->new_spells == 1?"":"s"));
1374 #endif
1375
1376         item_tester_tval = TV_HISSATSU_BOOK;
1377
1378         /* Get an item */
1379 #ifdef JP
1380 q = "¤É¤Î½ñ¤«¤é³Ø¤Ó¤Þ¤¹¤«? ";
1381 #else
1382         q = "Study which book? ";
1383 #endif
1384
1385 #ifdef JP
1386 s = "Æɤá¤ë½ñ¤¬¤Ê¤¤¡£";
1387 #else
1388         s = "You have no books that you can read.";
1389 #endif
1390
1391         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1392
1393         /* Get the item (in the pack) */
1394         if (item >= 0)
1395         {
1396                 o_ptr = &inventory[item];
1397         }
1398
1399         /* Get the item (on the floor) */
1400         else
1401         {
1402                 o_ptr = &o_list[0 - item];
1403         }
1404
1405         for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
1406         {
1407                 if (p_ptr->spell_learned1 & (1L << i)) continue;
1408                 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
1409
1410                 p_ptr->spell_learned1 |= (1L << i);
1411                 p_ptr->spell_worked1 |= (1L << i);
1412 #ifdef JP
1413                 msg_format("%s¤Îµ»¤ò³Ð¤¨¤¿¡£", spell_names[technic2magic(REALM_HISSATSU)-1][i]);
1414 #else
1415                 msg_format("You have learned the special attack of %s.", spell_names[technic2magic(REALM_HISSATSU)-1][i]);
1416 #endif
1417                 for (j = 0; j < 64; j++)
1418                 {
1419                         /* Stop at the first empty space */
1420                         if (p_ptr->spell_order[j] == 99) break;
1421                 }
1422                 p_ptr->spell_order[j] = i;
1423                 gain = TRUE;
1424         }
1425         if (!gain)
1426 #ifdef JP
1427                 msg_print("²¿¤â³Ð¤¨¤é¤ì¤Ê¤«¤Ã¤¿¡£");
1428 #else
1429                 msg_print("You were not able to learn any special attacks.");
1430 #endif
1431
1432         p_ptr->update |= (PU_SPELLS);
1433 }