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
17 #include "monsterrace-hook.h"
18 #include "player-status.h"
19 #include "player-effects.h"
22 #include "cmd-basic.h"
23 #include "cmd-spell.h"
24 #include "view-mainwindow.h"
26 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
30 * @brief 使用可能な剣術を選択する /
31 * Allow user to choose a blade arts.
32 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
33 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
35 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
36 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
37 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
39 * The "prompt" should be "cast", "recite", or "study"\n
40 * The "known" should be TRUE for cast/pray, FALSE for study\n
42 * nb: This function has a (trivial) display bug which will be obvious\n
43 * when you run it. It's probably easy to fix but I haven't tried,\n
46 static int get_hissatsu_power(SPELL_IDX *sn)
53 PLAYER_LEVEL plev = p_ptr->lev;
57 SPELL_IDX sentaku[32];
58 concptr p = _("必殺剣", "special attack");
62 int menu_line = (use_menu ? 1 : 0);
64 /* Assume cancelled */
67 /* Get the spell, if available */
68 if (repeat_pull(&code))
70 *sn = (SPELL_IDX)code;
71 /* Verify the spell */
72 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
79 /* Nothing chosen yet */
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(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
136 if (menu_line > 32) menu_line -= 32;
137 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
148 bool reverse = FALSE;
149 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
156 while(!(p_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 (!(p_ptr->spell_learned1 >> i)) break;
208 /* Access the spell */
209 if (spell.slevel > plev) continue;
210 if (!(p_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 do_spell(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) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
285 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
287 /* Belay that order */
288 if (!get_check(tmp_val)) continue;
294 if (redraw) screen_load();
296 p_ptr->window |= (PW_SPELL);
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(void)
321 if (cmd_limit_confused(p_ptr)) return;
322 if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
324 if (flush_failure) flush();
325 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
328 if (!p_ptr->spell_learned1)
330 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
334 if (p_ptr->special_defense & KATA_MASK)
336 set_action(ACTION_NONE);
339 if (!get_hissatsu_power(&n)) return;
341 spell = technic_info[TECHNIC_HISSATSU][n];
343 /* Verify "dangerous" spells */
344 if (spell.smana > p_ptr->csp)
346 if (flush_failure) flush();
348 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
355 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
357 take_turn(p_ptr, 100);
360 p_ptr->csp -= spell.smana;
363 if (p_ptr->csp < 0) p_ptr->csp = 0;
364 p_ptr->redraw |= (PR_MANA);
365 p_ptr->window |= (PW_PLAYER | PW_SPELL);
373 void do_cmd_gain_hissatsu(void)
383 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
385 set_action(ACTION_NONE);
388 if (p_ptr->blind || no_lite())
390 msg_print(_("目が見えない!", "You cannot see!"));
394 if (cmd_limit_confused(p_ptr)) return;
396 if (!(p_ptr->new_spells))
398 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
403 msg_format("あと %d 種の必殺技を学べる。", p_ptr->new_spells);
405 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells, (p_ptr->new_spells == 1?"":"s"));
408 item_tester_tval = TV_HISSATSU_BOOK;
410 q = _("どの書から学びますか? ", "Study which book? ");
411 s = _("読める書がない。", "You have no books that you can read.");
413 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR), item_tester_tval);
416 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
418 if (p_ptr->spell_learned1 & (1L << i)) continue;
419 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
421 p_ptr->spell_learned1 |= (1L << i);
422 p_ptr->spell_worked1 |= (1L << i);
423 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
424 for (j = 0; j < 64; j++)
426 /* Stop at the first empty space */
427 if (p_ptr->spell_order[j] == 99) break;
429 p_ptr->spell_order[j] = i;
435 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
439 take_turn(p_ptr, 100);
442 p_ptr->update |= (PU_SPELLS);