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

Project1

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

[已经过期] 关于HN_Light灯光脚本怎么让黑暗盖住系统默认的雨

[复制链接]

Lv1.梦旅人

梦石
0
星屑
150
在线时间
369 小时
注册时间
2012-8-6
帖子
47
跳转到指定楼层
1
发表于 2016-7-29 18:45:11 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题,我尝试把HN_Light灯光脚本的黑暗的z值改到无穷大(99999)仍然无法盖住游戏系统自带的雨。如何解决呢?
RUBY 代码复制
  1. =begin
  2.   HN_Light version 0.0.0.4
  3.         by 半生
  4. [url]http://www11.atpages.jp/namahanka/[/url]
  5.  
  6.   要HN_RG_BITMAP(ver 0.1.2.1以降)
  7.   ver 0.0.0.4
  8.    イベント条件を満たすページが無い状態に移行する時に落ちるバグを修正
  9. =end
  10.  
  11. # ----- ▽ 设定 ▽ -----
  12. module HN_Light
  13.   # 分辨率 0:(高清)~2:(流畅)
  14.   SIMPLIFY = 2
  15.  
  16.   # 玩家的灯光类型使用变量号码
  17.   PLAYER_LIGHT_TYPE = 1
  18.  
  19.   # 开关
  20.   DARK_SWITCH = 2
  21.  
  22.   # 灯光活动识别用的正规表达式
  23.   REGEX_LIGHT = /灯光(\d+)/
  24.  
  25.   # 灯光图像的目录
  26.   LIGHT_IMG_DIR = "Graphics/Pictures/"
  27.  
  28.   # 灯光Bitmap设定
  29.   LIGHTS = [
  30.   # [文件名称, 帧数, 缩放率, 光的Y轴, 色相]
  31.     ["light1",     1,  0.5,        0,   0],
  32.     ["light2",     1,  1.7,        0,   0],
  33.     ["light3",     1,  1.7,        0,   0],
  34.     ["light4",     1,  3.0,        0,   0],
  35.     ["light5",     1,  5.0,        -40,   50],
  36.     ["light6",     1,  3.0,        0,   0],
  37.     ["light7",     1,  3.0,        0,   0],
  38.     ["light8",     1,  1.0,        0,  50],
  39.     ["light9",     1,  1.5,        0,  10],
  40.     ["light10",    1,  4.0,        0,  0],
  41.     ["light11",    1,  1.0,        0,  0],
  42.     ["light11",    1,  1.0,        0,  0],
  43.     ["light12",    1,  1.0,        0,  0],
  44.     ["light11",    1,  1.0,        0,  0],
  45.   ]
  46. end
  47. # ----- △ 設定ここまで △ -----
  48.  
  49. module HN_Light
  50.   # イベントへのmix-in用
  51.   module LightEvent
  52.     attr_reader :light_type
  53.     def initialize
  54.       super()
  55.       @light_type = 0
  56.     end
  57.  
  58.     def check_light
  59.       @light_type = 0
  60.       return if @list.nil?
  61.       @list.each do |command|
  62.         break if @light_type > 0
  63.         if command.code == 108 or command.code == 408
  64.           command.parameters.each do |line|
  65.             if line =~ REGEX_LIGHT
  66.               @light_type = $1.to_i
  67.               break
  68.             end
  69.           end
  70.         end
  71.       end # END @list.each
  72.     end
  73.  
  74.   end # END module LightEvent
  75.  
  76.  
  77.   class Light
  78.     attr_reader :bitmap
  79.     attr_reader :cells
  80.     attr_reader :width
  81.     attr_reader :height
  82.     attr_reader :ox
  83.     attr_reader :oy
  84.     def initialize(light_type, s_zoom = 1)
  85.       light = LIGHTS[light_type - 1]
  86.       if light.nil?
  87.         # 本来ならここには来ないはず
  88.         @bitmap = Bitmap.new(32, 32)
  89.         @cels = 1
  90.         [url=home.php?mod=space&uid=98379]@zoom[/url] = 1.0
  91.         @oy = 16
  92.         @ox = 16
  93.         @width  = 32
  94.         [url=home.php?mod=space&uid=291977]@height[/url] = 32
  95.       else
  96.         @bitmap = Bitmap.new(LIGHT_IMG_DIR + light[0])
  97.         @bitmap.invert()
  98.         @cells = light[1].to_i
  99.         @cells = 1 if (@cells < 1 or @cells > @bitmap.width)
  100.         @zoom = light[2].to_f
  101.         @zoom = 1.0 if @zoom <= 0.0
  102.         @zoom /= s_zoom
  103.         @width  = @bitmap.width / @cells
  104.         @height = @bitmap.height
  105.  
  106.         # 拡大縮小処理
  107.         if @zoom != 1.0
  108.           new_width  = (@width * @zoom).round
  109.           new_height = (@height * @zoom).round
  110.           if new_width * new_height < 1
  111.             @zoom = 1.0
  112.           else
  113.             @width = new_width
  114.             @height = new_height
  115.             new_bitmap = Bitmap.new(@width * @cells, @height)
  116.             new_bitmap.stretch_blt(new_bitmap.rect,@bitmap, @bitmap.rect)
  117.             @bitmap.dispose
  118.             @bitmap = new_bitmap
  119.           end
  120.         end
  121.         @ox = @width / 2
  122.         @oy = @height / 2 - light[3].to_i / s_zoom
  123.  
  124.         # 色相変換
  125.         if ( (hue = light[4].to_i) != 0)
  126.           @bitmap.hue_change(hue)
  127.         end
  128.       end
  129.     end # End def initialize
  130.  
  131.     # 終了処理
  132.     def dispose
  133.       @bitmap.dispose
  134.       @bitmap = nil
  135.     end
  136.   end
  137.  
  138. end
  139.  
  140. class Game_Event
  141.   include HN_Light::LightEvent
  142.   alias :_hn_light__setup :setup unless method_defined?(:_hn_light__setup)
  143.   def setup(new_page)
  144.     _hn_light__setup(new_page)
  145.     check_light()
  146.   end
  147. end
  148.  
  149. class Game_Player
  150.   def light_type
  151.     return $game_variables[HN_Light::PLAYER_LIGHT_TYPE]
  152.   end
  153. end
  154.  
  155. class Game_Map
  156.   attr_reader :light_events
  157.  
  158.   # 灯りイベントリストの更新
  159.   def refresh_lights
  160.     @light_events = []
  161.     @events.values.each do |event|
  162.       if (event.light_type > 0)
  163.         @light_events.push(event)
  164.       end
  165.     end
  166.   end
  167.  
  168.   alias :_hn_light__setup_events :setup_events unless method_defined?(:_hn_light__setup_events)
  169.   def setup_events
  170.     _hn_light__setup_events()
  171.     refresh_lights()
  172.   end
  173.  
  174.   alias :_hn_light__refresh :refresh unless method_defined?(:_hn_light__refresh)
  175.   def refresh
  176.     _hn_light__refresh()
  177.     refresh_lights()
  178.   end
  179. end
  180.  
  181. class Sprite_Dark < Sprite
  182.  
  183.   @@base_color = Color.new(255,255,255)
  184.  
  185.   def initialize(viewport = nil)
  186.     super(viewport)
  187.     @width = Graphics.width
  188.     @height = Graphics.height
  189.  
  190.     case HN_Light::SIMPLIFY
  191.     when 1
  192.       @zoom = 2
  193.     when 2
  194.       @zoom = 4
  195.     else
  196.       @zoom = 1
  197.     end
  198.     @width /= @zoom
  199.     @height /= @zoom
  200.     self.zoom_x = @zoom.to_f
  201.     self.zoom_y = @zoom.to_f
  202.  
  203.     self.bitmap = Bitmap.new(@width, @height)
  204.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)
  205.     self.blend_type = 2 # ブレンドタイプ(減算)
  206.     self.z = 500
  207.     self.visible = false
  208.     @light_cache = {}
  209.   end
  210.  
  211.   # 灯りを追加する
  212.   def add_light(charactor)
  213.     light_type = charactor.light_type
  214.     return if (light_type < 1 or light_type > HN_Light::LIGHTS.size)
  215.     unless @light_cache.key?(light_type)
  216.       @light_cache[light_type] = HN_Light::Light.new(light_type, @zoom)
  217.     end
  218.     light = @light_cache[light_type]
  219.  
  220.     # 画面外の場合は何もしない
  221.     if @zoom == 1
  222.       return if (charactor.screen_x < 0  - light.width + light.ox)
  223.       return if (charactor.screen_x > @width + light.ox)
  224.       return if (charactor.screen_y < 0 - light.height + light.oy)
  225.       return if (charactor.screen_y > @height + light.oy)
  226.     else
  227.       return if (charactor.screen_x < 0  - (light.width + light.ox) * @zoom)
  228.       return if (charactor.screen_x > (@width + light.ox)  * @zoom)
  229.       return if (charactor.screen_y < 0 - (light.height + light.oy) * @zoom)
  230.       return if (charactor.screen_y > (@height + light.oy) * @zoom)
  231.     end
  232.  
  233.     # アニメーション判定
  234.     if light.cells > 1
  235.       index = (Graphics.frame_count / 4) % light.cells
  236.       rect = Rect.new(index * light.width , 0, light.width, light.height)
  237.     else
  238.       rect = light.bitmap.rect
  239.     end
  240.     if @zoom != 1
  241.       p_x = charactor.screen_x / @zoom - light.ox
  242.       p_y = (charactor.screen_y - 16) / @zoom - light.oy
  243.     else
  244.       p_x = charactor.screen_x - light.ox
  245.       p_y = charactor.screen_y - 16 - light.oy
  246.     end
  247.  
  248.     # 乗算合成(3)
  249.     self.bitmap.blend_blt(p_x, p_y, light.bitmap, rect, 3)
  250.   end
  251.  
  252.  
  253.   def refresh
  254.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)
  255.     $game_map.light_events.each do |event|
  256.       next if HN_Light::LIGHTS[event.light_type - 1].nil?
  257.       add_light(event)
  258.     end
  259.     add_light($game_player)
  260.   end
  261.  
  262.   # 更新
  263.   def update
  264.     super
  265.     refresh()
  266.   end
  267.  
  268.   #--------------------------------------------------------------------------
  269.   # ● 解放
  270.   #--------------------------------------------------------------------------
  271.   def dispose
  272.     self.bitmap.dispose
  273.     @light_cache.values.each do |light|
  274.       light.dispose
  275.     end
  276.     super
  277.   end
  278. end
  279.  
  280.  
  281. class Spriteset_Map  
  282.   # 暗闇スプライトの作成
  283.   def create_dark
  284.     @dark_sprite = Sprite_Dark.new(@viewport1)
  285.   end
  286.  
  287.   # 暗闇スプライトの更新
  288.   def update_dark
  289.     if (@dark_sprite.visible = $game_switches[HN_Light::DARK_SWITCH])
  290.       @dark_sprite.update
  291.       $game_switches[8] = false
  292.     end
  293.   end
  294.  
  295.   # 暗闇スプライトの破棄
  296.   def dispose_dark
  297.     @dark_sprite.dispose
  298.   end
  299.  
  300.   # 初期化
  301.   alias :_dark__initialize :initialize unless private_method_defined?(:_dark__initialize)
  302.   def initialize
  303.     _dark__initialize()
  304.     create_dark()
  305.     update_dark()
  306.   end
  307.  
  308.   # 更新
  309.   alias :_dark__update :update unless method_defined?(:_dark__update)
  310.   def update
  311.     _dark__update()
  312.     update_dark() if !@dark_sprite.nil? and !@dark_sprite.disposed?
  313.   end
  314.  
  315.   # 終了処理
  316.   alias :_dark__dispose :dispose unless method_defined?(:_dark__dispose)
  317.   def dispose
  318.     dispose_dark()
  319.     _dark__dispose()
  320.   end
  321. end

Lv1.梦旅人

梦石
0
星屑
150
在线时间
369 小时
注册时间
2012-8-6
帖子
47
2
 楼主| 发表于 2016-7-30 13:34:24 | 只看该作者
自顶{:2_263:}
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-19 15:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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