#============================================================================== # ■ シンボルエンカウント作成補助 接触イベント判定強化Ver1.04 by 星潟 #------------------------------------------------------------------------------ # プレイヤーから接触した場合が起動判定となっているイベントの上に # プレイヤーキャラクターが移動しようとした際に # シンボルエンカウントイベントと接触すると # プレイヤーから接触した場合の起動判定が行われない場合がある問題を解決します。 #============================================================================== # Ver1.01 特定条件下で接触イベントを発生させずに # スルーできる問題を新たに解決しました。 # Ver1.02 接触イベントの上で別のイベントを起動した場合 # 続けて接触イベントが起動してしまう不具合を修正しました。 # 移動ルートの強制の終端で触れた接触イベントが # 起動してしまう不具合を修正しました。 # Ver1.03 通常歩行によるエンカウントが発生しなくなっていた不具合を修正しました。 # Ver1.04 F12エラーを修正。 #============================================================================== class Game_Player < Game_Character attr_accessor :old_x attr_accessor :old_y attr_accessor :interpreter_ran attr_accessor :touch_flag #RGSS2 unless defined? Graphics.play_movie #-------------------------------------------------------------------------- # 動いていない場合の処理 #-------------------------------------------------------------------------- alias update_nonmoving_symbol_extra update_nonmoving def update_nonmoving(last_moving) #本来の処理を実行。 update_nonmoving_symbol_extra(last_moving) #古い座標と今の座標が一致しない場合は処理を行わない。 return if @old_x == @x && @old_y == @y #移動していない場合のみ処理を行う。 unless moving? #イベント実行中であり、直前にイベントが実行されていなかった場合は #イベントが実行されていたフラグを立てる。 if $game_map.interpreter.running? && !@interpreter_ran @interpreter_ran = true #イベント実行中でなく、イベントが実行されていたフラグが立っている場合は #接触イベントをチェックし、イベントが実行されていたフラグを折る。 elsif !$game_map.interpreter.running? && @interpreter_ran check_touch_event @interpreter_ran = false end end end #-------------------------------------------------------------------------- # 指定位置への移動 #-------------------------------------------------------------------------- alias moveto_symbol_extra moveto def moveto(x,y) #本来の処理を実行。 moveto_symbol_extra(x,y) #座標情報更新と接触フラグを立てる。 xy_t_f end #-------------------------------------------------------------------------- # 接触(重なり)によるイベント起動判定 #-------------------------------------------------------------------------- alias check_touch_event_symbol_extra check_touch_event def check_touch_event #本来の処理を実行し結果を取得。 flag = check_touch_event_symbol_extra != false #座標情報更新と接触フラグを立てる。 xy_t_f #フラグを返す。 flag end #-------------------------------------------------------------------------- # 方向ボタン入力による移動処理 #-------------------------------------------------------------------------- alias move_by_input_symbol_extra move_by_input def move_by_input #接触イベントチェックフラグが立っておらず #直前の座標と現在の座標が一致せず、移動していない場合。 if !@touch_flag && (@old_x != @x or @old_y != @y) && !moving? #イベント実行中であり、直前にイベントが実行されていなかった場合は #イベントが実行されていたフラグを立てる。 if $game_map.interpreter.running? && !@interpreter_ran @interpreter_ran = true #イベント実行中でなく、イベントが実行されていたフラグが立っている場合は #接触イベントをチェックし、イベントが実行されていたフラグを折る。 elsif !$game_map.interpreter.running? && @interpreter_ran check_touch_event @interpreter_ran = false end end #本来の処理を実行。 move_by_input_symbol_extra #移動に成功していた場合は接触イベントチェックフラグを折る。 @touch_flag = false if @move_succeed end #-------------------------------------------------------------------------- # 移動タイプ : カスタム #-------------------------------------------------------------------------- alias move_type_custom_symbol_extra move_type_custom unless $! def move_type_custom #本来の処理を実行。 move_type_custom_symbol_extra #座標情報更新と接触フラグを折る。 xy_t_f(false) end #-------------------------------------------------------------------------- # 座標情報更新と接触フラグを変更 #-------------------------------------------------------------------------- def xy_t_f(flag = true) @old_x = @x @old_y = @y @touch_flag = flag end #RGSS3 else #-------------------------------------------------------------------------- # 動いていない場合の処理 #-------------------------------------------------------------------------- alias update_nonmoving_symbol_extra update_nonmoving def update_nonmoving(last_moving) #本来の処理を実行。 update_nonmoving_symbol_extra(last_moving) #古い座標と今の座標が一致しない場合は処理を行わない。 return if @old_x == @x && @old_y == @y #接触イベント起動済フラグがONの時は処理を行わない。 return if @touch_flag #移動していない場合のみ処理を行う。 unless moving? #イベント実行中であり、直前にイベントが実行されていなかった場合は #イベントが実行されていたフラグを立てる。 if $game_map.interpreter.running? && !@interpreter_ran @interpreter_ran = true #イベント実行中でなく、イベントが実行されていたフラグが立っている場合は #接触イベントをチェックし、イベントが実行されていたフラグを折る。 elsif !$game_map.interpreter.running? && @interpreter_ran check_touch_event @interpreter_ran = false end end end #-------------------------------------------------------------------------- # 指定座標への移動 #-------------------------------------------------------------------------- alias moveto_symbol_extra moveto def moveto(x,y) #本来の処理を実行。 moveto_symbol_extra(x,y) #座標情報を更新しと接触イベントチェックフラグを立てる。 xy_t_f end #-------------------------------------------------------------------------- # 接触(重なり)によるイベント起動判定 #-------------------------------------------------------------------------- alias check_touch_event_symbol_extra check_touch_event def check_touch_event #本来の処理を実行し結果を取得。 flag = check_touch_event_symbol_extra != false #座標情報更新と接触フラグを立てる。 xy_t_f #フラグを返す。 flag end #-------------------------------------------------------------------------- # 方向ボタン入力による移動処理 #-------------------------------------------------------------------------- alias move_by_input_symbol_extra move_by_input def move_by_input #接触イベントチェックフラグが立っておらず #直前の座標と現在の座標が一致せず、移動していない場合。 if !@touch_flag && (@old_x != @x or @old_y != @y) && !moving? #イベント実行中であり、直前にイベントが実行されていなかった場合は #イベントが実行されていたフラグを立てる。 if $game_map.interpreter.running? && !@interpreter_ran @interpreter_ran = true #イベント実行中でなく、イベントが実行されていたフラグが立っている場合は #接触イベントをチェックし、イベントが実行されていたフラグを折る。 elsif !$game_map.interpreter.running? && @interpreter_ran check_touch_event @interpreter_ran = false end end #本来の処理を実行。 move_by_input_symbol_extra #移動に成功していた場合は接触イベントチェックフラグを折る。 @touch_flag = false if @move_succeed end #-------------------------------------------------------------------------- # 座標情報更新と接触フラグを立てる #-------------------------------------------------------------------------- def xy_t_f @old_x = @x @old_y = @y @touch_flag = true end #-------------------------------------------------------------------------- # 移動ルート強制のインデックス進行 #-------------------------------------------------------------------------- alias advance_move_route_index_symbol_extra advance_move_route_index unless $! def advance_move_route_index #本来の処理を実行。 advance_move_route_index_symbol_extra #座標情報の更新を行う。 @old_x = @x @old_y = @y end end end class Game_Map #-------------------------------------------------------------------------- # セットアップ #-------------------------------------------------------------------------- alias setup_symbol_extra setup def setup(map_id) #座標情報の更新を行う。 $game_player.xy_t_f #本来の処理を実行。 setup_symbol_extra(map_id) end end