1 #include "mind/mind-archer.h"
2 #include "action/action-limited.h"
3 #include "autopick/autopick.h"
4 #include "core/asking-player.h"
5 #include "core/player-update-types.h"
6 #include "flavor/flavor-describer.h"
7 #include "floor/cave.h"
8 #include "floor/floor-object.h"
9 #include "floor/geometry.h"
10 #include "grid/feature.h"
11 #include "grid/grid.h"
12 #include "inventory/inventory-object.h"
13 #include "io/command-repeater.h"
14 #include "object-enchant/apply-magic.h"
15 #include "object-enchant/item-apply-magic.h"
16 #include "object-enchant/object-boost.h"
17 #include "object-hook/hook-bow.h"
18 #include "object/item-tester-hooker.h"
19 #include "object/item-use-flags.h"
20 #include "object/object-generator.h"
21 #include "object/object-kind-hook.h"
22 #include "perception/object-perception.h"
23 #include "system/floor-type-definition.h"
24 #include "system/object-type-definition.h"
25 #include "system/player-type-definition.h"
26 #include "target/target-getter.h"
27 #include "util/bit-flags-calculator.h"
28 #include "view/display-messages.h"
30 enum ammo_creation_type {
37 static bool select_ammo_creation_type(ammo_creation_type &type, PLAYER_LEVEL plev)
40 if (repeat_pull(&code)) {
41 type = static_cast<ammo_creation_type>(code);
55 com = _("[S]弾, [A]矢, [B]クロスボウの矢 :", "Create [S]hots, Create [A]rrow or Create [B]olt ?");
57 com = _("[S]弾, [A]矢:", "Create [S]hots or Create [A]rrow ?");
59 com = _("[S]弾:", "Create [S]hots ?");
61 while (type == AMMO_NONE) {
64 if (!get_com(com, &ch, TRUE)) {
68 if (ch == 'S' || ch == 's') {
73 if ((ch == 'A' || ch == 'a') && (plev >= 10)) {
78 if ((ch == 'B' || ch == 'b') && (plev >= 20)) {
84 repeat_push(static_cast<COMMAND_CODE>(type));
89 * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
90 * Hook to determine if an object is contertible in an arrow/bolt
91 * @return 製造を実際に行ったらTRUE、キャンセルしたらFALSEを返す
93 bool create_ammo(player_type *creature_ptr)
95 if (cmd_limit_confused(creature_ptr) || cmd_limit_blind(creature_ptr))
98 ammo_creation_type ext = AMMO_NONE;
100 if (!select_ammo_creation_type(ext, creature_ptr->lev))
106 if (!get_rep_dir(creature_ptr, &dir, FALSE))
109 POSITION y = creature_ptr->y + ddy[dir];
110 POSITION x = creature_ptr->x + ddx[dir];
111 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
112 if (!has_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG)) {
113 msg_print(_("そこには岩石がない。", "You need a pile of rubble."));
117 if (!cave_has_flag_grid(g_ptr, FF_CAN_DIG) || !cave_has_flag_grid(g_ptr, FF_HURT_ROCK)) {
118 msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
123 object_type *q_ptr = &forge;
124 object_prep(creature_ptr, q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
125 q_ptr->number = (byte)rand_range(15, 30);
126 object_aware(creature_ptr, q_ptr);
128 apply_magic_to_object(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
129 q_ptr->discount = 99;
130 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
131 GAME_TEXT o_name[MAX_NLEN];
132 describe_flavor(creature_ptr, o_name, q_ptr, 0);
133 msg_format(_("%sを作った。", "You make some ammo."), o_name);
135 autopick_alter_item(creature_ptr, slot, FALSE);
137 cave_alter_feat(creature_ptr, y, x, FF_HURT_ROCK);
138 creature_ptr->update |= PU_FLOW;
142 item_tester_hook = item_tester_hook_convertible;
143 concptr q = _("どのアイテムから作りますか? ", "Convert which item? ");
144 concptr s = _("材料を持っていない。", "You have no item to convert.");
146 object_type *q_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, TV_NONE);
152 object_prep(creature_ptr, q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
153 q_ptr->number = (byte)rand_range(5, 10);
154 object_aware(creature_ptr, q_ptr);
156 apply_magic_to_object(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
157 q_ptr->discount = 99;
158 GAME_TEXT o_name[MAX_NLEN];
159 describe_flavor(creature_ptr, o_name, q_ptr, 0);
160 msg_format(_("%sを作った。", "You make some ammo."), o_name);
161 vary_item(creature_ptr, item, -1);
162 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
164 autopick_alter_item(creature_ptr, slot, FALSE);
169 item_tester_hook = item_tester_hook_convertible;
170 concptr q = _("どのアイテムから作りますか? ", "Convert which item? ");
171 concptr s = _("材料を持っていない。", "You have no item to convert.");
173 object_type *q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_NONE);
179 object_prep(creature_ptr, q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
180 q_ptr->number = (byte)rand_range(4, 8);
181 object_aware(creature_ptr, q_ptr);
183 apply_magic_to_object(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
184 q_ptr->discount = 99;
185 GAME_TEXT o_name[MAX_NLEN];
186 describe_flavor(creature_ptr, o_name, q_ptr, 0);
187 msg_format(_("%sを作った。", "You make some ammo."), o_name);
188 vary_item(creature_ptr, item, -1);
189 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
191 autopick_alter_item(creature_ptr, slot, FALSE);