Project1

标题: [RMVA]日本的烛光系統-中文化 [打印本页]

作者: tseyik    时间: 2012-2-28 22:10
标题: [RMVA]日本的烛光系統-中文化
本帖最后由 tseyik 于 2015-2-17 11:59 编辑

這個灯光系統、可以用事件指定地図光/暗切換

原脚本來自
半生@Page(仮)
灯光(日文)  sample_beta.zip
http://pan.baidu.com/share/link?shareid=99516&uk=2635094904


繁体範本
http://115.com/file/e7fk7e7v#
Project3.exe

這個脚本要把Bitmap功能拡張DLL(tktk_bitmap.dll)
放在専案/GAME.exe同一件夾中
叧外加入這二個脚本
Bitmap
HN_Ligh

Bitmap脚本
  1. # coding: utf-8
  2. =begin
  3. = Bitmap类拡张 (DLL版)
  4. RPGツクールXP/VX/VA共用
  5. 添加功能 Bitmap 类。
  6. - Marshaldump 启用
  7. - 保存为PNG文件
  8. -色调变化
  9. -马赛克效果
  10. -反相颜色
  11. -模糊效果
  12. -使用遮罩-切除
  13. -混合

  14. ■ 注意
  15. 这个脚本需要"tktk_bitmap.dll"(ver0.1.2.6以上)。

  16. Author::    半生
  17. Date::      2010/12/13
  18. Version::   0.1.2.6
  19. URL::       [url]http://www.tktkgame.com/[/url]

  20. ################更新########################
  21. 2010/12/13 ver 0.1.2.6
  22.  dll名称从"hn_rg_bitmap.dll"变更为"tktk_bitmap.dll"
  23.  LARGE_BITMAP机能でメモリを确保できなかった场合の処理を追加
  24. 2010/10/12 ver 0.1.2.5(デンジャラスベータ版)
  25.  大きいサイズのBitmapオブジェクトを机能を试験的に実装(危険)
  26. 2010/03/24 ver 0.1.2.2
  27.  ブレンディング机能関连の軽量化。
  28.  画像连结系メソッドの分离。
  29. 2010/03/24 ver 0.1.2.1
  30.  ブレンディング机能関连のバグフィックス
  31. 2010/03/22 ver 0.1.2.0
  32.  加算合成等のブレンディング机能の追加
  33. 2010/02/07 ver 0.1.1.0
  34.  マーシャル化の処理の一部をDLLに移动
  35. 2010/01/17 ver 0.1.0.0
  36.  dllの名称を"hn_rx_bitmap.dll"から"hn_rg_bitmap.dll"に変更
  37.  モザイク効果・色反転・ぼかし効果の追加
  38. ############################################
  39. =end

  40. module TKTK_Bitmap
  41.   LARGE_BITMAP = true # 是否使用大型点阵图的功能
  42.   DLL_NAME = 'tktk_bitmap'

  43.   ERROR_ALLOCATE_FAILED = -110002

  44.   @@png_save = Win32API.new(DLL_NAME, 'PngSaveA', 'p n i i', 'i')
  45.   @@blur = Win32API.new(DLL_NAME, 'Blur', 'n i', 'i')
  46.   @@change_tone = Win32API.new(DLL_NAME, 'ChangeTone', 'n i i i i', 'i')
  47.   @@clip_mask = Win32API.new(DLL_NAME, 'ClipMask', 'n n i i i', 'i')
  48.   @@invert = Win32API.new(DLL_NAME, 'InvertColor', 'n', 'i')
  49.   @@mosaic = Win32API.new(DLL_NAME, 'Mosaic', 'n i i i i i i', 'i')
  50.   @@address = Win32API.new(DLL_NAME, 'GetAddress', 'n', 'n')
  51.   @@get_pixel_data = Win32API.new(DLL_NAME, 'GetPixelData', 'n p i', 'i')
  52.   @@set_pixel_data = Win32API.new(DLL_NAME, 'SetPixelData', 'n p i', 'i')
  53.   @@blend_blt = Win32API.new(DLL_NAME, 'BlendBlt', 'n i i n i i i i i i', 'i')
  54.   #@@get_hwnd = Win32API.new(DLL_NAME, 'GetGameHWND', 'v', 'l')
  55.   @@change_size = Win32API.new(DLL_NAME, 'ChangeSize', 'n i i', 'i')
  56.   module_function

  57.   # PNG形式储存
  58.   def png_save(bitmap,file_name,compression_level,filter)
  59.     return @@png_save.call(file_name, bitmap.object_id, compression_level, filter)
  60.   end

  61.   # 模糊效果
  62.   def blur(bitmap, r = 1)
  63.     return @@blur.call(bitmap.object_id, r)
  64.   end
  65.   
  66.   # 更改颜色平衡?
  67.   def change_tone(bitmap, red = 0, green = 0, blue = 0, simplify = 1)
  68.     return @@change_tone.call(bitmap.object_id, red, green, blue, simplify)
  69.   end
  70. # 剪贴蒙版图像(α乘法)
  71.   def clip_mask(g_bitmap, m_bitmap, x=0, y=0, outer=0)
  72.     return @@clip_mask.call(g_bitmap.object_id, m_bitmap.object_id, x, y, outer)
  73.   end

  74.   # 色的反转
  75.   def invert(bitmap)
  76.     return @@invert.call(bitmap.object_id)
  77.   end

  78.   # 马赛克效果
  79.   def mosaic(bitmap, msw=5, msh=5)
  80.     return self.mosaic_rect(bitmap, bitmap.rect, msw, msh)
  81.   end

  82.   # 马赛克效果(范围指定)
  83.   def mosaic_rect(bitmap, rect, msw=5, msh=5)
  84.     return @@mosaic.call(bitmap.object_id,
  85.     rect.x, rect.y, rect.width, rect.height, msw, msh)
  86.   end

  87.   # 获取Bitmap资料位址
  88.   def address(bitmap)
  89.     return @@address.call(bitmap.object_id)
  90.   end
  91.   
  92.   # 二进位资料获取点Bitmap阵图
  93.   def get_pixel_data(bitmap)
  94.     buffer = "bgra" * bitmap.width * bitmap.height
  95.     @@get_pixel_data.call(bitmap.object_id, buffer, buffer.size)
  96.     return buffer
  97.   end
  98.   
  99.   #替换为Bitmap中的二进位资料
  100.   def set_pixel_data(bitmap, data)
  101.     return @@set_pixel_data.call(bitmap.object_id, data, data.size)
  102.   end
  103.   
  104.   def blend_blt(dest_bmp, x, y, src_bmp, rect, blend_type=0, opacity=255)
  105.     @@blend_blt.call(dest_bmp.object_id, x, y, src_bmp.object_id,
  106.                 rect.x, rect.y, rect.width, rect.height,
  107.                 blend_type, opacity)
  108.   end

  109.   # 改变Bitmap的大小(风险)
  110.   def change_size(bitmap, new_width, new_height)
  111.     return -1 if (new_width <=0 or new_height <= 0)
  112.     result = @@change_size.call(bitmap.object_id, new_width, new_height)
  113.     if result == ERROR_ALLOCATE_FAILED
  114.       raise("tktk_bitmap:ERROR ALLOCATE FAILED")
  115.     end
  116.     return result
  117.   end
  118.   
  119. end

  120. class Font
  121.   def marshal_dump;end
  122.   def marshal_load(obj);end
  123. end
  124. class Bitmap
  125.   # PNG 压缩筛检程式
  126.   PNG_NO_FILTERS   = 0x00
  127.   PNG_FILTER_NONE  = 0x08
  128.   PNG_FILTER_SUB   = 0x10
  129.   PNG_FILTER_UP    = 0x20
  130.   PNG_FILTER_AVG   = 0x40
  131.   PNG_FILTER_PAETH = 0x80
  132.   PNG_ALL_FILTERS  = (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP |
  133.                       PNG_FILTER_AVG | PNG_FILTER_PAETH)

  134.   # Marshal_dump
  135.   def _dump(limit)
  136.     return "" if self.disposed?
  137.     data = TKTK_Bitmap.get_pixel_data(self)
  138.     [width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # ついでに圧缩
  139.   end
  140.   
  141.   # Marshal_load
  142.   def self._load(str)
  143.     if str == ""
  144.       b = Bitmap.new(1,1)
  145.       b.dispose
  146.       return b
  147.     end
  148.     w, h, zdata = str.unpack("LLa*"); b = new(w, h)
  149.     TKTK_Bitmap.set_pixel_data(b, Zlib::Inflate.inflate(zdata))
  150.     return b
  151.   end  
  152.   
  153.   def address
  154.     TKTK_Bitmap.address(self)
  155.   end

  156.   #     模糊效果
  157.   def blur2(r=1)
  158.     TKTK_Bitmap.blur(self, r)
  159.   end

  160.   # 色调变化
  161.   def change_tone(red, green, blue, simplify = 1)
  162.     TKTK_Bitmap.change_tone(self, red, green, blue, simplify)
  163.   end
  164.   
  165.   # 剪切
  166.   def clip_mask(bitmap, x=0, y=0, outer=0)
  167.     TKTK_Bitmap.clip_mask(self, bitmap, x, y, outer)
  168.   end

  169.   # 反相颜色
  170.   def invert
  171.     TKTK_Bitmap.invert(self)
  172.   end

  173.   # 马赛克效果
  174.   def mosaic(msw=5, msh=5)
  175.     TKTK_Bitmap.mosaic(self, msw, msh)
  176.   end

  177.   # 马赛克效果 (指定区域)
  178.   def mosaic_rect(rect=self.rect, msw=5, msh=5)
  179.     TKTK_Bitmap.mosaic_rect(self, rect, msw, msh)
  180.   end

  181.   # 混合
  182.   def blend_blt(x, y, src_bmp, rect, blend_type=0, opacity=255)
  183.     return if opacity <= 0
  184.     TKTK_Bitmap.blend_blt(self, x, y, src_bmp, rect, blend_type, opacity)
  185.   end

  186.   #Png 格式保存
  187.   def png_save(outp, level = 9, filter = PNG_NO_FILTERS)
  188.     if (TKTK_Bitmap.png_save(self, outp, level, filter) != 0)
  189.       raise("Bitmap\#png_save failed")
  190.     end
  191.   end

  192.   # 允许更大的 bitmap.new (危険)
  193.   # 宽度 * 高度大约是1073741823
  194.   if TKTK_Bitmap::LARGE_BITMAP
  195.     class << self
  196.       unless method_defined?(:_hn_large_bm__new)
  197.         alias :_hn_large_bm__new :new
  198.       end
  199.       def new(*args)
  200.         if args.size == 2 && args[0] * args[1] >= 4194304
  201.           new_width = args[0]
  202.           new_height = args[1]
  203.           # 暂时以小尺寸作成
  204.           bitmap = _hn_large_bm__new(16, 16)
  205.           TKTK_Bitmap.change_size(bitmap, new_width, new_height)
  206.           return bitmap
  207.         else
  208.           _hn_large_bm__new(*args)
  209.         end
  210.       end
  211.     end # Bitmap.new
  212.   end
  213. end # CLASS Bitmap
复制代码
HN_Ligh脚本

  1. =begin
  2.   HN_Light version 1.0.1.0 for VX Ace
  3.         by 半生
  4. http://www.tktkgame.com

  5.   要HN_RG_BITMAP(ver 0.1.2.1以降)

  6. 2012/01/08 ver 1.0.1.2
  7.  队列歩行の仲间に対応

  8. =end

  9. # ----- 在这里设定-----
  10. module HN_Light
  11.   # 简略化0:(精细)~2:(粗暴,负荷轻)
  12.   SIMPLIFY = 1
  13.   
  14.   # 家的烛光类型使用的变量号码
  15.   PLAYER_LIGHT_TYPE = 12

  16.   # 队友的烛光类型使用的变量号码
  17.   FOLLOWER_LIGHT_TYPE = 12
  18.   
  19.   # 黑暗判断上使用的开
  20.   DARK_SWITCH = 11
  21.   
  22.   # 烛光事件识别用的正规表达式
  23.   REGEX_LIGHT = /@LIGHT(\d+)/
  24.   
  25.   # 烛光图像的目录
  26.   LIGHT_IMG_DIR = "Graphics/Pictures/"
  27.   
  28.   # 烛光Bitmap设定
  29.   LIGHTS = [
  30.   # [FILENAME, CELLS, ZOOM, OFFSET_Y, HUE]
  31.     ["light5",     1,  1.5,        0,   0],
  32.     ["light2",     1,  1.0,        0,   0],
  33.     ["light3",     1,  0.8,        0,   0],
  34.     ["light4",     1,  1.0,      -16,   0],
  35.     ["light5",     1,  2.0,        0,   0],
  36.     ["light6",     1,  1.0,        0,   0],
  37.     ["light7",     1,  3.0,      -16,   0],
  38.     ["light1",     1,  0.5,        0,   0],
  39.     ["light6",     1,  2.0,        0,   0],
  40.   ]
  41. end
  42. #  ----- 在这里设定 -----

  43. module HN_Light
  44.   # 事件mix-in用
  45.   module LightEvent
  46.     attr_reader :light_type
  47.     def initialize
  48.       super()
  49.       @light_type = 0
  50.     end
  51.    
  52.     def check_light
  53.       @light_type = 0
  54.       return if @list.nil?
  55.       @list.each do |command|
  56.         break if @light_type > 0
  57.         if command.code == 108 or command.code == 408
  58.           command.parameters.each do |line|
  59.             if line =~ REGEX_LIGHT
  60.               @light_type = $1.to_i
  61.               break
  62.             end
  63.           end
  64.         end
  65.       end # END @list.each
  66.     end
  67.    
  68.   end # END module LightEvent
  69.   
  70.   
  71.   class Light
  72.     attr_reader :bitmap
  73.     attr_reader :cells
  74.     attr_reader :width
  75.     attr_reader :height
  76.     attr_reader :ox
  77.     attr_reader :oy
  78.     def initialize(light_type, s_zoom = 1)
  79.       light = LIGHTS[light_type - 1]
  80.       if light.nil?
  81.         # 本来不应该来这里
  82.         @bitmap = Bitmap.new(32, 32)
  83.         @cels = 1
  84.         @zoom = 1.0
  85.         @oy = 16
  86.         @ox = 16
  87.         @width  = 32
  88.         @height = 32
  89.       else
  90.         @bitmap = Bitmap.new(LIGHT_IMG_DIR + light[0])
  91.         @bitmap.invert()
  92.         @cells = light[1].to_i
  93.         @cells = 1 if (@cells < 1 or @cells > @bitmap.width)
  94.         @zoom = light[2].to_f
  95.         @zoom = 1.0 if @zoom <= 0.0
  96.         @zoom /= s_zoom
  97.         @width  = @bitmap.width / @cells
  98.         @height = @bitmap.height

  99.         # 缩放处理
  100.         if @zoom != 1.0
  101.           new_width  = (@width * @zoom).round
  102.           new_height = (@height * @zoom).round
  103.           if new_width * new_height < 1
  104.             @zoom = 1.0
  105.           else
  106.             @width = new_width
  107.             @height = new_height
  108.             new_bitmap = Bitmap.new(@width * @cells, @height)
  109.             new_bitmap.stretch_blt(new_bitmap.rect,@bitmap, @bitmap.rect)
  110.             @bitmap.dispose
  111.             @bitmap = new_bitmap
  112.           end
  113.         end
  114.         @ox = @width / 2
  115.         @oy = @height / 2 - light[3].to_i / s_zoom

  116.         # 色相変换
  117.         if ( (hue = light[4].to_i) != 0)
  118.           @bitmap.hue_change(hue)
  119.         end
  120.       end
  121.     end # End def initialize

  122.     # 色调转换
  123.     def dispose
  124.       @bitmap.dispose
  125.       @bitmap = nil
  126.     end
  127.   end

  128. end

  129. class Game_Event
  130.   include HN_Light::LightEvent
  131.   alias :_hn_light__setup :setup_page unless method_defined?(:_hn_light__setup)
  132.   def setup_page(new_page)
  133.     _hn_light__setup(new_page)
  134.     check_light()
  135.   end
  136. end

  137. class Game_Player
  138.   def light_type
  139.     return $game_variables[HN_Light::PLAYER_LIGHT_TYPE]
  140.   end
  141. end

  142. class Game_Follower
  143.   def light_type
  144.     return 0 if !self.visible?
  145.     return $game_variables[HN_Light::FOLLOWER_LIGHT_TYPE]
  146.   end
  147. end

  148. class Game_Map
  149.   attr_reader :light_events
  150.   
  151.   # 更新烛光事件列表
  152.   def refresh_lights
  153.     @light_events = []
  154.     @events.values.each do |event|
  155.       if (event.light_type > 0)
  156.         @light_events.push(event)
  157.       end
  158.     end
  159.   end

  160.   alias :_hn_light__setup_events :setup_events unless method_defined?(:_hn_light__setup_events)
  161.   def setup_events
  162.     _hn_light__setup_events()
  163.     refresh_lights()
  164.   end
  165.   
  166.   alias :_hn_light__refresh :refresh unless method_defined?(:_hn_light__refresh)
  167.   def refresh
  168.     _hn_light__refresh()
  169.     refresh_lights()
  170.   end
  171. end

  172. class Sprite_Dark < Sprite
  173.   @@base_color = Color.new(255,255,255)

  174.   def initialize(viewport = nil)
  175.     super(viewport)
  176.     @width = Graphics.width
  177.     @height = Graphics.height
  178.    
  179.     case HN_Light::SIMPLIFY
  180.     when 1
  181.       @zoom = 2
  182.     when 2
  183.       @zoom = 4
  184.     else
  185.       @zoom = 1
  186.     end
  187.     @width /= @zoom
  188.     @height /= @zoom
  189.     self.zoom_x = @zoom.to_f
  190.     self.zoom_y = @zoom.to_f
  191.    
  192.     self.bitmap = Bitmap.new(@width, @height)
  193.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)
  194.     self.blend_type = 2 # 混合型(减算)
  195.     self.z = 500
  196.     self.visible = false
  197.     @light_cache = {}
  198.   end

  199.   # 追加烛光
  200.   def add_light(charactor)
  201.     return if charactor.nil?
  202.     light_type = charactor.light_type
  203.     return if (light_type < 1 or light_type > HN_Light::LIGHTS.size)
  204.     unless @light_cache.key?(light_type)
  205.       @light_cache[light_type] = HN_Light::Light.new(light_type, @zoom)
  206.     end
  207.     light = @light_cache[light_type]

  208.     # 画面外什麽都不做
  209.     if @zoom == 1
  210.       return if (charactor.screen_x < 0  - light.width + light.ox)
  211.       return if (charactor.screen_x > @width + light.ox)
  212.       return if (charactor.screen_y < 0 - light.height + light.oy)
  213.       return if (charactor.screen_y > @height + light.oy)
  214.     else
  215.       return if (charactor.screen_x < 0  - (light.width + light.ox) * @zoom)
  216.       return if (charactor.screen_x > (@width + light.ox)  * @zoom)
  217.       return if (charactor.screen_y < 0 - (light.height + light.oy) * @zoom)
  218.       return if (charactor.screen_y > (@height + light.oy) * @zoom)
  219.     end

  220.     # 动画判定
  221.     if light.cells > 1
  222.       index = (Graphics.frame_count / 4) % light.cells
  223.       rect = Rect.new(index * light.width , 0, light.width, light.height)
  224.     else
  225.       rect = light.bitmap.rect
  226.     end
  227.     if @zoom != 1
  228.       p_x = charactor.screen_x / @zoom - light.ox
  229.       p_y = (charactor.screen_y - 16) / @zoom - light.oy
  230.     else
  231.       p_x = charactor.screen_x - light.ox
  232.       p_y = charactor.screen_y - 16 - light.oy
  233.     end
  234.    
  235.     # 乗算合成(3)
  236.     self.bitmap.blend_blt(p_x, p_y, light.bitmap, rect, 3)
  237.   end

  238.   
  239.   def refresh
  240.     self.bitmap.fill_rect(self.bitmap.rect, @@base_color)
  241.     $game_map.light_events.each do |event|
  242.       next if HN_Light::LIGHTS[event.light_type - 1].nil?
  243.       add_light(event)
  244.     end
  245.     add_light($game_player)
  246.     $game_player.followers.each{|f| add_light(f)}
  247.   end
  248.   
  249.   # 更新
  250.   def update
  251.     super
  252.     refresh()
  253.   end
  254.   
  255.   #--------------------------------------------------------------------------
  256.   # ● 解放
  257.   #--------------------------------------------------------------------------
  258.   def dispose
  259.     self.bitmap.dispose
  260.     @light_cache.values.each do |light|
  261.       light.dispose
  262.     end
  263.     super
  264.   end
  265. end


  266. class Spriteset_Map  
  267.   # 动画判定
  268.   def create_dark
  269.     @dark_sprite = Sprite_Dark.new(@viewport1)
  270.   end

  271.   # 更新黑暗Sprite
  272.   def update_dark
  273.     if (@dark_sprite.visible = $game_switches[HN_Light::DARK_SWITCH])
  274.       @dark_sprite.update
  275.     end
  276.   end

  277.   # 破弃黑暗Sprite
  278.   def dispose_dark
  279.     @dark_sprite.dispose
  280.   end
  281.   
  282.   # 初期化
  283.   alias :_dark__initialize :initialize unless private_method_defined?(:_dark__initialize)
  284.   def initialize
  285.     _dark__initialize()
  286.     create_dark()
  287.     update_dark()
  288.   end
  289.   
  290.   # 更新
  291.   alias :_dark__update :update unless method_defined?(:_dark__update)
  292.   def update
  293.     _dark__update()
  294.     update_dark() if !@dark_sprite.nil? and !@dark_sprite.disposed?
  295.   end
  296.   
  297.   # 结束处理
  298.   alias :_dark__dispose :dispose unless method_defined?(:_dark__dispose)
  299.   def dispose
  300.     dispose_dark()
  301.     _dark__dispose()
  302.   end
  303. end
