Facebook
From arev, 1 Week ago, written in Ruby.
Embed
Download Paste or View Raw
Hits: 28
  1. #=============================================================================
  2. # ** Lighting Effects with Additional Fogs
  3. #
  4. # ** coded by arevulopapo, concept by Ludzix
  5. #    Jul 8th 2007
  6. #=============================================================================
  7. # This script automatically sets a light map and a shadow map for every game map
  8. # if required files are present in the fogs folder. For shadow maps the file must
  9. # be named sID.png, where ID is the Map ID. For example: for map with ID of 3
  10. # the file should be named s3.png (only .png files are accepted for shadow maps).
  11. # For light maps the file can be in either .png, .jpg or .bmp format. The name
  12. # of the light map file must include the type of blending in which the file will
  13. # be displayed over the game map. General file name is lID b_TYPE.EXT, where
  14. # ID is the Map ID, TYPE is the blending type (0 - normal, 1 - additive,
  15. # 2 - substractive) and EXT is of the extensions mentioned above.
  16. # For game map No. 3, and additive blending the file should be named as follows:
  17. # l3 b_1.jpg (the SPACE between Map ID and blending is required).
  18. # Both maps are displayed over the tilemap/events and under the fog.
  19. #=============================================================================
  20. class Spriteset_Map
  21.  
  22.   alias ssm_initialize initialize
  23.   alias ssm_dispose dispose
  24.   alias ssm_update update
  25.  
  26.   def initialize
  27.     @shadow_layer = Sprite.new
  28.     @shadow_layer.z = 2900
  29.     @lighting_layer = Sprite.new
  30.     @lighting_layer.z = 2950
  31.     ssm_initialize
  32.   end
  33.  
  34.   def dispose
  35.     @shadow_layer.dispose
  36.     @lighting_layer.dispose
  37.     ssm_dispose
  38.   end
  39.  
  40.   def update
  41.     shadow = "Graphics/Fogs/s" + $game_map.map_id.to_s
  42.     light = "Graphics/Fogs/l" + $game_map.map_id.to_s
  43.     if FileTest.exist?(shadow + ".png")
  44.       @shadow_layer.bitmap = RPG::Cache.fog("s" + $game_map.map_id.to_s, 0)
  45.     else
  46.       @shadow_layer.bitmap = nil
  47.     end
  48.     if FileTest.exist?(light + " b_0.png") or FileTest.exist?(light + " b_0.jpg") or FileTest.exist?(light + " b_0.bmp")
  49.       @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s, 0)
  50.       @lighting_layer.blend_type = 0
  51.     elsif FileTest.exist?(light + " b_1.png") or FileTest.exist?(light + " b_1.jpg") or FileTest.exist?(light + " b_1.bmp")
  52.       @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s + " b_1", 0)
  53.       @lighting_layer.blend_type = 1
  54.     elsif FileTest.exist?(light + " b_2.png") or FileTest.exist?(light + " b_2.jpg") or FileTest.exist?(light + " b_2.bmp")
  55.       @lighting_layer.bitmap = RPG::Cache.fog("l" + $game_map.map_id.to_s + " b_2", 0)
  56.       @lighting_layer.blend_type = 2
  57.     else
  58.       @lighting_layer.bitmap = nil
  59.     end
  60.     @shadow_layer.ox = $game_map.display_x / 4
  61.     @shadow_layer.oy = $game_map.display_y / 4
  62.     @lighting_layer.ox = $game_map.display_x / 4
  63.     @lighting_layer.oy = $game_map.display_y / 4
  64.     ssm_update
  65.   end
  66.  
  67. end