OSDN Git Service

[Refactor] #38862 Moved feature.c/h, grid.c/h and trap.c/h to grid/
[hengband/hengband.git] / src / cmd / cmd-pet.c
index f99a017..e6ed4d0 100644 (file)
@@ -1,26 +1,28 @@
-#include "angband.h"
-#include "core.h"
+#include "system/angband.h"
+#include "core/stuff-handler.h"
 #include "util.h"
 
-#include "cmd-dump.h"
-#include "floor.h"
-#include "grid.h"
+#include "io/write-diary.h"
+#include "cmd/cmd-dump.h"
+#include "floor/floor.h"
+#include "grid/grid.h"
 #include "melee.h"
 #include "sort.h"
-#include "player-move.h"
-#include "player-status.h"
-#include "player-effects.h"
-#include "player-skill.h"
-#include "player-class.h"
-#include "player-damage.h"
-#include "object-hook.h"
-#include "monster.h"
-#include "monster-status.h"
+#include "player/player-move.h"
+#include "player/player-status.h"
+#include "player/player-effects.h"
+#include "player/player-skill.h"
+#include "player/player-class.h"
+#include "player/player-damage.h"
+#include "object/object-hook.h"
+#include "monster/monster.h"
+#include "monster/monster-status.h"
 #include "cmd-pet.h"
 #include "cmd-basic.h"
-#include "view-mainwindow.h"
+#include "view/display-main-window.h"
 #include "targeting.h"
-#include "world.h"
+#include "world/world.h"
+#include "effect/spells-effect-util.h"
 
 int total_friends = 0;
 
@@ -30,103 +32,45 @@ int total_friends = 0;
 * @param now_riding TRUEなら下馬処理、FALSEならば騎乗処理
 * @return 可能ならばTRUEを返す
 */
-bool player_can_ride_aux(grid_type *g_ptr, bool now_riding)
+bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_riding)
 {
        bool p_can_enter;
        bool old_character_xtra = current_world_ptr->character_xtra;
-       MONSTER_IDX old_riding = p_ptr->riding;
-       bool old_riding_ryoute = p_ptr->riding_ryoute;
-       bool old_old_riding_ryoute = p_ptr->old_riding_ryoute;
-       bool old_pf_ryoute = (p_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE;
+       MONSTER_IDX old_riding = creature_ptr->riding;
+       bool old_riding_ryoute = creature_ptr->riding_ryoute;
+       bool old_old_riding_ryoute = creature_ptr->old_riding_ryoute;
+       bool old_pf_ryoute = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? TRUE : FALSE;
 
        /* Hack -- prevent "icky" message */
        current_world_ptr->character_xtra = TRUE;
 
-       if (now_riding) p_ptr->riding = g_ptr->m_idx;
+       if (now_riding) creature_ptr->riding = g_ptr->m_idx;
        else
        {
-               p_ptr->riding = 0;
-               p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
-               p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
+               creature_ptr->riding = 0;
+               creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+               creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
        }
 
-       p_ptr->update |= PU_BONUS;
-       handle_stuff();
+       creature_ptr->update |= PU_BONUS;
+       handle_stuff(creature_ptr);
 
-       p_can_enter = player_can_enter(g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
+       p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN);
 
-       p_ptr->riding = old_riding;
-       if (old_pf_ryoute) p_ptr->pet_extra_flags |= (PF_RYOUTE);
-       else p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
-       p_ptr->riding_ryoute = old_riding_ryoute;
-       p_ptr->old_riding_ryoute = old_old_riding_ryoute;
+       creature_ptr->riding = old_riding;
+       if (old_pf_ryoute) creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
+       else creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+       creature_ptr->riding_ryoute = old_riding_ryoute;
+       creature_ptr->old_riding_ryoute = old_old_riding_ryoute;
 
-       p_ptr->update |= PU_BONUS;
-       handle_stuff();
+       creature_ptr->update |= PU_BONUS;
+       handle_stuff(creature_ptr);
 
        current_world_ptr->character_xtra = old_character_xtra;
 
        return p_can_enter;
 }
 
-
-/*!
-* @brief ペットの維持コスト計算
-* @return 維持コスト(%)
-*/
-PERCENTAGE calculate_upkeep(player_type *creature_ptr)
-{
-       MONSTER_IDX m_idx;
-       bool have_a_unique = FALSE;
-       DEPTH total_friend_levels = 0;
-
-       total_friends = 0;
-
-       for (m_idx = current_floor_ptr->m_max - 1; m_idx >= 1; m_idx--)
-       {
-               monster_type *m_ptr;
-               monster_race *r_ptr;
-
-               m_ptr = &current_floor_ptr->m_list[m_idx];
-               if (!monster_is_valid(m_ptr)) continue;
-               r_ptr = &r_info[m_ptr->r_idx];
-
-               if (is_pet(m_ptr))
-               {
-                       total_friends++;
-                       if (r_ptr->flags1 & RF1_UNIQUE)
-                       {
-                               if (creature_ptr->pclass == CLASS_CAVALRY)
-                               {
-                                       if (creature_ptr->riding == m_idx)
-                                               total_friend_levels += (r_ptr->level + 5) * 2;
-                                       else if (!have_a_unique && (r_info[m_ptr->r_idx].flags7 & RF7_RIDING))
-                                               total_friend_levels += (r_ptr->level + 5) * 7 / 2;
-                                       else
-                                               total_friend_levels += (r_ptr->level + 5) * 10;
-                                       have_a_unique = TRUE;
-                               }
-                               else
-                                       total_friend_levels += (r_ptr->level + 5) * 10;
-                       }
-                       else
-                               total_friend_levels += r_ptr->level;
-
-               }
-       }
-
-       if (total_friends)
-       {
-               int upkeep_factor;
-               upkeep_factor = (total_friend_levels - (creature_ptr->lev * 80 / (cp_ptr->pet_upkeep_div)));
-               if (upkeep_factor < 0) upkeep_factor = 0;
-               if (upkeep_factor > 1000) upkeep_factor = 1000;
-               return upkeep_factor;
-       }
-       else
-               return 0;
-}
-
 /*!
 * @brief ペットを開放するコマンドのメインルーチン
 * @return なし
@@ -150,12 +94,12 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
        Term->scr->cv = 1;
 
        /* Allocate the "who" array */
-       C_MAKE(who, current_floor_ptr->max_m_idx, MONSTER_IDX);
+       C_MAKE(who, current_world_ptr->max_m_idx, MONSTER_IDX);
 
        /* Process the monsters (backwards) */
-       for (pet_ctr = current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
+       for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
        {
-               if (is_pet(&current_floor_ptr->m_list[pet_ctr]))
+               if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr]))
                        who[max_pet++] = pet_ctr;
        }
 
