#============================================================================== # ■ RGSS3 斜め移動リージョン Ver1.00 by 星潟 #============================================================================== # 左右キーを押した際、移動前の座標と斜め方向のリージョンIDが # 共通の特定の値である場合、左右の直線移動とならず、斜め方向の移動となります。 # 斜め移動系のスクリプトとは相性が悪い場合があります。 #============================================================================== # 記号別 # □ 本来移動不可の座標 # ○ 元々移動可能の座標 # △ 斜め移動リージョン&移動可能な座標(斜め階段等の移動可能マップチップを置く) # △と○が接している場所は互いの移動可否判定に注意。 # (○が△側の方向に移動できないようなチップになっている等のミスを警戒) #============================================================================== # 右下/左上移動用の斜め移動リージョンIDの設置例。 # あくまで例なので、状況に応じて工夫して下さい。 #------------------------------------------------------------------------------ # 幅1マスの場合 # # ○△□□○ # ○□△□○ # ○□□△○ # # 幅2マスの場合 # # ○△□□□○ # ○△△□□○ # ○□△△□○ # ○□□△△○ # ○□□□△○ #============================================================================== # 右上/左下移動用の斜め移動リージョンIDの設置例。 # あくまで例なので、状況に応じて工夫して下さい。 #------------------------------------------------------------------------------ # 幅1マスの場合 # # ○□□△○ # ○□△□○ # ○△□□○ # # 幅2マスの場合 # # ○□□□△○ # ○□□△△○ # ○□△△□○ # ○△△□□○ # ○△□□□○ # #============================================================================== module DiagonalMoveRegion #右下/左上移動用の斜め移動リージョンIDを指定。 RID1 = 31 #右上/左下移動用の斜め移動リージョンIDを指定。 RID2 = 32 #リージョン依存の斜め移動時、マップチップの移動判定を無視するかどうか指定。 #無視する場合は幅1の斜め移動リージョンを作成する事も可能。 #ただし、それによって何らかの不都合が生じる可能性はあり。 #trueで無視。falseで無視しない。 Through = true #隊列移動を行う場合、隊列歩行用キャラクターも #リージョンの条件を満たす場合は #斜め移動の向きに応じて左右のみしか向かないようにするかを指定。 #trueで左右のみ。falseで直前の向きに影響。 LRFix = true #接触判定・調べた際のイベント起動判定も #リージョンの条件を満たす場合は通常の判定に加えて #斜め方向の判定も行うようにするかを指定。 #trueで行う。falseで行わない。 Trigger = true end class Game_CharacterBase #-------------------------------------------------------------------------- # まっすぐに移動 #-------------------------------------------------------------------------- alias move_straight_diagonal_move_region move_straight def move_straight(d, turn_ok = true) r = $game_map.region_id(x,y) if r == DiagonalMoveRegion::RID1 case d when 4 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 8) if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 @through_by_diagonal_move_region = DiagonalMoveRegion::Through move_diagonal(4,8) @through_by_diagonal_move_region = nil set_direction(4) check_event_trigger_touch_front return end when 6 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 2) if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 @through_by_diagonal_move_region = DiagonalMoveRegion::Through move_diagonal(6,2) @through_by_diagonal_move_region = nil set_direction(6) check_event_trigger_touch_front return end end elsif r == DiagonalMoveRegion::RID2 case d when 4 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 2) if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 @through_by_diagonal_move_region = DiagonalMoveRegion::Through move_diagonal(4,2) @through_by_diagonal_move_region = nil set_direction(4) check_event_trigger_touch_front return end when 6 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 8) if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 @through_by_diagonal_move_region = DiagonalMoveRegion::Through move_diagonal(6,8) @through_by_diagonal_move_region = nil set_direction(6) check_event_trigger_touch_front return end end end move_straight_diagonal_move_region(d, turn_ok) end if DiagonalMoveRegion::LRFix #-------------------------------------------------------------------------- # 斜めに移動 #-------------------------------------------------------------------------- alias move_diagonal_diagonal_move_region move_diagonal def move_diagonal(horz, vert) r = $game_map.region_id(x,y) move_diagonal_diagonal_move_region(horz, vert) if @move_succeed if r == DiagonalMoveRegion::RID1 r = $game_map.region_id(x,y) set_direction(horz) if r == DiagonalMoveRegion::RID1 elsif r == DiagonalMoveRegion::RID2 r = $game_map.region_id(x,y) set_direction(horz) if r == DiagonalMoveRegion::RID2 end end end end #-------------------------------------------------------------------------- # マップ通行可能判定 #-------------------------------------------------------------------------- alias map_passable_diagonal_move_region? map_passable? def map_passable?(x, y, d) return true if @through_by_diagonal_move_region r = map_passable_diagonal_move_region?(x, y, d) end end if DiagonalMoveRegion::Trigger class Game_CharacterBase #-------------------------------------------------------------------------- # 正面の接触イベントの起動判定 #-------------------------------------------------------------------------- alias check_event_trigger_touch_front_diagonal_move_region check_event_trigger_touch_front def check_event_trigger_touch_front check_event_trigger_touch_front_diagonal_move_region flag = false case @direction when 4 r = $game_map.region_id(x,y) if r == DiagonalMoveRegion::RID1 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 8) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 elsif r == DiagonalMoveRegion::RID2 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 2) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 end when 6 r = $game_map.region_id(x,y) if r == DiagonalMoveRegion::RID1 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 2) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 elsif r == DiagonalMoveRegion::RID2 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 8) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 end end if flag $game_player.diagonal_move_region_direction = true check_event_trigger_touch(nx, ny) $game_player.diagonal_move_region_direction = nil end end end class Game_Character < Game_CharacterBase #-------------------------------------------------------------------------- # キャラクターの方を向く #-------------------------------------------------------------------------- alias turn_toward_character_diagonal_move_region turn_toward_character def turn_toward_character(character) d = $game_player.diagonal_move_region_direction return set_direction(distance_x_from(character.x) > 0 ? 4 : 6) if d turn_toward_character_diagonal_move_region(character) end end class Game_Player < Game_Character attr_accessor :diagonal_move_region_direction #-------------------------------------------------------------------------- # 正面のイベント起動判定 #-------------------------------------------------------------------------- alias check_event_trigger_there_diagonal_move_region check_event_trigger_there def check_event_trigger_there(triggers) check_event_trigger_there_diagonal_move_region(triggers) return if $game_map.any_event_starting? flag = false case @direction when 4 r = $game_map.region_id(x,y) if r == DiagonalMoveRegion::RID1 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 8) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 elsif r == DiagonalMoveRegion::RID2 nx = $game_map.round_x_with_direction(x, 4) ny = $game_map.round_y_with_direction(y, 2) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 end when 6 r = $game_map.region_id(x,y) if r == DiagonalMoveRegion::RID1 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 2) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID1 elsif r == DiagonalMoveRegion::RID2 nx = $game_map.round_x_with_direction(x, 6) ny = $game_map.round_y_with_direction(y, 8) flag = true if $game_map.region_id(nx,ny) == DiagonalMoveRegion::RID2 end end if flag $game_player.diagonal_move_region_direction = true start_map_event(nx, ny, triggers, true) $game_player.diagonal_move_region_direction = nil return if $game_map.any_event_starting? return unless $game_map.counter?(nx, ny) x3 = $game_map.round_x_with_direction(x2, @direction) y3 = $game_map.round_y_with_direction(y2, @direction) $game_player.diagonal_move_region_direction = true start_map_event(x3, y3, triggers, true) $game_player.diagonal_move_region_direction = nil end end end end