| 赞 | 428 |
| VIP | |
| 好人卡 | |
| 积分 | 423 |
| 经验 | |
| 最后登录 | 2026-11-16 |
| 在线时间 | 6022 小时 |
- 梦石
- 0
- 星屑
- 42345
- 在线时间
- 6022 小时
- 注册时间
- 2006-11-10
- 回帖
- 6975
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 灯笼菜刀王 于 2018-12-21 10:06 编辑
emmm, 以前的版本使用不方便, 要用一个事件定义不同范围做不到, 所以推翻重来,
~~ 不过这次有改动到 game player的update, 所以冲突可能性大大增加, 会和一些常用的按键加速什么的冲突...
嘛有冲突的话,把脚本里备注"菜刀王到此一游"的部分塞到对方身体...脚本对应位置就可以了
-------------------------------------------------------------------------------------------------
2.1 更新内容
1, 因为之前只能是主角移动才会触发, 不移动被动进入范围不会触发, 增加了一个由NPC移动来判定触发的开关
2, 追加新的[视野]设置, 根据NPC朝向变化的锥形范围, 进入视野范围内触发
--------------------------------------------------------------------------------------------------
2.0 更新内容:
1, 设置改为用注释设置, 可以用切换页面改变原本范围
2, 追加固定坐标范围触发, 可以代替需要判断坐标的并列处理
3, 优化判断方法, 确实等角色走到位再触发,(以前是一碰范围就触发)
4, 不用手动关闭重复开关了
5, 追加朝向判定
6, 追加每步触发判定
-------------------------------------------------------------------------------------------------
能用来干嘛? 省去设置用来判定坐标的并行处理咯
固定范围触发, 事件随意移动不影响
事件周围触发, 可以随着事件移动范围
范围内每一步都触发
范围内判定朝向后触发
- # 范围触发2.1 by 灯笼菜刀君 2018.12.16
- #
- # 使用方法: 事件触发条件改为"接触事件", 然后用注释写下
- #
- # [范围]起始点x,y,终点x,y,朝向(可省略),要重复触发(省略为不触发)
- # [范围]的触发范围为起始点到终点的圈起来的矩形,朝向写2468,省略或者0为全方向触发
- # 栗子: [范围]0,0,19,14,0,yes #=> 宽20,高15的触发范围,全方向,每步触发
- #
- # [身旁]x轴距离,y轴距离,要重复触发(省略为不触发)
- # [身旁]的触发范围为自身为中心 x轴距离和y轴距离圈起来的矩形
- # 栗子: [身旁]5,5 #=> 以事件为中心,5格范围内的范围,不重复触发
- #
- # [视野]有效距离,要重复触发(省略为不触发)
- # [视野]的触发范围为事件面朝方向N格距离的三角形
- # 栗子: [视野]2,yes #=> 视野2格范围内,重复触发
- # □□■□
- # □■■□
- # →■■□
- # □■■□
- # □□■□
- #-----------------------------------------------------------
- # 注意: 以上触发条件都为"主角移动",主角不移动的话进入范围也不会触发,
- # 需要以事件移动为刷新条件, 打开下面的开关(打开开关后,触发范围重叠的话
- # 可能会引起判断异常,非必要别开开关)
- CAIDAO_EVENT_FANWEI = 1 #允许以事件移动来触发范围的开关ID
- #-----------------------------------------------------------
- def 范围触发
- for event in $game_map.events.values
- next if event.list.nil?
- for i in event.list
- if i.code == 108 or i.code == 408
- if i.parameters[0] =~ /[范围]/
- b = i.parameters[0].gsub("[范围]", "").split(/,/)
- if b.size > 3 and $game_player.x >= b[0].to_i and \
- $game_player.x <= b[2].to_i and $game_player.y >= b[1].to_i and \
- $game_player.y <= b[3].to_i
- @触范 = [0] if b[5] != nil
- if b[4] != nil and b[4] != "0"
- return [event.id] if $game_player.direction == b[4].to_i
- else
- return [event.id]
- end
- end
- end
- if i.parameters[0] =~ /[身旁]/
- b = i.parameters[0].gsub("[身旁]", "").split(/,/)
- if b.size > 1 and ($game_player.x - event.x).abs <= b[0].to_i and \
- ($game_player.y - event.y).abs <= b[1].to_i
- @触范 = [0] if b[2] != nil
- return [-event.id,[event.x,event.y]]
- end
- end
- if i.parameters[0] =~ /[视野]/
- b = i.parameters[0].gsub("[视野]", "").split(/,/)
- if b.size > 0
- @触范 = [0] if b[1] != nil
- case event.direction
- when 2
- if $game_player.y > event.y and \
- $game_player.y <= event.y + b[0].to_i and \
- ($game_player.y - event.y).abs >= ($game_player.x - event.x).abs
- return [-event.id,[event.x,event.y,2]]
- end
- when 8
- if $game_player.y < event.y and \
- $game_player.y >= event.y - b[0].to_i and \
- ($game_player.y - event.y).abs >= ($game_player.x - event.x).abs
- return [-event.id,[event.x,event.y,8]]
- end
- when 4
- if $game_player.x < event.x and \
- $game_player.x >= event.x - b[0].to_i and \
- ($game_player.y - event.y).abs <= ($game_player.x - event.x).abs
- return [-event.id,[event.x,event.y,4]]
- end
- when 6
- if $game_player.x > event.x and \
- $game_player.x <= event.x + b[0].to_i and \
- ($game_player.y - event.y).abs <= ($game_player.x - event.x).abs
- return [-event.id,[event.x,event.y,6]]
- end
- end
- end
- end
- end
- end
- end
- return [0]
- end
-
- class Game_Player < Game_Character
- def initialize
- super()
- @触范 = [0]
- end
- def update
- # 本地变量记录移动信息
- last_moving = moving?
- # 移动中、事件执行中、强制移动路线中、
- # 信息窗口一个也不显示的时候
- f = @触范 #菜刀王到此一游
- unless moving? or $game_system.map_interpreter.running?
- @move_route_forcing or $game_temp.message_window_showing
- # 如果方向键被按下、主角就朝那个方向移动
- case Input.dir4
- when 2
- move_down
- f = 范围触发 #菜刀王到此一游
- when 4
- move_left
- f = 范围触发 #菜刀王到此一游
- when 6
- move_right
- f = 范围触发 #菜刀王到此一游
- when 8
- move_up
- f = 范围触发 #菜刀王到此一游
- end
- end
- # 本地变量记忆坐标
- last_real_x = @real_x
- last_real_y = @real_y
- super
- # 角色向下移动、画面上的位置在中央下方的情况下
- if @real_y > last_real_y and @real_y - $game_map.display_y > CENTER_Y
- # 画面向下卷动
- $game_map.scroll_down(@real_y - last_real_y)
- end
- # 角色向左移动、画面上的位置在中央左方的情况下
- if @real_x < last_real_x and @real_x - $game_map.display_x < CENTER_X
- # 画面向左卷动
- $game_map.scroll_left(last_real_x - @real_x)
- end
- # 角色向右移动、画面上的位置在中央右方的情况下
- if @real_x > last_real_x and @real_x - $game_map.display_x > CENTER_X
- # 画面向右卷动
- $game_map.scroll_right(@real_x - last_real_x)
- end
- # 角色向上移动、画面上的位置在中央上方的情况下
- if @real_y < last_real_y and @real_y - $game_map.display_y < CENTER_Y
- # 画面向上卷动
- $game_map.scroll_up(last_real_y - @real_y)
- end
- #-菜刀王到此一游----------------------------------------------
- if @触范[0] != f[0] or (f[0] < 0 and @触范[1] != f[1])
- if f[0] == 0
- @触范 = f
- else
- event = $game_map.events[f[0].abs]
- if event != nil and event.trigger == 1 and !event.jumping?
- event.start
- @触范 = f
- return
- end
- end
- end
-
- #-------------------------------------------------------------
- # 不在移动中的情况下
- unless moving?
- # 上次主角移动中的情况
- if last_moving
- # 与同位置的事件接触就判定为事件启动
- result = check_event_trigger_here([1,2])
- # 没有可以启动的事件的情况下
- if result == false
- # 调试模式为 ON 并且按下 CTRL 键的情况下除外
- unless $DEBUG and Input.press?(Input::CTRL)
- # 遇敌计数下降
- if @encounter_count > 0
- @encounter_count -= 1
- end
- end
- end
- end
- # 按下 C 键的情况下
- if Input.trigger?(Input::C)
- # 判定为同位置以及正面的事件启动
- check_event_trigger_here([0])
- check_event_trigger_there([0,1,2])
- end
- end
- end
- end
- class Game_Event < Game_Character
- alias oxox_initialize initialize
- def initialize(map_id, event)
- oxox_initialize(map_id,event)
- @范触 = []
- end
- alias oxox_check_event_trigger_auto check_event_trigger_auto
- def check_event_trigger_auto
- oxox_check_event_trigger_auto
- if @trigger == 1 and $game_switches[CAIDAO_EVENT_FANWEI]
- f = 范围触发
- if f[0] == -@id and @范触 != f[1]
- start
- @范触 = f[1]
- end
- end
- end
- end
-
复制代码
饭粒一个
范围触发2.1.rar
(191.92 KB, 下载次数: 217)
|
评分
-
查看全部评分
|