#============================================================================ # # ■壁タイル拡張×隊列歩行スクリプト 併用スクリプト # # □作成時バージョン:壁タイル拡張 Ver3.01 #           隊列歩行スクリプト Last update : 2008/3/16 # □製作者:月紳士 # ・RPGツクールVX用 RGSS2スクリプト # # ●…書き換えメソッド(競合注意) ◎…メソッドのエイリアス ○…新規メソッド #  ○●…月紳士の新規メソッドをさらに書き換えた物 #  ◎●…すでにエイリアス定義済みのメソッドをさらに書き換えた物 # # ※二次配布禁止!配布元には利用規約があります。必ずそちらを見てください。 #============================================================================ =begin  月紳士のスクリプト「壁タイル拡張」と  HARTS HORN様の「隊列歩行スクリプト」を併用する際、  プレイヤーの動きと、パーティーキャラクターの追従の動きを  正しく動作させる為の追加スクリプトです。  ※このスクリプトと、   月紳士のスクリプト「壁タイル拡張」   に関する問題報告や質問は、HARTS HORN様へは絶対になさらないでください。   使用は自己責任で。   「HARTS HORN様へご迷惑をお掛けしない」これを必ず守ってください。  導入順   隊列歩行スクリプト   壁タイル拡張   このスクリプト  の順で導入してください。 =end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● キャラクター衝突判定 # x : X 座標 # y : Y 座標 # プレイヤーと乗り物を含め、通常キャラの衝突を検出する。 #-------------------------------------------------------------------------- def collide_with_characters?(x, y) for event in $game_map.events_xy(x, y) # イベントの座標と一致 next unless parallel?(event) ##### 追加部分 (この行) ##### unless event.through # すり抜け OFF? return true if self.is_a?(Game_Event) # 自分がイベント return true if event.priority_type == 1 # 相手が通常キャラ end end if @priority_type == 1 # 自分が通常キャラ return true if $game_player.pos_nt?(x, y) # プレイヤーの座標と一致 return true if $game_subplayer1.pos_nt?(x,y) # サブプレイヤーの座標と一致#追加 return true if $game_subplayer2.pos_nt?(x,y) # サブプレイヤーの座標と一致#追加 return true if $game_subplayer3.pos_nt?(x,y) # サブプレイヤーの座標と一致#追加 return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致 return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致 end return false end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ◎ 下に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_pc_move_down move_down def move_down(turn_ok = true) unless ex_passable(2) turn_down if turn_ok @move_failed = true check_event_trigger_touch(@x, @y+1) # 接触イベントの起動判定 return end tig_ew_pc_move_down(turn_ok) end #-------------------------------------------------------------------------- # ◎ 左に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_pc_move_left move_left def move_left(turn_ok = true) unless ex_passable(4) turn_left if turn_ok @move_failed = true check_event_trigger_touch(@x-1, @y) # 接触イベントの起動判定 return end tig_ew_pc_move_left(turn_ok) end #-------------------------------------------------------------------------- # ◎ 右に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_pc_move_right move_right def move_right(turn_ok = true) unless ex_passable(6) turn_right if turn_ok check_event_trigger_touch(@x+1, @y) # 接触イベントの起動判定 @move_failed = true return end tig_ew_pc_move_right(turn_ok) end #-------------------------------------------------------------------------- # ◎ 上に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_pc_move_up move_up def move_up(turn_ok = true) unless ex_passable(8) turn_up if turn_ok check_event_trigger_touch(@x, @y-1) # 接触イベントの起動判定 @move_failed = true return end tig_ew_pc_move_up(turn_ok) end #-------------------------------------------------------------------------- # ◎ 左下に移動 #-------------------------------------------------------------------------- alias tig_ew_pc_move_lower_left move_lower_left def move_lower_left turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back unless passable?(@x, @y+1) and passable?(@x-1, @y) and passable?(@x-1, @y+1) and ex_passable(2) and ex_passable(4, @x-1, @y+1, turn_back1) and ex_passable(4) and ex_passable(2, @x-1, @y+1, turn_back2) if @direction == 2 if passable?(@x-1, @y) and ex_passable(4) move_left else move_down end elsif @direction == 4 if passable?(@x, @y+1) and ex_passable(2) move_down else move_left end end return end tig_ew_pc_move_lower_left end #-------------------------------------------------------------------------- # ◎ 右下に移動 #-------------------------------------------------------------------------- alias tig_ew_pc_move_lower_right move_lower_right def move_lower_right turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back unless passable?(@x, @y+1) and passable?(@x+1, @y) and passable?(@x+1, @y+1) and ex_passable(2) and ex_passable(6, @x+1, @y+1, turn_back1) and ex_passable(6) and ex_passable(2, @x+1, @y+1, turn_back2) if @direction == 2 if passable?(@x-1, @y) and ex_passable(6) move_right else move_down end elsif @direction == 6 if passable?(@x, @y+1) and ex_passable(2) move_down else move_right end end return end tig_ew_pc_move_lower_right end #-------------------------------------------------------------------------- # ◎ 左上に移動 #-------------------------------------------------------------------------- alias tig_ew_pc_move_upper_left move_upper_left def move_upper_left turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back unless passable?(@x, @y-1) and passable?(@x-1, @y) and passable?(@x-1, @y-1) and ex_passable(8) and ex_passable(4, @x-1, @y-1, turn_back1) and ex_passable(4) and ex_passable(8, @x-1, @y-1, turn_back2) if @direction == 8 if passable?(@x-1, @y) and ex_passable(4) move_left else move_up end elsif @direction == 4 if passable?(@x, @y+1) and ex_passable(8) move_up else move_left end end return end tig_ew_pc_move_upper_left end #-------------------------------------------------------------------------- # ◎ 右上に移動 #-------------------------------------------------------------------------- alias tig_ew_pc_move_upper_right move_upper_right def move_upper_right turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back unless passable?(@x, @y-1) and passable?(@x+1, @y) and passable?(@x+1, @y-1) and ex_passable(8) and ex_passable(6, @x+1, @y-1, turn_back1) and ex_passable(6) and ex_passable(8, @x+1, @y-1, turn_back2) if @direction == 8 if passable?(@x+1, @y) and ex_passable(6) move_right else move_up end elsif @direction == 6 if passable?(@x, @y-1) and ex_passable(8) move_up else move_right end end return end tig_ew_pc_move_upper_right end #-------------------------------------------------------------------------- # ● キャラクター衝突判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def collide_with_characters?(x, y) for event in $game_map.events_xy(x, y) # イベントの座標と一致 next unless parallel?(event) ##### 追加部分 (この行) ##### unless event.through # すり抜け OFF? return true if self.is_a?(Game_Event) # 自分がイベント return true if event.priority_type == 1 # 相手が通常キャラ end end if @priority_type == 1 # 自分が通常キャラ return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致 return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致 end return false end #-------------------------------------------------------------------------- # ○● 裏回り状態更新 #-------------------------------------------------------------------------- def update_turn_back tile_id = $game_map.point_tile_id(@x, @y) direction = search_direction(@real_x, @real_y, @x * 256, @y * 256) #- 段差マップの場合 if Expansion_Passable::CLIFF_MAP.include?($game_map.map_id) #- 停止時の更新 if direction == 5 @turn_back = false if @no_turn_back unless $game_map.back_tile?(@x, @y) @turn_back = false @no_turn_back = false end @on_tile = true unless @turn_back $game_subplayer1.update_turn_back_move_end $game_subplayer2.update_turn_back_move_end $game_subplayer3.update_turn_back_move_end #- 移動開始時の更新 else if direction % 2 == 0 if $game_map.rip?(10 - direction, @x, @y) @turn_back = true unless @no_turn_back end else if diagonal_move_turn_back(direction, @x, @y) @turn_back = true unless @no_turn_back end end @on_tile = false if @turn_back $game_subplayer1.update_turn_back_move_start $game_subplayer2.update_turn_back_move_start $game_subplayer3.update_turn_back_move_start end if not @turn_back or @no_turn_back if $game_map.keep_back_position != nil and $game_map.keep_back_position.include?([@x, @y]) @on_tile = false return end end #- 通常マップの場合 else #- 停止時の更新 if direction == 5 unless $game_map.back_tile?(@x, @y) @turn_back = false @no_turn_back = false end if $game_map.upper_layer?(tile_id[0]) @on_tile = true else @on_tile = false end $game_subplayer1.update_turn_back_move_end $game_subplayer2.update_turn_back_move_end $game_subplayer3.update_turn_back_move_end #- 移動開始時の更新 else if direction % 2 == 0 if $game_map.rip?(10 - direction, @x, @y) @turn_back = true unless @no_turn_back end else if diagonal_move_turn_back(direction, @x, @y) @turn_back = true unless @no_turn_back end end $game_subplayer1.update_turn_back_move_start $game_subplayer2.update_turn_back_move_start $game_subplayer3.update_turn_back_move_start end if $game_map.back_tile?(@x, @y) if @turn_back @on_tile = false else @on_tile = true end elsif Data_Tile::STEP.include?(tile_id[0]) or Data_Tile::STEP.include?(tile_id[2]) @on_tile = true end end end end #============================================================================== # ■ Game_Subplayer #------------------------------------------------------------------------------ #  サブプレイヤーを扱うクラスです。 # このクラスのインスタンスは $game_subplayer1〜3で参照されます。 # Game_Playerクラスを元に作っています #============================================================================== class Game_Subplayer < Game_Character #-------------------------------------------------------------------------- # ◎ オブジェクト初期化 #-------------------------------------------------------------------------- alias tig_ew_sc_initialize initialize def initialize tig_ew_sc_initialize @vehicle_type = -1 @turn_back = false @no_turn_back = false @on_tile = true @not_back_seeing = false end #-------------------------------------------------------------------------- # ◎ 下に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_sc_move_down move_down def move_down(turn_ok = true) unless ex_passable(2) turn_down if turn_ok @move_failed = true return end tig_ew_sc_move_down(turn_ok) end #-------------------------------------------------------------------------- # ◎ 左に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_sc_move_left move_left def move_left(turn_ok = true) unless ex_passable(4) turn_left if turn_ok @move_failed = true return end tig_ew_sc_move_left(turn_ok) end #-------------------------------------------------------------------------- # ◎ 右に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_sc_move_right move_right def move_right(turn_ok = true) unless ex_passable(6) turn_right if turn_ok @move_failed = true return end tig_ew_sc_move_right(turn_ok) end #-------------------------------------------------------------------------- # ◎ 上に移動 # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias tig_ew_sc_move_up move_up def move_up(turn_ok = true) unless ex_passable(8) turn_up if turn_ok @move_failed = true return end tig_ew_sc_move_up(turn_ok) end #-------------------------------------------------------------------------- # ◎ 左下に移動 #-------------------------------------------------------------------------- alias tig_ew_sc_move_lower_left move_lower_left def move_lower_left turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back unless passable?(@x, @y+1) and passable?(@x-1, @y) and passable?(@x-1, @y+1) and ex_passable(2) and ex_passable(4, @x-1, @y+1, turn_back1) and ex_passable(4) and ex_passable(2, @x-1, @y+1, turn_back2) if @direction == 2 if passable?(@x-1, @y) and ex_passable(4) move_left else move_down end elsif @direction == 4 if passable?(@x, @y+1) and ex_passable(2) move_down else move_left end end return end tig_ew_sc_move_lower_left end #-------------------------------------------------------------------------- # ◎ 右下に移動 #-------------------------------------------------------------------------- alias tig_ew_sc_move_lower_right move_lower_right def move_lower_right turn_back1 = $game_map.rip?(8, @x, @y+1) ? true : @turn_back turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back unless passable?(@x, @y+1) and passable?(@x+1, @y) and passable?(@x+1, @y+1) and ex_passable(2) and ex_passable(6, @x+1, @y+1, turn_back1) and ex_passable(6) and ex_passable(2, @x+1, @y+1, turn_back2) if @direction == 2 if passable?(@x-1, @y) and ex_passable(6) move_right else move_down end elsif @direction == 6 if passable?(@x, @y+1) and ex_passable(2) move_down else move_right end end return end tig_ew_sc_move_lower_right end #-------------------------------------------------------------------------- # ◎ 左上に移動 #-------------------------------------------------------------------------- alias tig_ew_sc_move_upper_left move_upper_left def move_upper_left turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back turn_back2 = $game_map.rip?(6, @x-1, @y) ? true : @turn_back unless passable?(@x, @y-1) and passable?(@x-1, @y) and passable?(@x-1, @y-1) and ex_passable(8) and ex_passable(4, @x-1, @y-1, turn_back1) and ex_passable(4) and ex_passable(8, @x-1, @y-1, turn_back2) if @direction == 8 if passable?(@x-1, @y) and ex_passable(4) move_left else move_up end elsif @direction == 4 if passable?(@x, @y+1) and ex_passable(8) move_up else move_left end end return end tig_ew_sc_move_upper_left end #-------------------------------------------------------------------------- # ◎ 右上に移動 #-------------------------------------------------------------------------- alias tig_ew_sc_move_upper_right move_upper_right def move_upper_right turn_back1 = $game_map.rip?(2, @x, @y-1) ? true : @turn_back turn_back2 = $game_map.rip?(4, @x+1, @y) ? true : @turn_back unless passable?(@x, @y-1) and passable?(@x+1, @y) and passable?(@x+1, @y-1) and ex_passable(8) and ex_passable(6, @x+1, @y-1, turn_back1) and ex_passable(6) and ex_passable(8, @x+1, @y-1, turn_back2) if @direction == 8 if passable?(@x+1, @y) and ex_passable(6) move_right else move_up end elsif @direction == 6 if passable?(@x, @y-1) and ex_passable(8) move_up else move_right end end return end tig_ew_sc_move_upper_right end #----------------------------------------------------------------------- # ◎ 裏回り状態更新(無効化) #-------------------------------------------------------------------------- alias tig_ew_sc_update_turn_back update_turn_back def update_turn_back end #-------------------------------------------------------------------------- # ○ 裏回り状態更新(移動開始時) #-------------------------------------------------------------------------- def update_turn_back_move_start tile_id = $game_map.point_tile_id(@x, @y) direction = search_direction(@real_x, @real_y, @x * 256, @y * 256) #- 段差マップの場合 if Expansion_Passable::CLIFF_MAP.include?($game_map.map_id) if direction % 2 == 0 if $game_map.rip?(10 - direction, @x, @y) @turn_back = true unless @no_turn_back end else if diagonal_move_turn_back(direction, @x, @y) @turn_back = true unless @no_turn_back end end @on_tile = false if @turn_back if not @turn_back or @no_turn_back if $game_map.keep_back_position != nil and $game_map.keep_back_position.include?([@x, @y]) @on_tile = false return end end #- 通常マップの場合 else if direction % 2 == 0 if $game_map.rip?(10 - direction, @x, @y) @turn_back = true unless @no_turn_back end else if diagonal_move_turn_back(direction, @x, @y) @turn_back = true unless @no_turn_back end end if $game_map.back_tile?(@x, @y) if @turn_back @on_tile = false else @on_tile = true end elsif Data_Tile::STEP.include?(tile_id[0]) or Data_Tile::STEP.include?(tile_id[2]) @on_tile = true end end end #-------------------------------------------------------------------------- # ○ 裏回り状態更新(移動終了時) #-------------------------------------------------------------------------- def update_turn_back_move_end tile_id = $game_map.point_tile_id(@x, @y) direction = search_direction(@real_x, @real_y, @x * 256, @y * 256) #- 段差マップの場合 if Expansion_Passable::CLIFF_MAP.include?($game_map.map_id) @turn_back = false if @no_turn_back unless $game_map.back_tile?(@x, @y) @turn_back = false @no_turn_back = false end @on_tile = true unless @turn_back if not @turn_back or @no_turn_back if $game_map.keep_back_position != nil and $game_map.keep_back_position.include?([@x, @y]) @on_tile = false return end end #- 通常マップの場合 else unless $game_map.back_tile?(@x, @y) @turn_back = false @no_turn_back = false end if $game_map.upper_layer?(tile_id[0]) @on_tile = true else @on_tile = false end if $game_map.back_tile?(@x, @y) if @turn_back @on_tile = false else @on_tile = true end elsif Data_Tile::STEP.include?(tile_id[0]) or Data_Tile::STEP.include?(tile_id[2]) @on_tile = true end end end #-------------------------------------------------------------------------- # ● キャラクター衝突判定 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def collide_with_characters?(x, y) for event in $game_map.events_xy(x, y) # イベントの座標と一致 next unless parallel?(event) ##### 追加部分 (この行) ##### unless event.through # すり抜け OFF? return true if self.is_a?(Game_Event) # 自分がイベント return true if event.priority_type == 1 # 相手が通常キャラ end end if @priority_type == 1 # 自分が通常キャラ return true if $game_map.boat.pos_nt?(x, y) # 小型船の座標と一致 return true if $game_map.ship.pos_nt?(x, y) # 大型船の座標と一致 end return false end end #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ #  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは # Scene_Map クラスの内部で使用されます。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ◎● キャラクタースプライトの更新 #-------------------------------------------------------------------------- def update_characters back_seeing_characters = [] for sprite in @character_sprites if sprite.character.on_tile sprite.viewport = @viewport4 else sprite.viewport = @viewport1 end next if sprite.character.not_back_seeing if $game_player.turn_back and Expansion_Passable::BACK_SEEING x = $game_player.x ; y = $game_player.y if ($game_map.round_x(x-4)..$game_map.round_x(x+4)).include?(sprite.character.x) and ($game_map.round_y(y-4)..$game_map.round_y(y+4)).include?(sprite.character.y) back_seeing_characters.push(sprite.character) end end end back_seeing(back_seeing_characters) tig_ew_update_characters end #-------------------------------------------------------------------------- # ○● 拡張ビューポートの更新 #-------------------------------------------------------------------------- def update_ew_ex_viewports @viewport4.ox = $game_map.screen.shake @viewport4.update if Expansion_Passable::BACK_SEEING @viewport5.rect.set($game_player.screen_x - 112, $game_player.screen_y - 128, 228, 228) @viewport5.ox = $game_map.screen.shake @viewport5.update end end end #============================================================================== # ■ Sprite_Character #------------------------------------------------------------------------------ #  キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを # 監視し、スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # ◎● フレーム更新 #-------------------------------------------------------------------------- def update tig_ew_update if @back_seeing self.opacity = 100 if self.opacity > 100 self.x -= $game_player.screen_x - 112 self.y -= $game_player.screen_y - 128 end end end