Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # =============================================================================
- # TheoAllen - Fog Screen
- # Version : 1.3
- # Contact : www.rpgmakerid.com (or) http://theolized.blogspot.com
- # (This script documentation is written in informal indonesian language)
- # =============================================================================
- ($imported ||={})[:Theo_FogScreen] = true
- # =============================================================================
- # CHANGE LOGS:
- # -----------------------------------------------------------------------------
- # 2013.06.13 - Nambahin global fog (v1.3)
- # - Nambahin global disable switch
- # - Nambahin specific disable switch
- # 2013.06.12 - Bug Fix. Saat pindah map fog ngga ilang (v1.15b)
- # 2013.05.15 - Nambahin blend type (v1.15)
- # - Nambahin zoom
- # - Nambahin variasi opacity dan kecepatannya
- # 2013.05.09 - Started and Finished script (v1.0)
- # =============================================================================
- =begin
- -----------------------------------------------------------------------------
- PERKENALAN :
- Script ini ngebikin kamu bisa nampilin fog seperti yang dimiliki RMXP.
- -----------------------------------------------------------------------------
- CARA PENGGUNAAN :
- Tulis notetag berikut dalam note di map properties:
- - <fog name: nama>
- nama adalah nama file fog yang ada dalam folder Graphics/picture
- - <fog opacity: n>
- n adalah angka transparansi. 255 adalah full tanpa transparan
- - <loop x plus: n>
- - <loop y plus: n>
- - <loop x minus: n>
- - <loop y minus: n>
- n adalah angka yang digunakan untuk kecepatan loop.
- jika tag yang u gunain adalah x plus, maka fog akan scroll ke kiri
- jika tag yang u gunain adalah y plus, maka fog akan scroll ke atas
- minus adalah kebalikannya
- - <blend type: n>
- 0 : normal
- 1 : addition (makin cerah)
- 2 : substraction (makin gelap)
- - <zoom x: n%>
- - <zoom y: n%>
- Memperbesar gambar. Jika input 50%, maka akan jadi 50% dari ukuran asli
- - <opacity var: n>
- Variasi nilai opacity. Semisal kalo u masukin opacity dengan nnilai 150
- dan opacity var adalah 20, maka fog akan berubah opacitynya antara
- - <fade speed: n>
- Kecepatan fade jika kamu memasukkan opacity var lebih dari 0
- Semakin gede fade speed, makin cepet jg fog ngefadein ama fadeout.
- - <fog switch: n>
- Adalah switch id untuk mendisable fog pada map tertentu. Apabila switch
- tersebut menyala, maka fog akan hilang.
- -----------------------------------------------------------------------------
- TENTANG GLOBAL FOG :
- Global fog adalah fog yang bakal ditampilkan pada semua peta meski kamu sudah
- pindah map dan map tersebut tidak terdapat notetag untuk fog. Global fog akan
- mengganti fog yang terdapat dipeta. Global fog dapat kamu panggil dengan cara
- menggunakan script call sebagai berikut
- fog.name = "namafog" >> Nama file gambar fog yg ada di Graphics/picture
- fog.opacity = number >> Opacity fog 1 - 255
- fog.ox = number >> Pergeseran horizontal
- fog.oy = number >> Pergeseran vertical
- fog.blend = number >> Tipe blend (0 - 2)
- fog.zoom_x = number >> Skala zoom horizontal (dalam bentuk pecahan)
- fog.zoom_y = number >> Skala zoom vertical (dalam bentuk pecahan)
- fog.variance = number >> variansi opacity
- fog.speed = number >> kecepatan perubahan opacity
- Untuk menghilangkan fog bisa langsung gunain script call
- fog.clear
- -----------------------------------------------------------------------------
- TERMS OF USE :
- Credit gw, TheoAllen. Kalo semisal u bisa ngedit2 script gw trus jadi lebih
- keren, terserah. Ane bebasin. Asal ngga ngeklaim aja. Kalo semisal mau
- dipake buat komersil, jangan lupa, gw dibagi gratisannya.
- =end
- # =============================================================================
- # Konfigurasi :
- # =============================================================================
- module THEO
- module FOG
- DEFAULT_OPACITY = 90 # Default opacity untuk fog
- DEFAULT_LOOP_X = 0 # Nilai default untuk loop x
- DEFAULT_LOOP_Y = 0 # Nilai default untuk loop y
- GLOBAL_DISABLE_ID = 0 # Untuk ngedisable fog global
- end
- end
- # =============================================================================
- # Akhir dari konfigurasi. Setelah ini ga usah diedit kecuali ente ngerti
- # =============================================================================
- module THEO
- module FOG
- module REGEXP
- NAME = /<(?:FOG_NAME|fog name):[ ](.*)>/i
- OPACITY = /<(?:FOG_OPACITY|fog opacity):[ ]*(\d+)>/i
- LOOP_X_PLUS = /<(?:LOOP_X_PLUS|loop x plus):[ ]*(\d+)>/i
- LOOP_Y_PLUS = /<(?:LOOP_Y_PLUS|loop y plus):[ ]*(\d+)>/i
- LOOP_X_MINUS = /<(?:LOOP_X_MINUS|loop x minus):[ ]*(\d+)>/i
- LOOP_Y_MINUS = /<(?:LOOP_Y_MINUS|loop y minus):[ ]*(\d+)>/i
- BLEND_TYPE = /<(?:BLEND_TYPE|blend type):[ ]*(\d+)>/i
- ZOOM_X = /<(?:ZOOM_X|zoom x):[ ]*(\d+)([%%])>/i
- ZOOM_Y = /<(?:ZOOM_Y|zoom y):[ ]*(\d+)([%%])>/i
- VARIANCE = /<(?:OPACITY_VAR|opacity var):[ ]*(\d+)>/i
- FADE_SPEED = /<(?:FADE_SPEED|fade speed):[ ]*(\d+)>/i
- SWITCH_ID = /<(?:FOG_SWITCH|fog switch):[ ]*(\d+)>/i
- end
- end
- end
- class RPG::Map
- attr_accessor :fog_name
- attr_accessor :fog_opacity
- attr_accessor :fog_x
- attr_accessor :fog_y
- attr_accessor :fog_blend
- attr_accessor :fog_zoom_x
- attr_accessor :fog_zoom_y
- attr_accessor :fog_variance
- attr_accessor :fade_speed
- attr_accessor :fog_switch
- include THEO::FOG
- def load_fog_infos
- @fog_name = nil
- @fog_opacity = DEFAULT_OPACITY
- @fog_x = DEFAULT_LOOP_X
- @fog_y = DEFAULT_LOOP_Y
- @fog_blend = 0
- @fog_zoom_x = 1.0
- @fog_zoom_y = 1.0
- @fog_variance = 0
- @fade_speed = 0
- @fog_switch = 0
- self.note.split(/[\r\n]+/).each do |line|
- case line
- when REGEXP::NAME
- @fog_name = $1.to_s
- when REGEXP::OPACITY
- @fog_opacity = $1.to_i
- when REGEXP::LOOP_X_PLUS
- @fog_x = $1.to_i
- when REGEXP::LOOP_Y_PLUS
- @fog_y = $1.to_i
- when REGEXP::LOOP_X_MINUS
- @fog_x = -($1.to_i)
- when REGEXP::LOOP_Y_MINUS
- @fog_y = -($1.to_i)
- when REGEXP::BLEND_TYPE
- @fog_blend = [[$1.to_i,0].max,2].min
- when REGEXP::ZOOM_X
- @fog_zoom_x = $1.to_i * 0.01
- when REGEXP::ZOOM_Y
- @fog_zoom_y = $1.to_i * 0.01
- when REGEXP::VARIANCE
- @fog_variance = $1.to_i
- when REGEXP::FADE_SPEED
- @fade_speed = $1.to_i
- when REGEXP::SWITCH_ID
- @fog_switch = $1.to_i
- end
- end
- end
- def no_fog?
- self.note.include?("<no fog>")
- end
- end
- class Game_Map
- attr_accessor :fog_name
- attr_accessor :fog_opacity
- attr_accessor :fog_x
- attr_accessor :fog_y
- attr_accessor :fog_blend
- attr_accessor :fog_zoom_x
- attr_accessor :fog_zoom_y
- attr_accessor :fog_variance
- attr_accessor :fade_speed
- attr_accessor :fog_switch
- alias pre_fog_setup setup
- def setup(map_id)
- pre_fog_setup(map_id)
- setup_fog
- end
- def setup_fog
- @map.load_fog_infos
- @fog_name = @map.fog_name
- @fog_opacity = @map.fog_opacity
- @fog_x = @map.fog_x
- @fog_y = @map.fog_y
- @fog_blend = @map.fog_blend
- @fog_zoom_x = @map.fog_zoom_x
- @fog_zoom_y = @map.fog_zoom_y
- @fog_variance = @map.fog_variance
- @fade_speed = @map.fade_speed
- @fog_switch = @map.fog_switch
- end
- def no_fog?
- @map.no_fog?
- end
- end
- class Global_Fog
- attr_accessor :name
- attr_accessor :opacity
- attr_accessor :ox
- attr_accessor :oy
- attr_accessor :blend
- attr_accessor :zoom_x
- attr_accessor :zoom_y
- attr_accessor :variance
- attr_accessor :speed
- include THEO::FOG
- def initialize
- clear
- end
- def clear
- @name = ""
- @opacity = DEFAULT_OPACITY
- @ox = DEFAULT_LOOP_X
- @oy = DEFAULT_LOOP_Y
- @blend = 0
- @zoom_x = 1.0
- @zoom_y = 1.0
- @variance = 0
- @speed = 0
- end
- def used?
- !@name.empty?
- end
- end
- class Game_System
- attr_reader :fog
- alias pre_fogscreen_init initialize
- def initialize
- pre_fogscreen_init
- init_fog
- end
- def init_fog
- @fog = Global_Fog.new
- end
- end
- class Game_Interpreter
- def fog
- $game_system.fog
- end
- end
- class Scene_Map < Scene_Base
- alias pre_fog_transfer pre_transfer
- def pre_transfer
- pre_fog_transfer
- @spriteset.dispose_fog
- end
- alias post_fog_transfer post_transfer
- def post_transfer
- @spriteset.create_fog
- post_fog_transfer
- end
- end
- class PlaneFog < Plane
- include THEO::FOG
- def update
- self.bitmap = Cache.picture($game_system.fog.name)
- self.blend_type = $game_system.fog.blend
- self.zoom_x = $game_system.fog.zoom_x
- self.zoom_y = $game_system.fog.zoom_y
- self.ox += $game_system.fog.ox
- self.oy += $game_system.fog.oy
- self.visible = !$game_switches[GLOBAL_DISABLE_ID]
- end
- end
- class Spriteset_Map
- alias pre_fog_create_viewports create_viewports
- def create_viewports
- pre_fog_create_viewports
- create_fog
- end
- def create_fog
- if $game_system.fog.used?
- create_global_fog
- else
- create_map_fog
- end
- @count = 0
- end
- def create_global_fog
- @fog = PlaneFog.new(@viewport2)
- @fog.opacity = $game_system.fog.opacity
- @opacity_f = @fog.opacity
- end
- def create_map_fog
- return unless $game_map.fog_name
- @fog = Plane.new(@viewport2)
- @fog.z = -1
- @fog.bitmap = Cache.picture($game_map.fog_name)
- @fog.opacity = $game_map.fog_opacity
- @fog.blend_type = $game_map.fog_blend
- @fog.zoom_x = $game_map.fog_zoom_x
- @fog.zoom_y = $game_map.fog_zoom_y
- @fog_variance = $game_map.fog_variance
- @fog_fade_speed = $game_map.fade_speed
- @opacity_f = @fog.opacity
- @fog.visible = !$game_switches[$game_map.fog_switch]
- end
- alias pre_fog_update update
- def update
- pre_fog_update
- update_fog
- end
- def update_fog
- if (@fog.is_a?(Plane) ? !@fog.disposed? : @fog)
- if @fog.is_a?(PlaneFog)
- @fog.update
- @fog_variance = $game_system.fog.variance
- @fog_fade_speed = $game_system.fog.speed
- if @opacity_f != $game_system.fog.opacity
- @fog.opacity = $game_system.fog.opacity
- @opacity_f = @fog.opacity
- end
- else
- @fog.ox += $game_map.fog_x
- @fog.oy += $game_map.fog_y
- @fog.visible = !$game_switches[$game_map.fog_switch]
- end
- update_fog_opacity
- end
- check_map_fog_existence
- end
- def update_fog_opacity
- derajat = (@count.to_f/180) * Math::PI
- @fog.opacity = @opacity_f + (Math.sin(derajat) * @fog_variance)
- @count += (rand * @fog_fade_speed)
- end
- def check_map_fog_existence
- if $game_map.no_fog?
- dispose_fog
- return
- end
- if $game_system.fog.used? && (!@fog.is_a?(PlaneFog) || @fog.nil?)
- dispose_fog
- create_global_fog
- elsif !$game_system.fog.used? && (@fog.is_a?(PlaneFog) || @fog.nil?)
- dispose_fog
- create_map_fog
- end
- end
- alias pre_fog_dispose dispose
- def dispose
- pre_fog_dispose
- dispose_fog
- end
- def dispose_fog
- @fog.dispose if @fog
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment