Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 13.14 KB | None | 0 0
  1. #===============================================================
  2. # ● [VX] ◦ Multiple Fogs + Casha Edit ◦ □
  3. # * Use unlimited layers of fog *
  4. #--------------------------------------------------------------
  5. # ◦ by Woratana [woratana@hotmail.com]
  6. # ◦ Thaiware RPG Maker Community
  7. # ◦ Released on: 13/05/2008
  8. # ◦ Version: 1.1
  9. #--------------------------------------------------------------
  10.  
  11. #==================================================================
  12. # ** HOW TO USE **
  13. # * use event command 'Script...' for the any script line below~
  14. #-----------------------------------------------------------------
  15. #
  16. #---------------------------------------------------------------
  17. # ** SETUP FOG PROPERTIES & SHOW FOG **
  18. # * You have to setup fog properties, before show fog~
  19. #-------------------------------------------------------------
  20. # * There are 3 ways to setup fog properties:
  21. # >> Setup Fog [Custom]:
  22. # $fog.name = 'image_name' # Image file name, must be in fog image path (setup path below).
  23. # $fog.hue = (integer) # Fog's hue. 0 - 360, 0 for no hue.
  24. # $fog.tone = [red, green, blue, gray] # Fog's tone color.
  25. # $fog.opacity = (integer) # Fog's opacity. 0 - 255, you will not see fog in 0.
  26. # $fog.blend = (0, 1, or 2) # Fog's blend type. 0 for Normal, 1 for Add, 2 for Subtract.
  27. # $fog.zoom = (integer) # Fog's size (in %). 100 for normal size.
  28. # $fog.sx = (+ or - integer) # Fog's horizontal move speed.
  29. # $fog.sy = (+ or - integer) # Fog's vertical move speed.
  30. #
  31. # >> Setup Fog [From Preset]:
  32. # (You can setup fog presets, in part FOG PRESET SETUP below)
  33. # $fog.load_preset(preset_id)
  34. #
  35. # >> Setup Fog [From Fog that showing]:
  36. # $fog.load_fog(fog_id)
  37. #
  38. #--------------------------------------------------------------
  39. # ** SHOW FOG **
  40. #-------------------------------------------------------------
  41. # After setup the fog, show fog by call script:
  42. # $fog.show(fog_id)
  43. #
  44. # In case you want to show new fog on same ox, oy, tone as old fog. Call Script:
  45. # $fog.show(old_fog_id, false)
  46. #
  47. # * fog_id: the ID number you want to put this fog in.
  48. # (It can be any positive number or zero)
  49. #
  50. # After you show fog, the fog properties you've set will replace with default setting.
  51. # (You can setup default setting, in part FOG DEFAULT SETTING below)
  52. #
  53. #--------------------------------------------------------------
  54. # ** DELETE FOG **
  55. #-------------------------------------------------------------
  56. # You can delete 1 or more fog(s) at a time by call script:
  57. # $fog.delete(fog_id, fog_id, fog_id, ...)
  58. #
  59. #---------------------------------------------------------------
  60. # ** OLD FOG CONTROL EVENT COMMANDS **
  61. #-------------------------------------------------------------
  62. # Change Fog Tone:
  63. # $game_map.fogtone(fog_id, [red, green, blue, gray], duration)
  64. # e.g. $game_map.fogtone(1, [100,200,-100,0], 10)
  65.  
  66. # Change Fog Opacity:
  67. # $game_map.fogopac(fog_id, new_opacity, duration)
  68. # e.g. $game_map.fogopac(2, 200, 10)
  69. #
  70. #---------------------------------------------------------------
  71. # ** ADDITIONAL SETTINGS **
  72. #-------------------------------------------------------------
  73. # Change Fog Image's Path:
  74. # $game_map.fog_path = 'image_path'
  75. # e.g. $game_map.fog_path = 'Graphics/Pictures/'
  76.  
  77. # Turn ON/OFF [Automatically clear all fogs when transfer player]:
  78. # $game_map.fog_reset = (true / false)
  79. #
  80. #===============================================================
  81.  
  82. #==================================================================
  83. # START ** MULTIPLE FOG SETUP **
  84. #==================================================================
  85. class Game_Map
  86.   alias wora_mulfog_gammap_ini initialize
  87.   def initialize
  88.     wora_mulfog_gammap_ini
  89.    
  90.     #==================================================================
  91.     # ** MULTIPLE FOG SETUP ** SETTINGS
  92.     #--------------------------------------------------------------
  93.     @fog_path = 'Graphics/Pictures/'
  94.     # Fog image's path
  95.     @fog_reset = true # (true or false)
  96.     # Automatically clear all multiple fogs when transfer player
  97.     #==================================================================
  98.    
  99.     @mulfog_name = []
  100.     @mulfog_hue = []
  101.     @mulfog_opacity = []
  102.     @mulfog_blend_type = []
  103.     @mulfog_zoom = []
  104.     @mulfog_sx = []
  105.     @mulfog_sy = []
  106.     @mulfog_ox = []
  107.     @mulfog_oy = []
  108.     @mulfog_tone = []
  109.     @mulfog_tone_target = []
  110.     @mulfog_tone_duration = []
  111.     @mulfog_opacity_duration = []
  112.     @mulfog_opacity_target = []
  113.   end
  114. end
  115. class Wora_Multiple_Fog
  116.   def set_default
  117.     #==================================================================
  118.     # ** MULTIPLE FOG SETUP ** FOG DEFAULT SETTING
  119.     #--------------------------------------------------------------
  120.     @name = ''
  121.     @hue = 0
  122.     @opacity = 64
  123.     @blend = 0
  124.     @zoom = 200
  125.     @sx = 0
  126.     @sy = 0
  127.     @tone = [0,0,0,0]
  128.     #==================================================================
  129.   end
  130.  
  131.   def load_preset(preset_id)
  132.     case preset_id
  133.     #==================================================================
  134.     # ** MULTIPLE FOG SETUP ** FOG PRESET SETUP
  135.     #--------------------------------------------------------------
  136.     when 1 # Preset ID 1
  137.       @name = '001-Fog01'
  138.       @hue = 0
  139.       @tone = [-150,-150,-150,0]
  140.       @opacity = 120
  141.       @blend = 0
  142.       @zoom = 150
  143.       @sx = 3
  144.       @sy = 0
  145.     when 2 # Preset ID 2
  146.       @name = '002-Clouds01'
  147.       @hue = 0
  148.       @tone = [0,0,0,0]
  149.       @opacity = 200
  150.       @blend = 2
  151.       @zoom = 200
  152.       @sx = -2
  153.       @sy = -2
  154.     when 3 # Preset ID 3
  155.       @name = 'ForestShade'
  156.       @hue = 0
  157.       @tone = [0,0,0,0]
  158.       @opacity = 41
  159.       @blend = 0
  160.       @zoom = 100
  161.       @sx = 0
  162.       @sy = 0
  163.     when 4 # Preset ID 4
  164.       @name = 'ak47lol_rain'
  165.       @hue = 0
  166.       @tone = [0,0,0,0]
  167.       @opacity = 190
  168.       @blend = 1
  169.       @zoom = 100
  170.       @sx = 0
  171.       @sy = 50
  172.     when 5 # Preset ID 4
  173.       @name = 'ak47lol_rain'
  174.       @hue = 0
  175.       @tone = [0,0,0,0]
  176.       @opacity = 100
  177.       @blend = 2
  178.       @zoom = 130
  179.       @sx = 2
  180.       @sy = 50
  181.     #==================================================================
  182.     end
  183.   end
  184. #==================================================================
  185. # END ** MULTIPLE FOG SETUP **
  186. # * Don't change anything below unless you know what you're doing.
  187. #==================================================================
  188.  
  189.   attr_accessor :name, :hue, :opacity, :blend, :zoom, :sx, :sy, :tone
  190.   def initialize
  191.     set_default
  192.   end
  193.  
  194.   def load_fog(id)
  195.     @name = $game_map.mulfog_name[id].sub($game_map.fog_path, '')
  196.     @hue = $game_map.mulfog_hue[id]
  197.     @opacity = $game_map.mulfog_opacity[id]
  198.     @blend = $game_map.mulfog_blend_type[id]
  199.     @zoom = $game_map.mulfog_zoom[id]
  200.     @sx = $game_map.mulfog_sx[id]
  201.     @sy = $game_map.mulfog_sy[id]
  202.     tn = $game_map.mulfog_tone[id]
  203.     @tone = [tn.red, tn.blue, tn.green, tn.gray]
  204.   end
  205.  
  206.   def show(id, reset_all = true)
  207.     $game_map.mulfog_name[id] = $game_map.fog_path + @name
  208.     $game_map.mulfog_hue[id] = @hue
  209.     $game_map.mulfog_opacity[id] = @opacity
  210.     $game_map.mulfog_blend_type[id] = @blend
  211.     $game_map.mulfog_zoom[id] = @zoom
  212.     $game_map.mulfog_sx[id] = @sx
  213.     $game_map.mulfog_sy[id] = @sy
  214.     $game_map.mulfog_tone[id] = Tone.new(@tone[0], @tone[1], @tone[2], @tone[3])
  215.     if $game_map.mulfog_ox[id].nil? or reset_all
  216.       $game_map.mulfog_ox[id] = 0
  217.       $game_map.mulfog_oy[id] = 0
  218.       $game_map.mulfog_tone_target[id] = Tone.new(0, 0, 0, 0)
  219.       $game_map.mulfog_tone_duration[id] = 0
  220.       $game_map.mulfog_opacity_duration[id] = 0
  221.       $game_map.mulfog_opacity_target[id] = 0
  222.     end
  223.     set_default
  224.   end
  225.  
  226.   def delete(*args)
  227.     args.each do |id|
  228.       $game_map.mulfog_name[id] = ''
  229.     end
  230.   end
  231. end
  232.  
  233. class Game_Interpreter
  234.   alias wora_mulfog_interpret_com201 command_201
  235.   #--------------------------------------------------------------------------
  236.   # * Transfer Player
  237.   #--------------------------------------------------------------------------
  238.   def command_201
  239.     if $game_map.fog_reset
  240.       if @params[0] == 0; id_map = @params[1]
  241.       else; id_map = $game_variables[@params[1]]
  242.       end
  243.       $game_map.clear_mulfog if id_map != @map_id
  244.     end
  245.     wora_mulfog_interpret_com201
  246.   end
  247. end
  248.  
  249. class Game_Map
  250.   attr_accessor :mulfog_name, :mulfog_hue, :mulfog_opacity, :mulfog_blend_type,
  251.   :mulfog_zoom, :mulfog_sx, :mulfog_sy, :mulfog_ox, :mulfog_oy, :mulfog_tone,
  252.   :mulfog_tone_target, :mulfog_tone_duration, :mulfog_opacity_duration,
  253.   :mulfog_opacity_target, :fog_reset, :fog_path
  254.  
  255.   def fogupdate
  256.    @mulfog_name.each_index do |i|
  257.       next if @mulfog_name[i].nil? or @mulfog_name[i] == ''
  258.       # Manage fog scrolling
  259.       @mulfog_ox[i] -= @mulfog_sx[i] / 8.0
  260.       @mulfog_oy[i] -= @mulfog_sy[i] / 8.0
  261.       # Manage change in fog color tone
  262.       if @mulfog_tone_duration[i] >= 1
  263.         d = @mulfog_tone_duration[i]
  264.         target = @mulfog_tone_target[i]
  265.         @mulfog_tone[i].red = (@mulfog_tone[i].red * (d - 1) + target.red) / d
  266.         @mulfog_tone[i].green = (@mulfog_tone[i].green * (d - 1) + target.green) / d
  267.         @mulfog_tone[i].blue = (@mulfog_tone[i].blue * (d - 1) + target.blue) / d
  268.         @mulfog_tone[i].gray = (@mulfog_tone[i].gray * (d - 1) + target.gray) / d
  269.         @mulfog_tone_duration[i] -= 1
  270.       end
  271.       # Manage change in fog opacity level
  272.       if @mulfog_opacity_duration[i] >= 1
  273.         d = @mulfog_opacity_duration[i]
  274.         @mulfog_opacity[i] = (@mulfog_opacity[i] * (d - 1) + @mulfog_opacity_target[i]) / d
  275.         @mulfog_opacity_duration[i] -= 1
  276.       end
  277.     end
  278.   end
  279.   #--------------------------------------------------------------------------
  280.   # * Start Changing Fog Color Tone
  281.   #--------------------------------------------------------------------------
  282.   def fogtone(i, tone, duration)
  283.     duration = duration * 2
  284.     tone = Tone.new(tone[0], tone[1], tone[2], tone[3])
  285.     @mulfog_tone_target[i] = tone.clone
  286.     @mulfog_tone_duration[i] = duration
  287.     if @mulfog_tone_duration[i] == 0
  288.       @mulfog_tone[i] = @mulfog_tone_target[i].clone
  289.     end
  290.   end
  291.   #--------------------------------------------------------------------------
  292.   # * Start Changing Fog Opacity Level
  293.   #--------------------------------------------------------------------------
  294.   def fogopac(i, opacity, duration)
  295.     duration = duration * 2
  296.     @mulfog_opacity_target[i] = opacity * 1.0
  297.     @mulfog_opacity_duration[i] = duration
  298.     if @mulfog_opacity_duration[i] == 0
  299.       @mulfog_opacity[i] = @mulfog_opacity_target[i]
  300.     end
  301.   end
  302.  
  303.   def clear_mulfog
  304.     @mulfog_name.each_index {|i| @mulfog_name[i] = '' }
  305.   end
  306. end
  307. $worale = {} if !$worale
  308. $worale['MutipleFog'] = true
  309. $fog = Wora_Multiple_Fog.new
  310. class Spriteset_Weather
  311.   alias wora_mulfog_sprmap_crepal initialize
  312.   alias wora_mulfog_sprmap_updpal update
  313.   alias wora_mulfog_sprmap_dispal dispose
  314.  
  315.   def initialize(viewport = nil)
  316.     @mulfog = []
  317.     @mulfog_name = []
  318.     @mulfog_hue = []
  319.     wora_mulfog_sprmap_crepal
  320.     @viewport1 = viewport
  321.   end
  322.  
  323.   def update
  324.     wora_mulfog_sprmap_updpal
  325.     $game_map.fogupdate
  326.     $game_map.mulfog_name.each_index do |i|
  327.       next if $game_map.mulfog_name[i].nil?
  328.       # If fog is different than current fog
  329.       if @mulfog_name[i] != $game_map.mulfog_name[i] or @mulfog_hue[i] != $game_map.mulfog_hue[i]
  330.         @mulfog_name[i] = $game_map.mulfog_name[i]
  331.         @mulfog_hue[i] = $game_map.mulfog_hue[i]
  332.         if @mulfog[i].nil?
  333.           @mulfog[i] = Plane.new(@viewport1)
  334.          # @mulfog[i].z = 3000
  335.         end
  336.         if @mulfog[i].bitmap != nil
  337.           @mulfog[i].bitmap.dispose
  338.           @mulfog[i].bitmap = nil
  339.         end
  340.         if @mulfog_name[i] != ''
  341.           @mulfog[i].bitmap = Cache.load_bitmap('', @mulfog_name[i], @mulfog_hue[i])
  342.         end
  343.         Graphics.frame_reset
  344.       end
  345.       next if @mulfog[i].bitmap.nil?
  346.       # Update fog plane
  347.       @mulfog[i].zoom_x = ($game_map.mulfog_zoom[i] / 100.0) if @mulfog[i].zoom_x != ($game_map.mulfog_zoom[i] / 100.0)
  348.       @mulfog[i].zoom_y = ($game_map.mulfog_zoom[i] / 100.0) if @mulfog[i].zoom_y != ($game_map.mulfog_zoom[i] / 100.0)
  349.       @mulfog[i].opacity = $game_map.mulfog_opacity[i] if @mulfog[i].opacity != $game_map.mulfog_opacity[i]
  350.       @mulfog[i].blend_type = $game_map.mulfog_blend_type[i] if @mulfog[i].blend_type != $game_map.mulfog_blend_type[i]
  351.       @mulfog[i].ox = ($game_map.display_x / 8.0 + $game_map.mulfog_ox[i]) if @mulfog[i].ox != ($game_map.display_x / 8.0 + $game_map.mulfog_ox[i])
  352.       @mulfog[i].oy = ($game_map.display_y / 8.0 + $game_map.mulfog_oy[i]) if @mulfog[i].oy != ($game_map.display_y / 8.0 + $game_map.mulfog_oy[i])
  353.       @mulfog[i].tone = $game_map.mulfog_tone[i] if @mulfog[i].tone != $game_map.mulfog_tone[i]
  354.     end
  355.   end
  356.  
  357.   def dispose
  358.     @mulfog.each_index do |i|
  359.       next if @mulfog[i].nil?
  360.       @mulfog[i].bitmap.dispose if !@mulfog[i].bitmap.nil?
  361.       @mulfog[i].dispose
  362.     end
  363.     wora_mulfog_sprmap_dispal
  364.   end
  365. end
  366. #==================================================================
  367. # [END] VX Multiple Fog by Woratana [woratana@hotmail.com]
  368. #==================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement