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();
92 /* Get a spell from the user */
94 choice= always_show_list ? ESCAPE:1 ;
97 if(choice==ESCAPE) choice = ' ';
98 else if( !get_com(out_val, &choice, FALSE) )break;
100 if (use_menu && choice != ' ')
117 if (menu_line > 32) menu_line -= 32;
118 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
129 if (menu_line > 32) menu_line -= 32;
130 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
141 bool reverse = FALSE;
142 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
149 while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
154 if (menu_line < 2) reverse = FALSE;
159 if (menu_line > 31) reverse = TRUE;
177 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
180 if (!redraw || use_menu)
187 if (!use_menu) screen_save();
189 /* Display a list of spells */
191 put_str(_("名前 Lv MP 名前 Lv MP ",
192 "name Lv SP name Lv SP "), y, x + 5);
194 /* Dump the spells */
195 for (i = 0, line = 0; i < 32; i++)
197 spell = technic_info[TECHNIC_HISSATSU][i];
199 if (spell.slevel > PY_MAX_LEVEL) continue;
201 if (!(p_ptr->spell_learned1 >> i)) break;
203 /* Access the spell */
204 if (spell.slevel > plev) continue;
205 if (!(p_ptr->spell_learned1 & (1L << i))) continue;
208 if (i == (menu_line-1))
209 strcpy(psi_desc, _(" 》", " > "));
210 else strcpy(psi_desc, " ");
217 letter = I2A(line-1);
219 letter = '0' + line - 27;
220 sprintf(psi_desc, " %c)",letter);
223 /* Dump the spell --(-- */
224 strcat(psi_desc, format(" %-18s%2d %3d",
225 do_spell(REALM_HISSATSU, i, SPELL_NAME),
226 spell.slevel, spell.smana));
227 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
228 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
249 ask = (isupper(choice));
252 if (ask) choice = (char)tolower(choice);
254 /* Extract request */
255 i = (islower(choice) ? A2I(choice) : -1);
259 ask = FALSE; /* Can't uppercase digits */
261 i = choice - '0' + 26;
265 /* Totally Illegal */
266 if ((i < 0) || (i >= 32) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
280 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
282 /* Belay that order */
283 if (!get_check(tmp_val)) continue;
289 if (redraw) screen_load();
291 p_ptr->window |= (PW_SPELL);
294 /* Abort if needed */
295 if (!flag) return (FALSE);
297 /* Save the choice */
300 repeat_push((COMMAND_CODE)j);
308 * @brief 剣術コマンドのメインルーチン
311 void do_cmd_hissatsu(void)
316 /* not if confused */
319 msg_print(_("混乱していて集中できない!", "You are too confused!"));
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);
340 if (!get_hissatsu_power(&n)) return;
342 spell = technic_info[TECHNIC_HISSATSU][n];
344 /* Verify "dangerous" spells */
345 if (spell.smana > p_ptr->csp)
347 if (flush_failure) flush();
349 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
357 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
359 p_ptr->energy_use = 100;
362 p_ptr->csp -= spell.smana;
365 if (p_ptr->csp < 0) p_ptr->csp = 0;
366 p_ptr->redraw |= (PR_MANA);
368 p_ptr->window |= (PW_PLAYER);
369 p_ptr->window |= (PW_SPELL);
377 void do_cmd_gain_hissatsu(void)
387 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
389 set_action(ACTION_NONE);
392 if (p_ptr->blind || no_lite())
394 msg_print(_("目が見えない!", "You cannot see!"));
400 msg_print(_("混乱していて読めない!", "You are too confused!"));
404 if (!(p_ptr->new_spells))
406 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
411 if( p_ptr->new_spells < 10 ){
412 msg_format("あと %d つの必殺技を学べる。", p_ptr->new_spells);
414 msg_format("あと %d 個の必殺技を学べる。", p_ptr->new_spells);
417 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells,
418 (p_ptr->new_spells == 1?"":"s"));
421 item_tester_tval = TV_HISSATSU_BOOK;
423 q = _("どの書から学びますか? ", "Study which book? ");
424 s = _("読める書がない。", "You have no books that you can read.");
426 o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
429 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
431 if (p_ptr->spell_learned1 & (1L << i)) continue;
432 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
434 p_ptr->spell_learned1 |= (1L << i);
435 p_ptr->spell_worked1 |= (1L << i);
436 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
437 for (j = 0; j < 64; j++)
439 /* Stop at the first empty space */
440 if (p_ptr->spell_order[j] == 99) break;
442 p_ptr->spell_order[j] = i;
448 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
451 p_ptr->energy_use = 100;
453 p_ptr->update |= (PU_SPELLS);
458 * @brief 剣術のスレイ倍率計算を行う /
459 * Calcurate magnification of hissatsu technics
460 * @param mult 剣術のスレイ効果以前に算出している多要素の倍率(/10倍)
461 * @param flgs 剣術に使用する武器のスレイフラグ配列
462 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
463 * @param mode 剣術のスレイ型ID
464 * @return スレイの倍率(/10倍)
466 MULTIPLY mult_hissatsu(MULTIPLY mult, BIT_FLAGS *flgs, monster_type *m_ptr, BIT_FLAGS mode)
468 monster_race *r_ptr = &r_info[m_ptr->r_idx];
470 /* Burning Strike (Fire) */
471 if (mode == HISSATSU_FIRE)
473 /* Notice immunity */
474 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
476 if (is_original_ap_and_seen(m_ptr))
478 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
482 /* Otherwise, take the damage */
483 else if (have_flag(flgs, TR_BRAND_FIRE))
485 if (r_ptr->flags3 & RF3_HURT_FIRE)
487 if (mult < 70) mult = 70;
488 if (is_original_ap_and_seen(m_ptr))
490 r_ptr->r_flags3 |= RF3_HURT_FIRE;
493 else if (mult < 35) mult = 35;
497 if (r_ptr->flags3 & RF3_HURT_FIRE)
499 if (mult < 50) mult = 50;
500 if (is_original_ap_and_seen(m_ptr))
502 r_ptr->r_flags3 |= RF3_HURT_FIRE;
505 else if (mult < 25) mult = 25;
509 /* Serpent's Tongue (Poison) */
510 if (mode == HISSATSU_POISON)
512 /* Notice immunity */
513 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
515 if (is_original_ap_and_seen(m_ptr))
517 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
521 /* Otherwise, take the damage */
522 else if (have_flag(flgs, TR_BRAND_POIS))
524 if (mult < 35) mult = 35;
528 if (mult < 25) mult = 25;
532 /* Zammaken (Nonliving Evil) */
533 if (mode == HISSATSU_ZANMA)
535 if (!monster_living(m_ptr->r_idx) && (r_ptr->flags3 & RF3_EVIL))
537 if (mult < 15) mult = 25;
538 else if (mult < 50) mult = MIN(50, mult+20);
542 /* Rock Smash (Hurt Rock) */
543 if (mode == HISSATSU_HAGAN)
545 if (r_ptr->flags3 & RF3_HURT_ROCK)
547 if (is_original_ap_and_seen(m_ptr))
549 r_ptr->r_flags3 |= RF3_HURT_ROCK;
551 if (mult == 10) mult = 40;
552 else if (mult < 60) mult = 60;
556 /* Midare-Setsugekka (Cold) */
557 if (mode == HISSATSU_COLD)
559 /* Notice immunity */
560 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
562 if (is_original_ap_and_seen(m_ptr))
564 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
567 /* Otherwise, take the damage */
568 else if (have_flag(flgs, TR_BRAND_COLD))
570 if (r_ptr->flags3 & RF3_HURT_COLD)
572 if (mult < 70) mult = 70;
573 if (is_original_ap_and_seen(m_ptr))
575 r_ptr->r_flags3 |= RF3_HURT_COLD;
578 else if (mult < 35) mult = 35;
582 if (r_ptr->flags3 & RF3_HURT_COLD)
584 if (mult < 50) mult = 50;
585 if (is_original_ap_and_seen(m_ptr))
587 r_ptr->r_flags3 |= RF3_HURT_COLD;
590 else if (mult < 25) mult = 25;
594 /* Lightning Eagle (Elec) */
595 if (mode == HISSATSU_ELEC)
597 /* Notice immunity */
598 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
600 if (is_original_ap_and_seen(m_ptr))
602 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
606 /* Otherwise, take the damage */
607 else if (have_flag(flgs, TR_BRAND_ELEC))
609 if (mult < 70) mult = 70;
613 if (mult < 50) mult = 50;
617 /* Bloody Maelstrom */
618 if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(m_ptr->r_idx))
620 MULTIPLY tmp = MIN(100, MAX(10, p_ptr->cut / 10));
621 if (mult < tmp) mult = tmp;
625 if (mode == HISSATSU_UNDEAD)
627 if (r_ptr->flags3 & RF3_UNDEAD)
629 if (is_original_ap_and_seen(m_ptr))
631 r_ptr->r_flags3 |= RF3_UNDEAD;
633 if (mult == 10) mult = 70;
634 else if (mult < 140) mult = MIN(140, mult+60);
636 if (mult == 10) mult = 40;
637 else if (mult < 60) mult = MIN(60, mult+30);
640 if (mult > 150) mult = 150;