@@ -169,17 +113,17 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
                bool kakunin;
 
                pet_ctr = who[i];
-               m_ptr = &current_floor_ptr->m_list[pet_ctr];
+               m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
 
                delete_this = FALSE;
                kakunin = ((pet_ctr == creature_ptr->riding) || (m_ptr->nickname));
-               monster_desc(friend_name, m_ptr, MD_ASSUME_VISIBLE);
+               monster_desc(creature_ptr, friend_name, m_ptr, MD_ASSUME_VISIBLE);
 
                if (!all_pets)
                {
                        /* Hack -- health bar for this monster */
-                       health_track(pet_ctr);
-                       handle_stuff();
+                       health_track(creature_ptr, pet_ctr);
+                       handle_stuff(creature_ptr);
 
                        msg_format(_("%sを放しますか? [Yes/No/Unnamed (%d体)]", "Dismiss %s? [Yes/No/Unnamed (%d remain)]"), friend_name, max_pet - i);
 
@@ -223,8 +167,8 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
                        {
                                GAME_TEXT m_name[MAX_NLEN];
 
-                               monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                               exe_write_diary(creature_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
+                               monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
+                               exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_DISMISS, m_name);
                        }
 
                        if (pet_ctr == creature_ptr->riding)
@@ -242,7 +186,7 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
                        creature_ptr->update |= (PU_BONUS);
                        creature_ptr->window |= (PW_MESSAGE);
 
-                       delete_monster_idx(pet_ctr);
+                       delete_monster_idx(creature_ptr, pet_ctr);
                        Dismissed++;
                }
        }
@@ -251,7 +195,7 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
        Term->scr->cv = cv;
        Term_fresh();
 
-       C_KILL(who, current_floor_ptr->max_m_idx, MONSTER_IDX);
+       C_KILL(who, current_world_ptr->max_m_idx, MONSTER_IDX);
 
 #ifdef JP
        msg_format("%d 体のペットを放しました。", Dismissed);
