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"
20 #include "player-inventory.h"
23 #include "cmd-basic.h"
24 #include "cmd-spell.h"
25 #include "view-mainwindow.h"
27 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
31 * @brief 使用可能な剣術を選択する /
32 * Allow user to choose a blade arts.
33 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
34 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
36 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
37 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
38 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
40 * The "prompt" should be "cast", "recite", or "study"\n
41 * The "known" should be TRUE for cast/pray, FALSE for study\n
43 * nb: This function has a (trivial) display bug which will be obvious\n
44 * when you run it. It's probably easy to fix but I haven't tried,\n
47 static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
54 PLAYER_LEVEL plev = creature_ptr->lev;
58 SPELL_IDX sentaku[32];
59 concptr p = _("必殺剣", "special attack");
63 int menu_line = (use_menu ? 1 : 0);
65 /* Assume cancelled */
68 /* Get the spell, if available */
69 if (repeat_pull(&code))
71 *sn = (SPELL_IDX)code;
72 /* Verify the spell */
73 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
83 for (i = 0; i < 32; i++)
85 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
92 /* Build a prompt (accept all spells) */
93 (void)strnfmt(out_val, 78,
94 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
95 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num - 1], p);
97 if (use_menu) screen_save();
98 choice = always_show_list ? ESCAPE : 1;
102 if(choice==ESCAPE) choice = ' ';
103 else if( !get_com(out_val, &choice, FALSE) )break;
105 if (use_menu && choice != ' ')
122 if (menu_line > 32) menu_line -= 32;
123 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
134 if (menu_line > 32) menu_line -= 32;
135 } while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))));
146 bool reverse = FALSE;
147 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
154 while(!(creature_ptr->spell_learned1 & (1L << (menu_line-1))))
159 if (menu_line < 2) reverse = FALSE;
164 if (menu_line > 31) reverse = TRUE;
182 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
185 if (!redraw || use_menu)
190 if (!use_menu) screen_save();
192 /* Display a list of spells */
194 put_str(_("名前 Lv MP 名前 Lv MP ",
195 "name Lv SP name Lv SP "), y, x + 5);
197 /* Dump the spells */
198 for (i = 0, line = 0; i < 32; i++)
200 spell = technic_info[TECHNIC_HISSATSU][i];
202 if (spell.slevel > PY_MAX_LEVEL) continue;
204 if (!(creature_ptr->spell_learned1 >> i)) break;
206 /* Access the spell */
207 if (spell.slevel > plev) continue;
208 if (!(creature_ptr->spell_learned1 & (1L << i))) continue;
211 if (i == (menu_line-1))
212 strcpy(psi_desc, _(" 》", " > "));
213 else strcpy(psi_desc, " ");
220 letter = I2A(line-1);
222 letter = '0' + line - 27;
223 sprintf(psi_desc, " %c)",letter);
226 /* Dump the spell --(-- */
227 strcat(psi_desc, format(" %-18s%2d %3d",
228 exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME),
229 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);
252 ask = (isupper(choice));
255 if (ask) choice = (char)tolower(choice);
257 /* Extract request */
258 i = (islower(choice) ? A2I(choice) : -1);
262 ask = FALSE; /* Can't uppercase digits */
264 i = choice - '0' + 26;
268 /* Totally Illegal */
269 if ((i < 0) || (i >= 32) || !(creature_ptr->spell_learned1 & (1 << sentaku[i])))
283 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(creature_ptr, REALM_HISSATSU, j, SPELL_NAME));
285 /* Belay that order */
286 if (!get_check(tmp_val)) continue;
292 if (redraw) screen_load();
294 creature_ptr->window |= (PW_SPELL);
295 handle_stuff(creature_ptr);
297 /* Abort if needed */
298 if (!flag) return (FALSE);
300 /* Save the choice */
303 repeat_push((COMMAND_CODE)j);
311 * @brief 剣術コマンドのメインルーチン
314 void do_cmd_hissatsu(player_type *creature_ptr)
319 if (cmd_limit_confused(creature_ptr)) return;
320 if (!has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
322 if (flush_failure) flush();
323 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
326 if (!creature_ptr->spell_learned1)
328 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
332 if (creature_ptr->special_defense & KATA_MASK)
334 set_action(creature_ptr, ACTION_NONE);
337 if (!get_hissatsu_power(creature_ptr, &n)) return;
339 spell = technic_info[TECHNIC_HISSATSU][n];
341 /* Verify "dangerous" spells */
342 if (spell.smana > creature_ptr->csp)
344 if (flush_failure) flush();
346 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
353 if (!exe_spell(creature_ptr, REALM_HISSATSU, n, SPELL_CAST)) return;
355 take_turn(creature_ptr, 100);
358 creature_ptr->csp -= spell.smana;
361 if (creature_ptr->csp < 0) creature_ptr->csp = 0;
362 creature_ptr->redraw |= (PR_MANA);
363 creature_ptr->window |= (PW_PLAYER | PW_SPELL);
371 void do_cmd_gain_hissatsu(player_type *creature_ptr)
381 if (creature_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
383 set_action(creature_ptr, ACTION_NONE);
386 if (cmd_limit_blind(creature_ptr)) return;
387 if (cmd_limit_confused(creature_ptr)) return;
389 if (!(creature_ptr->new_spells))
391 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
396 msg_format("あと %d 種の必殺技を学べる。", creature_ptr->new_spells);
398 msg_format("You can learn %d new special attack%s.", creature_ptr->new_spells, (creature_ptr->new_spells == 1?"":"s"));
401 q = _("どの書から学びますか? ", "Study which book? ");
402 s = _("読める書がない。", "You have no books that you can read.");
404 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_HISSATSU_BOOK);
407 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
409 if (creature_ptr->spell_learned1 & (1L << i)) continue;
410 if (technic_info[TECHNIC_HISSATSU][i].slevel > creature_ptr->lev) continue;
412 creature_ptr->spell_learned1 |= (1L << i);
413 creature_ptr->spell_worked1 |= (1L << i);
414 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(creature_ptr, REALM_HISSATSU, i, SPELL_NAME));
415 for (j = 0; j < 64; j++)
417 /* Stop at the first empty space */
418 if (creature_ptr->spell_order[j] == 99) break;
420 creature_ptr->spell_order[j] = i;
426 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
430 take_turn(creature_ptr, 100);
433 creature_ptr->update |= (PU_SPELLS);