查看: 4078|回复: 8

[已经解决] 菜鸟级问题-----如何调节灯光

[复制链接]
梦石
0
星屑
385
在线时间
117 小时
注册时间
2012-10-2
回帖
114
发表于 2013-6-6 08:22:10 | 显示全部楼层 |阅读模式

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

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

×
我在自己的游戏里了使用了灯光脚本(注意是灯光脚本,不是视野阻碍系统)

但是我觉得那灯光的照应范围太少,怎么可以把它调大一点?

求高手指点一下,谢谢了

Assassin-K

梦石
0
星屑
4138
在线时间
2281 小时
注册时间
2012-5-23
回帖
3964

贵宾

发表于 2013-6-9 00:34:25 | 显示全部楼层
不知道你指的是哪个的说。
如果是用光效图片的那种,直接修改素材。
如果不是,麻烦贴下脚本好吧?
(其实那种改数值的,慢慢摸索也能调适出来的……我会乱说~)

评分

参与人数 1星屑 +100 收起 理由
Sion + 100 感谢帮忙

查看全部评分


◆ROZONE◆
>洛子又要去流浪地球了……
>如果你看到我在线,又没动静,那只能说明我在挂机……
回复

使用道具 举报

梦石
0
星屑
385
在线时间
117 小时
注册时间
2012-10-2
回帖
114
 楼主| 发表于 2013-6-9 07:28:53 | 显示全部楼层
这种灯光系统是不是只能改图?
QQ图片20130609072240.jpg
回复

使用道具 举报

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-6-9 08:02:28 来自手机 | 显示全部楼层
找到灯光脚本中显示视野的那部分,调整它的放大率就好了


少年你不把脚本贴出来我这么说你看的懂自己会改么?
回复

使用道具 举报

梦石
0
星屑
385
在线时间
117 小时
注册时间
2012-10-2
回帖
114
 楼主| 发表于 2013-6-9 08:27:14 | 显示全部楼层
喵呜喵5 发表于 2013-6-9 08:02
找到灯光脚本中显示视野的那部分,调整它的放大率就好了

新人比较愚笨,不好意思哈

现在就贴出脚本

