赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1774 |
最后登录 | 2014-5-1 |
在线时间 | 28 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 28 小时
- 注册时间
- 2013-2-3
- 帖子
- 21
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
我的是rpgvx的……听说这脚本是VA的,怎么改啊?
#------------------------------------------------------------------------------#
# Name: Auto/Event-Light Reborn #
# By: SojaBird #
# Version: Reborn 4.1 #
# #
# Date: 30-08-09 #
#------------------------------------------------------------------------------#
$imported = {} if $imported == nil
$imported["SojaBird_AutoLight"] = true
#------------------------------------------------------------------------------#
# Call Script #
#------------------------------------------------------------------------------#
# - AL.mode(val) # #
# - AL.light(parm, val) # parm: name, opacity, blend, visible #
# - AL.shadow(parm, val) # parm: name, opacity, blend, visible #
# - AL.spot(parm, val) # parm: name, opacity, blend, visible #
# - AL.flicker(parm, val) # parm: opacity, width, height, x, y #
# # #
# - EL.bitmap(val, index = nil) # #
# - EL.color(val, index = nil) # #
# - EL.opacity(val, index = nil) # #
# - EL.blend(val, index = nil) # #
# - EL.visible(val, index = nil) # #
# - EL.zoom(val, index = nil) # #
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
# How to use #
#------------------------------------------------------------------------------#
# *AutoLight #
# MODE 0/2 #
# To use autolights, put a light- and/or shadow-map picture in the #
# folder ../Graphics/Pictures/ #
# Name to picture correct! Start with the, by you set, light- and/or #
# shadow-map name, followed by the corresponding map-ID. #
# Put the AutoLight mode to 0 or 2 to show light- and/or shadow-maps. #
# #
# MODE 1/2 #
# To use the spot, put your spotpicture in the folder ../Graphics/Pictures/ #
# and set the name correct! #
# Put the AutoLight mode to 1 or 2 to show the spot. #
# #
# #
# *EventLight #
# To make a event cast a light, give it a comment with the following code: #
# cast(*picture, *color, *opacity, *blend_type, *zoom) #
# All the parameters are optional. Default they are set to: #
# picture: Default, set in the module #
# color: White #
# opacity: 255 #
# blend_type: 1 #
# zoom: 100 #
# For the color you can choose: #
# - white #
# - red #
# - green #
# - blue #
# - yellow #
# - orange #
# - purple #
# - random (one of above, but not the same as it is at the moment (if set)) #
# #
#------------------------------------------------------------------------------#
#--------------------------#
# Customization AutoLights #
#--------------------------#
module AL
#0 = Light and/or Shadow
#1 = Spot
#2 = Both
Mode = 0
module Light
Name = "Light"
Opacity = 150
Blend = 1
Visible = true
end
module Shadow
Name = "Shadow"
Opacity = 150
Blend = 2
Visible = true
end
module Spot
Name = "Spot"
Opacity = 255
Blend = 2
Visible = true
module Flicker
Opacity = 2 #Random opacity change
Width = 2 #Random horizontal zoom
Height = 2 #Random vertical zoom
X = 2 #Random horizontal movement
Y = 2 #Random vertical movement
end
end
end
#---------------------------#
# Customization EventLights #
#---------------------------#
module EL
Default = "EventLight"
module Flicker
Opacity = 2 #Random opacity change
Width = 2 #Random horizontal zoom
Height = 2 #Random vertical zoom
X = 2 #Random horizontal movement
Y = 2 #Random vertical movement
end
end
#\####/\####/\####/\####/\##------------------------##/\####/\####/\####/\####/#
##\##/##\##/##\##/##\##/##\# DON'T CROSS THIS LINE! #/##\##/##\##/##\##/##\##/##
###\/####\/####\/####\/####\------------------------/####\/####\/####\/####\/###
#---------------------------#
# Script playerlight engine #
#---------------------------#
class AutoLight
include AL
def initialize
@map_id = $game_map.map_id
@light_exist = check_existence("#{Light::Name}#{@map_id}")
@shadow_exist = check_existence("#{Shadow::Name}#{@map_id}")
@spot_exist = check_existence("#{Spot::Name}")
create_lights
end
def check_existence(file)
format_list = [".png", ".jpeg", ".jpg"]
format_list.each do |format|
return true if FileTest.exist?("Graphics/Pictures/#{file}#{format}")
end
return false
end
def create_lights
@viewport = Viewport.new(0, 0, 544, 416)
case Mode
when 0
draw_light
draw_shadow
when 1
draw_spot
when 2
draw_light
draw_shadow
draw_spot
end
update
end
def draw_light
return if !@light_exist
@light = Sprite.new(@viewport)
@light.bitmap = Cache.picture("#{Light::Name}#{@map_id}")
@light.z = 9998
@light.opacity = Light::Opacity
@light.blend_type = Light::Blend
@light.visible = Light::Visible
end
def draw_shadow
return if !@shadow_exist
@Shadow = Sprite.new(@viewport)
@shadow.bitmap = Cache.picture("#{Shadow::Name}#{@map_id}")
@shadow.z = 9997
@shadow.opacity = Shadow::Opacity
@shadow.blend_type = Shadow::Blend
@shadow.visible = Shadow::Visible
end
def draw_spot
return if !@spot_exist
@spot = Sprite.new(@viewport)
@spot.bitmap = Cache.picture("#{Spot::Name}")
@spot.z = 9999
@spot.opacity = Spot::Opacity
@spot.blend_type = Spot::Blend
@spot.visible = Spot::Visible
end
def update
@map_x = $game_map.display_x / 8
@map_y = $game_map.display_y / 8
@player_x = $game_player.real_x / 8
@player_y = $game_player.real_y / 8
case Mode
when 0
update_light
update_shadow
when 1
update_spot
when 2
update_light
update_shadow
update_spot
end
end
def update_light
return if !(@light_exist and [email protected]?)
@light.visible = Light::Visible
return if !(@light.x == 0 or
@light.y == 0 or
@light.x != @map_x / 256 or
@light.y != @map_y / 256)
@light.x = -@map_x
@light.y = -@map_y
end
def update_shadow
return if !(@shadow_exist and [email protected]?)
@shadow.visible = Shadow::Visible
return if !(@shadow.x == 0 or
@shadow.y == 0 or
@shadow.x != @map_x / 256 or
@shadow.y != @map_y / 256)
@shadow.x = -@map_x
@shadow.y = -@map_y
end
def update_spot
return if !(@spot_exist and [email protected]?)
@spot.visible = Spot::Visible
@spot.opacity = Spot::Opacity + rand(Spot::Flicker::Opacity) -
rand(Spot::Flicker::Opacity)
@spot.zoom_x = 1 + (rand(Spot::Flicker::Width) / 100.0) -
(rand(Spot::Flicker::Width) / 100.0)
@spot.x = @player_x - @map_x - (@spot.width / 2) + 16 +
rand(Spot::Flicker::X) - rand(Spot::Flicker::X)
@spot.zoom_y = 1 + (rand(Spot::Flicker::Height) / 100.0) -
(rand(Spot::Flicker::Height) / 100.0)
@spot.y = @player_y - @map_y - (@spot.height / 2) + 16 +
rand(Spot::Flicker::Y) - rand(Spot::Flicker::Y)
end
def dispose
case Mode
when 0
dispose_light
dispose_shadow
when 1
dispose_spot
when 2
dispose_light
dispose_shadow
dispose_spot
end
@viewport.dispose
end
def dispose_light
return if !(@light_exist and [email protected]?)
@light.dispose
end
def dispose_shadow
return if !(@shadow_exist and [email protected]?)
@shadow.dispose
end
def dispose_spot
return if !(@spot_exist and [email protected]?)
@spot.dispose
end
end
#--------------------------#
# Script eventlight engine #
#--------------------------#
class EventLight
attr_reader :event_lights
def initialize
create_autolights
end
def create_autolights
@event_lights = {}
$game_map.events.values.each do |event|
next if event.list == nil
event.list.each do |list|
if (list.code == 108 or list.code == 408) and
list.parameters[0].include?("cast")
data = eval(list.parameters[0])
el = Event_LightHolder.new(event, data)
settings(el, data)
@event_lights[event.id] = el
update
end
end
end
end
def cast(pic = EL::Default,
color = "white",
opacity = 255,
blend_type = 1,
zoom = 100,
range = 0)
return [pic, color, opacity, blend_type, zoom, range]
end
def settings(event_light, data)
event_light.el.tone = pick_color(data[1])
event_light.el.opacity = data[2]
event_light.el.blend_type = data[3]
event_light.el.zoom_x = event_light.el.zoom_y = data[4] / 100.0
end
def dispose
@event_lights.each_value do |light|
light.el.dispose
end
@event_lights.clear
end
def update
@event_lights.each_value do |light|
light.el.opacity = light.el.opacity + rand(EL::Flicker::Opacity) -
rand(EL::Flicker::Opacity)
x_zoom = light.el.zoom_x
y_zoom = light.el.zoom_y
light.el.zoom_x = x_zoom + (rand(EL::Flicker::Width) / 100.0) -
(rand(EL::Flicker::Width) / 100.0)
light.el.zoom_y = y_zoom + (rand(EL::Flicker::Height) / 100.0) -
(rand(EL::Flicker::Height) / 100.0)
light.el.x = (light.event.real_x - $game_map.display_x) / 8 -
((light.el.width * x_zoom) / 2) + 16 +
rand(EL::Flicker::X) - rand(EL::Flicker::X)
light.el.y = (light.event.real_y - $game_map.display_y) / 8 -
((light.el.height * y_zoom) / 2) + 16 +
rand(EL::Flicker::Y) - rand(EL::Flicker::Y)
end
end
end
#-----------------#
# Event lightdata #
#-----------------#
class Event_LightHolder
attr_reader :event
attr_accessor :el
attr_accessor :range
def initialize(event, data)
@event = event
@el = Sprite.new
@el.visible = true
settings(data)
end
def settings(data)
@el.bitmap = Cache.picture(data[0])
@el.tone = pick_color(data[1])
@el.opacity = data[2]
@el.blend_type = data[3]
@el.zoom_x = @el.zoom_y = data[4]
@range = data[5]
end
end
#--------------#
# Color picker #
#--------------#
def pick_color(color, old_value = Tone.new(0, 0, 0, 0))
@color = color
colors = {"white" => Tone.new(255, 255, 255, 255),
"red" => Tone.new(255, -255, -255, 255),
"green" => Tone.new(-255, 255, -255, 255),
"blue" => Tone.new(-255, -255, 255, 255),
"yellow" => Tone.new(255, 255, -255, 255),
"orange" => Tone.new(255, -128, -255, 255),
"purple" => Tone.new(255, -255, 255, 255)
}
if @color == "random"
@color = colors.keys[rand(colors.size)]
until colors[@color] != old_value
@color = colors.keys[rand(colors.size)]
end
end
return colors[@color]
end
#----------------#
# On map display #
#----------------#
class Scene_Map < Scene_Base
alias autolight_start start
alias autolight_terminate terminate
alias autolight_update update
alias autolight_fadein fadein
def start
autolight_start
light_start
end
def light_start
$AutoLight = AutoLight.new
$EventLight = EventLight.new
end
def terminate
autolight_terminate
light_terminate
end
def light_terminate
$AutoLight.dispose
$EventLight.dispose
end
def update
light_update
autolight_update
end
def light_update
$AutoLight.update
$EventLight.update
end
def fadein(duration)
light_fade
autolight_fadein(duration)
end
def light_fade
$AutoLight.dispose
$AutoLight = AutoLight.new
$EventLight.dispose
$EventLight = EventLight.new
end
end
#---------------#
# Read event_id #
#---------------#
class Game_Interpreter
attr_reader :event_id
end
#---------------------#
# Change Functions AL #
#---------------------#
module AL
def self.mode(val)
@val = val
return if !fixnum?(@val)
eval("AL::Mode = #{@val}")
$AutoLight.dispose
$AutoLight = AutoLight.new
end
def self.light(parm, val)
@val = val
case parm.capitalize
when "Name"; @val.to_s!
when "Visible"; return if !boolean?(@val)
else; return if !fixnum?(@val)
end
eval("AL::Light::#{parm.capitalize} = #{@val}")
$AutoLight.dispose
$AutoLight = AutoLight.new
end
def self.shadow(parm, val)
@val = val
case parm.capitalize
when "Name"; @val.to_s!
when "Visible"; return if !boolean?(@val)
else; return if !fixnum?(@val)
end
eval("AL::Shadow::#{parm.capitalize} = #{@val}")
$AutoLight.dispose
$AutoLight = AutoLight.new
end
def self.spot(parm, val)
@val = val
case parm.capitalize
when "Name"; @val.to_s!
when "Visible"; return if !boolean?(@val)
else; return if !fixnum?(@val)
end
eval("AL::Spot::#{parm.capitalize} = #{@val}")
$AutoLight.dispose
$AutoLight = AutoLight.new
end
def self.flicker(parm, val)
@val = val
return if !fixnum?(@val)
eval("AL::Spot::Flicker::#{parm.capitalize} = #{@val}")
$AutoLight.dispose
$AutoLight = AutoLight.new
end
end
#---------------------#
# Change Functions EL #
#---------------------#
module EL
def self.bitmap(val, index = nil)
@val = val
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].el.bitmap = Cache.picture(@val)
end
def self.color(val, index = nil)
@val = val
index = $game_map.interpreter.event_id if index == nil
old_value = $EventLight.event_lights[index].el.tone
$EventLight.event_lights[index].el.tone = pick_color(@val, old_value)
end
def self.opacity(val, index = nil)
@val = val
return if !fixnum?(@val)
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].el.opacity = @val
end
def self.blend(val, index = nil)
@val = val
return if !fixnum?(@val)
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].el.blend_type = @val
end
def self.visible(val, index = nil)
@val = val
return if !boolean?(@val)
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].el.visible = @val
end
def self.zoom(val, index = nil)
@val = val
return if !fixnum?(@val)
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].el.zoom_x = @val / 100.0
$EventLight.event_lights[index].el.zoom_y = @val / 100.0
end
def self.range(val, index = nil)
@val = val
return if !fixnum?(@val)
index = $game_map.interpreter.event_id if index == nil
$EventLight.event_lights[index].range = @val
end
end
#-----------------#
# Wrong input fix #
#-----------------#
# String/Fixnum -> Boolean
def boolean?(val)
return false if !(val.is_a? FalseClass or
val.is_a? TrueClass or
val.is_a? String or
val.is_a? Fixnum)
@val = eval(val) if val.is_a? String
if val.is_a? Fixnum or @val.is_a? Fixnum
val = @val if @val.is_a? Fixnum
if val == -1 or val == 1; @val = true
elsif val == 0; @val = false
else; return false
end
end
return true
end
# String -> Fixnum
def fixnum?(val)
return false if !(val.is_a? Fixnum or val.is_a? String)
@val = val.to_i if val.is_a? String
return true
end |
|