Marin

Age 19
Male
Seen June 27th, 2021
Posted June 27th, 2021
966 posts
5.2 Years
Enhanced Staircases

This script provides pixel movement while walking on staircases, while also slowing down movement to capture the real feeling and motion of a staircase.

Usage
To make a stair work smoothly, it must have one event at the bottom, and one at the top (not on the staircase; one tile outwards). Staircase events utilize comments to configure the properties of the stairs. These comments are not compiled it any different format unlike, say, trainer generation, and as such do not require you to restart RPG Maker XP.

For events to be able to walk on the staircases, they must have their Through flag set to ON before they attempt to walk on the Stair events. Following Pokémon can walk on stairs to some degree, but there will be visual oddities when you come off the staircase. I do not intend to fix this, as it is an issue deeply rooted in how dependent events work in Pokémon Essentials.

The name of a staircase event must be
Slope
, and the event must contain a comment with the following text:
Slope: AxB
where A and B are numbers, specifying how many tiles away the second event is.
If the staircase is wider than 1 tile, this must match up with event that has the same stair index, as explained below.

If your staircase is more than 1 tile wide, you require an additional
Width: A/B
comment, where A is the index of the event in the staircase (i.e. if it's the bottom part of the staircase 0, if it's one higher 1, etc) and B is the total width of the staircase.
If you understand this explanation properly, then you'll agree that this means that the top event of a 3-wide staircase will say
Width: 2/3
.

It is also possible to specify at which point during movement from the event to the start of the staircase to increment the vertical offset. By default, this is a value of 16 pixels. This means that you move without any vertical increase for the first 16 pixels, and after that start climbing the staircase. To change this offset, write in a comment,
Offset: Apx
, where A is the number of pixels after which to start climbing the staircase.

Installation
Download the script below and insert it in a new script section above
Main
.
EnhancedStaircases
Please follow all the instructions and examples in this thread before asking for help.

Examples
That explanation was likely rather hard to really grasp/comprehend, so below is an example of a good staircase setup. It's for the one shown at the top of this thread.

The events are at the bottom and top of the staircase, but not on the staircase. It is important to note that the name of each of these events must be Slope.
The lower railing of this bridge has its priority set separately from the bridge tiles, which is why the player appears below said railing.
Click the spoiler below to see the contents of the events.
Spoiler:

Bottom Left.
This is the lowest starting point of the 2-wide staircase, so the Width field must say
0/2
.
The distance between this event and the lowest end point of the staircase is 3 pixels horizontally, and -1 pixel vertically, meaning the Slope field must say 3x-1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Top Left.
This is the highest starting point of the 2-wide staircase, so the Width field must say
1/2
.
The distance between this event and the lowest end point of the staircase is 3 pixels horizontally, and -1 pixel vertically, meaning the Slope field must say 3x-1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Bottom Right.
This is the lowest end point of the 2-wide staircase, so the Width field must say
0/2
.
The distance between this event and the lowest starting point of the staircase is -3 pixels horizontally, and 1 pixel vertically, meaning the Slope field must say -3x1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Top Right.
This is the highest end point of the 2-wide staircase, so the Width field must say
1/2
.
The distance between this event and the lowest starting point of the staircase is -3 pixels horizontally, and 1 pixel vertically, meaning the Slope field must say -3x1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.



What makes a good stair tile?
When you walk on or off a staircase, you must end up on a tile perfectly. A staircase must have as many points to walk on it as there are points to walk off it.

Please view the following examples, and why they do or don't work.
Example 1
Spoiler:

This is a simple staircase which works perfectly. The horizontal red line in the center of the tile represents the 16 pixel non-vertical-movement offset, with which the angle at which you would move up the stairs is just about perfect with the stair tiles. This is a great staircase.



Example 2
Spoiler:

This takes the staircase from the previous example, and uses just one of the two stacked staircases.
As you can see, you can walk on these staircases nicely, but there is no seamless way to get off it, as you end up in the middle of a tile under normal circumstances. This is not a good staircase.



Examples 3 & 4
Spoiler:

Although you can walk up these staircases nicely, there is no way to introduce an angle to these staircases, making the character walk in a straight line without any inclination. All staircases need to have some degree of inclination, so these are not good staircases.



Example 5
Spoiler:

The Driftveil Drawbridge might not be the first thing you think of when you think of stairs, but its beginning and end does have a small incline/slope. This script is usable for these situations too, and you can see that the angle and general transition works well. This is a great staircase.



Example 6
Spoiler:

This staircase works by the standards set above, but you can see that the angle introduced with a 16 pixel offset does not match up at all with the angle in the tile itself. You could play around with the offset or tile positioning to fix this, but this is not an example of a great staircase.



Example 7
Spoiler:

All starting points match up with the end points, the angle matches that of the tiles. This is a great staircase.

Marin

Age 19
Male
Seen June 27th, 2021
Posted June 27th, 2021
966 posts
5.2 Years
Updated to v1.3:
- Now fully compatible with mej's Following Pokémon script!
- Fixed issue where the stair would be triggerable by walking on the event and off again, and then going over or under the staircase.

Check out the example staircase with a follower!

Marin

Age 19
Male
Seen June 27th, 2021
Posted June 27th, 2021
966 posts
5.2 Years
Updated to v1.4:
  • The offset property is now actually optional (it used not to work without the comment).

Marin

Age 19
Male
Seen June 27th, 2021
Posted June 27th, 2021
966 posts
5.2 Years
Updated to v1.5:
  • Stair progress/data is now cleared upon map transfer, which means it's also usable for, say, stairs that lead up to a second floor via a transfer event.

Marin

Age 19
Male
Seen June 27th, 2021
Posted June 27th, 2021
966 posts
5.2 Years
Updated to v1.6:
  • Offset property works again

Shashu-Greninja

"With great power comes great responsibility"- When you have the power to change the world it's your responsibility to make the right decisions to change it in the positive way that will benefit everybody.

Male
Kalos Region
Seen 2 Days Ago
Posted September 21st, 2021
97 posts
1.3 Years
Updated to v1.6:
  • Offset property works again
Thanks for the script, it works great but I am facing one issue with it. After adding the script in my game the ledges became weird, it appears as if you are walking through it rather than jumping over it. Can you please look after it?
Seen January 14th, 2021
Posted January 7th, 2021
19 posts
2.5 Years
I created a fix for the ledge issue back in November. The issue was caused by a change to the jump mechanic, which had been updated in 18.1.

This script change starts at around line 507, with "def screen_Y":