话说怎么把脚本贴成有框框的样式啊·不会·= =




  1. =begin

  2.   HN_Light version 1.0.1.0 for VX Ace

  3.         by 半生


  4.   要HN_RG_BITMAP(ver 0.1.2.1以降)


  5. 2012/01/08 ver 1.0.1.2

  6.  队列歩行の仲间に対応


  7. =end


  8. # ----- 在这里设定-----

  9. module HN_Light

  10.   # 简略化0:(精细)~2:(粗暴,负荷轻)

  11.   SIMPLIFY = 1

  12.   

  13.   # 玩家的烛光类型使用的变量号码

  14.   PLAYER_LIGHT_TYPE = 12


  15.   # 队友的烛光类型使用的变量号码

  16.   FOLLOWER_LIGHT_TYPE = 12

  17.   

  18.   # 黑暗判断上使用的开关

  19.   DARK_SWITCH = 13

  20.   

  21.   # 烛光事件识别用的正规表达式

  22.   REGEX_LIGHT = /@LIGHT(\d+)/

  23.   

  24.   # 烛光图像的目录

  25.   LIGHT_IMG_DIR = "Graphics/Pictures/"

  26.   

  27.   # 烛光Bitmap设定

  28.   LIGHTS = [
  29.   # [FILENAME, CELLS, ZOOM, OFFSET_Y, HUE]

  30.     ["light5",     1,  1.5,        0,   0],

  31.     ["light2",     1,  1.0,        0,   0],

  32.     ["light3",     1,  0.8,        0,   0],

  33.     ["light4",     1,  1.0,      -16,   0],

  34.     ["light5",     1,  2.0,        0,   0],

  35.     ["light6",     1,  1.0,        0,   0],

  36.     ["light7",     1,  3.0,      -16,   0],

  37.     ["light1",     1,  0.5,        0,   0],

  38.     ["light6",     1,  2.0,        0,   0],

  39.   ]

  40. end

  41. #  ----- 在这里设定 -----


  42. module HN_Light

  43.   # 事件mix-in用

  44.   module LightEvent

  45.     attr_reader :light_type

  46.     def initialize

  47.       super()

  48.       @light_type = 0

  49.     end

  50.    
  51.     def check_light

  52.       @light_type = 0

  53.       return if @list.nil?

  54.       @list.each do |command|

  55.         break if @light_type > 0

  56.         if command.code == 108 or command.code == 408

  57.           command.parameters.each do |line|

  58.             if line =~ REGEX_LIGHT

  59.               @light_type = $1.to_i

  60.               break

  61.             end

  62.           end

  63.         end

  64.       end # END @list.each

  65.     end

  66.    
  67.   end # END module LightEvent

  68.   

  69.   

  70.   class Light

  71.     attr_reader :bitmap

  72.     attr_reader :cells

  73.     attr_reader :width

  74.     attr_reader :height

  75.     attr_reader :ox

  76.     attr_reader :oy

  77.     def initialize(light_type, s_zoom = 1)

  78.       light = LIGHTS[light_type - 1]

  79.       if light.nil?

  80.         # 本来不应该来这里

  81.         @bitmap = Bitmap.new(32, 32)

  82.         @cels = 1

  83.         @zoom = 1.0

  84.         @oy = 16

  85.         @ox = 16

  86.         @width  = 32

  87.         @height = 32

  88.       else

  89.         @bitmap = Bitmap.new(LIGHT_IMG_DIR + light[0])

  90.         @bitmap.invert()

  91.         @cells = light[1].to_i

  92.         @cells = 1 if (@cells < 1 or @cells > @bitmap.width)

  93.         @zoom = light[2].to_f

  94.         @zoom = 1.0 if @zoom <= 0.0

  95.         @zoom /= s_zoom

  96.         @width  = @bitmap.width / @cells

  97.         @height = @bitmap.height


  98.         # 缩放处理

  99.         if @zoom != 1.0

  100.           new_width  = (@width * @zoom).round

  101.           new_height = (@height * @zoom).round

  102.           if new_width * new_height < 1

  103.             @zoom = 1.0

  104.           else

  105.             @width = new_width

  106.             @height = new_height

  107.             new_bitmap = Bitmap.new(@width * @cells, @height)

  108.             new_bitmap.stretch_blt(new_bitmap.rect,@bitmap, @bitmap.rect)

  109.             @bitmap.dispose

  110.             @bitmap = new_bitmap

  111.           end

  112.         end

  113.         @ox = @width / 2

  114.         @oy = @height / 2 - light[3].to_i / s_zoom


  115.         # 色相変换

  116.         if ( (hue = light[4].to_i) != 0)

  117.           @bitmap.hue_change(hue)

  118.         end

  119.       end

  120.     end # End def initialize


  121.     # 色调转换

  122.     def dispose

  123.       @bitmap.dispose

  124.       @bitmap = nil

  125.     end

  126.   end


  127. end


  128. class Game_Event

  129.   include HN_Light::LightEvent

  130.   alias :_hn_light__setup :setup_page unless method_defined?(:_hn_light__setup)

  131.   def setup_page(new_page)

  132.     _hn_light__setup(new_page)

  133.     check_light()

  134.   end

  135. end


  136. class Game_Player

  137.   def light_type

  138.     return $game_variables[HN_Light::PLAYER_LIGHT_TYPE]

  139.   end

  140. end


  141. class Game_Follower

  142.   def light_type

  143.     return 0 if !self.visible?

  144.     return $game_variables[HN_Light::FOLLOWER_LIGHT_TYPE]

  145.   end

  146. end


  147. class Game_Map

  148.   attr_reader :light_events

  149.   

  150.   # 更新烛光事件列表

  151.   def refresh_lights

  152.     @light_events = []

  153.     @events.values.each do |event|

  154.       if (event.light_type > 0)

  155.         @light_events.push(event)

  156.       end

  157.     end

  158.   end


  159.   alias :_hn_light__setup_events :setup_events unless method_defined?(:_hn_light__setup_events)

  160.   def setup_events

  161.     _hn_light__setup_events()

  162.     refresh_lights()

  163.   end

  164.   

  165.   alias :_hn_light__refresh :refresh unless method_defined?(:_hn_light__refresh)

  166.   def refresh

  167.     _hn_light__refresh()

  168.     refresh_lights()

  169.   end

  170. end


  171. class Sprite_Dark < Sprite

  172.   @@base_color = Color.new(255,255,255)


  173.   def initialize(viewport = nil)

  174.     super(viewport)

  175.     @width = Graphics.width

  176.     @height = Graphics.height

  177.    
  178.     case HN_Light::SIMPLIFY

  179.     when 1

  180.       @zoom = 2

  181.     when 2

  182.       @zoom = 4

  183.     else

  184.       @zoom = 1

  185.     end

  186.     @width /= @zoom

  187.     @height /= @zoom

  188.     self.zoom_x = @zoom.to_f

  189.     self.zoom_y = @zoom.to_f

  190.    
  191.     self.bitmap = Bitmap.new(@width, @height)

  192.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)

  193.     self.blend_type = 2 # 混合型(减算)

  194.     self.z = 500

  195.     self.visible = false

  196.     @light_cache = {}

  197.   end


  198.   # 追加烛光

  199.   def add_light(charactor)

  200.     return if charactor.nil?

  201.     light_type = charactor.light_type

  202.     return if (light_type < 1 or light_type > HN_Light::LIGHTS.size)

  203.     unless @light_cache.key?(light_type)

  204.       @light_cache[light_type] = HN_Light::Light.new(light_type, @zoom)

  205.     end

  206.     light = @light_cache[light_type]


  207.     # 画面外什麽都不做

  208.     if @zoom == 1

  209.       return if (charactor.screen_x < 0  - light.width + light.ox)

  210.       return if (charactor.screen_x > @width + light.ox)

  211.       return if (charactor.screen_y < 0 - light.height + light.oy)

  212.       return if (charactor.screen_y > @height + light.oy)

  213.     else

  214.       return if (charactor.screen_x < 0  - (light.width + light.ox) * @zoom)

  215.       return if (charactor.screen_x > (@width + light.ox)  * @zoom)

  216.       return if (charactor.screen_y < 0 - (light.height + light.oy) * @zoom)

  217.       return if (charactor.screen_y > (@height + light.oy) * @zoom)

  218.     end


  219.     # 动画判定

  220.     if light.cells > 1

  221.       index = (Graphics.frame_count / 4) % light.cells

  222.       rect = Rect.new(index * light.width , 0, light.width, light.height)

  223.     else

  224.       rect = light.bitmap.rect

  225.     end

  226.     if @zoom != 1

  227.       p_x = charactor.screen_x / @zoom - light.ox

  228.       p_y = (charactor.screen_y - 16) / @zoom - light.oy

  229.     else

  230.       p_x = charactor.screen_x - light.ox

  231.       p_y = charactor.screen_y - 16 - light.oy

  232.     end

  233.    
  234.     # 乗算合成(3)

  235.     self.bitmap.blend_blt(p_x, p_y, light.bitmap, rect, 3)

  236.   end


  237.   

  238.   def refresh

  239.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)

  240.     $game_map.light_events.each do |event|

  241.       next if HN_Light::LIGHTS[event.light_type - 1].nil?

  242.       add_light(event)

  243.     end

  244.     add_light($game_player)

  245.     $game_player.followers.each{|f| add_light(f)}

  246.   end

  247.   

  248.   # 更新

  249.   def update

  250.     super

  251.     refresh()

  252.   end

  253.   

  254.   #--------------------------------------------------------------------------

  255.   # ● 解放

  256.   #--------------------------------------------------------------------------

  257.   def dispose

  258.     self.bitmap.dispose

  259.     @light_cache.values.each do |light|

  260.       light.dispose

  261.     end

  262.     super

  263.   end

  264. end



  265. class Spriteset_Map  

  266.   # 动画判定

  267.   def create_dark

  268.     @dark_sprite = Sprite_Dark.new(@viewport1)

  269.   end


  270.   # 更新黑暗Sprite

  271.   def update_dark

  272.     if (@dark_sprite.visible = $game_switches[HN_Light::DARK_SWITCH])

  273.       @dark_sprite.update

  274.     end

  275.   end


  276.   # 破弃黑暗Sprite

  277.   def dispose_dark

  278.     @dark_sprite.dispose

  279.   end

  280.   

  281.   # 初期化

  282.   alias :_dark__initialize :initialize unless private_method_defined?(:_dark__initialize)

  283.   def initialize

  284.     _dark__initialize()

  285.     create_dark()

  286.     update_dark()

  287.   end

  288.   

  289.   # 更新

  290.   alias :_dark__update :update unless method_defined?(:_dark__update)

  291.   def update

  292.     _dark__update()

  293.     update_dark() if !@dark_sprite.nil? and !@dark_sprite.disposed?

  294.   end

  295.   

  296.   # 结束处理

  297.   alias :_dark__dispose :dispose unless method_defined?(:_dark__dispose)

  298.   def dispose

  299.     dispose_dark()

  300.     _dark__dispose()

  301.   end

  302. end
