3 #include "spells-summon.h"
5 #include "player-status.h"
8 * @brief 箱からアイテムを引き出す /
9 * Allocates objects upon opening a chest -BEN-
10 * @param scatter TRUEならばトラップによるアイテムの拡散処理
11 * @param y 箱の存在するマスのY座標
12 * @param x 箱の存在するマスのX座標
13 * @param o_idx 箱のオブジェクトID
17 * Disperse treasures from the given chest, centered at (x,y).
19 * Small chests often contain "gold", while Large chests always contain
20 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
21 * and Steel chests contain 6 items. The "value" of the items in a
22 * chest is based on the "power" of the chest, which is in turn based
23 * on the level on which the chest is generated.
26 void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx)
31 BIT_FLAGS mode = AM_GOOD;
36 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
39 /* Small chests often hold "gold" */
40 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
42 /* Determine how much to drop (see above) */
43 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
45 if (o_ptr->sval == SV_CHEST_KANDUME)
50 current_floor_ptr->object_level = o_ptr->xtra3;
54 /* Determine the "value" of the items */
55 current_floor_ptr->object_level = ABS(o_ptr->pval) + 10;
58 /* Zero pval means empty chest */
59 if (!o_ptr->pval) number = 0;
64 /* Drop some objects (non-chests) */
65 for (; number > 0; --number)
70 /* Small chests often drop gold */
71 if (small && (randint0(100) < 25))
74 if (!make_gold(q_ptr)) continue;
77 /* Otherwise drop an item */
80 /* Make a good object */
81 if (!make_object(q_ptr, mode)) continue;
84 /* If chest scatters its contents, pick any floor square. */
88 for (i = 0; i < 200; i++)
90 /* Pick a totally random spot. */
91 y = randint0(MAX_HGT);
92 x = randint0(MAX_WID);
94 /* Must be an empty floor. */
95 if (!cave_empty_bold(y, x)) continue;
97 /* Place the object there. */
98 (void)drop_near(q_ptr, -1, y, x);
104 /* Normally, drop object near the chest. */
105 else (void)drop_near(q_ptr, -1, y, x);
108 /* Reset the object level */
109 current_floor_ptr->object_level = current_floor_ptr->base_level;
111 /* No longer opening a chest */
112 opening_chest = FALSE;
124 * Chests have traps too.
125 * @param y 箱の存在するマスのY座標
126 * @param x 箱の存在するマスのX座標
127 * @param o_idx 箱のオブジェクトID
131 * Exploding chest destroys contents (and traps).
132 * Note that the chest itself is never destroyed.
135 void chest_trap(POSITION y, POSITION x, OBJECT_IDX o_idx)
139 object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx];
141 int mon_level = o_ptr->xtra3;
143 /* Ignore disarmed chests */
144 if (o_ptr->pval <= 0) return;
146 /* Obtain the traps */
147 trap = chest_traps[o_ptr->pval];
150 if (trap & (CHEST_LOSE_STR))
152 msg_print(_("仕掛けられていた小さな針に刺されてしまった!", "A small needle has pricked you!"));
153 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), _("毒針", "a poison needle"), -1);
154 (void)do_dec_stat(A_STR);
157 /* Lose constitution */
158 if (trap & (CHEST_LOSE_CON))
160 msg_print(_("仕掛けられていた小さな針に刺されてしまった!", "A small needle has pricked you!"));
161 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), _("毒針", "a poison needle"), -1);
162 (void)do_dec_stat(A_CON);
166 if (trap & (CHEST_POISON))
168 msg_print(_("突如吹き出した緑色のガスに包み込まれた!", "A puff of green gas surrounds you!"));
169 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
171 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
176 if (trap & (CHEST_PARALYZE))
178 msg_print(_("突如吹き出した黄色いガスに包み込まれた!", "A puff of yellow gas surrounds you!"));
179 if (!p_ptr->free_act)
181 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
185 /* Summon monsters */
186 if (trap & (CHEST_SUMMON))
188 int num = 2 + randint1(3);
189 msg_print(_("突如吹き出した煙に包み込まれた!", "You are enveloped in a cloud of smoke!"));
190 for (i = 0; i < num; i++)
192 if (randint1(100)<current_floor_ptr->dun_level)
193 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
195 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
199 /* Elemental summon. */
200 if (trap & (CHEST_E_SUMMON))
202 msg_print(_("宝を守るためにエレメンタルが現れた!", "Elemental beings appear to protect their treasures!"));
203 for (i = 0; i < randint1(3) + 5; i++)
205 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
209 /* Force clouds, then summon birds. */
210 if (trap & (CHEST_BIRD_STORM))
212 msg_print(_("鳥の群れがあなたを取り巻いた!", "A storm of birds swirls around you!"));
214 for (i = 0; i < randint1(3) + 3; i++)
215 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
217 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
219 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
223 /* Various colorful summonings. */
224 if (trap & (CHEST_H_SUMMON))
229 msg_print(_("炎と硫黄の雲の中に悪魔が姿を現した!", "Demons materialize in clouds of fire and brimstone!"));
230 for (i = 0; i < randint1(3) + 2; i++)
232 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
233 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
237 /* Summon dragons. */
240 msg_print(_("暗闇にドラゴンの影がぼんやりと現れた!", "Draconic forms loom out of the darkness!"));
241 for (i = 0; i < randint1(3) + 2; i++)
243 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
247 /* Summon hybrids. */
250 msg_print(_("奇妙な姿の怪物が襲って来た!", "Creatures strange and twisted assault you!"));
251 for (i = 0; i < randint1(5) + 3; i++)
253 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
257 /* Summon vortices (scattered) */
260 msg_print(_("渦巻が合体し、破裂した!", "Vortices coalesce and wreak destruction!"));
261 for (i = 0; i < randint1(3) + 2; i++)
263 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET), '\0');
269 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
271 /* Determine how many nasty tricks can be played. */
272 int nasty_tricks_count = 4 + randint0(3);
274 msg_print(_("恐ろしい声が響いた: 「暗闇が汝をつつまん!」", "Hideous voices bid: 'Let the darkness have thee!'"));
275 /* This is gonna hurt... */
276 for (; nasty_tricks_count > 0; nasty_tricks_count--)
278 /* ...but a high saving throw does help a little. */
279 if (randint1(100 + o_ptr->pval * 2) > p_ptr->skill_sav)
281 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), _("破滅のトラップの宝箱", "a chest dispel-player trap"), -1);
282 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
285 if (!p_ptr->free_act)
286 (void)set_paralyzed(p_ptr->paralyzed + 2 +
289 (void)set_stun(p_ptr->stun + 10 +
292 else if (one_in_(3)) apply_disenchant(0);
295 (void)do_dec_stat(A_STR);
296 (void)do_dec_stat(A_DEX);
297 (void)do_dec_stat(A_CON);
298 (void)do_dec_stat(A_INT);
299 (void)do_dec_stat(A_WIS);
300 (void)do_dec_stat(A_CHR);
302 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
307 /* Aggravate monsters. */
308 if (trap & (CHEST_ALARM))
310 msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!"));
311 aggravate_monsters(0);
315 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
317 msg_print(_("突然、箱が爆発した!", "There is a sudden explosion!"));
318 msg_print(_("箱の中の物はすべて粉々に砕け散った!", "Everything inside the chest is destroyed!"));
320 sound(SOUND_EXPLODE);
321 take_hit(DAMAGE_ATTACK, damroll(5, 8), _("爆発する箱", "an exploding chest"), -1);
323 /* Scatter contents. */
324 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
326 msg_print(_("宝箱の中身はダンジョンじゅうに散乱した!", "The contents of the chest scatter all over the dungeon!"));
327 chest_death(TRUE, y, x, o_idx);