复制代码
Bitmap+"tktk_bitmap.dll"(ver0.1.2.6以上) 拡張提供以下功能

效果可到覷看
http://www.tktkgame.com/tkool/rgss_common/bitmap_extension.html
- Marshaldump 启用
- 保存为PNG文件
-色调变化
-马赛克效果
-反相颜色
-模糊效果
-使用遮罩-切除
-混合

HN_Ligh脚本提供燭光効果
地図黒暗模式使用了開閉11
主人公黒暗模式on/off用了変量12,可設定0不使用;1〜9不同図形
図形調用用了註釋@LIGHT0~9(和主人公黒暗図形ー様)(中文版)
地図黒暗模式on/off
只要在事件中切換
至於所要用到的図形放到Graphics\Pictures文件夾中

     

Image001.gif (25.37 KB, 下载次数: 0)

Image001.gif

Image002.gif (15.66 KB, 下载次数: 467)

Image002.gif

作者: gz29767562    时间: 2012-3-1 12:45
这个效果不错,但是不能让物品能够增大视野的功能
作者: A66018299    时间: 2012-3-28 22:36
用了沒反應.....
我複製範本的...
改了地點而已...


‘‘──A66018299于2012-3-28 22:49补充以下内容

以上兩個都有
’’
作者: tseyik    时间: 2012-3-29 00:10
本帖最后由 tseyik 于 2012-3-29 00:27 编辑
A66018299 发表于 2012-3-28 22:36
用了沒反應.....
我複製範本的...
改了地點而已...

