加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
有时我们会需要做一个"持续移动后穿过NPC"的效果,避免被随意行走的NPC把路堵死。
# By Lanza Schneider # 2020.09.04 # 在你想要穿过的事件中添加一条 crushable 注释即可 class Game_Event def crushable? @crushable end alias :setup_page_2020090400 :setup_page def setup_page(*args) setup_page_2020090400 *args @crushable = false @page.list.each do |command| if command.code == 108 && command.parameters[0] == 'crushable' @crushable = true break end end end end class Game_Player alias :update_2020090400 :update def update *args @crushed = false update_2020090400 *args @crush_count = @crushed ? @crush_count + 1 : 0 end def collide_with_events?(x, y) $game_map.events_xy_nt(x, y).any? do |event| result = event.normal_priority? || self.is_a?(Game_Event) if result && event.crushable? @crushed = true result = false if @crush_count > 30 end result end end end
# By Lanza Schneider
# 2020.09.04
# 在你想要穿过的事件中添加一条 crushable 注释即可
class Game_Event
def crushable?
@crushable
end
alias :setup_page_2020090400 :setup_page
def setup_page(*args)
setup_page_2020090400 *args
@crushable = false
@page.list.each do |command|
if command.code == 108 && command.parameters[0] == 'crushable'
@crushable = true
break
end
end
end
end
class Game_Player
alias :update_2020090400 :update
def update *args
@crushed = false
update_2020090400 *args
@crush_count = @crushed ? @crush_count + 1 : 0
end
def collide_with_events?(x, y)
$game_map.events_xy_nt(x, y).any? do |event|
result = event.normal_priority? || self.is_a?(Game_Event)
if result && event.crushable?
@crushed = true
result = false if @crush_count > 30
end
result
end
end
end
|