Permanent
Creation

RPGツクールXP/VX用のRGSS素材です。
一部英語版対応です。 (A few materials can be used for English RPG MAKER XP/VX.)
競合率はルファーの独断と偏見なのでたまにハズレます。


スクリーンショット
↑スクリーンショット (クリックで拡大)
#==============================================================================
# ■ 特殊バトルトランジション
#------------------------------------------------------------------------------
#  戦闘開始時に、画面が崩れたりズームインしたりするようにします。どこかで見た
# ような演出もあるかも。
# (C)     ルファー
# WebSite https://tkoolerlufar.pages.dev/
#==============================================================================

=begin
  =対応RGSS
  2

  =他の素材との競合の可能性
  ... なし

  =使い方
  この素材を導入するとバトル開始トランジションがランダムに変わります。
  イベントコマンド「スクリプト」で、以下のように入力すると固定できます。

    $game_system.battle_start_pattern = [パターン ID]

  パターン ID は以下のパターンに対応した数字です。

    ID|説明
    --+----
    -1|ランダム。
     0|いつものようにトランジションする。
     1|左上から徐々に消える。このとき、境界が白っぽくなる。
     2|くるくるっと二枚羽のプロペラが回る感じ。
     3|画面が爆発して粉々になる。
     4|タイルが2回くるくると裏返って消える。三角形の波が見える。
    10|画面を横に引き伸ばす。
    11|画面を縦に引き伸ばす。
    12|画面を縦横に引き伸ばす。
    13|画面が横に波打つ。
    14|画面が縦に波打つ。
    15|画面が2方向に細かく波打つ。
    16|画面が横に波打つ。(逆位相)
    17|画面が縦に波打つ。(逆位相)
    18|画面が2方向に細かく波打つ。(逆位相)

  =ちなみに
  ランダムに設定した場合、演出パターンは
  71行目に書かれているパターンの中から選ばれるようになります。
  これを変えれば、ランダムで選ばれる演出をあなたのお好みチョイスにできます。

  =更新履歴
  2014/12/28 画面解像度変更対応していなかったのを修正
  2011/07/28 公開

  =再定義しているメソッド (いずれもエイリアス使用)
  Scene_Map#perform_battle_transition

  =新規定義しているメソッド
  Scene_Map#snapshot_for_background
  Scene_Map#_Lufar_SBT_PerformBattleTransitionGrid
=end

#----------------------------------------------------------------------------
# ◆ Lufar モジュール
#----------------------------------------------------------------------------
module Lufar
  #--------------------------------------------------------------------------
  # ◆ SpecialBattleStart モジュール
  #--------------------------------------------------------------------------
  module SpecialBattleStart
    #------------------------------------------------------------------------
    # ◎ 設定項目
    #------------------------------------------------------------------------
    APPLIED_RANDOM = [                    # ランダムで許可されるパターン
      1, 2, 3, 4, 10, 11, 12, 13, 14, 15, 16, 17, 18
      ]
    #------------------------------------------------------------------------
    # ● 定数 (いじらないでください)
    #------------------------------------------------------------------------
    DOUBLE_FLASH = [1, 2, 4]              # 2回フラッシュするパターン
    CLIPPING_SIZE = 040                   # クリッピングの寸法
  end
end
#----------------------------------------------------------------------------
# ◆ Game_System クラス
#----------------------------------------------------------------------------
class Game_System
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :battle_start_pattern     # バトル開始パターン
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias _Lufar_SBS_PrototypeOfInit initialize
  def initialize
    _Lufar_SBS_PrototypeOfInit()
    @battle_start_pattern = -1
  end
