Jump to content

Chucksaint

Member
  • Content Count

    45
  • Joined

  • Last visited

Posts posted by Chucksaint


  1. On 8/19/2019 at 11:20 PM, Kayzee said:

    Oh darn... I was just looking at the minimap script you sent me and it seems it probobly won't work with my way of doing masks after all. :(

     

    Well not unless the whole thing is redone anyway. It's possible to make a map script that does the mask effect, but it would probably need to be a whole new script. I somehow thought the script was simpler then it actually is. I thought it mostly just loaded a bitmap image and displayed it, but it also has a bunch of other sprites and stuff so, yeah. My mask trick is really really limited sometimes, but it's the only way I know of to do masks with RGSS...

    That's alright. thanks anyway, I'll use the squared one.

    No worries ^^

     

    Meanwhile.... I have some other questions... sorry for hijacking (:´D)

     

    EDIT: I've managed to do this one width the help of AMN DQ Battle Addon script and some editing ^^

     

    I've created my own window in Scene_Battle to appear when Skill_list is opened.

    In that window I've managed to display current in action actor HP/MP when I'm selecting skills..

    But I wanted to display MP_Cost when the cursor is on skill.

     

    (see image bellow for future reference) 

    Quote

    ex1.png.183956caa7e64b077458a62981dbefc5.png

     

    Alsooooo,

     

    Is there any way to make Critical Hits animation depending on the weapon ? 

    If I remember right, some years ago when I started my first project there was one, I think it was named Golden Sun Critical hits or something related to Golden Sun, but, sadly is gone.

     

    For reference:

    - If Emerald Sword is equipped then Critical Hit animation is Flash.

    - if current weapon is Daggers of doom  then the critical Hit animation is Meteor.

     

    Thank youuu ~~

    • Like 1

  2. 2 hours ago, Kayzee said:

     

    Normally the game uses RPG::AudioFile subclasses (like RPG::BGM) to hold data about volume and pitch, and those classes call the Audio module to play themselves. The way Yanfly's system options volume settings work is to adjust the volume automatically as the RPG::AudioFile subclasses play themselves, but the jukebox script just uses the Audio module directly so it completely bypasses yanfly's script actually... May look into it more later.

     

     

    How isn't it working? The tricky bit is step 2, because you can't just create a sprite for that mask. Instead you have to draw it on top of the map's bitmap (or a copy of the map's bitmap). It won't work otherwise. Remember Bitmaps and Sprites are different things! A Bitmap is the image you want to draw, a Sprite is where and how the game should draw it. I will have to look over that script in detail later I think.

    I must be doing something wrong of course -.-

    Thank you for your help :D :D


  3. 19 hours ago, Kayzee said:

    Yeah I figured that is what you meant. :3 I just mean you can't easily just make an image to use as a mask because you can't copy channels form one image to another. You would either have to clear the transparent bits line per line, or do tricks with additive blending. Here look I made this thing to show you what I mean:

     

    image.thumb.png.dfd4140b91d9d27e39f683d98472e2f2.png

     

    This is the only good way I have found to do masks in VX Ace.

     

    Oh oops. I was saying addictive instead of additive...  Silly Kayzee they aren't the same word at all! I mean a sprite with a blend_type of 1 okay? >w<

     

    Er, anyway, I am not exactly sure how that minimap script works and most of the links on that page are dead, so I don't think I can help code it right now, but the basic idea is something I have done before. For example, the glow effects on my title sequence near the start of this video (after I am done talking about 21 seconds in)  Is done by hiding a repeating plane behind a mask and additivly blending the background on top of it (uses quite a bit of subtractive blending too). Never tried it on a ui element though. :O

     

    Luckily the script already has that 3 sprites that simulate what you mention.

    I did as you said and created the images but I can't seem to make it work..

    The script is divided in 3 parts, but I'm pretty sure that is the second part, Iv'e already tried @map_img.blend_type = 1

    Quote
    
    #sb:nap_minimap [gui]
    =begin
    Minimap Script
    Version 1.22
    By Napoleon
    
    About:
    A minimap class that scales automatically according to it's size and which is
    only displayed when the scene is a map. It also has a 'scroll-mode' and works
    with huge maps. It has many more features just see the settings section.
    
    Instructions:
    - Place below "▼ Materials" but above "▼ Main Process".
    - You can combine all my minimap scripts into one big script of course.
    - Configure the (default) settings in the section below as desired.
    - Place mapshots of your map inside the Minimap Folder with in the (default)
      format "MAP<map_id>.png" w/o te quotes. Example: Graphics/Minimap/Map025.png
      The map must have 3 digits. So Map001 is good but Map1 or Map01 is not good.
      You may use: http://himeworks.wordpress.com/2013/02/25/map-screenshot/
    - Commands (optional of course):
        $minimap.enabled = true/false # Enables/Disables the minimap
        $minimap.opacity = 0-255      # Minimap opacity
        $minimap.set_location(rect)   # Rect is of type Rect
                                      # Rect.new(x,y,width,height)
                                      # Example: Rect.new(10,10,192,192)
        $minimap.mode = x             # x can be ":default" or ":scroll"
                                      (w/o quotes)
        $minimap.overlay_enabled = x  # x can be true/false
    --------------------------------------------------------------------------------
        $minimap.add_icon(icon_id,x,y,icon_index)
       
         Parameter explanation:
         - icon_id: is an identifier purely used to allow to remove it later by
           using this id again. If you do not supply an id it will default to -1.
         - x,y: the location on the real map in pixels (not in tiles).
         - icon_index: the index of the icon from the ICON_SHEET. Starts at 0 but
           the 0-index is by default an empy icon.   
    --------------------------------------------------------------------------------
        $minimap.rem_icon(icon_id)    # removes all icons that match the icon_id
    
    - Events:
        To enable events on the minimap, add a comment in their event page and add:
        <minimap: render blinks arrow>
         render, blinks & arrow are optional parameters but you need to supply at
         least one of them.
         Note: If you have multiple pages in your event then you need to add the
               'minimap-comment-tag' to every page where you want the event to be
               shown/used on the minimap.
        
         #---------------
         Tag explanation:
         render: renders the event on the minimap
         blinks: makes the event blink
         arrow:  adds an arrow on the minimap pointing to the even when the event
                 is outside of the visible minimap region.
         original_size: renders the event on the minimap in it's original size
                        multiplied by the minimap's zoomfactor.
         menu_hide: does not render the event on the menu map. But the event is
                    still rendered on the regular minimap if the "render" option is
                    included as well.
         #---------------
    
         # Name for the menu. If this tag is ommited and the event is rendered in
         # the menu then the name will default to the name of the event.
         <minimap name: Name of the minimap-event here>
         
         # Description for the menu.
         <minimap desc: Description of the minimap-event here>
    
    Requires:
    - RPG Maker VX Ace
    - Napoleon's Core Script version 1.15+
    
    Important Notes:
    - Map settings are currently not saved when saving your game.
    - I'm aware of a bug (version 1.22) that the minimap icons for the minimap-menu-
      addon are invisible after transferring. I haven't figured out yet how this is
      caused.
    
    Terms of Use:
    - Attribution 3.0 Unported (CC BY 3.0)
      http://creativecommons.org/licenses/by/3.0/
    - Attribution instructions:
        - Give Credit to: Napoleon
        - Attribution may change over time and I have the right to have it
          changed.
        - When changed I may or may not contact you to update the attribution in
          your product within reasonable time.
    
    Known issues/bugs:
    - Events on the map are not perfectly centered and currently make use of an
      offset to somewhat work around this problem.
    - If the minimap-area itself is larger than the minimap image then it will
      'teleport' around within the minimap area.
          
    Version History:
    1.22 (1 September 2014)
      - Removed the standalone script. The Core script is now a requirement.
      - Changed get_minimap_events()
      - Changed add_ev_by_command()
      - Added add_ev_by_nap_note()
    1.21 (31 August 2014)
      - Events that have no name-comment-tag set now default to their event's name.
    1.20a+b+c+d (09 July 2014)
      - Added "@has_map" to prevent crashes when opening the menu/entering a battle
        when the current map has no map image.
      - Fixed a crash when loading a savegame.
      - Fixed another crash when loading a savegame caused by version 1.20.
      - Fixed another crash when an event is trying to add events to the minimap
        when the minimap is nil.
    1.20 (26 June 2014)
      - Was mainly written by Breaking Owl/Lemony. Commissioned by Napoleon.
      - Fixed a crash when opening the minimap-menu.
      - Fixed a bug that caused the minimap to 'teleport' when the minimap-bitmap
        was smaller than the minimap area itself. It is now centered instead.
      - Fixed icon positioning on the minimap. They should now be perfect!
      - Added a FRAME_SKIP setting for even more performance.
      - Refactored and improved the code that hides the minimap before battles and
        such. Instead of disposing the minimap, the minimap is instead hidden.
      - The minimap menu now uses the name of the party-leader instead of the first
        Actor. 
      - Thanks to Duqueelmagoblanco for reporting 3 issues/bugs.
      - Moved the MM_Icon to "Nap 4/4| MM Event, POI & Icon".
      - Added the Fixnum & Float clamp methods to the standalone script (and renamed
        the script).
    1.11b (20 June 2014)
      - Fixed a crash when entering a random battle.
    1.11a (31 May 2014)
      - Added the minimap menu.
      - Some methods have been altered/added to accommodate the new addon.
      - Removed method: get_event(..)
      - Added MM_POI class.
      - Added 2 addons: "Minimap Menu" and "Minimap Menu Item".
      - Added a new notetag option: no_render
      - Fixed POI location bug & removed debug messages...
      - Increased imported version number (was forgotten in 1.11).
    1.10 (03 Januari 2014)
      - Increased performance for retrieving character sprites.
      - Fixed memory leak caused by removing icons.
      - The minimap now saves&loads it's settings when saving&loading the game.
      - The minimap no longer shows in custom scenes and when calling the save
        menu directly from the map. Also refactored this code a lot. Because of this
        the HIDE_IN_BATTLE setting has been replaced by:
        HIDE_BEFORE_BATTLE_TRANSITION.
    1.06 (31 December 2013)
      - Made it compatible with Napoleons Core Script 1.05
      - Applied a patch from Mario Buonocore to hide the minimap during battle.
      - Fixed a crash
      - The minimap now remembers it's transparency when it is recreated.
    1.05d (02 September 2013)
      - Fixed a bug that would cause the minimap to crash when the player is not the
        minimap-blip and then transferring to another map.
      - Added the "original_size" comment tag for large(r) events.
      - Fixed a crash caused in 1.05 an increased the version number.
      - Added a custom cache to support large maps.
      - Is no longer re-created when browsing through the game-menu.
      - Fixed a bug that caused the minimap to be loaded twice after returning from
        the menu.
    1.04a&b&c (21&22&23 July 2013)
      - Fixed a bug that caused the minimap to be shown in the default menu.
      - Now supports compressed and encrypted game data.
      - Increased imported version number from 1.03 to 1.04
      - Replaced the replacement-method Scene_Map.perform_transfer with an alias
        (nap_minimap_post_transfer) for compatibility reasons.
    1.04 (20 June 2013) (Mainly by estriole)
      - Fixed [F12] crash.
      - Never updates the minimap when not in Scene_Map.
      - Made the dispose method 'failsafe'.
      - Disposes the minimap instead of hiding it.
      - Added new setting: SCALE_OVERLAY = true/false.
      - You can now use a switch to turn on/off the minimap.
    1.03(a) (13 June 2013)
      - Fixed a crash when selecting "load game" and then cancelling back to the
        main menu.
      - You can now add (animated & blinking) events to the minimap.
      - Events can also have an arrow pointing to their location.
      - New Setting to override the displayed map (ex: show map005.png on map010).
      - The player cursor can now flicker (blink).
      - Minimap can now be shown only when the party has a specific item, weapon.
        or armor in it's possession.
      - Added various other settings.
      - Added arrows pointing to events containing the arrow-comment-tag.
      - Added minimap icons.
      - Fixed a bug that prevented the correct minimap from being loaded when
        transferring the player back to a previously visited map.
    1.02(a) (11 June 2013)
      - Fixed a bug that didn't cause the Minimap to hide itself when entering
        a battle through a random battle on the map.
      - Fixed the FAQ item and removed it.
    1.01 (09 June 2013)
      - The minimap now automatically hides when the default menu is active
    1.00 (07 June 2013)
      - First Release
    =end
    #===============================================================================
    module Nap; class Minimap
    #===============================================================================
    # Settings
    #===============================================================================
      # ** Files **
      FILE_PREFIX = 'Map'                 # File prefix for the minimap images.
      FILE_EXT    = 'png'                 # File extension for minimap images.
      FOLDER      = 'Minimap'             # Folder name that contains the minimap.
                                          # images (inside the Graphics folder).
      ARROWS      = 'Arrows'              # Filename of the arrow spritesheet.
      ICON_SHEET  = 'Iconset'             # The name of the Iconset (in
                                          # Graphics/System). By default this is
                                          # 'Iconset'.
    
      # ** Misc **
      LOCATION = Rect.new(                # Default minimap location & size.
                      Graphics.width - 12 - 128,             
                      12,
                      128,
                      128
                    ) # << do not remove this ')'
      HIDE_IN_MENU = true                 # Set to false to display minimap in
                                          # the default menu.
      HIDE_BEFORE_BATTLE_TRANSITION = true# Set to false to display the minimap
                                          # during the battle transition.
      OPACITY = 255                       # Minimap opacity.
      Z_INDEX_MAP = 500                   # Minimap Z-index.
      Z_INDEX_CURSOR = Z_INDEX_MAP + 1    # Cursor (player blip) Z-index.
      MIN_CACHE_SIZE = 40000              # When a map's width x height is equal
                                          # or bigger than this value then the 
                                          # map image is stored in cache. This
                                          # will cost more RAM but costs less
                                          # performance when re-entering a map.
                                          # The value is in grid-coordinates.
                                          # A 200x200 map = 40.000 tiles.
                                          
      # Frame cooldown between full redraws. A value of 9 means that every 9
      # frames the minimap update is skipped (unless the update forced-parameter
      # is set to true)
      # This is purely a performance setting. A lower number means more
      # performance but may cause the minimap to stutter.
      # Note: Do not use a value of 0 or the minimap will never be updated. Use a
      #       nil value to disable this.
      FRAME_SKIP = 20
      
      # - The switch that determines if the minimap is enabled. Use -1 to disable
      # this feature.
      # - true/ON = enabled, false/OFF = disabled.
      # - This is not the same as $minimap.enabled. If $minimap.enabled is set to
      #   false OR this switch is turned OFF then the minimap won't show.
      ENABLED_SWITCH = -1
      
      # The hash below configures maps to use the map from another map (if you
      # know what I mean haha). 5 => 1 means that map with id 5 uses the minimap
      # image from map with map id 1. And 6 => 1 would mean that the map with id 6
      # will use the minimap image from map with id 1.
      MAP_IMAGE_OVERRIDE = {
        #<map id that this applies to> => <map_id of the map image to use>
        9 => 6,
      } # << do not remove this '}'
      
      # ** Events on map **
      # The event comment tag value. By default this is: "<minimap>".
      # Do NOT edit the 3 settings belowif you do not know what they are for!
      EV_COMMENT_TAG = 'minimap'
      EV_NAME_COMMENT_TAG = 'minimap name'
      EV_DESC_COMMENT_TAG = 'minimap desc'
      
      
      EV_SIZE = 16                        # The size of the events on the minimap
                                          # in pixels.
      EV_OFFSET = [0, 0]                  # x,y offset on the minimap for all
                                          # events in pixels.
      
      # ** Item/Armor/Wpn Requirement **
      REQUIRE_ITEM = false                # When set to true the minimap is only
                                          # shown when the party possesses at
                                          # least one map item for the current
                                          # map.
                                          
      # Enter the item id here followed by the maps that it applies to.
      # Example: If you want the minimap to show on maps with id 1, 10, 20 then
      # when the party possesses a potion then add this to the :item section:
      # 1  => [1],
      # 10 => [1],
      # 20 => [1],
      ITEMS = { # only applies when REQUIRE_ITEM is set to true
        :item => {
          # format: <map id> => [<id of item>, <id of item>],
          4 => [1]
        },
        :weapon => {
          4 => [2, 3]
        },
        :armor => {
        }
      } # << do not remove this '}'
      
      # ** Cursor (the player/blip in the minimap): **
      USE_PLAYER_GRAPHIC = true           # Use the player graphic for the blip?
      CURSOR_IMG = 'Blip'                 # Cursor image or nil if you prefer to
                                          # use a single color instead. Only
                                          # applies if USE_PLAYER_GRAPHIC is set
                                          # to false.
      CURSOR_SIZE = 16                    # Cursor size in pixels.
      CURSOR_COLOR = Color.new(255,0,0)   # Cursor color when BORDER_IMG is nil.
      CURSOR_OPACITY = 255                # Cursor opacity.
    
      # ** Border **
      BORDER_IMG = 'Border'               # Name of the border image or nil if
                                          # you prefer to just use a single color.
      BORDER_SIZE = 3                     # Minimap Border size in pixels.
      BORDER_COLOR = Color.new(0,0,0)     # Minimap Border color
    
      # ** Blink **
      BLINK_PLAYER = false                # Blink player blip/cursor?
      BLINK_SPEED = 40                    # How fast the player and events on the
                                          # minimap blink.
      
      # ** Show/Hide overrides **
      ALWAYS_SHOW = [] # List of map id's on which the minimap is always shown
      ALWAYS_HIDE = [] # List of map id's on which the minimap is never shown
    
      # ** Overlay **
      OVERLAY_IMG = 'Overlay'             # Overlay image. Use nil to use none.
      OVERLAY_OFFSET = [0,0]              # The offset for the overlay image.
      Z_INDEX_OVERLAY = Z_INDEX_CURSOR + 1# Overlay Z-index.
      OVERLAY_ENABLED = true             # Determines the default overlay state.
      SCALE_OVERLAY = true               # Determines if the overlay is scaled
                                          # to the size of the minimap.
      
      # Add all scenes that you want the minimap to be visible in into this array.
      # Note: Not case sensitive.
      ONLY_VISIBLE_IN_SCENES = [
        'Scene_Map',
      ]
                                          
      #---------------------------------------------------------------------------
      # Minimap Scroll-style specific settings
      #---------------------------------------------------------------------------
      MODE = :scroll   # Sets the default modus. Can be :default, :scroll
      MAP_ZOOM_X = 0.2 # Must be a float! Use 1.0 instead of 1 for example.
                       # A value of 1.0 = 100% zoom (no zoom) and a value of 0.2
                       # means 20% zoom (zoomed out)
      MAP_ZOOM_Y = 0.2 # Must be a float! Use 1.0 instead of 1 for example.
      MAP_ZOOMS = {
        # map_id => [zoom_x (float), zoom_y (float)],
        # Sample below will set the zoom for x&y to 0.5 for map with map_id 1
        # 1 => [0.5, 0.5],       
        6 => [0.3, 0.3],
        9 => [0.1, 0.1],
      } # << do not remove this '}'
      BG_COLOR = nil                # The minimap background color in case the map
                                    # plus zoomfactor is smaller than the minimap.
                                    # Use a nil value to disable.
                                    # Note: Does not respond to $minimap.opacity
      AUTO_CORRECT_MAP_SCROLL = true      # When true the map won't scroll further
                                          # than it's own size.
    #===============================================================================
    # Do not edit below this line
    #===============================================================================
      $imported ||= {}
      $imported[:nap_minimap] = 1.22
      
      raise "Napoleon's Minimap script requires Napoleon's Core script version 1.15 or higher." if !$imported[:nap_core] || $imported[:nap_core] < 1.15
      #---------------------------------------------------------------------------
      # * Members
      #---------------------------------------------------------------------------
      attr_accessor :visibility_override # :hide, :normal, :show
      attr_accessor :enabled # set to true/false to enable/disable the minimap
      attr_reader   :location # Rect
      attr_reader   :arrows_src_img # Bitmap that contains the arrow spritesheet
      attr_reader   :scroll_src_rect # Rectangle that contains the source rect from the @base_img when :scroll mode is active
      attr_reader   :mm_events # array of MM_Event
      attr_accessor :show_icons # determines if icons are rendered
      attr_reader   :map_zoom_x
      attr_reader   :map_zoom_y
      attr_reader   :save_icons
    
      def disposed?
        @disposed
      end
      
      @@save_data = nil
      def self.save_data
        @@save_data
      end
      def self.save_data=(value)
        @@save_data = value
      end
      
      def overlay_enabled
        @overlay_enabled
      end
      def overlay_enabled=(value)
        @overlay_enabled = value
        set_visibility
      end
      
      def opacity
        @@opacity
      end
      def opacity=(value)
        if value < 0
          @@opacity = 0
        elsif value > 255
          @@opacity = 255
        else
          @@opacity = value
        end
        
        create_sprite
      end
      
      def mode
        @@mode
      end
      def mode=(value)
        set_mode(value)
      end
    end; end # module Nap; class Minimap
    #===============================================================================

     

    Quote
    
    #sb:nap_minimap [gui]
    #===============================================================================
    # Game Event
    # For: Adding a name-accessor to it.
    #===============================================================================
    class Game_Event
      if !defined?(self.name) || !defined?(self.name=())
        attr_accessor :name
    
        #---------------------------------------------------------------------------
        # Initialize                                                         [ALIAS]
        #---------------------------------------------------------------------------
        alias nam_minimap_initialize initialize
        def initialize(map_id, event)
          nam_minimap_initialize(map_id, event)
          @name = event.name
        end
      end
    end
    #===============================================================================
    # Nap::Minimap
    #===============================================================================
    module Nap; class Minimap
      #-----------------------------------------------------------------------------
      # Super Visible Setter
      # For hiding/unhiding the minimap
      #-----------------------------------------------------------------------------
      def super_visible=(v)
        return if !@has_map
        update(true) if v # Is required to make sure that the minimap is up2date before it becomes visible. Imagine if the player teleports to another section of the map or comes out of a battle after walking without this. Then the minimap would be off for 1 frame (which is noticable).
        @sprite.visible = v
        @overlay.visible = v if @overlay
        @border.visible = v
        @player_sprite.visible = v
      end
      #-----------------------------------------------------------------------------
      # * initialize
      #-----------------------------------------------------------------------------
      def initialize
        @save_icons = [] # contains map-icon data for saving&loading
        @@cache ||= {}
        @disposed = false
        @arrows_src_img = Cache.minimap(ARROWS) if !@arrows_src_img
        @overlay_enabled = OVERLAY_ENABLED      
        @@mode = MODE if !defined?(@@mode)
        @map_zoom_x = MAP_ZOOM_X
        @map_zoom_y = MAP_ZOOM_Y
        @border_img = Cache.minimap(BORDER_IMG) if BORDER_IMG
        @cursor_img = Cache.minimap(CURSOR_IMG) if CURSOR_IMG      
        @enabled = true
        @visible = false      
        @visibility_override = :normal
        @sprite = Sprite.new
        @@opacity = OPACITY if !defined?(@@opacity)
        @show_icons = true
        @icons = []
        @updated_count = 0
    
        @mm_events = Minimap.get_minimap_events
        set_location(LOCATION) # also calls: create_sprite
        create_cursor
        
        load_data
        
        # Icons for poi
        # $mm_icons contains a hash with the event_id as the key and it's
        # sprite-character as the value.
        if $imported[:nap_minimap_menu]
          $mm_icons[:events].values.each { |icon| icon.dispose } if !$mm_icons.nil?
          $mm_icons = {:events => {}}
          @mm_events.each { |mm_ev|
            if mm_ev.event.sprite
              icon = Bitmap.new(mm_ev.event.sprite.src_rect.width, mm_ev.event.sprite.src_rect.height)
              icon.blt(0, 0, mm_ev.event.sprite.bitmap, mm_ev.event.sprite.src_rect)
              $mm_icons[:events][mm_ev.event.id] = icon
            end
          }
        end
      end
      #-----------------------------------------------------------------------------
      # * store_player_source_rect
      #-----------------------------------------------------------------------------
      def store_player_source_rect
        $mm_icons[:player_src_rect] = $game_player.sprite.src_rect if $imported[:nap_minimap_menu]
      end
      #-----------------------------------------------------------------------------
      # * Create Map Events
      #-----------------------------------------------------------------------------
      def self.get_minimap_events
        mm_events = []
        # Loop through all map events
        $game_map.events.values.each { |e|
          next if e.list.nil?
          
          new_mm_ev = nil
          name      = e.name # Default name in case no name-command will be found
          desc      = nil
          
          e.nap_note.each { |note|
            new_mm_ev = add_ev_by_nap_note(e) if new_mm_ev.nil?
            
            if note =~ /<#{Regexp.escape(Minimap::EV_NAME_COMMENT_TAG)}: ([^>]*)>/ix
              name = $1
            elsif note =~ /<#{Regexp.escape(Minimap::EV_DESC_COMMENT_TAG)}: ([^>]*)>/ix
              desc = $1
            end
          } # e.nap_note.each { |note|
    # Old (outcommented) code below:
    #~       # Loop through all commands within the looped-event.
    #~       e.list.each{ |command|
    #~         # Scan for new mm_event command
    #~         new_mm_ev = Minimap.add_ev_by_command(e, command) if new_mm_ev.nil?
    #~         
    #~         # Scan for name/desc commands
    #~         if command.code == 108
    #~           if command.parameters[0] =~ /<#{Regexp.escape(Minimap::EV_NAME_COMMENT_TAG)}: ([^>]*)>/ix
    #~             name = $1
    #~           elsif command.parameters[0] =~ /<#{Regexp.escape(Minimap::EV_DESC_COMMENT_TAG)}: ([^>]*)>/ix
    #~             desc = $1
    #~           end
    #~         end
    #~       } # Loop through all commands within the looped-event.   
          
          if !new_mm_ev.nil?
            new_mm_ev.name = name
            new_mm_ev.desc = desc
            mm_events << new_mm_ev
          end
        } # Loop through all map events
        return mm_events
      end
      #-----------------------------------------------------------------------------
      # Add Event By Nap-Note
      #-----------------------------------------------------------------------------
      def self.add_ev_by_nap_note(event)
        event.nap_note.each { |note|
          if note =~ /<#{Regexp.escape(Minimap::EV_COMMENT_TAG)}: ([^>]*)>/ix
            return MM_Event.new(event, $1.downcase.split(' '))
          end
        }
        return nil
      end
      #-----------------------------------------------------------------------------
      # * Add Event By Command
      # Returns: The minimap_event or nil if none was found.
      #-----------------------------------------------------------------------------
      def self.add_ev_by_command(ev, command)
        if command.code == 108
          if command.parameters[0] =~ /<#{Regexp.escape(Minimap::EV_COMMENT_TAG)}: ([^>]*)>/ix
            return MM_Event.new(ev, $1.downcase.split(' '))
          end
        end
        return nil
      end
      #-----------------------------------------------------------------------------
      # * Add Event Unique
      # - Only adds the event if it doesn't already exist on the minimap.
      #-----------------------------------------------------------------------------
      def add_ev_unique(ev, command)
        return if @mm_events.find {|e| e.event.id == ev.id}
        new_mm_ev = Minimap.add_ev_by_command(ev, command)
        @mm_events << new_mm_ev if !new_mm_ev.nil?
      end
      #-----------------------------------------------------------------------------
      # * Remove Event
      # - Removes the event from the minimap
      #-----------------------------------------------------------------------------
      def remove_ev(ev_id)
        @mm_events.reject!{ |e| e.event.id == ev_id}
      end
      #-----------------------------------------------------------------------------
      # * Create Cursor
      #-----------------------------------------------------------------------------    
      def create_cursor
        @player_sprite.dispose if @player_sprite
        @player_sprite = Sprite.new
        @player_sprite.bitmap = Bitmap.new(CURSOR_SIZE, CURSOR_SIZE)
        @player_sprite.ox = CURSOR_SIZE / 2.0
        @player_sprite.oy = CURSOR_SIZE / 2.0
        
        if !USE_PLAYER_GRAPHIC
          if @cursor_img
            @player_sprite.bitmap.stretch_blt(Rect.new(0,0,@player_sprite.bitmap.width, @player_sprite.bitmap.height),@cursor_img,Rect.new(0,0,@cursor_img.width,@cursor_img.height), 255)
          else
            @player_sprite.bitmap.fill_rect(0, 0, CURSOR_SIZE, CURSOR_SIZE, CURSOR_COLOR)
          end
        end
        
        @player_sprite.z = Z_INDEX_CURSOR
        @player_sprite.visible = @visible
        reset_cursor_location
      end
      #-----------------------------------------------------------------------------
      # * Update Player Cursor
      # - Only called when USE_PLAYER_GRAPHIC == true
      #-----------------------------------------------------------------------------  
      def update_player_cursor
        player_character = $game_player.sprite
        return if !player_character || player_character.disposed?
        
        @player_sprite.bitmap.clear
        @player_sprite.bitmap.stretch_blt(Rect.new(0,0,@player_sprite.bitmap.width, @player_sprite.bitmap.height),
                                          player_character.bitmap,
                                          player_character.src_rect,
                                          255)
      end
      #-----------------------------------------------------------------------------
      # * Reset Cursor Location
      #-----------------------------------------------------------------------------     
      def reset_cursor_location
        @player_sprite.x = @location.x + @location.width / 2 + 16 * @map_zoom_x
        @player_sprite.y = @location.y + @location.height / 2 + 16 * @map_zoom_y
      end
      #-----------------------------------------------------------------------------
      # * Set location
      #   Sets the new location and size of the minimap
      #-----------------------------------------------------------------------------     
      def set_location(rect)
        @location = rect      
        
        @sprite.x = rect.x
        @sprite.y = rect.y
        @sprite.z = Z_INDEX_MAP
        
        @sprite.bitmap.dispose if @sprite.bitmap
        @sprite.bitmap = Bitmap.new(rect.width, rect.height)
                    
        create_overlay if OVERLAY_IMG      
        create_sprite
        reset_cursor_location if @player_sprite
      end
      #-----------------------------------------------------------------------------
      # * Refresh
      #-----------------------------------------------------------------------------     
      def refresh
        @has_map = false
        return if !SceneManager.scene.instance_of?(Scene_Map)
    
        @mm_events = Minimap.get_minimap_events
        create_overlay if OVERLAY_IMG
        create_sprite
        reset_cursor_location if @player_sprite
      end
      #-----------------------------------------------------------------------------
      # * Create Overlay
      #-----------------------------------------------------------------------------     
      def create_overlay
        @overlay.dispose if @overlay
        @overlay = Sprite.new
        
        # bitmap
        if SCALE_OVERLAY
          img = Cache.minimap(OVERLAY_IMG)
          @overlay.bitmap = Bitmap.new(@location.width, @location.height)
          @overlay.bitmap.stretch_blt(Rect.new(0, 0, @location.width, @location.height),
                                      img, Rect.new(0, 0, img.width, img.height))
          img.dispose
        else
          @overlay.bitmap = Cache.minimap(OVERLAY_IMG)
        end   
        
        @overlay.x = @location.x + OVERLAY_OFFSET[0]
        @overlay.y = @location.y + OVERLAY_OFFSET[1]
        @overlay.z = Z_INDEX_OVERLAY
        @overlay.visible = @visible && @overlay_enabled
      end
      #-----------------------------------------------------------------------------
      # * Get Effective Map ID
      #-----------------------------------------------------------------------------
      def self.get_effective_map_id
        if MAP_IMAGE_OVERRIDE.has_key?($game_map.map_id)
          return MAP_IMAGE_OVERRIDE[$game_map.map_id]
        else
          return $game_map.map_id
        end
      end
      #-----------------------------------------------------------------------------
      # * get_map_bitmap
      # - returns the map bitmap (or nil if non exists) and sets @has_image
      # - also saves/loads from custom cache (if applicable)
      #-----------------------------------------------------------------------------
      def get_map_bitmap
        eff_map_id = Minimap.get_effective_map_id
        filename = "#{FILE_PREFIX}#{eff_map_id.to_s.rjust(3, '0')}"
      
        # Use the bitmap from the custom cache if there is one.
        if @@cache.has_key?(Minimap.get_effective_map_id)        
          @cached = true
          @has_image = true
          return @@cache[eff_map_id]
        else
          @cached = false
        end
        
        # Rescue is required because if the game data is encrypted then
        # File.exists? will always return false (not supported by RPG Maker)
        # and Cache.load_bitmap will crash.
        # RM encryption supported methods: load_data(), Bitmap.new(),
        # Graphics.transition()
        #@has_image = (Cache.load_bitmap("Graphics/#{FOLDER}","#{filename}.#{FILE_EXT}") != nil)      
        begin
          bmp = Bitmap.new("Graphics/#{FOLDER}/#{filename}.#{FILE_EXT}")
          @has_image = true
        rescue
          @has_image = false
          return nil
        end
    
        # Save to cache if conditions are met
        if (bmp.width * bmp.height / 32) >= MIN_CACHE_SIZE && !@@cache.has_key?(eff_map_id)
          @@cache[eff_map_id] = bmp
          @cached = true
        end
        
        return bmp
      end
      #-----------------------------------------------------------------------------
      # * Set Zoom
      #-----------------------------------------------------------------------------
      def set_zoom
        # Set Zoom
        if MAP_ZOOMS[$game_map.map_id] == nil
          @map_zoom_x = MAP_ZOOM_X
          @map_zoom_y = MAP_ZOOM_Y
        else
          @map_zoom_x = MAP_ZOOMS[$game_map.map_id][0]
          @map_zoom_y = MAP_ZOOMS[$game_map.map_id][1]
        end
      end    
      #-----------------------------------------------------------------------------
      # * Create Sprite (the map itself)
      #-----------------------------------------------------------------------------     
      def create_sprite
        map_img = get_map_bitmap    
        if !@has_image
          @has_map = false
          return
        end
        @has_map = true
        @map_img = map_img.dup
        
        @map_w = map_img.width.to_f
        @map_h = map_img.height.to_f
    
        @base_map.dispose if @base_map
        case @@mode
        when :default
          @sprite.bitmap.stretch_blt(Rect.new(0, 0, @location.width, @location.height), map_img, Rect.new(0,0,@map_w,@map_h), @@opacity)
          @base_map = Bitmap.new(@location.width, @location.height)
          @base_map.stretch_blt(Rect.new(0, 0, @location.width, @location.height), map_img, Rect.new(0,0,@map_w,@map_h), @@opacity)
        when :scroll
          set_zoom        
          # Store source map (zoomed)
          @base_map = Bitmap.new(map_img.width * @map_zoom_x, map_img.height * @map_zoom_y)
          @base_map.stretch_blt(Rect.new(0,0,@base_map.width, @base_map.height), map_img, Rect.new(0,0,map_img.width,map_img.height), @@opacity)
        else
          raise "create_sprite: Unknown @@mode (#{@@mode})"
        end      
        map_img.dispose if !@cached
        
        create_border
        @sprite.visible = @visible
        render_events
      end
      
      def refresh_events
        @mm_events = Minimap.get_minimap_events
      end
      
      #-----------------------------------------------------------------------------
      # * Render Events
      #-----------------------------------------------------------------------------
      def render_events
        return if @mm_events.length == 0 || @player_sprite.nil?
        # There is no need to render a clean map (basemap w/o events) in :scroll_mode because the sets_scroll handles that.
        case @@mode
        when :default
          # Render the basemap onto the new spritemap (removing all events and such).
          @sprite.bitmap.dispose if @sprite.bitmap
          @sprite.bitmap = Bitmap.new(@location.width, @location.height)
          @sprite.bitmap.blt(0,0,@base_map, Rect.new(0,0,@sprite.bitmap.width,@sprite.bitmap.height))
        when :scroll
          # Make sur ethat the scroll_src_rect is set before rendering events in :scroll mode
          get_scroll_base_src_rect if !@scroll_src_rect
        else
          raise "render_events: Unknown @@mode (#{@@mode})"
        end
      
        @mm_events.each { |ev| ev.render(self, @sprite.bitmap, @map_zoom_x, @map_zoom_y) }
      end
      #-----------------------------------------------------------------------------
      # * Create Border
      #-----------------------------------------------------------------------------
      def create_border
        @border.dispose if @border
        @border = Sprite.new
        @border.bitmap = Bitmap.new(@location.width + BORDER_SIZE * 2, @location.height + BORDER_SIZE * 2)
        @border.x = @location.x - BORDER_SIZE
        @border.y = @location.y - BORDER_SIZE
        
        if BORDER_IMG
          @border.bitmap.stretch_blt(Rect.new(0,0,@border.bitmap.width, @border.bitmap.height),@border_img,Rect.new(0,0,@border_img.width,@border_img.height), 255)
        else
          @border.bitmap.fill_rect(0, 0, @border.bitmap.width, BORDER_SIZE, BORDER_COLOR)
          @border.bitmap.fill_rect(@border.bitmap.width - BORDER_SIZE, 0, BORDER_SIZE, @border.bitmap.height, BORDER_COLOR)
          @border.bitmap.fill_rect(0, @border.bitmap.height - BORDER_SIZE, @border.bitmap.width, BORDER_SIZE, BORDER_COLOR)
          @border.bitmap.fill_rect(0, 0, BORDER_SIZE, @border.bitmap.height, BORDER_COLOR)
        end
        
        @border.z = Z_INDEX_MAP
        @border.visible = @visible
      end
      #-----------------------------------------------------------------------------
      # * Set Mode
      #-----------------------------------------------------------------------------    
      def set_mode(mode)
        raise "Minimap.set_mode(#{mode}) Invalid mode." if mode != :default && mode != :scroll
        @@mode = mode
        
        @sprite.bitmap.clear # This line is necessary in case the opacity is < 255.
        create_sprite
        reset_cursor_location
      end
      #-----------------------------------------------------------------------------
      # * Set Cursor Location
      #-----------------------------------------------------------------------------    
      def set_cursor_location
        ratio_x = @location.width / @map_w
        ratio_y = @location.height / @map_h
        
        map_x = $game_player.real_x * 32 * ratio_x + @location.x
        map_y = $game_player.real_y * 32 * ratio_y + @location.y
        
        @player_sprite.x = map_x
        @player_sprite.y = map_y
      end
      #-----------------------------------------------------------------------------
      # * World map to minimap coordinates
      # real_x & real_y is the location in pixels (upper left corner is 0,0)
      # returns 2 values
      # Note: real_x usually requires a * 32 multiplication
      #-----------------------------------------------------------------------------
      def to_minimap_coords(real_x, real_y)
        case @@mode
        when :default
          ratio_x = @location.width.to_f / @map_w.to_f
          ratio_y = @location.height.to_f / @map_h.to_f
          x = real_x * @map_zoom_x
          y = real_y * @map_zoom_y
          return real_x * ratio_x, real_y * ratio_y
        when :scroll
          real_x += 16
          real_y += 16
          x = real_x * @map_zoom_x
          y = real_y * @map_zoom_y
          return x, y
        else
          raise "def to_minimap_coords - unknown mode: #{@@mode}"
        end
      end
      #-----------------------------------------------------------------------------
      # * Get Scroll Base Source Rectangle
      # - This method contains the real logic for drawing and calculating the
      #   scrolling map.
      #-----------------------------------------------------------------------------
      def get_scroll_base_src_rect
        half_w = @location.width / 2
        half_h = @location.height / 2
        
        # Calculate the location of the player on the basemap with zoom factor
        x = $game_player.real_x * 32 * @map_zoom_x - half_w
        y = $game_player.real_y * 32 * @map_zoom_y - half_h
        
        
        
        mw = @map_img.width.to_f  * @map_zoom_x
        mh = @map_img.height.to_f * @map_zoom_y      
        dh = @location.height - mh
        dw = @location.width - mw
        equals = @location.width > mw && @location.height > mh
        if AUTO_CORRECT_MAP_SCROLL# && equals
          # The code below makes sure that the map is not scrolled when the player
          # is near the edge of the map. Otherwise you could see the minimap bg
          # near the edge...
          if x < 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            delta_x = x
            x = 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            @player_sprite.x = @location.x + @location.width / 2 + delta_x + 16 * @map_zoom_x
          elsif x + @location.width > @base_map.width
            delta_x = (x + @location.width) - @base_map.width
            x = @base_map.width - @location.width # Prevent the map from scrolling too far to the left (otherwise creating a gap on the right side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            @player_sprite.x = @location.x + @location.width / 2 + delta_x + 16 * @map_zoom_x
          end
    
          if y < 0 # Prevent the map from scrolling too far to the bottom (otherwise creating a gap on the top side)
            delta_y = y
            y = 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            @player_sprite.y = @location.y + @location.height / 2 + delta_y + 16 * @map_zoom_y
          elsif y + @location.height > @base_map.height
            delta_y = (y + @location.height) - @base_map.height
            y = @base_map.height - @location.height # Prevent the map from scrolling too far to the left (otherwise creating a gap on the right side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            @player_sprite.y = @location.y + @location.height / 2 + delta_y + 16 * @map_zoom_y
          end
        end
        if equals
          if y < 0 # Prevent the map from scrolling too far to the bottom (otherwise creating a gap on the top side)
            delta_y = y
            y = 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            #@player_sprite.y = @location.y + @location.height / 2 + delta_y + 16 * @map_zoom_y
            @player_sprite.y -= dh
          end
          if x < 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            delta_x = x
            x = 0 # Prevent the map from scrolling too far to the right (otherwise creating a gap on the left side)
            # Because the map did not scroll we have to adjust the player cursor so that he is stilled drawn on the correct location on the minimap.
            @player_sprite.x -= dw
          end        
          #unless equals
            cx = (@location.width  - mw).ceil / 2
            cy = (@location.height - mh).ceil / 2
            x -= cx #* @map_zoom_x
            y -= cy #* @map_zoom_y
            @player_sprite.y += cy
            @player_sprite.x += cx
          #end
        end
        
        @scroll_src_rect = Rect.new(x,y,@location.width, @location.height)
        return @scroll_src_rect
      end
      #-----------------------------------------------------------------------------
      # * Set Scroll
      #-----------------------------------------------------------------------------
      def set_scroll
        @sprite.bitmap.clear # This line is necessary in case the opacity is < 255.      
        
        # BG Color
        if BG_COLOR != nil
          @sprite.bitmap.fill_rect(0, 0, @sprite.bitmap.width, @sprite.bitmap.height,
          Color.new(BG_COLOR.red, BG_COLOR.blue, BG_COLOR.green, @@opacity))
        end
    
        # Redraw the (newly) visible portion on the minimap
        @sprite.bitmap.stretch_blt(Rect.new(0,0,@location.width,@location.height),
          @base_map,
          get_scroll_base_src_rect,
          255 # opacity was already applied when caching the @sprite.bitmap. So keep it at 255 here.
        ) # stretch_blt
      end
      #-----------------------------------------------------------------------------
      # * Blink Cursor
      #-----------------------------------------------------------------------------
      def blink_cursor
        @player_sprite.visible = !BLINK_PLAYER || Nap::MM_Event.blink_visible?
      end
      #-----------------------------------------------------------------------------
      # * Update
      # Set forced to true to skip the frame-skipping.
      #-----------------------------------------------------------------------------
      def update(forced=false)
        if !forced && FRAME_SKIP
          if @updated_count < Nap::Minimap::FRAME_SKIP
            @updated_count += 1
          else
            @updated_count = 0
            return
          end
        end
        
        return if !SceneManager.scene.instance_of?(Scene_Map) || @disposed
        
        if (SceneManager.scene.instance_of?(Scene_Map) || @visibility_override == :show) && @visibility_override != :hide && @enabled && switch_enabled? && @has_image
          set_visibility(true) if !@visible
          
          MM_Event.update_blink
          blink_cursor
          update_player_cursor if USE_PLAYER_GRAPHIC
          
          case @@mode
          when :default
            set_cursor_location
          when :scroll
            set_scroll
          else
            raise "update: Unknown @@mode (#{@@mode})"
          end
              
          render_events
          @icons.each { |i| i.render(self, @sprite.bitmap) } if @show_icons
          @visible = true
        else
          set_visibility(false) if @visible
          @visible = false
        end
      end
      #-----------------------------------------------------------------------------
      # Switch Enabled?
      #-----------------------------------------------------------------------------
      def switch_enabled?
        return true if ENABLED_SWITCH == -1
        return $game_switches[ENABLED_SWITCH]
      end
      #-----------------------------------------------------------------------------
      # * Set Visibiliy Override
      # - Sets minimap visibility according to item/wpn/armor settings
      # - returns true if the map should be visible
      #-----------------------------------------------------------------------------
      def item_visiblity
        return true if !REQUIRE_ITEM # return true if items are not required
        map_id = $game_map.map_id
    
        if ITEMS[:item].has_key?(map_id)
          $data_items.each { |i|
            next if i.nil?
            return true if ITEMS[:item][map_id].include?(i.id) && $game_party.item_number(i) > 0
          }
        end
    
        if ITEMS[:weapon].has_key?(map_id)
          $data_weapons.each { |w|
            next if w.nil?
            return true if ITEMS[:weapon][map_id].include?(w.id) && $game_party.item_number(w) > 0
          }
        end
    
        if ITEMS[:armor].has_key?(map_id)
          $data_armors.each { |a|
            next if a.nil?
            return true if ITEMS[:armor][map_id].include?(a.id) && $game_party.item_number(a) > 0
          }
        end
    
        return false
      end
      #-----------------------------------------------------------------------------
      # * Set Visibiliy Override
      #-----------------------------------------------------------------------------  
      def set_visibility_override
        if !item_visiblity
          @visibility_override = :hide
          return
        end
        
        # Always hide/show on this map depending on the 2 setting arrays
        @visibility_override = :normal
        if ALWAYS_SHOW.include?($game_map.map_id)
          @visibility_override = :show
        elsif ALWAYS_HIDE.include?($game_map.map_id)
          @visibility_override = :hide
        end
      end
      #-----------------------------------------------------------------------------
      # * Set Visibility
      #-----------------------------------------------------------------------------
      def set_visibility(visibility=@visible)
        @sprite.visible = visibility
        @border.visible = visibility if @border
        @player_sprite.visible = visibility if @player_sprite
        @overlay.visible = visibility && @overlay_enabled if @overlay
      end
      #-----------------------------------------------------------------------------
      # * Add Icon
      # - icon_id: is an identifier purely used to allow to remove it later by
      #   using this id again. If you do not supply an id it will default to -1.
      # - x,y: the location on the real map in pixels (not in tiles).
      # - icon_index: the index of the icon from the ICON_SHEET. Starts at 0 but
      #   the 0-index is by default an empy icon.
      #-----------------------------------------------------------------------------
      def add_icon(icon_id=-1, x, y, icon_index)
        icon_sheet = Cache.system(ICON_SHEET)
        
        icon_img = Bitmap.new(24, 24)
        rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
        icon_img.blt(0, 0, icon_sheet, rect)
        @icons << MM_Icon.new(icon_id, x, y, icon_img)
        icon_sheet.dispose
        
        @save_icons << [icon_id, x, y, icon_index]
      end
      #-----------------------------------------------------------------------------
      # * Remove Icon
      #-----------------------------------------------------------------------------
      def rem_icon(id)
        @icons.each { |i| i.dispose if i.id == id }      
        @icons.reject! { |i| i.id == id }
        @save_icons.reject! { |i| i[0] == id}
      end
      #-----------------------------------------------------------------------------
      # * Dispose
      #-----------------------------------------------------------------------------
      def dispose      
        @disposed = true
        @map_img.dispose if @map_img
        @map_img = nil
        @sprite.dispose if @sprite && !@sprite.disposed?
        @player_sprite.dispose if @player_sprite && !@player_sprite.disposed?      
        @border.dispose if @border && !@border.disposed?
        @border_img.dispose if @border_img && !@border_img.disposed?
        @cursor_img.dispose if @cursor_img && !@cursor_img.disposed?
        @overlay.dispose if @overlay && !@overlay.disposed?
        @base_map.dispose if @base_map && !@base_map.disposed?
        @arrows_src_img.dispose if @arrows_src_img && !@arrows_src_img.disposed?
        @icons.each { |i| i.dispose if i && !i.disposed?}
      end
    end; end # Nap; Minimap
    #===============================================================================
    # Cache
    #===============================================================================
    module Cache
      #-----------------------------------------------------------------------------
      # * Get Minimap Graphic                                                  [NEW]
      #-----------------------------------------------------------------------------
      def self.minimap(filename)
        load_bitmap("Graphics/#{Nap::Minimap::FOLDER}/", filename)
      end
    end
    #===============================================================================
    # Game Party
    # To show/hide the minimap whenever the party gains/loses a 'map-related' item
    #===============================================================================
    class Game_Party < Game_Unit
      #-----------------------------------------------------------------------------
      # Gain Item                                                            [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_gain_item gain_item
      def gain_item(item, amount, include_equip = false)
        nap_minimap_gain_item(item, amount, include_equip)
        $minimap.set_visibility_override if $minimap && Nap::Minimap::REQUIRE_ITEM
      end
      
      #-----------------------------------------------------------------------------
      # Lose Item                                                            [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_lose_item lose_item
      def lose_item(item, amount, include_equip = false)
        nap_minimap_lose_item(item, amount, include_equip)
        $minimap.set_visibility_override if $minimap && Nap::Minimap::REQUIRE_ITEM
      end
    end
    #===============================================================================
    # Spriteset Map
    # For updating the minimap
    #===============================================================================
    class Spriteset_Map  
      #-----------------------------------------------------------------------------
      # Update                                                               [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_update update
      def update
        nap_minimap_update
        $minimap.update if $minimap
      end
    end
    #===============================================================================
    # Class Event
    # For removing events from the minimap when the event is erased
    #===============================================================================
    class Game_Event < Game_Character
      #-----------------------------------------------------------------------------
      # Erase                                                                [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_erase erase
      def erase
        nap_minimap_erase
        $minimap.mm_events.reject! { |e| e.event.id == @id } if $minimap
      end
    end
    #===============================================================================
    # Game Event
    # For making sure that the event is only shown on the minimap when the page
    # that contains the minimap-comment-tag is actually active.
    #===============================================================================
    class Game_Event < Game_Character
      #-----------------------------------------------------------------------------
      # Setup Page Settings                                                  [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_setup_page_settings setup_page_settings
      def setup_page_settings
        nap_minimap_setup_page_settings
        
        if SceneManager.scene.instance_of?(Scene_Map) && $minimap
          $minimap.remove_ev(self.id)
          return if self.list == nil
          for command in self.list
            $minimap.add_ev_unique(self, command)
          end
        end
      end
    end
    #===============================================================================
    # Saving & Loading
    #===============================================================================
    module DataManager
      class << self
        alias nap_minimap_make_save_contents    make_save_contents
        alias nap_minimap_extract_save_contents extract_save_contents
      end
      #-----------------------------------------------------------------------------
      # Make Save Contents                                                   [ALIAS]
      #-----------------------------------------------------------------------------
      def self.make_save_contents    
        contents = nap_minimap_make_save_contents
        contents[:nap_minimap] = {}
    
        if $minimap && !$minimap.disposed?
          contents[:nap_minimap][:mode] = $minimap.mode
          contents[:nap_minimap][:visibility_override] = $minimap.visibility_override
          contents[:nap_minimap][:enabled] = $minimap.enabled
          contents[:nap_minimap][:location] = $minimap.location
          contents[:nap_minimap][:scroll_src_rect] = $minimap.scroll_src_rect
          #contents[:nap_minimap][:mm_events] = $minimap.mm_events
          contents[:nap_minimap][:show_icons] = $minimap.show_icons
          contents[:nap_minimap][:map_zoom_x] = $minimap.map_zoom_x
          contents[:nap_minimap][:map_zoom_y] = $minimap.map_zoom_y
          contents[:nap_minimap][:overlay_enabled] = $minimap.overlay_enabled
          
          contents[:nap_minimap][:opacity] = $minimap.opacity
          contents[:nap_minimap][:map_icons] = $minimap.save_icons
        end
        
        contents
      end
      #-----------------------------------------------------------------------------
      # Extract Save Contents                                             [ALIAS]
      #-----------------------------------------------------------------------------
      def self.extract_save_contents(contents)
        nap_minimap_extract_save_contents(contents)
        Nap::Minimap.save_data = contents[:nap_minimap]
      end
    end
    #===============================================================================
    # Class Minimap
    #===============================================================================
    module Nap
      class Minimap
        # in case a savegame was loaded
        def load_data
          return if Minimap.save_data.nil? || @@save_data.empty?
    
          set_mode(@@save_data[:mode]) # no "self."
          self.visibility_override = @@save_data[:visibility_override]
          self.enabled = @@save_data[:enabled]
          location = @@save_data[:location] # no "self."
          scroll_src_rect = @@save_data[:scroll_src_rect] # no "self."
          #mm_events = @@save_data[:mm_events]
          self.show_icons = @@save_data[:show_icons]
          map_zoom_x = @@save_data[:map_zoom_x] # no "self."
          map_zoom_y= @@save_data[:map_zoom_y] # no "self."
          self.overlay_enabled = @@save_data[:overlay_enabled]
          
          @@save_data[:map_icons].each { |i|
            @save_icons << i
            add_icon(i[0], i[1], i[2], i[3])
          }
          
          self.opacity = @@save_data[:opacity]
        end
      end
    end
    #===============================================================================
    # Scene Base
    # For: Creates the minimap
    #===============================================================================
    class Scene_Base
      #-----------------------------------------------------------------------------
      # Post Start                                                           [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_post_start post_start
      def post_start
        if SceneManager.scene.instance_of?(Scene_Map) &&
          Nap::Minimap::ONLY_VISIBLE_IN_SCENES.include?(self.class.name)
          if $minimap
            $minimap.super_visible = true
            $minimap.refresh
          else
            $minimap = Nap::Minimap.new
          end
        else
          $minimap.super_visible = false if $minimap
        end
        nap_minimap_post_start
      end
    end
    #===============================================================================
    # Scene Map
    #===============================================================================
    class Scene_Map < Scene_Base
    #-------------------------------------------------------------------------------
    # Pre Battle Scene                                                       [ALIAS]
    # ** Mario Buonocore - Hide Napoleon's Minimap before the battle transition.
    #
    #    Nasconde la minimappa durante la battaglia.
    #    Fa riferimento al valore della costante HIDE_IN_MENU.
    #-------------------------------------------------------------------------------
      alias lm_pre_battle_scene pre_battle_scene
      def pre_battle_scene    
        $minimap.super_visible = false if Nap::Minimap::HIDE_BEFORE_BATTLE_TRANSITION    
        lm_pre_battle_scene
      end
      #-----------------------------------------------------------------------------
      # Call Menu                                                            [ALIAS]
      # For: Storing player source rect before opening the menu
      #-----------------------------------------------------------------------------
      alias nap_minimap_call_menu call_menu
      def call_menu
        $minimap.store_player_source_rect
        nap_minimap_call_menu
      end
      #-----------------------------------------------------------------------------
      # Post Transfer                                                        [ALIAS]
      #-----------------------------------------------------------------------------
      alias nap_minimap_post_transfer post_transfer
      def post_transfer
        $minimap.refresh
        nap_minimap_post_transfer
        $minimap.refresh_events
      end
    end # Scene_Map
    #===============================================================================

     

    Quote
    
    #sb:nap_minimap [gui]
    module Nap
    #===============================================================================
    # Minimap Event
    #===============================================================================  
      class MM_Event
        attr_accessor :event
        attr_accessor :render # false will not draw this event on the map but still display an arrow to it if applicable
        attr_accessor :blinks
        attr_accessor :arrow
        attr_accessor :original_size
        attr_accessor :name
        attr_accessor :desc
        attr_reader   :hide_in_menu
        
        @@blink_cnt = 0
        @@blink_visible = false
        
        def self.blink_visible?
          @@blink_visible
        end
        
        ARROW_DIRECTION = {
          :NA => -1,
          :N  =>  0,
          :NE =>  1,
          :E  =>  2,
          :SE =>  3,
          :S  =>  4,
          :SW =>  5,
          :W  =>  6,
          :NW =>  7
        }
        #---------------------------------------------------------------------------
        # * Initialize
        #---------------------------------------------------------------------------
        def initialize(ev, options)
          @event = ev
          @sprite_character = @event.sprite
    
          return if @sprite_character.nil?
    
          @render = options.include?('render')
          @blinks = options.include?('blinks')
          @arrow = options.include?('arrow')
          @original_size = options.include?('original_size')
          @hide_in_menu = options.include?('menu_hide')
          if @original_size && !@sprite_character.disposed?
            @dest_width = @sprite_character.src_rect.width
            @dest_height = @sprite_character.src_rect.height
            @original_offset = [@dest_width / 2, @dest_height / 2]
          else
            @dest_width = @dest_height = Minimap::EV_SIZE
          end
          
        end    
        #---------------------------------------------------------------------------
        # * Update Blink (static)
        # ! call this only ONCE per update-cycle
        #---------------------------------------------------------------------------    
        def self.update_blink
          @@blink_cnt += 1
          if @@blink_cnt == Nap::Minimap::BLINK_SPEED
            @@blink_cnt = 0
            @@blink_visible = !@@blink_visible
          end
        end   
        #---------------------------------------------------------------------------
        # * Render
        #---------------------------------------------------------------------------
        def render(minimap, img, zoom_x, zoom_y)
          return if @sprite_character.nil? || @sprite_character.disposed? || @sprite_character.bitmap.nil? || @sprite_character.bitmap.disposed? || img.disposed? # In case the player just transferred to another map
          if @render && (!@blinks || @@blink_visible)
            x, y = minimap.to_minimap_coords(@event.real_x * 32.0, @event.real_y * 32.0)#(@event.real_x * 32, @event.real_y * 32)
            
            if minimap.mode == :scroll
              x -= minimap.scroll_src_rect.x
              y -= minimap.scroll_src_rect.y
            end
    
            if !@original_size
              img.stretch_blt(Rect.new(x - (@dest_width  / 2 ) + Nap::Minimap::EV_OFFSET[0],
                                       y - (@dest_height / 2 ) + Nap::Minimap::EV_OFFSET[1],
                                       @dest_width,
                                       @dest_height),
                              @sprite_character.bitmap,
                              @sprite_character.src_rect)
            else
              dify = (@sprite_character.src_rect.height - 32) / 2
              y -= dify * zoom_y
              img.stretch_blt(Rect.new(x - (@original_offset[0].to_f ) * zoom_x,
                                       y - (@original_offset[1].to_f ) * zoom_y,
                                       @dest_width.to_f * zoom_x,
                                       @dest_height.to_f * zoom_y),
                              @sprite_character.bitmap,
                              @sprite_character.src_rect)
            end
                  
            render_arrow(minimap, img, x, y) if @arrow && minimap.mode == :scroll
          end      
        end    
        #---------------------------------------------------------------------------
        # * Render Arrow
        #---------------------------------------------------------------------------
        def render_arrow(minimap, img, x, y)
          frame_w = minimap.arrows_src_img.width / 8 # 8 frames
          frame_h = minimap.arrows_src_img.height
          arrow_x = x
          arrow_y = y
          src_idx = :NA
          
          if x < 0
            arrow_x = Nap::Minimap::BORDER_SIZE
            src_idx = :W
          elsif x > minimap.location.width
            arrow_x = minimap.location.width - frame_w #- Nap::Minimap::BORDER_SIZE
            src_idx = :E
          end
          
          if y < 0
            arrow_y = Nap::Minimap::BORDER_SIZE
            if src_idx == :NA
              src_idx = :N
            else
              if src_idx == :W
                src_idx = :NW
              else
                src_idx = :NE
              end
            end
          elsif y > minimap.location.height
            arrow_y = minimap.location.height - frame_h - Nap::Minimap::BORDER_SIZE
            if src_idx == :NA
              src_idx = :S
            else
              if src_idx == :W
                src_idx = :SW
              else
                src_idx = :SE
              end
            end
          end
          
          return if src_idx == :NA # No arrow needed because the event is within the visible minimap area.
          
          img.stretch_blt(Rect.new(arrow_x, arrow_y, frame_w, frame_h),
                          minimap.arrows_src_img,
                          Rect.new(frame_w * ARROW_DIRECTION[src_idx], 0, frame_w, frame_h))                     
        end
        #---------------------------------------------------------------------------
        # To POI
        #---------------------------------------------------------------------------
        def to_poi
          return nil if @hide_in_menu
          return MM_POI.new(@event.real_x * 32, @event.real_y * 32, @name, @desc, $mm_icons[:events][@event.id])
        end
      end # class MM_Event
      #=============================================================================
      # Nap.MM_POI
      # For: Minimap POI Container
      #=============================================================================
      class MM_POI
        attr_reader :x
        attr_reader :y
        attr_reader :name
        attr_reader :desc # description
        attr_reader :icon # Use a nil value to not render it
        
        #---------------------------------------------------------------------------
        # Initialize
        #---------------------------------------------------------------------------
        def initialize(x, y, name, description, icon)
          @x = x
          @y = y
          @name = name
          @desc = description
          @icon = icon
        end
        #---------------------------------------------------------------------------
        # Player POI
        #---------------------------------------------------------------------------
        def self.player_poi
          return MM_POI.new($game_player.real_x * 32, $game_player.real_y * 32,
                            $game_party.leader.name, 'It\'s you!', nil)
        end
        #---------------------------------------------------------------------------
        # To string override
        #---------------------------------------------------------------------------
        def to_s
          @name
        end
      end # class MM_POI
    #===============================================================================
    # MM_Icon
    #===============================================================================
      class MM_Icon
        attr_accessor :x
        attr_accessor :y
        attr_accessor :id
        attr_accessor :bitmap
        SRC_RECT = Rect.new(0, 0, 24, 24)
        
        #---------------------------------------------------------------------------
        # * Initialize
        #---------------------------------------------------------------------------
        def initialize(id, x, y, bitmap)
          @x = x
          @y = y
          @id = id
          @bitmap = bitmap
          @disposed = false
        end
        #---------------------------------------------------------------------------
        # * Render
        #---------------------------------------------------------------------------
        def render(minimap, map)
          r_x, r_y = minimap.to_minimap_coords(@x+32, @y+32)
    
          if minimap.mode == :scroll
            r_x -= minimap.scroll_src_rect.x
            r_y -= minimap.scroll_src_rect.y
          end
    
          map.stretch_blt(Rect.new(r_x - 12, r_y - 12, 12, 12), @bitmap, SRC_RECT)
        end
        #---------------------------------------------------------------------------
        # * Dispose
        #---------------------------------------------------------------------------
        def dispose
          bitmap.dispose
          @disposed = true
        end
        #---------------------------------------------------------------------------
        # * Disposed?
        #---------------------------------------------------------------------------
        def disposed?
          @disposed
        end
      end # MM_Icon
    #===============================================================================
    end # module Nap

     

    I aprecciate your help :D


  4. 20 minutes ago, Kayzee said:

    Unfortunately, there is really no easy way to make masks in VX Ace. I managed to make some mask-like effects using subtractive and addictive blending, but it pretty much only works in some situations.

    Hi there, thank you for your response..I don't know if I am making sense. 

    D: so is it impossible to make this:

    Spoiler

    Untitled-1f.thumb.png.33e87e5f6a0dfd76846cd120498e2050.png

    into this? 

    Quote

    Untitled-12f.thumb.png.e9a4dd90176b4be2c1163e5bd537c01d.png

     

    • Like 1

  5. Hi Guys, so I've managed to make TSBS work with Ao no Kiseki almost in perfection, but sadly the <slow> and <cancel> doesn't work...

     

    I think they have similiar methods hence the "incompatibility"(?)

     

    Any one knows how to fix this ? 

     

    Thank youu


  6. I think that Enemy drops I can make it work with Enemy animation death

    sadly it gives me error with theo SBS... "double resume" 😧
     

    So I found a way to make it work with TSBS... Is there any way to get enemy item? 

    For example . if enemy has item(ID) ? 

     

    thank youu 
     


  7. HI there! How can I make random AP?
    I've tried to modify a script by TroyZ but the AP output is wrong..

     

    Here I leave the script that I modified

    Spoiler
    
    # ==============================================================================
    # ▼▼▼▼▼▼                    TroyZ - Random AP Drop                       ▼▼▼▼▼▼
    # ==============================================================================
    # Script by : Agung Prasetyo(TroyZ)
    # Contact me by : - Email agung.endisnear.xyz@gmail.com
    #                 - Forum RPGMakerID, username TroyZ
    #                 - Handphone 085756289121
    # Engine : VXAce
    # Level : Easy
    # Version : 1.1
    # ------------------------------------------------------------------------------
    # Change Logs :
    # 27 Mei 2013 - Rilis script versi 1.0
    # 15 Mei 2013 - Rilis update versi 1.1
    # ------------------------------------------------------------------------------
    # License : Silahkan digunakan untuk game free ataupun yang komersil.
    # Gak dikasih credit juga gak apa-apa, dikarenakan script ini sangat mudah dan
    # berhasil saya selesaikan kurang dari 10 menit. Kalo mau kasih credit boleh juga,
    # credit atas nama Agung Prasetyo(TroyZ).
    # ------------------------------------------------------------------------------
    # How to Use : Pasang saja dibawah material tapi diatas main
    # ------------------------------------------------------------------------------
    # Dengan script ini, aperience yang diberikan oleh musuh akan diacak sesuai
    # dengan konfigurasi yang kamu setting nantinya dibawah ini. Misalnya random
    # ratenya = 20% dengan aperience musuh 50. Maka, kamu akan mendapatkan aperience
    # yang diantara 20% dibawahnya 50 dan 20% diatasnya 50, jadi ada rentang aperience
    # gitu lah.
    #
    # Update versi 1.1
    # Kamu bisa setting sendiri rate terendah dan rate tertinggi ap musuh dengan
    # notetag seperti ini :
    # <ap lower rate: x>
    # <ap upper rate: x>
    # Dimana x adalah persentasenya. Misalnya, slime mempunyai notetag seperti ini :
    # <ap lower rate: 20>
    # <ap upper rate: 60>
    # Berarti, slime itu akan memberikan ap dengan rentang 20% dibawah base ap, dan
    # 60% diatas base ap. Kalau tidak mau ada ratenya, berikan angka 0 pada persentasenya
    $imported = {} if $imported.nil?
    $imported[:TroyZ_RandomAPDrop] = true
         
    module X_Random_AP_Drop_X
      module RandomRate
        DEFAULT_LOWER_RATE = 20 # random rate ini dalam persen
        DEFAULT_UPPER_RATE = 20 # random rate ini dalam persen
      end
      
      module NOTETAGS_RANDOM_RATE
        LOWER_RATE = /<(?:AP LOWER RATE|ap lower rate):[ ]*(\d+)>/i
        UPPER_RATE = /<(?:AP UPPER RATE|ap upper rate):[ ]*(\d+)>/i
      end
    end
    
    module DataManager
      class << self
        alias agung_load_random_ap_dbase_x    load_database
      end
      
      def self.load_database
        agung_load_random_ap_dbase_x
        agung_load_random_ap_notetags_x
      end
      
      def self.agung_load_random_ap_notetags_x
        [$data_enemies].each do |enemies|
            enemies.compact.each do |obj|
              next unless obj
              obj.agung_load_random_ap_notetags_x
            end
        end
      end
    end
    
    class RPG::Enemy
      include X_Random_AP_Drop_X
      
      attr_accessor :random_ap_lower
      attr_accessor :random_ap_upper
        attr_reader   :ap
    
      def agung_load_random_ap_notetags_x
        @random_ap_lower = RandomRate::DEFAULT_LOWER_RATE
        @random_ap_upper = RandomRate::DEFAULT_UPPER_RATE
        
        self.note.split(/[\r\n]+/).each { |baris|
          case baris
          when NOTETAGS_RANDOM_RATE::LOWER_RATE
            @random_ap_lower = $1.to_i
          when NOTETAGS_RANDOM_RATE::UPPER_RATE
            @random_ap_upper = $1.to_i
          end
        }
      end 
    end
    
    class Game_Enemy < Game_Battler
      def ap
        ap_1 = (self.element_rate(14) * 100)# * 100)#.to_i
        ap_batas_bawah = (ap_1 * (100 - enemy.random_ap_lower) / 100)
        ap_batas_atas = (ap_1 * (100 + enemy.random_ap_upper) / 100)
        ap = ap_batas_bawah + rand(ap_batas_atas - ap_batas_bawah + 1) #+1
        return ap.to_i
       end
    end

     

    thank you 


  8. Hi there, :)

    So to do an animation I need to create 

      def animateface(actor, x, y, enabled = true)
      bitmap = Cache.picture(actor.name + "_bg")
      rect = Rect.new(0, 0, 640,95)
      self.contents.blt( x, y, bitmap, rect, 255)
      bitmap.dispose
      end
    
    
    or
    
    blt(x, y, src_bitmap, src_rect, opacity = 255)
      bitmap = Cache.picture(actor.name + "_bg")
      rect = Rect.new(0, 0, 640,95)
      self.contents.blt( x, y, bitmap, rect, 255)
      bitmap.dispose
      end

    ?? 

    follow those steps here? https://www.rubydoc.info/github/cstrahan/open-rpg-maker/Rect

    Sorry I am a little lost rigt now

     


  9. Yeah... sorry, I think that's the last of it! (I really hope so)

     

    How can I animate a sprite by frames? 

     

    for instance this one?

                 def draw_actor_next(actor, x, y, enabled = true)
      bitmap = Cache.picture(actor.name + "_bg")
         rect = Rect.new(0, 0, 640,480)
        self.contents.blt( x , y + 3, bitmap, rect, 255)
        bitmap.dispose
               self.z = 999
             end

    Thank youu

×
Top ArrowTop Arrow Highlighted