#============================================================================== # Pixel Offset # by IMP1 #------------------------------------------------------------------------------ # This script allows events' locations on screen to be offset. # # Usage: # In an event, create a new comment. # Add either of the following: # MOVE 0, 0 # OFFSET 0, 0 # Change the first 0 to the number, in pixels, that you want the event to be # moved horizontally, and the second 0 to the vertical offset. If you use MOVE, # it will move the event for that specific page, and if you use OFFSET, it will # offset the event for all pages. When combining OFFSET and MOVE, MOVE will # take priorty. # #------------------------------------------------------------------------------ # Compatability: # # Aliased Methods: # Game_Event.refresh # Sprite_Character.update # # New Methods/Fields: # imp1_pixel_offset # # Overwritten Methods: # none. # #------------------------------------------------------------------------------ # Version History: # v1.0 [2014/05/31] : Initial release. # v1.1 [2014/06/01] : Fixed Erase Event crashing game. #============================================================================== module IMP1_Pixel_Offset #------------------------------------------------------------------------------ # CONFIGURATION BEGIN: #------------------------------------------------------------------------------ # This is the text affecting all pages of an event ALL_PAGES = "OFFSET" # This is the text affecting a specific page of an event THIS_PAGE = "MOVE" #------------------------------------------------------------------------------ # CONFIGURATION END: #------------------------------------------------------------------------------ end # IMP1_Pixel_Offset #============================================================================== # Game_Event # Read comments for MOVE or OFFSET, extract the offset numbers, and save in # the new variable 'imp1_pixel_offset'. #============================================================================== class Game_Event #-------------------------------------------------------------------------- # Creates offset field #-------------------------------------------------------------------------- attr_reader :imp1_pixel_offset #-------------------------------------------------------------------------- # Checks for comments, and adds offsets. #-------------------------------------------------------------------------- alias imp_offset_refresh refresh unless $@ def refresh(*args) imp_offset_refresh(*args) @imp1_pixel_offset = [0, 0] for i in 0...@event.pages.length next if @event.pages[i].nil? page_list = @event.pages[i].list if !page_list.nil? for i in 0...page_list.size next if page_list[i].code != 108 text = page_list[i].parameters[0].clone if text.gsub!(/\s*#{IMP1_Pixel_Offset::ALL_PAGES}\s*/, '') offset = text.split(',') @imp1_pixel_offset[0] = offset[0].to_i @imp1_pixel_offset[1] = offset[1].to_i end end end end if !@page.nil? && !@page.list.nil? for i in 0...@page.list.size next if @page.list[i].code != 108 text = @page.list[i].parameters[0].clone if text.gsub!(/\s*#{IMP1_Pixel_Offset::THIS_PAGE}\s*/, '') offset = text.split(',') @imp1_pixel_offset[0] = offset[0].to_i @imp1_pixel_offset[1] = offset[1].to_i end end end end end # Game_Event #============================================================================== # Sprite_Character # Access event's offset and incrememnt self.x by that amount. #============================================================================== class Sprite_Character < Sprite_Base #-------------------------------------------------------------------------- # Adds offsets to events. #-------------------------------------------------------------------------- alias imp_offset_update update unless $@ def update(*args) imp_offset_update(*args) if @character.is_a?(Game_Event) self.x += @character.imp1_pixel_offset[0] self.y += @character.imp1_pixel_offset[1] end end end # Sprite_Character