查看: 3964|回复: 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
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 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
找到灯光脚本中显示视野的那部分,调整它的放大率就好了

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

现在就贴出脚本

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




[pre lang="ruby" line="1"]=begin

  HN_Light version 1.0.1.0 for VX Ace

        by 半生


  要HN_RG_BITMAP(ver 0.1.2.1以降)


2012/01/08 ver 1.0.1.2

 队列歩行の仲间に対応


=end


# ----- 在这里设定-----

module HN_Light

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

  SIMPLIFY = 1

  

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

  PLAYER_LIGHT_TYPE = 12


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

  FOLLOWER_LIGHT_TYPE = 12

  

  # 黑暗判断上使用的开关

  DARK_SWITCH = 13

  

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

  REGEX_LIGHT = /@LIGHT(\d+)/

  

  # 烛光图像的目录

  LIGHT_IMG_DIR = "Graphics/Pictures/"

  

  # 烛光Bitmap设定

  LIGHTS = [
  # [FILENAME, CELLS, ZOOM, OFFSET_Y, HUE]

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

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

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

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

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

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

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

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

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

  ]

end

#  ----- 在这里设定 -----


module HN_Light

  # 事件mix-in用

  module LightEvent

    attr_reader :light_type

    def initialize

      super()

      @light_type = 0

    end

   
    def check_light

      @light_type = 0

      return if @list.nil?

      @list.each do |command|

        break if @light_type > 0

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

          command.parameters.each do |line|

            if line =~ REGEX_LIGHT

              @light_type = $1.to_i

              break

            end

          end

        end

      end # END @list.each

    end

   
  end # END module LightEvent

  

  

  class Light

    attr_reader :bitmap

    attr_reader :cells

    attr_reader :width

    attr_reader :height

    attr_reader :ox

    attr_reader :oy

    def initialize(light_type, s_zoom = 1)

      light = LIGHTS[light_type - 1]

      if light.nil?

        # 本来不应该来这里

        @bitmap = Bitmap.new(32, 32)

        @cels = 1

        @zoom = 1.0

        @oy = 16

        @ox = 16

        @width  = 32

        @height = 32

      else

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

        @bitmap.invert()

        @cells = light[1].to_i

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

        @zoom = light[2].to_f

        @zoom = 1.0 if @zoom <= 0.0

        @zoom /= s_zoom

        @width  = @bitmap.width / @cells

        @height = @bitmap.height


        # 缩放处理

        if @zoom != 1.0

          new_width  = (@width * @zoom).round

          new_height = (@height * @zoom).round

          if new_width * new_height < 1

            @zoom = 1.0

          else

            @width = new_width

            @height = new_height

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

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

            @bitmap.dispose

            @bitmap = new_bitmap

          end

        end

        @ox = @width / 2

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


        # 色相変换

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

          @bitmap.hue_change(hue)

        end

      end

    end # End def initialize


    # 色调转换

    def dispose

      @bitmap.dispose

      @bitmap = nil

    end

  end


end


class Game_Event

  include HN_Light::LightEvent

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

  def setup_page(new_page)

    _hn_light__setup(new_page)

    check_light()

  end

end


class Game_Player

  def light_type

    return $game_variables[HN_Light::PLAYER_LIGHT_TYPE]

  end

end


class Game_Follower

  def light_type

    return 0 if !self.visible?

    return $game_variables[HN_Light::FOLLOWER_LIGHT_TYPE]

  end

end


class Game_Map

  attr_reader :light_events

  

  # 更新烛光事件列表

  def refresh_lights

    @light_events = []

    @events.values.each do |event|

      if (event.light_type > 0)

        @light_events.push(event)

      end

    end

  end


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

  def setup_events

    _hn_light__setup_events()

    refresh_lights()

  end

  

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

  def refresh

    _hn_light__refresh()

    refresh_lights()

  end

end


class Sprite_Dark < Sprite

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


  def initialize(viewport = nil)

    super(viewport)

    @width = Graphics.width

    @height = Graphics.height

   
    case HN_Light::SIMPLIFY

    when 1

      @zoom = 2

    when 2

      @zoom = 4

    else

      @zoom = 1

    end

    @width /= @zoom

    @height /= @zoom

    self.zoom_x = @zoom.to_f

    self.zoom_y = @zoom.to_f

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

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

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

    self.z = 500

    self.visible = false

    @light_cache = {}

  end


  # 追加烛光

  def add_light(charactor)

    return if charactor.nil?

    light_type = charactor.light_type

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

    unless @light_cache.key?(light_type)

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

    end

    light = @light_cache[light_type]


    # 画面外什麽都不做

    if @zoom == 1

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

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

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

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

    else

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

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

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

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

    end


    # 动画判定

    if light.cells > 1

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

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

    else

      rect = light.bitmap.rect

    end

    if @zoom != 1

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

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

    else

      p_x = charactor.screen_x - light.ox

      p_y = charactor.screen_y - 16 - light.oy

    end

   
    # 乗算合成(3)

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

  end


  

  def refresh

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

    $game_map.light_events.each do |event|

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

      add_light(event)

    end

    add_light($game_player)

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

  end

  

  # 更新

  def update

    super

    refresh()

  end

  

  #--------------------------------------------------------------------------

  # ● 解放

  #--------------------------------------------------------------------------

  def dispose

    self.bitmap.dispose

    @light_cache.values.each do |light|

      light.dispose

    end

    super

  end

end



class Spriteset_Map  

  # 动画判定

  def create_dark

    @dark_sprite = Sprite_Dark.new(@viewport1)

  end


  # 更新黑暗Sprite

  def update_dark

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

      @dark_sprite.update

    end

  end


  # 破弃黑暗Sprite

  def dispose_dark

    @dark_sprite.dispose

  end

  

  # 初期化

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

  def initialize

    _dark__initialize()

    create_dark()

    update_dark()

  end

  

  # 更新

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

  def update

    _dark__update()

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

  end

  

  # 结束处理

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

  def dispose

    dispose_dark()

    _dark__dispose()

  end

end
[/pre]
回复

使用道具 举报

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 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
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 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.

在本版发帖返回顶部