From 444b0cda16d25a0834392edeacd4087cc9529a19 Mon Sep 17 00:00:00 2001 From: nothere Date: Sat, 6 Dec 2003 00:00:17 +0000 Subject: [PATCH] =?utf8?q?move=5Fplayer=5Feffect()=E3=81=AE=E5=87=A6?= =?utf8?q?=E7=90=86=E3=82=92bit=E3=83=95=E3=83=A9=E3=82=B0=E3=81=A7?= =?utf8?q?=E5=88=B6=E5=BE=A1=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= =?utf8?q?=E5=A4=89=E6=9B=B4.=20=E3=81=BE=E3=81=9F,=20=E3=83=97=E3=83=AC?= =?utf8?q?=20=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=8C=E7=A7=BB=E5=8B=95?= =?utf8?q?=E3=81=99=E3=82=8B,=20=E3=81=A4=E3=81=BE=E3=82=8Apy=E3=82=84px?= =?utf8?q?=E3=81=8C=E5=A4=89=E6=9B=B4=E3=81=95=E3=82=8C=E3=82=8B=E9=83=A8?= =?utf8?q?=E5=88=86=E3=81=ABmove=5Fplayer=5Feffect()=20=E3=82=92=E4=BD=BF?= =?utf8?q?=E3=81=84,=20=E5=9C=B0=E5=BD=A2=E5=8A=B9=E6=9E=9C=E3=82=92?= =?utf8?q?=E9=81=A9=E7=94=A8=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?utf8?q?=E3=81=AB=E5=A4=89=E6=9B=B4.=20py,=20px=E3=81=B8=E3=81=AE?= =?utf8?q?=E7=9B=B4=E6=8E=A5=E4=BB=A3=E5=85=A5=E3=81=A8=E6=8F=8F=E7=94=BB,?= =?utf8?q?=20=E4=B9=97=20=E9=A6=AC=E3=82=92=E5=90=AB=E3=81=BF=E3=83=97?= =?utf8?q?=E3=83=AC=E3=82=A4=E3=83=A4=E3=83=BC=E3=81=8C=E9=96=A2=E4=BF=82?= =?utf8?q?=E3=81=99=E3=82=8B=E3=83=A2=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=BC?= =?utf8?q?=E3=81=AE=E4=BD=8D=E7=BD=AE=E4=BA=A4=E6=8F=9B=E3=82=82=E3=81=BE?= =?utf8?q?=E3=81=A8=E3=82=81=E3=82=89=E3=82=8C=E3=82=8B=E9=99=90=E3=82=8A?= =?utf8?q?=E3=81=93=20=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=A7=E3=81=BE?= =?utf8?q?=E3=81=A8=E3=82=81=E3=81=9F.=20=E9=96=A2=E9=80=A3=E3=81=97?= =?utf8?q?=E3=81=A6,=20=E4=BB=A5=E4=B8=8B=E3=81=AE=E5=A4=89=E6=9B=B4?= =?utf8?q?=E3=82=92=E5=90=AB=E3=82=80.=20*=20=E3=81=9D=E3=81=AE=E5=A0=B4?= =?utf8?q?=E3=81=AB=E7=95=99=E3=81=BE=E3=81=A3=E3=81=A6do=5Fcmd=5Fstay()?= =?utf8?q?=E3=81=8C=E5=91=BC=E3=81=B0=E3=82=8C=E3=81=9F=E3=82=8A,=20?= =?utf8?q?=E3=83=86=E3=83=AC=E3=83=9D=E3=83=BC=E3=83=88=E3=81=A7=E6=96=B0?= =?utf8?q?=E3=81=97=E3=81=84=E4=BD=8D=E7=BD=AE=E3=81=AB=20=20=20=E9=A3=9B?= =?utf8?q?=E3=82=93=E3=81=A0=E9=9A=9B=E3=82=82move=5Fplayer=5Feffect()?= =?utf8?q?=E3=81=A7=E5=88=A4=E5=AE=9A=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?utf8?q?=E3=81=AB=E5=A4=89=E6=9B=B4.=20=E3=81=9F=E3=81=A0=E3=81=97?= =?utf8?q?=E3=81=9D=E3=81=AE=E5=A0=B4=E3=81=AB=20=20=20=E7=95=99=E3=81=BE?= =?utf8?q?=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=AF=E3=83=88=E3=83=A9=E3=83=83?= =?utf8?q?=E3=83=97=E3=81=AF=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B.=20*=20?= =?utf8?q?=E6=AD=8C=20"=E5=88=86=E8=A7=A3=E9=9F=B3=E6=B3=A2"=20=E3=81=A7?= =?utf8?q?=E4=B9=97=E9=A6=AC=E3=81=8C=E3=83=80=E3=83=A1=E3=83=BC=E3=82=B8?= =?utf8?q?=E3=82=92=E5=8F=97=E3=81=91=E3=81=9F=E3=82=8A=E3=82=A2=E3=82=A4?= =?utf8?q?=E3=83=86=E3=83=A0=E3=81=8C=E5=A3=8A=E3=82=8C=E3=81=9F=E3=82=8A?= =?utf8?q?=E3=81=99=E3=82=8B=E5=88=A4=E5=AE=9A=20=20=20=E3=82=92move=5Fpla?= =?utf8?q?yer=5Feffect()=E3=81=AB=E5=8A=A0=E3=81=88=E3=81=9F.=20=E3=82=BF?= =?utf8?q?=E3=83=BC=E3=83=B3=E3=82=92=E6=B6=88=E8=B2=BB=E3=81=97=E3=81=A6?= =?utf8?q?=E3=81=9D=E3=81=AE=E5=A0=B4=E3=81=AB=E7=95=99=E3=81=BE=E3=82=8B?= =?utf8?q?=E9=9A=9B=E3=82=82=20=20=20=E5=88=A4=E5=AE=9A=E3=82=92=E5=8A=A0?= =?utf8?q?=E3=81=88=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F.?= =?utf8?q?=20*=20=E3=83=A2=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=BC=E3=81=AB?= =?utf8?q?=E7=A7=BB=E5=8B=95=E3=82=92=E4=BB=BB=E3=81=9B=E3=81=A6=E3=81=84?= =?utf8?q?=E3=82=8B=E5=A0=B4=E5=90=88,=20=E4=B9=97=E9=A6=AC=E6=99=82/?= =?utf8?q?=E4=B8=8B=E9=A6=AC=E6=99=82/=E8=90=BD=E9=A6=AC=E6=99=82=E3=81=AF?= =?utf8?q?=E3=82=A2=E3=82=A4=E3=83=86=E3=83=A0=E3=82=92=20=20=20=E6=8B=BE?= =?utf8?q?=E3=82=8F=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB=E5=A4=89?= =?utf8?q?=E6=9B=B4.=20*=20=E8=90=BD=E9=A6=AC=E6=99=82=E3=81=AEmove=5Fplay?= =?utf8?q?er=5Feffect()=E3=81=8C=E3=83=97=E3=83=AC=E3=82=A4=E3=83=A4?= =?utf8?q?=E3=83=BC=E6=AD=BB=E4=BA=A1=E6=99=82=E3=81=AB=E3=81=97=E3=81=8B?= =?utf8?q?=E6=9C=89=E5=8A=B9=E3=81=A7=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?utf8?q?=20=20=20=E3=83=90=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3.=20*=20ca?= =?utf8?q?rry(),=20do=5Fcmd=5Fwalk(),=20do=5Fcmd=5Fstay(),=20py=5Fpickup?= =?utf8?q?=5Ffloor()=E3=81=AE=E5=BC=95=E6=95=B0=20=20=20pickup=E3=82=92boo?= =?utf8?q?l=E5=9E=8B=E3=81=AB=E5=A4=89=E6=9B=B4.=20*=20move=5Fplayer()?= =?utf8?q?=E3=81=AE=E5=BC=95=E6=95=B0do=5Fpickup=E3=82=92bool=E5=9E=8B?= =?utf8?q?=E3=81=AB=E5=A4=89=E6=9B=B4.=20*=20=E5=89=A3=E8=A1=93=20"?= =?utf8?q?=E7=84=A1=E5=8F=8C=E4=B8=89=E6=AE=B5"=20=E3=81=A7=E3=83=A2?= =?utf8?q?=E3=83=B3=E3=82=B9=E3=82=BF=E3=83=BC=E3=81=8C=E5=8B=95=E3=81=91?= =?utf8?q?=E3=81=AA=E3=81=8F=E3=81=A6continue;=E3=81=97=E3=81=9F=E5=A0=B4?= =?utf8?q?=E5=90=88=E3=81=AB=E3=82=82=20=20=20msg=5Fprint(NULL);=E3=81=99?= =?utf8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E4=BF=AE=E6=AD=A3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd1.c | 225 +++++++++++++++++++++++++++++++++------------------------ src/cmd2.c | 76 ++----------------- src/cmd5.c | 37 ++-------- src/defines.h | 11 +++ src/externs.h | 12 +-- src/hissatsu.c | 99 +++++-------------------- src/melee2.c | 71 +++++++++--------- src/mind.c | 32 +------- src/mutation.c | 27 +------ src/object1.c | 2 +- src/spells2.c | 86 ++-------------------- src/spells3.c | 78 +------------------- 12 files changed, 226 insertions(+), 530 deletions(-) diff --git a/src/cmd1.c b/src/cmd1.c index 2e259938a..3615ef288 100644 --- a/src/cmd1.c +++ b/src/cmd1.c @@ -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); } } diff --git a/src/cmd2.c b/src/cmd2.c index daf82fcf4..a2795a94b 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -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); } diff --git a/src/cmd5.c b/src/cmd5.c index 5cba0f4d0..2f917f640 100644 --- a/src/cmd5.c +++ b/src/cmd5.c @@ -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; } diff --git a/src/defines.h b/src/defines.h index 5d1251b9c..eeed379a1 100644 --- a/src/defines.h +++ b/src/defines.h @@ -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 diff --git a/src/externs.h b/src/externs.h index d4879a07c..d22462f7f 100644 --- a/src/externs.h +++ b/src/externs.h @@ -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; diff --git a/src/hissatsu.c b/src/hissatsu.c index c7f0ca9d2..87ec9c9f4 100644 --- a/src/hissatsu.c +++ b/src/hissatsu.c @@ -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); diff --git a/src/melee2.c b/src/melee2.c index 9667c46c4..a7eac17dd 100644 --- a/src/melee2.c +++ b/src/melee2.c @@ -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 */ diff --git a/src/mind.c b/src/mind.c index 5ae6f4f67..b8273809e 100644 --- a/src/mind.c +++ b/src/mind.c @@ -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; } diff --git a/src/mutation.c b/src/mutation.c index 4773cc3bd..ded04998a 100644 --- a/src/mutation.c +++ b/src/mutation.c @@ -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; diff --git a/src/object1.c b/src/object1.c index ced944f58..dd7b325c5 100644 --- a/src/object1.c +++ b/src/object1.c @@ -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; diff --git a/src/spells2.c b/src/spells2.c index 6b668a4f6..9aed65e2f 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -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; diff --git a/src/spells3.c b/src/spells3.c index 26d5db21a..5d1431f7a 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -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); } -- 2.11.0