X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fcmd-basic.c;h=7a7129430ce572a82733d545ac6c57990eaf58d1;hb=684c96b740dd868a22045164bd8b43148045f76c;hp=cc72733b01a4515940cc5c63573f18becb2a87f9;hpb=3de14b2e6c253d8fc18b77e0a97cd4b5faa7ed26;p=hengband%2Fhengband.git diff --git a/src/cmd-basic.c b/src/cmd-basic.c index cc72733b0..7a7129430 100644 --- a/src/cmd-basic.c +++ b/src/cmd-basic.c @@ -183,17 +183,17 @@ bool cmd_limit_time_walk(player_type *creature_ptr) * @brief 階段を使って階層を昇る処理 / Go up one level * @return なし */ -void do_cmd_go_up(void) +void do_cmd_go_up(player_type *creature_ptr) { bool go_up = FALSE; /* Player grid */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x]; + grid_type *g_ptr = ¤t_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]; feature_type *f_ptr = &f_info[g_ptr->feat]; int up_num = 0; - if (p_ptr->special_defense & KATA_MUSOU) + if (creature_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } @@ -208,42 +208,40 @@ void do_cmd_go_up(void) /* Quest up stairs */ if (have_flag(f_ptr->flags, FF_QUEST)) { - /* Cancel the command */ - if (!confirm_leave_level(p_ptr, FALSE)) return; + if (!confirm_leave_level(creature_ptr, FALSE)) return; - /* Success */ - if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) + if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) msg_print(_("なんだこの階段は!", "What's this STAIRWAY!")); else msg_print(_("上の階に登った。", "You enter the up staircase.")); leave_quest_check(); - p_ptr->inside_quest = g_ptr->special; + creature_ptr->inside_quest = g_ptr->special; /* Activate the quest */ - if (!quest[p_ptr->inside_quest].status) + if (!quest[creature_ptr->inside_quest].status) { - if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) + if (quest[creature_ptr->inside_quest].type != QUEST_TYPE_RANDOM) { init_flags = INIT_ASSIGN; process_dungeon_file("q_info.txt", 0, 0, 0, 0); } - quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN; + quest[creature_ptr->inside_quest].status = QUEST_STATUS_TAKEN; } /* Leaving a quest */ - if (!p_ptr->inside_quest) + if (!creature_ptr->inside_quest) { current_floor_ptr->dun_level = 0; } - p_ptr->leaving = TRUE; + creature_ptr->leaving = TRUE; - p_ptr->oldpx = 0; - p_ptr->oldpy = 0; + creature_ptr->oldpx = 0; + creature_ptr->oldpy = 0; - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); /* End the command */ return; @@ -255,32 +253,31 @@ void do_cmd_go_up(void) } else { - go_up = confirm_leave_level(p_ptr, FALSE); + go_up = confirm_leave_level(creature_ptr, FALSE); } - /* Cancel the command */ if (!go_up) return; - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); if (autosave_l) do_cmd_save_game(TRUE); /* For a random quest */ - if (p_ptr->inside_quest && - quest[p_ptr->inside_quest].type == QUEST_TYPE_RANDOM) + if (creature_ptr->inside_quest && + quest[creature_ptr->inside_quest].type == QUEST_TYPE_RANDOM) { leave_quest_check(); - p_ptr->inside_quest = 0; + creature_ptr->inside_quest = 0; } /* For a fixed quest */ - if (p_ptr->inside_quest && - quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) + if (creature_ptr->inside_quest && + quest[creature_ptr->inside_quest].type != QUEST_TYPE_RANDOM) { leave_quest_check(); - p_ptr->inside_quest = g_ptr->special; + creature_ptr->inside_quest = g_ptr->special; current_floor_ptr->dun_level = 0; up_num = 0; } @@ -305,19 +302,19 @@ void do_cmd_go_up(void) } /* Get out from current dungeon */ - if (current_floor_ptr->dun_level - up_num < d_info[p_ptr->dungeon_idx].mindepth) + if (current_floor_ptr->dun_level - up_num < d_info[creature_ptr->dungeon_idx].mindepth) up_num = current_floor_ptr->dun_level; } if (record_stair) do_cmd_write_nikki(NIKKI_STAIR, 0-up_num, _("階段を上った", "climbed up the stairs to")); /* Success */ - if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) + if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) msg_print(_("なんだこの階段は!", "What's this STAIRWAY!")); else if (up_num == current_floor_ptr->dun_level) msg_print(_("地上に戻った。", "You go back to the surface.")); else msg_print(_("階段を上って新たなる迷宮へと足を踏み入れた。", "You enter a maze of up staircases.")); - p_ptr->leaving = TRUE; + creature_ptr->leaving = TRUE; } @@ -325,16 +322,16 @@ void do_cmd_go_up(void) * @brief 階段を使って階層を降りる処理 / Go down one level * @return なし */ -void do_cmd_go_down(void) +void do_cmd_go_down(player_type *creature_ptr) { /* Player grid */ - grid_type *g_ptr = ¤t_floor_ptr->grid_array[p_ptr->y][p_ptr->x]; + grid_type *g_ptr = ¤t_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x]; feature_type *f_ptr = &f_info[g_ptr->feat]; bool fall_trap = FALSE; int down_num = 0; - if (p_ptr->special_defense & KATA_MUSOU) + if (creature_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } @@ -358,9 +355,9 @@ void do_cmd_go_down(void) else if (have_flag(f_ptr->flags, FF_QUEST)) { /* Confirm Leaving */ - if(!confirm_leave_level(p_ptr, TRUE)) return; + if(!confirm_leave_level(creature_ptr, TRUE)) return; - if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) + if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) msg_print(_("なんだこの階段は!", "What's this STAIRWAY!")); else msg_print(_("下の階に降りた。", "You enter the down staircase.")); @@ -368,29 +365,29 @@ void do_cmd_go_down(void) leave_quest_check(); leave_tower_check(); - p_ptr->inside_quest = g_ptr->special; + creature_ptr->inside_quest = g_ptr->special; /* Activate the quest */ - if (!quest[p_ptr->inside_quest].status) + if (!quest[creature_ptr->inside_quest].status) { - if (quest[p_ptr->inside_quest].type != QUEST_TYPE_RANDOM) + if (quest[creature_ptr->inside_quest].type != QUEST_TYPE_RANDOM) { init_flags = INIT_ASSIGN; process_dungeon_file("q_info.txt", 0, 0, 0, 0); } - quest[p_ptr->inside_quest].status = QUEST_STATUS_TAKEN; + quest[creature_ptr->inside_quest].status = QUEST_STATUS_TAKEN; } /* Leaving a quest */ - if (!p_ptr->inside_quest) + if (!creature_ptr->inside_quest) { current_floor_ptr->dun_level = 0; } - p_ptr->leaving = TRUE; - p_ptr->oldpx = 0; - p_ptr->oldpy = 0; + creature_ptr->leaving = TRUE; + creature_ptr->oldpx = 0; + creature_ptr->oldpy = 0; - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); } else @@ -414,9 +411,9 @@ void do_cmd_go_down(void) } /* Save old player position */ - p_ptr->oldpx = p_ptr->x; - p_ptr->oldpy = p_ptr->y; - p_ptr->dungeon_idx = target_dungeon; + creature_ptr->oldpx = creature_ptr->x; + creature_ptr->oldpy = creature_ptr->y; + creature_ptr->dungeon_idx = target_dungeon; /* * Clear all saved floors @@ -425,7 +422,7 @@ void do_cmd_go_down(void) prepare_change_floor_mode(CFM_FIRST_FLOOR); } - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); if (autosave_l) do_cmd_save_game(TRUE); @@ -436,8 +433,8 @@ void do_cmd_go_down(void) if (!current_floor_ptr->dun_level) { /* Enter the dungeon just now */ - p_ptr->enter_dungeon = TRUE; - down_num = d_info[p_ptr->dungeon_idx].mindepth; + creature_ptr->enter_dungeon = TRUE; + down_num = d_info[creature_ptr->dungeon_idx].mindepth; } if (record_stair) @@ -455,18 +452,18 @@ void do_cmd_go_down(void) /* Success */ if (target_dungeon) { - msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[p_ptr->dungeon_idx].text); + msg_format(_("%sへ入った。", "You entered %s."), d_text + d_info[creature_ptr->dungeon_idx].text); } else { - if ((p_ptr->pseikaku == SEIKAKU_COMBAT) || (p_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) + if ((creature_ptr->pseikaku == SEIKAKU_COMBAT) || (creature_ptr->inventory_list[INVEN_BOW].name1 == ART_CRIMSON)) msg_print(_("なんだこの階段は!", "What's this STAIRWAY!")); else msg_print(_("階段を下りて新たなる迷宮へと足を踏み入れた。", "You enter a maze of down staircases.")); } } - p_ptr->leaving = TRUE; + creature_ptr->leaving = TRUE; if (fall_trap) { @@ -493,22 +490,21 @@ void do_cmd_go_down(void) * @brief 探索コマンドのメインルーチン / Simple command to "search" for one current_world_ptr->game_turn * @return なし */ -void do_cmd_search(void) +void do_cmd_search(player_type * creature_ptr) { /* Allow repeated command */ if (command_arg) { /* Set repeat count */ command_rep = command_arg - 1; - p_ptr->redraw |= (PR_STATE); + creature_ptr->redraw |= (PR_STATE); /* Cancel the arg */ command_arg = 0; } - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); - /* Search */ - search(); + search(creature_ptr); } @@ -547,7 +543,7 @@ static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped) } /*! - * @brief 箱を開けるコマンドのメインルーチン / + * @brief 箱を開ける実行処理 / * Attempt to open the given chest at the given location * @param y 箱の存在するマスのY座標 * @param x 箱の存在するマスのX座標 @@ -556,14 +552,14 @@ static OBJECT_IDX chest_check(POSITION y, POSITION x, bool trapped) * @details * Assume there is no monster blocking the destination */ -static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx) +static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OBJECT_IDX o_idx) { int i, j; bool flag = TRUE; bool more = FALSE; object_type *o_ptr = ¤t_floor_ptr->o_list[o_idx]; - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); /* Attempt to unlock it */ if (o_ptr->pval > 0) @@ -572,11 +568,11 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx) flag = FALSE; /* Get the "disarm" factor */ - i = p_ptr->skill_dis; + i = creature_ptr->skill_dis; /* Penalize some conditions */ - if (p_ptr->blind || no_lite()) i = i / 10; - if (p_ptr->confused || p_ptr->image) i = i / 10; + if (creature_ptr->blind || no_lite()) i = i / 10; + if (creature_ptr->confused || creature_ptr->image) i = i / 10; /* Extract the difficulty */ j = i - o_ptr->pval; @@ -588,7 +584,7 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx) if (randint0(100) < j) { msg_print(_("鍵をはずした。", "You have picked the lock.")); - gain_exp(1); + gain_exp(p_ptr, 1); flag = TRUE; } @@ -788,7 +784,7 @@ static bool do_cmd_open_aux(POSITION y, POSITION x) sound(SOUND_OPENDOOR); /* Experience */ - gain_exp(1); + gain_exp(p_ptr, 1); } /* Failure */ @@ -822,7 +818,7 @@ static bool do_cmd_open_aux(POSITION y, POSITION x) * @details * Unlocking a locked door/chest is worth one experience point. */ -void do_cmd_open(void) +void do_cmd_open(player_type *creature_ptr) { POSITION y, x; DIRECTION dir; @@ -830,9 +826,9 @@ void do_cmd_open(void) bool more = FALSE; - if (p_ptr->wild_mode) return; + if (creature_ptr->wild_mode) return; - if (p_ptr->special_defense & KATA_MUSOU) + if (creature_ptr->special_defense & KATA_MUSOU) { set_action(ACTION_NONE); } @@ -842,13 +838,8 @@ void do_cmd_open(void) { int num_doors, num_chests; - /* Count closed doors (locked or jammed) */ num_doors = count_dt(&y, &x, is_closed_door, FALSE); - - /* Count chests (locked) */ - num_chests = count_chests(p_ptr, &y, &x, FALSE); - - /* See if only one target */ + num_chests = count_chests(creature_ptr, &y, &x, FALSE); if (num_doors || num_chests) { bool too_many = (num_doors && num_chests) || (num_doors > 1) || @@ -862,7 +853,7 @@ void do_cmd_open(void) { /* Set repeat count */ command_rep = command_arg - 1; - p_ptr->redraw |= (PR_STATE); + creature_ptr->redraw |= (PR_STATE); /* Cancel the arg */ command_arg = 0; @@ -875,8 +866,8 @@ void do_cmd_open(void) grid_type *g_ptr; /* Get requested location */ - y = p_ptr->y + ddy[dir]; - x = p_ptr->x + ddx[dir]; + y = creature_ptr->y + ddy[dir]; + x = creature_ptr->x + ddx[dir]; /* Get requested grid */ g_ptr = ¤t_floor_ptr->grid_array[y][x]; @@ -887,31 +878,22 @@ void do_cmd_open(void) /* Check for chest */ o_idx = chest_check(y, x, FALSE); - /* Nothing useful */ if (!have_flag(f_info[feat].flags, FF_OPEN) && !o_idx) { msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open.")); } - - /* Monster in the way */ - else if (g_ptr->m_idx && p_ptr->riding != g_ptr->m_idx) + else if (g_ptr->m_idx && creature_ptr->riding != g_ptr->m_idx) { - take_turn(p_ptr, 100); + take_turn(creature_ptr, 100); msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!")); py_attack(y, x, 0); } - - /* Handle chests */ else if (o_idx) { - /* Open the chest */ - more = do_cmd_open_chest(y, x, o_idx); + more = exe_open_chest(creature_ptr, y, x, o_idx); } - - /* Handle doors */ else { - /* Open the door */ more = do_cmd_open_aux(y, x); } } @@ -1192,7 +1174,7 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x) /* We may continue chopping */ msg_format(_("%sを切っている。", "You chop away at the %s."), name); /* Occasional Search XXX XXX */ - if (randint0(100) < 25) search(); + if (randint0(100) < 25) search(p_ptr); } else { @@ -1207,7 +1189,7 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x) if (is_hidden_door(g_ptr)) { /* Occasional Search XXX XXX */ - if (randint0(100) < 25) search(); + if (randint0(100) < 25) search(p_ptr); } return more; } @@ -1363,7 +1345,7 @@ bool easy_open_door(POSITION y, POSITION x) sound(SOUND_OPENDOOR); /* Experience */ - gain_exp(1); + gain_exp(p_ptr, 1); } /* Failure */ @@ -1446,7 +1428,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx) else if (randint0(100) < j) { msg_print(_("箱に仕掛けられていたトラップを解除した。", "You have disarmed the chest.")); - gain_exp(o_ptr->pval); + gain_exp(p_ptr, o_ptr->pval); o_ptr->pval = (0 - o_ptr->pval); } @@ -1521,7 +1503,7 @@ bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir) msg_format(_("%sを解除した。", "You have disarmed the %s."), name); /* Reward */ - gain_exp(power); + gain_exp(p_ptr, power); /* Remove the trap */ cave_alter_feat(y, x, FF_DISARM); @@ -1736,7 +1718,7 @@ static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir) msg_print(_("体のバランスをくずしてしまった。", "You are off-balance.")); /* Hack -- Lose balance ala paralysis */ - (void)set_paralyzed(p_ptr->paralyzed + 2 + randint0(2)); + (void)set_paralyzed(p_ptr, p_ptr->paralyzed + 2 + randint0(2)); } return (more); } @@ -2225,7 +2207,7 @@ void do_cmd_rest(void) if (command_arg > 9999) command_arg = 9999; - if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE); + if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(p_ptr, FALSE); /* Take a current_world_ptr->game_turn (?) */ take_turn(p_ptr, 100); @@ -2326,8 +2308,8 @@ void do_cmd_fire(SPELL_IDX snipe_type) if (snipe_type == SP_FINAL) { msg_print(_("射撃の反動が体を襲った。", "A reactionary of shooting attacked you. ")); - (void)set_slow(p_ptr->slow + randint0(7) + 7, FALSE); - (void)set_stun(p_ptr->stun + randint1(25)); + (void)set_slow(p_ptr, p_ptr->slow + randint0(7) + 7, FALSE); + (void)set_stun(p_ptr, p_ptr->stun + randint1(25)); } } @@ -2839,7 +2821,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken) else if (equiped_item) { kamaenaoshi(item); - calc_android_exp(); + calc_android_exp(p_ptr); } if (do_drop)