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

[转载发布] Push, Bridge and Jump Events

[复制链接]
累计送礼:
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 09:12:58 | 显示全部楼层 |阅读模式
    Push, Bridge and Jump Events
    by AMoonlessNight
    14 Apr 2018





    This script makes it so that you can push certain events and use them as bridges, or even hop between them. It works best with events with multiple parts, such as pillars.

    You must set up regions for where the bridges should go, or else it won't work.

    Known issues:
    1. At the moment, bridges only work horizontally, not vertically.
    2. To hop between events, they must be placed two tiles apart.

    Compatibility:
    I haven't tested this script with other scripts that modify passability, etc. Let me know if there are any issues.

    I may look at improvements for this script upon request.

    Script
    Spoiler: Script
                    Code:       
    1. =begin
    2. #============================================================================
    3. #   AMN Push, Bridge and Jump Events
    4. #   Version 1.04
    5. #   Author: AMoonlessNight
    6. #   Date: 14 Apr 2018
    7. #   Latest: 28 Dec 2018
    8. #============================================================================#
    9. #   UPDATE LOG
    10. #----------------------------------------------------------------------------#
    11. # 14 Apr 2018 - created the original script
    12. # 15 Apr 2018 - fixed an issue with being able to push events while upon them
    13. #             - added a wait for the player while pushing events
    14. #             - added passability checks to the pushing script call
    15. # 18 Apr 2018 - fixed an issue with priority types for top events
    16. # 28 Dec 2018 - squashed a few bugs related to passability
    17. #============================================================================#
    18. This script makes it so you can push certain events and use them as bridges.
    19. It works best with events with multiple parts, such as pillars.
    20. You can also set it so that you can jump between events.
    21. You must set up regions for where the bridges should go.
    22. SETTING UP EVENTS:
    23. Name:
    24.   * the name must include <move> if you wish for it to be moveable
    25.   * if you have an event with multiple parts (e.g. a pillar spanning three
    26.     tiles), they must all include the unique name of the BASE event
    27.    
    28.   * the top-most event must include <top> if you wish for it to be used like
    29.     a bridge
    30.    
    31. Priority:
    32.   * the top-most event must be set to Through
    33.   * any other below or above priority sections should be set to Through
    34.    
    35. Script call:
    36.   * the base event must have the script call 'push_event' if you wish for it
    37.     to be pushed
    38.    
    39.   * the top-most event must have the script call 'pillar_jump' if you wish for
    40.     the player to jump from one to the other
    41.    
    42. *** IMPORTANT:
    43. * Each separate set of events MUST have a unique name
    44.   e.g. a bunch of events just called <move> will all move together.
    45. * For now, bridges only work horizontally, not vertically
    46. * Bridge events will not pass in front of one another
    47. SETTING UP REGIONS:
    48.   * Use the first region (Topmost_Region) to designate areas that can be used for
    49.     bridges.
    50.   * Use the second region (TopRegion_Bookend) to designate the 'on' and 'off'
    51.     points on either side of the first region. This is so the player can get on
    52.     and off the bridge.
    53.    
    54. #============================================================================#
    55.           SCRIPT CALLS
    56. #============================================================================#
    57. You can use the following script calls:
    58.     * push_event
    59.   #----------------------------------------------------------------#
    60.   # Pushes the event and any related events. This should go on the
    61.   # base event
    62.   #----------------------------------------------------------------#
    63.     * pillar_jump
    64.   #----------------------------------------------------------------#
    65.   # Allows the player to jump from one 'top' event to another
    66.   #----------------------------------------------------------------#
    67. =end
    68. module AMNEventMove
    69. #==============================================================================
    70. # ** EDITABLE REGION BELOW
    71. #------------------------------------------------------------------------------
    72. #  Change the values in the area below to suit your needs.
    73. #==============================================================================
    74.   Topmost_Region =    2   # The region ID for areas that can be used as bridges
    75.   TopRegion_Bookend = 3   # The region ID for the areas next to bridges. You
    76.                           # must paint these regions on either side of the
    77.                           # Topmost_Region or else the player can't get off
    78.                           # or jump off
    79. #==============================================================================
    80. # ** END OF EDITABLE REGION
    81. #------------------------------------------------------------------------------
    82. #  Please do not edit below this point unless you know what you are doing.
    83. #==============================================================================
    84. end
    85. class Game_Map
    86.   def bridge_region
    87.     AMNEventMove::Topmost_Region
    88.   end
    89.   def bridge_adjacent
    90.     AMNEventMove::TopRegion_Bookend
    91.   end
    92.   def bridge_region?(x, y)
    93.     region_id(x, y) == bridge_region
    94.   end
    95.   def bridge_adjacent?(x, y)
    96.     region_id(x, y) == bridge_adjacent
    97.   end
    98. end
    99. class Game_CharacterBase
    100.   alias amn_eventmove_gamecharabase_passable? passable?
    101.   def passable?(x, y, d)
    102.     return false if check_player_bridges?(x, y, d)
    103.     amn_eventmove_gamecharabase_passable?(x, y, d)
    104.   end
    105.   def check_player_bridges?(x, y, d)
    106.     return false unless self.is_a?(Game_Player)
    107.     return false if debug_through?
    108.     region = 0
    109.     case d
    110.     when 1; reg = $game_map.region_id(x-1, y+1); ev = collide_with_top_event(x-1, y+1)
    111.     when 2; reg = $game_map.region_id(x+0, y+1); ev = collide_with_top_event(x+0, y+1)
    112.     when 3; reg = $game_map.region_id(x+1, y+1); ev = collide_with_top_event(x+1, y+1)
    113.     when 4; reg = $game_map.region_id(x-1, y+0); ev = collide_with_top_event(x-1, y+0)
    114.     when 5; reg = $game_map.region_id(x+0, y+0); ev = collide_with_top_event(x+0, y+0)
    115.     when 6; reg = $game_map.region_id(x+1, y+0); ev = collide_with_top_event(x+1, y+0)
    116.     when 7; reg = $game_map.region_id(x-1, y-1); ev = collide_with_top_event(x-1, y-1)
    117.     when 8; reg = $game_map.region_id(x+0, y-1); ev = collide_with_top_event(x+0, y-1)
    118.     when 9; reg = $game_map.region_id(x+1, y-1); ev = collide_with_top_event(x+1, y-1)
    119.     end
    120.     if not_on_bridge(x, y)
    121.       return true if bridge_adj?(reg)
    122.     elsif on_bridge_region(x, y)
    123.       if $game_player.playerbridge?
    124.         return true unless bridge_region?(reg) && ev || bridge_adj?(reg)
    125.       else
    126.         return true if bridge_adj?(reg)
    127.       end
    128.     elsif next_to_bridge(x, y)
    129.       return true if bridge_region?(reg) && !ev
    130.     end
    131.     return false
    132.   end
    133.   def bridge_region?(region)
    134.     region == $game_map.bridge_region
    135.   end
    136.   def bridge_adj?(region)
    137.     region == $game_map.bridge_adjacent
    138.   end
    139.   def on_bridge_region(x, y)
    140.     $game_map.bridge_region?(x, y) && collide_with_top_event(x, y)
    141.   end
    142.   def next_to_bridge(x, y)
    143.     $game_map.bridge_adjacent?(x, y)
    144.   end
    145.   def not_on_bridge(x, y)
    146.     $game_map.bridge_region?(x, y) && !collide_with_top_event(x, y)
    147.   end
    148.   def collide_with_top_event(x, y)
    149.     $game_map.events_xy(x, y).any? { |event| event.top_event? }
    150.   end
    151. end
    152. class Game_Player < Game_Character
    153.    
    154.   alias amn_eventmove_gameplayer_movebyinput  move_by_input
    155.   def move_by_input
    156.     last_pos = [@x, @y]
    157.     amn_eventmove_gameplayer_movebyinput
    158.     new_pos = [@x, @y]
    159.     @playerbridge = bridge_movement_check(last_pos, new_pos)
    160.   end
    161.   def bridge_movement_check(last, current)
    162.     last_region = $game_map.region_id(last[0], last[1])
    163.     return true if bridge_adj?(last_region) && on_bridge_region(current[0], current[1])
    164.     return false if !@playerbridge && on_bridge_region(current[0], current[1])
    165.     return true if on_bridge_region(last[0], last[1]) && on_bridge_region(current[0], current[1])
    166.     return false
    167.   end
    168.   def playerbridge?
    169.     @playerbridge
    170.   end
    171.   def wait(duration)
    172.     mr = RPG::MoveRoute.new
    173.     mr.repeat = false
    174.     mr.wait = true
    175.     mr.list = []
    176.     mr.list.push( RPG::MoveCommand.new(15, [duration]) )
    177.     mr.list.push( RPG::MoveCommand.new )
    178.     force_move_route(mr)
    179.   end
    180.   def jumpable_?(x, y)
    181.     evs = $game_map.events_xy(x, y).select{|ev| ev.top_event? }
    182.     @playerbridge = true if bridge_adj?(region_id)
    183.     evs.each { |e| return false if !bridge_region?(e.region_id) }
    184.     return true if !evs.empty? && playerbridge?
    185.     return true if !evs.empty? && bridge_adj?(region_id)
    186.     return true if playerbridge? && $game_map.bridge_adjacent?(x, y)
    187.     return true if bridge_adj?(region_id) && $game_map.bridge_adjacent?(x, y)
    188.   end
    189. end
    190. class Game_Event < Game_Character
    191.   attr_reader   :name                  # name of event
    192.   attr_accessor :priority_type         # priority type (normal, above, below)
    193.   alias amn_eventname_init  initialize
    194.   def initialize(*args)
    195.     amn_eventname_init(*args)
    196.     @name = @event.name
    197.   end
    198.   def top_event?
    199.     return true if @name.include?("<top>")
    200.   end
    201.   def bridge_check
    202.     player = $game_player
    203.     return @priority_type = 2 if !bridge_region?(region_id)
    204.     if distance_x_from($game_player.x) <= 1 && distance_y_from($game_player.y) <= 1
    205.       @priority_type = 0 if player.playerbridge?
    206.     else
    207.       @priority_type = 2
    208.     end
    209.   end
    210.   alias amn_eventmove_gameevent_update  update
    211.   def update
    212.     amn_eventmove_gameevent_update
    213.     bridge_check if top_event? && @name.include?("<move>")
    214.   end
    215. end
    216. class Game_Interpreter
    217.   def push_event(event = $game_map.events[@event_id])
    218.     return unless event.name.include?("<move>")
    219.     return unless event.passable?(event.x, event.y, $game_player.direction)
    220.     evs = $game_map.events.values.select{|ev| ev.name.include?(event.name) }
    221.     x2 = $game_map.round_x_with_direction(event.x, $game_player.direction)
    222.     y2 = $game_map.round_y_with_direction(event.y, $game_player.direction)
    223.     # check if there are any matching events behind the event and check passability
    224.     ev2 = $game_map.events_xy(x2,y2).select{|ev| ev.name.include?(event.name)}
    225.     ev2.each {|ev| return unless ev.passable?(ev.x, ev.y, $game_player.direction)}
    226.     # don't let the events move if there are any other moveable events behind them
    227.     evs.each do |ev|
    228.       evx2 = $game_map.round_x_with_direction(ev.x, $game_player.direction)
    229.       evy2 = $game_map.round_y_with_direction(ev.y, $game_player.direction)
    230.       return unless $game_map.events_xy(evx2,evy2).select{|evv| evv.name.include?("<move>") && !evv.name.include?(event.name)}.empty?
    231.     end
    232.     return unless $game_map.events_xy(x2,y2).select{|ev| ev.name.include?("<move>") && !ev.name.include?(event.name)}.empty?
    233.     #
    234.     $game_player.wait(20)
    235.     # make each event move
    236.     evs.each do |ev|
    237.       mr = RPG::MoveRoute.new
    238.       mr.repeat = false
    239.       mr.wait = true
    240.       mr.list = []
    241.       mr.list.push(RPG::MoveCommand.new($game_player.direction/2, []))
    242.       mr.list.push( RPG::MoveCommand.new )
    243.       ev.force_move_route(mr)
    244.     end
    245.   end
    246.   def pillar_jump
    247.     tilex = $game_player.x
    248.     tiley = $game_player.y
    249.     case $game_player.direction
    250.     when 2; jumpx = 0; jumpy = 2; tiley += 2
    251.     when 4; jumpx = -2; jumpy = 0; tilex -= 2;
    252.     when 6; jumpx = 2; jumpy = 0; tilex += 2;
    253.     when 8; jumpx = 0; jumpy = -2; tiley -= 2
    254.     end
    255.     if $game_player.jumpable_?(tilex, tiley)
    256.       $game_player.jump(jumpx, jumpy)
    257.     else
    258.       # the player cannot push if they are on the bridge
    259.       return if $game_player.playerbridge?
    260.       x2 = $game_map.round_x_with_direction($game_player.x, $game_player.direction)
    261.       y2 = $game_map.round_y_with_direction($game_player.y, $game_player.direction)
    262.       $game_map.events_xy(x2, y2).select{|ev| ev.priority_type == 1}.each { |ev| ev.start }
    263.     end
    264.   end
    265. end
    复制代码


    Demo
    Version 1.4: https://www.dropbox.com/s/yagqfvvmie5ksxb/Push Bridge Jump script demo.exe?dl=0
    updated 28 Dec 2018

    Instructions
    Spoiler: Instructions
    1. Set up your two regions:
    a. The first region should designate the 'bridge' area, or topmost area.
    b. The second region should designate where the player should get on or off the bridge. It should be on either side of the bridge region.​

    2. Set up your events:
    Spoiler: Base event



    a. The bottom or base of the event should have the script call 'push_event' if you wish for it to be pushed.
    b. The name must include <move> if you wish for it to be moveable.
    c. The name must be unique to this set of events, or else everything with the same name will move.
    d. If you have an event with multiple parts (such as a pillar), they must all include the unique name of the base event.
    Spoiler: Top event[quote]


    a. The top-most event should include the script call 'pillar_jump' if you wish for the player to hop between them.
    b. It must include the name of the base event, otherwise it won't move with it.
    c. It must include <top> in the name if you wish for it to be used like a bridge.
    [/quote]
    Screenshots
    Spoiler: Screenshots




    本贴来自国际rpgmaker官方论坛作者:A-Moonless-Night处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/push-bridge-and-jump-events.94049/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

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

    本版积分规则

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

    幸运抽奖

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

    立即查看

    聊天机器人
    Loading...

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

    GMT+8, 2026-8-17 12:39 , Processed in 0.103538 second(s), 56 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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