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-expendable.h"
8 #include "object/object-broken.h"
9 #include "object/object-info.h"
10 #include "object/object-stack.h"
11 #include "player/player-status.h"
12 #include "system/floor-type-definition.h"
13 #include "system/object-type-definition.h"
14 #include "system/player-type-definition.h"
15 #include "view/display-messages.h"
18 * @brief 手持ちのアイテムを指定確率で破損させる /
19 * Destroys a type of item on a given percent chance
20 * @param player_ptr プレーヤーへの参照ポインタ
21 * @param typ 破損判定関数ポインタ
24 * Note that missiles are no longer necessarily all destroyed
25 * Destruction taken from "melee.c" code for "stealing".
26 * New-style wands and rods handled correctly. -LM-
28 void inventory_damage(player_type *player_ptr, const ObjectBreaker& breaker, int perc)
33 GAME_TEXT o_name[MAX_NLEN];
35 if (check_multishadow(player_ptr) || player_ptr->current_floor_ptr->inside_arena)
38 /* Scan through the slots backwards */
39 for (i = 0; i < INVEN_PACK; i++) {
40 o_ptr = &player_ptr->inventory_list[i];
44 /* Hack -- for now, skip artifacts */
45 if (o_ptr->is_artifact())
48 /* Give this item slot a shot at death */
49 if (!breaker.can_destroy(o_ptr))
52 /* Count the casualties */
53 for (amt = j = 0; j < o_ptr->number; ++j) {
54 if (randint0(100) < perc)
58 /* Some casualities */
62 describe_flavor(player_ptr, o_name, o_ptr, OD_OMIT_PREFIX);
64 msg_format(_("%s(%c)が%s壊れてしまった!", "%sour %s (%c) %s destroyed!"),
66 o_name, index_to_label(i), ((o_ptr->number > 1) ? ((amt == o_ptr->number) ? "全部" : (amt > 1 ? "何個か" : "一個")) : ""));
68 ((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),
69 ((amt > 1) ? "were" : "was"));
73 if (is_echizen(player_ptr))
74 msg_print("やりやがったな!");
75 else if (is_chargeman(player_ptr)) {
77 msg_print(_("ジュラル星人め!", ""));
79 msg_print(_("弱い者いじめは止めるんだ!", ""));
83 /* Potions smash open */
84 if (o_ptr->is_potion()) {
85 (void)potion_smash_effect(player_ptr, 0, player_ptr->y, player_ptr->x, o_ptr->k_idx);
88 /* Reduce the charges of rods/wands */
89 reduce_charges(o_ptr, amt);
91 /* Destroy "amt" items */
92 inven_item_increase(player_ptr, i, -amt);
93 inven_item_optimize(player_ptr, i);