赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 745 |
最后登录 | 2018-4-2 |
在线时间 | 17 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 17 小时
- 注册时间
- 2012-9-23
- 帖子
- 21
|
还有就是要用到的脚本。。。这个脚本连接我找不到了。。。就在这发下好了。。- #==============================================================================
- # ■ LCF_Leyeshot (linetype eyeshot)XP 2.1 Creator LCF Date 2008.11.3
- #------------------------------------------------------------------------------
- # 线形视野系统 编者:流川枫 QQ:350773875
- #==============================================================================
- #【使用说明】
- #------------------------------------------------------------------------------
- # 视野系统开关 $game_map.events[@event_id].le_seeing = true/false
- # 功能:该值为true表示该NPC视野开启,否则未开启,默认为false。
- #------------------------------------------------------------------------------
- # 视野透视开关 $game_map.events[@event_id].le_clairv = true/false
- # 功能:该值为true表示该NPC视野不扫描视线障碍,否则扫描,默认为false。
- #------------------------------------------------------------------------------
- # 视线显示开关 $game_map.events[@event_id].le_show = true/false
- # 功能:该值为true表示显示该NPC的视线,否则不显示,默认为false。
- #------------------------------------------------------------------------------
- # 侧面可视开关 $game_map.events[@event_id].le_side = true/false
- # 功能:该值为true表示该NPC可以看到侧面一格内的人,否则由斜率决定,默认为true。
- #------------------------------------------------------------------------------
- # 视野环绕开关 $game_map.events[@event_id].le_circle = true/false
- # 功能:该值为true表示该NPC为环绕视野,否则不能看见自己的身后,默认为false。
- #------------------------------------------------------------------------------
- # 设置视野深度 $game_map.events[@event_id].le_deepness = 深度值
- # 功能:该值代表视野的能见度,默认为7。
- #------------------------------------------------------------------------------
- # 设置视野斜率 $game_map.events[@event_id].le_slope = 斜率值
- # 功能:该值代表视野的斜率,默认为1.0。
- #------------------------------------------------------------------------------
- # 设置显示颜色 $game_map.events[@event_id].le_color = 颜色值
- # 功能:该值代表视线显示的颜色,默认为0xf0。
- #==============================================================================
- # 当NPC看到主角的时候,独立开关D会被打开,否则为关闭状态。
- #==============================================================================
- #==============================================================================
- # ■ Game_Event
- #------------------------------------------------------------------------------
- # 重载事件类
- #==============================================================================
- class Game_Event
- attr_accessor :le_seeing # 视野系统开关
- attr_accessor :le_clairv # 视野透视开关
- attr_accessor :le_show # 视线显示开关
- attr_accessor :le_side # 侧面可视开关
- attr_accessor :le_circle # 视野环绕开关
- attr_accessor :le_deepness # 视野深度
- attr_accessor :le_slope # 视野斜率
- attr_accessor :le_color # 显示颜色
- #--------------------------------------------------------------------------
- # ● 初始化对像
- # map_id : 地图 ID
- # event : 事件 (RPG::Event)
- #--------------------------------------------------------------------------
- alias original_initialize initialize
- def initialize (map_id, event)
- original_initialize (map_id, event)
- @le_seeing = true
- @le_clairv = false
- @le_show = false
- @le_side = true
- @le_circle = false
- @le_deepness = 7
- @le_slope = 1.0
- @le_color = 0xf0
- @trace = Table.new (@le_deepness,2)
- @trace[0,0] = -1
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- alias original_update update
- def update
- if @le_seeing
- @trace.resize (@le_deepness,2) if @trace.xsize != @le_deepness
- original_switch = $game_self_switches[[$game_map.map_id, @id, "D"]]
- self.see
- $game_map.need_refresh = true if original_switch != $game_self_switches[[$game_map.map_id, @id, "D"]]
- end
- original_update
- end
- #--------------------------------------------------------------------------
- # ● 视野检测
- #--------------------------------------------------------------------------
- def see
- $game_self_switches[[$game_map.map_id, @id, "D"]] = false
- if ($game_player.x-@x).abs<@le_deepness and ($game_player.y-@y).abs<@le_deepness
- difference_x = $game_player.x - @x
- difference_y = $game_player.y - @y
- case @direction
- when 2
- return if @le_circle != true and $game_player.y < @y
- unless @le_side and (difference_y == 0 and difference_x.abs == 1)
- return if (difference_y/(difference_x+0.0)).abs < @le_slope
- end
- when 4
- return if @le_circle != true and $game_player.x > @x
- unless @le_side and difference_y.abs == 1 and difference_x == 0
- return if (difference_x/(difference_y+0.0)).abs < @le_slope
- end
- when 6
- return if @le_circle != true and $game_player.x < @x
- unless @le_side and difference_y.abs == 1 and difference_x == 0
- return if (difference_x/(difference_y+0.0)).abs < @le_slope
- end
- else
- return if @le_circle != true and $game_player.y > @y
- unless @le_side and difference_y == 0 and difference_x.abs == 1
- return if (difference_y/(difference_x+0.0)).abs < @le_slope
- end
- end
- $game_self_switches[[$game_map.map_id, @id, "D"]] = scan_line
- end
- end
- #--------------------------------------------------------------------------
- # ● 视线检测
- #--------------------------------------------------------------------------
- def scan_line
- difference_x = $game_player.x - @x
- difference_y = $game_player.y - @y
- direction_x = (difference_x > 0 ? 1 : -1)
- direction_y = (difference_y > 0 ? 1 : -1)
- i = 0
- if difference_x.abs > difference_y.abs
- while difference_x.abs > i+1
- i+=1
- x = @x+i*direction_x
- if direction_y>0
- y = @y+i*difference_y/(difference_x+0.0)*direction_y*direction_x+0.5
- else
- y = @y-i*difference_y/(difference_x+0.0)*direction_y*direction_x+0.5
- end
- x = x.floor
- y = y.floor
- if @le_clairv != true
- unless (direction_x > 0 ? passable?(x-1,y,6) : passable?(x+1,y,4))
- @trace[i-1,0] = -1
- return false
- end
- end
- if @le_show
- @trace[i-1,0] = x
- @trace[i-1,1] = y
- $scene.spriteset.tilemap.flash_data[x,y] = @le_color
- end
- end
- else
- while difference_y.abs > i+1
- i+=1
- y = @y+i*direction_y
- if direction_x>0
- x = @x+i*difference_x/(difference_y+0.0)*direction_x*direction_y+0.5
- else
- x = @x-i*difference_x/(difference_y+0.0)*direction_x*direction_y+0.5
- end
- x = x.floor
- y = y.floor
- if @le_clairv != true
- unless (direction_y > 0 ? passable?(x,y-1,2) : passable?(x,y+1,8))
- @trace[i-1,0] = -1
- return false
- end
- end
- if @le_show
- @trace[i-1,0] = x
- @trace[i-1,1] = y
- $scene.spriteset.tilemap.flash_data[x,y] = @le_color
- end
- end
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 清楚痕迹
- #--------------------------------------------------------------------------
- def clear
- for i in 0 .. @trace.xsize-1
- break if @trace[i,0] == -1
- $scene.spriteset.tilemap.flash_data[@trace[i,0],@trace[i,1]] = 0
- end
- @trace[0,0] = -1
- end
- end
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 重载地图显示
- #==============================================================================
- class Spriteset_Map
- attr_reader:tilemap
- alias :original_ini :initialize
- def initialize
- original_ini
- @tilemap.flash_data=Table.new(@tilemap.map_data.xsize,@tilemap.map_data.ysize)
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 重载地图场景
- #==============================================================================
- class Scene_Map
- attr_reader:spriteset
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 重载地图类
- #==============================================================================
- class Game_Map
- alias original_update update
- def update
- # 清除视线痕迹
- for event in @events.values
- event.clear
- end
- original_update
- end
- end
复制代码 |
|