X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcmd2.c;h=e9aabde24a8593c8fd1d6b265d80eee5d78312e7;hb=6b79d8d2bd1224c91a486561f8f671a29bb9dce4;hp=42adb5a6fe158b5a2af561cdadc61481fc9b7e06;hpb=e60acc778fcffacc3774f976716f75695c600fa0;p=hengband%2Fhengband.git diff --git a/src/cmd2.c b/src/cmd2.c index 42adb5a6f..e9aabde24 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -11,7 +11,8 @@ */ #include "angband.h" - +#include "chest.h" +#include "object-hook.h" /*! * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理 @@ -31,13 +32,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 +76,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 +179,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 +229,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 +335,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.")); } @@ -446,349 +434,6 @@ static s16b chest_check(int y, int x, bool trapped) 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; - u32b 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(int y, int x, s16b 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)y, p_ptr->x, FALSE); - else - (void)summon_specific(0, y, x, mon_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Elemental summon. */ - if (trap & (CHEST_E_SUMMON)) - { - msg_print(_("宝を守るためにエレメンタルが現れた!", "Elemental beings appear to protect their treasures!")); - for (i = 0; i < randint1(3) + 5; i++) - { - (void)summon_specific(0, y, x, mon_level, SUMMON_ELEMENTAL, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Force clouds, then summon birds. */ - if (trap & (CHEST_BIRD_STORM)) - { - msg_print(_("鳥の群れがあなたを取り巻いた!", "A storm of birds swirls around you!")); - - for (i = 0; i < randint1(3) + 3; i++) - (void)fire_meteor(-1, GF_FORCE, y, x, o_ptr->pval / 5, 7); - - for (i = 0; i < randint1(5) + o_ptr->pval / 5; i++) - { - (void)summon_specific(0, y, x, mon_level, SUMMON_BIRD, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Various colorful summonings. */ - if (trap & (CHEST_H_SUMMON)) - { - /* Summon demons. */ - if (one_in_(4)) - { - msg_print(_("炎と硫黄の雲の中に悪魔が姿を現した!", "Demons materialize in clouds of fire and brimstone!")); - for (i = 0; i < randint1(3) + 2; i++) - { - (void)fire_meteor(-1, GF_FIRE, y, x, 10, 5); - (void)summon_specific(0, y, x, mon_level, SUMMON_DEMON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Summon dragons. */ - else if (one_in_(3)) - { - msg_print(_("暗闇にドラゴンの影がぼんやりと現れた!", "Draconic forms loom out of the darkness!")); - for (i = 0; i < randint1(3) + 2; i++) - { - (void)summon_specific(0, y, x, mon_level, SUMMON_DRAGON, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Summon hybrids. */ - else if (one_in_(2)) - { - msg_print(_("奇妙な姿の怪物が襲って来た!", "Creatures strange and twisted assault you!")); - for (i = 0; i < randint1(5) + 3; i++) - { - (void)summon_specific(0, y, x, mon_level, SUMMON_HYBRID, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - - /* Summon vortices (scattered) */ - else - { - msg_print(_("渦巻が合体し、破裂した!", "Vortices coalesce and wreak destruction!")); - for (i = 0; i < randint1(3) + 2; i++) - { - (void)summon_specific(0, y, x, mon_level, SUMMON_VORTEX, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)); - } - } - } - - /* Dispel player. */ - if ((trap & (CHEST_RUNES_OF_EVIL)) && o_ptr->k_idx) - { - /* Determine how many nasty tricks can be played. */ - int nasty_tricks_count = 4 + randint0(3); - - /* Message. */ - msg_print(_("恐ろしい声が響いた: 「暗闇が汝をつつまん!」", "Hideous voices bid: 'Let the darkness have thee!'")); - /* This is gonna hurt... */ - for (; nasty_tricks_count > 0; nasty_tricks_count--) - { - /* ...but a high saving throw does help a little. */ - if (randint1(100+o_ptr->pval*2) > p_ptr->skill_sav) - { - if (one_in_(6)) take_hit(DAMAGE_NOESCAPE, damroll(5, 20), _("破滅のトラップの宝箱", "a chest dispel-player trap"), -1); - else if (one_in_(5)) (void)set_cut(p_ptr->cut + 200); - else if (one_in_(4)) - { - if (!p_ptr->free_act) - (void)set_paralyzed(p_ptr->paralyzed + 2 + - randint0(6)); - else - (void)set_stun(p_ptr->stun + 10 + - randint0(100)); - } - else if (one_in_(3)) apply_disenchant(0); - else if (one_in_(2)) - { - (void)do_dec_stat(A_STR); - (void)do_dec_stat(A_DEX); - (void)do_dec_stat(A_CON); - (void)do_dec_stat(A_INT); - (void)do_dec_stat(A_WIS); - (void)do_dec_stat(A_CHR); - } - else (void)fire_meteor(-1, GF_NETHER, y, x, 150, 1); - } - } - } - - /* Aggravate monsters. */ - if (trap & (CHEST_ALARM)) - { - msg_print(_("けたたましい音が鳴り響いた!", "An alarm sounds!")); - aggravate_monsters(0); - } - - /* Explode */ - if ((trap & (CHEST_EXPLODE)) && o_ptr->k_idx) - { - msg_print(_("突然、箱が爆発した!", "There is a sudden explosion!")); - msg_print(_("箱の中の物はすべて粉々に砕け散った!", "Everything inside the chest is destroyed!")); - o_ptr->pval = 0; - sound(SOUND_EXPLODE); - take_hit(DAMAGE_ATTACK, damroll(5, 8), _("爆発する箱", "an exploding chest"), -1); - } - /* Scatter contents. */ - if ((trap & (CHEST_SCATTER)) && o_ptr->k_idx) - { - msg_print(_("宝箱の中身はダンジョンじゅうに散乱した!", "The contents of the chest scatter all over the dungeon!")); - chest_death(TRUE, y, x, o_idx); - o_ptr->pval = 0; - } -} - - /*! * @brief 箱を開けるコマンドのメインルーチン / * Attempt to open the given chest at the given location @@ -874,7 +519,7 @@ static bool do_cmd_open_chest(int y, int x, s16b o_idx) * @param feat 地形ID * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door */ -static bool is_open(int feat) +static bool is_open(IDX feat) { return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE)); } @@ -891,7 +536,7 @@ static bool is_open(int feat) * @details Return the number of features around (or under) the character. * Usually look for doors and floor traps. */ -static int count_dt(POSITION *y, POSITION *x, bool (*test)(int feat), bool under) +static int count_dt(POSITION *y, POSITION *x, bool (*test)(IDX feat), bool under) { int d, count, xx, yy; @@ -1985,8 +1630,7 @@ void do_cmd_disarm(void) /* See if only one target */ if (num_traps || num_chests) { - bool too_many = (num_traps && num_chests) || (num_traps > 1) || - (num_chests > 1); + bool too_many = (num_traps && num_chests) || (num_traps > 1) || (num_chests > 1); if (!too_many) command_dir = coords_to_dir(y, x); } } @@ -2513,7 +2157,7 @@ void do_cmd_walk(bool pickup) } /* Get a "repeated" direction */ - if (get_rep_dir(&dir,FALSE)) + if (get_rep_dir(&dir, FALSE)) { /* Take a turn */ p_ptr->energy_use = 100; @@ -2638,7 +2282,7 @@ void do_cmd_rest(void) set_action(ACTION_NONE); - if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] || p_ptr->magic_num1[1])) + if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) || INTERUPTING_SONG_EFFECT(p_ptr))) { stop_singing(); } @@ -2664,19 +2308,19 @@ void do_cmd_rest(void) /* Rest until done */ if (out_val[0] == '&') { - command_arg = (-2); + command_arg = COMMAND_ARG_REST_UNTIL_DONE; } /* Rest a lot */ else if (out_val[0] == '*') { - command_arg = (-1); + command_arg = COMMAND_ARG_REST_FULL_HEALING; } /* Rest some */ else { - command_arg = atoi(out_val); + command_arg = (COMMAND_ARG)atoi(out_val); if (command_arg <= 0) return; } } @@ -2731,9 +2375,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) @@ -3192,11 +2836,13 @@ static s16b tot_dam_aux_shot(object_type *o_ptr, int tdam, monster_type *m_ptr) */ void do_cmd_fire_aux(int 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; @@ -3488,7 +3134,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) int now_exp = p_ptr->weapon_exp[0][j_ptr->sval]; if (now_exp < s_info[p_ptr->pclass].w_max[0][j_ptr->sval]) { - int amount = 0; + SUB_EXP amount = 0; if (now_exp < WEAPON_EXP_BEGINNER) amount = 80; else if (now_exp < WEAPON_EXP_SKILLED) amount = 25; else if ((now_exp < WEAPON_EXP_EXPERT) && (p_ptr->lev > 19)) amount = 10; @@ -3648,7 +3294,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (snipe_type == SP_RUSH) { int n = randint1(5) + 3; - IDX m_idx = c_mon_ptr->m_idx; + MONSTER_IDX m_idx = c_mon_ptr->m_idx; for ( ; cur_dis <= tdis; ) { @@ -3711,9 +3357,9 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) if (stick_to) { - int m_idx = cave[y][x].m_idx; + MONSTER_IDX m_idx = cave[y][x].m_idx; monster_type *m_ptr = &m_list[m_idx]; - int o_idx = o_pop(); + IDX o_idx = o_pop(); if (!o_idx) { @@ -3767,7 +3413,7 @@ void do_cmd_fire_aux(int item, object_type *j_ptr) */ void do_cmd_fire(void) { - int item; + OBJECT_IDX item; object_type *j_ptr; cptr q, s; @@ -3834,22 +3480,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 @@ -3864,14 +3497,17 @@ 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, int shuriken) +bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken) { - int dir, item; - int i, j, y, x, ty, tx, prev_y, prev_x; - int ny[19], nx[19]; + DIRECTION dir; + OBJECT_IDX item; + 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; @@ -3961,6 +3597,7 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int shuriken) /* Nope */ return FALSE; } + } /* Get local object */ @@ -4000,8 +3637,8 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int 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 { @@ -4133,7 +3770,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int 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 */ @@ -4423,17 +4059,6 @@ bool do_cmd_throw_aux(int mult, bool boomerang, int 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 @@ -4442,8 +4067,8 @@ void do_cmd_throw(void) static int flow_head = 0; static int flow_tail = 0; -static s16b temp2_x[MAX_SHORT]; -static s16b temp2_y[MAX_SHORT]; +static POSITION temp2_x[MAX_SHORT]; +static POSITION temp2_y[MAX_SHORT]; /*! * @brief トラベル処理の記憶配列を初期化する Hack: forget the "flow" information @@ -4515,7 +4140,7 @@ static int travel_flow_cost(int y, int x) * @param wall プレイヤーが壁の中にいるならばTRUE * @return なし */ -static void travel_flow_aux(int y, int x, int n, bool wall) +static void travel_flow_aux(POSITION y, POSITION x, int n, bool wall) { cave_type *c_ptr = &cave[y][x]; feature_type *f_ptr = &f_info[c_ptr->feat];