/* * Take off an item */ void do_cmd_takeoff(void) { int item; object_type *o_ptr; cptr q, s; /* Get an item */ #ifdef JP q = "どれを装備からはずしますか? "; s = "はずせる装備がない。"; #else q = "Take off which item? "; s = "You are not wearing anything to take off."; #endif if (!get_item(&item, q, s, (USE_EQUIP))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Item is cursed */ if (cursed_p(o_ptr)) { /* Oops */ #ifdef JP msg_print("ふーむ、どうやら呪われているようだ。"); #else msg_print("Hmmm, it seems to be cursed."); #endif /* Nope */ return; } /* Take a partial turn */ energy_use = 50; /* Take off the item */ (void)inven_takeoff(item, 255); /* Swap hands wielding sub weapon */ if (item == INVEN_WIELD) swap_wielding_hands(); p_ptr->redraw |= (PR_EQUIPPY); }
/* * Calc which body parts the player have, based on the * monster he incarnate, note that that's bnot a hack * since body parts of the player when in it's own body * are also defined in r_info(monster 0) */ void calc_body() { monster_type *body = &p_ptr->body_monster; monster_race *r_ptr = &r_info[body->r_idx]; s32b i; if (p_ptr->body_monster.r_idx == 0) { /* Setup for player race */ for (i = 0; i < INVEN_TOTAL; i++) { /* Get the race/subrace slots */ s32b max = flag_get(&p_ptr->descriptor.body_parts, i); if (max < 0) max = 0; flag_set(get_inven(p_ptr, i), INVEN_LIMIT_KEY, max); } } else { /* Setup for monster race */ for (i = 0; i < INVEN_TOTAL; i++) { s32b max = flag_get(&r_ptr->body_parts, i); if (max < 0) max = 0; flag_set(get_inven(p_ptr, i), INVEN_LIMIT_KEY, max); } } /* Do we need more parts ? ;) */ process_hooks(HOOK_BODY_PARTS, "()"); /* Ok now if the player lost a body part, he must drop the object he had on it */ for (i = 0; i < INVEN_TOTAL; i++) { flags_type *inven = get_inven(p_ptr, i); s32b j; /* For all objects that are in excess, drop them */ for (j = flag_max_key(inven); j > inventory_limit_inven(inven); j--) { /* Drop it NOW ! */ if (i > INVEN_INVEN) inven_takeoff(compute_slot(i, j), 255, TRUE, FALSE); else inven_drop(compute_slot(i, j), 255, p_ptr->py, p_ptr->px, FALSE); } } }
/** * Drop (some of) a non-cursed inventory/equipment item "near" the current * location * * There are two cases here - a single object or entire stack is being dropped, * or part of a stack is being split off and dropped */ void inven_drop(struct object *obj, int amt) { int py = player->py; int px = player->px; struct object *dropped; char o_name[80]; char label; /* Error check */ if (amt <= 0) return; /* Check it is still held, in case there were two drop commands queued * for this item. This is in theory not ideal, but in practice should * be safe. */ if (!pile_contains(player->gear, obj)) return; /* Get where the object is now */ label = gear_to_label(obj); /* Not too many */ if (amt > obj->number) amt = obj->number; /* Take off equipment */ if (object_is_equipped(player->body, obj)) inven_takeoff(obj); /* Get the object */ dropped = gear_object_for_use(obj, amt, TRUE); /* Describe the dropped object */ object_desc(o_name, sizeof(o_name), dropped, ODESC_PREFIX | ODESC_FULL); /* Message */ msg("You drop %s (%c).", o_name, label); /* Drop it near the player */ drop_near(cave, dropped, 0, py, px, FALSE); event_signal(EVENT_INVENTORY); event_signal(EVENT_EQUIPMENT); }
/* * Take off an item */ void do_cmd_takeoff(void) { int item; object_type *o_ptr; cptr q, s; /* Get an item */ q = "Take off which item? "; s = "You are not wearing anything to take off."; if (!get_item(&item, q, s, (USE_EQUIP))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Item is cursed */ if (cursed_p(o_ptr)) { /* Oops */ msg_print("Hmmm, it seems to be cursed."); /* Nope */ return; } /* Take a partial turn */ p_ptr->energy_use = 50; /* Take off the item */ (void)inven_takeoff(item, 255); }
/** * Drop (some of) a non-cursed inventory/equipment item "near" the current * location * * There are two cases here - a single object or entire stack is being dropped, * or part of a stack is being split off and dropped */ void inven_drop(struct object *obj, int amt) { int py = player->py; int px = player->px; struct object *dropped; char o_name[80]; /* Error check */ if (amt <= 0) return; /* This should not happen - ask for report */ if (!pile_contains(player->gear, obj)) { /* Describe the dropped object */ object_desc(o_name, sizeof(o_name), obj, ODESC_PREFIX | ODESC_FULL); msg("Bug - attempt to drop %s when not held!", o_name); return; } /* Not too many */ if (amt > obj->number) amt = obj->number; /* Take off equipment */ if (object_is_equipped(player->body, obj)) inven_takeoff(obj); /* Get the object */ dropped = gear_object_for_use(obj, amt, TRUE); /* Describe the dropped object */ object_desc(o_name, sizeof(o_name), dropped, ODESC_PREFIX | ODESC_FULL); /* Message */ msg("You drop %s (%c).", o_name, gear_to_label(obj)); /* Drop it near the player */ drop_near(cave, dropped, 0, py, px, FALSE); event_signal(EVENT_INVENTORY); }
/* Take off an item */ void do_cmd_takeoff(cmd_code code, cmd_arg args[]) { int item = args[0].item; if (!item_is_available(item, NULL, USE_EQUIP)) { msg("You are not wielding that item."); return; } if (!obj_can_takeoff(object_from_item_idx(item))) { msg("You cannot take off that item."); return; } (void)inven_takeoff(item, 255); pack_overflow(); p_ptr->energy_use = 50; }
/** * Drop (some of) a non-cursed inventory/equipment item "near" the current * location * * There are two cases here - a single object or entire stack is being dropped, * or part of a stack is being split off and dropped */ void inven_drop(struct object *obj, int amt) { int py = player->py; int px = player->px; struct object *dropped; bool none_left = false; bool quiver = false; char name[80]; char label; /* Error check */ if (amt <= 0) return; /* Check it is still held, in case there were two drop commands queued * for this item. This is in theory not ideal, but in practice should * be safe. */ if (!object_is_carried(player, obj)) return; /* Get where the object is now */ label = gear_to_label(obj); /* Is it in the quiver? */ if (object_is_in_quiver(player, obj)) quiver = true; /* Not too many */ if (amt > obj->number) amt = obj->number; /* Take off equipment, don't combine */ if (object_is_equipped(player->body, obj)) inven_takeoff(obj); /* Get the object */ dropped = gear_object_for_use(obj, amt, false, &none_left); /* Describe the dropped object */ object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL); /* Message */ msg("You drop %s (%c).", name, label); /* Describe what's left */ if (dropped->artifact) { object_desc(name, sizeof(name), dropped, ODESC_FULL | ODESC_SINGULAR); msg("You no longer have the %s (%c).", name, label); } else if (none_left) { /* Play silly games to get the right description */ int number = dropped->number; dropped->number = 0; object_desc(name, sizeof(name), dropped, ODESC_PREFIX | ODESC_FULL); msg("You have %s (%c).", name, label); dropped->number = number; } else { object_desc(name, sizeof(name), obj, ODESC_PREFIX | ODESC_FULL); msg("You have %s (%c).", name, label); } /* Drop it near the player */ drop_near(cave, &dropped, 0, py, px, false); /* Sound for quiver objects */ if (quiver) sound(MSG_QUIVER); event_signal(EVENT_INVENTORY); event_signal(EVENT_EQUIPMENT); }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(void) { int i, item, slot; object_type forge; object_type *q_ptr; object_type *o_ptr; cptr act; char o_name[MAX_NLEN]; cptr q, s; int need_switch_wielding = 0; if (p_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ #ifdef JP q = "どれを装備しますか? "; s = "装備可能なアイテムがない。"; #else q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Check the slot */ slot = wield_slot(o_ptr); /* Ugly hack! */ if ( object_is_melee_weapon(o_ptr) && p_ptr->pclass == CLASS_PSION && psion_weapon_graft() ) { msg_print("Failed! Your weapon is currently grafted to your arm!"); return; } switch (o_ptr->tval) { /* Shields and some misc. items */ case TV_CAPTURE: case TV_SHIELD: case TV_CARD: /* Dual wielding */ if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM)) { /* Restrict the choices */ item_tester_hook = item_tester_hook_melee_weapon; item_tester_no_ryoute = TRUE; /* Choose a weapon from the equipment only */ #ifdef JP q = "どちらの武器と取り替えますか?"; s = "おっと。"; #else q = "Replace which weapon? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM; } else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM; /* Both arms are already used by non-weapon */ else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) && inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM])) { /* Restrict the choices */ item_tester_hook = item_tester_hook_mochikae; /* Choose a hand */ #ifdef JP q = "どちらの手に装備しますか?"; s = "おっと。"; #else q = "Equip which hand? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } break; /* Melee weapons */ case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: /* Asking for dual wielding */ if (slot == INVEN_LARM) { #ifdef JP if (!get_check("二刀流で戦いますか?")) slot = INVEN_RARM; #else if (!get_check("Dual wielding? ")) slot = INVEN_RARM; #endif } else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM)) { #ifdef JP if (!get_check("二刀流で戦いますか?")) slot = INVEN_LARM; #else if (!get_check("Dual wielding? ")) slot = INVEN_LARM; #endif } /* Both arms are already used */ else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx) { /* Restrict the choices */ item_tester_hook = item_tester_hook_mochikae; /* Choose a hand */ #ifdef JP q = "どちらの手に装備しますか?"; s = "おっと。"; #else q = "Equip which hand? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM)) need_switch_wielding = INVEN_RARM; } break; /* Rings */ case TV_RING: /* Choose a ring slot */ if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx) { #ifdef JP q = "どちらの指輪と取り替えますか?"; #else q = "Replace which ring? "; #endif } else { #ifdef JP q = "どちらの手に装備しますか?"; #else q = "Equip which hand? "; #endif } #ifdef JP s = "おっと。"; #else s = "Oops."; #endif /* Restrict the choices */ select_ring_slot = TRUE; item_tester_no_ryoute = TRUE; if (!get_item(&slot, q, s, (USE_EQUIP))) { select_ring_slot = FALSE; return; } select_ring_slot = FALSE; break; } /* Prevent wielding into a cursed slot */ if (object_is_cursed(&inventory[slot])) { /* Describe it */ object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY)); /* Message */ #ifdef JP msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name ); #else msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); #endif /* Cancel the command */ return; } if (have_flag(inventory[slot].art_flags, TR_SIGNATURE)) { object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY)); msg_format("The %s you are %s is your signature item and may not be removed.", o_name, describe_use(slot)); return; } if (confirm_wear && ((object_is_cursed(o_ptr) && object_is_known(o_ptr)) || ((o_ptr->ident & IDENT_SENSE) && (FEEL_BROKEN <= o_ptr->feeling) && (o_ptr->feeling <= FEEL_CURSED)))) { char dummy[MAX_NLEN+80]; /* Describe it */ object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); #ifdef JP sprintf(dummy, "本当に%s{呪われている}を使いますか?", o_name); #else sprintf(dummy, "Really use the %s {cursed}? ", o_name); #endif if (!get_check(dummy)) return; } if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID) && (p_ptr->pclass != CLASS_BLOOD_KNIGHT)) { char dummy[MAX_NLEN+80]; /* Describe it */ object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); #ifdef JP sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name); #else msg_format("%s will transforms you into a vampire permanently when equiped.", o_name); sprintf(dummy, "Do you become a vampire?"); #endif if (!get_check(dummy)) return; } if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding])) { object_type *slot_o_ptr = &inventory[slot]; object_type *switch_o_ptr = &inventory[need_switch_wielding]; object_type object_tmp; object_type *otmp_ptr = &object_tmp; char switch_name[MAX_NLEN]; object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY)); object_copy(otmp_ptr, switch_o_ptr); object_copy(switch_o_ptr, slot_o_ptr); object_copy(slot_o_ptr, otmp_ptr); #ifdef JP msg_format("%sを%sに構えなおした。", switch_name, (slot == INVEN_RARM) ? (left_hander ? "左手" : "右手") : (left_hander ? "右手" : "左手")); #else msg_format("You wield %s at %s hand.", switch_name, (slot == INVEN_RARM) ? (left_hander ? "left" : "right") : (left_hander ? "right" : "left")); #endif slot = need_switch_wielding; } /* Check if completed a quest */ for (i = 0; i < max_quests; i++) { if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) && (quest[i].status == QUEST_STATUS_TAKEN) && (quest[i].k_idx == o_ptr->name1 || quest[i].k_idx == o_ptr->name3)) { if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL); quest[i].status = QUEST_STATUS_COMPLETED; quest[i].complev = (byte)p_ptr->lev; #ifdef JP msg_print("クエストを達成した!"); #else msg_print("You completed the quest!"); #endif msg_print(NULL); } } if (p_ptr->personality == PERS_MUNCHKIN) { identify_item(o_ptr); /* Auto-inscription */ autopick_alter_item(item, FALSE); } /* Take a turn */ energy_use = weaponmaster_wield_hack(o_ptr); /* Get local object */ q_ptr = &forge; /* Obtain local object */ object_copy(q_ptr, o_ptr); /* Modify quantity */ q_ptr->number = 1; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } /* Access the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Wear the new stuff */ object_copy(o_ptr, q_ptr); /* Player touches it */ o_ptr->marked |= OM_TOUCHED; /* Increase the weight */ p_ptr->total_weight += q_ptr->weight; /* Increment the equip counter by hand */ equip_cnt++; #ifdef JP #define STR_WIELD_RARM "%s(%c)を右手に装備した。" #define STR_WIELD_LARM "%s(%c)を左手に装備した。" #define STR_WIELD_ARMS "%s(%c)を両手で構えた。" #else #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand." #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand." #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands." #endif /* Where is the item now */ switch (slot) { case INVEN_RARM: if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING()) act = STR_WIELD_ARMS; else act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM); break; case INVEN_LARM: if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING()) act = STR_WIELD_ARMS; else act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM); break; case INVEN_BOW: #ifdef JP act = "%s(%c)を射撃用に装備した。"; #else act = "You are shooting with %s (%c)."; #endif break; case INVEN_LITE: #ifdef JP act = "%s(%c)を光源にした。"; #else act = "Your light source is %s (%c)."; #endif break; default: #ifdef JP act = "%s(%c)を装備した。"; #else act = "You are wearing %s (%c)."; #endif break; } /* Describe the result */ object_desc(o_name, o_ptr, 0); /* Message */ msg_format(act, o_name, index_to_label(slot)); /* Cursed! */ if (object_is_cursed(o_ptr)) { /* Warn the player */ #ifdef JP msg_print("うわ! すさまじく冷たい!"); #else msg_print("Oops! It feels deathly cold!"); #endif chg_virtue(V_HARMONY, -1); /* Note the curse */ o_ptr->ident |= (IDENT_SENSE); } if (o_ptr->name1 == ART_HAND_OF_VECNA) { msg_print("You chop off your own hand to wield the Hand of Vecna!"); set_cut(CUT_MORTAL_WOUND, FALSE); } if (o_ptr->name1 == ART_EYE_OF_VECNA) { msg_print("You pluck out your own eye to wield the Eye of Vecna!"); set_cut(CUT_MORTAL_WOUND, FALSE); } /* The Stone Mask make the player turn into a vampire! */ if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID) && (p_ptr->pclass != CLASS_BLOOD_KNIGHT) && (p_ptr->pclass != CLASS_BLOOD_MAGE)) { /* Turn into a vampire */ change_race(RACE_VAMPIRE, ""); } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Recalculate mana */ p_ptr->update |= (PU_MANA); p_ptr->redraw |= (PR_EQUIPPY); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); calc_android_exp(); }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(void) { int item, slot; object_type *o_ptr; object_type *i_ptr; object_type object_type_body; cptr act; cptr q, s; char o_name[80]; /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Check the slot */ slot = wield_slot(o_ptr); /* Prevent wielding into a cursed slot */ if (cursed_p(&inventory[slot])) { /* Describe it */ object_desc(o_name, &inventory[slot], FALSE, 0); /* Message */ msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); /* Cancel the command */ return; } /* Take a turn */ p_ptr->energy_use = 100; /* Get local object */ i_ptr = &object_type_body; /* Obtain local object */ object_copy(i_ptr, o_ptr); /* Modify quantity */ i_ptr->number = 1; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } /* Get the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Wear the new stuff */ object_copy(o_ptr, i_ptr); /* Increase the weight */ p_ptr->total_weight += i_ptr->weight; /* Increment the equip counter by hand */ p_ptr->equip_cnt++; /* Where is the item now */ if (slot == INVEN_WIELD) { act = "You are wielding"; } else if (slot == INVEN_BOW) { act = "You are shooting with"; } else if (slot == INVEN_LIGHT) { act = "Your light source is"; } else { act = "You are wearing"; } /* Describe the result */ object_desc(o_name, o_ptr, TRUE, 3); /* Message */ msg_format("%s %s (%c).", act, o_name, index_to_label(slot)); /* Cursed! */ if (cursed_p(o_ptr)) { /* Warn the player */ msg_print("Oops! It feels deathly cold!"); /* Remove special inscription, if any */ if (o_ptr->discount >= INSCRIP_NULL) o_ptr->discount = 0; /* Sense the object if allowed */ if (o_ptr->discount == 0) o_ptr->discount = INSCRIP_CURSED; /* The object has been "sensed" */ o_ptr->ident |= (IDENT_SENSE); } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Recalculate mana */ p_ptr->update |= (PU_MANA); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER_0 | PW_PLAYER_1); p_ptr->redraw |= (PR_EQUIPPY); }
/* * Wield or wear a single item from the pack or floor */ void wield_item(object_type *o_ptr, int item, int slot) { object_type object_type_body; object_type *i_ptr = &object_type_body; const char *fmt; char o_name[80]; bool combined_ammo = FALSE; bool track_wielded_item = FALSE; int num = 1; /* If we are stacking ammo in the quiver */ if (obj_is_ammo(o_ptr)) { num = o_ptr->number; combined_ammo = object_similar(o_ptr, &p_ptr->inventory[slot], OSTACK_QUIVER); } /* Take a turn */ p_ptr->energy_use = 100; /* Obtain local object */ object_copy(i_ptr, o_ptr); /* Modify quantity */ i_ptr->number = num; /* Update object_idx if necessary, once object is in slot */ if (p_ptr->object_idx == item) { track_wielded_item = TRUE; } /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -num); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -num); floor_item_optimize(0 - item); } /* Get the wield slot */ o_ptr = &p_ptr->inventory[slot]; if (combined_ammo) { /* Add the new ammo to the already-quiver-ed ammo */ object_absorb(o_ptr, i_ptr); } else { /* Take off existing item */ if (o_ptr->kind) (void)inven_takeoff(slot, 255); /* If we are wielding ammo we may need to "open" the slot by shifting * later ammo up the quiver; this is because we already called the * inven_item_optimize() function. */ if (slot >= QUIVER_START) open_quiver_slot(slot); /* Wear the new stuff */ object_copy(o_ptr, i_ptr); /* Increment the equip counter by hand */ p_ptr->equip_cnt++; } /* Increase the weight */ p_ptr->total_weight += i_ptr->weight * num; /* Track object if necessary */ if (track_wielded_item) { track_object(slot); } /* Do any ID-on-wield */ object_notice_on_wield(o_ptr); /* Where is the item now */ if (slot == INVEN_WIELD) fmt = "You are wielding %s (%c)."; else if (slot == INVEN_BOW) fmt = "You are shooting with %s (%c)."; else if (slot == INVEN_LIGHT) fmt = "Your light source is %s (%c)."; else if (combined_ammo) fmt = "You combine %s in your quiver (%c)."; else if (slot >= QUIVER_START && slot < QUIVER_END) fmt = "You add %s to your quiver (%c)."; else fmt = "You are wearing %s (%c)."; /* Describe the result */ object_desc(o_name, sizeof(o_name), o_ptr, ODESC_PREFIX | ODESC_FULL); /* Message */ msgt(MSG_WIELD, fmt, o_name, index_to_label(slot)); /* Cursed! */ if (cursed_p(o_ptr->flags)) { /* Warn the player */ msgt(MSG_CURSED, "Oops! It feels deathly cold!"); /* Sense the object */ object_notice_curses(o_ptr); } /* Save quiver size */ save_quiver_size(p_ptr); /* See if we have to overflow the pack */ pack_overflow(); /* Recalculate bonuses, torch, mana */ p_ptr->notice |= PN_SORT_QUIVER; p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA); p_ptr->redraw |= (PR_INVEN | PR_EQUIP); }
static void choose_melee() { int i, j, z = 0; character_icky = TRUE; Term_save(); Term_clear(); j = get_melee_skills(); prt("Choose a melee style:", 0, 0); for (i = 0; i < MAX_MELEE; i++) { if (melee_bool[i]) { prt(format("%c) %s", I2A(z), melee_names[i]), z + 1, 0); melee_num[z] = i; z++; } } while (TRUE) { char c = inkey(); if (c == ESCAPE) break; if (A2I(c) < 0) continue; if (A2I(c) >= j) continue; for (i = 0, z = 0; z < A2I(c); i++) if (melee_bool[i]) z++; for (i = INVEN_WIELD; p_ptr->body_parts[i - INVEN_WIELD] == INVEN_WIELD; i++) { if (p_ptr->inventory[i].k_idx) { if (cursed_p(&p_ptr->inventory[i])) { char name[80]; object_desc(name, &p_ptr->inventory[i], 0, 0); msg_format("Hmmm, your %s seems to be cursed.", name); break; } else { inven_takeoff(i, 255, FALSE); } } } p_ptr->melee_style = melee_skills[melee_num[z]]; energy_use = 100; break; } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate hitpoint */ p_ptr->update |= (PU_HP); /* Redraw monster hitpoint */ p_ptr->redraw |= (PR_MH); Term_load(); character_icky = FALSE; }
/* * Take off an item */ void do_cmd_takeoff(object_type *default_o_ptr, int default_item) { int item; object_type *o_ptr; cptr q, s; // use specified item if possible if (default_o_ptr != NULL) { o_ptr = default_o_ptr; item = default_item; } /* Get an item */ else { q = "Remove which item? "; s = "You are not wearing anything to remove."; if (!get_item(&item, q, s, (USE_EQUIP))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } } /* Item is cursed */ if (cursed_p(o_ptr)) { if (p_ptr->active_ability[S_WIL][WIL_CURSE_BREAKING]) { /* Message */ msg_print("With a great strength of will, you break the curse!"); /* Uncurse the object */ uncurse_object(o_ptr); } else { /* Oops */ msg_print("It seems to be cursed, preventing you from removing it."); /* Nope */ return; } } /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; /* Take off the item */ (void)inven_takeoff(item, 255); /* Deal with wielding of shield when already wielding a hand and a half weapon */ if ((item == INVEN_ARM) && (k_info[inventory[INVEN_WIELD].k_idx].flags3 & (TR3_HAND_AND_A_HALF))) { char o_name[80]; /* Describe it */ object_desc(o_name, sizeof(o_name), &inventory[INVEN_WIELD], FALSE, 0); /* Message */ msg_format("You can now wield your %s more effectively.", o_name); } }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(object_type *default_o_ptr, int default_item) { int item, slot; object_type *o_ptr; object_type *i_ptr; object_type object_type_body; cptr act; cptr q, s; int i, quantity, original_quantity; bool weapon_less_effective = FALSE; bool grants_two_weapon = FALSE; char o_name[80]; bool combine = FALSE; // use specified item if possible if (default_o_ptr != NULL) { o_ptr = default_o_ptr; item = default_item; } /* Get an item */ else { /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } else { o_ptr = &o_list[0 - item]; } } // remember how many there were original_quantity = o_ptr->number; // Check whether it would be too heavy if ((item < 0) && (p_ptr->total_weight + o_ptr->weight > weight_limit()*3/2)) { /* Describe it */ object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); if (o_ptr->k_idx) msg_format("You cannot lift %s.", o_name); /* Abort */ return; } /* Check the slot */ slot = wield_slot(o_ptr); /* Ask for ring to replace */ if ((o_ptr->tval == TV_RING) && inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx) { /* Restrict the choices */ item_tester_tval = TV_RING; /* Choose a ring from the equipment only */ q = "Replace which ring? "; s = "Oops."; if (!get_item(&slot, q, s, USE_EQUIP)) return; } // Special cases for merging arrows if (object_similar(&inventory[INVEN_QUIVER1], o_ptr)) { slot = INVEN_QUIVER1; combine = TRUE; } else if (object_similar(&inventory[INVEN_QUIVER2], o_ptr)) { slot = INVEN_QUIVER2; combine = TRUE; } /* Ask for arrow set to replace */ else if ((o_ptr->tval == TV_ARROW) && inventory[INVEN_QUIVER1].k_idx && inventory[INVEN_QUIVER2].k_idx) { /* Restrict the choices */ item_tester_tval = TV_ARROW; /* Choose a set of arrows from the equipment only */ q = "Replace which set of arrows? "; s = "Oops."; if (!get_item(&slot, q, s, USE_EQUIP)) return; } // Ask about two weapon fighting if necessary for (i = 0; i < o_ptr->abilities; i++) { if ((o_ptr->skilltype[i] == S_MEL) && (o_ptr->abilitynum[i] == MEL_TWO_WEAPON) && object_known_p(o_ptr)) { grants_two_weapon = TRUE; } } if ((p_ptr->active_ability[S_MEL][MEL_TWO_WEAPON] || grants_two_weapon) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED) || (o_ptr->tval == TV_DIGGING))) { if (!(k_info[o_ptr->k_idx].flags3 & (TR3_TWO_HANDED))) { if (get_check("Do you wish to wield it in your off-hand? ")) { slot = INVEN_ARM; } } } /* Prevent wielding into a cursed slot */ if (cursed_p(&inventory[slot])) { /* Describe it */ object_desc(o_name, sizeof(o_name), &inventory[slot], FALSE, 0); /* Message */ msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); /* Cancel the command */ return; } /* Deal with wielding of two-handed weapons when already using a shield */ if ((k_info[o_ptr->k_idx].flags3 & (TR3_TWO_HANDED)) && (inventory[INVEN_ARM].k_idx)) { if (cursed_p(&inventory[INVEN_ARM])) { if (inventory[INVEN_ARM].tval == TV_SHIELD) { msg_print("You would need to remove your shield, but it appears to be cursed."); } else { msg_print("You would need to put down your off-hand weapon, but it appears to be cursed."); } /* Cancel the command */ return; } // warn about dropping item in left hand if ((item < 0) && (&inventory[INVEN_PACK-1])->tval) { /* Flush input */ flush(); if (inventory[INVEN_ARM].tval == TV_SHIELD) { if (!get_check("This would require removing (and dropping) your shield. Proceed? ")) { /* Cancel the command */ return; } } else { msg_print("This would require removing (and dropping) your off-hand weapon."); if (!get_check("Proceed? ")) { /* Cancel the command */ return; } } } } /* Deal with wielding of shield or second weapon when already wielding a two handed weapon */ if ((slot == INVEN_ARM) && (k_info[inventory[INVEN_WIELD].k_idx].flags3 & (TR3_TWO_HANDED))) { if (cursed_p(&inventory[INVEN_WIELD])) { msg_print("You would need to put down your weapon, but it appears to be cursed."); /* Cancel the command */ return; } // warn about dropping item in left hand if ((item < 0) && (&inventory[INVEN_PACK-1])->tval) { /* Flush input */ flush(); if (inventory[INVEN_ARM].tval == TV_SHIELD) { if (!get_check("This would require removing (and dropping) your weapon. Proceed? ")) { /* Cancel the command */ return; } } else { msg_print("This would require removing (and dropping) your weapon."); if (!get_check("Proceed? ")) { /* Cancel the command */ return; } } } } /* Deal with wielding of shield or second weapon when already wielding a hand and a half weapon */ if ((slot == INVEN_ARM) && (k_info[inventory[INVEN_WIELD].k_idx].flags3 & (TR3_HAND_AND_A_HALF)) && (!inventory[INVEN_ARM].k_idx)) { weapon_less_effective = TRUE; } /* Take a turn */ p_ptr->energy_use = 100; // store the action type p_ptr->previous_action[0] = ACTION_MISC; /* Get local object */ i_ptr = &object_type_body; /* Obtain local object */ object_copy(i_ptr, o_ptr); // Handle quantity differently for arrows if (i_ptr->tval == TV_ARROW) { if (combine) quantity = MIN(o_ptr->number, MAX_STACK_SIZE - 1 - (&inventory[slot])->number); else quantity = o_ptr->number; } else { quantity = 1; } /* Modify quantity */ i_ptr->number = quantity; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -quantity); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -quantity); floor_item_optimize(0 - item); } /* Get the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx && !combine) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Deal with wielding of two-handed weapons when already using a shield */ if ((k_info[i_ptr->k_idx].flags3 & (TR3_TWO_HANDED)) && (inventory[INVEN_ARM].k_idx)) { /* Take off shield */ check_pack_overflow(); (void)inven_takeoff(INVEN_ARM, 255); } /* Deal with wielding of shield or second weapon when already wielding a two handed weapon */ if ((slot == INVEN_ARM) && (k_info[inventory[INVEN_WIELD].k_idx].flags3 & (TR3_TWO_HANDED))) { /* Stop wielding two handed weapon */ (void)inven_takeoff(INVEN_WIELD, 255); } /* Combine the new stuff into the equipment */ if (combine) { msg_print("You combine them with some that are already in your quiver."); object_absorb(o_ptr, i_ptr); } /* Wear the new stuff */ else { object_copy(o_ptr, i_ptr); } /* Increment the equip counter by hand */ if (!combine) p_ptr->equip_cnt++; /* Where is the item now */ if ((slot == INVEN_WIELD) || ((slot == INVEN_ARM) && (o_ptr->tval != TV_SHIELD))) { act = "You are wielding"; } else if (slot == INVEN_BOW) { act = "You are shooting with"; } else if (slot == INVEN_LITE) { act = "Your light source is"; } else if ((slot == INVEN_QUIVER1) || (slot == INVEN_QUIVER2)) { act = "In your quiver you have"; } else { act = "You are wearing"; } /* Describe the result */ object_desc(o_name, sizeof(o_name), o_ptr, TRUE, 3); /* Message */ msg_format("%s %s (%c).", act, o_name, index_to_label(slot)); // Deal with wielding from the floor if (item < 0) { /* Forget monster */ o_ptr->held_m_idx = 0; /* Forget location */ o_ptr->iy = o_ptr->ix = 0; // Break the truce if picking up an item from the floor break_truce(FALSE); // Special effects when picking up all the items from the floor if (i_ptr->number == original_quantity) { /* No longer marked */ o_ptr->marked = FALSE; } } /* Cursed! */ if (cursed_p(o_ptr)) { /* Warn the player */ msg_print("You have a very bad feeling about this..."); /* Remove special inscription, if any */ if (o_ptr->discount >= INSCRIP_NULL) o_ptr->discount = 0; /* Sense the object if allowed */ if (o_ptr->discount == 0) o_ptr->discount = INSCRIP_CURSED; /* The object has been "sensed" */ o_ptr->ident |= (IDENT_SENSE); } if (weapon_less_effective) { /* Describe it */ object_desc(o_name, sizeof(o_name), &inventory[INVEN_WIELD], FALSE, 0); /* Message */ msg_format("You are no longer able to wield your %s as effectively.", o_name); } ident_on_wield(o_ptr); // activate all of its new abilities for (i = 0; i < o_ptr->abilities; i++) { if (!p_ptr->have_ability[o_ptr->skilltype[i]][o_ptr->abilitynum[i]]) { p_ptr->have_ability[o_ptr->skilltype[i]][o_ptr->abilitynum[i]] = TRUE; p_ptr->active_ability[o_ptr->skilltype[i]][o_ptr->abilitynum[i]] = TRUE; } } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate mana */ p_ptr->update |= (PU_MANA); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER_0); p_ptr->redraw |= (PR_EQUIPPY | PR_RESIST); }
/* * Wield or wear a single item from the pack or floor */ void do_cmd_wield(void) { int i, item, slot; object_type forge; object_type *q_ptr; object_type *o_ptr; cptr act; char o_name[MAX_NLEN]; cptr q, s; bool newrace = FALSE; /* Restrict the choices */ item_tester_hook = item_tester_hook_wear; /* Get an item */ #ifdef JP q = "どれを装備しますか? "; s = "装備可能なアイテムがない。"; #else q = "Wear/Wield which item? "; s = "You have nothing you can wear or wield."; #endif if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return; /* Get the item (in the pack) */ if (item >= 0) { o_ptr = &inventory[item]; } /* Get the item (on the floor) */ else { o_ptr = &o_list[0 - item]; } /* Check the slot */ slot = wield_slot(o_ptr); /* Where is the item now */ if (slot == INVEN_WIELD) { #ifdef JP act = "を打撃用に装備した"; #else act = "You are wielding"; #endif } else if (slot == INVEN_BOW) { #ifdef JP act = "を射撃用に装備した"; #else act = "You are shooting with"; #endif } else if (slot == INVEN_LITE) { #ifdef JP act = "を光源にした"; #else act = "Your light source is"; #endif } else { #ifdef JP act = "を装備した"; #else act = "You are wearing"; #endif } if ((o_ptr->tval == TV_RING) && inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx) { /* Restrict the choices */ item_tester_tval = TV_RING; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの指輪と取り替えますか?"; s = "おっと。"; #else q = "Replace which ring? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } if (slot == INVEN_WIELD) { if (is_two_handed()) { /* Restrict the choices */ item_tester_hook = item_tester_hook_melee_weapon; /* Choose a ring from the equipment only */ #ifdef JP q = "どちらの武器と取り替えますか?"; s = "おっと。"; #else q = "Replace which weapon? "; s = "Oops."; #endif if (!get_item(&slot, q, s, (USE_EQUIP))) return; } else if (inventory[slot].k_idx) { /* Confirm doing two handed combat */ #ifdef JP if (get_check("二刀流を行いますか?")) #else if (get_check("Do you want to do two handed combat?")) #endif { slot = INVEN_ARM; } } } /* Prevent wielding into a cursed slot */ if (cursed_p(&inventory[slot])) { /* Describe it */ object_desc(o_name, &inventory[slot], OD_OMIT_PREFIX | OD_NAME_ONLY); /* Message */ #ifdef JP msg_format("%s%sは呪われているようだ。", describe_use(slot) , o_name ); #else msg_format("The %s you are %s appears to be cursed.", o_name, describe_use(slot)); #endif /* Cancel the command */ return; } if (cursed_p(o_ptr) && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE))) { char dummy[512]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "本当に%s{呪われている}を使いますか?", o_name); #else sprintf(dummy, "Really use the %s {cursed}? ", o_name); #endif if (!get_check(dummy)) return; } #if 0 if ((o_ptr->name1 == ART_STONEMASK) && object_known_p(o_ptr) && (p_ptr->prace != RACE_VAMPIRE)) { char dummy[MAX_NLEN+80]; /* Describe it */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX | OD_NAME_ONLY); #ifdef JP sprintf(dummy, "%sを装備すると吸血鬼になります。よろしいですか?", o_name); #else msg_format("%s will transforms you into a vampire permanently when equiped.", o_name); sprintf(dummy, "Do you become a vampire?"); #endif if (!get_check(dummy)) return; } #endif /* Check if completed a quest */ for (i = 0; i < max_quests; i++) { if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) && (quest[i].status == QUEST_STATUS_TAKEN) && (quest[i].k_idx == o_ptr->name1)) { quest[i].status = QUEST_STATUS_COMPLETED; quest[i].complev = (byte)p_ptr->lev; #ifdef JP msg_print("クエストを達成した!"); #else msg_print("You completed your quest!"); #endif sound(SOUND_LEVEL); /* (Sound substitute) No quest sound */ msg_print(NULL); } } /* Take a turn */ energy_use = 100; /* Get local object */ q_ptr = &forge; /* Obtain local object */ object_copy(q_ptr, o_ptr); /* Modify quantity */ q_ptr->number = 1; /* Decrease the item (from the pack) */ if (item >= 0) { inven_item_increase(item, -1); inven_item_optimize(item); } /* Decrease the item (from the floor) */ else { floor_item_increase(0 - item, -1); floor_item_optimize(0 - item); } /* Access the wield slot */ o_ptr = &inventory[slot]; /* Take off existing item */ if (o_ptr->k_idx) { /* Take off existing item */ (void)inven_takeoff(slot, 255); } /* Wear the new stuff */ object_copy(o_ptr, q_ptr); /* Player touches it */ o_ptr->marked |= OM_TOUCHED; /* Forget stack */ o_ptr->next_o_idx = 0; /* Forget location */ o_ptr->iy = o_ptr->ix = 0; /* Increase the weight */ p_ptr->total_weight += q_ptr->weight; /* Increment the equip counter by hand */ equip_cnt++; /* Describe the result */ object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP msg_format("%s(%c)%s。", o_name, index_to_label(slot), act ); #else msg_format("%s %s (%c).", act, o_name, index_to_label(slot)); #endif sound(SOUND_WIELD); /* Cursed! */ if (cursed_p(o_ptr)) { /* Warn the player */ #ifdef JP msg_print("うわ! すさまじく冷たい!"); #else msg_print("Oops! It feels deathly cold!"); #endif sound(SOUND_CURSED); /* Note the curse */ o_ptr->ident |= (IDENT_SENSE); } #if 0 /* if you weild stonemask, you morph into vampire */ if ((o_ptr->name1 == ART_STONEMASK) && (!is_undead())) { p_ptr->prace = RACE_VAMPIRE; newrace = TRUE; #ifdef JP msg_format("あなたは吸血鬼に変化した!"); #else msg_format("You polymorphed into a vampire!"); #endif } #endif if (newrace) { rp_ptr = &race_info[p_ptr->prace]; /* Experience factor */ calc_expfact(); /* Get new height and weight */ get_ahw(FALSE); check_experience(); /* Hitdice */ p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp; do_cmd_rerate(TRUE); p_ptr->redraw |= (PR_BASIC); p_ptr->update |= (PU_BONUS); handle_stuff(); /* Load an autopick preference file */ autopick_load_pref(FALSE); lite_spot(py, px); } /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate torch */ p_ptr->update |= (PU_TORCH); /* Recalculate mana */ p_ptr->update |= (PU_MANA); p_ptr->redraw |= (PR_EQUIPPY); /* Window stuff */ p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER | PW_STATS); }