X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fchest.c;h=b2cacbab27179f0bc3a74488198a7afa27e42619;hb=31bc4ee11d50f8e9c542d44fc7579b52cd1fd00d;hp=eb648203971137cef78804242511072a87700e0a;hpb=de13de0a0bb1871c82b224d9817c2aadab81d4b6;p=hengband%2Fhengband.git diff --git a/src/chest.c b/src/chest.c index eb6482039..b2cacbab2 100644 --- a/src/chest.c +++ b/src/chest.c @@ -1,344 +1,331 @@ - -#include "angband.h" - -/*! -* @brief ©çACeðø«o· / -* Allocates objects upon opening a chest -BEN- -* @param scatter TRUEÈçÎgbvÉæéACeÌgU -* @param y ̶ݷé}XÌYÀW -* @param x ̶ݷé}XÌXÀW -* @param o_idx ÌIuWFNgID -* @return ȵ -* @details -*
-* Disperse treasures from the given chest, centered at (x,y). -* -* Small chests often contain "gold", while Large chests always contain -* items. Wooden chests contain 2 items, Iron chests contain 4 items, -* and Steel chests contain 6 items. The "value" of the items in a -* chest is based on the "power" of the chest, which is in turn based -* on the level on which the chest is generated. -*-*/ -void chest_death(bool scatter, int y, int x, s16b o_idx) -{ - int number; - - bool small; - BIT_FLAGS mode = AM_GOOD; - - object_type forge; - object_type *q_ptr; - - object_type *o_ptr = &o_list[o_idx]; - - - /* Small chests often hold "gold" */ - small = (o_ptr->sval < SV_CHEST_MIN_LARGE); - - /* Determine how much to drop (see above) */ - number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2; - - if (o_ptr->sval == SV_CHEST_KANDUME) - { - number = 5; - small = FALSE; - mode |= AM_GREAT; - object_level = o_ptr->xtra3; - } - else - { - /* Determine the "value" of the items */ - object_level = ABS(o_ptr->pval) + 10; - } - - /* Zero pval means empty chest */ - if (!o_ptr->pval) number = 0; - - /* Opening a chest */ - opening_chest = TRUE; - - /* Drop some objects (non-chests) */ - for (; number > 0; --number) - { - /* Get local object */ - q_ptr = &forge; - - /* Wipe the object */ - object_wipe(q_ptr); - - /* Small chests often drop gold */ - if (small && (randint0(100) < 25)) - { - /* Make some gold */ - if (!make_gold(q_ptr)) continue; - } - - /* Otherwise drop an item */ - else - { - /* Make a good object */ - if (!make_object(q_ptr, mode)) continue; - } - - /* If chest scatters its contents, pick any floor square. */ - if (scatter) - { - int i; - for (i = 0; i < 200; i++) - { - /* Pick a totally random spot. */ - y = randint0(MAX_HGT); - x = randint0(MAX_WID); - - /* Must be an empty floor. */ - if (!cave_empty_bold(y, x)) continue; - - /* Place the object there. */ - drop_near(q_ptr, -1, y, x); - - /* Done. */ - break; - } - } - /* Normally, drop object near the chest. */ - else drop_near(q_ptr, -1, y, x); - } - - /* Reset the object level */ - object_level = base_level; - - /* No longer opening a chest */ - opening_chest = FALSE; - - /* Empty */ - o_ptr->pval = 0; - - /* Known */ - object_known(o_ptr); -} - - -/*! -* @brief Ìgbv / -* Chests have traps too. -* @param y ̶ݷé}XÌYÀW -* @param x ̶ݷé}XÌXÀW -* @param o_idx ÌIuWFNgID -* @return ȵ -* @details -*
-* Exploding chest destroys contents (and traps). -* Note that the chest itself is never destroyed. -*-*/ -void chest_trap(POSITION y, POSITION x, KIND_OBJECT_IDX o_idx) -{ - int i, trap; - - object_type *o_ptr = &o_list[o_idx]; - - int mon_level = o_ptr->xtra3; - - /* Ignore disarmed chests */ - if (o_ptr->pval <= 0) return; - - /* Obtain the traps */ - trap = chest_traps[o_ptr->pval]; - - /* Lose strength */ - if (trap & (CHEST_LOSE_STR)) - { -#ifdef JP - msg_print("d|¯çêÄ¢½¬³ÈjÉh³êĵÜÁ½I"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "Åj", -1); -#else - msg_print("A small needle has pricked you!"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1); -#endif - - (void)do_dec_stat(A_STR); - } - - /* Lose constitution */ - if (trap & (CHEST_LOSE_CON)) - { -#ifdef JP - msg_print("d|¯çêÄ¢½¬³ÈjÉh³êĵÜÁ½I"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "Åj", -1); -#else - msg_print("A small needle has pricked you!"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "a poison needle", -1); -#endif - - (void)do_dec_stat(A_CON); - } - - /* Poison */ - if (trap & (CHEST_POISON)) - { - msg_print(_("Ë@«oµ½ÎFÌKXÉïÝÜê½I", "A puff of green gas surrounds you!")); - if (!(p_ptr->resist_pois || IS_OPPOSE_POIS())) - { - (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20)); - } - } - - /* Paralyze */ - if (trap & (CHEST_PARALYZE)) - { - msg_print(_("Ë@«oµ½©F¢KXÉïÝÜê½I", "A puff of yellow gas surrounds you!")); - if (!p_ptr->free_act) - { - (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20)); - } - } - - /* Summon monsters */ - if (trap & (CHEST_SUMMON)) - { - int num = 2 + randint1(3); - msg_print(_("Ë@«oµ½ÉïÝÜê½I", "You are enveloped in a cloud of smoke!")); - for (i = 0; i < num; i++) - { - if (randint1(100)
+* Disperse treasures from the given chest, centered at (x,y). +* +* Small chests often contain "gold", while Large chests always contain +* items. Wooden chests contain 2 items, Iron chests contain 4 items, +* and Steel chests contain 6 items. The "value" of the items in a +* chest is based on the "power" of the chest, which is in current_world_ptr->game_turn based +* on the level on which the chest is generated. +*+*/ +void chest_death(bool scatter, POSITION y, POSITION x, OBJECT_IDX o_idx) +{ + int number; + + bool small; + BIT_FLAGS mode = AM_GOOD; + + object_type forge; + object_type *q_ptr; + + object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx]; + + + /* Small chests often hold "gold" */ + small = (o_ptr->sval < SV_CHEST_MIN_LARGE); + + /* Determine how much to drop (see above) */ + number = (o_ptr->sval % SV_CHEST_MIN_LARGE) * 2; + + if (o_ptr->sval == SV_CHEST_KANDUME) + { + number = 5; + small = FALSE; + mode |= AM_GREAT; + current_floor_ptr->object_level = o_ptr->xtra3; + } + else + { + /* Determine the "value" of the items */ + current_floor_ptr->object_level = ABS(o_ptr->pval) + 10; + } + + /* Zero pval means empty chest */ + if (!o_ptr->pval) number = 0; + + /* Opening a chest */ + opening_chest = TRUE; + + /* Drop some objects (non-chests) */ + for (; number > 0; --number) + { + q_ptr = &forge; + object_wipe(q_ptr); + + /* Small chests often drop gold */ + if (small && (randint0(100) < 25)) + { + /* Make some gold */ + if (!make_gold(q_ptr)) continue; + } + + /* Otherwise drop an item */ + else + { + /* Make a good object */ + if (!make_object(q_ptr, mode)) continue; + } + + /* If chest scatters its contents, pick any floor square. */ + if (scatter) + { + int i; + for (i = 0; i < 200; i++) + { + /* Pick a totally random spot. */ + y = randint0(MAX_HGT); + x = randint0(MAX_WID); + + /* Must be an empty floor. */ + if (!cave_empty_bold(y, x)) continue; + + /* Place the object there. */ + (void)drop_near(q_ptr, -1, y, x); + + /* Done. */ + break; + } + } + /* Normally, drop object near the chest. */ + else (void)drop_near(q_ptr, -1, y, x); + } + + /* Reset the object level */ + current_floor_ptr->object_level = current_floor_ptr->base_level; + + /* No longer opening a chest */ + opening_chest = FALSE; + + /* Empty */ + o_ptr->pval = 0; + + /* Known */ + object_known(o_ptr); +} + + +/*! +* @brief ç®±ã®ãã©ããå¦ç / +* Chests have traps too. +* @param y ç®±ã®åå¨ãããã¹ã®Yåº§æ¨ +* @param x ç®±ã®åå¨ãããã¹ã®Xåº§æ¨ +* @param o_idx ç®±ã®ãªãã¸ã§ã¯ãID +* @return ãªã +* @details +*
+* Exploding chest destroys contents (and traps). +* Note that the chest itself is never destroyed. +*+*/ +void chest_trap(POSITION y, POSITION x, OBJECT_IDX o_idx) +{ + int i, trap; + + object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx]; + + int mon_level = o_ptr->xtra3; + + /* Ignore disarmed chests */ + if (o_ptr->pval <= 0) return; + + /* Obtain the traps */ + trap = chest_traps[o_ptr->pval]; + + /* Lose strength */ + if (trap & (CHEST_LOSE_STR)) + { + msg_print(_("ä»æãããã¦ããå°ããªéã«åºããã¦ãã¾ã£ãï¼", "A small needle has pricked you!")); + take_hit(DAMAGE_NOESCAPE, damroll(1, 4), _("æ¯é", "a poison needle"), -1); + (void)do_dec_stat(A_STR); + } + + /* Lose constitution */ + if (trap & (CHEST_LOSE_CON)) + { + msg_print(_("ä»æãããã¦ããå°ããªéã«åºããã¦ãã¾ã£ãï¼", "A small needle has pricked you!")); + take_hit(DAMAGE_NOESCAPE, damroll(1, 4), _("æ¯é", "a poison needle"), -1); + (void)do_dec_stat(A_CON); + } + + /* Poison */ + if (trap & (CHEST_POISON)) + { + msg_print(_("çªå¦å¹ãåºããç·è²ã®ã¬ã¹ã«å ã¿è¾¼ã¾ããï¼", "A puff of green gas surrounds you!")); + if (!(p_ptr->resist_pois || IS_OPPOSE_POIS())) + { + (void)set_poisoned(p_ptr->poisoned + 10 + randint1(20)); + } + } + + /* Paralyze */ + if (trap & (CHEST_PARALYZE)) + { + msg_print(_("çªå¦å¹ãåºããé»è²ãã¬ã¹ã«å ã¿è¾¼ã¾ããï¼", "A puff of yellow gas surrounds you!")); + if (!p_ptr->free_act) + { + (void)set_paralyzed(p_ptr->paralyzed + 10 + randint1(20)); + } + } + + /* Summon monsters */ + if (trap & (CHEST_SUMMON)) + { + int num = 2 + randint1(3); + msg_print(_("çªå¦å¹ãåºããç ã«å ã¿è¾¼ã¾ããï¼", "You are enveloped in a cloud of smoke!")); + for (i = 0; i < num; i++) + { + if (randint1(100)