end
#----------------------------------------------------------------------------
# ◆ Scene_Map クラス
#----------------------------------------------------------------------------
class Scene_Map
  #--------------------------------------------------------------------------
  # ● 別画面の背景として使うためのスナップショット作成
  #--------------------------------------------------------------------------
  unless method_defined?(:_Lufar_SBT_SnapshotForBackground)
    alias _Lufar_SBT_SnapshotForBackground snapshot_for_background
  end
  def snapshot_for_background(*args)
    unless $scene.is_a?(Scene_Battle)
      return _Lufar_SBT_SnapshotForBackground(*args)
    end
    $game_temp.background_bitmap.dispose
    $game_temp.background_bitmap = Graphics.snap_to_bitmap
  end
  #--------------------------------------------------------------------------
  # ● 戦闘前トランジション実行
  #--------------------------------------------------------------------------
  unless method_defined?(:_Lufar_SBT_PerformBattleTransition)
    alias _Lufar_SBT_PerformBattleTransition perform_battle_transition
  end
  def perform_battle_transition(*args)
    pattern = $game_system.battle_start_pattern
    # ランダム
    if pattern < 0
      pattern = Lufar::SpecialBattleStart::APPLIED_RANDOM[
        rand(Lufar::SpecialBattleStart::APPLIED_RANDOM.length)]
    end
    # 普通にトランジション
    if pattern == 0
      $game_temp.background_bitmap.blur
      return _Lufar_SBT_PerformBattleTransition(*args)
    end
    # その他なら演出の準備
    viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
    viewport.color.set(255.0, 255.0, 255.0, 255.0)
    # クリッピングの列数と行数
    @Lufar_clips_cols = ($game_temp.background_bitmap.width  +
      Lufar::SpecialBattleStart::CLIPPING_SIZE * 3 - 1) / (
      Lufar::SpecialBattleStart::CLIPPING_SIZE * 2) * 2 - 1
    @Lufar_clips_rows = ($game_temp.background_bitmap.height +
      Lufar::SpecialBattleStart::CLIPPING_SIZE * 3 - 1) / (
      Lufar::SpecialBattleStart::CLIPPING_SIZE * 2) * 2 - 1
    # クリッピング開始点
    @Lufar_clips_ox = (640-$game_temp.background_bitmap.width  +
      Lufar::SpecialBattleStart::CLIPPING_SIZE) / 2 %
      Lufar::SpecialBattleStart::CLIPPING_SIZE * (-1)
    @Lufar_clips_oy = (480-$game_temp.background_bitmap.height +
      Lufar::SpecialBattleStart::CLIPPING_SIZE) / 2 %
      Lufar::SpecialBattleStart::CLIPPING_SIZE * (-1)
    clipping_rect = Rect.new(0, 0,
      Lufar::SpecialBattleStart::CLIPPING_SIZE,
      Lufar::SpecialBattleStart::CLIPPING_SIZE)
    piece_sprites = Array.new(@Lufar_clips_cols * @Lufar_clips_rows) do |i|
      ## スプライトの参照点
      clipping_rect.x = i % @Lufar_clips_cols *
        Lufar::SpecialBattleStart::CLIPPING_SIZE + @Lufar_clips_ox
      clipping_rect.y = i / @Lufar_clips_cols *
        Lufar::SpecialBattleStart::CLIPPING_SIZE + @Lufar_clips_oy
      # スプライトを設定
      sprite = Sprite.new(viewport)
      sprite.bitmap = $game_temp.background_bitmap
      sprite.src_rect = clipping_rect.dup
      # クリッピング領域をビットマップの範囲内に丸める
      if sprite.src_rect.x < 0
        sprite.src_rect.width += sprite.src_rect.x
        sprite.src_rect.x = 0
      elsif sprite.src_rect.x + sprite.src_rect.width > Graphics.width
        sprite.src_rect.width = Graphics.width - sprite.src_rect.x
      end
      if sprite.src_rect.y < 0
        sprite.src_rect.height += sprite.src_rect.y
        sprite.src_rect.y = 0
      elsif sprite.src_rect.y + sprite.src_rect.height > Graphics.height
        sprite.src_rect.height = Graphics.height - sprite.src_rect.y
      end
      sprite.ox =
      sprite.oy = Lufar::SpecialBattleStart::CLIPPING_SIZE / 2
      sprite.x = sprite.src_rect.x + sprite.ox
      sprite.y = sprite.src_rect.y + sprite.oy
      sprite.color.set(255.0, 255.0, 255.0, 0.0)
      sprite
    end
    Graphics.transition(0)
    case pattern/10
    when 0
      for t in 1..80
        @Lufar_clips_rows.times do |y|
          @Lufar_clips_cols.times do |x|
            i = x + @Lufar_clips_cols * y
            sprite = piece_sprites[i]
            case pattern
            when 1
              ## 左上から消える
              sprite.opacity = 0xFF -
                (t - x - y - 20) *
                0xFF / (62 - @Lufar_clips_cols - @Lufar_clips_rows)
              sprite.color.alpha = 255 - sprite.opacity
            when 2
              ## DQ的な
              effect_ox = @Lufar_clips_cols * 0.5 - 0.5
              effect_oy = @Lufar_clips_rows * 0.5 - 0.5
              if x == effect_ox and y == effect_oy
                theta = 0.0
              else
                theta = Math.atan((y-effect_oy) / (x-effect_ox))
                theta += Math::PI if theta < 0.0
                theta += Math::PI if x+y & 1 != 0
              end
              sprite.visible = theta >= Math::PI * (t-20) / 30.0
            when 3
              ## 爆発
              sprite.x += 2*x -   (@Lufar_clips_cols - 1)
              sprite.y += 2*y - 2*(@Lufar_clips_rows - 1) +
                          t * (@Lufar_clips_rows - 1) / 80
              sprite.opacity = (80 - t) * 255 / 80
              sprite.zoom_x =
              sprite.zoom_y = Math.sqrt(sprite.opacity / 255.0)
            when 4
              ## うぇーぶ
              # (20:開始時刻)
              u = t - 20 -
                  (@Lufar_clips_cols - 1 - 2*x).abs -
                  (@Lufar_clips_rows - 1 -   y)
              #(62:演出時間60+補正)
              mu = 62 - @Lufar_clips_cols - @Lufar_clips_rows
              z = u < 0 ? 1.0 : u < mu ? Math.cos(1.5*Math::PI * u/mu) : 0.0
              sprite.zoom_x = z.abs
              sprite.mirror = z < 0.0
            end
          end
        end
        Graphics.update
        if Lufar::SpecialBattleStart::DOUBLE_FLASH.include?(pattern)
          viewport.color.alpha -=  25.5
          viewport.color.alpha  = 255.0 if viewport.color.alpha == 0.0 && t < 20
        else
          viewport.color.alpha -=  12.75
        end
      end
    when 1
      _Lufar_SBT_PerformBattleTransitionGrid(pattern, viewport, piece_sprites)
    end
    Graphics.freeze
    for sprite in piece_sprites
      sprite.dispose
    end
    viewport.dispose
    $game_temp.background_bitmap.blur
  end
  #--------------------------------------------------------------------------
  # ● 戦闘前トランジション実行 (グリッド操作)
  #--------------------------------------------------------------------------
  def _Lufar_SBT_PerformBattleTransitionGrid(pattern, viewport, piece_sprites)
    # スプライトの配置からグリッドを作成
    vgrid = Array.new(@Lufar_clips_cols+1) do |i|
      Lufar::SpecialBattleStart::CLIPPING_SIZE*i + @Lufar_clips_ox
      if i == @Lufar_clips_cols
        piece_sprites[-1].src_rect.x + piece_sprites[-1].src_rect.width
      else
        piece_sprites[i].src_rect.x
      end
    end
    hgrid = Array.new(@Lufar_clips_rows+1) do |i|
      Lufar::SpecialBattleStart::CLIPPING_SIZE*i + @Lufar_clips_oy
      if i == @Lufar_clips_rows
        piece_sprites[-1].src_rect.y + piece_sprites[-1].src_rect.height
      else
        piece_sprites[i * @Lufar_clips_cols].src_rect.y
      end
    end
    piece_sprites.length.times do |i|
      piece_sprites[i].ox =
      piece_sprites[i].oy = 0
    end
    for t in 0...80
      if [10, 12].include?(pattern)
        ## 横エキスパンド
        u = (vgrid.length / 2) * t    # 伸ばすグリッドの数*40
        for i in 0..(u/80)
          delta = t - 80 * i / (vgrid.length / 2)
          vgrid[+i] -= delta
          vgrid[-i] += delta
        end
      end
      if [11, 12].include?(pattern)
        ## 縦エキスパンド
        u = (hgrid.length / 2) * t
        for i in 0..(u/80)
          delta = t - 80 * i / (hgrid.length / 2)
          hgrid[+i] -= delta
          hgrid[-i] += delta
        end
      end
      ## 波打ち
      if pattern.between?(13, 18)
        frequency = 0.125
        x_amplitude = pattern % 3 == 2 ? 0 : t * (pattern % 3 != 0 ? 0.4 : 0.2)
        y_amplitude = pattern % 3 == 1 ? 0 : t * (pattern % 3 != 0 ? 0.4 : 0.2)
        for i in 1...(vgrid.length-1)
          phase = (pattern <= 15 ? +i : -i) / (vgrid.length - 1.0)
          vgrid[i] =
            (Math.sin((t * frequency + phase)*Math::PI) * x_amplitude).round +
            Lufar::SpecialBattleStart::CLIPPING_SIZE*i + @Lufar_clips_ox
        end
        for i in 1...(hgrid.length-1)
          phase = (pattern <= 15 ? +i : -i) / (hgrid.length - 1.0)
          hgrid[i] =
            (Math.sin((t * frequency + phase)*Math::PI) * y_amplitude).round +
            Lufar::SpecialBattleStart::CLIPPING_SIZE*i + @Lufar_clips_oy
        end
      end
      @Lufar_clips_rows.times do |y|
        show_y      = hgrid[y  ]
        show_height = hgrid[y+1] - show_y
        @Lufar_clips_cols.times do |x|
          show_x     = vgrid[x  ]
          show_width = vgrid[x+1] - show_x
          i = x + @Lufar_clips_cols*y
          sprite = piece_sprites[i]
          sprite.x = show_x
          sprite.y = show_y
          sprite.zoom_x = show_width .to_f / sprite.width .to_f
          sprite.zoom_y = show_height.to_f / sprite.height.to_f
          sprite.opacity = 0xff * (79-t) / 80
        end
      end
      Graphics.update
      if Lufar::SpecialBattleStart::DOUBLE_FLASH.include?(pattern)
        viewport.color.alpha -=  25.5
        viewport.color.alpha  = 255.0  if t == 9
      else
        viewport.color.alpha -=  12.75
      end
    end
  end
end

戻る