OSDN Git Service

move_player_effect()の処理をbitフラグで制御するように変更. また, プレ
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 6 Dec 2003 00:00:17 +0000 (00:00 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 6 Dec 2003 00:00:17 +0000 (00:00 +0000)
イヤーが移動する, つまりpyやpxが変更される部分にmove_player_effect()
を使い, 地形効果を適用できるように変更. py, pxへの直接代入と描画, 乗
馬を含みプレイヤーが関係するモンスターの位置交換もまとめられる限りこ
の関数でまとめた. 関連して, 以下の変更を含む.
* その場に留まってdo_cmd_stay()が呼ばれたり, テレポートで新しい位置に
  飛んだ際もmove_player_effect()で判定するように変更. ただしその場に
  留まる場合はトラップは無視する.
* 歌 "分解音波" で乗馬がダメージを受けたりアイテムが壊れたりする判定
  をmove_player_effect()に加えた. ターンを消費してその場に留まる際も
  判定を加えるようにした.
* モンスターに移動を任せている場合, 乗馬時/下馬時/落馬時はアイテムを
  拾わないように変更.
* 落馬時のmove_player_effect()がプレイヤー死亡時にしか有効でなかった
  バグを修正.
* carry(), do_cmd_walk(), do_cmd_stay(), py_pickup_floor()の引数
  pickupをbool型に変更.
* move_player()の引数do_pickupをbool型に変更.
* 剣術 "無双三段" でモンスターが動けなくてcontinue;した場合にも
  msg_print(NULL);するように修正.

12 files changed:
src/cmd1.c
src/cmd2.c
src/cmd5.c
src/defines.h
src/externs.h
src/hissatsu.c
src/melee2.c
src/mind.c
src/mutation.c
src/object1.c
src/spells2.c
src/spells3.c

index 2e25993..3615ef2 100644 (file)
@@ -875,7 +875,7 @@ void py_pickup_aux(int o_idx)
  * Note that we ONLY handle things that can be picked up.
  * See "move_player()" for handling of other things.
  */
-void carry(int pickup)
+void carry(bool pickup)
 {
        cave_type *c_ptr = &cave[py][px];
 
@@ -981,7 +981,6 @@ void carry(int pickup)
                        }
                        /* Describe the object */
                        else if (!pickup)
-
                        {
 #ifdef JP
                                msg_format("%s¤¬¤¢¤ë¡£", o_name);
@@ -3439,68 +3438,122 @@ bool player_can_enter(s16b feature, u16b mode)
 }
 
 
-void move_player_effect(int do_pickup, bool break_trap)
+/*
+ * Move the player
+ */
+bool move_player_effect(int oy, int ox, int ny, int nx, u32b mpe_mode)
 {
-       cave_type *c_ptr = &cave[py][px];
+       cave_type *c_ptr = &cave[ny][nx];
        feature_type *f_ptr = &f_info[c_ptr->feat];
 
-       /* Check for new panel (redraw map) */
-       verify_panel();
+       if (!(mpe_mode & MPE_STAYING))
+       {
+               cave_type *oc_ptr = &cave[oy][ox];
+               int om_idx = oc_ptr->m_idx;
+               int nm_idx = c_ptr->m_idx;
 
-       /* Update stuff */
-       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
+               /* Move the player */
+               py = ny;
+               px = nx;
 
-       /* Update the monsters */
-       p_ptr->update |= (PU_DISTANCE);
+               /* Hack -- For moving monster or riding player's moving */
+               if (!(mpe_mode & MPE_DONT_SWAP_MON))
+               {
+                       /* Swap two monsters */
+                       c_ptr->m_idx = om_idx;
+                       oc_ptr->m_idx = nm_idx;
 
-       /* Window stuff */
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+                       if (om_idx > 0) /* Monster on old spot (or p_ptr->riding) */
+                       {
+                               monster_type *om_ptr = &m_list[om_idx];
+                               om_ptr->fy = ny;
+                               om_ptr->fx = nx;
+                               update_mon(om_idx, TRUE);
+                       }
 
-       /* Remove "unsafe" flag */
-       if ((!p_ptr->blind && !no_lite()) || !is_trap(c_ptr->feat)) c_ptr->info &= ~(CAVE_UNSAFE);
+                       if (nm_idx > 0) /* Monster on new spot */
+                       {
+                               monster_type *nm_ptr = &m_list[nm_idx];
+                               nm_ptr->fy = oy;
+                               nm_ptr->fx = ox;
+                               update_mon(nm_idx, TRUE);
+                       }
+               }
 
-       /* For get everything when requested hehe I'm *NASTY* */
-       if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET)) wiz_dark();
+               /* Redraw old spot */
+               lite_spot(oy, ox);
 
-       if (p_ptr->pclass == CLASS_NINJA)
-       {
-               if (c_ptr->info & (CAVE_GLOW)) set_superstealth(FALSE);
-               else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE);
-       }
+               /* Redraw new spot */
+               lite_spot(ny, nx);
 
