#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Special Transitions - KGC_SpecialTransition ◆ VX ◆ #_/ ◇ Last Update: 2008/09/06 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/---------------------------------------------------------------------------- #_/ This script creates special transitional types. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ BEGIN Customization ★ #============================================================================== module KGC module SpecialTransition # ◆ Stop Gameplay Process While Transitioning ◆ # This toggle allows you to stop the gameplay process while the transition is # Taking place. Please note that setting this to false also requires more CPU # power, so keep that in mind. # true : Game play is stopped while the transition is run. # false : Events and game play on the map continue to run in the transition. STOP_WHILE_TRANSITION = true # ◆ Splash Block Size ◆ # This determines how large the blocks are, in pixels. SPLASH_SIZE = 32 # ◆ Splash Block Scattering ◆ # This determines how far spread the blocks are moved during the transition. SPLASH_VAGUE = 7.2 # ◆ Splash Block Rotation ◆ # This toggle allows you to enable or disable block rotation. # true : Each block is rotated. # false : No rotation. SPLASH_ROTATE = true # ◆ Random Stripe Pixel Width ◆ # This allows you to specify the width of the bars/stripes as used by the # Random Stripe transition. (See Below) RAND_STRIPE_SIZE = 2 # ◆ Default Battle Transition Type ◆ # This allows you to set the type of transition that is used by default. # 0..Default ("Graphics/BattleStart.png" is used) # 1..Splash # 2..Random Stripe DEFAULT_BATTLE_TRANSITION_TYPE = 1 # ◆ Default Battle Transition Duration ◆ # This allows you to change the time (in frames) in which the transition lasts. DEFAULT_BATTLE_TRANSITION_DURATION = 60 # ◆ Default Battle Transition Movement Direction ◆ # This allows you to specify to movement pattern of the transition. # # 0..Move To Center 2..Down 4..Left 6..Right 8..Up # # 0..Horizontal 1..Vertical DEFAULT_BATTLE_TRANSITION_DIRECTION = 0 end end #============================================================================= # ★ End Customization ★ #============================================================================= #=================================================# # IMPORT # #=================================================# $imported = {} if $imported == nil $imported["SpecialTransition"] = true #=================================================# #============================================================================== # □ KGC::SpecialTransition #============================================================================== module KGC::SpecialTransition # 特殊トランジションタイプ module Type NONE = 0 # なし (通常) SPLASH = 1 # スプラッシュ RAND_STRIPE = 2 # ランダムストライプ VALUE_RANGE = SPLASH..RAND_STRIPE end # 特殊トランジション方向 module Direction HORIZONTAL = 0 VERTICAL = 1 end end #-------------------------------------------------------------------------- # ○ 1 or -1 を返す #-------------------------------------------------------------------------- def pmrand return (rand(2) == 0 ? 1 : -1) end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # □ KGC::Commands #============================================================================== module KGC module Commands module_function #-------------------------------------------------------------------------- # ○ 戦闘トランジションを変更 # type : 形式 # duration : 時間 # direction : 方向 #-------------------------------------------------------------------------- def set_battle_transition(type = nil, duration = nil, direction = nil) $game_system.battle_transition_type = type $game_system.battle_transition_duration = duration $game_system.battle_transition_direction = direction end #-------------------------------------------------------------------------- # ○ 特殊トランジション設定 # type : 形式 # duration : 時間 # direction : 方向 #-------------------------------------------------------------------------- def set_special_transition(type, duration = 60, direction = 0) Graphics.set_special_transition(type, duration, direction) end end end class Game_Interpreter include KGC::Commands end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Module_Graphics #============================================================================== module Graphics # 特殊トランジションタイプ @@_sp_transition_type = KGC::SpecialTransition::Type::NONE # 特殊トランジション方向 @@_sp_transition_dir = 0 # 特殊トランジション用バッファ @@_sp_transition_buffer = nil # 特殊トランジション用スプライト @@_sp_transition_sprites = [] # 特殊トランジション期間 @@_sp_transition_duration_max = -1 @@_sp_transition_duration = -1 module_function unless $@ #-------------------------------------------------------------------------- # ● トランジション実行 #-------------------------------------------------------------------------- class << Graphics alias transition_KGC_SpecialTransition transition end def transition(duration = 10, filename = "", vague = 40) if @@_sp_transition_type != KGC::SpecialTransition::Type::NONE duration = 0 end transition_KGC_SpecialTransition(duration, filename, vague) if KGC::SpecialTransition::STOP_WHILE_TRANSITION while @@_sp_transition_duration >= 0 update end end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- class << Graphics alias update_KGC_SpecialTransition update end def update update_KGC_SpecialTransition if @@_sp_transition_duration >= 0 update_special_transition end end end # unless @ #-------------------------------------------------------------------------- # ○ 特殊トランジション設定 # type : トランジションタイプ # duration : トランジション期間 # dir : 方向 #-------------------------------------------------------------------------- def set_special_transition(type, duration = 90, dir = 0) finish_special_transition return unless KGC::SpecialTransition::Type::VALUE_RANGE.include?(type) @@_sp_transition_type = type @@_sp_transition_dir = dir @@_sp_transition_duration_max = duration prepare_special_transition end #-------------------------------------------------------------------------- # ○ 特殊トランジション準備 #-------------------------------------------------------------------------- def prepare_special_transition @@_sp_transition_buffer = Graphics.snap_to_bitmap # トランジション用変数初期化 case @@_sp_transition_type when KGC::SpecialTransition::Type::SPLASH init_splash when KGC::SpecialTransition::Type::RAND_STRIPE init_rand_stripe end Graphics.frame_reset end #-------------------------------------------------------------------------- # ○ スプラッシュ初期化 #-------------------------------------------------------------------------- def init_splash @@_sp_transition_duration = @@_sp_transition_duration_max @@_splash_dir = [] @@_splash_angle = [] size = KGC::SpecialTransition::SPLASH_SIZE hsize = size / 2 cells = (Graphics.width * Graphics.height) / (size ** 2) cols = Graphics.width / size rect = Rect.new(0, 0, size, size) # 各セルの作成・移動方向算出 cells.times { |i| rect.x = i % cols * size rect.y = i / cols * size sprite = create_special_transition_sprite(rect) sprite.bitmap.blt(0, 0, @@_sp_transition_buffer, rect) sprite.x += hsize sprite.y += hsize sprite.ox = sprite.oy = hsize @@_sp_transition_sprites << sprite x = rect.x / size y = rect.y / size @@_splash_dir[i] = calc_splash_move_direction(x, y, cells, cols) if KGC::SpecialTransition::SPLASH_ROTATE @@_splash_angle[i] = rand(24) - 12 else @@_splash_angle[i] = 0 end } end #-------------------------------------------------------------------------- # ○ 特殊トランジション用スプライト生成 # rect : スプライトの位置・サイズ #-------------------------------------------------------------------------- def create_special_transition_sprite(rect) sprite = Sprite.new sprite.bitmap = Bitmap.new(rect.width, rect.height) sprite.x = rect.x sprite.y = rect.y sprite.z = 20000 return sprite end #-------------------------------------------------------------------------- # ○ スプラッシュ移動方向計算 # x, y : 基準位置 # cells : セル数 # cols : 列数 #-------------------------------------------------------------------------- def calc_splash_move_direction(x, y, cells, cols) vague = KGC::SpecialTransition::SPLASH_VAGUE vx = vy = 0 case @@_sp_transition_dir when 0 # 中央から広がる x -= cols >> 1 y -= (cells / cols) >> 1 r = Math.sqrt(x ** 2 + y ** 2) / vague if r != 0 vx = x / r vy = y / r else vx = ( x != 0 ? (x * 1.5) : (pmrand * vague) ) vy = ( y != 0 ? (y * 1.5) : (pmrand * vague) ) end vx += (rand - 0.5) * vague vy += (rand - 0.5) * vague when 2 # 下 rows = cells / cols vx = (rand(50) - 25) / 10.0 vy = 1 + vague * (rows - y) / rows * (1.0 + rand / 5.0) when 4 # 左 vx = -1 - vague * (x + 1) / cols * (1.0 + rand / 5.0) vy = (rand(50) - 25) / 10.0 when 6 # 右 vx = 1 + vague * (cols - x) / cols * (1.0 + rand / 5.0) vy = (rand(50) - 25) / 10.0 when 8 # 上 rows = cells / cols vx = (rand(50) - 25) / 10.0 vy = -1 - vague * (y + 1) / rows * (1.0 + rand / 5.0) end mag = 60.0 / @@_sp_transition_duration_max return [vx * mag, vy * mag] end #-------------------------------------------------------------------------- # ○ ランダムストライプ初期化 #-------------------------------------------------------------------------- def init_rand_stripe case @@_sp_transition_dir when KGC::SpecialTransition::Direction::VERTICAL @@_rand_stripe_direction = 0 else @@_rand_stripe_direction = 1 end size = KGC::SpecialTransition::RAND_STRIPE_SIZE bands = (@@_rand_stripe_direction == 0 ? Graphics.width : Graphics.height) / size @@_sp_transition_duration = @@_sp_transition_duration_max @@_rand_stripe_deleted = [] @@_rand_stripe_deleted_count = 0 # ランダム消去用配列を生成 ary = (0...bands).to_a @@_rand_stripe_index_array = ary.sort_by { rand } sprite = create_special_transition_sprite(@@_sp_transition_buffer.rect) sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height) sprite.bitmap.blt(0, 0, @@_sp_transition_buffer, @@_sp_transition_buffer.rect) @@_sp_transition_sprites << sprite end #-------------------------------------------------------------------------- # ○ 特殊トランジション更新 #-------------------------------------------------------------------------- def update_special_transition if @@_sp_transition_duration == 0 finish_special_transition return end case @@_sp_transition_type when KGC::SpecialTransition::Type::SPLASH update_splash when KGC::SpecialTransition::Type::RAND_STRIPE update_rand_stripe end @@_sp_transition_duration -= 1 end #-------------------------------------------------------------------------- # ○ スプラッシュ更新 #-------------------------------------------------------------------------- def update_splash opacity = 384 * @@_sp_transition_duration / @@_sp_transition_duration_max # セルを移動 @@_sp_transition_sprites.each_with_index { |sprite, i| sprite.x += @@_splash_dir[i][0] sprite.y += @@_splash_dir[i][1] sprite.angle += @@_splash_angle[i] sprite.opacity = opacity } end #-------------------------------------------------------------------------- # ○ ランダムストライプ更新 #-------------------------------------------------------------------------- def update_rand_stripe dir = @@_rand_stripe_direction size = KGC::SpecialTransition::RAND_STRIPE_SIZE bands = (dir == 0 ? Graphics.width : Graphics.height) / size rect = Rect.new(0, 0, (dir == 0 ? size : Graphics.width), (dir == 0 ? Graphics.height : size)) buffer = @@_sp_transition_buffer sprite = @@_sp_transition_sprites[0] phase = @@_sp_transition_duration_max - @@_sp_transition_duration # 消去箇所を設定 count = (bands - bands * @@_sp_transition_duration / @@_sp_transition_duration_max) - @@_rand_stripe_deleted_count while count > 0 @@_rand_stripe_deleted[@@_rand_stripe_index_array.pop] = true @@_rand_stripe_deleted_count += 1 count -= 1 end # 未消去部分のみ描画 sprite.bitmap.clear bands.times { |i| unless @@_rand_stripe_deleted[i] if dir == 0 # 縦 rect.x = i * size sprite.bitmap.blt(rect.x, 0, buffer, rect) else # 横 rect.y = i * size sprite.bitmap.blt(0, rect.y, buffer, rect) end end } end #-------------------------------------------------------------------------- # ○ 特殊トランジション終了 #-------------------------------------------------------------------------- def finish_special_transition if @@_sp_transition_buffer != nil @@_sp_transition_buffer.dispose @@_sp_transition_buffer = nil end case @@_sp_transition_type when KGC::SpecialTransition::Type::SPLASH @@_splash_dir = nil @@_splash_angle = nil when KGC::SpecialTransition::Type::RAND_STRIPE @@_rand_stripe_direction = nil @@_rand_stripe_deleted = nil @@_rand_stripe_deleted_count = nil @@_rand_stripe_index_array = nil end @@_sp_transition_type = KGC::SpecialTransition::Type::NONE @@_sp_transition_sprites.each { |sprite| sprite.bitmap.dispose sprite.dispose } @@_sp_transition_sprites = [] @@_sp_transition_duration_max = -1 @@_sp_transition_duration = -1 end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_System #============================================================================== class Game_System #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_writer :battle_transition_type # 戦闘トランジション : 形式 attr_writer :battle_transition_duration # 戦闘トランジション : 時間 attr_writer :battle_transition_direction # 戦闘トランジション : 方向 #-------------------------------------------------------------------------- # ○ 戦闘トランジション : 形式 #-------------------------------------------------------------------------- def battle_transition_type if @battle_transition_type == nil return KGC::SpecialTransition::DEFAULT_BATTLE_TRANSITION_TYPE else return @battle_transition_type end end #-------------------------------------------------------------------------- # ○ 戦闘トランジション : 時間 #-------------------------------------------------------------------------- def battle_transition_duration if @battle_transition_duration == nil return KGC::SpecialTransition::DEFAULT_BATTLE_TRANSITION_DURATION else return @battle_transition_duration end end #-------------------------------------------------------------------------- # ○ 戦闘トランジション : 方向 #-------------------------------------------------------------------------- def battle_transition_direction if @battle_transition_direction == nil return KGC::SpecialTransition::DEFAULT_BATTLE_TRANSITION_DIRECTION else return @battle_transition_direction end end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Map #============================================================================== class Scene_Map < Scene_Base #-------------------------------------------------------------------------- # ● バトル画面への切り替え #-------------------------------------------------------------------------- alias call_battle_KGC_SpecialTransition call_battle def call_battle call_battle_KGC_SpecialTransition KGC::Commands.set_special_transition( $game_system.battle_transition_type, $game_system.battle_transition_duration, $game_system.battle_transition_direction) end end