從没開啓燭光地図(Map001)進入下個地図(Map002)及開啓燭光(後三句)



從開啓燭光地図(Map002)進入下個地図(Map001)及関閉燭光(後三句)


燭光事件的其中一種設定方法(按鍵可開関該図象的燭光)







作者: candy2266    时间: 2012-3-29 00:52
这脚本 真适合在山洞里用
作者: lsu666666    时间: 2012-3-29 01:24
很棒的系統....我最喜歡燈光的了...
作者: A66018299    时间: 2012-3-29 17:17
- -
搞好了....原来是代号错了.....
话说大大这能做扩大范围的视角吗???
道具和火焰的视角


‘‘──A66018299于2012-3-29 20:26补充以下内容

!!!
灰常感謝大大
等我做好我會給你玩的!!
’’
作者: load_ing    时间: 2012-4-10 11:13
非常强力的东西啊,不过就是略显复杂
作者: 1243852    时间: 2012-8-29 23:15
115硬盘关闭了,麻烦楼主发我邮箱或者重新上传吧。谢谢了

[email protected]

作者: 1243852    时间: 2012-8-30 01:52
我直接下载的日站的, 请问,有没有办法把色调稍微调亮一点点? 全黑不好看。
作者: 杰总    时间: 2012-10-14 17:37
本帖最后由 杰总 于 2012-10-14 17:39 编辑

好东西啊!

异界风云.png (74.27 KB, 下载次数: 0)

售价: 6554 星屑  [记录]  [购买]

请54


作者: 孤客    时间: 2012-12-2 01:40
本帖最后由 孤客 于 2012-12-2 01:42 编辑

= =我下载了,,,根本不能用啊。。就算是下载了原文件,打开测试时候老弹出一些英文出错。。只用灯的那个测试也是一样,一进洞就说第97行的invert出错。。无语啊。。
作者: 纲·炎    时间: 2012-12-10 11:19
用不了啊{:2_271:}
作者: 精灵使者    时间: 2012-12-10 16:53
精灵想要XP和VX的……
作者: 城市猎人    时间: 2012-12-10 17:16
还以为人物走在灯光里会有影子~~~
         而影子还会根据灯光的角度变换位置~~~

原来没有想象中的效果啊~~~  
作者: paledream    时间: 2013-1-23 01:33
在第一次启用黑暗模式的时候会有短暂的延迟,就是说会看到亮着的全地图然后再变成主人公烛光,切换地图后延迟消失,但退出游戏再重新进入,触发事件后依旧会出现这样的情况,请问怎么解决?
作者: paledream    时间: 2013-1-23 14:06
我截了GIF,可惜上传不了
作者: 冰动南瓜    时间: 2013-2-24 22:08
这个是怎么回事?我放了图片了。就是灯光的那个

