2 * @brief 剣術の実装 / Blade arts
5 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
6 * This software may be copied and distributed for educational, research,\n
7 * and not for profit purposes provided that this copyright and statement\n
8 * are included in all such copies. Other copyrights may also apply.\n
9 * 2014 Deskull rearranged comment for Doxygen.\n
12 #include "action/action-limited.h"
13 #include "cmd-action/cmd-spell.h"
14 #include "core/asking-player.h"
15 #include "core/player-redraw-types.h"
16 #include "core/player-update-types.h"
17 #include "core/stuff-handler.h"
18 #include "core/window-redrawer.h"
19 #include "floor/floor-object.h"
20 #include "game-option/disturbance-options.h"
21 #include "game-option/text-display-options.h"
22 #include "inventory/inventory-slot-types.h"
23 #include "io/command-repeater.h"
24 #include "io/input-key-requester.h"
25 #include "main/sound-definitions-table.h"
26 #include "main/sound-of-music.h"
27 #include "monster-race/monster-race-hook.h"
28 #include "object/item-tester-hooker.h"
29 #include "object/item-use-flags.h"
30 #include "player-info/equipment-info.h"
31 #include "player-status/player-energy.h"
32 #include "player/attack-defense-types.h"
33 #include "player/special-defense-types.h"
34 #include "spell/spells-execution.h"
35 #include "spell/technic-info-table.h"
36 #include "status/action-setter.h"
37 #include "system/object-type-definition.h"
38 #include "system/player-type-definition.h"
39 #include "term/screen-processor.h"
40 #include "util/int-char-converter.h"
41 #include "view/display-messages.h"
43 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
46 * @brief 使用可能な剣術を選択する /
47 * Allow user to choose a blade arts.
48 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
49 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
51 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
52 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
53 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
55 * The "prompt" should be "cast", "recite", or "study"\n
56 * The "known" should be TRUE for cast/pray, FALSE for study\n
58 * nb: This function has a (trivial) display bug which will be obvious\n
59 * when you run it. It's probably easy to fix but I haven't tried,\n
62 static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
69 PLAYER_LEVEL plev = creature_ptr->lev;
73 SPELL_IDX sentaku[32];
74 concptr p = _("必殺剣", "special attack");
78 int menu_line = (use_menu ? 1 : 0);
80 /* Assume cancelled */
83 /* Get the spell, if available */
84 if (repeat_pull(&code)) {
85 *sn = (SPELL_IDX)code;
86 /* Verify the spell */
87 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev) {
96 for (i = 0; i < 32; i++) {
97 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL) {
103 /* Build a prompt (accept all spells) */
104 (void)strnfmt(out_val, 78, _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "), p, I2A(0),
105 "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
109 choice = always_show_list ? ESCAPE : 1;
112 if (choice == ESCAPE)
114 else if (!get_com(out_val, &choice, false))
117 if (use_menu && choice != ' ') {
131 } while (!(creature_ptr->spell_learned1 & (1UL << (menu_line - 1))));
142 } while (!(creature_ptr->spell_learned1 & (1UL << (menu_line - 1))));
152 bool reverse = false;
153 if ((choice == '4') || (choice == 'h') || (choice == 'H'))
155 if (menu_line > 16) {
160 while (!(creature_ptr->spell_learned1 & (1UL << (menu_line - 1)))) {
185 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask)) {
187 if (!redraw || use_menu) {
194 /* Display a list of spells */
196 put_str(_("名前 Lv MP 名前 Lv MP ", "name Lv SP name Lv SP "), y, x + 5);
198 /* Dump the spells */
199 for (i = 0, line = 0; i < 32; i++) {
200 spell = technic_info[TECHNIC_HISSATSU][i];
202 if (spell.slevel > PY_MAX_LEVEL)
205 if (!(creature_ptr->spell_learned1 >> i))
208 /* Access the spell */
209 if (spell.slevel > plev)
211 if (!(creature_ptr->spell_learned1 & (1UL << i)))
214 if (i == (menu_line - 1))
215 strcpy(psi_desc, _(" 》", " > "));
217 strcpy(psi_desc, " ");
222 letter = I2A(line - 1);
224 letter = '0' + line - 27;
225 sprintf(psi_desc, " %c)", letter);
228 /* Dump the spell --(-- */
229 strcat(psi_desc, format(" %-18s%2d %3d", exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME), spell.slevel, spell.smana));
230 prt(psi_desc, y + (line % 17) + (line >= 17), x + (line / 17) * 30);
231 prt("", y + (line % 17) + (line >= 17) + 1, x + (line / 17) * 30);
247 if (isalpha(choice)) {
249 ask = (isupper(choice));
253 choice = (char)tolower(choice);
255 /* Extract request */
256 i = (islower(choice) ? A2I(choice) : -1);
258 ask = false; /* Can't uppercase digits */
260 i = choice - '0' + 26;
264 /* Totally Illegal */
265 if ((i < 0) || (i >= 32) || !(creature_ptr->spell_learned1 & (1U << sentaku[i]))) {
277 (void)strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(creature_ptr, REALM_HISSATSU, j, SPELL_NAME));
279 /* Belay that order */
280 if (!get_check(tmp_val))
290 creature_ptr->window_flags |= (PW_SPELL);
291 handle_stuff(creature_ptr);
293 /* Abort if needed */
297 /* Save the choice */
300 repeat_push((COMMAND_CODE)j);
307 * @brief 剣術コマンドのメインルーチン
309 void do_cmd_hissatsu(player_type *creature_ptr)
314 if (cmd_limit_confused(creature_ptr))
316 if (!has_melee_weapon(creature_ptr, INVEN_MAIN_HAND) && !has_melee_weapon(creature_ptr, INVEN_SUB_HAND)) {
319 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
322 if (!creature_ptr->spell_learned1) {
323 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
327 if (creature_ptr->special_defense & KATA_MASK) {
328 set_action(creature_ptr, ACTION_NONE);
331 if (!get_hissatsu_power(creature_ptr, &n))
334 spell = technic_info[TECHNIC_HISSATSU][n];
336 /* Verify "dangerous" spells */
337 if (spell.smana > creature_ptr->csp) {
341 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
348 if (!exe_spell(creature_ptr, REALM_HISSATSU, n, SPELL_CAST))
351 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
354 creature_ptr->csp -= spell.smana;
357 if (creature_ptr->csp < 0)
358 creature_ptr->csp = 0;
359 creature_ptr->redraw |= (PR_MANA);
360 creature_ptr->window_flags |= (PW_PLAYER | PW_SPELL);
366 void do_cmd_gain_hissatsu(player_type *creature_ptr)
376 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN)) {
377 set_action(creature_ptr, ACTION_NONE);
380 if (cmd_limit_blind(creature_ptr))
382 if (cmd_limit_confused(creature_ptr))
385 if (!(creature_ptr->new_spells)) {
386 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
391 msg_format("あと %d 種の必殺技を学べる。", creature_ptr->new_spells);
393 msg_format("You can learn %d new special attack%s.", creature_ptr->new_spells, (creature_ptr->new_spells == 1 ? "" : "s"));
396 q = _("どの書から学びますか? ", "Study which book? ");
397 s = _("読める書がない。", "You have no books that you can read.");
399 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TvalItemTester(TV_HISSATSU_BOOK));
403 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++) {
404 if (creature_ptr->spell_learned1 & (1UL << i))
406 if (technic_info[TECHNIC_HISSATSU][i].slevel > creature_ptr->lev)
409 creature_ptr->spell_learned1 |= (1UL << i);
410 creature_ptr->spell_worked1 |= (1UL << i);
411 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME));
412 for (j = 0; j < 64; j++) {
413 /* Stop at the first empty space */
414 if (creature_ptr->spell_order[j] == 99)
417 creature_ptr->spell_order[j] = i;
422 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
424 PlayerEnergy(creature_ptr).set_player_turn_energy(100);
427 creature_ptr->update |= (PU_SPELLS);