-       if ((p_ptr->action == ACTION_HAYAGAKE) && !have_flag(f_ptr->flags, FF_PROJECT))
-       {
+               if (mpe_mode & MPE_FORGET_FLOW) forget_flow();
+
+               /* Check for new panel (redraw map) */
+               verify_panel();
+
+               /* Update stuff */
+               p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
+
+               /* Update the monsters */
+               p_ptr->update |= (PU_DISTANCE);
+
+               /* Window stuff */
+               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+
+               /* Remove "unsafe" flag */
+               if ((!p_ptr->blind && !no_lite()) || !is_trap(c_ptr->feat)) c_ptr->info &= ~(CAVE_UNSAFE);
+
+               /* For get everything when requested hehe I'm *NASTY* */
+               if (dun_level && (d_info[dungeon_type].flags1 & DF1_FORGET)) wiz_dark();
+
+               /* Handle stuff */
+               if (mpe_mode & MPE_HANDLE_STUFF) handle_stuff();
+
+               if (p_ptr->pclass == CLASS_NINJA)
+               {
+                       if (c_ptr->info & (CAVE_GLOW)) set_superstealth(FALSE);
+                       else if (p_ptr->cur_lite <= 0) set_superstealth(TRUE);
+               }
+
+               if ((p_ptr->action == ACTION_HAYAGAKE) && !have_flag(f_ptr->flags, FF_PROJECT))
+               {
 #ifdef JP
-               msg_print("¤³¤³¤Ç¤ÏÁÇÁ᤯ư¤±¤Ê¤¤¡£");
+                       msg_print("¤³¤³¤Ç¤ÏÁÇÁ᤯ư¤±¤Ê¤¤¡£");
 #else
-               msg_print("You cannot run in wall.");
+                       msg_print("You cannot run in wall.");
 #endif
-               set_action(ACTION_NONE);
-       }
-
-       /* Spontaneous Searching */
-       if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
-       {
-               search();
+                       set_action(ACTION_NONE);
+               }
        }
 
-       /* Continuous Searching */
-       if (p_ptr->action == ACTION_SEARCH)
+       if (mpe_mode & MPE_ENERGY_USE)
        {
-               search();
-       }
-
-       /* Handle "objects" */
-
-#ifdef ALLOW_EASY_DISARM /* TNB */
+               if (music_singing(MUSIC_WALL))
+               {
+                       (void)project(0, 0, py, px, (60 + p_ptr->lev), GF_DISINTEGRATE,
+                               PROJECT_KILL | PROJECT_ITEM, -1);
 
-       carry(do_pickup != always_pickup);
+                       if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
+               }
 
-#else /* ALLOW_EASY_DISARM -- TNB */
+               /* Spontaneous Searching */
+               if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
+               {
+                       search();
+               }
 
-       carry(do_pickup);
+               /* Continuous Searching */
+               if (p_ptr->action == ACTION_SEARCH)
+               {
+                       search();
+               }
+       }
 
-#endif /* ALLOW_EASY_DISARM -- TNB */
+       /* Handle "objects" */
+       if (!(mpe_mode & MPE_DONT_PICKUP))
+       {
+               carry((mpe_mode & MPE_DO_PICKUP) ? TRUE : FALSE);
+       }
 
        /* Handle "store doors" */
        if (have_flag(f_ptr->flags, FF_STORE))
@@ -3562,7 +3615,7 @@ void move_player_effect(int do_pickup, bool break_trap)
        }
 
        /* Set off a trap */
-       else if (have_flag(f_ptr->flags, FF_HIT_TRAP))
+       else if (have_flag(f_ptr->flags, FF_HIT_TRAP) && !(mpe_mode & MPE_STAYING))
        {
                /* Disturb */
                disturb(0, 0);
@@ -3582,18 +3635,20 @@ void move_player_effect(int do_pickup, bool break_trap)
                }
 
                /* Hit the trap */
-               hit_trap(break_trap);
+               hit_trap((mpe_mode & MPE_BREAK_TRAP) ? TRUE : FALSE);
+
+               if (!player_bold(ny, nx) || p_ptr->is_dead || p_ptr->leaving) return FALSE;
        }
 
        /* Warn when leaving trap detected region */
-       if ((disturb_trap_detect || alert_trap_detect)
-           && p_ptr->dtrap && !(cave[py][px].info & CAVE_IN_DETECT))
+       if (!(mpe_mode & MPE_STAYING) && (disturb_trap_detect || alert_trap_detect)
+           && p_ptr->dtrap && !(c_ptr->info & CAVE_IN_DETECT))
        {
                /* No duplicate warning */
                p_ptr->dtrap = FALSE;
 
                /* You are just on the edge */
-               if (!(cave[py][px].info & CAVE_UNSAFE))
+               if (!(c_ptr->info & CAVE_UNSAFE))
                {
                        if (alert_trap_detect)
                        {
@@ -3607,6 +3662,8 @@ void move_player_effect(int do_pickup, bool break_trap)
                        if (disturb_trap_detect) disturb(0, 0);
                }
        }
+
+       return player_bold(ny, nx) && !p_ptr->is_dead && !p_ptr->leaving;
 }
 
 
@@ -3628,7 +3685,7 @@ void move_player_effect(int do_pickup, bool break_trap)
  * any monster which might be in the destination grid.  Previously,
  * moving into walls was "free" and did NOT hit invisible monsters.
  */
-void move_player(int dir, int do_pickup, bool break_trap)
+void move_player(int dir, bool do_pickup, bool break_trap)
 {
        /* Find the result of moving */
        int y = py + ddy[dir];
@@ -4079,21 +4136,17 @@ void move_player(int dir, int do_pickup, bool break_trap)
        /* Normal movement */
        if (oktomove)
        {
-               int oy, ox;
+               u32b mpe_mode = MPE_ENERGY_USE;
 
                if (p_ptr->warning)
                {
-                       if(!process_warning(x, y))
+                       if (!process_warning(x, y))
                        {
                                energy_use = 25;
                                return;
                        }
                }
 
-               /* Hack -- For moving monster or riding player's moving */
-               cave[py][px].m_idx = c_ptr->m_idx;
-               c_ptr->m_idx = 0;
-
                if (do_past)
                {
 #ifdef JP
@@ -4101,62 +4154,44 @@ void move_player(int dir, int do_pickup, bool break_trap)
 #else
                        msg_format("You push past %s.", m_name);
 #endif
-
-                       m_ptr->fy = py;
-                       m_ptr->fx = px;
-                       update_mon(cave[py][px].m_idx, TRUE);
                }
 
                /* Change oldpx and oldpy to place the player well when going back to big mode */
                if (p_ptr->wild_mode)
                {
-                       if(ddy[dir] > 0)  p_ptr->oldpy = 1;
-                       if(ddy[dir] < 0)  p_ptr->oldpy = MAX_HGT - 2;
-                       if(ddy[dir] == 0) p_ptr->oldpy = MAX_HGT / 2;
-                       if(ddx[dir] > 0)  p_ptr->oldpx = 1;
-                       if(ddx[dir] < 0)  p_ptr->oldpx = MAX_WID - 2;
-                       if(ddx[dir] == 0) p_ptr->oldpx = MAX_WID / 2;
+                       if (ddy[dir] > 0)  p_ptr->oldpy = 1;
+                       if (ddy[dir] < 0)  p_ptr->oldpy = MAX_HGT - 2;
+                       if (ddy[dir] == 0) p_ptr->oldpy = MAX_HGT / 2;
+                       if (ddx[dir] > 0)  p_ptr->oldpx = 1;
+                       if (ddx[dir] < 0)  p_ptr->oldpx = MAX_WID - 2;
+                       if (ddx[dir] == 0) p_ptr->oldpx = MAX_WID / 2;
                }
 
-               /* Save old location */
-               oy = py;
-               ox = px;
-
-               /* Move the player */
-               py = y;
-               px = x;
-
-               if (music_singing(MUSIC_WALL))
+               if (p_can_kill_walls)
                {
-                       project(0, 0, py, px,
-                               (60 + p_ptr->lev), GF_DISINTEGRATE, PROJECT_KILL | PROJECT_ITEM, -1);
-               }
-               else if (p_can_kill_walls)
-               {
-                       cave_alter_feat(py, px, FF_HURT_DISI);
+                       cave_alter_feat(y, x, FF_HURT_DISI);
 
                        /* Update some things -- similar to GF_KILL_WALL */
                        p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MONSTERS | PU_MON_LITE);
                }
 
-               if (p_ptr->riding)
-               {
-                       riding_m_ptr->fy = py;
-                       riding_m_ptr->fx = px;
-                       cave[py][px].m_idx = p_ptr->riding;
-                       update_mon(p_ptr->riding, TRUE);
-               }
+               /* Sound */
+               /* sound(SOUND_WALK); */
 
-               /* Redraw new spot */
-               lite_spot(py, px);
+#ifdef ALLOW_EASY_DISARM /* TNB */
 
-               /* Redraw old spot */
-               lite_spot(oy, ox);
+               if (do_pickup != always_pickup) mpe_mode |= MPE_DO_PICKUP;
 
-               /* Sound */
-               /* sound(SOUND_WALK); */
+#else /* ALLOW_EASY_DISARM -- TNB */
 
-               move_player_effect(do_pickup, break_trap);
+               if (do_pickup) mpe_mode |= MPE_DO_PICKUP;
+
+#endif /* ALLOW_EASY_DISARM -- TNB */
+
+               if (break_trap) mpe_mode |= MPE_BREAK_TRAP;
+
+               /* Move the player */
+               (void)move_player_effect(py, px, y, x, mpe_mode);
        }
 }
 
index daf82fc..a2795a9 100644 (file)
@@ -2685,7 +2685,7 @@ void do_cmd_spike(void)
 /*
  * Support code for the "Walk" and "Jump" commands
  */
-void do_cmd_walk(int pickup)
+void do_cmd_walk(bool pickup)
 {
        int dir;
 
@@ -2802,10 +2802,11 @@ void do_cmd_run(void)
  * Stay still.  Search.  Enter stores.
  * Pick up treasure if "pickup" is true.
  */
-void do_cmd_stay(int pickup)
+void do_cmd_stay(bool pickup)
 {
        cave_type *c_ptr = &cave[py][px];
        feature_type *f_ptr = &f_info[c_ptr->feat];
+       u32b mpe_mode = MPE_STAYING | MPE_ENERGY_USE;
 
        /* Allow repeated command */
        if (command_arg)
@@ -2820,78 +2821,11 @@ void do_cmd_stay(int pickup)
                command_arg = 0;
        }
 
-
        /* Take a turn */
        energy_use = 100;
 
-
-       /* Spontaneous Searching */
-       if ((p_ptr->skill_fos >= 50) || (0 == randint0(50 - p_ptr->skill_fos)))
-       {
-               search();
-       }
-
-       /* Continuous Searching */
-       if (p_ptr->action == ACTION_SEARCH)
-       {
-               search();
-       }
-
-
-       /* Handle "objects" */
-       carry(pickup);
-
-
-       /* Hack -- enter a store if we are on one */
-       if (have_flag(f_ptr->flags, FF_STORE))
-       {
-               /* Disturb */
-               disturb(0, 0);
-
-               energy_use = 0;
-               /* Hack -- enter store */
-               command_new = SPECIAL_KEY_STORE;
-       }
-
-       /* Hack -- enter a building if we are on one -KMW- */
-       else if (have_flag(f_ptr->flags, FF_BLDG))
-       {
-               /* Disturb */
-               disturb(0, 0);
-
-               energy_use = 0;
-               /* Hack -- enter building */
-               command_new = SPECIAL_KEY_BUILDING;
-       }
-
-       /* Exit a quest if reach the quest exit */
-       else if (have_flag(f_ptr->flags, FF_QUEST_EXIT))
-       {
-               int q_index = p_ptr->inside_quest;
-
-               /* Was quest completed? */
-               if (quest[q_index].type == QUEST_TYPE_FIND_EXIT)
-               {
-                       quest[q_index].status = QUEST_STATUS_COMPLETED;
-                       quest[q_index].complev = (byte)p_ptr->lev;
-#ifdef JP
-                       msg_print("¥¯¥¨¥¹¥È¤ò´°Î»¤·¤¿¡ª");
-#else
-                       msg_print("You accomplished your quest!");
-#endif
-
-                       msg_print(NULL);
-               }
-
-               leave_quest_check();
-
-               p_ptr->inside_quest = cave[py][px].special;
-               dun_level = 0;
-               p_ptr->oldpx = 0;
-               p_ptr->oldpy = 0;
-
-               p_ptr->leaving = TRUE;
-       }
+       if (pickup) mpe_mode |= MPE_DO_PICKUP;
+       (void)move_player_effect(py, px, py, px, mpe_mode);
 }
 
 
index 5cba0f4..2f917f6 100644 (file)
@@ -5613,14 +5613,16 @@ msg_format("%s
                fall_dam = TRUE;
        }
 
-       if (sy && p_ptr->is_dead) move_player_effect(FALSE, FALSE);
+       /* Move the player */
+       if (sy && !p_ptr->is_dead)
+               (void)move_player_effect(py, px, py, px, MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
 
        return fall_dam;
 }
 
 bool do_riding(bool force)
 {
-       int oy, ox, x, y, dir = 0;
+       int x, y, dir = 0;
        cave_type *c_ptr;
        monster_type *m_ptr;
 
@@ -5760,48 +5762,21 @@ bool do_riding(bool force)
                if (p_ptr->riding == p_ptr->health_who) health_track(0);
        }
 
-       /* Save the old location */
-       oy = py;
-       ox = px;
-
-       /* Move the player */
-       py = y;
-       px = x;
-
-       /* Redraw the old spot */
-       lite_spot(oy, ox);
-
-       /* Redraw the new spot */
-       lite_spot(py, px);
-
-       /* Check for new panel */
-       verify_panel();
-
        energy_use = 100;
 
        /* Mega-Hack -- Forget the view and lite */
        p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
 
-       /* Update stuff */
-       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_DISTANCE);
-
        /* Update the monsters */
        p_ptr->update |= (PU_BONUS);
 
        /* Redraw map */
        p_ptr->redraw |= (PR_MAP | PR_EXTRA);
 
-       /* Window stuff */
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
        p_ptr->redraw |= (PR_UHEALTH);
 
-       handle_stuff();
-
-       move_player_effect(FALSE, FALSE);
+       /* Move the player */
+       (void)move_player_effect(py, px, y, x, MPE_HANDLE_STUFF | MPE_ENERGY_USE | MPE_DONT_PICKUP | MPE_DONT_SWAP_MON);
 
        return TRUE;
 }
index 5d1251b..eeed379 100644 (file)
@@ -5507,3 +5507,14 @@ extern int PlayerUID;
 #define SKEY_TOP         0xf007
 #define SKEY_BOTTOM      0xf008
 
