OSDN Git Service

Reworded English description for sniper's exploding arrow ability.
[hengband/hengband.git] / src / mind / mind-magic-eater.c
1 #include "mind/mind-magic-eater.h"
2 #include "flavor/flavor-describer.h"
3 #include "floor/floor-object.h"
4 #include "inventory/inventory-object.h"
5 #include "object-hook/hook-magic.h"
6 #include "object/item-tester-hooker.h"
7 #include "object/item-use-flags.h"
8 #include "perception/object-perception.h"
9 #include "sv-definition/sv-staff-types.h"
10 #include "system/object-type-definition.h"
11 #include "view/display-messages.h"
12
13 /*!
14  * @brief 魔道具術師の魔力取り込み処理
15  * @param user_ptr アイテムを取り込むクリーチャー
16  * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
17  */
18 bool import_magic_device(player_type *user_ptr)
19 {
20     item_tester_hook = item_tester_hook_recharge;
21     concptr q = _("どのアイテムの魔力を取り込みますか? ", "Gain power of which item? ");
22     concptr s = _("魔力を取り込めるアイテムがない。", "You have nothing to gain power.");
23     OBJECT_IDX item;
24     object_type *o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
25     if (!o_ptr)
26         return FALSE;
27
28     if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING) {
29         msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
30         return FALSE;
31     }
32
33     if (!object_is_known(o_ptr)) {
34         msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
35         return FALSE;
36     }
37
38     if (o_ptr->timeout) {
39         msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
40         return FALSE;
41     }
42
43     PARAMETER_VALUE pval = o_ptr->pval;
44     int ext = 0;
45     if (o_ptr->tval == TV_ROD)
46         ext = 72;
47     else if (o_ptr->tval == TV_WAND)
48         ext = 36;
49
50     if (o_ptr->tval == TV_ROD) {
51         user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)o_ptr->number;
52         if (user_ptr->magic_num2[o_ptr->sval + ext] > 99)
53             user_ptr->magic_num2[o_ptr->sval + ext] = 99;
54     } else {
55         int num;
56         for (num = o_ptr->number; num; num--) {
57             int gain_num = pval;
58             if (o_ptr->tval == TV_WAND)
59                 gain_num = (pval + num - 1) / num;
60             if (user_ptr->magic_num2[o_ptr->sval + ext]) {
61                 gain_num *= 256;
62                 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
63                 if (gain_num < 1)
64                     gain_num = 1;
65             }
66             user_ptr->magic_num2[o_ptr->sval + ext] += (MAGIC_NUM2)gain_num;
67             if (user_ptr->magic_num2[o_ptr->sval + ext] > 99)
68                 user_ptr->magic_num2[o_ptr->sval + ext] = 99;
69             user_ptr->magic_num1[o_ptr->sval + ext] += pval * 0x10000;
70             if (user_ptr->magic_num1[o_ptr->sval + ext] > 99 * 0x10000)
71                 user_ptr->magic_num1[o_ptr->sval + ext] = 99 * 0x10000;
72             if (user_ptr->magic_num1[o_ptr->sval + ext] > user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000)
73                 user_ptr->magic_num1[o_ptr->sval + ext] = user_ptr->magic_num2[o_ptr->sval + ext] * 0x10000;
74             if (o_ptr->tval == TV_WAND)
75                 pval -= (pval + num - 1) / num;
76         }
77     }
78
79     GAME_TEXT o_name[MAX_NLEN];
80     describe_flavor(user_ptr, o_name, o_ptr, 0);
81     msg_format(_("%sの魔力を取り込んだ。", "You absorb magic of %s."), o_name);
82
83     vary_item(user_ptr, item, -999);
84     take_turn(user_ptr, 100);
85     return TRUE;
86 }