OSDN Git Service

Merge pull request #936 from shimitei/feature/#916_fix_sound_on_off
[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 "monster-race/monster-race.h"
6 #include "monster-race/race-flags-resistance.h"
7 #include "player-attack/player-attack-util.h"
8 #include "system/monster-race-definition.h"
9 #include "system/monster-type-definition.h"
10 #include "system/object-type-definition.h"
11 #include "system/player-type-definition.h"
12 #include "view/display-messages.h"
13
14 /*!
15  * @brief ヴォーパル武器で攻撃した時のメッセージ表示
16  * @param pa_ptr 直接攻撃構造体への参照ポインタ
17  * @param int 倍率
18  * @return なし
19  */
20 static void print_vorpal_message(player_attack_type *pa_ptr, const int magnification)
21 {
22     switch (magnification) {
23     case 2:
24         msg_format(_("%sを斬った!", "You gouge %s!"), pa_ptr->m_name);
25         break;
26     case 3:
27         msg_format(_("%sをぶった斬った!", "You maim %s!"), pa_ptr->m_name);
28         break;
29     case 4:
30         msg_format(_("%sをメッタ斬りにした!", "You carve %s!"), pa_ptr->m_name);
31         break;
32     case 5:
33         msg_format(_("%sをメッタメタに斬った!", "You cleave %s!"), pa_ptr->m_name);
34         break;
35     case 6:
36         msg_format(_("%sを刺身にした!", "You smite %s!"), pa_ptr->m_name);
37         break;
38     case 7:
39         msg_format(_("%sを斬って斬って斬りまくった!", "You eviscerate %s!"), pa_ptr->m_name);
40         break;
41     default:
42         msg_format(_("%sを細切れにした!", "You shred %s!"), pa_ptr->m_name);
43         break;
44     }
45 }
46
47 /*!
48  * @brief チェンソーのノイズ音を表示する
49  * @param o_ptr チェンソーへの参照ポインタ
50  * @return なし
51  */
52 static void print_chainsword_noise(object_type *o_ptr)
53 {
54     if ((o_ptr->name1 != ART_CHAINSWORD) || one_in_(2))
55         return;
56
57     char chainsword_noise[1024];
58     if (!get_rnd_line(_("chainswd_j.txt", "chainswd.txt"), 0, chainsword_noise))
59         msg_print(chainsword_noise);
60 }
61
62 /*!
63  * @brief ヴォーパル武器利用時の処理メインルーチン
64  * @param attacker_ptr プレーヤーへの参照ポインタ
65  * @param pa_ptr 直接攻撃構造体への参照ポインタ
66  * @param vorpal_cut メッタ斬りにできるかどうか
67  * @param vorpal_chance ヴォーパル倍率上昇の機会値
68  * @return なし
69  */
70 void process_vorpal_attack(player_type *attacker_ptr, player_attack_type *pa_ptr, const bool vorpal_cut, const int vorpal_chance)
71 {
72     if (!vorpal_cut)
73         return;
74
75     object_type *o_ptr = &attacker_ptr->inventory_list[INVEN_MAIN_HAND + pa_ptr->hand];
76     int vorpal_magnification = 2;
77     print_chainsword_noise(o_ptr);
78     if (o_ptr->name1 == ART_VORPAL_BLADE)
79         msg_print(_("目にも止まらぬヴォーパルブレード、手錬の早業!", "Your Vorpal Blade goes snicker-snack!"));
80     else
81         msg_format(_("%sをグッサリ切り裂いた!", "Your weapon cuts deep into %s!"), pa_ptr->m_name);
82
83     while (one_in_(vorpal_chance))
84         vorpal_magnification++;
85
86     pa_ptr->attack_damage *= (HIT_POINT)vorpal_magnification;
87     monster_race *r_ptr = &r_info[pa_ptr->m_ptr->r_idx];
88     if (((r_ptr->flagsr & RFR_RES_ALL) ? pa_ptr->attack_damage / 100 : pa_ptr->attack_damage) > pa_ptr->m_ptr->hp)
89         msg_format(_("%sを真っ二つにした!", "You cut %s in half!"), pa_ptr->m_name);
90     else
91         print_vorpal_message(pa_ptr, vorpal_magnification);
92
93     pa_ptr->drain_result = pa_ptr->drain_result * 3 / 2;
94 }