+/*
+ * Bit flags for move_player_effect()
+ */
+#define MPE_STAYING       0x00000001
+#define MPE_FORGET_FLOW   0x00000002
+#define MPE_HANDLE_STUFF  0x00000004
+#define MPE_ENERGY_USE    0x00000008
+#define MPE_DONT_PICKUP   0x00000010
+#define MPE_DO_PICKUP     0x00000020
+#define MPE_BREAK_TRAP    0x00000040
+#define MPE_DONT_SWAP_MON 0x00000080
index d4879a0..d22462f 100644 (file)
@@ -654,12 +654,12 @@ extern s16b critical_norm(int weight, int plus, int dam, s16b meichuu, int mode)
 extern s16b tot_dam_aux(object_type *o_ptr, int tdam, monster_type *m_ptr, int mode, bool thrown);
 extern void search(void);
 extern void py_pickup_aux(int o_idx);
-extern void carry(int pickup);
+extern void carry(bool pickup);
 extern bool py_attack(int y, int x, int mode);
 extern bool pattern_seq(int c_y, int c_x, int n_y, int n_x);
 extern bool player_can_enter(s16b feature, u16b mode);
-extern void move_player_effect(int do_pickup, bool break_trap);
-extern void move_player(int dir, int do_pickup, bool break_trap);
+extern bool move_player_effect(int oy, int ox, int ny, int nx, u32b mpe_mode);
+extern void move_player(int dir, bool do_pickup, bool break_trap);
 extern void run_step(int dir);
 
 /* cmd2.c */
@@ -673,8 +673,8 @@ extern void do_cmd_disarm(void);
 extern void do_cmd_bash(void);
 extern void do_cmd_alter(void);
 extern void do_cmd_spike(void);
-extern void do_cmd_walk(int pickup);
-extern void do_cmd_stay(int pickup);
+extern void do_cmd_walk(bool pickup);
+extern void do_cmd_stay(bool pickup);
 extern void do_cmd_run(void);
 extern void do_cmd_rest(void);
 extern void do_cmd_fire(void);
@@ -1548,7 +1548,7 @@ extern bool do_cmd_disarm_aux(int y, int x, int dir);
 extern int scan_floor(int *items, int y, int x, int mode);
 extern int show_floor(int target_item, int y, int x, int *min_width);
 extern bool get_item_floor(int *cp, cptr pmt, cptr str, int mode);
-extern void py_pickup_floor(int pickup);
+extern void py_pickup_floor(bool pickup);
 
 /* variable.c */
 extern bool easy_floor;
index c7f0ca9..87ec9c9 100644 (file)
@@ -501,40 +501,10 @@ static bool cast_hissatsu_spell(int spell)
 
                if (player_can_enter(cave[y][x].feat, 0) && !is_trap(cave[y][x].feat) && !cave[y][x].m_idx)
                {
-                       int oy, ox;
-
                        msg_print(NULL);
 
-                       /* Save the old location */
-                       oy = py;
-                       ox = px;
-
                        /* Move the player */
-                       py = y;
-                       px = x;
-
-                       forget_flow();
-
-                       /* Redraw the old spot */
-                       lite_spot(oy, ox);
-
-                       /* Redraw the new spot */
-                       lite_spot(py, px);
-
-                       /* Check for new panel (redraw map) */
-                       verify_panel();
-
-                       /* Update stuff */
-                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-                       /* Update the monsters */
-                       p_ptr->update |= (PU_DISTANCE);
-
-                       /* Window stuff */
-                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-                       /* Handle stuff XXX XXX XXX */
-                       handle_stuff();
+                       (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
                }
                break;
        }
