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"
14 * @brief 魔道具術師の魔力取り込み処理
15 * @param user_ptr アイテムを取り込むクリーチャー
16 * @return 取り込みを実行したらTRUE、キャンセルしたらFALSEを返す
18 bool import_magic_device(player_type *user_ptr)
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.");
24 object_type *o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, 0);
28 if (o_ptr->tval == TV_STAFF && o_ptr->sval == SV_STAFF_NOTHING) {
29 msg_print(_("この杖には発動の為の能力は何も備わっていないようだ。", "This staff doesn't have any magical ability."));
33 if (!object_is_known(o_ptr)) {
34 msg_print(_("鑑定されていないと取り込めない。", "You need to identify before absorbing."));
39 msg_print(_("充填中のアイテムは取り込めない。", "This item is still charging."));
43 PARAMETER_VALUE pval = o_ptr->pval;
45 if (o_ptr->tval == TV_ROD)
47 else if (o_ptr->tval == TV_WAND)
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;
56 for (num = o_ptr->number; num; num--) {
58 if (o_ptr->tval == TV_WAND)
59 gain_num = (pval + num - 1) / num;
60 if (user_ptr->magic_num2[o_ptr->sval + ext]) {
62 gain_num = (gain_num / 3 + randint0(gain_num / 3)) / 256;
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;
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);
83 vary_item(user_ptr, item, -999);
84 take_turn(user_ptr, 100);