Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Meph's Map Scrolling System
- #------------------------------------------------------------------------------
- # MephistoX
- # Version 1.1
- # 01-28-2015
- #------------------------------------------------------------------------------
- # * Version History :
- #
- # Version 1 ---------------------------------------------------- (03-01-2014)
- # - Log : First Version Released
- # Version 1.1 -------------------------------------------------- (01-28-2015)
- # - Log : Change to Game_System to Store Scrolling Variables
- #------------------------------------------------------------------------------
- # * Requirements :
- #
- # - Meph's Sorted Methods and Classes
- #------------------------------------------------------------------------------
- # * Description :
- #
- # This Script allows you to block the map scroll for certain maps, or even
- # for specific part of the map at some x,y point.
- #
- # Also allow you to determine the part of the map visible when you are
- # teleported. This is useful to create several parts of the map in just one.
- #
- #------------------------------------------------------------------------------
- # * Instructions :
- #
- # Place The Script Above Main as Usual
- # Refer to Syntax to Check how to configure the Scrolling
- #------------------------------------------------------------------------------
- # * Syntax :
- #
- # - To create a Special Scrollable Map use before a transfer command:
- # <<$game_temp.set_scroll_flags(Block, Scroll, SX, SY, BR, BL, BU, BD)>>
- #
- # Reeplace:
- # - Block: true/false if you want to block the scroll for the map
- # - Scroll: true/false if after transfer map must scroll
- # - SX: Position X to Scroll after transfer
- # - SY: Position Y to Scroll after transfer
- # - BD: Tile visible until block scroll from Right direction
- # - BL: Tile visible until block scroll from Left direction
- # - BU: Tile visible until block scroll from Up direction
- # - BD: Tile visible until block scroll from Down direction
- #
- #
- # - Each time you transfer to a new map you must define again the
- # scroll parameters (to avoid problems), if you don't want a
- # Special Scrollable Map, use before a transfer command:
- # $script << $game_system.clean_scroll_flags >>
- #
- #------------------------------------------------------------------------------
- # * Terms & Conditions:
- #
- # ** Made by MephistoX
- # ** Free for non-commercial & commercial use.
- # ** Any modifications to the system are not to be re-distributed without my
- # consent.
- #==============================================================================
- #==============================================================================
- # ** Game_Player
- #==============================================================================
- class Game_Player
- #--------------------------------------------------------------------------
- # ** Alias Listing
- #--------------------------------------------------------------------------
- alias_method :meph_nonscroll_gplay_prtransf, :perform_transfer
- alias_method :meph_nonscroll_gplay_updscroll, :update_scroll
- #--------------------------------------------------------------------------
- # ** Get Map_id
- #--------------------------------------------------------------------------
- def map_id
- $game_map.map_id
- end
- #--------------------------------------------------------------------------
- # * Execute Player Transfer
- #--------------------------------------------------------------------------
- def perform_transfer
- # The Usual
- meph_nonscroll_gplay_prtransf
- # Set Variable
- sflag = $game_system.scroll_flags
- # If AutoScroll Map
- if sflag[:scroll]
- # Clean Scroll Flag
- sflag[:scroll] = false
- # Set Display Position (Scroll to)
- $game_map.set_display_pos(sflag[:scroll_x], sflag[:scroll_y])
- end
- end
- #--------------------------------------------------------------------------
- # ** Update Scroll : Update Map Scroll for Player
- #--------------------------------------------------------------------------
- def update_scroll(*args)
- # Check if Map is in the no_scrollable List
- return if $game_system.scroll_flags[:block]
- # The Usual
- meph_nonscroll_gplay_updscroll(*args)
- end
- end
- #==============================================================================
- # ** Game_Map
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ** Alias Listing
- #--------------------------------------------------------------------------
- alias_method :meph_nonscroll_gmap_scrolllf, :scroll_left
- alias_method :meph_nonscroll_gmap_scrollrt, :scroll_right
- alias_method :meph_nonscroll_gmap_scrollup, :scroll_up
- alias_method :meph_nonscroll_gmap_scrolldn, :scroll_down
- #--------------------------------------------------------------------------
- # * Can Scroll? : Check if Can Scroll Map Display
- #--------------------------------------------------------------------------
- def can_scroll?(direction)
- # Set Variable
- gtdir = $game_system.scroll_flags[direction]
- # Return true if no parameteres assigned
- return true if gtdir.nil?
- # Check according with set parameters
- case direction
- when :block_r ; return @display_x < gtdir
- when :block_l ; return @display_x > gtdir
- when :block_u ; return @display_y > gtdir
- when :block_d ; return @display_y < gtdir
- end
- end
- #--------------------------------------------------------------------------
- # * Scroll Left
- #--------------------------------------------------------------------------
- def scroll_left(*args)
- # Return if can't scroll
- return unless can_scroll?(:block_l)
- # The Usual
- meph_nonscroll_gmap_scrolllf(*args)
- end
- #--------------------------------------------------------------------------
- # * Scroll Right
- #--------------------------------------------------------------------------
- def scroll_right(*args)
- # Return if can't scroll
- return unless can_scroll?(:block_r)
- # The Usual
- meph_nonscroll_gmap_scrollrt(*args)
- end
- #--------------------------------------------------------------------------
- # * Scroll Up
- #--------------------------------------------------------------------------
- def scroll_up(*args)
- # Return if can't scroll
- return unless can_scroll?(:block_u)
- # The Usual
- meph_nonscroll_gmap_scrollup(*args)
- end
- #--------------------------------------------------------------------------
- # * Scroll Down
- #--------------------------------------------------------------------------
- def scroll_down(*args)
- # Return if can't scroll
- return unless can_scroll?(:block_d)
- # The Usual
- meph_nonscroll_gmap_scrolldn(*args)
- end
- end
- #==============================================================================
- # ** Game_Temp
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :scroll_flags
- #--------------------------------------------------------------------------
- # ** Alias Listing
- #--------------------------------------------------------------------------
- alias_method :meph_nonscroll_gsys_init, :initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- # The Usual
- meph_nonscroll_gsys_init
- # Set Scroll Flags [Block Scroll?, Set Scroll?, x, y]
- @scroll_flags = {:block => false, :scroll => false,
- :scroll_x => nil, :scroll_y => nil,
- :block_r => nil, :block_l => nil,
- :block_u => nil, :block_d => nil}
- end
- #--------------------------------------------------------------------------
- # * Set Scroll Flags : Set Parameters for Hash
- #--------------------------------------------------------------------------
- def set_scroll_flags(*args)
- # Set Flags on call
- @scroll_flags = {:block => args[0], :scroll => args[1],
- :scroll_x => args[2], :scroll_y => args[3],
- :block_r => args[4], :block_l => args[5],
- :block_u => args[6], :block_d => args[7]}
- end
- #--------------------------------------------------------------------------
- # * Clean Scroll Flags : Set Parameters for Scroll to initial values
- #--------------------------------------------------------------------------
- def clean_scroll_flags
- # Clean Scroll Flags
- @scroll_flags = {:block => false, :scroll => false,
- :scroll_x => nil, :scroll_y => nil,
- :block_r => nil, :block_l => nil,
- :block_u => nil, :block_d => nil}
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement