1 #include "inventory/inventory-damage.h"
2 #include "flavor/flavor-describer.h"
3 #include "flavor/object-flavor-types.h"
4 #include "inventory/inventory-object.h"
5 #include "inventory/inventory-slot-types.h"
6 #include "mind/mind-mirror-master.h"
7 #include "object-hook/hook-enchant.h"
8 #include "object-hook/hook-expendable.h"
9 #include "object/object-broken.h"
10 #include "object/object-info.h"
11 #include "object/object-stack.h"
12 #include "player/player-status.h"
13 #include "system/floor-type-definition.h"
14 #include "system/object-type-definition.h"
15 #include "system/player-type-definition.h"
16 #include "view/display-messages.h"
19 * @brief アイテムを指定確率で破損させる /
20 * Destroys a type of item on a given percent chance
21 * @param player_ptr プレーヤーへの参照ポインタ
22 * @param typ 破損判定関数ポインタ
25 * Note that missiles are no longer necessarily all destroyed
26 * Destruction taken from "melee.c" code for "stealing".
27 * New-style wands and rods handled correctly. -LM-
29 void inventory_damage(player_type *player_ptr, inven_func typ, int perc)
34 GAME_TEXT o_name[MAX_NLEN];
36 if (check_multishadow(player_ptr) || player_ptr->current_floor_ptr->inside_arena)
39 /* Scan through the slots backwards */
40 for (i = 0; i < INVEN_PACK; i++) {
41 o_ptr = &player_ptr->inventory_list[i];
45 /* Hack -- for now, skip artifacts */
46 if (object_is_artifact(o_ptr))
49 /* Give this item slot a shot at death */
50 if (!(*typ)(player_ptr, o_ptr))
53 /* Count the casualties */
54 for (amt = j = 0; j < o_ptr->number; ++j) {
55 if (randint0(100) < perc)
59 /* Some casualities */
63 describe_flavor(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
65 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
67 o_name, index_to_label(i), ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "全部" : (amt > 1 ? "何個か" : "一個")) : ""));
69 ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "All of y" : (amt > 1 ? "Some of y" : "One of y")) : "Y"), o_name, index_to_label(i),
70 ((amt > 1) ? "were" : "was"));
74 if (is_echizen(player_ptr))
75 msg_print("やりやがったな!");
76 else if (player_ptr->pseikaku == PERSONALITY_CHARGEMAN) {
78 msg_print(_("ジュラル星人め!", ""));
80 msg_print(_("弱い者いじめは止めるんだ!", ""));
84 /* Potions smash open */
85 if (object_is_potion(o_ptr)) {
86 (void)potion_smash_effect(player_ptr, 0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
89 /* Reduce the charges of rods/wands */
90 reduce_charges(o_ptr, amt);
92 /* Destroy "amt" items */
93 inven_item_increase(player_ptr, i, -amt);
94 inven_item_optimize(player_ptr, i);