2 * @brief 剣術家のレイシャルパワー処理
7 #include "mind/mind-samurai.h"
8 #include "action/action-limited.h"
9 #include "avatar/avatar.h"
10 #include "cmd-action/cmd-attack.h"
11 #include "core/player-redraw-types.h"
12 #include "core/player-update-types.h"
13 #include "inventory/inventory-slot-types.h"
14 #include "io/input-key-acceptor.h"
15 #include "mind/stances-table.h"
16 #include "monster-attack/monster-attack-player.h"
17 #include "monster-race/monster-race-hook.h"
18 #include "monster-race/monster-race.h"
19 #include "monster-race/race-flags-resistance.h"
20 #include "monster-race/race-flags3.h"
21 #include "monster-race/race-resistance-mask.h"
22 #include "monster/monster-describer.h"
23 #include "monster/monster-info.h"
24 #include "monster/monster-status-setter.h"
25 #include "monster/monster-status.h"
26 #include "object-enchant/tr-types.h"
27 #include "pet/pet-util.h"
28 #include "player-attack/player-attack-util.h"
29 #include "player-base/player-class.h"
30 #include "player-info/samurai-data-type.h"
31 #include "player/attack-defense-types.h"
32 #include "status/action-setter.h"
33 #include "system/grid-type-definition.h"
34 #include "system/monster-race-definition.h"
35 #include "system/monster-type-definition.h"
36 #include "system/object-type-definition.h"
37 #include "system/player-type-definition.h"
38 #include "term/screen-processor.h"
39 #include "timed-effect/player-cut.h"
40 #include "timed-effect/player-fear.h"
41 #include "timed-effect/player-stun.h"
42 #include "timed-effect/timed-effects.h"
43 #include "util/bit-flags-calculator.h"
44 #include "util/int-char-converter.h"
45 #include "view/display-messages.h"
47 struct samurai_slaying_type {
55 static samurai_slaying_type *initialize_samurai_slaying_type(
56 samurai_slaying_type *samurai_slaying_ptr, MULTIPLY mult, const TrFlags &flags, monster_type *m_ptr, combat_options mode, monster_race *r_ptr)
58 samurai_slaying_ptr->mult = mult;
59 samurai_slaying_ptr->flags = flags;
60 samurai_slaying_ptr->m_ptr = m_ptr;
61 samurai_slaying_ptr->mode = mode;
62 samurai_slaying_ptr->r_ptr = r_ptr;
63 return samurai_slaying_ptr;
68 * @param player_ptr プレイヤーへの参照ポインタ
69 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
71 static void hissatsu_burning_strike(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
73 if (samurai_slaying_ptr->mode != HISSATSU_FIRE) {
78 if (samurai_slaying_ptr->r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_FIRE_MASK)) {
79 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
80 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(samurai_slaying_ptr->r_ptr->resistance_flags & RFR_EFF_IM_FIRE_MASK);
86 /* Otherwise, take the damage */
87 if (samurai_slaying_ptr->flags.has(TR_BRAND_FIRE)) {
88 if (samurai_slaying_ptr->r_ptr->resistance_flags.has(MonsterResistanceType::HURT_FIRE)) {
89 if (samurai_slaying_ptr->mult < 70) {
90 samurai_slaying_ptr->mult = 70;
93 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
94 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(MonsterResistanceType::HURT_FIRE);
97 } else if (samurai_slaying_ptr->mult < 35) {
98 samurai_slaying_ptr->mult = 35;
104 if (samurai_slaying_ptr->r_ptr->resistance_flags.has(MonsterResistanceType::HURT_FIRE)) {
105 if (samurai_slaying_ptr->mult < 50) {
106 samurai_slaying_ptr->mult = 50;
109 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
110 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(MonsterResistanceType::HURT_FIRE);
112 } else if (samurai_slaying_ptr->mult < 25) {
113 samurai_slaying_ptr->mult = 25;
118 * @brief サーペンツタン (毒殺スレイ)
119 * @param player_ptr プレイヤーへの参照ポインタ
120 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
122 static void hissatsu_serpent_tongue(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
124 if (samurai_slaying_ptr->mode != HISSATSU_POISON) {
128 /* Notice immunity */
129 if (samurai_slaying_ptr->r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_POISON_MASK)) {
130 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
131 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(samurai_slaying_ptr->r_ptr->resistance_flags & RFR_EFF_IM_POISON_MASK);
137 /* Otherwise, take the damage */
138 if (samurai_slaying_ptr->flags.has(TR_BRAND_POIS)) {
139 if (samurai_slaying_ptr->mult < 35) {
140 samurai_slaying_ptr->mult = 35;
142 } else if (samurai_slaying_ptr->mult < 25) {
143 samurai_slaying_ptr->mult = 25;
148 * @brief 二重の極み^h^h^h^h^h 斬魔剣弐の太刀 (邪悪無生命スレイ)
149 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
151 static void hissatsu_zanma_ken(samurai_slaying_type *samurai_slaying_ptr)
153 if (samurai_slaying_ptr->mode != HISSATSU_ZANMA) {
157 if (!monster_living(samurai_slaying_ptr->m_ptr->r_idx) && samurai_slaying_ptr->r_ptr->kind_flags.has(MonsterKindType::EVIL)) {
158 if (samurai_slaying_ptr->mult < 15) {
159 samurai_slaying_ptr->mult = 25;
160 } else if (samurai_slaying_ptr->mult < 50) {
161 samurai_slaying_ptr->mult = std::min<short>(50, samurai_slaying_ptr->mult + 20);
168 * @param player_ptr プレイヤーへの参照ポインタ
169 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
171 static void hissatsu_rock_smash(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
173 if (samurai_slaying_ptr->mode != HISSATSU_HAGAN) {
177 if (samurai_slaying_ptr->r_ptr->resistance_flags.has(MonsterResistanceType::HURT_ROCK)) {
178 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
179 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(MonsterResistanceType::HURT_ROCK);
182 if (samurai_slaying_ptr->mult == 10) {
183 samurai_slaying_ptr->mult = 40;
184 } else if (samurai_slaying_ptr->mult < 60) {
185 samurai_slaying_ptr->mult = 60;
191 * @brief 乱れ雪月花 (冷気スレイ)
192 * @param player_ptr プレイヤーへの参照ポインタ
193 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
195 static void hissatsu_midare_setsugetsuka(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
197 if (samurai_slaying_ptr->mode != HISSATSU_COLD) {
201 /* Notice immunity */
202 if (samurai_slaying_ptr->r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_COLD_MASK)) {
203 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
204 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(samurai_slaying_ptr->r_ptr->resistance_flags & RFR_EFF_IM_COLD_MASK);
210 /* Otherwise, take the damage */
211 if (samurai_slaying_ptr->flags.has(TR_BRAND_COLD)) {
212 if (samurai_slaying_ptr->r_ptr->resistance_flags.has(MonsterResistanceType::HURT_COLD)) {
213 if (samurai_slaying_ptr->mult < 70) {
214 samurai_slaying_ptr->mult = 70;
217 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
218 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(MonsterResistanceType::HURT_COLD);
220 } else if (samurai_slaying_ptr->mult < 35) {
221 samurai_slaying_ptr->mult = 35;
227 if (samurai_slaying_ptr->r_ptr->resistance_flags.has(MonsterResistanceType::HURT_COLD)) {
228 if (samurai_slaying_ptr->mult < 50) {
229 samurai_slaying_ptr->mult = 50;
232 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
233 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(MonsterResistanceType::HURT_COLD);
235 } else if (samurai_slaying_ptr->mult < 25) {
236 samurai_slaying_ptr->mult = 25;
242 * @param player_ptr プレイヤーへの参照ポインタ
243 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
245 static void hissatsu_lightning_eagle(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
247 if (samurai_slaying_ptr->mode != HISSATSU_ELEC) {
251 /* Notice immunity */
252 if (samurai_slaying_ptr->r_ptr->resistance_flags.has_any_of(RFR_EFF_IM_ELEC_MASK)) {
253 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
254 samurai_slaying_ptr->r_ptr->r_resistance_flags.set(samurai_slaying_ptr->r_ptr->resistance_flags & RFR_EFF_IM_ELEC_MASK);
260 /* Otherwise, take the damage */
261 if (samurai_slaying_ptr->flags.has(TR_BRAND_ELEC)) {
262 if (samurai_slaying_ptr->mult < 70) {
263 samurai_slaying_ptr->mult = 70;
265 } else if (samurai_slaying_ptr->mult < 50) {
266 samurai_slaying_ptr->mult = 50;
271 * @brief 赤流渦 (ペインバッカー)
272 * @param player_ptr プレイヤーへの参照ポインタ
273 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
275 static void hissatsu_bloody_maelstroem(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
277 auto player_cut = player_ptr->effects()->cut();
278 if ((samurai_slaying_ptr->mode == HISSATSU_SEKIRYUKA) && player_cut->is_cut() && monster_living(samurai_slaying_ptr->m_ptr->r_idx)) {
279 auto tmp = std::min<short>(100, std::max<short>(10, player_cut->current() / 10));
280 if (samurai_slaying_ptr->mult < tmp) {
281 samurai_slaying_ptr->mult = tmp;
287 * @brief 慶雲鬼忍剣 (アンデッドスレイ)
288 * @param player_ptr プレイヤーへの参照ポインタ
289 * @param samurai_slaying_ptr スレイ計算に必要なパラメータ群への参照ポインタ
291 static void hissatsu_keiun_kininken(PlayerType *player_ptr, samurai_slaying_type *samurai_slaying_ptr)
293 if (samurai_slaying_ptr->mode != HISSATSU_UNDEAD) {
297 if (samurai_slaying_ptr->r_ptr->kind_flags.has(MonsterKindType::UNDEAD)) {
298 if (is_original_ap_and_seen(player_ptr, samurai_slaying_ptr->m_ptr)) {
299 samurai_slaying_ptr->r_ptr->r_kind_flags.set(MonsterKindType::UNDEAD);
301 if (samurai_slaying_ptr->mult == 10) {
302 samurai_slaying_ptr->mult = 70;
303 } else if (samurai_slaying_ptr->mult < 140) {
304 samurai_slaying_ptr->mult = std::min<short>(140, samurai_slaying_ptr->mult + 60);
309 if (samurai_slaying_ptr->mult == 10) {
310 samurai_slaying_ptr->mult = 40;
311 } else if (samurai_slaying_ptr->mult < 60) {
312 samurai_slaying_ptr->mult = std::min<short>(60, samurai_slaying_ptr->mult + 30);
317 * @brief 剣術のスレイ倍率計算を行う /
318 * Calcurate magnification of hissatsu technics
319 * @param mult 剣術のスレイ効果以前に算出している多要素の倍率(/10倍)
320 * @param flags 剣術に使用する武器のスレイフラグ配列
321 * @param m_ptr 目標となるモンスターの構造体参照ポインタ
322 * @param mode 剣術のスレイ型ID
323 * @return スレイの倍率(/10倍)
325 MULTIPLY mult_hissatsu(PlayerType *player_ptr, MULTIPLY mult, const TrFlags &flags, monster_type *m_ptr, combat_options mode)
327 auto *r_ptr = &r_info[m_ptr->r_idx];
328 samurai_slaying_type tmp_slaying;
329 samurai_slaying_type *samurai_slaying_ptr = initialize_samurai_slaying_type(&tmp_slaying, mult, flags, m_ptr, mode, r_ptr);
330 hissatsu_burning_strike(player_ptr, samurai_slaying_ptr);
331 hissatsu_serpent_tongue(player_ptr, samurai_slaying_ptr);
332 hissatsu_zanma_ken(samurai_slaying_ptr);
333 hissatsu_rock_smash(player_ptr, samurai_slaying_ptr);
334 hissatsu_midare_setsugetsuka(player_ptr, samurai_slaying_ptr);
335 hissatsu_lightning_eagle(player_ptr, samurai_slaying_ptr);
336 hissatsu_bloody_maelstroem(player_ptr, samurai_slaying_ptr);
337 hissatsu_keiun_kininken(player_ptr, samurai_slaying_ptr);
339 if (samurai_slaying_ptr->mult > 150) {
340 samurai_slaying_ptr->mult = 150;
343 return samurai_slaying_ptr->mult;
346 void concentration(PlayerType *player_ptr)
348 int max_csp = std::max(player_ptr->msp * 4, player_ptr->lev * 5 + 5);
351 msg_print(_("今はペットを操ることに集中していないと。", "Your pets demand all of your attention."));
355 if (!PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::NONE)) {
356 msg_print(_("今は構えに集中している。", "You're already concentrating on your stance."));
360 msg_print(_("精神を集中して気合いを溜めた。", "You concentrate to charge your power."));
362 player_ptr->csp += player_ptr->msp / 2;
363 if (player_ptr->csp >= max_csp) {
364 player_ptr->csp = max_csp;
365 player_ptr->csp_frac = 0;
368 player_ptr->redraw |= PR_MANA;
373 * @return 型を変化させたらTRUE、型の構え不能かキャンセルしたらFALSEを返す。
375 bool choose_samurai_stance(PlayerType *player_ptr)
380 if (cmd_limit_confused(player_ptr)) {
384 auto effects = player_ptr->effects();
385 if (effects->stun()->is_stunned()) {
386 msg_print(_("意識がはっきりとしない。", "You are not clear-headed"));
390 if (effects->fear()->is_fearful()) {
391 msg_print(_("体が震えて構えられない!", "You are trembling with fear!"));
396 prt(_(" a) 型を崩す", " a) No Form"), 2, 20);
397 for (auto i = 0U; i < samurai_stances.size(); i++) {
398 if (player_ptr->lev >= samurai_stances[i].min_level) {
399 sprintf(buf, _(" %c) %sの型 %s", " %c) Stance of %-12s %s"), I2A(i + 1), samurai_stances[i].desc, samurai_stances[i].info);
405 prt(_(" どの型で構えますか?", " Choose Stance: "), 1, 14);
407 SamuraiStanceType new_stance = SamuraiStanceType::NONE;
411 if (choice == ESCAPE) {
414 } else if ((choice == 'a') || (choice == 'A')) {
415 if (player_ptr->action == ACTION_SAMURAI_STANCE) {
416 set_action(player_ptr, ACTION_NONE);
418 msg_print(_("もともと構えていない。", "You are not in a special stance."));
422 } else if ((choice == 'b') || (choice == 'B')) {
423 new_stance = SamuraiStanceType::IAI;
425 } else if (((choice == 'c') || (choice == 'C')) && (player_ptr->lev > 29)) {
426 new_stance = SamuraiStanceType::FUUJIN;
428 } else if (((choice == 'd') || (choice == 'D')) && (player_ptr->lev > 34)) {
429 new_stance = SamuraiStanceType::KOUKIJIN;
431 } else if (((choice == 'e') || (choice == 'E')) && (player_ptr->lev > 39)) {
432 new_stance = SamuraiStanceType::MUSOU;
437 set_action(player_ptr, ACTION_SAMURAI_STANCE);
438 if (PlayerClass(player_ptr).samurai_stance_is(new_stance)) {
439 msg_print(_("構え直した。", "You reassume a stance."));
441 player_ptr->update |= (PU_BONUS | PU_MONSTERS);
442 msg_format(_("%sの型で構えた。", "You assume the %s stance."), samurai_stances[enum2i(new_stance) - 1].desc);
443 PlayerClass(player_ptr).set_samurai_stance(new_stance);
446 player_ptr->redraw |= (PR_STATE | PR_STATUS);
452 * @brief 剣術家限定で、型等に応じて命中率を高める
453 * @param player_ptr プレイヤーへの参照ポインタ
454 * @param pa_ptr 直接攻撃構造体への参照ポインタ
457 int calc_attack_quality(PlayerType *player_ptr, player_attack_type *pa_ptr)
459 auto *o_ptr = &player_ptr->inventory_list[INVEN_MAIN_HAND + pa_ptr->hand];
460 int bonus = player_ptr->to_h[pa_ptr->hand] + o_ptr->to_h;
461 int chance = (player_ptr->skill_thn + (bonus * BTH_PLUS_ADJ));
462 if (pa_ptr->mode == HISSATSU_IAI) {
466 if (PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::KOUKIJIN)) {
470 if (player_ptr->sutemi) {
471 chance = std::max(chance * 3 / 2, chance + 60);
474 int vir = virtue_number(player_ptr, V_VALOUR);
476 chance += (player_ptr->virtues[vir - 1] / 10);
484 * @param player_ptr プレイヤーへの参照ポインタ
485 * @param pa_ptr 直接攻撃構造体への参照ポインタ
487 void mineuchi(PlayerType *player_ptr, player_attack_type *pa_ptr)
489 if (pa_ptr->mode != HISSATSU_MINEUCHI) {
493 pa_ptr->attack_damage = 0;
494 anger_monster(player_ptr, pa_ptr->m_ptr);
496 auto *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
497 if ((r_ptr->flags3 & (RF3_NO_STUN))) {
498 msg_format(_("%s には効果がなかった。", "%s is not effected."), pa_ptr->m_name);
502 int tmp = (10 + randint1(15) + player_ptr->lev / 5);
503 if (monster_stunned_remaining(pa_ptr->m_ptr)) {
504 msg_format(_("%sはひどくもうろうとした。", "%s is more dazed."), pa_ptr->m_name);
507 msg_format(_("%s はもうろうとした。", "%s is dazed."), pa_ptr->m_name);
510 (void)set_monster_stunned(player_ptr, pa_ptr->g_ptr->m_idx, monster_stunned_remaining(pa_ptr->m_ptr) + tmp);
515 * @param player_ptr プレイヤーへの参照ポインタ
516 * @param pa_ptr 直接攻撃構造体への参照ポインタ
518 void musou_counterattack(PlayerType *player_ptr, MonsterAttackPlayer *monap_ptr)
520 if ((!player_ptr->counter && !PlayerClass(player_ptr).samurai_stance_is(SamuraiStanceType::MUSOU)) || !monap_ptr->alive || player_ptr->is_dead || !monap_ptr->m_ptr->ml || (player_ptr->csp <= 7)) {
524 char m_target_name[MAX_NLEN];
525 monster_desc(player_ptr, m_target_name, monap_ptr->m_ptr, 0);
526 player_ptr->csp -= 7;
527 msg_format(_("%^sに反撃した!", "You counterattacked %s!"), m_target_name);
528 do_cmd_attack(player_ptr, monap_ptr->m_ptr->fy, monap_ptr->m_ptr->fx, HISSATSU_COUNTER);
529 monap_ptr->fear = false;
530 player_ptr->redraw |= (PR_MANA);