Advertisement
diamondandplatinum3

Tile Highlight ~ RGSS3

Jan 10th, 2013
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 6.43 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Tile Highlight
  3. #             Version: 1.0
  4. #             Authors: DiamondandPlatinum3
  5. #             Date: January 10, 2013
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #
  9. #    This script allows you to highlight tiles on your map, by doing so that
  10. #    tile will also start flashing.
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. #------------------------------------------------------------------------------
  13. #  Instructions:
  14. #
  15. #   Use the Following Script Calls:
  16. #
  17. #   Script Call:  highlight_player_tile(red, green, blue)
  18. #   This Script Call WIll Highlight the Player Tile, pass in RGB values in place
  19. #   of the Red, Green, Blue.
  20. #
  21. #
  22. #   Script Call:  highlight_event_tile(event_id, red, green, blue)
  23. #   This Script Call will highlight the tile an event is standing on.
  24. #   Replace event_id with the ID of the event.
  25. #
  26. #
  27. #   Script Call:  highlight_map_tile(x, y, red, green, blue)
  28. #   This Script Call will Highlight a Map Tile at a specific positon.
  29. #   Replace X & Y with the posiion you want this to be.
  30. #
  31. #
  32. #
  33. #   Script Call:  unhighlight_player_tile()
  34. #   This Script Call simply unhighlights the actors tile.
  35. #
  36. #  
  37. #   Script Call:  unhighlight_event_tile(event_id)
  38. #   This Script Call Simply unhighlights the tile the event is standing on.
  39. #
  40. #
  41. #   Script Call:  unhighlight_map_tile(x, y)
  42. #   This Script Call Simply unhighlights a specific Map Tile.
  43. #
  44. #
  45. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. #==============================================================================
  56. # ** Game_Interpreter
  57. #------------------------------------------------------------------------------
  58. #  An interpreter for executing event commands. This class is used within the
  59. # Game_Map, Game_Troop, and Game_Event classes.
  60. #==============================================================================
  61.  
  62. class Game_Interpreter
  63.   #--------------------------------------------------------------------------
  64.   # * Highlight Player Tile
  65.   #--------------------------------------------------------------------------
  66.   def highlight_player_tile(red, green, blue)
  67.     return unless SceneManager.scene_is?(Scene_Map)
  68.     return unless red.is_a?(Integer) && green.is_a?(Integer) && blue.is_a?(Integer)
  69.     SceneManager.scene.dp3_add_tile_highlight($game_player.x, $game_player.y, [red, green, blue])    
  70.   end
  71.   #--------------------------------------------------------------------------
  72.   # * Highlight Event Tile
  73.   #--------------------------------------------------------------------------
  74.   def highlight_event_tile(event_id, red, green, blue)
  75.     return unless SceneManager.scene_is?(Scene_Map)
  76.     return unless event_id > 0 && $game_map.events[event_id]
  77.     return unless red.is_a?(Integer) && green.is_a?(Integer) && blue.is_a?(Integer)
  78.     args = [$game_map.events[event_id].x, $game_map.events[event_id].y, [red, green, blue]]
  79.     SceneManager.scene.dp3_add_tile_highlight( *args )    
  80.   end
  81.   #--------------------------------------------------------------------------
  82.   # * Highlight Map Tile
  83.   #--------------------------------------------------------------------------
  84.   def highlight_map_tile(x, y, red, green, blue)
  85.     return unless SceneManager.scene_is?(Scene_Map)
  86.     return unless $game_map.valid?(x, y)
  87.     return unless red.is_a?(Integer) && green.is_a?(Integer) && blue.is_a?(Integer)
  88.     SceneManager.scene.dp3_add_tile_highlight(x, y, [red, green, blue])    
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # * Unhighlight Event Tile
  92.   #--------------------------------------------------------------------------
  93.   def unhighlight_player_tile()
  94.     highlight_player_tile(255, 255, 255)
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Unhighlight Event Tile
  98.   #--------------------------------------------------------------------------
  99.   def unhighlight_event_tile(event_id)
  100.     highlight_event_tile(event_id, 255, 255, 255)
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # * UnHighlight Map Tile
  104.   #--------------------------------------------------------------------------
  105.   def unhighlight_map_tile(x, y)
  106.     highlight_map_tile(x, y, 255, 255, 255)    
  107.   end
  108. end
  109.  
  110.  
  111.  
  112.  
  113.  
  114. #==============================================================================
  115. # ** Scene_Map
  116. #------------------------------------------------------------------------------
  117. #  This class performs the map screen processing.
  118. #==============================================================================
  119.  
  120. class Scene_Map < Scene_Base
  121.   #--------------------------------------------------------------------------
  122.   # * Add Tile Highlight
  123.   #--------------------------------------------------------------------------
  124.   def dp3_add_tile_highlight( x, y, colour )
  125.     @spriteset.dp3_set_flash_tile( x, y, colour ) if @spriteset
  126.   end
  127. end
  128.  
  129.  
  130.  
  131.  
  132. #==============================================================================
  133. # ** Spriteset_Map
  134. #------------------------------------------------------------------------------
  135. #  This class brings together map screen sprites, tilemaps, etc. It's used
  136. # within the Scene_Map class.
  137. #==============================================================================
  138.  
  139. class Spriteset_Map
  140.   #--------------------------------------------------------------------------
  141.   # * Set Flash Tile
  142.   #--------------------------------------------------------------------------
  143.   def dp3_set_flash_tile( x, y, colour )
  144.     if @tilemap
  145.       if @tilemap.flash_data == nil
  146.         @tilemap.flash_data = Table.new($game_map.width, $game_map.height)
  147.       end
  148.       @tilemap.flash_data[x, y] = dp3_convert_rgb_to_hex( *colour )
  149.     end
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * Convert RGB to Hex
  153.   #--------------------------------------------------------------------------
  154.   def dp3_convert_rgb_to_hex( red, green, blue )
  155.     if red    > 255; red    = 255; elsif red    < 0; red    = 0; end
  156.     if green  > 255; green  = 255; elsif green  < 0; green  = 0; end
  157.     if blue   > 255; blue   = 255; elsif blue   < 0; blue   = 0; end
  158.     return ((red & 0xF0) << 4) | (green & 0xF0) | ((blue & 0xF0) >> 4)
  159.   end
  160. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement