设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1865|回复: 1
打印 上一主题 下一主题

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
9617
在线时间
3220 小时
注册时间
2011-3-24
帖子
739

开拓者

跳转到指定楼层
1
发表于 2020-9-4 23:40:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

RUBY 代码复制
  1. # By Lanza Schneider
  2. # 2020.09.04
  3. # 在你想要穿过的事件中添加一条 crushable 注释即可
  4. class Game_Event
  5.   def crushable?
  6.     @crushable
  7.   end
  8.  
  9.   alias :setup_page_2020090400 :setup_page
  10.   def setup_page(*args)
  11.     setup_page_2020090400 *args
  12.     @crushable = false
  13.     @page.list.each do |command|
  14.       if command.code == 108 && command.parameters[0] == 'crushable'
  15.         @crushable = true
  16.         break
  17.       end
  18.     end
  19.   end
  20. end
  21.  
  22. class Game_Player
  23.   alias :update_2020090400 :update
  24.   def update *args
  25.     @crushed = false
  26.     update_2020090400 *args
  27.     @crush_count = @crushed ? @crush_count + 1 : 0
  28.   end
  29.  
  30.   def collide_with_events?(x, y)
  31.     $game_map.events_xy_nt(x, y).any? do |event|
  32.       result = event.normal_priority? || self.is_a?(Game_Event)
  33.       if result && event.crushable?
  34.         @crushed = true
  35.         result = false if @crush_count > 30
  36.       end
  37.       result
  38.     end
  39.   end
  40. end

评分

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

查看全部评分

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-19 14:18

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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