复制代码
回复

使用道具 举报

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-6-9 10:49:38 来自手机 | 显示全部楼层
1、尝试修改12号变量的数值
2、修改“# 烛光Bitmap设定”下面几行的zoom数值,也就是第二个逗号后面那个数字(比如第一行["light5",1,1.5,0,0],把1.5改成2.5试试看)
回复

使用道具 举报

梦石
0
星屑
385
在线时间
117 小时
注册时间
2012-10-2
回帖
114
 楼主| 发表于 2013-6-9 13:09:32 | 显示全部楼层
喵呜喵5 发表于 2013-6-9 10:49
1、尝试修改12号变量的数值
2、修改“# 烛光Bitmap设定”下面几行的zoom数值,也就是第二个逗号后面那个数 ...

用第二种方法可以确实解决灯光范围问题,谢谢了啊

另外还想问一下,想学习一下怎么使用这个脚本

这几个数字代表什么意思?

QQ图片20130609130839.jpg
回复

使用道具 举报

梦石
1
星屑
23371
在线时间
9572 小时
注册时间
2012-6-19
回帖
7021

开拓者短篇九导演组冠军

发表于 2013-6-9 20:05:18 | 显示全部楼层
113340 发表于 2013-6-9 13:09
用第二种方法可以确实解决灯光范围问题,谢谢了啊

另外还想问一下,想学习一下怎么使用这个脚本

filename:烛光图片文件名
cells:貌似是设定烛光摇曳的动画?
zoom:缩放放大倍率
offset_Y:Y补偿,大概就是烛光不以玩家为中心这样的感觉,没用过
hue:色调

评分

参与人数 1梦石 +1 收起 理由
Sion + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
385
在线时间
117 小时
注册时间
2012-10-2
回帖
114
 楼主| 发表于 2013-6-9 22:36:28 | 显示全部楼层
感觉会用了一点·谢谢楼上的帮忙了啊
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

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

在本版发帖返回顶部