#============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数を扱うモジュールです。 #============================================================================== module Numset SIZE_CHANGE = "大きさ" # 大きさ変更名称 SPEED_CHANGE = "移動速度" # 移動速度変更名称 DEPTH_CHANGE = "半透明度" # 深さ変更名称 Z_CHANGTE = "Z" # Z座標変更名称 BASE_DEPTH = 12 # ベースの深さ CUSTOM_DEPTH = {2 => 24} # {地形タグ => 深さ}のハッシュ end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 大きさの取得 #-------------------------------------------------------------------------- def size eleset = self.multy_element_set percent = XRXS.element_percent(eleset, /^#{Numset::SIZE_CHANGE}/) psize = 100 + percent return [psize, 1].max end end #============================================================================== # ■ Game_Character #------------------------------------------------------------------------------ #  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event # クラスのスーパークラスとして使用されます。 #============================================================================== class Game_Character #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :size # キャラクターの大きさ(%) attr_writer :depth # キャラクターの半透明度 attr_writer :move_speed # キャラクターの速度 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :base_initialize :initialize def initialize @ms = 0 @size = 100 @size_duration = 0 @depth_duration = 0 @final_size = 0 @final_depth = 0 base_initialize end #-------------------------------------------------------------------------- # ● 移動速度の取得 #-------------------------------------------------------------------------- def move_speed return @move_speed end #-------------------------------------------------------------------------- # ● 大きさの変更 #-------------------------------------------------------------------------- def size_change(value, duration) @size_duration = duration if duration == 0 @size = value else @finalsize = value end end #-------------------------------------------------------------------------- # ● 半透明度の変更 #-------------------------------------------------------------------------- def depth_change(value, duration) @depth_duration = duration if duration == 0 @depth = value else @finaldepth = value end end #-------------------------------------------------------------------------- # ● 深さの取得 #-------------------------------------------------------------------------- def depth # 最前面に表示フラグが ON の場合 if @always_on_top return 0 end # タイルに応じて変更 if $game_map.bush?(@x, @y) deep = Numset::CUSTOM_DEPTH[terrain_tag] deep = Numset::BASE_DEPTH if deep == nil else deep = 0 end n = @jump_peak - @jump_count hosei = (@jump_peak ** 2 - n ** 2) / 2 return [(deep - hosei), 0].max end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :base_update :update def update # 大きさを徐々に変更 if @size_duration > 0 @size = (@size * (@size_duration - 1) + @final_size) / @size_duration @size_duration -= 1 end # 半透明度を徐々に変更 if @depth_duration > 0 @depth = (@depth * (@depth_duration - 1) + @final_depth) / @depth_duration @depth_duration -= 1 end base_update end #-------------------------------------------------------------------------- # ● フレーム更新 (移動) #-------------------------------------------------------------------------- def update_move # 移動速度からマップ座標系での移動距離に変換 distance = 2 ** move_speed # 論理座標が実座標より下の場合 if @y * 128 > @real_y # 下に移動 @real_y = [@real_y + distance, @y * 128].min end # 論理座標が実座標より左の場合 if @x * 128 < @real_x # 左に移動 @real_x = [@real_x - distance, @x * 128].max end # 論理座標が実座標より右の場合 if @x * 128 > @real_x # 右に移動 @real_x = [@real_x + distance, @x * 128].min end # 論理座標が実座標より上の場合 if @y * 128 < @real_y # 上に移動 @real_y = [@real_y - distance, @y * 128].max end # 移動時アニメが ON の場合 if @walk_anime # アニメカウントを 1.5 増やす @anime_count += 1.5 # 移動時アニメが OFF で、停止時アニメが ON の場合 elsif @step_anime # アニメカウントを 1 増やす @anime_count += 1 end end end #============================================================================== # ■ Game_Player #------------------------------------------------------------------------------ #  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの # 機能を持っています。このクラスのインスタンスは $game_player で参照されます。 #============================================================================== class Game_Player < Game_Character #-------------------------------------------------------------------------- # ● 移動速度の取得 #-------------------------------------------------------------------------- def move_speed amount = 0 if @ms == 0 for actor in $game_party.actors eleset = actor.multy_element_set amount += XRXS.element_amount(eleset, /^#{Numset::SPEED_CHANGE}/) end end return [(super + amount), 1].max end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z(height = 0) eleset = $game_party.actors[0].multy_element_set amount = XRXS.element_amount(eleset, /^#{Numset::DEPTH_CHANGE}/) # superは最低が0なので手抜き return [super(height) + amount, 0].max end #-------------------------------------------------------------------------- # ● 大きさの取得 #-------------------------------------------------------------------------- def size eleset = $game_party.actors[0].multy_element_set percent = XRXS.element_percent(eleset, /^#{Numset::SIZE_CHANGE}/) psize = super * (100 + percent) / 100 return [psize, 1].max end #-------------------------------------------------------------------------- # ● 半透明度の取得 #-------------------------------------------------------------------------- def depth eleset = $game_party.actors[0].multy_element_set amount = XRXS.element_amount(eleset, /^#{Numset::DEPTH_CHANGE}/) # superは最低が0なので手抜き return [super + amount, 0].max end end #============================================================================== # ■ Game_Event #------------------------------------------------------------------------------ #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理 # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。 #============================================================================== class Game_Event < Game_Character def initialize(map_id, event) super() @map_id = map_id @event = event @id = @event.id @name = @event.name @erased = false @starting = false @through = true # 初期位置に移動 moveto(@event.x, @event.y) refresh end #-------------------------------------------------------------------------- # ● 画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z(height = 0) dsize = (@name[/\\d\[\d+?\]/i] == nil ? 0 : @name[/\\d\[\d+?\]/i].to_i) # superは最低が0なので手抜き return [super(height) + dsize, 0].max end #-------------------------------------------------------------------------- # ● 大きさの取得 #-------------------------------------------------------------------------- def size esize = (@name[/\\s\[\d+?\]/i] == nil ? 100 : @name[/\\s\[\d+?\]/i].to_i) esize = esize * super / 100 return [esize, 1].max end #-------------------------------------------------------------------------- # ● 半透明度の取得 #-------------------------------------------------------------------------- def depth dsize = (@name[/\\d\[\d+?\]/i] == nil ? 0 : @name[/\\d\[\d+?\]/i].to_i) # superは最低が0なので手抜き return [super + dsize, 0].max end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias :base_refresh :refresh def refresh # 強制部分を退避 org_route = @move_route org_index = @move_route_index org_forcing = @move_route_forcing # 呼び戻す base_refresh # オリジナルの移動ルートを変更 @original_move_route_index = 0 @original_move_route = @page.move_route # 強制部分を復帰 if org_route != nil @move_route = org_route @move_route_index = org_index @move_route_forcing = org_forcing end end end #============================================================================== # ■ Sprite_Character #------------------------------------------------------------------------------ #  キャラクター表示用のスプライトです。Game_Character クラスのインスタンスを # 監視し、スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Character < RPG::Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :base_initialize :initialize def initialize(viewport, character = nil) @size = 100 @depth = 0 @opacity = 255 @blend_type = 0 base_initialize(viewport, character) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # タイル ID、ファイル名、色相のどれかが現在のものと異なる場合 if @tile_id != @character.tile_id or @character_name != @character.character_name or @character_hue != @character.character_hue # タイル ID とファイル名、色相を記憶 @tile_id = @character.tile_id @character_name = @character.character_name @character_hue = @character.character_hue # タイル ID が有効な値の場合 if @tile_id >= 384 self.bitmap = RPG::Cache.tile($game_map.tileset_name, @tile_id, @character.character_hue) self.src_rect.set(0, 0, 32, 32) self.ox = 16 self.oy = 32 # タイル ID が無効な値の場合 else self.bitmap = RPG::Cache.character(@character.character_name, @character.character_hue) @cw = bitmap.width / 4 @ch = bitmap.height / 4 self.ox = @cw / 2 self.oy = @ch end end # 可視状態を設定 self.visible = (not @character.transparent) # グラフィックがキャラクターの場合 if @tile_id == 0 # 転送元の矩形を設定 sx = @character.pattern * @cw sy = (@character.direction - 2) / 2 * @ch self.src_rect.set(sx, sy, @cw, @ch) end # スプライトの座標を設定 self.x = @character.screen_x self.y = @character.screen_y self.z = @character.screen_z(@ch) # 不透明度、合成方法、半透明度、大きさを設定(変化した時のみ) if @opacity != @character.opacity self.opacity = @character.opacity @opacity = @character.opacity end if @size != @character.size self.zoom_x = (@character.size / 100.0) self.zoom_y = (@character.size / 100.0) @size = @character.size end if @blend_type != @character.blend_type self.blend_type = @character.blend_type @blend_type = @character.blend_type end if @depth != @character.depth self.bush_depth = @character.depth @depth = @character.depth end # アニメーション if @character.animation_id != 0 animation = $data_animations[@character.animation_id] animation(animation, true) @character.animation_id = 0 end end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias :size_update :update def update size_update # スプライトの大きさを設定 if @battler != nil and @battler_size != @battler.size self.zoom_x = (@battler.size / 100.0) self.zoom_y = (@battler.size / 100.0) @battler_size = @battler.size end end end