OSDN Git Service

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