1 #include "combat/attack-criticality.h"
2 #include "combat/combat-options-type.h"
3 #include "inventory/inventory-slot-types.h"
4 #include "main/sound-of-music.h"
5 #include "monster-race/monster-race.h"
6 #include "monster-race/race-flags1.h"
7 #include "monster-race/race-flags7.h"
8 #include "object/tval-types.h"
9 #include "player-attack/player-attack-util.h"
10 #include "player-base/player-class.h"
11 #include "player-info/equipment-info.h"
12 #include "sv-definition/sv-weapon-types.h"
13 #include "system/monster-race-definition.h"
14 #include "system/monster-type-definition.h"
15 #include "system/object-type-definition.h"
16 #include "system/player-type-definition.h"
17 #include "view/display-messages.h"
20 * @brief クリティカルダメージを適用する
22 * @param k クリティカルの強度を決定する値
23 * @param base_dam クリティカル適用前のダメージ
24 * @return クリティカルを適用したダメージと、クリティカル発生時に表示するメッセージと、クリティカル効果音のタプルを返す
26 std::tuple<HIT_POINT, concptr, sound_type> apply_critical_norm_damage(int k, HIT_POINT base_dam)
29 return { 2 * base_dam + 5, _("手ごたえがあった!", "It was a good hit!"), SOUND_GOOD_HIT };
32 return { 2 * base_dam + 10, _("かなりの手ごたえがあった!", "It was a great hit!"), SOUND_GREAT_HIT };
35 return { 3 * base_dam + 15, _("会心の一撃だ!", "It was a superb hit!"), SOUND_SUPERB_HIT };
38 return { 3 * base_dam + 20, _("最高の会心の一撃だ!", "It was a *GREAT* hit!"), SOUND_STAR_GREAT_HIT };
40 return { ((7 * base_dam) / 2) + 25, _("比類なき最高の会心の一撃だ!", "It was a *SUPERB* hit!"), SOUND_STAR_SUPERB_HIT };
44 * @brief プレイヤーからモンスターへの打撃クリティカル判定 /
45 * Critical hits (by player) Factor in weapon weight, total plusses, player melee bonus
48 * @param dam 現在算出中のダメージ値
49 * @param meichuu 打撃の基本命中力
50 * @param mode オプションフラグ
51 * @return クリティカル修正が入ったダメージ値
53 HIT_POINT critical_norm(PlayerType *player_ptr, WEIGHT weight, int plus, HIT_POINT dam, int16_t meichuu, combat_options mode, bool impact)
55 /* Extract "blow" power */
56 int i = (weight + (meichuu * 3 + plus * 5) + player_ptr->skill_thn);
59 auto pow = PlayerClass(player_ptr).equals(PlayerClassType::NINJA) ? 4444 : 5000;
63 bool is_special_option = randint1(pow) <= i;
64 is_special_option |= mode == HISSATSU_MAJIN;
65 is_special_option |= mode == HISSATSU_3DAN;
66 if (!is_special_option)
69 int k = weight + randint1(650);
70 if (impact || (mode == HISSATSU_MAJIN) || (mode == HISSATSU_3DAN))
73 auto [critical_dam, msg, battle_sound] = apply_critical_norm_damage(k, dam);
81 * @param player_ptr プレイヤーへの参照ポインタ
82 * @param pa_ptr 直接攻撃構造体への参照ポインタ
83 * @details 闇討ち&追討ちを実施した後に致命傷チェックを行う
84 * チェックを通ったら、ユニークならば2倍ダメージ、それ以外は一撃死
85 * @todo 3つの処理をdetailsに書くよりは関数自体を分割すべきだが、一旦後回しにする。他の項目と一緒に処理する
87 static void ninja_critical(PlayerType *player_ptr, player_attack_type *pa_ptr)
89 auto *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
90 int maxhp = pa_ptr->m_ptr->maxhp;
91 if (one_in_(pa_ptr->backstab ? 13 : (pa_ptr->stab_fleeing || pa_ptr->surprise_attack) ? 15
93 pa_ptr->attack_damage *= 5;
94 pa_ptr->drain_result *= 2;
95 msg_format(_("刃が%sに深々と突き刺さった!", "You critically injured %s!"), pa_ptr->m_name);
99 bool is_weaken = pa_ptr->m_ptr->hp < maxhp / 2;
100 bool is_unique = (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) || ((r_ptr->flags7 & RF7_UNIQUE2) != 0);
101 bool is_critical = (is_weaken && one_in_((player_ptr->num_blow[0] + player_ptr->num_blow[1] + 1) * 10)) || ((one_in_(666) || ((pa_ptr->backstab || pa_ptr->surprise_attack) && one_in_(11))) && !is_unique);
105 if (is_unique || !is_weaken) {
106 pa_ptr->attack_damage = std::max(pa_ptr->attack_damage * 5, pa_ptr->m_ptr->hp / 2);
107 pa_ptr->drain_result *= 2;
108 msg_format(_("%sに致命傷を負わせた!", "You fatally injured %s!"), pa_ptr->m_name);
110 pa_ptr->attack_damage = pa_ptr->m_ptr->hp + 1;
111 msg_format(_("刃が%sの急所を貫いた!", "You hit %s on a fatal spot!"), pa_ptr->m_name);
117 * @param player_ptr プレイヤーへの参照ポインタ
118 * @param pa_ptr 直接攻撃構造体への参照ポインタ
120 void critical_attack(PlayerType *player_ptr, player_attack_type *pa_ptr)
122 auto *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + pa_ptr->hand];
123 auto *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
124 if (((o_ptr->tval == ItemKindType::SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) || (pa_ptr->mode == HISSATSU_KYUSHO)) {
125 if ((randint1(randint1(r_ptr->level / 7) + 5) == 1) && r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)) {
126 pa_ptr->attack_damage = pa_ptr->m_ptr->hp + 1;
127 msg_format(_("%sの急所を突き刺した!", "You hit %s on a fatal spot!"), pa_ptr->m_name);
129 pa_ptr->attack_damage = 1;
134 bool is_ninja_hit = PlayerClass(player_ptr).equals(PlayerClassType::NINJA) && has_melee_weapon(player_ptr, INVEN_MAIN_HAND + pa_ptr->hand) && !player_ptr->is_icky_wield[pa_ptr->hand] && ((player_ptr->cur_lite <= 0) || one_in_(7));
136 ninja_critical(player_ptr, pa_ptr);