#============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #  〜+B1:移動コスト設定〜 by 水夜 #  ver0.90 Zenith Creation (http://zenith.ifdef.jp/) #------------------------------------------------------------------------------ # マップ上での戦略的なバトルを実現。 #============================================================================== #============================================================================== # [ZTBS] -Zenith Tactical Battle System- タクティカルバトルシステム #============================================================================== module ZTBS def self.tag_cost(tag, battler) case tag #============================================================================== # # when 地形タグ # return 移動コスト # バトラーの情報にbattlerでアクセス出来るので、 # バトラーによって移動コストを変更することも可能です。 # #============================================================================== when 0 return 1 when 1 return 1 when 2 return 1 when 3 return 1 when 4 return 1 when 5 return 1 when 6 return 1 when 7 return 1 end end def self.point_cost(battler, mapid, point) case [mapid, point] #============================================================================== # # when [マップID, タイル番号] # return 移動コスト # バトラーの情報にbattlerでアクセス出来るので、 # バトラーによって移動コストを変更することも可能です。 # #============================================================================== when [0, 0] return 1 else return 1 end end def self.event_cost(battler, x, y) #============================================================================== # # 普通にRubyのスクリプトを書くしかありません。 # ある程度Rubyが出来るなら、どうぞ。 # #============================================================================== result = 1 for event in $game_map.point_events(x, y) end return result end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 移動可能距離の取得 #-------------------------------------------------------------------------- def movable n = ztbs_agi / ZTBS::C_MOVABLE n = [[n.floor, 1].max, ZTBS::MOVABLE_MAX].min return n end end #============================================================================== # ■ Game_Map #============================================================================== class Game_Map #-------------------------------------------------------------------------- # ● ある地点のイベント取得 #-------------------------------------------------------------------------- def point_events(x, y) result = [] for event in self.events if event[1].x == x and event[1].y == y result.push(event) end end return result end #-------------------------------------------------------------------------- # ● 移動コストの取得 #-------------------------------------------------------------------------- def move_cost(battler, x, y) max = 1 for i in 0..2 real_point = self.data[x, y, i] if real_point >= 384 point = real_point - 378 else point = (real_point / 48.0).floor end if point > 0 tags = ZTBS.tag_cost(@terrain_tags[real_point], battler) pots = ZTBS.point_cost(battler, self.id, point) evts = ZTBS.event_cost(battler, x, y) max = [tags, pots, evts].max end end return max end end #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map #-------------------------------------------------------------------------- # ● 移動エリア & ルート検索 #-------------------------------------------------------------------------- def search_route if $game_system.tactics_actors.keys.include?(@battler.id) battler = $game_system.tactics_actors[@battler.id] else battler = $game_system.tactics_enemies[@battler.id] end @position = [[@battler.x, @battler.y]] @route = [[]] cost = [0] more_step = [0] for i in more_step x = @position[i][0] y = @position[i][1] # 下 if !@position.include?([x, y + 1]) and @battler.passable?(x, y, 2) mikomi = cost[i] + $game_map.move_cost(battler, x, y + 1) if mikomi < battler.movable @position.push([x, y + 1]) @route.push(@route[i] + [2]) cost.push(mikomi) if cost.last < battler.movable more_step.push(@route.index(@route[i] + [2])) end end end # 左 if !@position.include?([x - 1, y]) and @battler.passable?(x, y, 4) mikomi = cost[i] + $game_map.move_cost(battler, x - 1, y) if mikomi < battler.movable @position.push([x - 1, y]) @route.push(@route[i] + [4]) cost.push(mikomi) if cost.last < battler.movable more_step.push(@route.index(@route[i] + [4])) end end end # 右 if !@position.include?([x + 1, y]) and @battler.passable?(x, y, 6) mikomi = cost[i] + $game_map.move_cost(battler, x + 1, y) if mikomi < battler.movable @position.push([x + 1, y]) @route.push(@route[i] + [6]) cost.push(mikomi) if cost.last < battler.movable more_step.push(@route.index(@route[i] + [6])) end end end # 上 if !@position.include?([x, y - 1]) and @battler.passable?(x, y, 8) mikomi = cost[i] + $game_map.move_cost(battler, x, y - 1) if mikomi < battler.movable @position.push([x, y - 1]) @route.push(@route[i] + [8]) cost.push(mikomi) if cost.last < battler.movable more_step.push(@route.index(@route[i] + [8])) end end end end end end