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"
16 #define TECHNIC_HISSATSU (REALM_HISSATSU - MIN_TECHNIC)
20 * @brief 使用可能な剣術を選択する /
21 * Allow user to choose a blade arts.
22 * @param sn 選択した特殊技能ID、キャンセルの場合-1、不正な選択の場合-2を返す
23 * @return 発動可能な魔法を選択した場合TRUE、キャンセル処理か不正な選択が行われた場合FALSEを返す。
25 * If a valid spell is chosen, saves it in '*sn' and returns TRUE\n
26 * If the user hits escape, returns FALSE, and set '*sn' to -1\n
27 * If there are no legal choices, returns FALSE, and sets '*sn' to -2\n
29 * The "prompt" should be "cast", "recite", or "study"\n
30 * The "known" should be TRUE for cast/pray, FALSE for study\n
32 * nb: This function has a (trivial) display bug which will be obvious\n
33 * when you run it. It's probably easy to fix but I haven't tried,\n
36 static int get_hissatsu_power(SPELL_IDX *sn)
43 PLAYER_LEVEL plev = p_ptr->lev;
47 SPELL_IDX sentaku[32];
48 cptr p = _("必殺剣", "special attack");
52 int menu_line = (use_menu ? 1 : 0);
54 /* Assume cancelled */
57 /* Get the spell, if available */
58 if (repeat_pull(&code))
60 *sn = (SPELL_IDX)code;
61 /* Verify the spell */
62 if (technic_info[TECHNIC_HISSATSU][*sn].slevel <= plev)
69 /* Nothing chosen yet */
75 for (i = 0; i < 32; i++)
77 if (technic_info[TECHNIC_HISSATSU][i].slevel <= PY_MAX_LEVEL)
84 /* Build a prompt (accept all spells) */
85 (void) strnfmt(out_val, 78,
86 _("(%^s %c-%c, '*'で一覧, ESC) どの%sを使いますか?", "(%^ss %c-%c, *=List, ESC=exit) Use which %s? "),
87 p, I2A(0), "abcdefghijklmnopqrstuvwxyz012345"[num-1], p);
89 if (use_menu) screen_save();
91 /* Get a spell from the user */
93 choice= always_show_list ? ESCAPE:1 ;
96 if(choice==ESCAPE) choice = ' ';
97 else if( !get_com(out_val, &choice, FALSE) )break;
99 if (use_menu && choice != ' ')
116 if (menu_line > 32) menu_line -= 32;
117 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
128 if (menu_line > 32) menu_line -= 32;
129 } while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))));
140 bool reverse = FALSE;
141 if ((choice == '4') || (choice == 'h') || (choice == 'H')) reverse = TRUE;
148 while(!(p_ptr->spell_learned1 & (1L << (menu_line-1))))
153 if (menu_line < 2) reverse = FALSE;
158 if (menu_line > 31) reverse = TRUE;
176 if ((choice == ' ') || (choice == '*') || (choice == '?') || (use_menu && ask))
179 if (!redraw || use_menu)
187 /* Save the screen */
188 if (!use_menu) screen_save();
190 /* Display a list of spells */
192 put_str(_("名前 Lv MP 名前 Lv MP ",
193 "name Lv SP name Lv SP "), y, x + 5);
195 /* Dump the spells */
196 for (i = 0, line = 0; i < 32; i++)
198 spell = technic_info[TECHNIC_HISSATSU][i];
200 if (spell.slevel > PY_MAX_LEVEL) continue;
202 if (!(p_ptr->spell_learned1 >> i)) break;
204 /* Access the spell */
205 if (spell.slevel > plev) continue;
206 if (!(p_ptr->spell_learned1 & (1L << i))) continue;
209 if (i == (menu_line-1))
210 strcpy(psi_desc, _(" 》", " > "));
211 else strcpy(psi_desc, " ");
218 letter = I2A(line-1);
220 letter = '0' + line - 27;
221 sprintf(psi_desc, " %c)",letter);
224 /* Dump the spell --(-- */
225 strcat(psi_desc, format(" %-18s%2d %3d",
226 do_spell(REALM_HISSATSU, i, SPELL_NAME),
227 spell.slevel, spell.smana));
228 prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
229 prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
239 /* Restore the screen */
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) || !(p_ptr->spell_learned1 & (1 << sentaku[i])))
283 (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), do_spell(REALM_HISSATSU, j, SPELL_NAME));
285 /* Belay that order */
286 if (!get_check(tmp_val)) continue;
293 /* Restore the screen */
294 if (redraw) screen_load();
297 p_ptr->window |= (PW_SPELL);
302 /* Abort if needed */
303 if (!flag) return (FALSE);
305 /* Save the choice */
308 repeat_push((COMMAND_CODE)j);
316 * @brief 剣術コマンドのメインルーチン
319 void do_cmd_hissatsu(void)
324 /* not if confused */
327 msg_print(_("混乱していて集中できない!", "You are too confused!"));
330 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
332 if (flush_failure) flush();
333 msg_print(_("武器を持たないと必殺技は使えない!", "You need to wield a weapon!"));
336 if (!p_ptr->spell_learned1)
338 msg_print(_("何も技を知らない。", "You don't know any special attacks."));
342 if (p_ptr->special_defense & KATA_MASK)
344 set_action(ACTION_NONE);
348 if (!get_hissatsu_power(&n)) return;
350 spell = technic_info[TECHNIC_HISSATSU][n];
352 /* Verify "dangerous" spells */
353 if (spell.smana > p_ptr->csp)
355 if (flush_failure) flush();
357 msg_print(_("MPが足りません。", "You do not have enough mana to use this power."));
365 if (!do_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
367 p_ptr->energy_use = 100;
370 p_ptr->csp -= spell.smana;
373 if (p_ptr->csp < 0) p_ptr->csp = 0;
374 p_ptr->redraw |= (PR_MANA);
376 p_ptr->window |= (PW_PLAYER);
377 p_ptr->window |= (PW_SPELL);
385 void do_cmd_gain_hissatsu(void)
395 if (p_ptr->special_defense & (KATA_MUSOU | KATA_KOUKIJIN))
397 set_action(ACTION_NONE);
400 if (p_ptr->blind || no_lite())
402 msg_print(_("目が見えない!", "You cannot see!"));
408 msg_print(_("混乱していて読めない!", "You are too confused!"));
412 if (!(p_ptr->new_spells))
414 msg_print(_("新しい必殺技を覚えることはできない!", "You cannot learn any new special attacks!"));
419 if( p_ptr->new_spells < 10 ){
420 msg_format("あと %d つの必殺技を学べる。", p_ptr->new_spells);
422 msg_format("あと %d 個の必殺技を学べる。", p_ptr->new_spells);
425 msg_format("You can learn %d new special attack%s.", p_ptr->new_spells,
426 (p_ptr->new_spells == 1?"":"s"));
429 item_tester_tval = TV_HISSATSU_BOOK;
431 q = _("どの書から学びますか? ", "Study which book? ");
432 s = _("読める書がない。", "You have no books that you can read.");
434 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
436 /* Get the item (in the pack) */
439 o_ptr = &inventory[item];
442 /* Get the item (on the floor) */
445 o_ptr = &o_list[0 - item];
448 for (i = o_ptr->sval * 8; i < o_ptr->sval * 8 + 8; i++)
450 if (p_ptr->spell_learned1 & (1L << i)) continue;
451 if (technic_info[TECHNIC_HISSATSU][i].slevel > p_ptr->lev) continue;
453 p_ptr->spell_learned1 |= (1L << i);
454 p_ptr->spell_worked1 |= (1L << i);
455 msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), do_spell(REALM_HISSATSU, i, SPELL_NAME));
456 for (j = 0; j < 64; j++)
458 /* Stop at the first empty space */
459 if (p_ptr->spell_order[j] == 99) break;
461 p_ptr->spell_order[j] = i;
467 msg_print(_("何も覚えられなかった。", "You were not able to learn any special attacks."));
470 p_ptr->energy_use = 100;
472 p_ptr->update |= (PU_SPELLS);
477 * @brief 剣術のスレイ倍率計算を行う /
478 * Calcurate magnification of hissatsu technics
479 * @param mult 剣術のスレイ効果以前に算出している多要素の倍率(/10倍)
480 * @param flgs 剣術に使用する武器のスレイフラグ配列
481 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
482 * @param mode 剣術のスレイ型ID
483 * @return スレイの倍率(/10倍)
485 MULTIPLY mult_hissatsu(MULTIPLY mult, BIT_FLAGS *flgs, monster_type *m_ptr, BIT_FLAGS mode)
487 monster_race *r_ptr = &r_info[m_ptr->r_idx];
489 /* Burning Strike (Fire) */
490 if (mode == HISSATSU_FIRE)
492 /* Notice immunity */
493 if (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK)
495 if (is_original_ap_and_seen(m_ptr))
497 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK);
501 /* Otherwise, take the damage */
502 else if (have_flag(flgs, TR_BRAND_FIRE))
504 if (r_ptr->flags3 & RF3_HURT_FIRE)
506 if (mult < 70) mult = 70;
507 if (is_original_ap_and_seen(m_ptr))
509 r_ptr->r_flags3 |= RF3_HURT_FIRE;
512 else if (mult < 35) mult = 35;
516 if (r_ptr->flags3 & RF3_HURT_FIRE)
518 if (mult < 50) mult = 50;
519 if (is_original_ap_and_seen(m_ptr))
521 r_ptr->r_flags3 |= RF3_HURT_FIRE;
524 else if (mult < 25) mult = 25;
528 /* Serpent's Tongue (Poison) */
529 if (mode == HISSATSU_POISON)
531 /* Notice immunity */
532 if (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK)
534 if (is_original_ap_and_seen(m_ptr))
536 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK);
540 /* Otherwise, take the damage */
541 else if (have_flag(flgs, TR_BRAND_POIS))
543 if (mult < 35) mult = 35;
547 if (mult < 25) mult = 25;
551 /* Zammaken (Nonliving Evil) */
552 if (mode == HISSATSU_ZANMA)
554 if (!monster_living(m_ptr->r_idx) && (r_ptr->flags3 & RF3_EVIL))
556 if (mult < 15) mult = 25;
557 else if (mult < 50) mult = MIN(50, mult+20);
561 /* Rock Smash (Hurt Rock) */
562 if (mode == HISSATSU_HAGAN)
564 if (r_ptr->flags3 & RF3_HURT_ROCK)
566 if (is_original_ap_and_seen(m_ptr))
568 r_ptr->r_flags3 |= RF3_HURT_ROCK;
570 if (mult == 10) mult = 40;
571 else if (mult < 60) mult = 60;
575 /* Midare-Setsugekka (Cold) */
576 if (mode == HISSATSU_COLD)
578 /* Notice immunity */
579 if (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK)
581 if (is_original_ap_and_seen(m_ptr))
583 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_COLD_MASK);
586 /* Otherwise, take the damage */
587 else if (have_flag(flgs, TR_BRAND_COLD))
589 if (r_ptr->flags3 & RF3_HURT_COLD)
591 if (mult < 70) mult = 70;
592 if (is_original_ap_and_seen(m_ptr))
594 r_ptr->r_flags3 |= RF3_HURT_COLD;
597 else if (mult < 35) mult = 35;
601 if (r_ptr->flags3 & RF3_HURT_COLD)
603 if (mult < 50) mult = 50;
604 if (is_original_ap_and_seen(m_ptr))
606 r_ptr->r_flags3 |= RF3_HURT_COLD;
609 else if (mult < 25) mult = 25;
613 /* Lightning Eagle (Elec) */
614 if (mode == HISSATSU_ELEC)
616 /* Notice immunity */
617 if (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK)
619 if (is_original_ap_and_seen(m_ptr))
621 r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK);
625 /* Otherwise, take the damage */
626 else if (have_flag(flgs, TR_BRAND_ELEC))
628 if (mult < 70) mult = 70;
632 if (mult < 50) mult = 50;
636 /* Bloody Maelstrom */
637 if ((mode == HISSATSU_SEKIRYUKA) && p_ptr->cut && monster_living(m_ptr->r_idx))
639 MULTIPLY tmp = MIN(100, MAX(10, p_ptr->cut / 10));
640 if (mult < tmp) mult = tmp;
644 if (mode == HISSATSU_UNDEAD)
646 if (r_ptr->flags3 & RF3_UNDEAD)
648 if (is_original_ap_and_seen(m_ptr))
650 r_ptr->r_flags3 |= RF3_UNDEAD;
652 if (mult == 10) mult = 70;
653 else if (mult < 140) mult = MIN(140, mult+60);
655 if (mult == 10) mult = 40;
656 else if (mult < 60) mult = MIN(60, mult+30);
659 if (mult > 150) mult = 150;