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 "monsterrace-hook.h"
15 #include "player-status.h"
17 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
21 * @brief 使用可能な剣術を選択する /
22 * Allow user to choose a blade arts.
23 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
24 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
26 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
27 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
28 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
30 * The "prompt" should be "cast", "recite", or "study"\n
31 * The "known" should be TRUE for cast/pray, FALSE for study\n
33 * nb: This function has a (trivial) display bug which will be obvious\n
34 * when you run it. It's probably easy to fix but I haven't tried,\n
37 static int get_hissatsu_power(SPELL_IDX *sn)
44 PLAYER_LEVEL plev = p_ptr->lev;
48 SPELL_IDX sentaku[32];
49 concptr p = _("必殺剣", "special attack");
53 int menu_line = (use_menu ? 1 : 0);
55 /* Assume cancelled */
58 /* Get the spell, if available */
59 if (repeat_pull(&code))
61 *sn = (SPELL_IDX)code;
62 /* Verify the spell */
63 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
70 /* Nothing chosen yet */
76 for (i = 0; i < 32; i++)
78 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
85 /* Build a prompt (accept all spells) */
86 (void)strnfmt(out_val, 78,
87 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
88 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
90 if (use_menu) screen_save();
91 choice = always_show_list ? ESCAPE : 1;
95 if(choice==ESCAPE) choice = ' ';
96 else if( !get_com(out_val, &choice, FALSE) )break;
98 if (use_menu && choice != ' ')
115 if (menu_line > 32) menu_line -= 32;
116 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
127 if (menu_line > 32) menu_line -= 32;
128 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
139 bool reverse = FALSE;
140 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
147 while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
152 if (menu_line < 2) reverse = FALSE;
157 if (menu_line > 31) reverse = TRUE;
175 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
178 if (!redraw || use_menu)
183 if (!use_menu) screen_save();
185 /* Display a list of spells */
187 put_str(_("名前 Lv MP 名前 Lv MP ",
188 "name Lv SP name Lv SP "), y, x + 5);
190 /* Dump the spells */
191 for (i = 0, line = 0; i < 32; i++)
193 spell = technic_info[TECHNIC_HISSATSU][i];
195 if (spell.slevel > PY_MAX_LEVEL) continue;
197 if (!(p_ptr->spell_learned1 >> i)) break;
199 /* Access the spell */
200 if (spell.slevel > plev) continue;
201 if (!(p_ptr->spell_learned1 & (1L << i))) continue;
204 if (i == (menu_line-1))
205 strcpy(psi_desc, _(" 》", " > "));
206 else strcpy(psi_desc, " ");
213 letter = I2A(line-1);
215 letter = '0' + line - 27;
216 sprintf(psi_desc, " %c)",letter);
219 /* Dump the spell --(-- */
220 strcat(psi_desc, format(" %-18s%2d %3d",
221 do_spell(REALM_HISSATSU, i, SPELL_NAME),
222 spell.slevel, spell.smana));
223 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
224 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
245 ask = (isupper(choice));
248 if (ask) choice = (char)tolower(choice);
250 /* Extract request */
251 i = (islower(choice) ? A2I(choice) : -1);
255 ask = FALSE; /* Can't uppercase digits */
257 i = choice - '0' + 26;
261 /* Totally Illegal */
262 if ((i < 0) || (i >= 32) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
276 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
278 /* Belay that order */
279 if (!get_check(tmp_val)) continue;
285 if (redraw) screen_load();
287 p_ptr->window |= (PW_SPELL);
290 /* Abort if needed */
291 if (!flag) return (FALSE);
293 /* Save the choice */
296 repeat_push((COMMAND_CODE)j);
304 * @brief 剣術コマンドのメインルーチン
307 void do_cmd_hissatsu(void)
312 if (cmd_limit_confused(p_ptr)) return;
313 if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
315 if (flush_failure) flush();
316 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
319 if (!p_ptr->spell_learned1)
321 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
325 if (p_ptr->special_defense & KATA_MASK)
327 set_action(ACTION_NONE);
330 if (!get_hissatsu_power(&n)) return;
332 spell = technic_info[TECHNIC_HISSATSU][n];
334 /* Verify "dangerous" spells */
335 if (spell.smana > p_ptr->csp)
337 if (flush_failure) flush();
339 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
346 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
348 take_turn(p_ptr, 100);
351 p_ptr->csp -= spell.smana;
354 if (p_ptr->csp < 0) p_ptr->csp = 0;
355 p_ptr->redraw |= (PR_MANA);
356 p_ptr->window |= (PW_PLAYER | PW_SPELL);
364 void do_cmd_gain_hissatsu(void)
374 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
376 set_action(ACTION_NONE);
379 if (p_ptr->blind || no_lite())
381 msg_print(_("目が見えない!", "You cannot see!"));
385 if (cmd_limit_confused(p_ptr)) return;
387 if (!(p_ptr->new_spells))
389 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
394 msg_format("あと %d 種の必殺技を学べる。", p_ptr->new_spells);
396 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells, (p_ptr->new_spells == 1?"":"s"));
399 item_tester_tval = TV_HISSATSU_BOOK;
401 q = _("どの書から学びますか? ", "Study which book? ");
402 s = _("読める書がない。", "You have no books that you can read.");
404 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
407 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
409 if (p_ptr->spell_learned1 & (1L << i)) continue;
410 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
412 p_ptr->spell_learned1 |= (1L << i);
413 p_ptr->spell_worked1 |= (1L << i);
414 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
415 for (j = 0; j < 64; j++)
417 /* Stop at the first empty space */
418 if (p_ptr->spell_order[j] == 99) break;
420 p_ptr->spell_order[j] = i;
426 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
430 take_turn(p_ptr, 100);
433 p_ptr->update |= (PU_SPELLS);