1 #include "cmd-item/cmd-equipment.h"
2 #include "action/weapon-shield.h"
3 #include "art-definition/art-protector-types.h"
4 #include "autopick/autopick.h"
5 #include "core/asking-player.h"
6 #include "core/player-redraw-types.h"
7 #include "core/player-update-types.h"
8 #include "core/window-redrawer.h"
9 #include "dungeon/quest.h" // todo
\88á
\98a
\8a´
\81A
\89½
\8cÌ
\83A
\83C
\83e
\83\80\82ð
\91\95\94õ
\82·
\82é
\82Æ
\83N
\83G
\83X
\83g
\82Ì
\90¬
\8c÷
\94»
\92è
\82ª
\91\96\82é
\82Ì
\82©
\81H.
10 #include "flavor/flavor-describer.h"
11 #include "flavor/object-flavor-types.h"
12 #include "floor/floor-object.h"
13 #include "game-option/birth-options.h"
14 #include "game-option/input-options.h"
15 #include "inventory/inventory-describer.h"
16 #include "inventory/inventory-object.h"
17 #include "inventory/inventory-slot-types.h"
18 #include "io/input-key-acceptor.h"
19 #include "io/input-key-requester.h"
20 #include "object-enchant/item-feeling.h"
21 #include "object-enchant/special-object-flags.h"
22 #include "object-enchant/trc-types.h"
23 #include "object-hook/hook-armor.h"
24 #include "object-hook/hook-checker.h"
25 #include "object-hook/hook-weapon.h"
26 #include "object/item-tester-hooker.h"
27 #include "object/item-use-flags.h"
28 #include "object/object-generator.h"
29 #include "object/object-info.h"
30 #include "object/object-mark-types.h"
31 #include "perception/object-perception.h"
32 #include "player/attack-defense-types.h"
33 #include "player-info/avatar.h"
34 #include "player/special-defense-types.h"
35 #include "racial/racial-android.h"
36 #include "spell-kind/spells-perception.h"
37 #include "status/action-setter.h"
38 #include "status/shape-changer.h"
39 #include "system/object-type-definition.h"
40 #include "term/screen-processor.h"
41 #include "util/int-char-converter.h"
42 #include "view/display-inventory.h"
43 #include "view/display-messages.h"
46 * @brief
\91\95\94õ
\88ê
\97\97\82ð
\95\
\8e¦
\82·
\82é
\83R
\83}
\83\93\83h
\82Ì
\83\81\83C
\83\93\83\8b\81[
\83`
\83\93 / Display equipment
49 void do_cmd_equip(player_type *creature_ptr)
54 command_wrk = USE_EQUIP;
57 (void)show_equipment(creature_ptr, 0, USE_FULL, 0);
58 WEIGHT weight = calc_inventory_weight(creature_ptr);
59 WEIGHT weight_lim = weight_limit(creature_ptr);
61 sprintf(out_val, "
\91\95\94õ
\81F
\8d\87\8cv %3d.%1d kg (
\8cÀ
\8aE
\82Ì%ld%%)
\83R
\83}
\83\93\83h: ", (int)lbtokg1(weight), (int)lbtokg2(weight), (long int)((weight * 100) / weight_lim));
63 sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ", (int)(weight / 10), (int)(weight % 10),
64 (long int)((weight * 100) / weight_lim);
68 command_new = inkey();
71 if (command_new != ESCAPE) {
77 term_get_size(&wid, &hgt);
79 command_gap = wid - 30;
82 bool select_ring_slot = FALSE;
85 * @brief
\91\95\94õ
\82·
\82é
\83R
\83}
\83\93\83h
\82Ì
\83\81\83C
\83\93\83\8b\81[
\83`
\83\93 / Wield or wear a single item from the pack or floor
86 * @param creature_ptr
\83v
\83\8c\81[
\83\84\81[
\82Ö
\82Ì
\8eQ
\8fÆ
\83|
\83C
\83\93\83^
89 void do_cmd_wield(player_type *creature_ptr)
91 OBJECT_IDX item, slot;
96 GAME_TEXT o_name[MAX_NLEN];
97 OBJECT_IDX need_switch_wielding = 0;
98 if (creature_ptr->special_defense & KATA_MUSOU)
99 set_action(creature_ptr, ACTION_NONE);
101 item_tester_hook = item_tester_hook_wear;
102 concptr q = _("
\82Ç
\82ê
\82ð
\91\95\94õ
\82µ
\82Ü
\82·
\82©? ", "Wear/Wield which item? ");
103 concptr s = _("
\91\95\94õ
\89Â
\94\
\82È
\83A
\83C
\83e
\83\80\82ª
\82È
\82¢
\81B", "You have nothing you can wear or wield.");
104 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_INVEN | USE_FLOOR), 0);
108 slot = wield_slot(creature_ptr, o_ptr);
110 switch (o_ptr->tval) {
114 if (has_melee_weapon(creature_ptr, INVEN_RARM) && has_melee_weapon(creature_ptr, INVEN_LARM)) {
115 item_tester_hook = item_tester_hook_melee_weapon;
116 q = _("
\82Ç
\82¿
\82ç
\82Ì
\95\90\8aí
\82Æ
\8eæ
\82è
\91Ö
\82¦
\82Ü
\82·
\82©?", "Replace which weapon? ");
117 s = _("
\82¨
\82Á
\82Æ
\81B", "Oops.");
118 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0))
121 if (slot == INVEN_RARM)
122 need_switch_wielding = INVEN_LARM;
123 } else if (has_melee_weapon(creature_ptr, INVEN_LARM))
125 else if (creature_ptr->inventory_list[INVEN_RARM].k_idx && !object_is_melee_weapon(&creature_ptr->inventory_list[INVEN_RARM])
126 && creature_ptr->inventory_list[INVEN_LARM].k_idx && !object_is_melee_weapon(&creature_ptr->inventory_list[INVEN_LARM])) {
127 item_tester_hook = item_tester_hook_mochikae;
128 q = _("
\82Ç
\82¿
\82ç
\82Ì
\8eè
\82É
\91\95\94õ
\82µ
\82Ü
\82·
\82©?", "Equip which hand? ");
129 s = _("
\82¨
\82Á
\82Æ
\81B", "Oops.");
130 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP), 0))
139 if (slot == INVEN_LARM) {
140 if (!get_check(_("
\93ñ
\93\81\97¬
\82Å
\90í
\82¢
\82Ü
\82·
\82©
\81H", "Dual wielding? ")))
142 } else if (!creature_ptr->inventory_list[INVEN_RARM].k_idx && has_melee_weapon(creature_ptr, INVEN_LARM)) {
143 if (!get_check(_("
\93ñ
\93\81\97¬
\82Å
\90í
\82¢
\82Ü
\82·
\82©
\81H", "Dual wielding? ")))
145 } else if (creature_ptr->inventory_list[INVEN_LARM].k_idx && creature_ptr->inventory_list[INVEN_RARM].k_idx) {
146 item_tester_hook = item_tester_hook_mochikae;
147 q = _("
\82Ç
\82¿
\82ç
\82Ì
\8eè
\82É
\91\95\94õ
\82µ
\82Ü
\82·
\82©?", "Equip which hand? ");
148 s = _("
\82¨
\82Á
\82Æ
\81B", "Oops.");
149 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP), 0))
152 if ((slot == INVEN_LARM) && !has_melee_weapon(creature_ptr, INVEN_RARM))
153 need_switch_wielding = INVEN_RARM;
158 if (creature_ptr->inventory_list[INVEN_LEFT].k_idx && creature_ptr->inventory_list[INVEN_RIGHT].k_idx)
159 q = _("
\82Ç
\82¿
\82ç
\82Ì
\8ew
\97Ö
\82Æ
\8eæ
\82è
\91Ö
\82¦
\82Ü
\82·
\82©?", "Replace which ring? ");
161 q = _("
\82Ç
\82¿
\82ç
\82Ì
\8eè
\82É
\91\95\94õ
\82µ
\82Ü
\82·
\82©?", "Equip which hand? ");
163 s = _("
\82¨
\82Á
\82Æ
\81B", "Oops.");
164 select_ring_slot = TRUE;
165 if (!choose_object(creature_ptr, &slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0)) {
166 select_ring_slot = FALSE;
170 select_ring_slot = FALSE;
174 if (object_is_cursed(&creature_ptr->inventory_list[slot])) {
175 describe_flavor(creature_ptr, o_name, &creature_ptr->inventory_list[slot], OD_OMIT_PREFIX | OD_NAME_ONLY);
177 msg_format("%s%s
\82Í
\8eô
\82í
\82ê
\82Ä
\82¢
\82é
\82æ
\82¤
\82¾
\81B", describe_use(creature_ptr, slot), o_name);
179 msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(creature_ptr, slot));
185 && ((object_is_cursed(o_ptr) && object_is_known(o_ptr))
186 || ((o_ptr->ident & IDENT_SENSE) && (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED)))) {
187 char dummy[MAX_NLEN + 80];
188 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
189 sprintf(dummy, _("
\96{
\93\96\82É%s{
\8eô
\82í
\82ê
\82Ä
\82¢
\82é}
\82ð
\8eg
\82¢
\82Ü
\82·
\82©
\81H", "Really use the %s {cursed}? "), o_name);
191 if (!get_check(dummy))
195 if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (creature_ptr->prace != RACE_VAMPIRE) && (creature_ptr->prace != RACE_ANDROID)) {
196 char dummy[MAX_NLEN + 100];
197 describe_flavor(creature_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
199 _("%s
\82ð
\91\95\94õ
\82·
\82é
\82Æ
\8bz
\8c\8c\8bS
\82É
\82È
\82è
\82Ü
\82·
\81B
\82æ
\82ë
\82µ
\82¢
\82Å
\82·
\82©
\81H", "%s will transforms you into a vampire permanently when equiped. Do you become a vampire?"),
202 if (!get_check(dummy))
206 if (need_switch_wielding && !object_is_cursed(&creature_ptr->inventory_list[need_switch_wielding])) {
207 object_type *slot_o_ptr = &creature_ptr->inventory_list[slot];
208 object_type *switch_o_ptr = &creature_ptr->inventory_list[need_switch_wielding];
209 object_type object_tmp;
210 object_type *otmp_ptr = &object_tmp;
211 GAME_TEXT switch_name[MAX_NLEN];
212 describe_flavor(creature_ptr, switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
213 object_copy(otmp_ptr, switch_o_ptr);
214 object_copy(switch_o_ptr, slot_o_ptr);
215 object_copy(slot_o_ptr, otmp_ptr);
216 msg_format(_("%s
\82ð%s
\82É
\8d\
\82¦
\82È
\82¨
\82µ
\82½
\81B", "You wield %s at %s hand."), switch_name,
217 (slot == INVEN_RARM) ? (left_hander ? _("
\8d¶
\8eè", "left") : _("
\89E
\8eè", "right")) : (left_hander ? _("
\89E
\8eè", "right") : _("
\8d¶
\8eè", "left")));
218 slot = need_switch_wielding;
221 check_find_art_quest_completion(creature_ptr, o_ptr);
222 if (creature_ptr->pseikaku == PERSONALITY_MUNCHKIN) {
223 identify_item(creature_ptr, o_ptr);
224 autopick_alter_item(creature_ptr, item, FALSE);
227 take_turn(creature_ptr, 100);
229 object_copy(q_ptr, o_ptr);
232 inven_item_increase(creature_ptr, item, -1);
233 inven_item_optimize(creature_ptr, item);
235 floor_item_increase(creature_ptr->current_floor_ptr, 0 - item, -1);
236 floor_item_optimize(creature_ptr, 0 - item);
239 o_ptr = &creature_ptr->inventory_list[slot];
241 (void)inven_takeoff(creature_ptr, slot, 255);
243 object_copy(o_ptr, q_ptr);
244 o_ptr->marked |= OM_TOUCHED;
245 creature_ptr->equip_cnt++;
247 #define STR_WIELD_RARM _("%s(%c)
\82ð
\89E
\8eè
\82É
\91\95\94õ
\82µ
\82½
\81B", "You are wielding %s (%c) in your right hand.")
248 #define STR_WIELD_LARM _("%s(%c)
\82ð
\8d¶
\8eè
\82É
\91\95\94õ
\82µ
\82½
\81B", "You are wielding %s (%c) in your left hand.")
249 #define STR_WIELD_ARMS _("%s(%c)
\82ð
\97¼
\8eè
\82Å
\8d\
\82¦
\82½
\81B", "You are wielding %s (%c) with both hands.")
253 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) && can_two_hands_wielding(creature_ptr))
254 act = STR_WIELD_ARMS;
256 act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
260 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) && can_two_hands_wielding(creature_ptr))
261 act = STR_WIELD_ARMS;
263 act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
267 act = _("%s(%c)
\82ð
\8eË
\8c\82\97p
\82É
\91\95\94õ
\82µ
\82½
\81B", "You are shooting with %s (%c).");
270 act = _("%s(%c)
\82ð
\8cõ
\8c¹
\82É
\82µ
\82½
\81B", "Your light source is %s (%c).");
273 act = _("%s(%c)
\82ð
\91\95\94õ
\82µ
\82½
\81B", "You are wearing %s (%c).");
277 describe_flavor(creature_ptr, o_name, o_ptr, 0);
278 msg_format(act, o_name, index_to_label(slot));
279 if (object_is_cursed(o_ptr)) {
280 msg_print(_("
\82¤
\82í
\81I
\82·
\82³
\82Ü
\82¶
\82
\97â
\82½
\82¢
\81I", "Oops! It feels deathly cold!"));
281 chg_virtue(creature_ptr, V_HARMONY, -1);
282 o_ptr->ident |= (IDENT_SENSE);
285 if ((o_ptr->name1 == ART_STONEMASK) && (creature_ptr->prace != RACE_VAMPIRE) && (creature_ptr->prace != RACE_ANDROID))
286 change_race(creature_ptr, RACE_VAMPIRE, "");
288 creature_ptr->update |= PU_BONUS | PU_TORCH | PU_MANA;
289 creature_ptr->redraw |= PR_EQUIPPY;
290 creature_ptr->window |= PW_INVEN | PW_EQUIP | PW_PLAYER;
291 calc_android_exp(creature_ptr);
295 * @brief
\91\95\94õ
\82ð
\8aO
\82·
\83R
\83}
\83\93\83h
\82Ì
\83\81\83C
\83\93\83\8b\81[
\83`
\83\93 / Take off an item
298 void do_cmd_takeoff(player_type *creature_ptr)
302 if (creature_ptr->special_defense & KATA_MUSOU)
303 set_action(creature_ptr, ACTION_NONE);
305 concptr q = _("
\82Ç
\82ê
\82ð
\91\95\94õ
\82©
\82ç
\82Í
\82¸
\82µ
\82Ü
\82·
\82©? ", "Take off which item? ");
306 concptr s = _("
\82Í
\82¸
\82¹
\82é
\91\95\94õ
\82ª
\82È
\82¢
\81B", "You are not wearing anything to take off.");
307 o_ptr = choose_object(creature_ptr, &item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT), 0);
311 if (object_is_cursed(o_ptr)) {
312 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (creature_ptr->pclass != CLASS_BERSERKER)) {
313 msg_print(_("
\82Ó
\81[
\82Þ
\81A
\82Ç
\82¤
\82â
\82ç
\8eô
\82í
\82ê
\82Ä
\82¢
\82é
\82æ
\82¤
\82¾
\81B", "Hmmm, it seems to be cursed."));
317 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4)) {
318 msg_print(_("
\8eô
\82í
\82ê
\82½
\91\95\94õ
\82ð
\97Í
\82Ã
\82
\82Å
\94\8d\82ª
\82µ
\82½
\81I", "You tore off a piece of cursed equipment by sheer strength!"));
319 o_ptr->ident |= (IDENT_SENSE);
320 o_ptr->curse_flags = 0L;
321 o_ptr->feeling = FEEL_NONE;
322 creature_ptr->update |= PU_BONUS;
323 creature_ptr->window |= PW_EQUIP;
324 msg_print(_("
\8eô
\82¢
\82ð
\91Å
\82¿
\94j
\82Á
\82½
\81B", "You break the curse."));
326 msg_print(_("
\91\95\94õ
\82ð
\8aO
\82¹
\82È
\82©
\82Á
\82½
\81B", "You couldn't remove the equipment."));
327 take_turn(creature_ptr, 50);
332 take_turn(creature_ptr, 50);
333 (void)inven_takeoff(creature_ptr, item, 255);
334 verify_equip_slot(creature_ptr, item);
335 calc_android_exp(creature_ptr);
336 creature_ptr->redraw |= PR_EQUIPPY;