Advertisement
Hime-Works

Remove/Restore Map Shadows

Apr 30th, 2013
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.02 KB | None | 0 0
  1. class Game_System
  2.  
  3.   attr_reader :remove_shadows
  4.  
  5.   alias :th_remove_shadows_initialize :initialize
  6.   def initialize
  7.     th_remove_shadows_initialize
  8.     @remove_shadows = false
  9.   end
  10.  
  11.   def remove_shadows=(val)
  12.     @remove_shadows = val
  13.     @remove_shadows ? $game_map.remove_shadows : $game_map.restore_shadows
  14.   end
  15. end
  16.  
  17. class Game_Map
  18.   alias :th_remove_shadows_setup :setup
  19.   def setup(map_id)
  20.     th_remove_shadows_setup(map_id)
  21.     @memory_shadow_map = data.clone
  22.     remove_shadows if $game_system.remove_shadows
  23.   end
  24.  
  25.   def remove_shadows
  26.     for x in 0...data.xsize
  27.       for y in 0...data.ysize
  28.         # check lowest 4 bits
  29.         if (data[x,y,3] & 0xF) != 0
  30.           # data stored in 2 bytes. Zero out the shadow bits
  31.           data[x,y,3] &= 0xFFF0
  32.         end
  33.       end
  34.     end
  35.   end
  36.  
  37.   def restore_shadows
  38.     for x in 0 ... @memory_shadow_map.xsize
  39.       for y in 0... @memory_shadow_map.ysize
  40.         data[x,y,3] = @memory_shadow_map[x, y, 3]
  41.       end
  42.     end
  43.   end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement