OSDN Git Service

[Refactor] #2645 display_object_list() を整形した
[hengbandforosx/hengbandosx.git] / src / object-enchant / vorpal-weapon.cpp
1 #include "object-enchant/vorpal-weapon.h"
2 #include "artifact/fixed-art-types.h"
3 #include "inventory/inventory-slot-types.h"
4 #include "io/files-util.h"
5 #include "main/sound-definitions-table.h"
6 #include "main/sound-of-music.h"
7 #include "monster-race/monster-race.h"
8 #include "monster-race/race-flags-resistance.h"
9 #include "player-attack/player-attack-util.h"
10 #include "system/monster-race-definition.h"
11 #include "system/monster-type-definition.h"
12 #include "system/object-type-definition.h"
13 #include "system/player-type-definition.h"
14 #include "view/display-messages.h"
15
16 /*!
17  * @brief ヴォーパル武器で攻撃した時のメッセージ表示
18  * @param pa_ptr 直接攻撃構造体への参照ポインタ
19  * @param int 倍率
20  */
21 static void print_vorpal_message(player_attack_type *pa_ptr, const int magnification)
22 {
23     switch (magnification) {
24     case 2:
25         msg_format(_("%sを斬った!", "You gouge %s!"), pa_ptr->m_name);
26         sound(SOUND_GOUGE_HIT);
27         break;
28     case 3:
29         msg_format(_("%sをぶった斬った!", "You maim %s!"), pa_ptr->m_name);
30         sound(SOUND_MAIM_HIT);
31         break;
32     case 4:
33         msg_format(_("%sをメッタ斬りにした!", "You carve %s!"), pa_ptr->m_name);
34         sound(SOUND_CARVE_HIT);
35         break;
36     case 5:
37         msg_format(_("%sをメッタメタに斬った!", "You cleave %s!"), pa_ptr->m_name);
38         sound(SOUND_CLEAVE_HIT);
39         break;
40     case 6:
41         msg_format(_("%sを刺身にした!", "You smite %s!"), pa_ptr->m_name);
42         sound(SOUND_SMITE_HIT);
43         break;
44     case 7:
45         msg_format(_("%sを斬って斬って斬りまくった!", "You eviscerate %s!"), pa_ptr->m_name);
46         sound(SOUND_EVISCERATE_HIT);
47         break;
48     default:
49         msg_format(_("%sを細切れにした!", "You shred %s!"), pa_ptr->m_name);
50         sound(SOUND_SHRED_HIT);
51         break;
52     }
53 }
54
55 /*!
56  * @brief チェンソーのノイズ音を表示する
57  * @param o_ptr チェンソーへの参照ポインタ
58  */
59 static void print_chainsword_noise(ObjectType *o_ptr)
60 {
61     if ((o_ptr->fixed_artifact_idx != FixedArtifactId::CHAINSWORD) || one_in_(2)) {
62         return;
63     }
64
65     char chainsword_noise[1024];
66     if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, chainsword_noise)) {
67         msg_print(chainsword_noise);
68     }
69 }
70
71 /*!
72  * @brief ヴォーパル武器利用時の処理メインルーチン
73  * @param player_ptr プレイヤーへの参照ポインタ
74  * @param pa_ptr 直接攻撃構造体への参照ポインタ
75  * @param vorpal_cut メッタ斬りにできるかどうか
76  * @param vorpal_chance ヴォーパル倍率上昇の機会値
77  */
78 void process_vorpal_attack(PlayerType *player_ptr, player_attack_type *pa_ptr, const bool vorpal_cut, const int vorpal_chance)
79 {
80     if (!vorpal_cut) {
81         return;
82     }
83
84     auto *o_ptr = &player_ptr->inventory_list[enum2i(INVEN_MAIN_HAND) + pa_ptr->hand];
85     int vorpal_magnification = 2;
86     print_chainsword_noise(o_ptr);
87     if (o_ptr->fixed_artifact_idx == FixedArtifactId::VORPAL_BLADE) {
88         msg_print(_("目にも止まらぬヴォーパルブレード、手錬の早業!", "Your Vorpal Blade goes snicker-snack!"));
89     } else {
90         msg_format(_("%sをグッサリ切り裂いた!", "Your weapon cuts deep into %s!"), pa_ptr->m_name);
91     }
92
93     while (one_in_(vorpal_chance)) {
94         vorpal_magnification++;
95     }
96
97     pa_ptr->attack_damage *= (int)vorpal_magnification;
98     auto *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
99     if ((r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL) ? pa_ptr->attack_damage / 100 : pa_ptr->attack_damage) > pa_ptr->m_ptr->hp) {
100         msg_format(_("%sを真っ二つにした!", "You cut %s in half!"), pa_ptr->m_name);
101     } else {
102         print_vorpal_message(pa_ptr, vorpal_magnification);
103     }
104
105     pa_ptr->drain_result = pa_ptr->drain_result * 3 / 2;
106 }