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 "object-enchant/apply-magic.h"
14 #include "object-enchant/item-apply-magic.h"
15 #include "object-enchant/object-boost.h"
16 #include "object-hook/hook-bow.h"
17 #include "object/item-tester-hooker.h"
18 #include "object/item-use-flags.h"
19 #include "object/object-generator.h"
20 #include "object/object-kind-hook.h"
21 #include "perception/object-perception.h"
22 #include "system/floor-type-definition.h"
23 #include "system/object-type-definition.h"
24 #include "system/player-type-definition.h"
25 #include "target/target-getter.h"
26 #include "util/bit-flags-calculator.h"
27 #include "view/display-messages.h"
29 enum ammo_creation_type {
37 * @brief「弾/矢の製造」処理 / do_cmd_cast calls this function if the player's class is 'archer'.
38 * Hook to determine if an object is contertible in an arrow/bolt
39 * @return 製造を実際に行ったらTRUE、キャンセルしたらFALSEを返す
41 bool create_ammo(player_type *creature_ptr)
44 if (creature_ptr->lev >= 20)
45 sprintf(com, _("[S]弾, [A]矢, [B]クロスボウの矢 :", "Create [S]hots, Create [A]rrow or Create [B]olt ?"));
46 else if (creature_ptr->lev >= 10)
47 sprintf(com, _("[S]弾, [A]矢:", "Create [S]hots or Create [A]rrow ?"));
49 sprintf(com, _("[S]弾:", "Create [S]hots ?"));
51 if (cmd_limit_confused(creature_ptr) || cmd_limit_blind(creature_ptr))
54 ammo_creation_type ext = AMMO_NONE;
57 if (!get_com(com, &ch, TRUE)) {
61 if (ch == 'S' || ch == 's') {
66 if ((ch == 'A' || ch == 'a') && (creature_ptr->lev >= 10)) {
71 if ((ch == 'B' || ch == 'b') && (creature_ptr->lev >= 20)) {
80 if (!get_rep_dir(creature_ptr, &dir, FALSE))
83 POSITION y = creature_ptr->y + ddy[dir];
84 POSITION x = creature_ptr->x + ddx[dir];
85 grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
86 if (!has_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_CAN_DIG)) {
87 msg_print(_("そこには岩石がない。", "You need a pile of rubble."));
91 if (!cave_has_flag_grid(g_ptr, FF_CAN_DIG) || !cave_has_flag_grid(g_ptr, FF_HURT_ROCK)) {
92 msg_print(_("硬すぎて崩せなかった。", "You failed to make ammo."));
97 object_type *q_ptr = &forge;
98 object_prep(creature_ptr, q_ptr, lookup_kind(TV_SHOT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
99 q_ptr->number = (byte)rand_range(15, 30);
100 object_aware(creature_ptr, q_ptr);
102 apply_magic(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
103 q_ptr->discount = 99;
104 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
105 GAME_TEXT o_name[MAX_NLEN];
106 describe_flavor(creature_ptr, o_name, q_ptr, 0);
107 msg_format(_("%sを作った。", "You make some ammo."), o_name);
109 autopick_alter_item(creature_ptr, slot, FALSE);
111 cave_alter_feat(creature_ptr, y, x, FF_HURT_ROCK);
112 creature_ptr->update |= PU_FLOW;
116 item_tester_hook = item_tester_hook_convertible;
117 concptr q = _("どのアイテムから作りますか? ", "Convert which item? ");
118 concptr s = _("材料を持っていない。", "You have no item to convert.");
120 object_type *q_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, TV_NONE);
126 object_prep(creature_ptr, q_ptr, lookup_kind(TV_ARROW, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
127 q_ptr->number = (byte)rand_range(5, 10);
128 object_aware(creature_ptr, q_ptr);
130 apply_magic(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
131 q_ptr->discount = 99;
132 GAME_TEXT o_name[MAX_NLEN];
133 describe_flavor(creature_ptr, o_name, q_ptr, 0);
134 msg_format(_("%sを作った。", "You make some ammo."), o_name);
135 vary_item(creature_ptr, item, -1);
136 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
138 autopick_alter_item(creature_ptr, slot, FALSE);
143 item_tester_hook = item_tester_hook_convertible;
144 concptr q = _("どのアイテムから作りますか? ", "Convert which item? ");
145 concptr s = _("材料を持っていない。", "You have no item to convert.");
147 object_type *q_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), TV_NONE);
153 object_prep(creature_ptr, q_ptr, lookup_kind(TV_BOLT, (OBJECT_SUBTYPE_VALUE)m_bonus(1, creature_ptr->lev) + 1));
154 q_ptr->number = (byte)rand_range(4, 8);
155 object_aware(creature_ptr, q_ptr);
157 apply_magic(creature_ptr, q_ptr, creature_ptr->lev, AM_NO_FIXED_ART);
158 q_ptr->discount = 99;
159 GAME_TEXT o_name[MAX_NLEN];
160 describe_flavor(creature_ptr, o_name, q_ptr, 0);
161 msg_format(_("%sを作った。", "You make some ammo."), o_name);
162 vary_item(creature_ptr, item, -1);
163 s16b slot = store_item_to_inventory(creature_ptr, q_ptr);
165 autopick_alter_item(creature_ptr, slot, FALSE);