#=========================================================================== # ◆ A1 Scripts ◆ # 階段斜め移動(RGSS3) # # バージョン : 1.00 (2011/12/31) # 作者 : A1 # URL     : http://a1tktk.web.fc2.com/ #--------------------------------------------------------------------------- # 機能: # ・階段を斜めに移動します #--------------------------------------------------------------------------- # 更新履歴   :2011/12/31 Ver1.00 リリース #--------------------------------------------------------------------------- # 設置場所 #  A1共通スクリプトより下 # # 必要スクリプト # A1共通スクリプト #--------------------------------------------------------------------------- # 使い方 # タイルセットの設定 # #  階段にしたいチップの通行設定を「○」にして「梯子」を適用 # 左上がりの場合、地形タグを「■ 設定項目」で # LEFT_STEP_TAGに設定した地形タグに設定 # 右上がりの場合、地形タグを「■ 設定項目」で # RIGHT_STEP_TAGに設定した地形タグに設定 # # マップ設定のメモに <マップチップサーチ> と記述 #--------------------------------------------------------------------------- # 注意事項 # 当機能を実現するにあたり、マップ読み込み時にマップの全座標・全レイヤーを調べます # マップが広いほど処理に時間がかかるので注意です # # また、当機能が必要ないマップを考慮して # マップ設定のメモに <マップチップサーチ> と記述しないと # 当機能は効果を発揮しない仕様となっています #============================================================================== $imported ||= {} $imported["A1_HorzStep"] = true if $imported["A1_Common_Script"] #============================================================================== # ■ 設定項目 #============================================================================== module A1_System::HorzStepConfig #-------------------------------------------------------------------------- # ○ 左上がりの階段の地形タグ #-------------------------------------------------------------------------- LEFT_STEP_TAG = 1 #-------------------------------------------------------------------------- # ○ 右上がりの階段の地形タグ #-------------------------------------------------------------------------- RIGHT_STEP_TAG = 2 end #============================================================================== # ■ Game_Map #------------------------------------------------------------------------------ #  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。 # このクラスのインスタンスは $game_map で参照されます。 #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ☆ セットアップ #-------------------------------------------------------------------------- alias a1_horz_step_gm_setup setup def setup(map_id) @use_horz_step = false a1_horz_step_gm_setup(map_id) end #-------------------------------------------------------------------------- # ☆ マップチップに対して処理を行う #-------------------------------------------------------------------------- alias a1_horz_step_map_chip_proc map_chip_proc def map_chip_proc(x, y, z) a1_horz_step_map_chip_proc(x, y, z) setup_horz_step(tile_id(x, y, z)) end #-------------------------------------------------------------------------- # ☆ タイルのイベントに対して処理を行う #-------------------------------------------------------------------------- alias a1_horz_step_tile_event_proc tile_event_proc def tile_event_proc(tile_id) a1_horz_step_tile_event_proc(tile_id) setup_horz_step(tile_id) end #-------------------------------------------------------------------------- # ○ 横階段属性付与 #-------------------------------------------------------------------------- def setup_horz_step(tile_id) flag = tileset.flags[tile_id] return false unless flag & 0x20 == 0x20 tag = flag >> 12 return unless tag == A1_System::HorzStepConfig::LEFT_STEP_TAG or tag == A1_System::HorzStepConfig::RIGHT_STEP_TAG tileset.ex_flags[tile_id] += 0x10 if tag == A1_System::HorzStepConfig::LEFT_STEP_TAG tileset.ex_flags[tile_id] += 0x20 if tag == A1_System::HorzStepConfig::RIGHT_STEP_TAG tileset.flags[tile_id] -= 0x20 @use_horz_step = true end #-------------------------------------------------------------------------- # ○ 左上がり横階段判定 #-------------------------------------------------------------------------- def horz_step_left?(x, y) valid?(x, y) && all_tiles_flag_ex?(x, y, 0x10) end #-------------------------------------------------------------------------- # ○ 右上がり横階段判定 #-------------------------------------------------------------------------- def horz_step_right?(x, y) valid?(x, y) && all_tiles_flag_ex?(x, y, 0x20) end #-------------------------------------------------------------------------- # ○ 横階段を使う? #-------------------------------------------------------------------------- def use_horz_step? return @use_horz_step end end #============================================================================== # ■ Game_CharacterBase #------------------------------------------------------------------------------ #  キャラクターを扱う基本のクラスです。全てのキャラクターに共通する、座標やグ # ラフィックなどの基本的な情報を保持します。 #============================================================================== class Game_CharacterBase #-------------------------------------------------------------------------- # ☆ まっすぐに移動 # d : 方向(2,4,6,8) # turn_ok : その場での向き変更を許可 #-------------------------------------------------------------------------- alias a1_horz_step_gcb_move_straight move_straight def move_straight(d, turn_ok = true) return a1_horz_step_gcb_move_straight(d, turn_ok) unless use_horz_step?(d) return if move_step_right(d, turn_ok) return if move_step_left(d, turn_ok) a1_horz_step_gcb_move_straight(d, turn_ok) end #-------------------------------------------------------------------------- # ○ 横階段を使う? #-------------------------------------------------------------------------- def use_horz_step?(d) return false if d == 2 || d == 8 return $game_map.use_horz_step? end #-------------------------------------------------------------------------- # ○ 右上がり階段移動 #-------------------------------------------------------------------------- def move_step_right(d, turn_ok) right_step = $game_map.horz_step_right?(@x + 1, @y) return false unless right_step if d == 6 return false unless $game_map.horz_step_right?(@x, @y) || (right_step && d == 6) vert = d == 4 ? 2 : 8 return move_step(d, vert, turn_ok) end #-------------------------------------------------------------------------- # ○ 左上がり階段移動 #-------------------------------------------------------------------------- def move_step_left(d, turn_ok) reft_step = $game_map.horz_step_left?(@x - 1, @y) return false unless reft_step if d == 4 return false unless $game_map.horz_step_left?(@x, @y) || (reft_step && d == 4) vert = d == 6 ? 2 : 8 return move_step(d, vert, turn_ok) end #-------------------------------------------------------------------------- # ○ 横階段移動 #-------------------------------------------------------------------------- def move_step(d, vert, turn_ok) @direction = d return false unless diagonal_passable?(x, y, d, vert) move_diagonal(d, vert) return true end end end