X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcmd2.c;h=17a260ba4976e88243fa01b0db474eed00b0f746;hb=849c2c2d6ea9aa00c785f5d33554b78b738315c4;hp=16bdb23bc35c0593059677ee9020c7808dfd91ee;hpb=47d74a92a2ddd225115d80bada589a295ca9811a;p=hengband%2Fhengband.git diff --git a/src/cmd2.c b/src/cmd2.c index 16bdb23bc..17a260ba4 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -11,7 +11,9 @@ */ #include "angband.h" - +#include "chest.h" +#include "melee.h" +#include "object-hook.h" /*! * @brief ããã¢è±åºæã«åºæ»ããä¸å¯è½ã ã£ãå ´åã«è¦åãå ããå¦ç @@ -31,13 +33,8 @@ bool confirm_leave_level(bool down_stair) ((q_ptr->status != QUEST_STATUS_STAGE_COMPLETED) || (down_stair && (quest[QUEST_TOWER1].status != QUEST_STATUS_COMPLETED)))))) { -#ifdef JP - msg_print("ãã®éãä¸åº¦å»ãã¨äºåº¦ã¨æ»ã£ã¦æ¥ããã¾ããã"); - if (get_check("æ¬å½ã«ãã®éãå»ãã¾ããï¼")) return TRUE; -#else - msg_print("You can't come back here once you leave this floor."); - if (get_check("Really leave this floor? ")) return TRUE; -#endif + msg_print(_("ãã®éãä¸åº¦å»ãã¨äºåº¦ã¨æ»ã£ã¦æ¥ããã¾ããã", "You can't come back here once you leave this floor.")); + if (get_check(_("æ¬å½ã«ãã®éãå»ãã¾ããï¼", "Really leave this floor? "))) return TRUE; } else { @@ -80,14 +77,10 @@ void do_cmd_go_up(void) /* Success */ -#ifdef JP if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)) - msg_print("ãªãã ãã®é段ã¯ï¼"); + msg_print(_("ãªãã ãã®é段ã¯ï¼", "What's this STAIRWAY!")); else - msg_print("ä¸ã®éã«ç»ã£ãã"); -#else - msg_print("You enter the up staircase."); -#endif + msg_print(_("ä¸ã®éã«ç»ã£ãã", "You enter the up staircase.")); leave_quest_check(); @@ -187,7 +180,7 @@ void do_cmd_go_up(void) /* Success */ if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)) - msg_print(_("ãªãã ãã®é段ã¯ï¼", "")); + msg_print(_("ãªãã ãã®é段ã¯ï¼", "What's this STAIRWAY!")); else if (up_num == dun_level) msg_print(_("å°ä¸ã«æ»ã£ãã", "You go back to the surface.")); else @@ -237,14 +230,10 @@ void do_cmd_go_down(void) /* Confirm Leaving */ if(!confirm_leave_level(TRUE)) return; -#ifdef JP if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)) - msg_print("ãªãã ãã®é段ã¯ï¼"); + msg_print(_("ãªãã ãã®é段ã¯ï¼", "What's this STAIRWAY!")); else - msg_print("ä¸ã®éã«éããã"); -#else - msg_print("You enter the down staircase."); -#endif + msg_print(_("ä¸ã®éã«éããã", "You enter the down staircase.")); leave_quest_check(); leave_tower_check(); @@ -347,7 +336,7 @@ void do_cmd_go_down(void) else { if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)) - msg_print(_("ãªãã ãã®é段ã¯ï¼", "")); + msg_print(_("ãªãã ãã®é段ã¯ï¼", "What's this STAIRWAY!")); else msg_print(_("é段ãä¸ãã¦æ°ããªãè¿·å®®ã¸ã¨è¶³ãè¸ã¿å ¥ããã", "You enter a maze of down staircases.")); } @@ -396,8 +385,6 @@ void do_cmd_search(void) /* Cancel the arg */ command_arg = 0; } - - /* Take a turn */ p_ptr->energy_use = 100; /* Search */ @@ -412,22 +399,17 @@ void do_cmd_search(void) * @param trapped TRUEãªãã°ãã©ãããåå¨ããç®±ã®ã¿ãFALSEãªãã°ç©ºã§ãªãç®±å ¨ã¦ã対象ã«ãã * @return ç®±ãåå¨ããå ´åãã®ãªãã¸ã§ã¯ãIDãåå¨ããªãå ´å0ãè¿ãã */ -static s16b chest_check(int y, int x, bool trapped) +static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped) { cave_type *c_ptr = &cave[y][x]; - - s16b this_o_idx, next_o_idx = 0; - + OBJECT_IDX this_o_idx, next_o_idx = 0; /* Scan all objects in the grid */ for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) { object_type *o_ptr; - /* Acquire object */ o_ptr = &o_list[this_o_idx]; - - /* Acquire next object */ next_o_idx = o_ptr->next_o_idx; /* Skip unknown chests XXX XXX */ @@ -441,354 +423,9 @@ static s16b chest_check(int y, int x, bool trapped) return (this_o_idx); } } - - /* No chest */ return (0); } - -/*! - * @brief ç®±ããã¢ã¤ãã ãå¼ãåºã / - * Allocates objects upon opening a chest -BEN- - * @param scatter TRUEãªãã°ãã©ããã«ããã¢ã¤ãã ã®æ¡æ£å¦ç - * @param y ç®±ã®åå¨ãããã¹ã®Yåº§æ¨ - * @param x ç®±ã®åå¨ãããã¹ã®Xåº§æ¨ - * @param o_idx ç®±ã®ãªãã¸ã§ã¯ãID - * @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. - *- */ -static 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 ç®±ã®ãã©ããå¦ç / - * 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. - *- */ -static 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("ä»æãããã¦ããå°ããªéã«åºããã¦ãã¾ã£ãï¼"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "æ¯é", -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("ä»æãããã¦ããå°ããªéã«åºããã¦ãã¾ã£ãï¼"); - take_hit(DAMAGE_NOESCAPE, damroll(1, 4), "æ¯é", -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(_("çªå¦å¹ãåºããç·è²ã®ã¬ã¹ã«å ã¿è¾¼ã¾ããï¼", "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)
- * XXX XXX XXX Let user choose a pile of spikes, perhaps? + * Let user choose a pile of spikes, perhaps? **/ -static bool get_spike(int *ip) +static bool get_spike(INVENTORY_IDX *ip) { - int i; + INVENTORY_IDX i; /* Check every item in the pack */ for (i = 0; i < INVEN_PACK; i++) @@ -2398,7 +1891,6 @@ static bool get_spike(int *ip) } } - /* Oops */ return (FALSE); } @@ -2414,7 +1906,7 @@ static bool get_spike(int *ip) */ void do_cmd_spike(void) { - int dir; + DIRECTION dir; if (p_ptr->special_defense & KATA_MUSOU) { @@ -2424,15 +1916,13 @@ void do_cmd_spike(void) /* Get a "repeated" direction */ if (get_rep_dir(&dir,FALSE)) { - int y, x, item; + POSITION y, x; + INVENTORY_IDX item; cave_type *c_ptr; - s16b feat; + FEAT_IDX feat; - /* Get location */ y = p_ptr->y + ddy[dir]; x = p_ptr->x + ddx[dir]; - - /* Get grid and contents */ c_ptr = &cave[y][x]; /* Feature code (applying "mimic" field) */ @@ -2441,24 +1931,20 @@ void do_cmd_spike(void) /* Require closed door */ if (!have_flag(f_info[feat].flags, FF_SPIKE)) { - /* Message */ msg_print(_("ããã«ã¯ããã³ãæã¦ããã®ãè¦å½ãããªãã", "You see nothing there to spike.")); } /* Get a spike */ else if (!get_spike(&item)) { - /* Message */ msg_print(_("ããã³ãæã£ã¦ããªãï¼", "You have no spikes!")); } /* Is a monster in the way? */ else if (c_ptr->m_idx) { - /* Take a turn */ p_ptr->energy_use = 100; - /* Message */ msg_print(_("ã¢ã³ã¹ã¿ã¼ãç«ã¡ãµããã£ã¦ããï¼", "There is a monster in the way!")); /* Attack */ @@ -2468,7 +1954,6 @@ void do_cmd_spike(void) /* Go for it */ else { - /* Take a turn */ p_ptr->energy_use = 100; /* Successful jamming */ @@ -2493,7 +1978,7 @@ void do_cmd_spike(void) */ void do_cmd_walk(bool pickup) { - int dir; + DIRECTION dir; bool more = FALSE; @@ -2514,7 +1999,6 @@ void do_cmd_walk(bool pickup) /* Get a "repeated" direction */ if (get_rep_dir(&dir, FALSE)) { - /* Take a turn */ p_ptr->energy_use = 100; if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU)) @@ -2558,7 +2042,7 @@ void do_cmd_walk(bool pickup) } /* Cancel repeat unless we may continue */ - if (!more) disturb(0, 0); + if (!more) disturb(FALSE, FALSE); } @@ -2569,7 +2053,7 @@ void do_cmd_walk(bool pickup) */ void do_cmd_run(void) { - int dir; + DIRECTION dir; /* Hack -- no running when confused */ if (p_ptr->confused) @@ -2619,7 +2103,6 @@ void do_cmd_stay(bool pickup) command_arg = 0; } - /* Take a turn */ p_ptr->energy_use = 100; if (pickup) mpe_mode |= MPE_DO_PICKUP; @@ -2637,7 +2120,7 @@ void do_cmd_rest(void) set_action(ACTION_NONE); - if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_ID(p_ptr) || p_ptr->magic_num1[1])) + if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr))) { stop_singing(); } @@ -2686,12 +2169,11 @@ void do_cmd_rest(void) if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE); - /* Take a turn XXX XXX XXX (?) */ + /* Take a turn (?) */ p_ptr->energy_use = 100; /* The sin of sloth */ - if (command_arg > 100) - chg_virtue(V_DILIGENCE, -1); + if (command_arg > 100) chg_virtue(V_DILIGENCE, -1); /* Why are you sleeping when there's no need? WAKE UP!*/ if ((p_ptr->chp == p_ptr->mhp) && @@ -2713,11 +2195,8 @@ void do_cmd_rest(void) /* Redraw the state */ p_ptr->redraw |= (PR_STATE); - - /* Handle stuff */ handle_stuff(); - /* Refresh */ Term_fresh(); } @@ -2730,9 +2209,9 @@ void do_cmd_rest(void) * @details * Note that artifacts never break, see the "drop_near()" function. */ -static int breakage_chance(object_type *o_ptr) +static PERCENTAGE breakage_chance(object_type *o_ptr) { - int archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (p_ptr->lev-1)/7 + 4: 0); + PERCENTAGE archer_bonus = (p_ptr->pclass == CLASS_ARCHER ? (PERCENTAGE)(p_ptr->lev-1)/7 + 4: 0); /* Examine the snipe type */ if (snipe_type) @@ -2794,7 +2273,7 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) monster_race *r_ptr = &r_info[m_ptr->r_idx]; - u32b flgs[TR_FLAG_SIZE]; + BIT_FLAGS flgs[TR_FLAG_SIZE]; /* Extract the flags */ object_flags(o_ptr, flgs); @@ -2806,153 +2285,115 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) case TV_ARROW: case TV_BOLT: { - /* Slay Animal */ - if ((have_flag(flgs, TR_SLAY_ANIMAL)) && - (r_ptr->flags3 & RF3_ANIMAL)) + if ((have_flag(flgs, TR_SLAY_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_ANIMAL; } - if (mult < 17) mult = 17; } - /* Kill Animal */ - if ((have_flag(flgs, TR_KILL_ANIMAL)) && - (r_ptr->flags3 & RF3_ANIMAL)) + if ((have_flag(flgs, TR_KILL_ANIMAL)) && (r_ptr->flags3 & RF3_ANIMAL)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_ANIMAL; } - if (mult < 27) mult = 27; } - /* Slay Evil */ - if ((have_flag(flgs, TR_SLAY_EVIL)) && - (r_ptr->flags3 & RF3_EVIL)) + if ((have_flag(flgs, TR_SLAY_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_EVIL; } - if (mult < 15) mult = 15; } - /* Kill Evil */ - if ((have_flag(flgs, TR_KILL_EVIL)) && - (r_ptr->flags3 & RF3_EVIL)) + if ((have_flag(flgs, TR_KILL_EVIL)) && (r_ptr->flags3 & RF3_EVIL)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_EVIL; } - if (mult < 25) mult = 25; } - /* Slay Human */ - if ((have_flag(flgs, TR_SLAY_HUMAN)) && - (r_ptr->flags2 & RF2_HUMAN)) + if ((have_flag(flgs, TR_SLAY_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags2 |= RF2_HUMAN; } - if (mult < 17) mult = 17; } - /* Kill Human */ - if ((have_flag(flgs, TR_KILL_HUMAN)) && - (r_ptr->flags2 & RF2_HUMAN)) + if ((have_flag(flgs, TR_KILL_HUMAN)) && (r_ptr->flags2 & RF2_HUMAN)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags2 |= RF2_HUMAN; } - if (mult < 27) mult = 27; } - /* Slay Undead */ - if ((have_flag(flgs, TR_SLAY_UNDEAD)) && - (r_ptr->flags3 & RF3_UNDEAD)) + if ((have_flag(flgs, TR_SLAY_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_UNDEAD; } - if (mult < 20) mult = 20; } - /* Kill Undead */ - if ((have_flag(flgs, TR_KILL_UNDEAD)) && - (r_ptr->flags3 & RF3_UNDEAD)) + if ((have_flag(flgs, TR_KILL_UNDEAD)) && (r_ptr->flags3 & RF3_UNDEAD)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_UNDEAD; } - if (mult < 30) mult = 30; } - /* Slay Demon */ - if ((have_flag(flgs, TR_SLAY_DEMON)) && - (r_ptr->flags3 & RF3_DEMON)) + if ((have_flag(flgs, TR_SLAY_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_DEMON; } - if (mult < 20) mult = 20; } - /* Kill Demon */ - if ((have_flag(flgs, TR_KILL_DEMON)) && - (r_ptr->flags3 & RF3_DEMON)) + if ((have_flag(flgs, TR_KILL_DEMON)) && (r_ptr->flags3 & RF3_DEMON)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_DEMON; } - if (mult < 30) mult = 30; } - /* Slay Orc */ - if ((have_flag(flgs, TR_SLAY_ORC)) && - (r_ptr->flags3 & RF3_ORC)) + if ((have_flag(flgs, TR_SLAY_ORC)) && (r_ptr->flags3 & RF3_ORC)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_ORC; } - if (mult < 20) mult = 20; } - /* Kill Orc */ - if ((have_flag(flgs, TR_KILL_ORC)) && - (r_ptr->flags3 & RF3_ORC)) + if ((have_flag(flgs, TR_KILL_ORC)) && (r_ptr->flags3 & RF3_ORC)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_ORC; } - if (mult < 30) mult = 30; } - /* Slay Troll */ - if ((have_flag(flgs, TR_SLAY_TROLL)) && - (r_ptr->flags3 & RF3_TROLL)) + if ((have_flag(flgs, TR_SLAY_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) { if (is_original_ap_and_seen(m_ptr)) { @@ -2962,72 +2403,54 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) if (mult < 20) mult = 20; } - /* Kill Troll */ - if ((have_flag(flgs, TR_KILL_TROLL)) && - (r_ptr->flags3 & RF3_TROLL)) + if ((have_flag(flgs, TR_KILL_TROLL)) && (r_ptr->flags3 & RF3_TROLL)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_TROLL; } - if (mult < 30) mult = 30; } - /* Slay Giant */ - if ((have_flag(flgs, TR_SLAY_GIANT)) && - (r_ptr->flags3 & RF3_GIANT)) + if ((have_flag(flgs, TR_SLAY_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_GIANT; } - if (mult < 20) mult = 20; } - /* Kill Giant */ - if ((have_flag(flgs, TR_KILL_GIANT)) && - (r_ptr->flags3 & RF3_GIANT)) + if ((have_flag(flgs, TR_KILL_GIANT)) && (r_ptr->flags3 & RF3_GIANT)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_GIANT; } - if (mult < 30) mult = 30; } - /* Slay Dragon */ - if ((have_flag(flgs, TR_SLAY_DRAGON)) && - (r_ptr->flags3 & RF3_DRAGON)) + if ((have_flag(flgs, TR_SLAY_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_DRAGON; } - if (mult < 20) mult = 20; } - /* Execute Dragon */ - if ((have_flag(flgs, TR_KILL_DRAGON)) && - (r_ptr->flags3 & RF3_DRAGON)) + if ((have_flag(flgs, TR_KILL_DRAGON)) && (r_ptr->flags3 & RF3_DRAGON)) { if (is_original_ap_and_seen(m_ptr)) { r_ptr->r_flags3 |= RF3_DRAGON; } - if (mult < 30) mult = 30; - - if ((o_ptr->name1 == ART_BARD_ARROW) && - (m_ptr->r_idx == MON_SMAUG) && + if ((o_ptr->name1 == ART_BARD_ARROW) && (m_ptr->r_idx == MON_SMAUG) && (inventory[INVEN_BOW].name1 == ART_BARD)) mult *= 5; } - /* Brand (Acid) */ if (have_flag(flgs, TR_BRAND_ACID)) { /* Notice immunity */ @@ -3038,15 +2461,12 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ACID_MASK); } } - - /* Otherwise, take the damage */ else { if (mult < 17) mult = 17; } } - /* Brand (Elec) */ if (have_flag(flgs, TR_BRAND_ELEC)) { /* Notice immunity */ @@ -3057,15 +2477,12 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_ELEC_MASK); } } - - /* Otherwise, take the damage */ else { if (mult < 17) mult = 17; } } - /* Brand (Fire) */ if (have_flag(flgs, TR_BRAND_FIRE)) { /* Notice immunity */ @@ -3076,7 +2493,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_FIRE_MASK); } } - /* Otherwise, take the damage */ else { @@ -3092,7 +2508,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) } } - /* Brand (Cold) */ if (have_flag(flgs, TR_BRAND_COLD)) { /* Notice immunity */ @@ -3118,7 +2533,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) } } - /* Brand (Poison) */ if (have_flag(flgs, TR_BRAND_POIS)) { /* Notice immunity */ @@ -3129,7 +2543,6 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) r_ptr->r_flagsr |= (r_ptr->flagsr & RFR_EFF_IM_POIS_MASK); } } - /* Otherwise, take the damage */ else { @@ -3189,13 +2602,15 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) * Note that Bows of "Extra Shots" give an extra shot. * */ -void do_cmd_fire_aux(int item, object_type *j_ptr) +void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr) { - int dir; - int i, j, y, x, ny, nx, ty, tx, prev_y, prev_x; + DIRECTION dir; + int i; + POSITION y, x, ny, nx, ty, tx, prev_y, prev_x; int tdam_base, tdis, thits, tmul; int bonus, chance; int cur_dis, visible; + PERCENTAGE j; object_type forge; object_type *q_ptr; @@ -3204,7 +2619,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) bool hit_body = FALSE; - char o_name[MAX_NLEN]; + GAME_TEXT o_name[MAX_NLEN]; u16b path_g[512]; /* For calcuration of path length */ @@ -3226,7 +2641,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) /* Sniper - Cannot shot a single arrow twice */ if ((snipe_type == SP_DOUBLE) && (o_ptr->number < 2)) snipe_type = SP_NONE; - /* Describe the object */ object_desc(o_name, o_ptr, OD_OMIT_PREFIX); /* Use the proper number of shots */ @@ -3322,8 +2736,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) /* Start at the player */ y = p_ptr->y; x = p_ptr->x; - - /* Get local object */ q_ptr = &forge; /* Obtain a local object */ @@ -3347,10 +2759,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) floor_item_optimize(0 - item); } - /* Sound */ sound(SOUND_SHOOT); - - /* Hack -- Handle stuff */ handle_stuff(); /* Save the old location */ @@ -3383,7 +2792,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩ãç ãæ£ã£ãã", "Wall rocks were shattered.")); /* Forget the wall */ c_ptr->info &= ~(CAVE_MARK); - p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE); /* Destroy the wall */ @@ -3404,11 +2812,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (snipe_type == SP_LITE) { cave[ny][nx].info |= (CAVE_GLOW); - - /* Notice */ note_spot(ny, nx); - - /* Redraw */ lite_spot(ny, nx); } @@ -3445,11 +2849,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (snipe_type == SP_EVILNESS) { cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK); - - /* Notice */ note_spot(ny, nx); - - /* Redraw */ lite_spot(ny, nx); } @@ -3461,7 +2861,6 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) x = nx; y = ny; - /* Monster here, Try to hit it */ if (cave[y][x].m_idx) { @@ -3527,12 +2926,11 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) /* Handle visible monster */ else { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; /* Get "the monster" or "it" */ monster_desc(m_name, m_ptr, 0); - /* Message */ msg_format(_("%sã%sã«å½ä¸ããã", "The %s hits %s."), o_name, m_name); if (m_ptr->ml) @@ -3550,7 +2948,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if ((randint1(randint1(r_ptr->level / (3 + p_ptr->concent)) + (8 - p_ptr->concent)) == 1) && !(r_ptr->flags1 & RF1_UNIQUE) && !(r_ptr->flags7 & RF7_UNIQUE2)) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; /* Get "the monster" or "it" */ monster_desc(m_name, m_ptr, 0); @@ -3562,7 +2960,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) } else { - /* Apply special damage XXX XXX XXX */ + /* Apply special damage */ tdam = tot_dam_aux_shot(q_ptr, tdam, m_ptr); tdam = critical_shot(q_ptr->weight, q_ptr->to_h, j_ptr->to_h, tdam); @@ -3591,16 +2989,12 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (snipe_type == SP_HOLYNESS) { cave[ny][nx].info |= (CAVE_GLOW); - - /* Notice */ note_spot(ny, nx); - - /* Redraw */ lite_spot(ny, nx); } /* Hit the monster, check for death */ - if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr)))) + if (mon_take_hit(c_mon_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr)))) { /* Dead monster */ } @@ -3612,7 +3006,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (object_is_fixed_artifact(q_ptr) && (p_ptr->pclass != CLASS_SNIPER || p_ptr->concent == 0)) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); @@ -3620,24 +3014,16 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) msg_format(_("%sã¯%sã«çªãåºãã£ãï¼", "%^s have stuck into %s!"),o_name, m_name); } - /* Message */ message_pain(c_mon_ptr->m_idx, tdam); /* Anger the monster */ if (tdam > 0) anger_monster(m_ptr); - /* Take note */ if (fear && m_ptr->ml) { - char m_name[80]; - - /* Sound */ + GAME_TEXT m_name[MAX_NLEN]; sound(SOUND_FLEE); - - /* Get the monster name (or "it") */ monster_desc(m_name, m_ptr, 0); - - /* Message */ msg_format(_("%^sã¯ææãã¦éãåºããï¼", "%^s flees in terror!"), m_name); } @@ -3675,7 +3061,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) m_ptr->fy = ny; /* Update the monster (new location) */ - update_mon(c_mon_ptr->m_idx, TRUE); + update_monster(c_mon_ptr->m_idx, TRUE); lite_spot(ny, nx); lite_spot(oy, ox); @@ -3712,7 +3098,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) { MONSTER_IDX m_idx = cave[y][x].m_idx; monster_type *m_ptr = &m_list[m_idx]; - IDX o_idx = o_pop(); + OBJECT_IDX o_idx = o_pop(); if (!o_idx) { @@ -3767,7 +3153,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) void do_cmd_fire(void) { OBJECT_IDX item; - object_type *j_ptr; + object_type *j_ptr, *ammo_ptr; cptr q, s; is_fired = FALSE; /* not fired yet */ @@ -3806,10 +3192,12 @@ void do_cmd_fire(void) /* Require proper missile */ item_tester_tval = p_ptr->tval_ammo; - /* Get an item */ q = _("ã©ããæã¡ã¾ãã? ", "Fire which item? "); s = _("çºå°ãããã¢ã¤ãã ãããã¾ããã", "You have nothing to fire."); - if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) + + + ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR)); + if (!ammo_ptr) { flush(); return; @@ -3833,22 +3221,9 @@ void do_cmd_fire(void) } } -/*! - * @brief ãªãã¸ã§ã¯ããæå°å¯è½ãªæ¦å¨ãã©ãããè¿ãã - * @param o_ptr å¤å®ãããªãã¸ã§ã¯ãã®æ§é ä½åç §ãã¤ã³ã¿ - * @return æå°å¯è½ãªæ¦å¨ãªãã°TRUE - */ -static bool item_tester_hook_boomerang(object_type *o_ptr) -{ - if ((o_ptr->tval==TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED)) return (TRUE); - - /* Assume not */ - return (FALSE); -} - /*! - * @brief æå°å¦çã®ãµãã«ã¼ãã³ / + * @brief æå°å¦çã¡ã¤ã³ã«ã¼ãã³ / * Throw an object from the pack or floor. * @param mult å¨åã®åç * @param boomerang ãã¼ã¡ã©ã³å¦çãªãã°TRUE @@ -3863,19 +3238,20 @@ static bool item_tester_hook_boomerang(object_type *o_ptr) * the item to be destroyed? Should it do any damage at all? * */ -bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) +bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken) { DIRECTION dir; OBJECT_IDX item; - int i, j, y, x, ty, tx, prev_y, prev_x; - int ny[19], nx[19]; + int i; + POSITION y, x, ty, tx, prev_y, prev_x; + POSITION ny[19], nx[19]; int chance, tdam, tdis; int mul, div, dd, ds; int cur_dis, visible; + PERCENTAGE j; object_type forge; object_type *q_ptr; - object_type *o_ptr; bool hit_body = FALSE; @@ -3883,11 +3259,11 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) bool equiped_item = FALSE; bool return_when_thrown = FALSE; - char o_name[MAX_NLEN]; + GAME_TEXT o_name[MAX_NLEN]; int msec = delay_factor * delay_factor * delay_factor; - u32b flgs[TR_FLAG_SIZE]; + BIT_FLAGS flgs[TR_FLAG_SIZE]; cptr q, s; bool come_back = FALSE; bool do_drop = TRUE; @@ -3909,7 +3285,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) item_tester_hook = item_tester_hook_boomerang; q = _("ã©ã®æ¦å¨ãæãã¾ãã? ", "Throw which item? "); s = _("æããæ¦å¨ããªãã", "You have nothing to throw."); - if (!get_item(&item, q, s, (USE_EQUIP))) + o_ptr = choose_object(&item, q, s, (USE_EQUIP)); + if (!o_ptr) { flush(); return FALSE; @@ -3920,34 +3297,21 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) } else { - /* Get an item */ q = _("ã©ã®ã¢ã¤ãã ãæãã¾ãã? ", "Throw which item? "); s = _("æããã¢ã¤ãã ããªãã", "You have nothing to throw."); - if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) + o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)); + if (!o_ptr) { flush(); return FALSE; } } - /* Access the item (if in the pack) */ - if (item >= 0) - { - o_ptr = &inventory[item]; - } - else - { - o_ptr = &o_list[0 - item]; - } - - /* Item is cursed */ if (object_is_cursed(o_ptr) && (item >= INVEN_RARM)) { - /* Oops */ msg_print(_("ãµã¼ããã©ãããåªããã¦ããããã ã", "Hmmm, it seems to be cursed.")); - /* Nope */ return FALSE; } @@ -3958,12 +3322,10 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) msg_print(_("ã¢ãªã¼ãã§ã¯ã¢ã¤ãã ã使ããªãï¼", "You're in the arena now. This is hand-to-hand!")); msg_print(NULL); - /* Nope */ return FALSE; } - } - /* Get local object */ + } q_ptr = &forge; /* Obtain a local object */ @@ -4000,8 +3362,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) if (shuriken >= 0) { - ty = randint0(101)-50+p_ptr->y; - tx = randint0(101)-50+p_ptr->x; + ty = randint0(101) - 50 + p_ptr->y; + tx = randint0(101) - 50 + p_ptr->x; } else { @@ -4049,7 +3411,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) p_ptr->redraw |= (PR_EQUIPPY); } - /* Take a turn */ p_ptr->energy_use = 100; /* Rogue and Ninja gets bonus */ @@ -4060,8 +3421,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) y = p_ptr->y; x = p_ptr->x; - - /* Hack -- Handle stuff */ handle_stuff(); if ((p_ptr->pclass == CLASS_NINJA) && ((q_ptr->tval == TV_SPIKE) || ((have_flag(flgs, TR_THROW)) && (q_ptr->tval == TV_SWORD)))) shuriken = TRUE; @@ -4133,7 +3492,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) if (cave[y][x].m_idx) { cave_type *c_ptr = &cave[y][x]; - monster_type *m_ptr = &m_list[c_ptr->m_idx]; /* Check the visibility */ @@ -4157,12 +3515,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) /* Handle visible monster */ else { - char m_name[80]; - - /* Get "the monster" or "it" */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); - - /* Message */ msg_format(_("%sã%sã«å½ä¸ããã", "The %s hits %s."), o_name, m_name); if (m_ptr->ml) @@ -4180,7 +3534,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) ds = q_ptr->ds; torch_dice(q_ptr, &dd, &ds); /* throwing a torch */ tdam = damroll(dd, ds); - /* Apply special damage XXX XXX XXX */ + /* Apply special damage */ tdam = tot_dam_aux(q_ptr, tdam, m_ptr, 0, TRUE); tdam = critical_shot(q_ptr->weight, q_ptr->to_h, 0, tdam); if (q_ptr->to_d > 0) @@ -4217,7 +3571,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) tdam, m_ptr->hp - tdam, m_ptr->maxhp, m_ptr->max_maxhp); /* Hit the monster, check for death */ - if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_ptr(m_ptr)))) + if (mon_take_hit(c_ptr->m_idx, tdam, &fear, extract_note_dies(real_r_idx(m_ptr)))) { /* Dead monster */ } @@ -4225,25 +3579,17 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) /* No death */ else { - /* Message */ message_pain(c_ptr->m_idx, tdam); /* Anger the monster */ if ((tdam > 0) && !object_is_potion(q_ptr)) anger_monster(m_ptr); - /* Take note */ if (fear && m_ptr->ml) { - char m_name[80]; - - /* Sound */ sound(SOUND_FLEE); - - /* Get the monster name (or "it") */ + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, m_ptr, 0); - - /* Message */ msg_format(_("%^sã¯ææãã¦éãåºããï¼", "%^s flees in terror!"), m_name); } } @@ -4265,8 +3611,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) { j = 100; - if (!(summon_named_creature(0, y, x, q_ptr->pval, - !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L))) + if (!(summon_named_creature(0, y, x, q_ptr->pval, !(object_is_cursed(q_ptr)) ? PM_FORCE_PET : 0L))) msg_print(_("人形ã¯æ»ãæ²ããç ãæ£ã£ã¦ãã¾ã£ãï¼", "The Figurine writhes and then shatters.")); else if (object_is_cursed(q_ptr)) msg_print(_("ããã¯ãã¾ãè¯ããªãæ°ãããã", "You have a bad feeling about this.")); @@ -4279,7 +3624,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) { if (hit_body || hit_wall || (randint1(100) < j)) { - /* Message */ msg_format(_("%sã¯ç ãæ£ã£ãï¼", "The %s shatters!"), o_name); if (potion_smash_effect(0, y, x, q_ptr->k_idx)) @@ -4291,7 +3635,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) is_friendly(&m_list[cave[y][x].m_idx]) && !MON_INVULNER(m_ptr)) { - char m_name[80]; + GAME_TEXT m_name[MAX_NLEN]; monster_desc(m_name, &m_list[cave[y][x].m_idx], 0); msg_format(_("%sã¯æã£ãï¼", "%^s gets angry!"), m_name); set_hostile(&m_list[cave[y][x].m_idx]); @@ -4380,16 +3724,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) /* Increment the equip counter by hand */ equip_cnt++; - /* Recalculate bonuses */ - p_ptr->update |= (PU_BONUS); - /* Recalculate torch */ - p_ptr->update |= (PU_TORCH); - - /* Recalculate mana XXX */ - p_ptr->update |= (PU_MANA); - - /* Window stuff */ + p_ptr->update |= (PU_BONUS | PU_TORCH | PU_MANA); p_ptr->window |= (PW_EQUIP); } else @@ -4404,17 +3740,14 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) calc_android_exp(); } - /* Drop (or break) near that location */ if (do_drop) { if (cave_have_flag_bold(y, x, FF_PROJECT)) { - /* Drop (or break) near that location */ (void)drop_near(q_ptr, j, y, x); } else { - /* Drop (or break) near that location */ (void)drop_near(q_ptr, j, prev_y, prev_x); } } @@ -4423,17 +3756,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, OBJECT_IDX shuriken) } -/*! - * @brief æå°å¦çã®ã¡ã¤ã³ã«ã¼ãã³ / - * Throw an object from the pack or floor. - * @return ãªã - */ -void do_cmd_throw(void) -{ - do_cmd_throw_aux(1, FALSE, -1); -} - - #ifdef TRAVEL /* * Hack: travel command @@ -4451,18 +3773,16 @@ static POSITION temp2_y[MAX_SHORT]; */ void forget_travel_flow(void) { - int x, y; - - /* Check the entire dungeon */ + POSITION x, y; + /* Check the entire dungeon / Forget the old data */ for (y = 0; y < cur_hgt; y++) { for (x = 0; x < cur_wid; x++) { - /* Forget the old data */ + travel.cost[y][x] = MAX_SHORT; } } - travel.y = travel.x = 0; } @@ -4472,7 +3792,7 @@ void forget_travel_flow(void) * @param x 該å½å°ç¹ã®Xåº§æ¨ * @return ã³ã¹ãå¤ */ -static int travel_flow_cost(int y, int x) +static int travel_flow_cost(POSITION y, POSITION x) { feature_type *f_ptr = &f_info[cave[y][x].feat]; int cost = 1; @@ -4572,9 +3892,9 @@ static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall) * @param tx ç®æ¨å°ç¹ã®Xåº§æ¨ * @return ãªã */ -static void travel_flow(int ty, int tx) +static void travel_flow(POSITION ty, POSITION tx) { - int x, y, d; + POSITION x, y, d; bool wall = FALSE; feature_type *f_ptr = &f_info[cave[p_ptr->y][p_ptr->x].feat]; @@ -4620,7 +3940,7 @@ void do_cmd_travel(void) { POSITION x, y; int i; - int dx, dy, sx, sy; + POSITION dx, dy, sx, sy; feature_type *f_ptr; if (travel.x != 0 && travel.y != 0 &&