@@ -262,7 +206,7 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
        if (Dismissed == 0 && all_pets)
                msg_print(_("'U'nnamed は、乗馬以外の名前のないペットだけを全て解放します。", "'U'nnamed means all your pets except named pets and your mount."));
 
-       handle_stuff();
+       handle_stuff(creature_ptr);
 }
 
 
@@ -272,54 +216,54 @@ void do_cmd_pet_dismiss(player_type *creature_ptr)
 * @param force 強制的に騎乗/下馬するならばTRUE
 * @return 騎乗/下馬できたらTRUE
 */
-bool do_riding(bool force)
+bool do_cmd_riding(player_type *creature_ptr, bool force)
 {
        POSITION x, y;
        DIRECTION dir = 0;
        grid_type *g_ptr;
        monster_type *m_ptr;
 
-       if (!get_direction(&dir, FALSE, FALSE)) return FALSE;
-       y = p_ptr->y + ddy[dir];
-       x = p_ptr->x + ddx[dir];
-       g_ptr = &current_floor_ptr->grid_array[y][x];
+       if (!get_direction(creature_ptr, &dir, FALSE, FALSE)) return FALSE;
+       y = creature_ptr->y + ddy[dir];
+       x = creature_ptr->x + ddx[dir];
+       g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
 
-       if (p_ptr->special_defense & KATA_MUSOU) set_action(p_ptr, ACTION_NONE);
+       if (creature_ptr->special_defense & KATA_MUSOU) set_action(creature_ptr, ACTION_NONE);
 
-       if (p_ptr->riding)
+       if (creature_ptr->riding)
        {
                /* Skip non-empty grids */
-               if (!player_can_ride_aux(g_ptr, FALSE))
+               if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE))
                {
-                       msg_print(_("そちらには降りられません。", "You cannot go to that direction."));
+                       msg_print(_("そちらには降りられません。", "You cannot go that direction."));
                        return FALSE;
                }
 
-               if (!pattern_seq(p_ptr, p_ptr->y, p_ptr->x, y, x)) return FALSE;
+               if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
 
                if (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);
+                       py_attack(creature_ptr, y, x, 0);
                        return FALSE;
                }
 
-               p_ptr->riding = 0;
-               p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
-               p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
+               creature_ptr->riding = 0;
+               creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+               creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
        }
        else
        {
-               if (cmd_limit_confused(p_ptr)) return FALSE;
+               if (cmd_limit_confused(creature_ptr)) return FALSE;
 
-               m_ptr = &current_floor_ptr->m_list[g_ptr->m_idx];
+               m_ptr = &creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
 
                if (!g_ptr->m_idx || !m_ptr->ml)
                {
-                       msg_print(_("その場所にはモンスターはいません。", "Here is no monster."));
+                       msg_print(_("その場所にはモンスターはいません。", "There is no monster here."));
                        return FALSE;
                }
                if (!is_pet(m_ptr) && !force)
@@ -333,58 +277,58 @@ bool do_riding(bool force)
                        return FALSE;
                }
 
-               if (!pattern_seq(p_ptr, p_ptr->y, p_ptr->x, y, x)) return FALSE;
+               if (!pattern_seq(creature_ptr, creature_ptr->y, creature_ptr->x, y, x)) return FALSE;
 
-               if (!player_can_ride_aux(g_ptr, TRUE))
+               if (!player_can_ride_aux(creature_ptr, g_ptr, TRUE))
                {
                        /* Feature code (applying "mimic" field) */
                        feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
 #ifdef JP
                        msg_format("そのモンスターは%sの%sにいる。", f_name + f_ptr->name,
                                ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
-                                       (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
+                               (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
                                "中" : "上");
 #else
                        msg_format("This monster is %s the %s.",
                                ((!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) ||
-                                       (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
+                               (!have_flag(f_ptr->flags, FF_LOS) && !have_flag(f_ptr->flags, FF_TREE))) ?
                                "in" : "on", f_name + f_ptr->name);
 #endif
 
                        return FALSE;
                }
-               if (r_info[m_ptr->r_idx].level > randint1((p_ptr->skill_exp[GINOU_RIDING] / 50 + p_ptr->lev / 2 + 20)))
+               if (r_info[m_ptr->r_idx].level > randint1((creature_ptr->skill_exp[GINOU_RIDING] / 50 + creature_ptr->lev / 2 + 20)))
                {
                        msg_print(_("うまく乗れなかった。", "You failed to ride."));
-                       take_turn(p_ptr, 100);
+                       take_turn(creature_ptr, 100);
                        return FALSE;
                }
 
                if (MON_CSLEEP(m_ptr))
                {
                        GAME_TEXT m_name[MAX_NLEN];
-                       monster_desc(m_name, m_ptr, 0);
-                       (void)set_monster_csleep(g_ptr->m_idx, 0);
-                       msg_format(_("%sを起こした。", "You have waked %s up."), m_name);
+                       monster_desc(creature_ptr, m_name, m_ptr, 0);
+                       (void)set_monster_csleep(creature_ptr, g_ptr->m_idx, 0);
+                       msg_format(_("%sを起こした。", "You have woken %s up."), m_name);
                }
 
-               if (p_ptr->action == ACTION_KAMAE) set_action(p_ptr, ACTION_NONE);
+               if (creature_ptr->action == ACTION_KAMAE) set_action(creature_ptr, ACTION_NONE);
 
-               p_ptr->riding = g_ptr->m_idx;
+               creature_ptr->riding = g_ptr->m_idx;
 
                /* Hack -- remove tracked monster */
-               if (p_ptr->riding == p_ptr->health_who) health_track(0);
+               if (creature_ptr->riding == creature_ptr->health_who) health_track(creature_ptr, 0);
        }
 
-       take_turn(p_ptr, 100);
+       take_turn(creature_ptr, 100);
 
        /* Mega-Hack -- Forget the view and lite */
-       p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
-       p_ptr->update |= (PU_BONUS);
-       p_ptr->redraw |= (PR_MAP | PR_EXTRA);
-       p_ptr->redraw |= (PR_UHEALTH);
+       creature_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
+       creature_ptr->update |= (PU_BONUS);
+       creature_ptr->redraw |= (PR_MAP | PR_EXTRA);
+       creature_ptr->redraw |= (PR_UHEALTH);
 
-       (void)move_player_effect(p_ptr, y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
+       (void)move_player_effect(creature_ptr, y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
 
        return TRUE;
 }
@@ -393,7 +337,7 @@ bool do_riding(bool force)
 * @brief ペットに名前をつけるコマンドのメインルーチン
 * @return なし
 */
-static void do_name_pet(void)
+static void do_name_pet(player_type *creature_ptr)
 {
        monster_type *m_ptr;
        char out_val[20];
@@ -402,16 +346,17 @@ static void do_name_pet(void)
        bool old_target_pet = target_pet;
 
        target_pet = TRUE;
-       if (!target_set(TARGET_KILL))
+       if (!target_set(creature_ptr, TARGET_KILL))
        {
                target_pet = old_target_pet;
                return;
        }
+
        target_pet = old_target_pet;
 
-       if (current_floor_ptr->grid_array[target_row][target_col].m_idx)
+       if (creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx)
        {
-               m_ptr = &current_floor_ptr->m_list[current_floor_ptr->grid_array[target_row][target_col].m_idx];
+               m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
 
                if (!is_pet(m_ptr))
                {
@@ -423,7 +368,7 @@ static void do_name_pet(void)
                        msg_print(_("そのモンスターの名前は変えられない!", "You cannot change name of this monster!"));
                        return;
                }
-               monster_desc(m_name, m_ptr, 0);
+               monster_desc(creature_ptr, m_name, m_ptr, 0);
 
                msg_format(_("%sに名前をつける。", "Name %s."), m_name);
                msg_print(NULL);
@@ -448,16 +393,16 @@ static void do_name_pet(void)
                                m_ptr->nickname = quark_add(out_val);
                                if (record_named_pet)
                                {
-                                       monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                                       exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
+                                       monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
+                                       exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_NAME, m_name);
                                }
                        }
                        else
                        {
                                if (record_named_pet && old_name)
                                {
-                                       monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
-                                       exe_write_diary(p_ptr, NIKKI_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
+                                       monster_desc(creature_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
+                                       exe_write_diary(creature_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_UNNAME, m_name);
                                }
                                m_ptr->nickname = 0;
                        }
@@ -492,17 +437,17 @@ void do_cmd_pet(player_type *creature_ptr)
 
        num = 0;
 
-       if(creature_ptr->wild_mode) return;
+       if (creature_ptr->wild_mode) return;
 
        power_desc[num] = _("ペットを放す", "dismiss pets");
        powers[num++] = PET_DISMISS;
 
 #ifdef JP
        sprintf(target_buf, "ペットのターゲットを指定 (現在:%s)",
-               (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "何か奇妙な物" : (r_name + r_info[current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
+               (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "何か奇妙な物" : (r_name + r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "指定なし"));
 #else
        sprintf(target_buf, "specify a target of pet (now:%s)",
-               (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "something strange" : (r_name + r_info[current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "nothing"));
+               (creature_ptr->pet_t_m_idx ? (creature_ptr->image ? "something strange" : (r_name + r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name)) : "nothing"));
 #endif
        power_desc[num] = target_buf;
        powers[num++] = PET_TARGET;
@@ -606,16 +551,16 @@ void do_cmd_pet(player_type *creature_ptr)
                        (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) &&
                                object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])))
                {
-                       if (creature_ptr->pet_extra_flags & PF_RYOUTE)
+                       if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
                        {
-                               power_desc[num] = _("武器を片手で持つ", "use one hand to control a riding pet");
+                               power_desc[num] = _("武器を片手で持つ", "use one hand to control the pet you are riding");
                        }
                        else
                        {
                                power_desc[num] = _("武器を両手で持つ", "use both hands for a weapon");
                        }
 
-                       powers[num++] = PET_RYOUTE;
+                       powers[num++] = PET_TWO_HANDS;
                }
                else
                {
@@ -626,29 +571,29 @@ void do_cmd_pet(player_type *creature_ptr)
                        case CLASS_BERSERKER:
                                if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM))
                                {
-                                       if (creature_ptr->pet_extra_flags & PF_RYOUTE)
+                                       if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
                                        {
-                                               power_desc[num] = _("片手で格闘する", "use one hand to control a riding pet");
+                                               power_desc[num] = _("片手で格闘する", "use one hand to control the pet you are riding");
                                        }
                                        else
                                        {
                                                power_desc[num] = _("両手で格闘する", "use both hands for melee");
                                        }
 
-                                       powers[num++] = PET_RYOUTE;
+                                       powers[num++] = PET_TWO_HANDS;
                                }
                                else if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM))
                                {
-                                       if (creature_ptr->pet_extra_flags & PF_RYOUTE)
+                                       if (creature_ptr->pet_extra_flags & PF_TWO_HANDS)
                                        {
-                                               power_desc[num] = _("格闘を行わない", "use one hand to control a riding pet");
+                                               power_desc[num] = _("格闘を行わない", "use one hand to control the pet you are riding");
                                        }
                                        else
                                        {
                                                power_desc[num] = _("格闘を行う", "use one hand for melee");
                                        }
 
-                                       powers[num++] = PET_RYOUTE;
+                                       powers[num++] = PET_TWO_HANDS;
                                }
                                break;
                        }
@@ -815,10 +760,10 @@ void do_cmd_pet(player_type *creature_ptr)
        case PET_DISMISS: /* Dismiss pets */
        {
                /* Check pets (backwards) */
-               for (pet_ctr = current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
+               for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
                {
                        /* Player has pet */
-                       if (is_pet(&current_floor_ptr->m_list[pet_ctr])) break;
+                       if (is_pet(&creature_ptr->current_floor_ptr->m_list[pet_ctr])) break;
                }
 
                if (!pet_ctr)
@@ -833,13 +778,13 @@ void do_cmd_pet(player_type *creature_ptr)
        case PET_TARGET:
        {
                project_length = -1;
-               if (!target_set(TARGET_KILL)) creature_ptr->pet_t_m_idx = 0;
+               if (!target_set(creature_ptr, TARGET_KILL)) creature_ptr->pet_t_m_idx = 0;
                else
                {
-                       grid_type *g_ptr = &current_floor_ptr->grid_array[target_row][target_col];
-                       if (g_ptr->m_idx && (current_floor_ptr->m_list[g_ptr->m_idx].ml))
+                       grid_type *g_ptr = &creature_ptr->current_floor_ptr->grid_array[target_row][target_col];
+                       if (g_ptr->m_idx && (creature_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml))
                        {
-                               creature_ptr->pet_t_m_idx = current_floor_ptr->grid_array[target_row][target_col].m_idx;
+                               creature_ptr->pet_t_m_idx = creature_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
                                creature_ptr->pet_follow_distance = PET_DESTROY_DIST;
                        }
                        else creature_ptr->pet_t_m_idx = 0;
@@ -893,13 +838,13 @@ void do_cmd_pet(player_type *creature_ptr)
                if (creature_ptr->pet_extra_flags & PF_PICKUP_ITEMS)
                {
                        creature_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
-                       for (pet_ctr = current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
+                       for (pet_ctr = creature_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--)
                        {
-                               m_ptr = &current_floor_ptr->m_list[pet_ctr];
+                               m_ptr = &creature_ptr->current_floor_ptr->m_list[pet_ctr];
 
                                if (is_pet(m_ptr))
                                {
-                                       monster_drop_carried_objects(m_ptr);
+                                       monster_drop_carried_objects(creature_ptr, m_ptr);
                                }
                        }
                }
@@ -938,22 +883,22 @@ void do_cmd_pet(player_type *creature_ptr)
 
        case PET_RIDING:
        {
-               (void)do_riding(FALSE);
+               (void)do_cmd_riding(creature_ptr, FALSE);
                break;
        }
 
        case PET_NAME:
        {
-               do_name_pet();
+               do_name_pet(creature_ptr);
                break;
        }
 
-       case PET_RYOUTE:
+       case PET_TWO_HANDS:
        {
-               if (creature_ptr->pet_extra_flags & PF_RYOUTE) creature_ptr->pet_extra_flags &= ~(PF_RYOUTE);
-               else creature_ptr->pet_extra_flags |= (PF_RYOUTE);
+               if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+               else creature_ptr->pet_extra_flags |= (PF_TWO_HANDS);
                creature_ptr->update |= (PU_BONUS);
-               handle_stuff();
+               handle_stuff(creature_ptr);
                break;
        }
        }
@@ -966,30 +911,30 @@ void do_cmd_pet(player_type *creature_ptr)
 * @param force TRUEならば強制的に落馬する
 * @return 実際に落馬したらTRUEを返す
 */
-bool rakuba(HIT_POINT dam, bool force)
+bool rakuba(player_type *creature_ptr, HIT_POINT dam, bool force)
 {
        DIRECTION i;
        POSITION y, x, oy, ox, sy = 0, sx = 0;
        int sn = 0;
        GAME_TEXT m_name[MAX_NLEN];
-       monster_type *m_ptr = &current_floor_ptr->m_list[p_ptr->riding];
+       monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
        bool fall_dam = FALSE;
 
-       if (!p_ptr->riding) return FALSE;
-       if (p_ptr->wild_mode) return FALSE;
+       if (!creature_ptr->riding) return FALSE;
+       if (creature_ptr->wild_mode) return FALSE;
 
        if (dam >= 0 || force)
        {
                if (!force)
                {
-                       int cur = p_ptr->skill_exp[GINOU_RIDING];
-                       int max = s_info[p_ptr->pclass].s_max[GINOU_RIDING];
+                       int cur = creature_ptr->skill_exp[GINOU_RIDING];
+                       int max = s_info[creature_ptr->pclass].s_max[GINOU_RIDING];
                        int ridinglevel = r_ptr->level;
 
                        /* 落馬のしやすさ */
                        int rakubalevel = r_ptr->level;
-                       if (p_ptr->riding_ryoute) rakubalevel += 20;
+                       if (creature_ptr->riding_ryoute) rakubalevel += 20;
 
                        if ((cur < max) && (max > 1000) &&
                                (dam / 2 + ridinglevel) > (cur / 30 + 10))
@@ -1001,13 +946,13 @@ bool rakuba(HIT_POINT dam, bool force)
                                else
                                        inc += 1;
 
-                               p_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
+                               creature_ptr->skill_exp[GINOU_RIDING] = MIN(max, cur + inc);
                        }
 
                        /* レベルの低い乗馬からは落馬しにくい */
                        if (randint0(dam / 2 + rakubalevel * 2) < cur / 30 + 10)
                        {
-                               if ((((p_ptr->pclass == CLASS_BEASTMASTER) || (p_ptr->pclass == CLASS_CAVALRY)) && !p_ptr->riding_ryoute) || !one_in_(p_ptr->lev*(p_ptr->riding_ryoute ? 2 : 3) + 30))
+                               if ((((creature_ptr->pclass == CLASS_BEASTMASTER) || (creature_ptr->pclass == CLASS_CAVALRY)) && !creature_ptr->riding_ryoute) || !one_in_(creature_ptr->lev*(creature_ptr->riding_ryoute ? 2 : 3) + 30))
                                {
                                        return FALSE;
                                }
@@ -1019,17 +964,17 @@ bool rakuba(HIT_POINT dam, bool force)
                {
                        grid_type *g_ptr;
 
-                       y = p_ptr->y + ddy_ddd[i];
-                       x = p_ptr->x + ddx_ddd[i];
+                       y = creature_ptr->y + ddy_ddd[i];
+                       x = creature_ptr->x + ddx_ddd[i];
 
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
 
                        if (g_ptr->m_idx) continue;
 
                        /* Skip non-empty grids */
                        if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !cave_have_flag_grid(g_ptr, FF_CAN_FLY))
                        {
-                               if (!player_can_ride_aux(g_ptr, FALSE)) continue;
+                               if (!player_can_ride_aux(creature_ptr, g_ptr, FALSE)) continue;
                        }
 
                        if (cave_have_flag_grid(g_ptr, FF_PATTERN)) continue;
@@ -1045,56 +990,55 @@ bool rakuba(HIT_POINT dam, bool force)
                }
                if (!sn)
                {
-                       monster_desc(m_name, m_ptr, 0);
+                       monster_desc(creature_ptr, m_name, m_ptr, 0);
                        msg_format(_("%sから振り落とされそうになって、壁にぶつかった。", "You have nearly fallen from %s, but bumped into wall."), m_name);
-                       take_hit(p_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
+                       take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("壁への衝突", "bumping into wall"), -1);
                        return FALSE;
                }
 
-               oy = p_ptr->y;
-               ox = p_ptr->x;
+               oy = creature_ptr->y;
+               ox = creature_ptr->x;
 
-               p_ptr->y = sy;
-               p_ptr->x = sx;
+               creature_ptr->y = sy;
+               creature_ptr->x = sx;
 
                /* Redraw the old spot */
-               lite_spot(oy, ox);
+               lite_spot(creature_ptr, oy, ox);
 
                /* Redraw the new spot */
-               lite_spot(p_ptr->y, p_ptr->x);
+               lite_spot(creature_ptr, creature_ptr->y, creature_ptr->x);
 
                /* Check for new panel */
-               verify_panel();
+               verify_panel(creature_ptr);
        }
 
-       p_ptr->riding = 0;
-       p_ptr->pet_extra_flags &= ~(PF_RYOUTE);
-       p_ptr->riding_ryoute = p_ptr->old_riding_ryoute = FALSE;
+       creature_ptr->riding = 0;
+       creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS);
+       creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE;
 
-       p_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
-       handle_stuff();
+       creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS);
+       handle_stuff(creature_ptr);
 
 
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-       p_ptr->redraw |= (PR_EXTRA);
+       creature_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+       creature_ptr->redraw |= (PR_EXTRA);
 
        /* Update health track of mount */
-       p_ptr->redraw |= (PR_UHEALTH);
+       creature_ptr->redraw |= (PR_UHEALTH);
 
-       if (p_ptr->levitation && !force)
+       if (creature_ptr->levitation && !force)
        {
-               monster_desc(m_name, m_ptr, 0);
+               monster_desc(creature_ptr, m_name, m_ptr, 0);
                msg_format(_("%sから落ちたが、空中でうまく体勢を立て直して着地した。", "You are thrown from %s, but make a good landing."), m_name);
        }
        else
        {
-               take_hit(p_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
+               take_hit(creature_ptr, DAMAGE_NOESCAPE, r_ptr->level + 3, _("落馬", "Falling from riding"), -1);
                fall_dam = TRUE;
        }
 
-       if (sy && !p_ptr->is_dead)
-               (void)move_player_effect(p_ptr, p_ptr->y, p_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
+       if (sy && !creature_ptr->is_dead)
+               (void)move_player_effect(creature_ptr, creature_ptr->y, creature_ptr->x, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
 
        return fall_dam;
 }
-