@@ -881,15 +851,16 @@ static bool cast_hissatsu_spell(int spell)
                if (dir == 5) return FALSE;
                for (i = 0; i < 3; i++)
                {
-                       int oy, ox;
                        int ny, nx;
                        int m_idx;
+                       cave_type *c_ptr;
                        monster_type *m_ptr;
 
                        y = py + ddy[dir];
                        x = px + ddx[dir];
+                       c_ptr = &cave[y][x];
 
-                       if (cave[y][x].m_idx)
+                       if (c_ptr->m_idx)
                                py_attack(y, x, HISSATSU_3DAN);
                        else
                        {
@@ -907,72 +878,40 @@ static bool cast_hissatsu_spell(int spell)
                        }
 
                        /* Monster is dead? */
-                       if (!cave[y][x].m_idx) break;
+                       if (!c_ptr->m_idx) break;
 
                        ny = y + ddy[dir];
                        nx = x + ddx[dir];
-                       m_idx = cave[y][x].m_idx;
+                       m_idx = c_ptr->m_idx;
                        m_ptr = &m_list[m_idx];
 
                        /* Monster cannot move back? */
-                       if (!monster_can_enter(ny, nx, &r_info[m_ptr->r_idx], 0)) continue;
+                       if (!monster_can_enter(ny, nx, &r_info[m_ptr->r_idx], 0))
+                       {
+                               /* -more- */
+                               if (i < 2) msg_print(NULL);
+                               continue;
+                       }
 
-                       cave[y][x].m_idx = 0;
+                       c_ptr->m_idx = 0;
                        cave[ny][nx].m_idx = m_idx;
                        m_ptr->fy = ny;
                        m_ptr->fx = nx;
 
                        update_mon(m_idx, TRUE);
 
-                       /* Player can move forward? */
-                       if (player_can_enter(cave[y][x].feat, 0))
-                       {
-                               /* Save the old location */
-                               oy = py;
-                               ox = px;
-
-                               /* Move the player */
-                               py = y;
-                               px = x;
-
-                               if (p_ptr->riding)
-                               {
-                                       cave[oy][ox].m_idx = cave[py][px].m_idx;
-                                       cave[py][px].m_idx = p_ptr->riding;
-                                       m_list[p_ptr->riding].fy = py;
-                                       m_list[p_ptr->riding].fx = px;
-                                       update_mon(p_ptr->riding, TRUE);
-                               }
-
-                               forget_flow();
-
-                               /* Redraw the old spot */
-                               lite_spot(oy, ox);
-
-                               /* Redraw the new spot */
-                               lite_spot(py, px);
-                       }
-
                        /* Redraw the old spot */
                        lite_spot(y, x);
 
                        /* Redraw the new spot */
                        lite_spot(ny, nx);
 
-                       /* Check for new panel (redraw map) */
-                       verify_panel();
-
-                       /* Update stuff */
-                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-                       /* Update the monsters */
-                       p_ptr->update |= (PU_DISTANCE);
-
-                       /* Window stuff */
-                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-                       /* Handle stuff */
-                       handle_stuff();
+                       /* Player can move forward? */
+                       if (player_can_enter(c_ptr->feat, 0))
+                       {
+                               /* Move the player */
+                               if (!move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP)) break;
+                       }
 
                        /* -more- */
                        if (i < 2) msg_print(NULL);
index 9667c46..a7eac17 100644 (file)
@@ -3198,7 +3198,7 @@ msg_format("%^s%s", m_name, monmessage);
                        }
 
                        /* Push past weaker monsters (unless leaving a wall) */
-                       else if ((r_ptr->flags2 & RF2_MOVE_BODY) &&
+                       else if ((r_ptr->flags2 & RF2_MOVE_BODY) && !(r_ptr->flags1 & RF1_NEVER_MOVE) &&
                                (r_ptr->mexp > z_ptr->mexp) &&
                                can_cross && (c_ptr->m_idx != p_ptr->riding) &&
                                monster_can_cross_terrain(cave[m_ptr->fy][m_ptr->fx].feat, z_ptr, 0))
@@ -3209,6 +3209,12 @@ msg_format("%^s%s", m_name, monmessage);
                                /* Monster pushed past another monster */
                                did_move_body = TRUE;
 
+                               /* Wake up the moved monster */
+                               y_ptr->csleep = 0;
+
+                               if (r_info[y_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
+                                       p_ptr->update |= (PU_MON_LITE);
+
                                /* XXX XXX XXX Message */
                        }
                }
@@ -3248,9 +3254,6 @@ msg_format("%^s%s", m_name, monmessage);
                        /* Take a turn */
                        do_turn = TRUE;
 
-                       /* Hack -- Update the old location */
-                       cave[oy][ox].m_idx = c_ptr->m_idx;
-
                        if (did_kill_wall)
                        {
                                if (one_in_(GRINDNOISE))
@@ -3275,53 +3278,45 @@ msg_format("%^s%s", m_name, monmessage);
                                }
                        }
 
-                       /* Mega-Hack -- move the old monster, if any */
-                       if (c_ptr->m_idx)
+                       if (!is_riding_mon)
                        {
-                               /* Move the old monster */
-                               y_ptr->fy = oy;
-                               y_ptr->fx = ox;
+                               /* Hack -- Update the old location */
+                               cave[oy][ox].m_idx = c_ptr->m_idx;
 
-                               /* Update the old monster */
-                               update_mon(c_ptr->m_idx, TRUE);
+                               /* Mega-Hack -- move the old monster, if any */
+                               if (c_ptr->m_idx)
+                               {
+                                       /* Move the old monster */
+                                       y_ptr->fy = oy;
+                                       y_ptr->fx = ox;
 
-                               /* Wake up the moved monster */
-                               y_ptr->csleep = 0;
+                                       /* Update the old monster */
+                                       update_mon(c_ptr->m_idx, TRUE);
+                               }
 
-                               if (r_info[y_ptr->r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK))
-                                       p_ptr->update |= (PU_MON_LITE);
-                       }
+                               /* Hack -- Update the new location */
+                               c_ptr->m_idx = m_idx;
 
-                       /* Hack -- Update the new location */
-                       c_ptr->m_idx = m_idx;
+                               /* Move the monster */
+                               m_ptr->fy = ny;
+                               m_ptr->fx = nx;
 
-                       /* Move the monster */
-                       m_ptr->fy = ny;
-                       m_ptr->fx = nx;
+                               /* Update the monster */
+                               update_mon(m_idx, TRUE);
 
-                       /* Update the monster */
-                       update_mon(m_idx, TRUE);
+                               /* Redraw the old grid */
+                               lite_spot(oy, ox);
 
-                       if (is_riding_mon)
-                       {
-                               py = ny;
-                               px = nx;
+                               /* Redraw the new grid */
+                               lite_spot(ny, nx);
                        }
-
-                       /* Redraw the old grid */
-                       lite_spot(oy, ox);
-
-                       /* Redraw the new grid */
-                       lite_spot(ny, nx);
-
-                       if (is_riding_mon)
+                       else
                        {
                                /* Sound */
                                /* sound(SOUND_WALK); */
 
-                               move_player_effect(FALSE, FALSE);
-
-                               if (!player_bold(ny, nx) || p_ptr->leaving) break;
+                               /* Move the player */
+                               if (!move_player_effect(py, px, ny, nx, MPE_DONT_PICKUP)) break;
                        }
 
                        /* Possible disturb */
index 5ae6f4f..b827380 100644 (file)
@@ -1498,40 +1498,10 @@ static bool cast_berserk_spell(int spell)
 
                if (player_can_enter(cave[y][x].feat, 0) && !is_trap(cave[y][x].feat) && !cave[y][x].m_idx)
                {
-                       int oy, ox;
-
                        msg_print(NULL);
 
-                       /* Save the old location */
-                       oy = py;
-                       ox = px;
-
                        /* Move the player */
-                       py = y;
-                       px = x;
-
-                       forget_flow();
-
-                       /* Redraw the old spot */
-                       lite_spot(oy, ox);
-
-                       /* Redraw the new spot */
-                       lite_spot(py, px);
-
-                       /* Check for new panel (redraw map) */
-                       verify_panel();
-
-                       /* Update stuff */
-                       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-                       /* Update the monsters */
-                       p_ptr->update |= (PU_DISTANCE);
-
-                       /* Window stuff */
-                       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-                       /* Handle stuff XXX XXX XXX */
-                       handle_stuff();
+                       (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
                }
                break;
        }
index 4773cc3..ded0499 100644 (file)
@@ -3457,7 +3457,7 @@ bool mutation_power_aux(u32b power)
 
                case MUT1_EAT_ROCK:
                        {
-                               int x, y, ox, oy;
+                               int x, y;
                                cave_type *c_ptr;
                                feature_type *f_ptr;
 
@@ -3527,29 +3527,8 @@ bool mutation_power_aux(u32b power)
                                /* Destroy the wall */
                                cave_alter_feat(y, x, FF_HURT_ROCK);
 
-                               oy = py;
-                               ox = px;
-
-                               py = y;
-                               px = x;
-
-                               if (p_ptr->riding)
-                               {
-                                       m_list[p_ptr->riding].fy = py;
-                                       m_list[p_ptr->riding].fx = px;
-                                       cave[py][px].m_idx = p_ptr->riding;
-                                       cave[oy][ox].m_idx = 0;
-                                       update_mon(p_ptr->riding, TRUE);
-                               }
-
-                               lite_spot(py, px);
-                               lite_spot(oy, ox);
-
-                               verify_panel();
-
-                               p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-                               p_ptr->update |= (PU_DISTANCE);
-                               p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+                               /* Move the player */
+                               (void)move_player_effect(py, px, y, x, MPE_DONT_PICKUP);
                        }
                        break;
 
index ced944f..dd7b325 100644 (file)
@@ -7783,7 +7783,7 @@ static bool py_pickup_floor_aux(void)
  *
  * This is called by py_pickup() when easy_floor is TRUE.
  */
-void py_pickup_floor(int pickup)
+void py_pickup_floor(bool pickup)
 {
        s16b this_o_idx, next_o_idx = 0;
 
index 6b668a4..9aed65e 100644 (file)
@@ -5477,7 +5477,7 @@ bool destroy_area(int y1, int x1, int r, bool in_generate)
  */
 bool earthquake(int cy, int cx, int r)
 {
-       int             i, t, y, x, yy, xx, dy, dx, oy, ox;
+       int             i, t, y, x, yy, xx, dy, dx;
        int             damage = 0;
        int             sn = 0, sy = 0, sx = 0;
        bool            hurt = FALSE;
@@ -5660,31 +5660,8 @@ msg_print("
                                }
                        }
 
-                       /* Save the old location */
-                       oy = py;
-                       ox = px;
-
                        /* Move the player to the safe location */
-                       py = sy;
-                       px = sx;
-
-                       if (p_ptr->riding)
-                       {
-                               cave[oy][ox].m_idx = cave[py][px].m_idx;
-                               cave[py][px].m_idx = p_ptr->riding;
-                               m_list[p_ptr->riding].fy = py;
-                               m_list[p_ptr->riding].fx = px;
-                               update_mon(p_ptr->riding, TRUE);
-                       }
-
-                       /* Redraw the old spot */
-                       lite_spot(oy, ox);
-
-                       /* Redraw the new spot */
-                       lite_spot(py, px);
-
-                       /* Check for new panel */
-                       verify_panel();
+                       (void)move_player_effect(py, px, sy, sx, MPE_DONT_PICKUP);
                }
 
                /* Important -- no wall on player */
