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"
25 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
29 * @brief 使用可能な剣術を選択する /
30 * Allow user to choose a blade arts.
31 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
32 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
34 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
35 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
36 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
38 * The "prompt" should be "cast", "recite", or "study"\n
39 * The "known" should be TRUE for cast/pray, FALSE for study\n
41 * nb: This function has a (trivial) display bug which will be obvious\n
42 * when you run it. It's probably easy to fix but I haven't tried,\n
45 static int get_hissatsu_power(SPELL_IDX *sn)
52 PLAYER_LEVEL plev = p_ptr->lev;
56 SPELL_IDX sentaku[32];
57 concptr p = _("必殺剣", "special attack");
61 int menu_line = (use_menu ? 1 : 0);
63 /* Assume cancelled */
66 /* Get the spell, if available */
67 if (repeat_pull(&code))
69 *sn = (SPELL_IDX)code;
70 /* Verify the spell */
71 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
78 /* Nothing chosen yet */
84 for (i = 0; i < 32; i++)
86 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
93 /* Build a prompt (accept all spells) */
94 (void)strnfmt(out_val, 78,
95 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
96 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
98 if (use_menu) screen_save();
99 choice = always_show_list ? ESCAPE : 1;
103 if(choice==ESCAPE) choice = ' ';
104 else if( !get_com(out_val, &choice, FALSE) )break;
106 if (use_menu && choice != ' ')
123 if (menu_line > 32) menu_line -= 32;
124 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
135 if (menu_line > 32) menu_line -= 32;
136 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
147 bool reverse = FALSE;
148 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
155 while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
160 if (menu_line < 2) reverse = FALSE;
165 if (menu_line > 31) reverse = TRUE;
183 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
186 if (!redraw || use_menu)
191 if (!use_menu) screen_save();
193 /* Display a list of spells */
195 put_str(_("名前 Lv MP 名前 Lv MP ",
196 "name Lv SP name Lv SP "), y, x + 5);
198 /* Dump the spells */
199 for (i = 0, line = 0; i < 32; i++)
201 spell = technic_info[TECHNIC_HISSATSU][i];
203 if (spell.slevel > PY_MAX_LEVEL) continue;
205 if (!(p_ptr->spell_learned1 >> i)) break;
207 /* Access the spell */
208 if (spell.slevel > plev) continue;
209 if (!(p_ptr->spell_learned1 & (1L << i))) continue;
212 if (i == (menu_line-1))
213 strcpy(psi_desc, _(" 》", " > "));
214 else strcpy(psi_desc, " ");
221 letter = I2A(line-1);
223 letter = '0' + line - 27;
224 sprintf(psi_desc, " %c)",letter);
227 /* Dump the spell --(-- */
228 strcat(psi_desc, format(" %-18s%2d %3d",
229 do_spell(REALM_HISSATSU, i, SPELL_NAME),
230 spell.slevel, spell.smana));
231 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
232 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
253 ask = (isupper(choice));
256 if (ask) choice = (char)tolower(choice);
258 /* Extract request */
259 i = (islower(choice) ? A2I(choice) : -1);
263 ask = FALSE; /* Can't uppercase digits */
265 i = choice - '0' + 26;
269 /* Totally Illegal */
270 if ((i < 0) || (i >= 32) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
284 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
286 /* Belay that order */
287 if (!get_check(tmp_val)) continue;
293 if (redraw) screen_load();
295 p_ptr->window |= (PW_SPELL);
298 /* Abort if needed */
299 if (!flag) return (FALSE);
301 /* Save the choice */
304 repeat_push((COMMAND_CODE)j);
312 * @brief 剣術コマンドのメインルーチン
315 void do_cmd_hissatsu(void)
320 if (cmd_limit_confused(p_ptr)) return;
321 if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
323 if (flush_failure) flush();
324 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
327 if (!p_ptr->spell_learned1)
329 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
333 if (p_ptr->special_defense & KATA_MASK)
335 set_action(ACTION_NONE);
338 if (!get_hissatsu_power(&n)) return;
340 spell = technic_info[TECHNIC_HISSATSU][n];
342 /* Verify "dangerous" spells */
343 if (spell.smana > p_ptr->csp)
345 if (flush_failure) flush();
347 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
354 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
356 take_turn(p_ptr, 100);
359 p_ptr->csp -= spell.smana;
362 if (p_ptr->csp < 0) p_ptr->csp = 0;
363 p_ptr->redraw |= (PR_MANA);
364 p_ptr->window |= (PW_PLAYER | PW_SPELL);
372 void do_cmd_gain_hissatsu(void)
382 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
384 set_action(ACTION_NONE);
387 if (p_ptr->blind || no_lite())
389 msg_print(_("目が見えない!", "You cannot see!"));
393 if (cmd_limit_confused(p_ptr)) return;
395 if (!(p_ptr->new_spells))
397 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
402 msg_format("あと %d 種の必殺技を学べる。", p_ptr->new_spells);
404 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells, (p_ptr->new_spells == 1?"":"s"));
407 item_tester_tval = TV_HISSATSU_BOOK;
409 q = _("どの書から学びますか? ", "Study which book? ");
410 s = _("読める書がない。", "You have no books that you can read.");
412 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
415 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
417 if (p_ptr->spell_learned1 & (1L << i)) continue;
418 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
420 p_ptr->spell_learned1 |= (1L << i);
421 p_ptr->spell_worked1 |= (1L << i);
422 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
423 for (j = 0; j < 64; j++)
425 /* Stop at the first empty space */
426 if (p_ptr->spell_order[j] == 99) break;
428 p_ptr->spell_order[j] = i;
434 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
438 take_turn(p_ptr, 100);
441 p_ptr->update |= (PU_SPELLS);