3 * @brief 剣術の実装 / Blade arts
6 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7 * This software may be copied and distributed for educational, research,\n
8 * and not for profit purposes provided that this copyright and statement\n
9 * are included in all such copies. Other copyrights may also apply.\n
10 * 2014 Deskull rearranged comment for Doxygen.\n
13 #include "cmd-action/cmd-spell.h"
14 #include "cmd/cmd-basic.h"
15 #include "core/asking-player.h"
16 #include "core/stuff-handler.h"
17 #include "game-option/disturbance-options.h"
18 #include "game-option/text-display-options.h"
19 #include "inventory/player-inventory.h"
20 #include "io/command-repeater.h"
21 #include "io/input-key-requester.h"
22 #include "main/sound-definitions-table.h"
23 #include "main/sound-of-music.h"
24 #include "monster-race/monster-race-hook.h"
25 #include "object/item-use-flags.h"
26 #include "player/player-effects.h"
27 #include "player/player-status.h"
28 #include "spell/spells-execution.h"
29 #include "spell/spells-util.h"
30 #include "spell/technic-info-table.h"
31 #include "term/screen-processor.h"
32 #include "view/display-main-window.h"
33 #include "view/display-messages.h"
35 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
38 * @brief 使用可能な剣術を選択する /
39 * Allow user to choose a blade arts.
40 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
41 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
43 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
44 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
45 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
47 * The "prompt" should be "cast", "recite", or "study"\n
48 * The "known" should be TRUE for cast/pray, FALSE for study\n
50 * nb: This function has a (trivial) display bug which will be obvious\n
51 * when you run it. It's probably easy to fix but I haven't tried,\n
54 static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
61 PLAYER_LEVEL plev = creature_ptr->lev;
65 SPELL_IDX sentaku[32];
66 concptr p = _("必殺剣", "special attack");
70 int menu_line = (use_menu ? 1 : 0);
72 /* Assume cancelled */
75 /* Get the spell, if available */
76 if (repeat_pull(&code))
78 *sn = (SPELL_IDX)code;
79 /* Verify the spell */
80 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
90 for (i = 0; i < 32; i++)
92 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
99 /* Build a prompt (accept all spells) */
100 (void)strnfmt(out_val, 78,
101 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
102 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
104 if (use_menu) screen_save();
105 choice = always_show_list ? ESCAPE : 1;
109 if(choice==ESCAPE) choice = ' ';
110 else if( !get_com(out_val, &choice, FALSE) )break;
112 if (use_menu && choice != ' ')
129 if (menu_line > 32) menu_line -= 32;
130 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
141 if (menu_line > 32) menu_line -= 32;
142 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
153 bool reverse = FALSE;
154 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
161 while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))))
166 if (menu_line < 2) reverse = FALSE;
171 if (menu_line > 31) reverse = TRUE;
189 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
192 if (!redraw || use_menu)
197 if (!use_menu) screen_save();
199 /* Display a list of spells */
201 put_str(_("名前 Lv MP 名前 Lv MP ",
202 "name Lv SP name Lv SP "), y, x + 5);
204 /* Dump the spells */
205 for (i = 0, line = 0; i < 32; i++)
207 spell = technic_info[TECHNIC_HISSATSU][i];
209 if (spell.slevel > PY_MAX_LEVEL) continue;
211 if (!(creature_ptr->spell_learned1 >> i)) break;
213 /* Access the spell */
214 if (spell.slevel > plev) continue;
215 if (!(creature_ptr->spell_learned1 & (1L << i))) continue;
218 if (i == (menu_line-1))
219 strcpy(psi_desc, _(" 》", " > "));
220 else strcpy(psi_desc, " ");
227 letter = I2A(line-1);
229 letter = '0' + line - 27;
230 sprintf(psi_desc, " %c)",letter);
233 /* Dump the spell --(-- */
234 strcat(psi_desc, format(" %-18s%2d %3d",
235 exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME),
236 spell.slevel, spell.smana));
237 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
238 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
259 ask = (isupper(choice));
262 if (ask) choice = (char)tolower(choice);
264 /* Extract request */
265 i = (islower(choice) ? A2I(choice) : -1);
269 ask = FALSE; /* Can't uppercase digits */
271 i = choice - '0' + 26;
275 /* Totally Illegal */
276 if ((i < 0) || (i >= 32) || !(creature_ptr->spell_learned1 & (1 << sentaku[i])))
290 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(creature_ptr, REALM_HISSATSU, j, SPELL_NAME));
292 /* Belay that order */
293 if (!get_check(tmp_val)) continue;
299 if (redraw) screen_load();
301 creature_ptr->window |= (PW_SPELL);
302 handle_stuff(creature_ptr);
304 /* Abort if needed */
305 if (!flag) return FALSE;
307 /* Save the choice */
310 repeat_push((COMMAND_CODE)j);
318 * @brief 剣術コマンドのメインルーチン
321 void do_cmd_hissatsu(player_type *creature_ptr)
326 if (cmd_limit_confused(creature_ptr)) return;
327 if (!has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
329 if (flush_failure) flush();
330 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
333 if (!creature_ptr->spell_learned1)
335 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
339 if (creature_ptr->special_defense & KATA_MASK)
341 set_action(creature_ptr, ACTION_NONE);
344 if (!get_hissatsu_power(creature_ptr, &n)) return;
346 spell = technic_info[TECHNIC_HISSATSU][n];
348 /* Verify "dangerous" spells */
349 if (spell.smana > creature_ptr->csp)
351 if (flush_failure) flush();
353 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
360 if (!exe_spell(creature_ptr, REALM_HISSATSU, n, SPELL_CAST)) return;
362 take_turn(creature_ptr, 100);
365 creature_ptr->csp -= spell.smana;
368 if (creature_ptr->csp < 0) creature_ptr->csp = 0;
369 creature_ptr->redraw |= (PR_MANA);
370 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
378 void do_cmd_gain_hissatsu(player_type *creature_ptr)
388 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
390 set_action(creature_ptr, ACTION_NONE);
393 if (cmd_limit_blind(creature_ptr)) return;
394 if (cmd_limit_confused(creature_ptr)) return;
396 if (!(creature_ptr->new_spells))
398 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
403 msg_format("あと %d 種の必殺技を学べる。", creature_ptr->new_spells);
405 msg_format("You can learn %d new special attack%s.", creature_ptr->new_spells, (creature_ptr->new_spells == 1?"":"s"));
408 q = _("どの書から学びますか? ", "Study which book? ");
409 s = _("読める書がない。", "You have no books that you can read.");
411 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_HISSATSU_BOOK);
414 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
416 if (creature_ptr->spell_learned1 & (1L << i)) continue;
417 if (technic_info[TECHNIC_HISSATSU][i].slevel > creature_ptr->lev) continue;
419 creature_ptr->spell_learned1 |= (1L << i);
420 creature_ptr->spell_worked1 |= (1L << i);
421 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME));
422 for (j = 0; j < 64; j++)
424 /* Stop at the first empty space */
425 if (creature_ptr->spell_order[j] == 99) break;
427 creature_ptr->spell_order[j] = i;
433 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
437 take_turn(creature_ptr, 100);
440 creature_ptr->update |= (PU_SPELLS);