The RPG Maker Resource Kit

RMRK RPG Maker Creation => Requests => Script Request => Topic started by: Alphablaster on March 20, 2011, 08:53:10 AM

Title: Fix pictures to Map Improvement?
Post by: Alphablaster on March 20, 2011, 08:53:10 AM
I have a request for Modern algebra's Fix pictures to map script
When i want to make a widescreen effect with pictures it also fixes to the map but it must follow the screen  :(
so what i would like is that only picture number 20 is fixed to the map and picture 1~19 must follow the screen
and maybe that it can be adjusted so you can have 10 pictures fixed and have 10 pictures follow the screen
here is the script that needs to be edited

Code: [Select]
#==============================================================================
#    Fix Pictures to Map
#    Version: 1.1
#    Author: modern algebra (rmrk.net)
#    Date: August 15, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This allows you to set the position of a picture by the X and Y position
#   of the map, rather than the screen, so that the picture won't move with you
#   when the screen scrolls. It also has a couple other features, such as
#   allowing you to set the Z value to show below characters, or below the
#   tiles to add another parallax (kind of).
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot above Main and below Materials in the
#   Script Editor (F11).
#
#    This switch is run by two switches and one variable that you specify.
#   They are:
#      FPM_SWITCH - This switch toggles the fix pictures feature. When this
#          switch is ON and a picture is shown, then that picture will be fixed
#          to the map coordinates you specify, not to the screen. This means
#          that if the screen scrolls, the picture will not scroll with it. It
#          is useful if you want to use a picture as an additional map layer,
#          or as a parallax. Note that this still sets it to pixels, so if you
#          want a picture to show up at the map coordinates 1, 2, you would set
#          it to 32, 64. To specify which switch should be used to control this
#          feature, go to line 56 and change the value to the ID of the switch
#          you want to use to control this feature.
#      FPM_Z_VARIABLE - This allows you to set the priority of the picture.
#          When showing a picture, the value of this ariable will determine the
#          z value of the picture. When the variable with this ID is set to 0,
#          the pictures are shown at their normal z value. Setting this
#          variable to 1 will place it below characters but above non-star
#          tiles. Setting this variable to 2 will draw the picture above all
#          tiles and characters except for "Above Characters" Events. Setting
#          it to 3 will put it below all tiles and characters but above the
#          parallax. Setting it to 4 will put it below everything, including
#          the parallax. Setting it to any other value directly sets the z of
#          that sprite to that value. To specify which variable controls this
#          feature, go to line 58 and set FPM_Z_VARIABLE to the ID of the
#          variable you want to use.
#==============================================================================
FPM_SWITCH = 99         # See line 22
FPM_Z_VARIABLE = 99     # See line 32
#==============================================================================
# ** Game_Picture
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    attr_reader - map_locked
#    aliased method - initialize, show
#==============================================================================

class Game_Picture
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_reader :map_locked
  attr_reader :fpm_viewport
  attr_reader :fpm_z
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_fixpicmp_initz_6yh3 initialize
  def initialize (*args)
    @map_locked = false
    @fpm_viewport = false
    malg_fixpicmp_initz_6yh3 (*args) # Run Original Method
    @fpm_z = 100 + self.number
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Show Picture
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fxpm_showpic_2dx4 show
  def show (*args)
    ma_fxpm_showpic_2dx4 (*args) # Run Original Method
    @map_locked = $game_switches[FPM_SWITCH]
    @fpm_viewport = ($game_variables[FPM_Z_VARIABLE] != 0) && ($game_variables[FPM_Z_VARIABLE] <= 300)
    if @fpm_viewport
      @fpm_z = case $game_variables[FPM_Z_VARIABLE]
      when 1 then 0
      when 2 then 200
      when 3 then -50
      when 4 then -150
      else
        @fpm_z = $game_variables[FPM_Z_VARIABLE]
      end
    else
      @fpm_z = 100 + self.number
    end
  end
end

#==============================================================================
# ** Sprite_Picture
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new attr_accessor - fpm_vp1, fpm_vp2
#    aliased method - update
#==============================================================================

class Sprite_Picture
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :fpm_vp1
  attr_accessor :fpm_vp2
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_fpm_updt_oxoy_5tb3 update
  def update (*args)
    pic_name = @picture_name
    ma_fpm_updt_oxoy_5tb3 (*args) # Run Original Method
    if pic_name != @picture_name
      self.viewport = @picture.fpm_viewport ? @fpm_vp1 : @fpm_vp2
      @picture_name = pic_name if self.viewport.nil?
      self.ox, self.oy = 0, 0 # Reset OX and OY for new picture
    end
    if @picture.map_locked
      self.ox, self.oy = $game_map.display_x / 8, $game_map.display_y / 8
    end
    self.z = @picture.fpm_z
  end
end

#==============================================================================
# ** Spriteset_Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - create_pictures
#==============================================================================

class Spriteset_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Pictures
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_fxpix_crtpi_5oq1 create_pictures
  def create_pictures (*args)
    malg_fxpix_crtpi_5oq1 (*args) # Run Original Method
    @picture_sprites.each { |sprite|
      sprite.fpm_vp1 = @viewport1
      sprite.fpm_vp2 = @viewport2
    }
  end
end

I have attached an example of what i mean
please help me   :)
Title: Re: Fix pictures to Map Improvement?
Post by: modern algebra on March 20, 2011, 01:52:10 PM
Well, the Fix Pictures to Map script doesn't automatically fix all pictures to the screen?

What it does is so that if you have the switch ON when you set a new picture, then that picture will be fixed to the map. If you want a picture to follow the screen, all you need to do is turn the switch OFF before setting it. Then, the first picture would still be fixed to the map while the second will follow the screen.
Title: Re: Fix pictures to Map Improvement?
Post by: Alphablaster on March 20, 2011, 05:55:46 PM
Now this is what happens (see attachments)  :(
The FPM switch is at 1
When i choose 0 i move under it
When i choose 1 the widescreen appears under the volcano when FPM_z Variable is 1
3 the volcano dissapears
4 is the same

I also have the events in the attachments
maybe they'll explain the situation a bit more


Title: Re: Fix pictures to Map Improvement?
Post by: modern algebra on March 20, 2011, 10:18:22 PM
Sorry, I'm confused. I assume this means you are no longer having the problem with fixing the picture to the screen and you are now on to priority? I don't know how to better explain it than I do in the Instructions.

Judging from your event, try setting the FPM variable back to 0 right before showing the "Widescreen" picture in Untitled-6.
Title: Re: Fix pictures to Map Improvement?
Post by: Alphablaster on March 21, 2011, 04:56:41 PM
Ah so that's how it works  :lol:
thanks now it works and heres the result   :) (see attachments)