Project1
标题: 烛光脚本能用的有吗。。。? [打印本页]
作者: 664299301 时间: 2013-9-1 13:17
标题: 烛光脚本能用的有吗。。。?
本帖最后由 664299301 于 2013-9-1 18:49 编辑
为了找到合适的烛光脚本,我试了一个有一个烛光脚本,最后都是以失败结尾。。。
哪位大神级别的人能帮小弟弄个烛光脚本呢
感激不尽
作者: 余烬之中 时间: 2013-9-1 14:12
本帖最后由 余烬之中 于 2014-4-5 18:47 编辑
把这个放在游戏文件夹\Lib下(不是Graphics)
tktk_bitmap.rar
(81.98 KB, 下载次数: 272)
操作方法脚本内都有
三段脚本分开插入
=begin
HN_Light脚本提供烛光效果
地图黒暗模式使用了开关11
主人公黒暗模式on/off用了变量12,可设定0不使用;1〜9不同图形
图形调用用了注释@LIGHT0~9(和主人公黑暗图形一样)(中文版)
地图黑暗模式on/off只要在事件中切换
至于所要用到的图形放到Graphics\Pictures文件夹中
=end
#2013.8.27
#影进行微调
#——————————————————————————
#上述中的@ 必须为全角 不能是半角@
#——————————————————————————
#需要的Dll放在Lib文件夹下
=begin
HN_Light脚本提供烛光效果
地图黒暗模式使用了开关11
主人公黒暗模式on/off用了变量12,可设定0不使用;1〜9不同图形
图形调用用了注释@LIGHT0~9(和主人公黑暗图形一样)(中文版)
地图黑暗模式on/off只要在事件中切换
至于所要用到的图形放到Graphics\Pictures文件夹中
=end
#2013.8.27
#影进行微调
#——————————————————————————
#上述中的@ 必须为全角 不能是半角@
#——————————————————————————
#需要的Dll放在Lib文件夹下
# coding: utf-8
=begin
= Bitmap类拡张 (DLL版)
RPGツクールXP/VX/VA共用
添加功能 Bitmap 类。
-Marshaldump 启用
-保存为PNG文件
-色调变化
-马赛克效果
-反相颜色
-模糊效果
-使用遮罩-切除
-混合
■ 注意
这个脚本需要"tktk_bitmap.dll"(ver0.1.2.6以上)。
Author:: 半生
Date:: 2010/12/13
Version:: 0.1.2.6
URL:: [url]http://www.tktkgame.com/[/url]
################更新########################
2010/12/13 ver 0.1.2.6
dll名称从"hn_rg_bitmap.dll"变更为"tktk_bitmap.dll"
LARGE_BITMAP机能でメモリを确保できなかった场合の処理を追加
2010/10/12 ver 0.1.2.5(デンジャラスベータ版)
大きいサイズのBitmapオブジェクトを机能を试験的に実装(危険)
2010/03/24 ver 0.1.2.2
ブレンディング机能関连の軽量化。
画像连结系メソッドの分离。
2010/03/24 ver 0.1.2.1
ブレンディング机能関连のバグフィックス
2010/03/22 ver 0.1.2.0
加算合成等のブレンディング机能の追加
2010/02/07 ver 0.1.1.0
マーシャル化の処理の一部をDLLに移动
2010/01/17 ver 0.1.0.0
dllの名称を"hn_rx_bitmap.dll"から"hn_rg_bitmap.dll"に変更
モザイク効果・色反転・ぼかし効果の追加
############################################
=end
module TKTK_Bitmap
LARGE_BITMAP = true # 是否使用大型点阵图的功能
DLL_NAME = 'Lib\tktk_bitmap'
ERROR_ALLOCATE_FAILED = -110002
@@png_save = Win32API.new(DLL_NAME, 'PngSaveA', 'p n i i', 'i')
@@blur = Win32API.new(DLL_NAME, 'Blur', 'n i', 'i')
@@change_tone = Win32API.new(DLL_NAME, 'ChangeTone', 'n i i i i', 'i')
@@clip_mask = Win32API.new(DLL_NAME, 'ClipMask', 'n n i i i', 'i')
@@invert = Win32API.new(DLL_NAME, 'InvertColor', 'n', 'i')
@@mosaic = Win32API.new(DLL_NAME, 'Mosaic', 'n i i i i i i', 'i')
@@address = Win32API.new(DLL_NAME, 'GetAddress', 'n', 'n')
@@get_pixel_data = Win32API.new(DLL_NAME, 'GetPixelData', 'n p i', 'i')
@@set_pixel_data = Win32API.new(DLL_NAME, 'SetPixelData', 'n p i', 'i')
@@blend_blt = Win32API.new(DLL_NAME, 'BlendBlt', 'n i i n i i i i i i', 'i')
#@@get_hwnd = Win32API.new(DLL_NAME, 'GetGameHWND', 'v', 'l')
@@change_size = Win32API.new(DLL_NAME, 'ChangeSize', 'n i i', 'i')
module_function
# PNG形式储存
def png_save(bitmap,file_name,compression_level,filter)
return @@png_save.call(file_name, bitmap.object_id, compression_level, filter)
end
# 模糊效果
def blur(bitmap, r = 1)
return @@blur.call(bitmap.object_id, r)
end
# 更改颜色平衡?
def change_tone(bitmap, red = 0, green = 0, blue = 0, simplify = 1)
return @@change_tone.call(bitmap.object_id, red, green, blue, simplify)
end
# 剪贴蒙版图像(α乘法)
def clip_mask(g_bitmap, m_bitmap, x=0, y=0, outer=0)
return @@clip_mask.call(g_bitmap.object_id, m_bitmap.object_id, x, y, outer)
end
# 色的反转
def invert(bitmap)
return @@invert.call(bitmap.object_id)
end
# 马赛克效果
def mosaic(bitmap, msw=5, msh=5)
return self.mosaic_rect(bitmap, bitmap.rect, msw, msh)
end
# 马赛克效果(范围指定)
def mosaic_rect(bitmap, rect, msw=5, msh=5)
return @@mosaic.call(bitmap.object_id,
rect.x, rect.y, rect.width, rect.height, msw, msh)
end
# 获取Bitmap资料位址
def address(bitmap)
return @@address.call(bitmap.object_id)
end
# 二进位资料获取点Bitmap阵图
def get_pixel_data(bitmap)
buffer = "bgra" * bitmap.width * bitmap.height
@@get_pixel_data.call(bitmap.object_id, buffer, buffer.size)
return buffer
end
#替换为Bitmap中的二进位资料
def set_pixel_data(bitmap, data)
return @@set_pixel_data.call(bitmap.object_id, data, data.size)
end
def blend_blt(dest_bmp, x, y, src_bmp, rect, blend_type=0, opacity=255)
@@blend_blt.call(dest_bmp.object_id, x, y, src_bmp.object_id,
rect.x, rect.y, rect.width, rect.height,
blend_type, opacity)
end
# 改变Bitmap的大小(风险)
def change_size(bitmap, new_width, new_height)
return -1 if (new_width <=0 or new_height <= 0)
result = @@change_size.call(bitmap.object_id, new_width, new_height)
if result == ERROR_ALLOCATE_FAILED
raise("tktk_bitmap:ERROR ALLOCATE FAILED")
end
return result
end
end
class Font
def marshal_dump;end
def marshal_load(obj);end
end
class Bitmap
# PNG 压缩筛检程式
PNG_NO_FILTERS = 0x00
PNG_FILTER_NONE = 0x08
PNG_FILTER_SUB = 0x10
PNG_FILTER_UP = 0x20
PNG_FILTER_AVG = 0x40
PNG_FILTER_PAETH = 0x80
PNG_ALL_FILTERS = (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP |
PNG_FILTER_AVG | PNG_FILTER_PAETH)
# Marshal_dump
def _dump(limit)
return "" if self.disposed?
data = TKTK_Bitmap.get_pixel_data(self)
[width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # ついでに圧缩
end
# Marshal_load
def self._load(str)
if str == ""
b = Bitmap.new(1,1)
b.dispose
return b
end
w, h, zdata = str.unpack("LLa*"); b = new(w, h)
TKTK_Bitmap.set_pixel_data(b, Zlib::Inflate.inflate(zdata))
return b
end
def address
TKTK_Bitmap.address(self)
end
# 模糊效果
def blur2(r=1)
TKTK_Bitmap.blur(self, r)
end
# 色调变化
def change_tone(red, green, blue, simplify = 1)
TKTK_Bitmap.change_tone(self, red, green, blue, simplify)
end
# 剪切
def clip_mask(bitmap, x=0, y=0, outer=0)
TKTK_Bitmap.clip_mask(self, bitmap, x, y, outer)
end
# 反相颜色
def invert
TKTK_Bitmap.invert(self)
end
# 马赛克效果
def mosaic(msw=5, msh=5)
TKTK_Bitmap.mosaic(self, msw, msh)
end
# 马赛克效果 (指定区域)
def mosaic_rect(rect=self.rect, msw=5, msh=5)
TKTK_Bitmap.mosaic_rect(self, rect, msw, msh)
end
# 混合
def blend_blt(x, y, src_bmp, rect, blend_type=0, opacity=255)
return if opacity <= 0
TKTK_Bitmap.blend_blt(self, x, y, src_bmp, rect, blend_type, opacity)
end
# Png 格式保存
def png_save(outp, level = 9, filter = PNG_NO_FILTERS)
if (TKTK_Bitmap.png_save(self, outp, level, filter) != 0)
raise("Bitmap\#png_save failed")
end
end
# 允许更大的 bitmap.new (危険)
# 宽度 * 高度大约是1073741823
if TKTK_Bitmap::LARGE_BITMAP
class << self
unless method_defined?(:_hn_large_bm__new)
alias :_hn_large_bm__new :new
end
def new(*args)
if args.size == 2 && args[0] * args[1] >= 4194304
new_width = args[0]
new_height = args[1]
# 暂时以小尺寸作成
bitmap = _hn_large_bm__new(16, 16)
TKTK_Bitmap.change_size(bitmap, new_width, new_height)
return bitmap
else
_hn_large_bm__new(*args)
end
end
end # Bitmap.new
end
end # CLASS Bitmap
# coding: utf-8
=begin
= Bitmap类拡张 (DLL版)
RPGツクールXP/VX/VA共用
添加功能 Bitmap 类。
-Marshaldump 启用
-保存为PNG文件
-色调变化
-马赛克效果
-反相颜色
-模糊效果
-使用遮罩-切除
-混合
■ 注意
这个脚本需要"tktk_bitmap.dll"(ver0.1.2.6以上)。
Author:: 半生
Date:: 2010/12/13
Version:: 0.1.2.6
URL:: [url]http://www.tktkgame.com/[/url]
################更新########################
2010/12/13 ver 0.1.2.6
dll名称从"hn_rg_bitmap.dll"变更为"tktk_bitmap.dll"
LARGE_BITMAP机能でメモリを确保できなかった场合の処理を追加
2010/10/12 ver 0.1.2.5(デンジャラスベータ版)
大きいサイズのBitmapオブジェクトを机能を试験的に実装(危険)
2010/03/24 ver 0.1.2.2
ブレンディング机能関连の軽量化。
画像连结系メソッドの分离。
2010/03/24 ver 0.1.2.1
ブレンディング机能関连のバグフィックス
2010/03/22 ver 0.1.2.0
加算合成等のブレンディング机能の追加
2010/02/07 ver 0.1.1.0
マーシャル化の処理の一部をDLLに移动
2010/01/17 ver 0.1.0.0
dllの名称を"hn_rx_bitmap.dll"から"hn_rg_bitmap.dll"に変更
モザイク効果・色反転・ぼかし効果の追加
############################################
=end
module TKTK_Bitmap
LARGE_BITMAP = true # 是否使用大型点阵图的功能
DLL_NAME = 'Lib\tktk_bitmap'
ERROR_ALLOCATE_FAILED = -110002
@@png_save = Win32API.new(DLL_NAME, 'PngSaveA', 'p n i i', 'i')
@@blur = Win32API.new(DLL_NAME, 'Blur', 'n i', 'i')
@@change_tone = Win32API.new(DLL_NAME, 'ChangeTone', 'n i i i i', 'i')
@@clip_mask = Win32API.new(DLL_NAME, 'ClipMask', 'n n i i i', 'i')
@@invert = Win32API.new(DLL_NAME, 'InvertColor', 'n', 'i')
@@mosaic = Win32API.new(DLL_NAME, 'Mosaic', 'n i i i i i i', 'i')
@@address = Win32API.new(DLL_NAME, 'GetAddress', 'n', 'n')
@@get_pixel_data = Win32API.new(DLL_NAME, 'GetPixelData', 'n p i', 'i')
@@set_pixel_data = Win32API.new(DLL_NAME, 'SetPixelData', 'n p i', 'i')
@@blend_blt = Win32API.new(DLL_NAME, 'BlendBlt', 'n i i n i i i i i i', 'i')
#@@get_hwnd = Win32API.new(DLL_NAME, 'GetGameHWND', 'v', 'l')
@@change_size = Win32API.new(DLL_NAME, 'ChangeSize', 'n i i', 'i')
module_function
# PNG形式储存
def png_save(bitmap,file_name,compression_level,filter)
return @@png_save.call(file_name, bitmap.object_id, compression_level, filter)
end
# 模糊效果
def blur(bitmap, r = 1)
return @@blur.call(bitmap.object_id, r)
end
# 更改颜色平衡?
def change_tone(bitmap, red = 0, green = 0, blue = 0, simplify = 1)
return @@change_tone.call(bitmap.object_id, red, green, blue, simplify)
end
# 剪贴蒙版图像(α乘法)
def clip_mask(g_bitmap, m_bitmap, x=0, y=0, outer=0)
return @@clip_mask.call(g_bitmap.object_id, m_bitmap.object_id, x, y, outer)
end
# 色的反转
def invert(bitmap)
return @@invert.call(bitmap.object_id)
end
# 马赛克效果
def mosaic(bitmap, msw=5, msh=5)
return self.mosaic_rect(bitmap, bitmap.rect, msw, msh)
end
# 马赛克效果(范围指定)
def mosaic_rect(bitmap, rect, msw=5, msh=5)
return @@mosaic.call(bitmap.object_id,
rect.x, rect.y, rect.width, rect.height, msw, msh)
end
# 获取Bitmap资料位址
def address(bitmap)
return @@address.call(bitmap.object_id)
end
# 二进位资料获取点Bitmap阵图
def get_pixel_data(bitmap)
buffer = "bgra" * bitmap.width * bitmap.height
@@get_pixel_data.call(bitmap.object_id, buffer, buffer.size)
return buffer
end
#替换为Bitmap中的二进位资料
def set_pixel_data(bitmap, data)
return @@set_pixel_data.call(bitmap.object_id, data, data.size)
end
def blend_blt(dest_bmp, x, y, src_bmp, rect, blend_type=0, opacity=255)
@@blend_blt.call(dest_bmp.object_id, x, y, src_bmp.object_id,
rect.x, rect.y, rect.width, rect.height,
blend_type, opacity)
end
# 改变Bitmap的大小(风险)
def change_size(bitmap, new_width, new_height)
return -1 if (new_width <=0 or new_height <= 0)
result = @@change_size.call(bitmap.object_id, new_width, new_height)
if result == ERROR_ALLOCATE_FAILED
raise("tktk_bitmap:ERROR ALLOCATE FAILED")
end
return result
end
end
class Font
def marshal_dump;end
def marshal_load(obj);end
end
class Bitmap
# PNG 压缩筛检程式
PNG_NO_FILTERS = 0x00
PNG_FILTER_NONE = 0x08
PNG_FILTER_SUB = 0x10
PNG_FILTER_UP = 0x20
PNG_FILTER_AVG = 0x40
PNG_FILTER_PAETH = 0x80
PNG_ALL_FILTERS = (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP |
PNG_FILTER_AVG | PNG_FILTER_PAETH)
# Marshal_dump
def _dump(limit)
return "" if self.disposed?
data = TKTK_Bitmap.get_pixel_data(self)
[width, height, Zlib::Deflate.deflate(data)].pack("LLa*") # ついでに圧缩
end
# Marshal_load
def self._load(str)
if str == ""
b = Bitmap.new(1,1)
b.dispose
return b
end
w, h, zdata = str.unpack("LLa*"); b = new(w, h)
TKTK_Bitmap.set_pixel_data(b, Zlib::Inflate.inflate(zdata))
return b
end
def address
TKTK_Bitmap.address(self)
end
# 模糊效果
def blur2(r=1)
TKTK_Bitmap.blur(self, r)
end
# 色调变化
def change_tone(red, green, blue, simplify = 1)
TKTK_Bitmap.change_tone(self, red, green, blue, simplify)
end
# 剪切
def clip_mask(bitmap, x=0, y=0, outer=0)
TKTK_Bitmap.clip_mask(self, bitmap, x, y, outer)
end
# 反相颜色
def invert
TKTK_Bitmap.invert(self)
end
# 马赛克效果
def mosaic(msw=5, msh=5)
TKTK_Bitmap.mosaic(self, msw, msh)
end
# 马赛克效果 (指定区域)
def mosaic_rect(rect=self.rect, msw=5, msh=5)
TKTK_Bitmap.mosaic_rect(self, rect, msw, msh)
end
# 混合
def blend_blt(x, y, src_bmp, rect, blend_type=0, opacity=255)
return if opacity <= 0
TKTK_Bitmap.blend_blt(self, x, y, src_bmp, rect, blend_type, opacity)
end
# Png 格式保存
def png_save(outp, level = 9, filter = PNG_NO_FILTERS)
if (TKTK_Bitmap.png_save(self, outp, level, filter) != 0)
raise("Bitmap\#png_save failed")
end
end
# 允许更大的 bitmap.new (危険)
# 宽度 * 高度大约是1073741823
if TKTK_Bitmap::LARGE_BITMAP
class << self
unless method_defined?(:_hn_large_bm__new)
alias :_hn_large_bm__new :new
end
def new(*args)
if args.size == 2 && args[0] * args[1] >= 4194304
new_width = args[0]
new_height = args[1]
# 暂时以小尺寸作成
bitmap = _hn_large_bm__new(16, 16)
TKTK_Bitmap.change_size(bitmap, new_width, new_height)
return bitmap
else
_hn_large_bm__new(*args)
end
end
end # Bitmap.new
end
end # CLASS Bitmap
=begin
HN_Light version 1.0.1.0 for VX Ace
by 半生
[url]http://www.tktkgame.com[/url]
要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 = 11
# 烛光事件识别用的正规表达式
REGEX_LIGHT = /@Light(\d+)/
# 烛光图像的目录
LIGHT_IMG_DIR = "Graphics/Pictures/"
# 烛光Bitmap设定
LIGHTS = [
# [FILENAME, CELLS, ZOOM, OFFSET_Y, HUE]
["light1", 1, 1.5, 0, 0],
["light2", 1, 1.5, 0, 0],
["light3", 1, 1.5, 0, 0],
["light4", 1, 1.5, -16, 0],
["light5", 1, 3.0, 0, 0],
["light6", 1, 3.0, 0, 0],
["light7", 1, 3.0, -16, 0],
["light1", 1, 1.0, 0, 0],
["light1", 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
[url=home.php?mod=space&uid=98379]@zoom[/url] = 1.0
@oy = 16
@ox = 16
@width = 32
[url=home.php?mod=space&uid=291977]@height[/url] = 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)
[url=home.php?mod=space&uid=98379]@zoom[/url] = light[2].to_f
@zoom = 1.0 if @zoom <= 0.0
@zoom /= s_zoom
@width = @bitmap.width / @cells
[url=home.php?mod=space&uid=291977]@height[/url] = @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
=begin
HN_Light version 1.0.1.0 for VX Ace
by 半生
[url]http://www.tktkgame.com[/url]
要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 = 11
# 烛光事件识别用的正规表达式
REGEX_LIGHT = /@Light(\d+)/
# 烛光图像的目录
LIGHT_IMG_DIR = "Graphics/Pictures/"
# 烛光Bitmap设定
LIGHTS = [
# [FILENAME, CELLS, ZOOM, OFFSET_Y, HUE]
["light1", 1, 1.5, 0, 0],
["light2", 1, 1.5, 0, 0],
["light3", 1, 1.5, 0, 0],
["light4", 1, 1.5, -16, 0],
["light5", 1, 3.0, 0, 0],
["light6", 1, 3.0, 0, 0],
["light7", 1, 3.0, -16, 0],
["light1", 1, 1.0, 0, 0],
["light1", 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
[url=home.php?mod=space&uid=98379]@zoom[/url] = 1.0
@oy = 16
@ox = 16
@width = 32
[url=home.php?mod=space&uid=291977]@height[/url] = 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)
[url=home.php?mod=space&uid=98379]@zoom[/url] = light[2].to_f
@zoom = 1.0 if @zoom <= 0.0
@zoom /= s_zoom
@width = @bitmap.width / @cells
[url=home.php?mod=space&uid=291977]@height[/url] = @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
作者: 664299301 时间: 2013-9-1 14:45
余烬之中 发表于 2013-9-1 14:12
把这个放在游戏文件夹\Lib下(不是Graphics)
操作方法脚本内都有
好吧,出错了,怎么修改?
作者: 余烬之中 时间: 2013-9-1 15:17
664299301 发表于 2013-9-1 14:45
好吧,出错了,怎么修改?
没想到真的碰到了这种情况……
把
[url=home.php?.......98379]
以及与此类似的所有[url=......]都找出来 删掉
注意不要误删
貌似是论坛的原因
作者: 余烬之中 时间: 2013-9-1 15:18
664299301 发表于 2013-9-1 14:45
好吧,出错了,怎么修改?
算了,我直接给你这一部分,稍微注意一下:- if light.nil?
- # 本来不应该来这里
- @bitmap = Bitmap.new(32, 32)
- @cels = 1
- [url=home.php?mod=space&uid=98379]@zoom[/url] = 1.0
- @oy = 16
- @ox = 16
- @width = 32
- [url=home.php?mod=space&uid=291977]@height[/url] = 32
- else
- @bitmap = Bitmap.new(LIGHT_IMG_DIR + light[0])
- @bitmap.invert()
复制代码
作者: 664299301 时间: 2013-9-1 16:01
是改成这样吗。。?
然后又出错了。。
有简单点的方法吗
作者: 余烬之中 时间: 2013-9-1 16:14
本帖最后由 余烬之中 于 2014-4-5 18:49 编辑
664299301 发表于 2013-9-1 16:01
是改成这样吗。。?
然后又出错了。。
有简单点的方法吗
我直接发txt吧……
找度娘分享已被取消
注意 HN_Light 放在 HN_RG_Bitmap 下面
作者: 余烬之中 时间: 2013-9-1 16:18
本帖最后由 余烬之中 于 2014-4-5 18:48 编辑
本来有两个图片 但是百度…………
作者: 664299301 时间: 2013-9-1 16:53
为什么事件依旧不发光呢。。。?
作者: 余烬之中 时间: 2013-9-1 17:32
本帖最后由 余烬之中 于 2014-4-5 18:49 编辑
这样吧,我给你范例,有句话忘了拿出来说= =!
需要在把范例内Graphics下的Picture文件夹复制过去
度娘分享已被取消
发完贴去学校 这个范例我测试过可行的
作者: 664299301 时间: 2013-9-1 18:48
余烬之中 发表于 2013-9-1 17:32
这样吧,我给你范例,有句话忘了拿出来说= =!
需要在把范例内Graphics下的Picture文件夹复制过去
度娘
太谢谢了,感激不尽啊。。。
欢迎光临 Project1 (https://rpg.blue/) |
Powered by Discuz! X3.1 |