Spoiler:
def screen_y
    ret = screen_y_ground # new - required for v18.1 jump mechanic
    real_y = @real_y
    if on_stair?
      if @real_x / Game_Map::X_SUBPIXELS.to_f <= @stair_start_x * Game_Map::TILE_WIDTH &&
         @stair_end_x < @stair_start_x
        distance = (@stair_start_x - @stair_end_x) * Game_Map::REAL_RES_X -
            2.0 * @stair_begin_offset * Game_Map::X_SUBPIXELS
        rpos = @real_x - @stair_end_x * Game_Map::REAL_RES_X - @stair_begin_offset * Game_Map::X_SUBPIXELS
        fraction = 1 - rpos / distance.to_f
        if fraction >= 0 && fraction <= 1
          diff = fraction * (@stair_end_y - @stair_start_y) * Game_Map::REAL_RES_Y
          real_y += diff
          if self.is_a?(Game_Player)
            if SMOOTH_SCROLLING
              @view_offset_y += diff - (@stair_last_increment || 0)
            else
              $game_map.scroll_down(diff - (@stair_last_increment || 0))
            end
          end
          @stair_last_increment = diff
        end
        if fraction >= 1
          endy = @stair_end_y
          if @stair_end_y < @stair_start_y
            endy -= @stair_y_position
          else
            endy -= @stair_y_position
          end
          @y = endy
          @real_y = endy * Game_Map::REAL_RES_Y
          @view_offset_y = 0 if SMOOTH_SCROLLING && self.is_a?(Game_Player)
          clear_stair_data
          return stair_screen_y
        end
      elsif @real_x / Game_Map::X_SUBPIXELS.to_f >= @stair_start_x * Game_Map::TILE_WIDTH &&
          @stair_end_x > @stair_start_x
        distance = (@stair_end_x - @stair_start_x) * Game_Map::REAL_RES_X -
            2.0 * @stair_begin_offset * Game_Map::X_SUBPIXELS
        rpos = @stair_start_x * Game_Map::REAL_RES_X - @real_x + @stair_begin_offset * Game_Map::X_SUBPIXELS
        fraction = rpos / distance.to_f
        if fraction <= 0 && fraction >= -1
          diff = fraction * (@stair_start_y - @stair_end_y) * Game_Map::REAL_RES_Y
          real_y += diff
          if self.is_a?(Game_Player)
            if SMOOTH_SCROLLING
              @view_offset_y += diff - (@stair_last_increment || 0)
            else
              $game_map.scroll_down(diff - (@stair_last_increment || 0))
            end
          end
          @stair_last_increment = diff
        end
        if fraction <= -1
          endy = @stair_end_y
          if @stair_end_y < @stair_start_y
            endy -= @stair_y_position
          else
            endy -= @stair_y_position
          end
          @y = endy
          @real_y = endy * Game_Map::REAL_RES_Y
          @view_offset_y = 0 if SMOOTH_SCROLLING && self.is_a?(Game_Player)
          clear_stair_data
          return stair_screen_y
        end
      else
        clear_stair_data
      end
    # elsif jumping?
      # n = (@jump_count - @jump_peak).abs
      # return (real_y - self.map.display_y + 3) / 4 + Game_Map::TILE_HEIGHT -
          # (@jump_peak * @jump_peak - n * n) / 2
    # end
    # Edit start
    elsif jumping?
      if @jump_count > 0
        jump_fraction = ((@jump_count * jump_speed_real / Game_Map::REAL_RES_X) - 0.5).abs   # 0.5 to 0 to 0.5
      else
        jump_fraction = ((@jump_distance_left / @jump_distance) - 0.5).abs   # 0.5 to 0 to 0.5
      end
      ret += @jump_peak * (4 * jump_fraction**2 - 1)
    end
    if jumping?
        return ret
    end
    #
    return (real_y - self.map.display_y + 3) / 4 + (Game_Map::TILE_HEIGHT)
  end
end

Canal_do_Lontra

Oshawott uses Razor Shell

Age 16
Male
Unova
Seen 3 Days Ago
Posted 3 Days Ago
177 posts
1.8 Years
Updated to v1.3:
- Now fully compatible with mej's Following Pokémon script!
- Fixed issue where the stair would be triggerable by walking on the event and off again, and then going over or under the staircase.

Check out the example staircase with a follower!
hello Marin I am with EBDX on essentials 18.1, and it isn't working, can you help me?
Seen November 5th, 2021
Posted September 1st, 2021
1 posts
2.8 Years
Enhanced Staircases

This script provides pixel movement while walking on staircases, while also slowing down movement to capture the real feeling and motion of a staircase.

Usage
To make a stair work smoothly, it must have one event at the bottom, and one at the top (not on the staircase; one tile outwards). Staircase events utilize comments to configure the properties of the stairs. These comments are not compiled it any different format unlike, say, trainer generation, and as such do not require you to restart RPG Maker XP.

For events to be able to walk on the staircases, they must have their Through flag set to ON before they attempt to walk on the Stair events. Following Pokémon can walk on stairs to some degree, but there will be visual oddities when you come off the staircase. I do not intend to fix this, as it is an issue deeply rooted in how dependent events work in Pokémon Essentials.

The name of a staircase event must be
Slope
, and the event must contain a comment with the following text:
Slope: AxB
where A and B are numbers, specifying how many tiles away the second event is.
If the staircase is wider than 1 tile, this must match up with event that has the same stair index, as explained below.

If your staircase is more than 1 tile wide, you require an additional
Width: A/B
comment, where A is the index of the event in the staircase (i.e. if it's the bottom part of the staircase 0, if it's one higher 1, etc) and B is the total width of the staircase.
If you understand this explanation properly, then you'll agree that this means that the top event of a 3-wide staircase will say
Width: 2/3
.

It is also possible to specify at which point during movement from the event to the start of the staircase to increment the vertical offset. By default, this is a value of 16 pixels. This means that you move without any vertical increase for the first 16 pixels, and after that start climbing the staircase. To change this offset, write in a comment,
Offset: Apx
, where A is the number of pixels after which to start climbing the staircase.

Installation
Download the script below and insert it in a new script section above
Main
.
EnhancedStaircases
Please follow all the instructions and examples in this thread before asking for help.

Examples
That explanation was likely rather hard to really grasp/comprehend, so below is an example of a good staircase setup. It's for the one shown at the top of this thread.

The events are at the bottom and top of the staircase, but not on the staircase. It is important to note that the name of each of these events must be Slope.
The lower railing of this bridge has its priority set separately from the bridge tiles, which is why the player appears below said railing.
Click the spoiler below to see the contents of the events.
Spoiler:

Bottom Left.
This is the lowest starting point of the 2-wide staircase, so the Width field must say
0/2
.
The distance between this event and the lowest end point of the staircase is 3 pixels horizontally, and -1 pixel vertically, meaning the Slope field must say 3x-1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Top Left.
This is the highest starting point of the 2-wide staircase, so the Width field must say
1/2
.
The distance between this event and the lowest end point of the staircase is 3 pixels horizontally, and -1 pixel vertically, meaning the Slope field must say 3x-1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Bottom Right.
This is the lowest end point of the 2-wide staircase, so the Width field must say
0/2
.
The distance between this event and the lowest starting point of the staircase is -3 pixels horizontally, and 1 pixel vertically, meaning the Slope field must say -3x1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.


Top Right.
This is the highest end point of the 2-wide staircase, so the Width field must say
1/2
.
The distance between this event and the lowest starting point of the staircase is -3 pixels horizontally, and 1 pixel vertically, meaning the Slope field must say -3x1.
The Offset parameter has been set to 16px to showcase how it is changed, although this is the default value and may as such be omitted.
It is important to note that the name of each of these events must be Slope.



What makes a good stair tile?
When you walk on or off a staircase, you must end up on a tile perfectly. A staircase must have as many points to walk on it as there are points to walk off it.

Please view the following examples, and why they do or don't work.
Example 1
Spoiler:

This is a simple staircase which works perfectly. The horizontal red line in the center of the tile represents the 16 pixel non-vertical-movement offset, with which the angle at which you would move up the stairs is just about perfect with the stair tiles. This is a great staircase.



Example 2
Spoiler:

This takes the staircase from the previous example, and uses just one of the two stacked staircases.
As you can see, you can walk on these staircases nicely, but there is no seamless way to get off it, as you end up in the middle of a tile under normal circumstances. This is not a good staircase.



Examples 3 & 4
Spoiler:

Although you can walk up these staircases nicely, there is no way to introduce an angle to these staircases, making the character walk in a straight line without any inclination. All staircases need to have some degree of inclination, so these are not good staircases.



Example 5
Spoiler:

The Driftveil Drawbridge might not be the first thing you think of when you think of stairs, but its beginning and end does have a small incline/slope. This script is usable for these situations too, and you can see that the angle and general transition works well. This is a great staircase.



Example 6
Spoiler:

This staircase works by the standards set above, but you can see that the angle introduced with a 16 pixel offset does not match up at all with the angle in the tile itself. You could play around with the offset or tile positioning to fix this, but this is not an example of a great staircase.



Example 7
Spoiler:

All starting points match up with the end points, the angle matches that of the tiles. This is a great staircase.







i Have A Question for This when Making the staircase what do you put on the right side if you made a bridge i have the Left Stuff Correct But I Cant Seem To Get it Correct For the Right side
Male
Seen October 15th, 2021
Posted October 9th, 2021
5 posts
5.7 Years
I am getting this error message, is there anything I can do to fix it. I followed your Instructions carefully.
Spoiler:
[Pokémon Essentials version 19.1]

Exception: ArgumentError
Message: wrong number of arguments (given 2, expected 1)

Backtrace:
047:Game_Player:281:in `check_event_trigger_touch'
372:Custom_Stairs by Marin:292:in `check_event_trigger_touch'
372:Custom_Stairs by Marin:337:in `move_up'
047:Game_Player:338:in `update_command_new'
045:Game_Character:859:in `update_command'
048:Game_Player_Visuals:66:in `update_command'
045:Game_Character:845:in `update'
372:Custom_Stairs by Marin:471:in `update'
047:Game_Player:312:in `update'
032:Scene_Map:158:in `block in update'


Edit: Nvm I found out why, this is for v18 not v19.