Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin =========================================================================
- Dekita's v1.2
- ★ FOG™ ★
- ================================================================================
- Script Information:
- ====================
- This script allows for upto 3 different fogs to be displayed on the map and in
- battle.
- I have limited it to 3 for game performance sake, also 3 is more than
- enough imo...
- Features :~
- Upto 3 seperate fogs,(per map)
- multiple options for each fog,
- e.g color / scroll speed / opacity / z value (importance)
- Note : if z value is lower than 0 it will be shown under the map like a parallax
- ================================================================================
- ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- ================================================================================
- 1. You must give credit to "Dekita"
- 2. You are NOT allowed to repost this script.(or modified versions)
- 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
- 4. You are NOT allowed to use this script for Commercial games.
- 5. ENJOY!
- "FINE PRINT"
- By using this script you hereby agree to the above terms and conditions,
- if any violation of the above terms occurs "legal action" may be taken.
- Not understanding the above terms and conditions does NOT mean that
- they do not apply to you.
- If you wish to discuss the terms and conditions in further detail you can
- contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
- ================================================================================
- History:
- =========
- D /M /Y
- 14/o1/2o13 - improved efficiency,
- 13/o1/2o13 - fixed bug with $BTEST,
- 12/o1/2o13 - finished,
- ??/o1/2o13 - started,
- ================================================================================
- Known Bugs:
- ============
- N/A
- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- If a new bug is found please contact me at
- http://dekitarpg.wordpress.com/
- ================================================================================
- INSTRUCTIONS:
- ==============
- Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
- ================================================================================
- Credit and Thanks to :
- =======================
- Hyde - for asking me to write this ^_^
- ================================================================================
- NOTETAGS: (map noteboxes)
- ==========
- <fog id: NAME>
- NAME = the name of the fog file (must be in parallax folder)
- <id move: x, y>
- x / y = how mych the fog moves per frame update
- <id opac: opacity>
- opacity = the transparency of the graphic
- <id col: red,green,blue,alpha>
- reg / green / blue / aplha = the color / visibility values
- <id z: z_value>
- z_value = the importance of the fog. below 0 will show the image behind the map.
- id can be : a / b / c
- e.g
- <fog a: FOG_NAME>
- <a move: 1, 1>
- <a opac: 150>
- <a z: 50>
- =end #=========================================================================#
- module FOG_By_Dekita
- Default_Fog_A_z = 51
- Default_Fog_B_z = 52
- Default_Fog_C_z = 53
- Show_In_Battle = true
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================#
- # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
- # YES?\.\. #
- # OMG, REALLY? \| #
- # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
- # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
- #===============================================================================#
- $imported = {} if $imported.nil?
- $imported[:Dekita_FOG] = true
- #===============================================================================#
- class RPG::Map
- #===============================================================================#
- attr_reader(:can_fog)
- attr_reader(:fog_a_name)
- attr_reader(:fog_a_move)
- attr_reader(:fog_a_opac)
- attr_reader(:fog_a_z)
- attr_reader(:fog_a_color)
- attr_reader(:fog_b_name)
- attr_reader(:fog_b_move)
- attr_reader(:fog_b_opac)
- attr_reader(:fog_b_z)
- attr_reader(:fog_b_color)
- attr_reader(:fog_c_name)
- attr_reader(:fog_c_move)
- attr_reader(:fog_c_opac)
- attr_reader(:fog_c_z)
- attr_reader(:fog_c_color)
- def get_fog_info
- @can_fog = false
- @fog_a_name = ""
- @fog_a_move = [0, 0]
- @fog_a_opac = 255
- @fog_a_z = FOG_By_Dekita::Default_Fog_A_z
- @fog_a_color = nil
- @fog_b_name = ""
- @fog_b_move = [0, 0]
- @fog_b_opac = 255
- @fog_b_z = FOG_By_Dekita::Default_Fog_B_z
- @fog_b_color = nil
- @fog_c_name = ""
- @fog_c_move = [0, 0]
- @fog_c_opac = 255
- @fog_c_z = FOG_By_Dekita::Default_Fog_C_z
- @fog_c_color = nil
- self.note.split(/[\r\n]+/).each { |line| case line
- when /<fog a: (.*)/i ; @can_fog = true ; @fog_a_name = $1.to_s
- when /<a move: (.*), (.*)>/i ; @fog_a_move = [$1.to_i, $2.to_i]
- when /<a opac: (.*)/i ; @fog_a_opac = $1.to_i
- when /<a z: (.*)/i ; @fog_a_z = $1.to_i
- when /<a col: (.*),(.*),(.*),(.*)>/im
- @fog_a_color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)
- when /<fog b: (.*)/i ; @can_fog = true ; @fog_b_name = $1.to_s
- when /<b move: (.*), (.*)>/i ; @fog_b_move = [$1.to_i, $2.to_i]
- when /<b opac: (.*)/i ; @fog_b_opac = $1.to_i
- when /<b z: (.*)/i ; @fog_b_z = $1.to_i
- when /<b col: (.*),(.*),(.*),(.*)>/im
- @fog_b_color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)
- when /<fog c: (.*)/i ; @can_fog = true ; @fog_c_name = $1.to_s
- when /<c move: (.*), (.*)>/i ; @fog_c_move = [$1.to_i, $2.to_i]
- when /<c opac: (.*)/i ; @fog_c_opac = $1.to_i
- when /<c z: (.*)/i ; @fog_c_z = $1.to_i
- when /<c col: (.*),(.*),(.*),(.*)>/im
- @fog_c_color = Color.new($1.to_i,$2.to_i,$3.to_i,$4.to_i)
- end ; } # self.note.split
- end
- end
- #===============================================================================#
- class Game_Map
- #===============================================================================#
- alias :fogsys :setup
- alias :sdp_for_fog :set_display_pos
- alias :s_d_for_fog :scroll_down
- alias :s_l_for_fog :scroll_left
- alias :s_r_for_fog :scroll_right
- alias :s_u_for_fog :scroll_up
- alias :update_for_fog :update_parallax
- attr_reader(:has_fog)
- attr_reader(:fog_a_name)
- attr_reader(:fog_a_move)
- attr_reader(:fog_a_opacity)
- attr_reader(:fog_a_z)
- attr_reader(:fog_a_color)
- attr_reader(:fog_b_name)
- attr_reader(:fog_b_move)
- attr_reader(:fog_b_opacity)
- attr_reader(:fog_b_z)
- attr_reader(:fog_b_color)
- attr_reader(:fog_c_name)
- attr_reader(:fog_c_move)
- attr_reader(:fog_c_opacity)
- attr_reader(:fog_c_z)
- attr_reader(:fog_c_color)
- def setup(map_id)
- fogsys(map_id)
- @map.get_fog_info
- @has_fog = @map.can_fog
- setup_fog_a
- setup_fog_b
- setup_fog_c
- end
- def setup_fog_a
- @fog_a_name = @map.fog_a_name
- @fog_a_move = @map.fog_a_move
- @fog_a_opacity = @map.fog_a_opac
- @fog_a_z = @map.fog_a_z
- @fog_a_color = @map.fog_a_color
- @fog_a_loop_x = @fog_a_move[0] != 0 ? true : false
- @fog_a_loop_y = @fog_a_move[1] != 0 ? true : false
- @fog_a_sx = @fog_a_move[0]
- @fog_a_sy = @fog_a_move[1]
- @fog_a_x = 0
- @fog_a_y = 0
- end
- def setup_fog_b
- @fog_b_name = @map.fog_b_name
- @fog_b_move = @map.fog_b_move
- @fog_b_opacity = @map.fog_b_opac
- @fog_b_z = @map.fog_b_z
- @fog_b_color = @map.fog_b_color
- @fog_b_loop_x = @fog_b_move[0] != 0 ? true : false
- @fog_b_loop_y = @fog_b_move[1] != 0 ? true : false
- @fog_b_sx = @fog_b_move[0]
- @fog_b_sy = @fog_b_move[1]
- @fog_b_x = 0
- @fog_b_y = 0
- end
- def setup_fog_c
- @fog_c_name = @map.fog_c_name
- @fog_c_move = @map.fog_c_move
- @fog_c_opacity = @map.fog_c_opac
- @fog_c_z = @map.fog_c_z
- @fog_c_color = @map.fog_c_color
- @fog_c_loop_x = @fog_c_move[0] != 0 ? true : false
- @fog_c_loop_y = @fog_c_move[1] != 0 ? true : false
- @fog_c_sx = @fog_c_move[0]
- @fog_c_sy = @fog_c_move[1]
- @fog_c_x = 0
- @fog_c_y = 0
- end
- def set_display_pos(x, y)
- sdp_for_fog(x, y)
- @fog_a_x = x
- @fog_a_y = y
- @fog_b_x = x
- @fog_b_y = y
- @fog_c_x = x
- @fog_c_y = y
- end
- def scroll_down(distance)
- last_y = @display_y
- s_d_for_fog(distance)
- fog_scroll_down(distance, last_y)
- end
- def fog_scroll_down(distance, last_y)
- value = loop_vertical? ? distance : @display_y - last_y
- @fog_a_y += value ; @fog_b_y += value ; @fog_c_y += value
- end
- def scroll_left(distance)
- last_x = @display_x
- s_l_for_fog(distance)
- fog_scroll_left(distance, last_x)
- end
- def fog_scroll_left(distance, last_x)
- value = loop_horizontal? ? -distance : @display_x - last_x
- @fog_a_x += value ; @fog_b_x += value ; @fog_c_x += value
- end
- def scroll_right(distance)
- last_x = @display_x
- s_r_for_fog(distance)
- fog_scroll_right(distance, last_x)
- end
- def fog_scroll_right(distance, last_x)
- value = loop_horizontal? ? distance : @display_x - last_x
- @fog_a_x += value ; @fog_b_x += value ; @fog_c_x += value
- end
- def scroll_up(distance)
- last_y = @display_y
- s_u_for_fog(distance)
- fog_scroll_down(distance, last_y)
- end
- def fog_scroll_down(distance, last_y)
- value = loop_vertical? ? -distance : @display_y - last_y
- @fog_a_y += value ; @fog_b_y += value ; @fog_c_y += value
- end
- def update_parallax
- update_for_fog
- update_fog
- end
- def update_fog
- @fog_a_x += @fog_a_sx / 128.0 if @fog_a_loop_x
- @fog_a_y += @fog_a_sy / 128.0 if @fog_a_loop_y
- @fog_b_x += @fog_b_sx / 128.0 if @fog_b_loop_x
- @fog_b_y += @fog_b_sy / 128.0 if @fog_b_loop_y
- @fog_c_x += @fog_c_sx / 128.0 if @fog_c_loop_x
- @fog_c_y += @fog_c_sy / 128.0 if @fog_c_loop_y
- end
- def fog_a_x
- @fog_a_x
- end
- def fog_a_y
- @fog_a_y
- end
- def fog_b_x
- @fog_b_x
- end
- def fog_b_y
- @fog_b_y
- end
- def fog_c_x
- @fog_c_x
- end
- def fog_c_y
- @fog_c_y
- end
- end
- #==============================================================================
- class Plane_FOG < Plane
- #==============================================================================
- def initialize(fog_id = "", fog_type)
- return unless fog_id != ""
- return if $BTEST
- super(nil)
- self.bitmap = Cache.parallax(fog_id)
- @fog_type = fog_type
- initialize_values
- update
- end
- def initialize_values
- case @fog_type
- when :type_a
- self.z = $game_map.fog_a_z
- self.opacity = $game_map.fog_a_opacity
- self.color = $game_map.fog_a_color if $game_map.fog_a_color != nil
- when :type_b
- self.z = $game_map.fog_b_z
- self.opacity = $game_map.fog_b_opacity
- self.color = $game_map.fog_b_color if $game_map.fog_b_color != nil
- when :type_c
- self.z = $game_map.fog_c_z
- self.opacity = $game_map.fog_c_opacity
- self.color = $game_map.fog_c_color if $game_map.fog_c_color != nil
- end
- end
- def get_position_update
- case @fog_type
- when :type_a
- self.ox = $game_map.fog_a_x * 32 + $game_map.fog_a_move[0]
- self.oy = $game_map.fog_a_y * 32 + $game_map.fog_a_move[1]
- when :type_b
- self.ox = $game_map.fog_b_x * 32 + $game_map.fog_b_move[0]
- self.oy = $game_map.fog_b_y * 32 + $game_map.fog_b_move[1]
- when :type_c
- self.ox = $game_map.fog_c_x * 32 + $game_map.fog_c_move[0]
- self.oy = $game_map.fog_c_y * 32 + $game_map.fog_c_move[1]
- end
- end
- def update
- return if self.disposed?
- get_position_update
- case @fog_type
- when :type_a
- self.opacity = $game_map.fog_a_opacity if self.opacity != $game_map.fog_a_opacity
- when :type_b
- self.opacity = $game_map.fog_b_opacity if self.opacity != $game_map.fog_b_opacity
- when :type_c
- self.opacity = $game_map.fog_c_opacity if self.opacity != $game_map.fog_c_opacity
- end
- end
- # def dispose
- # super
- # end
- end
- #==============================================================================
- module Planeset_FOG
- #==============================================================================
- def create_fog
- gm = $game_map
- create_fog_a(gm)
- create_fog_b(gm)
- create_fog_c(gm)
- end
- def create_fog_a(gm)
- @fogg_a = Plane_FOG.new(gm.fog_a_name,:type_a)
- @fogg_a_name = gm.fog_a_name
- end
- def create_fog_b(gm)
- @fogg_b = Plane_FOG.new(gm.fog_b_name,:type_b)
- @fogg_b_name = gm.fog_b_name
- end
- def create_fog_c(gm)
- @fogg_c = Plane_FOG.new(gm.fog_c_name,:type_c)
- @fogg_c_name = gm.fog_c_name
- end
- def dispose_fog
- @fogg_a.dispose if @fogg_a != nil
- @fogg_b.dispose if @fogg_b != nil
- @fogg_c.dispose if @fogg_c != nil
- end
- def update_fog
- if @fogg_a_name != $game_map.fog_a_name
- @fogg_a.dispose if @fogg_a != nil
- create_fog_a($game_map)
- end
- if @fogg_b_name != $game_map.fog_b_name
- @fogg_b.dispose if @fogg_b != nil
- create_fog_b($game_map)
- end
- if @fogg_c_name != $game_map.fog_c_name
- @fogg_c.dispose if @fogg_c != nil
- create_fog_c($game_map)
- end
- @fogg_a.update if @fogg_a != nil
- @fogg_b.update if @fogg_b != nil
- @fogg_c.update if @fogg_c != nil
- end
- end
- #==============================================================================
- class Spriteset_Map
- #==============================================================================
- include Planeset_FOG
- alias :initializefogg :initialize
- alias :disposefogg :dispose
- alias :updatefogg :update
- def initialize
- create_fog
- initializefogg
- end
- def dispose
- disposefogg
- dispose_fog
- end
- def update
- updatefogg
- update_fog
- end
- end
- #==============================================================================
- class Spriteset_Battle
- #==============================================================================
- include Planeset_FOG
- alias :initializefogg :initialize
- alias :disposefogg :dispose
- alias :updatefogg :update
- def initialize
- create_fog
- initializefogg if FOG_By_Dekita::Show_In_Battle
- end
- def dispose
- disposefogg
- dispose_fog
- end
- def update
- updatefogg
- update_battle_fog
- end
- def update_battle_fog
- return unless FOG_By_Dekita::Show_In_Battle
- $game_map.update_fog
- update_fog
- end
- end
- #===============================================================================#
- # - SCRIPT END - #
- #===============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #===============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement