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
14 #include "core/stuff-handler.h"
16 #include "main/sound-definitions-table.h"
18 #include "monsterrace-hook.h"
19 #include "player-status.h"
20 #include "player-effects.h"
21 #include "player-inventory.h"
22 #include "spell/technic-info-table.h"
24 #include "cmd-basic.h"
25 #include "cmd-spell.h"
26 #include "view/display-main-window.h"
27 #include "spell/spells-util.h"
28 #include "spell/spells-execution.h"
30 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
33 * @brief 使用可能な剣術を選択する /
34 * Allow user to choose a blade arts.
35 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
36 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
38 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
39 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
40 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
42 * The "prompt" should be "cast", "recite", or "study"\n
43 * The "known" should be TRUE for cast/pray, FALSE for study\n
45 * nb: This function has a (trivial) display bug which will be obvious\n
46 * when you run it. It's probably easy to fix but I haven't tried,\n
49 static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
56 PLAYER_LEVEL plev = creature_ptr->lev;
60 SPELL_IDX sentaku[32];
61 concptr p = _("必殺剣", "special attack");
65 int menu_line = (use_menu ? 1 : 0);
67 /* Assume cancelled */
70 /* Get the spell, if available */
71 if (repeat_pull(&code))
73 *sn = (SPELL_IDX)code;
74 /* Verify the spell */
75 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
85 for (i = 0; i < 32; i++)
87 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
94 /* Build a prompt (accept all spells) */
95 (void)strnfmt(out_val, 78,
96 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
97 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
99 if (use_menu) screen_save();
100 choice = always_show_list ? ESCAPE : 1;
104 if(choice==ESCAPE) choice = ' ';
105 else if( !get_com(out_val, &choice, FALSE) )break;
107 if (use_menu && choice != ' ')
124 if (menu_line > 32) menu_line -= 32;
125 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
136 if (menu_line > 32) menu_line -= 32;
137 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
148 bool reverse = FALSE;
149 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
156 while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))))
161 if (menu_line < 2) reverse = FALSE;
166 if (menu_line > 31) reverse = TRUE;
184 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
187 if (!redraw || use_menu)
192 if (!use_menu) screen_save();
194 /* Display a list of spells */
196 put_str(_("名前 Lv MP 名前 Lv MP ",
197 "name Lv SP name Lv SP "), y, x + 5);
199 /* Dump the spells */
200 for (i = 0, line = 0; i < 32; i++)
202 spell = technic_info[TECHNIC_HISSATSU][i];
204 if (spell.slevel > PY_MAX_LEVEL) continue;
206 if (!(creature_ptr->spell_learned1 >> i)) break;
208 /* Access the spell */
209 if (spell.slevel > plev) continue;
210 if (!(creature_ptr->spell_learned1 & (1L << i))) continue;
213 if (i == (menu_line-1))
214 strcpy(psi_desc, _(" 》", " > "));
215 else 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",
230 exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME),
231 spell.slevel, spell.smana));
232 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
233 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
254 ask = (isupper(choice));
257 if (ask) choice = (char)tolower(choice);
259 /* Extract request */
260 i = (islower(choice) ? A2I(choice) : -1);
264 ask = FALSE; /* Can't uppercase digits */
266 i = choice - '0' + 26;
270 /* Totally Illegal */
271 if ((i < 0) || (i >= 32) || !(creature_ptr->spell_learned1 & (1 << sentaku[i])))
285 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(creature_ptr, REALM_HISSATSU, j, SPELL_NAME));
287 /* Belay that order */
288 if (!get_check(tmp_val)) continue;
294 if (redraw) screen_load();
296 creature_ptr->window |= (PW_SPELL);
297 handle_stuff(creature_ptr);
299 /* Abort if needed */
300 if (!flag) return FALSE;
302 /* Save the choice */
305 repeat_push((COMMAND_CODE)j);
313 * @brief 剣術コマンドのメインルーチン
316 void do_cmd_hissatsu(player_type *creature_ptr)
321 if (cmd_limit_confused(creature_ptr)) return;
322 if (!has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
324 if (flush_failure) flush();
325 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
328 if (!creature_ptr->spell_learned1)
330 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
334 if (creature_ptr->special_defense & KATA_MASK)
336 set_action(creature_ptr, ACTION_NONE);
339 if (!get_hissatsu_power(creature_ptr, &n)) return;
341 spell = technic_info[TECHNIC_HISSATSU][n];
343 /* Verify "dangerous" spells */
344 if (spell.smana > creature_ptr->csp)
346 if (flush_failure) flush();
348 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
355 if (!exe_spell(creature_ptr, REALM_HISSATSU, n, SPELL_CAST)) return;
357 take_turn(creature_ptr, 100);
360 creature_ptr->csp -= spell.smana;
363 if (creature_ptr->csp < 0) creature_ptr->csp = 0;
364 creature_ptr->redraw |= (PR_MANA);
365 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
373 void do_cmd_gain_hissatsu(player_type *creature_ptr)
383 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
385 set_action(creature_ptr, ACTION_NONE);
388 if (cmd_limit_blind(creature_ptr)) return;
389 if (cmd_limit_confused(creature_ptr)) return;
391 if (!(creature_ptr->new_spells))
393 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
398 msg_format("あと %d 種の必殺技を学べる。", creature_ptr->new_spells);
400 msg_format("You can learn %d new special attack%s.", creature_ptr->new_spells, (creature_ptr->new_spells == 1?"":"s"));
403 q = _("どの書から学びますか? ", "Study which book? ");
404 s = _("読める書がない。", "You have no books that you can read.");
406 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_HISSATSU_BOOK);
409 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
411 if (creature_ptr->spell_learned1 & (1L << i)) continue;
412 if (technic_info[TECHNIC_HISSATSU][i].slevel > creature_ptr->lev) continue;
414 creature_ptr->spell_learned1 |= (1L << i);
415 creature_ptr->spell_worked1 |= (1L << i);
416 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME));
417 for (j = 0; j < 64; j++)
419 /* Stop at the first empty space */
420 if (creature_ptr->spell_order[j] == 99) break;
422 creature_ptr->spell_order[j] = i;
428 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
432 take_turn(creature_ptr, 100);
435 creature_ptr->update |= (PU_SPELLS);