Jump to content
brujah236

Minimap opacity when walking behind

Recommended Posts

Posted (edited)

Hi everybody! So I'm finally picking my project back up after several years. I've been pretty much handling everything ok but I've gotten to a point where I need some assistance. I'm using Azraven Minimap script (DL in 2015 so I'm not sure where I got it) which works as intended, however I want to modify the script so it fades when walking behind it like Falcao Pearl ABS skillbar (also being used in my game). Below is my translated and slightly modified version of the script and attached is the demo I got it from. (Cross posted on rpgmakerweb.com)

Spoiler

#==============================================================================#
#                          **Azraven Minimap**                                 #
#------------------------------------------------------------------------------#
#  ** Author: Azraven                                                          #
#  ** Version: 1.5b                                                            #
#  ** Date: 12/24/2012                                                         #
#------------------------------------------------------------------------------#
#  - Description:                                                              #
#     This script adds a mini circular map to the game.                        #
#  - Usage:                                                                    #
#     Paste this script in the "Additional Scripts" section.                   #
#------------------------------------------------------------------------------#
#  - Historic                                                                  #
#     12/24/2012 - Start and end of version 1.0b                               #
#     04/03/2013 - Version 1.5b Bug fixes and addition of new functions.       #
#                * Fixed a bug where it did not correctly check for            #
#                  of certain tiles.                                           #
#                * Fixed a bug where grass (bush) tiles were                   #
#                  presented as blocking.                                      #
#                * Fixed a bug where blocking tiles placed                     #
#                  over grass tiles were represented as passable.              #
#                * Improved code.                                              #
#                + Added the function to show vehicles.                        #
#                + Added the function to show followers.                       #
#                + Added the function to use Region IDs for                    #
#                  hide passable areas.                                        #
#     06/14/2014 * Bug related to "Delete Temporary Event" command             #
#                  adjusted.                                                   #
#                * Clean up the code.                                          #
#                                                                              #
#==============================================================================#
# I used Google translate to translate this from Portuguese into English so I  #
# could understand how to use this script in may game.    ~brujah236           #
#==============================================================================#
module Azraven
  module MiniMap
    #--------------------------------------------------------------------------#
    # SETTINGS                                                                 #
    #--------------------------------------------------------------------------#
    #Minimap tile size, recommended not to use values smaller than 3.
    TileSize = 8
    #--------------------------------------------------------------------------#
    #Adjusting the centering of the mini map, depending on the tile size.
    MapOffset = -4
    #--------------------------------------------------------------------------#
    #Defines the player's color on the map.
    PlayerColor = Color.new(255,0,0)
    #--------------------------------------------------------------------------#
    #Show followers.
    ShowFollowers = true
    #--------------------------------------------------------------------------#
    #Defines the color of followers on the map.
    FollowerColor = Color.new(0,128,255)
    #--------------------------------------------------------------------------#
    #Define whether to show vehicles on the map.
    ShowVehicles = true
    #--------------------------------------------------------------------------#
    #Defines the color of the boat.
    BoatColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the ship's color.
    ShipColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the color of the aircraft.
    AirshipColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the color of objects shown on the map.
    #Objects are NPCs, doors, teleports, chests and whatever else the user can
    #to imagine.
    #To add a new object use the following syntax inside the {}:
    # "tag" => Color.new(R,G,B,A)
    #Where tag is the comment that will be added to that event.
    #Separate each object by "," without the quotes.
    ObjectColor = {"npc" => Color.new(0,255,0),
                  "teleport" => Color.new(150,50,50),
                  "chest" => Color.new(100,100,100),
                  "enemy" => Color.new(255,48,48)}
    #--------------------------------------------------------------------------#
    #Defines the outline color of objects and player.
    BorderColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Opacity of objects shown on the map.
    ObjectLayerOpacity = 255
    #--------------------------------------------------------------------------#
    # Position of the map on the screen.
    #1 = Top left corner.
    #2 = Top right corner.
    #3 = Bottom left corner.
    #4 = Top right corner.
    
    #additional options added by me
    #5 = Left middle.
    #6 = Right middle.
    
    MiniMapCorner = 5
    #--------------------------------------------------------------------------#
    #Defines whether a particular region will show as locked on the minimap.
    #Useful not to reveal "secret passages".
    UseHideRegion = true
    #--------------------------------------------------------------------------#
    #Id of the region if UseHideRegion is true.
    HideRegionId = 60
    #--------------------------------------------------------------------------#
    #Color of the impassable area of the map.
    MapColor = Color.new(200,150,150)
    #--------------------------------------------------------------------------#
    #Outline color of the impassable area of the map.
    MapBorderColor = Color.new(50,50,50)
    #--------------------------------------------------------------------------#
    #Name of the minimap border image file in the Graphics/System folder.
    BorderName = "Border"
    #--------------------------------------------------------------------------#
    #Defines whether to use a background texture.
    UseBGTexture = true
    #--------------------------------------------------------------------------#
    #Name of the image file of the texture used when
    #minimap background in the Graphics/System folder.
    #Note: The image must be inverted.
    BackTextureName = "OldPaper"
    #--------------------------------------------------------------------------#
    #Background fill color if no texture is used.
    BGColor = Color.new( 100, 100, 100)
    #--------------------------------------------------------------------------#
    #Option to fill the external area of the map with a color.
    ClearOutsideArea = true
    #--------------------------------------------------------------------------#
    #Color used to fill the outer area of the map.
    ClearOutsideColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Option to demarcate the limits of the map.
    OutlineMapArea = true
    #--------------------------------------------------------------------------#
    #Color of the demarcation of the limits of the map.
    OutlineMapColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Id of the switch that enables/disables the minimap.
    EnableSwitchId = 195
    #--------------------------------------------------------------------------#
    # END OF CONFIGURATION. #
    #--------------------------------------------------------------------------#
    MiniMapCoords = {1 => [0,0,112,112],
                     2 => [Graphics.width - 112,0,112,112],
                     3 => [0,Graphics.height - 112,112,112],
                     4 => [Graphics.width - 112,Graphics.height - 112,112,112],
                     #additional options added by me
                     5 => [0,(Graphics.height/2) - 56,112,112],
                     6 => [Graphics.width - 112,(Graphics.height/2) - 56,112,112]}
     Tile_X = 0
     Tile_Y = 6
  end
end
#==============================================================================#
#  ** Color Class                                                              #
#==============================================================================#
class Color
  #----------------------------------------------------------------------------#
  # * Inverts the color value
  #----------------------------------------------------------------------------#
  def invert
    r = 255 - self.red
    g = 255 - self.green
    b = 255 - self.blue
    a = self.alpha
    self.set(r, g, b, a)
  end
end


#==============================================================================#
#  ** Mini Map Class                                                           #
#==============================================================================#
class MiniMap
  
  include Azraven::MiniMap
  
  def initialize(viewport)
    @viewport = viewport
    @playercolor = PlayerColor.dup.invert
    @followercolor = FollowerColor.dup.invert
    @boatcolor = BoatColor.dup.invert
    @shipcolor = ShipColor.dup.invert
    @airshipcolor = AirshipColor.dup.invert
    @objectcolor = ObjectColor.dup
    @objectcolor.each_pair do |key, value|
      @objectcolor[key] = value.dup.invert
    end
    @bordercolor = BorderColor.dup.invert
    @mapcolor = MapColor.dup.invert
    @mapbordercolor = MapBorderColor.dup.invert
    @clearoutsidecolor = ClearOutsideColor.dup.invert
    @outlinemapcolor = OutlineMapColor.dup.invert
    @on_map = SceneManager.scene_is?(Scene_Map) ###
    refresh
  end
  
  def refresh
    @map_id = $game_map.map_id
    @backmask = Sprite.new(@viewport)
    @backmask.bitmap = Cache::system("Back_96")
    @backmask.x = @backmask.y = 8
    @backtile = Sprite.new(@viewport)
    @backtile.blend_type = 2
    @backtile.z = 1
    @backtile.x = @backtile.y = -100
    @map = Sprite.new(@viewport)
    @map.z = 2
    @map.blend_type = 2
    @object_layer = Sprite.new(@viewport)
    @object_layer.z = 3
    @object_layer.blend_type = 2
    @object_layer.bitmap = Bitmap.new($game_map.width*TileSize + 112,$game_map.height*TileSize + 112)
    @object_layer.opacity = ObjectLayerOpacity
    @border = Sprite.new(@viewport)
    @border.bitmap = Cache::system(BorderName)
    @border.z = 4
    @border.opacity = 255
    @mask = Cache::system("Mask")
    draw_back
    draw_map
  end
  
  def visible?
    $game_switches[EnableSwitchId]
  end
  
  def draw_map
    
    front = make_map_bitmap(@mapcolor)
    border = make_map_bitmap(@mapbordercolor)
    
    result = Bitmap.new($game_map.width*TileSize + 112, 
                        $game_map.height*TileSize+ 112)
                        
    result.blt(-1, 0, border, border.rect)
    result.blt(1, 0, border, border.rect)
    result.blt(0, -1, border, border.rect)
    result.blt(0, 1, border, border.rect)
    result.blt(0, 0, front, front.rect)
    
    @mapbitmap = result
  end
  
  def draw_back
    bitmap = Bitmap.new($game_map.width*TileSize+112, 
                       $game_map.height*TileSize+112)
    if UseBGTexture
      bit = Cache::system(BackTextureName)
      bitmap.stretch_blt(bitmap.rect, bit, bit.rect)
    else
      bitmap.fill_rect(bitmap.rect, BGColor)
    end
    if ClearOutsideArea
      bitmap.fill_rect(0,0,bitmap.width, 56, @clearoutsidecolor)
      bitmap.fill_rect(0,0,56, bitmap.height, @clearoutsidecolor)
      bitmap.fill_rect(0,bitmap.height-56,bitmap.width, 56, @clearoutsidecolor)
      bitmap.fill_rect(bitmap.width-56,0,56, bitmap.height, @clearoutsidecolor)
    elsif OutlineMapArea
      bitmap.fill_rect(56,55,bitmap.width-112,1,@outlinemapcolor)
      bitmap.fill_rect(55,56,1,bitmap.height-112,@outlinemapcolor)
      bitmap.fill_rect(bitmap.width-56,55,1,bitmap.height-112,@outlinemapcolor)
      bitmap.fill_rect(56,bitmap.height-56,bitmap.width-112,1,@outlinemapcolor)
    end
    @backtilebitmap = bitmap
  end
  
  def draw_object_layer
    for event in $game_map.events.values
      unless event.list.nil?
        for item in event.list
          if item.code == 108 or item.code == 408
            if @objectcolor.has_key?(item.parameters[0])
              draw_object(event.real_x*TileSize+56, 
              event.real_y*TileSize+56, 
              @objectcolor[item.parameters[0]])
            end
          end
        end
      end
    end
    if ShowFollowers
      unless $game_player.vehicle
        $game_player.followers.each do |follower|
          draw_object(follower.real_x*TileSize+56, 
                      follower.real_y*TileSize+56, 
                      @followercolor) if follower.visible?
        end
      end
    end
    if ShowVehicles
      unless $game_map.airship.transparent
        draw_object($game_map.airship.real_x*TileSize+56,
                $game_map.airship.real_y*TileSize+56, 
                @airshipcolor)
      end
      unless $game_map.ship.transparent
        draw_object($game_map.ship.real_x*TileSize+56,
                $game_map.ship.real_y*TileSize+56, 
                @shipcolor)
      end
      unless $game_map.boat.transparent
        draw_object($game_map.boat.real_x*TileSize+56,
                $game_map.boat.real_y*TileSize+56, 
                @boatcolor)
      end        
    end
    draw_object($game_player.real_x*TileSize+56,
                $game_player.real_y*TileSize+56, 
                @playercolor)
  end
  
  def draw_object(x, y, color)
    @object_layer.bitmap.fill_rect(x, y, TileSize, TileSize, @bordercolor)
    @object_layer.bitmap.fill_rect(x+1, y+1, TileSize-2, TileSize-2, color)
    @object_layer.bitmap.clear_rect(x,y,1,1)
    @object_layer.bitmap.clear_rect(x,y+TileSize-1,1,1)
    @object_layer.bitmap.clear_rect(x+TileSize-1,y,1,1)
    @object_layer.bitmap.clear_rect(x+TileSize-1,y+TileSize-1,1,1)
  end
          
  def make_map_bitmap(color)
    bitmap = Bitmap.new($game_map.width*TileSize + 112, 
                       $game_map.height*TileSize + 112)
    for x in 0..$game_map.width - 1
      for y in 0..$game_map.height - 1
        if $game_map.airship_land_ok?(x, y) || $game_map.bush?(x, y)
          if UseHideRegion
            bitmap.fill_rect(x*TileSize+56, 
                             y*TileSize+56,
                             TileSize, TileSize, 
                             color) if $game_map.region_id(x, y) == HideRegionId
          else
             next                  
          end
          if $game_map.bush?(x, y) 
            unless $game_map.passable?(x, y, 4)
               bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
            end
          end
          next
        end
        bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
      end
    end
    bitmap
  end
  
  def update_object_layer
   @object_layer.bitmap.clear
   draw_object_layer
  end
 
  def dispose
    @backmask.dispose
    @backtile.dispose
    @map.dispose
    @object_layer.dispose
    @border.dispose
  end
  
  def update
    if @map_id != $game_map.map_id
      dispose
      @map_id = $game_map.map_id
      refresh
    end
    @backmask.visible = visible? 
    @backtile.visible = visible?
    @map.visible = visible?
    @object_layer.visible = visible?
    @border.visible = visible?
    if visible?
      @map.bitmap = @mapbitmap.dup
      @backtile.bitmap = @backtilebitmap.dup
      sx = $game_player.real_x * (TileSize * -1) + MapOffset
      sy = $game_player.real_y * (TileSize * -1) + MapOffset
      update_object_layer
      @map.x = @backtile.x = @object_layer.x = sx
      @map.y = @backtile.y = @object_layer.y = sy
      @backtile.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect) 
      @map.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
      @object_layer.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
#~     update_minimap_fade ###
    end
  end
  
=begin
  # fade effect when player is behind the minimap
  def update_minimap_fade
    if behind_minimap?
      if self.opacity >= 60
        self.opacity -= 10
        @backmask.opacity = @backtile.opacity = @map.opacity = @object_layer.opacity = @border.opacity = self.opacity
      end
    elsif self.opacity != 255
      self.opacity += 10
      @backmask.opacity = @backtile.opacity = @map.opacity = @object_layer.opacity = @border.opacity = self.opacity
    end
  end
  
  def behind_minimap?
    return false unless @on_map
    px = ($game_player.screen_x / 32).to_i
    py = ($game_player.screen_y / 32).to_i
    9.times.each {|x| return true if px == Tile_X + x and py == Tile_Y}
    return false
  end
=end

end
#==============================================================================#
#  ** Classe Spriteset_Map                                                     #
#==============================================================================#
class Spriteset_Map
  
  alias azraven_mini_map_init initialize
  alias azraven_mini_map_updt update
  alias azraven_mini_map_disp dispose
  
  include Azraven::MiniMap
  
  def initialize
    create_minimap
    azraven_mini_map_init
  end
  
  def create_minimap
    viewport = Viewport.new(Graphics.width - 112,0,112,112)
    viewport.rect.set(MiniMapCoords[MiniMapCorner][0],
                      MiniMapCoords[MiniMapCorner][1],
                      MiniMapCoords[MiniMapCorner][2],
                      MiniMapCoords[MiniMapCorner][3])
    viewport.z = 1 #500
    @minimapa = MiniMap.new(viewport)
  end
  
  def dispose
    azraven_mini_map_disp
    @minimapa.dispose
  end
  
  def update
    azraven_mini_map_updt
    @minimapa.update
  end
end
#==============================================================================#
#  ** Fim do Script                                                            #
#==============================================================================#

 

 

AzravenMiniMap.exe

Edited by brujah236
Updated text

Share this post


Link to post
Share on other sites

Answer on Forums.rpgmakerweb.com

but here is the revision

Spoiler

#==============================================================================#
#                          **Azraven Minimap**                                 #
#------------------------------------------------------------------------------#
#  ** Author: Azraven                                                          #
#  ** Version: 1.5b                                                            #
#  ** Date: 12/24/2012                                                         #
#------------------------------------------------------------------------------#
#  - Description:                                                              #
#     This script adds a mini circular map to the game.                        #
#  - Usage:                                                                    #
#     Paste this script in the "Additional Scripts" section.                   #
#------------------------------------------------------------------------------#
#  - Historic                                                                  #
#     12/24/2012 - Start and end of version 1.0b                               #
#     04/03/2013 - Version 1.5b Bug fixes and addition of new functions.       #
#                * Fixed a bug where it did not correctly check for            #
#                  of certain tiles.                                           #
#                * Fixed a bug where grass (bush) tiles were                   #
#                  presented as blocking.                                      #
#                * Fixed a bug where blocking tiles placed                     #
#                  over grass tiles were represented as passable.              #
#                * Improved code.                                              #
#                + Added the function to show vehicles.                        #
#                + Added the function to show followers.                       #
#                + Added the function to use Region IDs for                    #
#                  hide passable areas.                                        #
#     06/14/2014 * Bug related to "Delete Temporary Event" command             #
#                  adjusted.                                                   #
#                * Clean up the code.                                          #
#                                                                              #
#==============================================================================#
# I used Google translate to translate this from Portuguese into English so I  #
# could understand how to use this script in may game.    ~brujah236           #
#==============================================================================#
module Azraven
  module MiniMap
    #--------------------------------------------------------------------------#
    # SETTINGS                                                                 #
    #--------------------------------------------------------------------------#
    #Minimap tile size, recommended not to use values smaller than 3.
    TileSize = 8
    #--------------------------------------------------------------------------#
    #Adjusting the centering of the mini map, depending on the tile size.
    MapOffset = -4
    #--------------------------------------------------------------------------#
    #Defines the player's color on the map.
    PlayerColor = Color.new(255,0,0)
    #--------------------------------------------------------------------------#
    #Show followers.
    ShowFollowers = true
    #--------------------------------------------------------------------------#
    #Defines the color of followers on the map.
    FollowerColor = Color.new(0,128,255)
    #--------------------------------------------------------------------------#
    #Define whether to show vehicles on the map.
    ShowVehicles = true
    #--------------------------------------------------------------------------#
    #Defines the color of the boat.
    BoatColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the ship's color.
    ShipColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the color of the aircraft.
    AirshipColor = Color.new(255,0,255)
    #--------------------------------------------------------------------------#
    #Defines the color of objects shown on the map.
    #Objects are NPCs, doors, teleports, chests and whatever else the user can
    #to imagine.
    #To add a new object use the following syntax inside the {}:
    # "tag" => Color.new(R,G,B,A)
    #Where tag is the comment that will be added to that event.
    #Separate each object by "," without the quotes.
    ObjectColor = {"npc" => Color.new(0,255,0),
                  "teleport" => Color.new(150,50,50),
                  "chest" => Color.new(100,100,100),
                  "enemy" => Color.new(255,48,48)}
    #--------------------------------------------------------------------------#
    #Defines the outline color of objects and player.
    BorderColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Opacity of objects shown on the map.
    ObjectLayerOpacity = 255
    #--------------------------------------------------------------------------#
    # Position of the map on the screen.
    #1 = Top left corner.
    #2 = Top right corner.
    #3 = Bottom left corner.
    #4 = Top right corner.
  
    #additional options added by me
    #5 = Left middle.
    #6 = Right middle.
  
    MiniMapCorner = 5
    #--------------------------------------------------------------------------#
    #Defines whether a particular region will show as locked on the minimap.
    #Useful not to reveal "secret passages".
    UseHideRegion = true
    #--------------------------------------------------------------------------#
    #Id of the region if UseHideRegion is true.
    HideRegionId = 60
    #--------------------------------------------------------------------------#
    #Color of the impassable area of the map.
    MapColor = Color.new(200,150,150)
    #--------------------------------------------------------------------------#
    #Outline color of the impassable area of the map.
    MapBorderColor = Color.new(50,50,50)
    #--------------------------------------------------------------------------#
    #Name of the minimap border image file in the Graphics/System folder.
    BorderName = "Border"
    #--------------------------------------------------------------------------#
    #Defines whether to use a background texture.
    UseBGTexture = true
    #--------------------------------------------------------------------------#
    #Name of the image file of the texture used when
    #minimap background in the Graphics/System folder.
    #Note: The image must be inverted.
    BackTextureName = "OldPaper"
    #--------------------------------------------------------------------------#
    #Background fill color if no texture is used.
    BGColor = Color.new( 100, 100, 100)
    #--------------------------------------------------------------------------#
    #Option to fill the external area of the map with a color.
    ClearOutsideArea = true
    #--------------------------------------------------------------------------#
    #Color used to fill the outer area of the map.
    ClearOutsideColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Option to demarcate the limits of the map.
    OutlineMapArea = true
    #--------------------------------------------------------------------------#
    #Color of the demarcation of the limits of the map.
    OutlineMapColor = Color.new(0,0,0)
    #--------------------------------------------------------------------------#
    #Id of the switch that enables/disables the minimap.
    EnableSwitchId = 1
    #--------------------------------------------------------------------------#
    # END OF CONFIGURATION. #
    #--------------------------------------------------------------------------#
    MiniMapCoords = {1 => [0,0,112,112],
                     2 => [Graphics.width - 112,0,112,112],
                     3 => [0,Graphics.height - 112,112,112],
                     4 => [Graphics.width - 112,Graphics.height - 112,112,112],
                     #additional options added by me
                     5 => [0,(Graphics.height/2) - 56,112,112],
                     6 => [Graphics.width - 112,(Graphics.height/2) - 56,112,112]}
     Tile_X = 0
     Tile_Y = 6
  end
end
#==============================================================================#
#  ** Color Class                                                              #
#==============================================================================#
class Color
  #----------------------------------------------------------------------------#
  # * Inverts the color value
  #----------------------------------------------------------------------------#
  def invert
    r = 255 - self.red
    g = 255 - self.green
    b = 255 - self.blue
    a = self.alpha
    self.set(r, g, b, a)
  end
end


#==============================================================================#
#  ** Mini Map Class                                                           #
#==============================================================================#
class MiniMap
 
  include Azraven::MiniMap
 
  def initialize(viewport)
    @viewport = viewport
    @playercolor = PlayerColor.dup.invert
    @followercolor = FollowerColor.dup.invert
    @boatcolor = BoatColor.dup.invert
    @shipcolor = ShipColor.dup.invert
    @airshipcolor = AirshipColor.dup.invert
    @objectcolor = ObjectColor.dup
    @objectcolor.each_pair do |key, value|
      @objectcolor[key] = value.dup.invert
    end
    @bordercolor = BorderColor.dup.invert
    @mapcolor = MapColor.dup.invert
    @mapbordercolor = MapBorderColor.dup.invert
    @clearoutsidecolor = ClearOutsideColor.dup.invert
    @outlinemapcolor = OutlineMapColor.dup.invert
    @on_map = SceneManager.scene_is?(Scene_Map) ###
    refresh
  end
 
  def refresh
    @map_id = $game_map.map_id
    @backmask = Sprite.new(@viewport)
    @backmask.bitmap = Cache::system("Back_96")
    @backmask.x = @backmask.y = 8
    @backtile = Sprite.new(@viewport)
    @backtile.blend_type = 2
    @backtile.z = 1
    @backtile.x = @backtile.y = -100
    @map = Sprite.new(@viewport)
    @map.z = 2
    @map.blend_type = 2
    @object_layer = Sprite.new(@viewport)
    @object_layer.z = 3
    @object_layer.blend_type = 2
    @object_layer.bitmap = Bitmap.new($game_map.width*TileSize + 112,$game_map.height*TileSize + 112)
    @object_layer.opacity = ObjectLayerOpacity
    @border = Sprite.new(@viewport)
    @border.bitmap = Cache::system(BorderName)
    @border.z = 4
    @border.opacity = 255
    @mask = Cache::system("Mask")
    draw_back
    draw_map
  end
 
  def visible?
    $game_switches[EnableSwitchId]
  end
 
  def draw_map
  
    front = make_map_bitmap(@mapcolor)
    border = make_map_bitmap(@mapbordercolor)
  
    result = Bitmap.new($game_map.width*TileSize + 112,
                        $game_map.height*TileSize+ 112)
                      
    result.blt(-1, 0, border, border.rect)
    result.blt(1, 0, border, border.rect)
    result.blt(0, -1, border, border.rect)
    result.blt(0, 1, border, border.rect)
    result.blt(0, 0, front, front.rect)
  
    @mapbitmap = result
  end
 
  def draw_back
    bitmap = Bitmap.new($game_map.width*TileSize+112,
                       $game_map.height*TileSize+112)
    if UseBGTexture
      bit = Cache::system(BackTextureName)
      bitmap.stretch_blt(bitmap.rect, bit, bit.rect)
    else
      bitmap.fill_rect(bitmap.rect, BGColor)
    end
    if ClearOutsideArea
      bitmap.fill_rect(0,0,bitmap.width, 56, @clearoutsidecolor)
      bitmap.fill_rect(0,0,56, bitmap.height, @clearoutsidecolor)
      bitmap.fill_rect(0,bitmap.height-56,bitmap.width, 56, @clearoutsidecolor)
      bitmap.fill_rect(bitmap.width-56,0,56, bitmap.height, @clearoutsidecolor)
    elsif OutlineMapArea
      bitmap.fill_rect(56,55,bitmap.width-112,1,@outlinemapcolor)
      bitmap.fill_rect(55,56,1,bitmap.height-112,@outlinemapcolor)
      bitmap.fill_rect(bitmap.width-56,55,1,bitmap.height-112,@outlinemapcolor)
      bitmap.fill_rect(56,bitmap.height-56,bitmap.width-112,1,@outlinemapcolor)
    end
    @backtilebitmap = bitmap
  end
 
  def draw_object_layer
    for event in $game_map.events.values
      unless event.list.nil?
        for item in event.list
          if item.code == 108 or item.code == 408
            if @objectcolor.has_key?(item.parameters[0])
              draw_object(event.real_x*TileSize+56,
              event.real_y*TileSize+56,
              @objectcolor[item.parameters[0]])
            end
          end
        end
      end
    end
    if ShowFollowers
      unless $game_player.vehicle
        $game_player.followers.each do |follower|
          draw_object(follower.real_x*TileSize+56,
                      follower.real_y*TileSize+56,
                      @followercolor) if follower.visible?
        end
      end
    end
    if ShowVehicles
      unless $game_map.airship.transparent
        draw_object($game_map.airship.real_x*TileSize+56,
                $game_map.airship.real_y*TileSize+56,
                @airshipcolor)
      end
      unless $game_map.ship.transparent
        draw_object($game_map.ship.real_x*TileSize+56,
                $game_map.ship.real_y*TileSize+56,
                @shipcolor)
      end
      unless $game_map.boat.transparent
        draw_object($game_map.boat.real_x*TileSize+56,
                $game_map.boat.real_y*TileSize+56,
                @boatcolor)
      end     
    end
    draw_object($game_player.real_x*TileSize+56,
                $game_player.real_y*TileSize+56,
                @playercolor)
  end
 
  def draw_object(x, y, color)
    @object_layer.bitmap.fill_rect(x, y, TileSize, TileSize, @bordercolor)
    @object_layer.bitmap.fill_rect(x+1, y+1, TileSize-2, TileSize-2, color)
    @object_layer.bitmap.clear_rect(x,y,1,1)
    @object_layer.bitmap.clear_rect(x,y+TileSize-1,1,1)
    @object_layer.bitmap.clear_rect(x+TileSize-1,y,1,1)
    @object_layer.bitmap.clear_rect(x+TileSize-1,y+TileSize-1,1,1)
  end
        
  def make_map_bitmap(color)
    bitmap = Bitmap.new($game_map.width*TileSize + 112,
                       $game_map.height*TileSize + 112)
    for x in 0..$game_map.width - 1
      for y in 0..$game_map.height - 1
        if $game_map.airship_land_ok?(x, y) || $game_map.bush?(x, y)
          if UseHideRegion
            bitmap.fill_rect(x*TileSize+56,
                             y*TileSize+56,
                             TileSize, TileSize,
                             color) if $game_map.region_id(x, y) == HideRegionId
          else
             next               
          end
          if $game_map.bush?(x, y)
            unless $game_map.passable?(x, y, 4)
               bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
            end
          end
          next
        end
        bitmap.fill_rect(x*TileSize+56, y*TileSize+56, TileSize, TileSize, color)
      end
    end
    bitmap
  end
 
  def update_object_layer
   @object_layer.bitmap.clear
   draw_object_layer
  end
 
  def dispose
    @backmask.dispose
    @backtile.dispose
    @map.dispose
    @object_layer.dispose
    @border.dispose
  end
 
  def update
    if @map_id != $game_map.map_id
      dispose
      @map_id = $game_map.map_id
      refresh
    end
    @backmask.visible = visible?
    @backtile.visible = visible?
    @map.visible = visible?
    @object_layer.visible = visible?
    @border.visible = visible?
    if visible?
      @map.bitmap = @mapbitmap.dup
      @backtile.bitmap = @backtilebitmap.dup
      sx = $game_player.real_x * (TileSize * -1) + MapOffset
      sy = $game_player.real_y * (TileSize * -1) + MapOffset
      update_object_layer
      @map.x = @backtile.x = @object_layer.x = sx
      @map.y = @backtile.y = @object_layer.y = sy
      @backtile.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
      @map.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
      @object_layer.bitmap.blt(sx*-1, sy*-1,@mask,@mask.rect)
      update_minimap_fade ###
    end
  end
 
  # fade effect when player is behind the minimap
  def update_minimap_fade
    if behind_minimap?
      if @map.opacity >= 60
        @map.opacity -= 10
        @backmask.opacity = @backtile.opacity = @object_layer.opacity = @border.opacity = @map.opacity
      end
    elsif @map.opacity != 255
      @map.opacity += 10
      @backmask.opacity = @backtile.opacity = @object_layer.opacity = @border.opacity = @map.opacity
    end
  end
 
  def behind_minimap?
    return false unless @on_map
    px = ($game_player.screen_x).to_i
    py = ($game_player.screen_y).to_i
    x = MiniMapCoords[MiniMapCorner][0]
    y = MiniMapCoords[MiniMapCorner][1]
    w = MiniMapCoords[MiniMapCorner][2]
    h = MiniMapCoords[MiniMapCorner][3]
    return true if ((px > (x - 10)) && (px < (x + w + 10))) && 
    ((py > (y - 10)) && (py < (y + h + 35)))
    return false
  end

end
#==============================================================================#
#  ** Classe Spriteset_Map                                                     #
#==============================================================================#
class Spriteset_Map
 
  alias azraven_mini_map_init initialize
  alias azraven_mini_map_updt update
  alias azraven_mini_map_disp dispose
 
  include Azraven::MiniMap
 
  def initialize
    create_minimap
    azraven_mini_map_init
  end
 
  def create_minimap
    viewport = Viewport.new(Graphics.width - 112,0,112,112)
    viewport.rect.set(MiniMapCoords[MiniMapCorner][0],
                      MiniMapCoords[MiniMapCorner][1],
                      MiniMapCoords[MiniMapCorner][2],
                      MiniMapCoords[MiniMapCorner][3])
    viewport.z = 500
    @minimapa = MiniMap.new(viewport)
  end
 
  def dispose
    azraven_mini_map_disp
    @minimapa.dispose
  end
 
  def update
    azraven_mini_map_updt
    @minimapa.update
  end
end
#==============================================================================#
#  ** Fim do Script                                                            #
#==============================================================================#

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted