设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 135|回复: 0

[转载发布] Stairs Movement

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9071

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58883
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68848

    灌水之王

    发表于 2026-8-2 16:55:49 | 显示全部楼层 |阅读模式
    Stairs Movement v1.0
    FenixFyreX

    Introduction
    This script allows movement on a diagonal line to emulate scaling staircases.

    Features
    - Easily designate a staircase via a region
    - Change the speed at which steps are taken to match the pace of moving up/down the staircase
    - Alter the y coordinate offset of the character sprite to match the tileset staircase center

    Screenshots
    Not really applicable as you'd need to see it in action. Just put it in your project, set up a staircase, and try it out.

    How to Use
    1> Install the script below the default scripts and above Main.
    2> Edit the script config to change the staircase region id to your liking.
    3> Create a staircase on the map with your tileset.
    4> Along the path of the staircase, put that region down.
    5> Playtest!

    Demo
    Mediafire - Stairs Movement

    Script
    Spoiler                Code:       
    1. #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=## Stairs Movement v 1.1#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=### FenixFyreX## Final Fantasy VI had stairs that the player actually walked up. Their direction# became two way on these stairs, left or right. This script replicates that# feature.##-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#StairsRegionID = 10   # The region ID to use for designating staircasesStairsOffset   = 4    # The height of one tileset staircase plank (about 4px)CharAnimSpeed  = 2    # The speed at which a sprite cycles through frames#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=## End of Config. Do not edit below.#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#class Game_Map  def stairs?(x,y)    region_id(x,y) == StairsRegionID  endendclass Game_CharacterBase    # give other coders access to checking stairs status  attr_reader :on_stairs, :stairs_d  alias on_stairs? on_stairs    # check whether character is on stairs  def check_stairs    @on_stairs = stairs?(0)  end    # Checks if there are any sets of stairs in the given direction  def stairs?(d)    return case d    when 0      $game_map.stairs?(@x,@y)    when 2      $game_map.stairs?(@x-1,@y+1) || $game_map.stairs?(@x+1,@y+1)    when 4      $game_map.stairs?(@x-1,@y-1) || $game_map.stairs?(@x-1,@y+1)    when 6      $game_map.stairs?(@x+1,@y-1) || $game_map.stairs?(@x+1,@y+1)    when 8      $game_map.stairs?(@x-1,@y-1) || $game_map.stairs?(@x+1,@y-1)    else      false    end  end    # Checks passability in the given direction for stairs  def stairs_passable?(x, y, d)    x2 = $game_map.round_x_with_direction(x, d)    y2 = $game_map.round_y_with_direction(y, d)    return false unless $game_map.valid?(x2, y2)    return true if @through || debug_through?    return false unless map_passable?(x, y, d)    return false if collide_with_characters?(x2, y2)    return true  end    # Moves the character in the given direction diagonally up or down stairs  def move_diag_stairs(d, horz, vert, turn_ok)    x,y = @x+horz,@y+vert    horz = [4,6][[-1,1].index(horz)]    vert = [8,2][[-1,1].index(vert)]    @move_succeed = stairs_passable?(x,y,d)    d = [4,6][[[4,8],[6,8],[4,2],[6,2]].index([horz,vert])%2]    set_direction(d) if turn_ok    if @move_succeed      @x = $game_map.round_x_with_direction(@x, horz)      @y = $game_map.round_y_with_direction(@y, vert)      @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))      @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))      increase_steps    end  end    # Returns the stair vector for the given direction  def stair_vector(d)    x,y = 0,0    case d    when 4,6      x = [-1,1][[4,6].index(d)]      y = $game_map.stairs?(@x+x,@y-1) ? -1 : 1    when 2,8      y = [-1,1][[8,2].index(d)]      x = $game_map.stairs?(@x-1,@y+y) ? -1 : 1    end    [x,y]  end    # Checks whether or not the character is not getting on or off stairs  def midstairs?    @on_stairs && stairs?(reverse_dir(@direction))  end    # Alters original move method to put stairs into effect  alias move_straight_no_stairs move_straight  def move_straight(d, turn_ok = true)    if on_stairs? && stairs?(d)      @stairs_d = d      move_diag_stairs(d, *stair_vector(d), turn_ok)    else      d = @direction if @on_stairs && [2,8].include?(d)      move_straight_no_stairs(d, turn_ok)    end    check_stairs  end    alias move_diagonal_for_stairs move_diagonal  def move_diagonal(horz, vert)    if self.is_a?(Game_Follower) && @preceding_character.on_stairs?      check_stairs      if on_stairs? && stairs?(@preceding_character.stairs_d)        d = @preceding_character.stairs_d        move_diag_stairs(d, *stair_vector(d), true)      else        move_diagonal_for_stairs(horz, vert)      end    else      move_diagonal_for_stairs(horz, vert)    end  end    # Shift the y coordinate of the character's sprite to compensate for stairs  alias shift_y_for_stairs shift_y  def shift_y(*a,&bl)    shift_y_for_stairs(*a,&bl) + (midstairs? ? StairsOffset : 0)  end    # Update the sprite more to create pace-per-step effect on stairs  alias update_anime_count_for_stairs update_anime_count  def update_anime_count(*a,&bl)    ac = @anime_count    update_anime_count_for_stairs(*a,&bl)    @anime_count += CharAnimSpeed if midstairs?  endendclass Game_Player < Game_Character  alias move_straight_for_stairs move_straight  def move_straight(*a,&bl)    @followers.move if stairs_passable?(@x,@y,a[0]) if on_stairs?    move_straight_for_stairs(*a,&bl)  endend#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=## End of Script#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=#
    复制代码





    Credit and Thanks
    - FenixFyreX

    Changelog & Bug Fixes
    Version 1.1
    - Fixed bug where followers wouldn't follow the player up or down stairs.


    本贴来自国际rpgmaker官方论坛作者:FenixFyreX处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/stairs-movement.9216/
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-17 09:29 , Processed in 0.136774 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表