RPG Maker Forums

Script is taken from a Steam Workshop 2013 re-release. Can't find working links to the script on it's own.

Code:
#==============================================================================
# ** Lemony's Smooth Map Scrolling (LSMS), (ReStaff March 2013), v.1.0
#==============================================================================
#  This scripts makes the camera move smoothly, but not just while following
# the player but also when using scroll map event commands and in loop maps,
# since it changes how the map scroll is handled by the system.
#==============================================================================
# (*) How to use.-
#==============================================================================
# * You can change the strength of the movement delay by editing LSMS_STR to
# any number you wish, lower values means less delay, and bigger values means
# a stronger delay.
#
# * You can turn off the system at any time during the game, by activating the
# switch that has the id that you can specify in LSMS_SWT variable below.
#
# * The script adjusts the delay strength on the run to avoid letting the
# player off screen when the player is moving or running, to do this, it uses
# a base  value that represents the base speed of the player, change that value
# in LSMS_SPD if you use another default speed for the player. (Default is 4)
#==============================================================================
# (**) Terms of Use.-
#==============================================================================
# This script is free to use in any non commercial game or project created with
# any RPG Maker with a valid license as long as explicit credits are given to
# the author (Lemony).
# If you want to use this script in a commercial game, you must pay a one time
# fee of USD 6.99 per title plus explicit credits to the author (Lemony).
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Smooth Scrolling Delay Strength.                                  [OPT]
  #--------------------------------------------------------------------------
  LSMS_STR = 69
  #--------------------------------------------------------------------------
  # * Smooth Scrolling Off Switch (System goes off when activated).     [OPT]
  #--------------------------------------------------------------------------
  LSMS_SWT = 10
  #--------------------------------------------------------------------------
  # * Default Game Player Speed.                                        [OPT]
  #--------------------------------------------------------------------------
  LSMS_SPD = 4
  #--------------------------------------------------------------------------
  # * Alias Setup.                                                      [MOD]
  #--------------------------------------------------------------------------
  alias lsms_setup setup
  def setup(map_id)
    lsms_setup(map_id)
    @lsms_real_x = @lsms_real_y = 0
  end
  #--------------------------------------------------------------------------
  # * Alias Scroll Down.                                                [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_down scroll_down
  def scroll_down(distance)
    if $game_switches[LSMS_SWT]
      lsms_scroll_down(distance)
      return
    end
    if loop_vertical?
      @lsms_real_y += distance
      if @display_y > @map.height
        @lsms_real_y %= @map.height
        @display_y %= @map.height
      end
      @parallax_y += distance if @parallax_loop_y
    else
      last_y = @lsms_real_y
      @lsms_real_y = [@lsms_real_y + distance, (self.height - screen_tile_y)].min
      @parallax_y += @lsms_real_y - last_y
    end
  end
  #--------------------------------------------------------------------------
  # * Alias Scroll Left.                                                [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_left scroll_left
  def scroll_left(distance)
    if $game_switches[LSMS_SWT]
      lsms_scroll_left(distance)
      return
    end
    if loop_horizontal?
      @lsms_real_x -= distance
      if @display_x < 0
        @lsms_real_x %= @map.width
        @display_x %= @map.width
      end
      @parallax_x += distance if @parallax_loop_x
    else
      last_x = @lsms_real_x
      @lsms_real_x = [@lsms_real_x - distance, 0].max
      @parallax_x += @lsms_real_x - last_x
    end
  end
  #--------------------------------------------------------------------------
  # * Alias Scroll Right.                                               [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_right scroll_right
  def scroll_right(distance)
    if $game_switches[LSMS_SWT]
      lsms_scroll_right(distance)
      return
    end
    if loop_horizontal?
      @lsms_real_x += distance
      if @display_x > @map.width
        @lsms_real_x %= @map.width
        @display_x %= @map.width
      end
      @parallax_x += distance if @parallax_loop_x
    else
      last_x = @lsms_real_x
      @lsms_real_x = [@lsms_real_x + distance, (self.width - screen_tile_x)].min
      @parallax_x += @lsms_real_x - last_x
    end
  end
  #--------------------------------------------------------------------------
  # * Alias Scroll UP.                                                  [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_up scroll_up
  def scroll_up(distance)
    if $game_switches[LSMS_SWT]
      lsms_scroll_up(distance)
      return
    end
    if loop_horizontal?
      @lsms_real_y -= distance
      if @display_y < 0
        @lsms_real_y %= @map.height
        @display_y %= @map.height
      end
      @parallax_y += distance if @parallax_loop_y
    else
      last_y = @lsms_real_y
      @lsms_real_y = [@lsms_real_y - distance, 0].max
      @parallax_y += @lsms_real_y - last_y
    end
  end
  #--------------------------------------------------------------------------
  # * Update Scroll.                                                    [MOD]
  #--------------------------------------------------------------------------
  alias lsms_update_scroll update_scroll
  def update_scroll
    if !$game_switches[LSMS_SWT]
      x = ((@display_x - @lsms_real_x) ** 2 + (@display_x - @lsms_real_x) ** 2)
      y = ((@display_y - @lsms_real_y) ** 2 + (@display_y - @lsms_real_y) ** 2)
      spd_cor = (($game_player.real_move_speed - LSMS_SPD) * LSMS_STR)
      px = Math.sqrt(x) / [2, ((2 + (2 * LSMS_STR)) - spd_cor)].max
      py = Math.sqrt(y) / [2, ((2 + (2 * LSMS_STR)) - spd_cor)].max
      @display_x += (@display_x < @lsms_real_x) ? px : -px
      @display_y += (@display_y < @lsms_real_y) ? py : -py
      return unless scrolling?
      last_x = @display_x
      last_y = @display_y
      do_scroll(@scroll_direction, scroll_distance)
      @scroll_rest -= scroll_distance
    else
      lsms_update_scroll
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Scroll Distance.                                        [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_distance scroll_distance
  def scroll_distance
    lsms_on = !$game_switches[LSMS_SWT]
    lsms_on ? (2 ** @scroll_speed / 128.0) : lsms_scroll_distance
  end
end
Specifically, this section:
Code:
  alias lsms_setup setup
  def setup(map_id)
    lsms_setup(map_id)
    @lsms_real_x = @lsms_real_y = 0
  end
When smooth scrolling is enabled, map transfers + player starting positions leads to the camera not being centered on the player character. picture:
upload_2019-3-30_10-11-20.png

It's an edit over Game_Map, but I don't know how the engine/default code naturally centers the camera on the player sprite (when it can, anyway - exceptions being when you get to corners of maps and all that). This error(?) occurs with just this script in-game and nothing else added or modified to a blank RPG Maker project, so you can recreate this issue without needing the demo (place the player in a large map and paste the script under Materials).

Demo has been attached below.

EDIT:

I think it may actually be these sections also causing issues:
Code:
alias lsms_update_scroll update_scroll
  def update_scroll
    if !$game_switches[LSMS_SWT]
      x = ((@display_x - @lsms_real_x) ** 2 + (@display_x - @lsms_real_x) ** 2)
      y = ((@display_y - @lsms_real_y) ** 2 + (@display_y - @lsms_real_y) ** 2)
      spd_cor = (($game_player.real_move_speed - LSMS_SPD) * LSMS_STR)
      px = Math.sqrt(x) / [2, ((2 + (2 * LSMS_STR)) - spd_cor)].max
      py = Math.sqrt(y) / [2, ((2 + (2 * LSMS_STR)) - spd_cor)].max
      @display_x += (@display_x < @lsms_real_x) ? px : -px
      @display_y += (@display_y < @lsms_real_y) ? py : -py
      return unless scrolling?
      last_x = @display_x
      last_y = @display_y
      do_scroll(@scroll_direction, scroll_distance)
      @scroll_rest -= scroll_distance
    else
      lsms_update_scroll
    end
  end
  #--------------------------------------------------------------------------
  # * Calculate Scroll Distance.                                        [MOD]
  #--------------------------------------------------------------------------
  alias lsms_scroll_distance scroll_distance
  def scroll_distance
    lsms_on = !$game_switches[LSMS_SWT]
    lsms_on ? (2 ** @scroll_speed / 128.0) : lsms_scroll_distance
  end
end

Latest Threads

Latest Profile Posts

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.

Forum statistics

Threads
106,034
Messages
1,018,447
Members
137,820
Latest member
georg09byron
Top