5 * @brief
\94 \82©
\82ç
\83A
\83C
\83e
\83\80\82ð
\88ø
\82«
\8fo
\82· /
\r
6 * Allocates objects upon opening a chest -BEN-
\r
7 * @param scatter TRUE
\82È
\82ç
\82Î
\83g
\83\89\83b
\83v
\82É
\82æ
\82é
\83A
\83C
\83e
\83\80\82Ì
\8ag
\8eU
\8f\88\97\9d\r
8 * @param y
\94 \82Ì
\91¶
\8dÝ
\82·
\82é
\83}
\83X
\82ÌY
\8dÀ
\95W
\r
9 * @param x
\94 \82Ì
\91¶
\8dÝ
\82·
\82é
\83}
\83X
\82ÌX
\8dÀ
\95W
\r
10 * @param o_idx
\94 \82Ì
\83I
\83u
\83W
\83F
\83N
\83gID
\r
14 * Disperse treasures from the given chest, centered at (x,y).
\r
16 * Small chests often contain "gold", while Large chests always contain
\r
17 * items. Wooden chests contain 2 items, Iron chests contain 4 items,
\r
18 * and Steel chests contain 6 items. The "value" of the items in a
\r
19 * chest is based on the "power" of the chest, which is in turn based
\r
20 * on the level on which the chest is generated.
\r
23 void chest_death(bool scatter, int y, int x, s16b o_idx)
\r
28 BIT_FLAGS mode = AM_GOOD;
\r
33 object_type *o_ptr = &o_list[o_idx];
\r
36 /* Small chests often hold "gold" */
\r
37 small = (o_ptr->sval < SV_CHEST_MIN_LARGE);
\r
39 /* Determine how much to drop (see above) */
\r
40 number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2;
\r
42 if (o_ptr->sval == SV_CHEST_KANDUME)
\r
47 object_level = o_ptr->xtra3;
\r
51 /* Determine the "value" of the items */
\r
52 object_level = ABS(o_ptr->pval) + 10;
\r
55 /* Zero pval means empty chest */
\r
56 if (!o_ptr->pval) number = 0;
\r
58 /* Opening a chest */
\r
59 opening_chest = TRUE;
\r
61 /* Drop some objects (non-chests) */
\r
62 for (; number > 0; --number)
\r
64 /* Get local object */
\r
67 /* Wipe the object */
\r
70 /* Small chests often drop gold */
\r
71 if (small && (randint0(100) < 25))
\r
73 /* Make some gold */
\r
74 if (!make_gold(q_ptr)) continue;
\r
77 /* Otherwise drop an item */
\r
80 /* Make a good object */
\r
81 if (!make_object(q_ptr, mode)) continue;
\r
84 /* If chest scatters its contents, pick any floor square. */
\r
88 for (i = 0; i < 200; i++)
\r
90 /* Pick a totally random spot. */
\r
91 y = randint0(MAX_HGT);
\r
92 x = randint0(MAX_WID);
\r
94 /* Must be an empty floor. */
\r
95 if (!cave_empty_bold(y, x)) continue;
\r
97 /* Place the object there. */
\r
98 drop_near(q_ptr, -1, y, x);
\r
104 /* Normally, drop object near the chest. */
\r
105 else drop_near(q_ptr, -1, y, x);
\r
108 /* Reset the object level */
\r
109 object_level = base_level;
\r
111 /* No longer opening a chest */
\r
112 opening_chest = FALSE;
\r
118 object_known(o_ptr);
\r
123 * @brief
\94 \82Ì
\83g
\83\89\83b
\83v
\8f\88\97\9d /
\r
124 * Chests have traps too.
\r
125 * @param y
\94 \82Ì
\91¶
\8dÝ
\82·
\82é
\83}
\83X
\82ÌY
\8dÀ
\95W
\r
126 * @param x
\94 \82Ì
\91¶
\8dÝ
\82·
\82é
\83}
\83X
\82ÌX
\8dÀ
\95W
\r
127 * @param o_idx
\94 \82Ì
\83I
\83u
\83W
\83F
\83N
\83gID
\r
131 * Exploding chest destroys contents (and traps).
\r
132 * Note that the chest itself is never destroyed.
\r
135 void chest_trap(POSITION y, POSITION x, KIND_OBJECT_IDX o_idx)
\r
139 object_type *o_ptr = &o_list[o_idx];
\r
141 int mon_level = o_ptr->xtra3;
\r
143 /* Ignore disarmed chests */
\r
144 if (o_ptr->pval <= 0) return;
\r
146 /* Obtain the traps */
\r
147 trap = chest_traps[o_ptr->pval];
\r
149 /* Lose strength */
\r
150 if (trap & (CHEST_LOSE_STR))
\r
153 msg_print("
\8ed
\8a|
\82¯
\82ç
\82ê
\82Ä
\82¢
\82½
\8f¬
\82³
\82È
\90j
\82É
\8eh
\82³
\82ê
\82Ä
\82µ
\82Ü
\82Á
\82½
\81I");
\r
154 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "
\93Å
\90j", -1);
\r
156 msg_print("A small needle has pricked you!");
\r
157 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
\r
160 (void)do_dec_stat(A_STR);
\r
163 /* Lose constitution */
\r
164 if (trap & (CHEST_LOSE_CON))
\r
167 msg_print("
\8ed
\8a|
\82¯
\82ç
\82ê
\82Ä
\82¢
\82½
\8f¬
\82³
\82È
\90j
\82É
\8eh
\82³
\82ê
\82Ä
\82µ
\82Ü
\82Á
\82½
\81I");
\r
168 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "
\93Å
\90j", -1);
\r
170 msg_print("A small needle has pricked you!");
\r
171 take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1);
\r
174 (void)do_dec_stat(A_CON);
\r
178 if (trap & (CHEST_POISON))
\r
180 msg_print(_("
\93Ë
\94@
\90\81\82«
\8fo
\82µ
\82½
\97Î
\90F
\82Ì
\83K
\83X
\82É
\95ï
\82Ý
\8d\9e\82Ü
\82ê
\82½
\81I", "A puff of green gas surrounds you!"));
\r
181 if (!(p_ptr->resist_pois || IS_OPPOSE_POIS()))
\r
183 (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20));
\r
188 if (trap & (CHEST_PARALYZE))
\r
190 msg_print(_("
\93Ë
\94@
\90\81\82«
\8fo
\82µ
\82½
\89©
\90F
\82¢
\83K
\83X
\82É
\95ï
\82Ý
\8d\9e\82Ü
\82ê
\82½
\81I", "A puff of yellow gas surrounds you!"));
\r
191 if (!p_ptr->free_act)
\r
193 (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20));
\r
197 /* Summon monsters */
\r
198 if (trap & (CHEST_SUMMON))
\r
200 int num = 2 + randint1(3);
\r
201 msg_print(_("
\93Ë
\94@
\90\81\82«
\8fo
\82µ
\82½
\89\8c\82É
\95ï
\82Ý
\8d\9e\82Ü
\82ê
\82½
\81I", "You are enveloped in a cloud of smoke!"));
\r
202 for (i = 0; i < num; i++)
\r
204 if (randint1(100)<dun_level)
\r
205 activate_hi_summon(p_ptr->y, p_ptr->x, FALSE);
\r
207 (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
211 /* Elemental summon. */
\r
212 if (trap & (CHEST_E_SUMMON))
\r
214 msg_print(_("
\95ó
\82ð
\8eç
\82é
\82½
\82ß
\82É
\83G
\83\8c\83\81\83\93\83^
\83\8b\82ª
\8c»
\82ê
\82½
\81I", "Elemental beings appear to protect their treasures!"));
\r
215 for (i = 0; i < randint1(3) + 5; i++)
\r
217 (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
221 /* Force clouds, then summon birds. */
\r
222 if (trap & (CHEST_BIRD_STORM))
\r
224 msg_print(_("
\92¹
\82Ì
\8cQ
\82ê
\82ª
\82 \82È
\82½
\82ð
\8eæ
\82è
\8aª
\82¢
\82½
\81I", "A storm of birds swirls around you!"));
\r
226 for (i = 0; i < randint1(3) + 3; i++)
\r
227 (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7);
\r
229 for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++)
\r
231 (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
235 /* Various colorful summonings. */
\r
236 if (trap & (CHEST_H_SUMMON))
\r
238 /* Summon demons. */
\r
241 msg_print(_("
\89\8a\82Æ
\97°
\89©
\82Ì
\89_
\82Ì
\92\86\82É
\88«
\96\82\82ª
\8ep
\82ð
\8c»
\82µ
\82½
\81I", "Demons materialize in clouds of fire and brimstone!"));
\r
242 for (i = 0; i < randint1(3) + 2; i++)
\r
244 (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5);
\r
245 (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
249 /* Summon dragons. */
\r
250 else if (one_in_(3))
\r
252 msg_print(_("
\88Ã
\88Å
\82É
\83h
\83\89\83S
\83\93\82Ì
\89e
\82ª
\82Ú
\82ñ
\82â
\82è
\82Æ
\8c»
\82ê
\82½
\81I", "Draconic forms loom out of the darkness!"));
\r
253 for (i = 0; i < randint1(3) + 2; i++)
\r
255 (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
259 /* Summon hybrids. */
\r
260 else if (one_in_(2))
\r
262 msg_print(_("
\8aï
\96
\82È
\8ep
\82Ì
\89ö
\95¨
\82ª
\8fP
\82Á
\82Ä
\97\88\82½
\81I", "Creatures strange and twisted assault you!"));
\r
263 for (i = 0; i < randint1(5) + 3; i++)
\r
265 (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
269 /* Summon vortices (scattered) */
\r
272 msg_print(_("
\89Q
\8aª
\82ª
\8d\87\91Ì
\82µ
\81A
\94j
\97ô
\82µ
\82½
\81I", "Vortices coalesce and wreak destruction!"));
\r
273 for (i = 0; i < randint1(3) + 2; i++)
\r
275 (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET));
\r
280 /* Dispel player. */
\r
281 if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx)
\r
283 /* Determine how many nasty tricks can be played. */
\r
284 int nasty_tricks_count = 4 + randint0(3);
\r
287 msg_print(_("
\8b°
\82ë
\82µ
\82¢
\90º
\82ª
\8b¿
\82¢
\82½:
\81u
\88Ã
\88Å
\82ª
\93ð
\82ð
\82Â
\82Â
\82Ü
\82ñ
\81I
\81v", "Hideous voices bid: 'Let the darkness have thee!'"));
\r
288 /* This is gonna hurt... */
\r
289 for (; nasty_tricks_count > 0; nasty_tricks_count--)
\r
291 /* ...but a high saving throw does help a little. */
\r
292 if (randint1(100 + o_ptr->pval * 2) > p_ptr->skill_sav)
\r
294 if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), _("
\94j
\96Å
\82Ì
\83g
\83\89\83b
\83v
\82Ì
\95ó
\94 ", "a chest dispel-player trap"), -1);
\r
295 else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200);
\r
296 else if (one_in_(4))
\r
298 if (!p_ptr->free_act)
\r
299 (void)set_paralyzed(p_ptr->paralyzed + 2 +
\r
302 (void)set_stun(p_ptr->stun + 10 +
\r
305 else if (one_in_(3)) apply_disenchant(0);
\r
306 else if (one_in_(2))
\r
308 (void)do_dec_stat(A_STR);
\r
309 (void)do_dec_stat(A_DEX);
\r
310 (void)do_dec_stat(A_CON);
\r
311 (void)do_dec_stat(A_INT);
\r
312 (void)do_dec_stat(A_WIS);
\r
313 (void)do_dec_stat(A_CHR);
\r
315 else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1);
\r
320 /* Aggravate monsters. */
\r
321 if (trap & (CHEST_ALARM))
\r
323 msg_print(_("
\82¯
\82½
\82½
\82Ü
\82µ
\82¢
\89¹
\82ª
\96Â
\82è
\8b¿
\82¢
\82½
\81I", "An alarm sounds!"));
\r
324 aggravate_monsters(0);
\r
328 if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx)
\r
330 msg_print(_("
\93Ë
\91R
\81A
\94 \82ª
\94\9a\94
\82µ
\82½
\81I", "There is a sudden explosion!"));
\r
331 msg_print(_("
\94 \82Ì
\92\86\82Ì
\95¨
\82Í
\82·
\82×
\82Ä
\95²
\81X
\82É
\8dÓ
\82¯
\8eU
\82Á
\82½
\81I", "Everything inside the chest is destroyed!"));
\r
333 sound(SOUND_EXPLODE);
\r
334 take_hit(DAMAGE_ATTACK, damroll(5, 8), _("
\94\9a\94
\82·
\82é
\94 ", "an exploding chest"), -1);
\r
336 /* Scatter contents. */
\r
337 if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx)
\r
339 msg_print(_("
\95ó
\94 \82Ì
\92\86\90g
\82Í
\83_
\83\93\83W
\83\87\83\93\82¶
\82ã
\82¤
\82É
\8eU
\97\90\82µ
\82½
\81I", "The contents of the chest scatter all over the dungeon!"));
\r
340 chest_death(TRUE, y, x, o_idx);
\r