查看: 2542|回复: 1

[原创发布] VA阻碍后延时穿过NPC事件

[复制链接]
梦石
0
星屑
9687
在线时间
3224 小时
注册时间
2011-3-24
回帖
616

开拓者

发表于 2020-9-4 23:40:55 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
有时我们会需要做一个"持续移动后穿过NPC"的效果,避免被随意行走的NPC把路堵死。

[pre lang="ruby"]# 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
[/pre]

评分

参与人数 1星屑 +300 赞 +1 收起 理由
alexncf125 + 300 + 1 精品文章

查看全部评分

>>→Lanza Games 2020←<<
Lanza Schneider
浪子心,孤星梦永远流浪……
~不会放弃,我的精力永远充沛~
>>>>>Lanza Adventure<<<<<
>>>>>Lanza的新年派对!<<<<<
>>>>>Lanza的口袋心脏病!<<<<<
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部