#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数全般のモジュールです。 #============================================================================== module Numset Y_HOSEI = 32 # Y 座標補正(その分上に余白が出来ます) TILE_PATTERN = true # true ならば左が原点、 false ならば上が原点 TILE_WIDTH = 48 # タイルの横幅 TILE_HEIGHT = 24 # タイルの縦幅 end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 指定位置に移動 # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def moveto(x, y) @x = x % $game_map.width @y = y % $game_map.height @real_x = @x * 128 @real_y = @y * 128 @prelock_direction = 0 end #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x if Numset::TILE_PATTERN result = (@real_x + ($game_map.height + 1) * 128 - @real_y) * Numset::TILE_WIDTH / 256 - $game_map.display_x / 4 else result = (@real_x + @real_y + 1) * Numset::TILE_WIDTH / 256 + Numset::Y_HOSEI - $game_map.display_x / 4 end if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_x + (320 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y if Numset::TILE_PATTERN result = (@real_x + @real_y) * Numset::TILE_HEIGHT / 256 - $game_map.display_y / 4 else result = (@real_y - ($game_map.width + 1) * 128 - @real_x) * Numset::TILE_HEIGHT / 256 + Numset::Y_HOSEI - game_map.display_y / 4 end # ジャンプカウントに応じて Y 座標を小さくする if @jump_count >= @jump_peak n = @jump_count - @jump_peak else n = @jump_peak - @jump_count end result = result - (@jump_peak * @jump_peak - n * n) / 2 if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_y + (240 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 # height : キャラクターの高さ #-------------------------------------------------------------------------- def screen_z(height = 0) # 最前面に表示フラグが ON の場合 if @always_on_top # 無条件に 999 return 999 end # 実座標とマップの表示位置から画面座標を求める z = screen_y # タイルの場合 if @tile_id > 0 # タイルのプライオリティ * 32 を足す return z + $game_map.priorities[@tile_id] * 32 # キャラクターの場合 else # 高さが 32 を超えていれば 31 を足す return z + ((height > 32) ? 31 : 0) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :quarter_update :update def update quarter_update # スプライトのズーム倍率を設定 if $scene.spriteset.is_a?(Spriteset_Map) self.zoom_x = $scene.spriteset.zoom self.zoom_y = self.zoom_x end end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ローカル変数に移動中かどうかを記憶 last_moving = moving? # 移動中、イベント実行中、移動ルート強制中、 # メッセージウィンドウ表示中のいずれでもない場合 unless moving? or $game_system.map_interpreter.running? or @move_route_forcing or $game_temp.message_window_showing # 方向ボタンが押されていれば、その方向へプレイヤーを移動 case Input.dir4 when 2 move_down when 4 move_left when 6 move_right when 8 move_up end end # ローカル変数に座標を記憶 last_real_x = @real_x last_real_y = @real_y super # センタリング center(@real_x, @real_y) # 移動中ではない場合 unless moving? # 前回プレイヤーが移動中だった場合 if last_moving # 同位置のイベントとの接触によるイベント起動判定 result = check_event_trigger_here([1,2]) # 起動したイベントがない場合 if result == false # デバッグモードが ON かつ CTRL キーが押されている場合を除き unless $DEBUG and Input.press?(Input::CTRL) # エンカウント カウントダウン if @encounter_count > 0 @encounter_count -= 1 end end end end # C ボタンが押された場合 if Input.trigger?(Input::C) # 同位置および正面のイベント起動判定 check_event_trigger_here([0]) check_event_trigger_there([0,1,2]) end end end end #============================================================================== # ■ Spriteset_Map #------------------------------------------------------------------------------ #  マップ画面のスプライトやタイルマップなどをまとめたクラスです。このクラスは # Scene_Map クラスの内部で使用されます。 #============================================================================== class Spriteset_Map #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :zoom # 倍率 attr_reader :zoom_x # ズーム X 座標 attr_reader :zoom_y # ズーム Y 座標 attr_accessor :target_zoom # 倍率予約 attr_accessor :target_zoom_x # ズーム X 座標予約 attr_accessor :target_zoom_y # ズーム Y 座標予約 attr_accessor :zoom_duration # 倍率変更時間 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :quarter_initialize :initialize def initialize @zoom = 1.0 @zoom_x = 320 @zoom_y = 240 @target_zoom = 1.0 @target_zoom_x = 320 @target_zoom_y = 240 @zoom_duration = 0 quarter_initialize end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # パノラマが現在のものと異なる場合 if @panorama_name != $game_map.panorama_name or @panorama_hue != $game_map.panorama_hue @panorama_name = $game_map.panorama_name @panorama_hue = $game_map.panorama_hue if @panorama.bitmap != nil @panorama.bitmap.dispose @panorama.bitmap = nil end if @panorama_name != "" @panorama.bitmap = RPG::Cache.panorama(@panorama_name, @panorama_hue) end Graphics.frame_reset end # フォグが現在のものと異なる場合 if @fog_name != $game_map.fog_name or @fog_hue != $game_map.fog_hue @fog_name = $game_map.fog_name @fog_hue = $game_map.fog_hue if @fog.bitmap != nil @fog.bitmap.dispose @fog.bitmap = nil end if @fog_name != "" @fog.bitmap = RPG::Cache.fog(@fog_name, @fog_hue) end Graphics.frame_reset end # ズームを更新 if @zoom_duration >= 1 d = @zoom_duration @zoom = (@zoom * (d - 1) + @target_zoom) / d @zoom_x = (@zoom_x * (d - 1) + @target_zoom_x) / d @zoom_y = (@zoom_y * (d - 1) + @target_zoom_y) / d @zoom_duration -= 1 end unless defined?("$onscreen") # プレイヤーキャラ更新 for i in @party_sprites i.update end end # タイルマップを更新 @tilemap.ox = $game_map.display_x / 4 @tilemap.oy = $game_map.display_y / 4 @tilemap.update # パノラマプレーンを更新 @panorama.zoom_x = [@zoom, 1].max @panorama.zoom_y = [@zoom, 1].max @panorama.ox = ($game_map.display_x / 4.0 + @zoom_x - (320 / @zoom)) * @panorama.zoom_x @panorama.oy = ($game_map.display_y / 4.0 + @zoom_y - (240 / @zoom)) * @panorama.zoom_y # フォグプレーンを更新 @fog.zoom_x = $game_map.fog_zoom * @zoom / 100.0 @fog.zoom_y = $game_map.fog_zoom * @zoom / 100.0 @fog.opacity = $game_map.fog_opacity @fog.blend_type = $game_map.fog_blend_type @fog.ox = ($game_map.display_x / 4.0 + $game_map.fog_ox + @zoom_x - (320 / @zoom)) * @panorama.zoom_x @fog.oy = ($game_map.display_y / 4.0 + $game_map.fog_oy + @zoom_y - (240 / @zoom)) * @panorama.zoom_y @fog.tone = $game_map.fog_tone if Game_System.method_defined?("in_tactics") and $game_system.in_tactics # エリアスプライトを更新 for sprite in @area_sprites + @range_sprites sprite.update end end # キャラクタースプライトを更新 # マップ処理軽量化を使っている場合、画面外のスプライトは更新しない for i in $game_map.events.keys if !defined?("$onscreen") or $onscreen[i] @character_sprites[i].update end end # 天候グラフィックを更新 @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.ox = $game_map.display_x / 4 - 320 + @zoom_x @weather.oy = $game_map.display_y / 4 - 240 + @zoom_y @weather.update # ピクチャを更新 for sprite in @picture_sprites sprite.update end # タイマースプライトを更新 @timer_sprite.update # 画面の色調とシェイク位置を設定 @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake # 画面のフラッシュ色を設定 @viewport3.color = $game_screen.flash_color # ビューポートを更新 @viewport1.update @viewport3.update end end #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● ズーム #-------------------------------------------------------------------------- def zoom(duration = 0, target = 100, target_x = 320, target_y = 240) $scene.spriteset.zoom_duration = duration $scene.spriteset.target_zoom = target / 100.0 $scene.spriteset.target_zoom_x = target_x $scene.spriteset.target_zoom_y = target_y return true end end #============================================================================== # ■ Scene_Map #------------------------------------------------------------------------------ #  マップ画面の処理を行うクラスです。 #============================================================================== class Scene_Map attr_reader :spriteset end # ここから先はZTBS用 if defined?(ZTBS) #============================================================================= = # ■ Sprite_Cursor #============================================================================== class Sprite_Cursor < RPG::Sprite #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x if Numset::TILE_PATTERN result = (@real_x + ($game_map.height + 1) * 128 - @real_y) * Numset::TILE_WIDTH / 256 - game_map.display_x / 4 else result = (@real_x + @real_y + 1) * Numset::TILE_WIDTH / 256 + Numset::Y_HOSEI - $game_map.display_x / 4 end if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_x + (320 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y if Numset::TILE_PATTERN result = (@real_x + @real_y + 1) * Numset::TILE_HEIGHT / 256 - $game_map.display_y / 4 else result = (@real_y - ($game_map.width + 2) * 128 - @real_x) * Numset::TILE_HEIGHT / 256 + Numset::Y_HOSEI - game_map.display_y / 4 end result = result - (@jump_peak * @jump_peak - n * n) / 2 if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_y + (240 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end end #============================================================================== # ■ Sprite_Area #============================================================================== class Sprite_Area < RPG::Sprite #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x if Numset::TILE_PATTERN result = (@real_x + ($game_map.height + 1) * 128 - @real_y) * Numset::TILE_WIDTH / 256 - game_map.display_x / 4 else result = (@real_x + @real_y + 1) * Numset::TILE_WIDTH / 256 + Numset::Y_HOSEI - $game_map.display_x / 4 end if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_x + (320 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y if Numset::TILE_PATTERN result = (@real_x + @real_y + 1.5) * Numset::TILE_HEIGHT / 256 - $game_map.display_y / 4 else result = (@real_y - ($game_map.width + 2.5) * 128 - @real_x) * Numset::TILE_HEIGHT / 256 + Numset::Y_HOSEI - game_map.display_y / 4 end result = result - (@jump_peak * @jump_peak - n * n) / 2 if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_y + (240 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end end #============================================================================== # ■ Sprite_Range #============================================================================== class Sprite_Range < RPG::Sprite #-------------------------------------------------------------------------- # ● 画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x if Numset::TILE_PATTERN result = (@real_x + ($game_map.height + 1) * 128 - @real_y) * Numset::TILE_WIDTH / 256 - game_map.display_x / 4 else result = (@real_x + @real_y + 1) * Numset::TILE_WIDTH / 256 + Numset::Y_HOSEI - $game_map.display_x / 4 end if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_x + (320 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end #-------------------------------------------------------------------------- # ● 画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y if Numset::TILE_PATTERN result = (@real_x + @real_y + 1) * Numset::TILE_HEIGHT / 256 - $game_map.display_y / 4 else result = (@real_y - ($game_map.width + 2) * 128 - @real_x) * Numset::TILE_HEIGHT / 256 + Numset::Y_HOSEI - game_map.display_y / 4 end result = result - (@jump_peak * @jump_peak - n * n) / 2 if $scene.spriteset.is_a?(Spriteset_Map) result = (result - $scene.spriteset.zoom_y + (240 / $scene.spriteset.zoom)) * $scene.spriteset.zoom end return result end end end