未命名.jpg (14.53 KB, 下载次数: 8)

未命名.jpg

作者: 月迟利道    时间: 2013-3-12 09:51
提示: 作者被禁止或删除 内容自动屏蔽
作者: るるたん    时间: 2013-3-17 13:15
问一个问题,为什么我开启黑暗模式后物品还是不会发光,即使把范例的地图复制到我的游戏里也一样不发光,已经试过不是物品外观选测错误,仔细看了范例里的火炬上也没有加特殊的脚本,怎么回事?
作者: るるたん    时间: 2013-3-17 13:17
就是这个样子,东西完全不发光
作者: 遗忘    时间: 2013-3-27 15:40
本帖最后由 遗忘 于 2013-3-27 16:26 编辑

我只想问一下,怎么扩大主角发光的范围?
——————————

我知道了!
作者: swt4399    时间: 2013-6-26 14:38
vx用不了,HN_Ligh脚本发生NameError

作者: rachelkywong    时间: 2014-5-17 15:26
本帖最后由 rachelkywong 于 2014-5-17 15:27 编辑

脚本Bitmap82行: 發生RuntimeError
LoadLibrary:tktk_bitmap

P.S. tktk_bitmap.dll已放
作者: konechaos    时间: 2015-1-26 00:21
下了感觉很棒~我也想知道怎么放大发光范围 想做夜景的效果
作者: 超音速    时间: 2015-1-26 16:39
konechaos 发表于 2015-1-26 00:21
下了感觉很棒~我也想知道怎么放大发光范围 想做夜景的效果

把图片改一改
作者: 超音速    时间: 2015-1-26 16:40
https://rpg.blue/forum.php?mod=v ... p;page=2#pid2579564
https://rpg.blue/thread-375513-1-1.html
作者: tseyik    时间: 2015-1-26 17:27
本帖最后由 tseyik 于 2015-1-26 17:32 编辑
konechaos 发表于 2015-1-26 00:21
下了感觉很棒~我也想知道怎么放大发光范围 想做夜景的效果


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],
  ]
例:


用這裏設定发光范围
祥細可到這裏看看
http://forum.gamer.com.tw/C.php? ... A=22703&tnum=21
作者: tseyik    时间: 2015-1-26 17:35
rachelkywong 发表于 2014-5-17 15:26
脚本Bitmap82行: 發生RuntimeError
LoadLibrary:tktk_bitmap


作者: ttt55    时间: 2017-11-4 20:43
什么叫“对变数的操作”?
作者: 无端忆君    时间: 2017-11-24 09:33
可惜只有日文的了
作者: 耳可亦虫    时间: 2017-12-21 23:09
请问,使用这个脚本,黑暗程度可以在中途更改吗?
比如说在这个房间里面黑暗程度需要(225,225,225),
但去下一个房间要把黑暗程度改为(160,160,160)
请问这样可以实现吗?如果可以,用什么办法呢?
非常感谢!!!
作者: zhangc    时间: 2018-8-6 19:08
耳可亦虫 发表于 2017-12-21 23:09
请问,使用这个脚本,黑暗程度可以在中途更改吗?
比如说在这个房间里面黑暗程度需要(225,225,225),
但 ...

我自己照着XP版的修改了一下,可以根据变量来修改黑暗程度,把想下面的脚本,替换原来的就行了
脚本:

=begin
  HN_Light version 1.0.1.0 for VX Ace
        by 半生
http://www.tktkgame.com

  要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

  
  # 表示黑暗处的不透明度的变量号码
  # 变量的数值为0-255,越大则不可见度越高
  DARK_OPACITY_VAR = 11
  
  
  # 队友的烛光类型使用的变量号码
  FOLLOWER_LIGHT_TYPE = 12
  
  # 黑暗判断上使用的开
  DARK_SWITCH = 11
  
  # 烛光事件识别用的正规表达式
  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
    @@base_color = Color.new(255,255,255,$game_variables[HN_Light::DARK_OPACITY_VAR])
    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
作者: qgxlm    时间: 2018-11-9 20:52
不知道内存会不会增大
作者: Uirel    时间: 2020-10-29 10:56
呜呜,大大,下载的案例链接都挂了,求一个补档
作者: 老白窗晗    时间: 2021-1-6 13:00
Uirel 发表于 2020-10-29 10:56
呜呜,大大,下载的案例链接都挂了,求一个补档


这里有可以下载的范例
https://rpg.blue/thread-378534-1-1.html
作者: ttt666    时间: 2021-11-8 11:42
楼主,繁体范例能补个度盘吗?
作者: 帕克lit    时间: 2022-7-30 11:03
脚本"Bitmap" 第50行:发生RuntimeError。LoadLibrary: tktk bitmap怎么解决




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1