@@ -6660,6 +6637,9 @@ msg_print("
        m_ptr = &m_list[c_ptr->m_idx];
        r_ptr = &r_info[m_ptr->r_idx];
 
+       /* Redraw the health bar */
+       if (p_ptr->health_who == c_ptr->m_idx) p_ptr->redraw |= (PR_HEALTH);
+
        if (r_ptr->flagsr & RFR_RES_TELE)
        {
 #ifdef JP
@@ -6679,60 +6659,8 @@ msg_print("
 
        sound(SOUND_TELEPORT);
 
-       cave[py][px].m_idx = c_ptr->m_idx;
-
-       /* Update the old location */
-       c_ptr->m_idx = p_ptr->riding;
-
-       /* Move the monster */
-       m_ptr->fy = py;
-       m_ptr->fx = px;
-
-       /* Move the player */
-       px = tx;
-       py = ty;
-
-       if (p_ptr->riding)
-       {
-               m_list[p_ptr->riding].fy = ty;
-               m_list[p_ptr->riding].fx = tx;
-
-               /* Update the monster (new location) */
-               update_mon(p_ptr->riding, TRUE);
-       }
-
-       tx = m_ptr->fx;
-       ty = m_ptr->fy;
-
-       m_ptr->csleep = 0;
-
-       /* Update the monster (new location) */
-       update_mon(cave[ty][tx].m_idx, TRUE);
-
-       /* Redraw the old grid */
-       lite_spot(ty, tx);
-
-       /* Redraw the new grid */
-       lite_spot(py, px);
-
-       /* Check for new panel (redraw map) */
-       verify_panel();
-
-       /* Update stuff */
-       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_DISTANCE);
-
-       /* Window stuff */
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-       /* Redraw the health bar */
-       if (p_ptr->health_who == cave[ty][tx].m_idx)
-               p_ptr->redraw |= (PR_HEALTH);
-
-       /* Handle stuff XXX XXX XXX */
-       handle_stuff();
+       /* Swap the player and monster */
+       (void)move_player_effect(py, px, ty, tx, MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 
        /* Success */
        return TRUE;
index 26d5db2..5d1431f 100644 (file)
@@ -383,20 +383,7 @@ msg_print("
        ox = px;
 
        /* Move the player */
-       py = y;
-       px = x;
-
-       if (p_ptr->riding)
-       {
-               cave[oy][ox].m_idx = cave[py][px].m_idx;
-               cave[py][px].m_idx = p_ptr->riding;
-               m_list[p_ptr->riding].fy = py;
-               m_list[p_ptr->riding].fx = px;
-               update_mon(p_ptr->riding, TRUE);
-       }
-
-       /* Redraw the old spot */
-       lite_spot(oy, ox);
+       (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 
        /* Monsters with teleport ability may follow the player */
        for (xx = -1; xx < 2; xx++)
@@ -418,31 +405,11 @@ msg_print("
                                if ((r_ptr->flags6 & RF6_TPORT) &&
                                    !(r_ptr->flagsr & RFR_RES_TELE))
                                {
-                                       if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, py, px, r_ptr->level);
+                                       if (!m_ptr->csleep) teleport_monster_to(tmp_m_idx, y, x, r_ptr->level);
                                }
                        }
                }
        }
-
-       forget_flow();
-
-       /* Redraw the new spot */
-       lite_spot(py, px);
-
-       /* Check for new panel (redraw map) */
-       verify_panel();
-
-       /* Update stuff */
-       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_DISTANCE);
-
-       /* Window stuff */
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-       /* Handle stuff XXX XXX XXX */
-       handle_stuff();
 }
 
 
@@ -455,7 +422,7 @@ msg_print("
  */
 void teleport_player_to(int ny, int nx, bool no_tele)
 {
-       int y, x, oy, ox, dis = 0, ctr = 0;
+       int y, x, dis = 0, ctr = 0;
 
        if (p_ptr->anti_tele && no_tele)
        {
@@ -496,45 +463,8 @@ void teleport_player_to(int ny, int nx, bool no_tele)
        /* Sound */
        sound(SOUND_TELEPORT);
 
-       /* Save the old location */
-       oy = py;
-       ox = px;
-
        /* Move the player */
-       py = y;
-       px = x;
-
-       if (p_ptr->riding)
-       {
-               cave[oy][ox].m_idx = cave[py][px].m_idx;
-               cave[py][px].m_idx = p_ptr->riding;
-               m_list[p_ptr->riding].fy = py;
-               m_list[p_ptr->riding].fx = px;
-               update_mon(p_ptr->riding, TRUE);
-       }
-
-       forget_flow();
-
-       /* Redraw the old spot */
-       lite_spot(oy, ox);
-
-       /* Redraw the new spot */
-       lite_spot(py, px);
-
-       /* Check for new panel (redraw map) */
-       verify_panel();
-
-       /* Update stuff */
-       p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
-
-       /* Update the monsters */
-       p_ptr->update |= (PU_DISTANCE);
-
-       /* Window stuff */
-       p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
-
-       /* Handle stuff XXX XXX XXX */
-       handle_stuff();
+       (void)move_player_effect(py, px, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
 }