Here's the light effects script, it now uses the pictures folder. I'll go do the fog one, let me know if you have any issues.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# FenixFyreX's Light Effects (FFXLFX)
# Version 1.1
# http://www.rpgmakervx.net
# http://www.rpgmakervxace.net
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
#
# To use this script, either make a preset then setup an event's comment like so:
#
# <prelfx string> OR <prelfx=string> OR <prelfx = string> # You get the idea.
#
# Where string is the name of the preset below,
# or setup an event's comment like so:
#
# <lfx fn "image";>
#
# Where opts is any option defined below that you can put in a preset.
#
# fn = string # The filename of the image to use. Always pulls from Graphics/LFX.
# fa = number # Fadein? Default is 0(false).
# zx = number # The zoom x of the effect.
# zy = number # The zoom y of the effect.
# bl = number # Either 0(normal), 1(add), or 2(subtract).
# op = number # Anything from 0 to 255. Sets maximum opacity for effect.
# z = number # 0 is in front, the default. 1 is behind.
# s = number # Adheres to the light switch? 0 is false, 1 is true. Default is 1.
# fl = number # [n,n]. First n determines randomness of visibility. Second n
# determines the range of opacity change.
# cl = array # [n,n,n] or [n,n,n,n]. [red,green,blue,transparency].
# os = array # [x,y]. will offset the graphic by x,y.
# w = array # [n,n,n] or [n,n,n,n]. [strength,length,speed,phase].
#
# You must include filename if you make a direct light effect in a comment.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# Event Script Command Calls
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# These are commands you can call via Advanced/Script.
#
# remove_lfx(key)
# This will remove any light effects by the key. key has to be 1 or greater.
#
# player_lfx(preset_name,fade = false)
# This will add a light effect to the player. Must be a preset defined below.
# If you leave fade out, the effect will not fade in. If you set it to true,
# it will. es.g:
# player_lfx("Ground") # Will not fadein
# player_lfx("Ground",true) # Will fadein
#
# stop_player_lfx(fade = false)
# This will remove the player's light effect. If you leave out fade, the effect
# will just go away. If fade is true, the effect will fadeout. es.g:
# stop_player_lfx # Will not fadeout
# stop_player_lfx(true) # Will fadeout
#
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
module FFXLFX
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
#
# Set up preset light fx here. the preset can be named anything as long as it
# is a string(e.g. within " ")
# Options for the preset are as follows; if a * is next to it, its mandatory:
#
# :filename * The name of the file in Graphics/Lights/
# :fadein Should the effect fadein? 0 is false(default), 1 is true.
# :flicker Should the light flicker? Must be an array of two numbers.
# :zx Zoom X of the effect, 1 is default
# :zy Zoom Y of the effect, 1 is default
# :z Z coordinate of the effect. 0 is in front, 1 is behind.
# :blend 0 is normal, 1 is add, 2 is subtract
# :switch Adheres to the light switch? true or false. Default is true.
# :color An array of 3-4 numbers, like so: [155,100,0] # Yellow
# To make a random color, put -1 in the color index spot, so
# a fully random color would be [-1,-1,-1]
# :offset An array of two numbers. [-1,1] will offset the image left
# and down one pixel.
# :opacity Anything from 0 to 255. Sets maximum opacity for the effect.
# :wave An array of 3-4 numbers, [amp, length, speed, phase]
#
# :wave makes the image wiggle. Use the help file for further information on
# wave effects. Look up Sprite in the help file.
Presets = { # do NOT delete this.
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 1: Ground
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Ground" => {
:filename => "ground",
:flicker => [200,100],
:zx => 4,
:zy => 4,
:blend => 1,
:color => [155,100,0],
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 2: Lantern
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Lantern" => {
:filename => "lantern",
:flicker => [500,100],
:zx => 1,
:zy => 1,
:blend => 1,
:color => [190,100,0],
:offset => [0,0],
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 3: Lightbug
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Lightbug" => {
:filename => "ground",
:flicker => [500,200],
:zx => 1,
:zy => 1,
:z => 0,
:blend => 1,
:color => [-1,-1,-1],
:offset => [0,-6],
:switch => false,
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 4: Headstone
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Ghost" => {
:filename => "ghost",
:flicker => [0,0],
:zx => 2,
:zy => 2,
:blend => 1,
:color => [-1,-1,-1],
:offset => [0,-16],
:opacity => -170,
:wave => [2,5,1],
:fadein => true,
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 5: Fireplace
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Fireplace" => {
:filename => "fireplace",
:flicker => [500,200],
:color => [220,10,0],
:blend => 1,
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
# Preset 6: Drunk
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=--=- #
"Drunk" => {
:filename => "ground",
:switch => false,
:zx => 3,
:zy => 4,
:color => [220,10,0],
:blend => 1,
},
# -=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=--=- #
} # DO NOT DELETE THIS
# The switch that turns the whole system on or off. If on, the system will be off.
On_Off_Switch = 1
# Is the system on at startup? If true, it does. False, it doesn't.
Sys_Starts_On = true
# This number determines the speed at which light effects fade on and off.
# Higher numbers result in faster fading.
Fade_Time = 3
end
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
# DO NOT EDIT FURTHER UNLESS YOU KNOW WHAT YOU ARE DOING.
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- #
class Game_Switches
alias initialize_ffxlfx_switch_value initialize
def initialize(*a,&b)
initialize_ffxlfx_switch_value(*a,&b)
@data[FFXLFX::On_Off_Switch] = FFXLFX::Sys_Starts_On
end
end
module FFXLFX
def self.scene
return defined?($scene) ? $scene : SceneManager.scene
end
end
class Sprite
def start_wave(amp,speed,length,phase=nil)
self.wave_amp = amp
self.wave_speed = speed
self.wave_length = length
self.wave_phase = phase.to_i unless phase.nil?
end
end
class Spriteset_Map
alias initialize_ffxlfx_old initialize unless $@
alias update_ffxlfx_old update unless $@
alias dispose_ffxlfx_old dispose unless $@
def initialize(*a, &b)
@ffxlfx_sprites = {}
initialize_ffxlfx_old(*a, &b)
initialize_ffxlfx
update_ffxlfx
end
def update(*a, &b)
update_ffxlfx_old(*a, &b)
update_ffxlfx
end
def dispose(*a, &b)
dispose_ffxlfx
dispose_ffxlfx_old(*a, &b)
end
def initialize_ffxlfx
$game_map.events.each_pair do |id,event|
s = nil
cache = event.light_cache
if cache
s = Sprite_FFXLight.new(@viewport1,id)
s.setup(cache)
end
@ffxlfx_sprites[id] = s
end
@ffxlfx_sprites[:player] = nil
player_lfx
end
def refresh_ffxlfx
@ffxlfx_sprites.each_key do |key|
next unless key.is_a?(Integer)
if (@ffxlfx_sprites[key].nil? || @ffxlfx_sprites[key].disposed?)
cache = $game_map.events[key].nil? ? nil : $game_map.events[key].light_cache
next if (cache.nil? || cache.empty?)
@ffxlfx_sprites[key] = Sprite_FFXLight.new(@viewport1,key)
@ffxlfx_sprites[key].setup(cache)
else
cache = $game_map.events[key].nil? ? nil : $game_map.events[key].light_cache
if cache.nil?
remove_lfx(key)
elsif cache == @ffxlfx_sprites[key].cache
next
else
@ffxlfx_sprites[key].setup(cache)
end
end
end
end
def update_ffxlfx
rs = []
@ffxlfx_sprites.each_pair do |key,s|
next if s.nil?
next if s.disposed?
s.update
if s.to_nil?
rs << key
end
end
rs.each do |r|
@ffxlfx_sprites[r].dispose
@ffxlfx_sprites[r] = nil
end
end
def dispose_ffxlfx
@ffxlfx_sprites.each_pair do |key,s|
next if s.nil?
next if s.disposed?
s.dispose
end
@ffxlfx_sprites = {}
end
def remove_lfx(key)
@ffxlfx_sprites[key].fade2nil
end
def change_lfx(key,key2)
if @ffxlfx_sprites[key].nil?
@ffxlfx_sprites[key] = Sprite_FFXLight.new(@viewport1,key)
@ffxlfx_sprites[key].setup(FFXLFX::Presets[key2])
end
end
def player_lfx
return if $game_player.light_cache.nil?
return unless $game_player.light_cache[:filename]
if @ffxlfx_sprites[:player].nil? || @ffxlfx_sprites[:player].disposed?
@ffxlfx_sprites[:player] = Sprite_FFXLight.new(@viewport1,:player)
@ffxlfx_sprites[:player].cache = {}
@ffxlfx_sprites[:player].set_cache
end
end
def stop_player_lfx(fade)
return if @ffxlfx_sprites[:player].nil? || @ffxlfx_sprites[:player].disposed?
if fade
@ffxlfx_sprites[:player].fade2nil
else
@ffxlfx_sprites[:player].dispose
@ffxlfx_sprites[:player] = nil
end
end
#~ def add_lfx(opts)
#~ end
end
class Game_Player < Game_Character
attr_accessor :light_cache
alias initialize_light_cache initialize unless $@
def initialize(*a,&b)
initialize_light_cache(*a,&b)
@light_cache = nil
end
end
class Game_Event < Game_Character
FFXLFX_Light_Rgxp = /<lfx[ ]*[=]?/i
FFXLFX_Prelight_Rgxp = /<prelfx[ ]*[=]?[ ]*(.*)>/i
alias refresh_ffxlfx_refresh refresh unless $@
def refresh(*a,&b)
refresh_ffxlfx_refresh(*a,&b)
if FFXLFX.scene.is_a?(Scene_Map)
FFXLFX.scene.refresh_ffxlfx_lights
end
end
def name
return @event.nil? ? "" : @event.name
end
def comment?(txt,ret = false)
return false if @page.nil?
@page.list.each do |item|
if [108,408].include?(item.code)
item_text = item.parameters[0]
case txt
when Regexp
m = (item_text.match(txt))
if ret && !m.nil?
return m.captures
else
return !m.nil?
end
when String
if ret && (m = item_text.include?(txt))
return item.parameters[0]
else
return m
end
end
end
end
return false
end
def light?
return comment?(FFXLFX_Light_Rgxp)
end
def prelight?
return comment?(FFXLFX_Prelight_Rgxp)
end
def light_cache
cache = nil
if light?
txt = comment_block(FFXLFX_Prelight_Rgxp, ">")
cache = parse_lfx(txt)
elsif prelight?
txt = comment?(FFXLFX_Prelight_Rgxp, true)
cache = FFXLFX::Presets[txt[0]]
end
unless cache.nil?
cache[:fadein] = false if cache[:fadein].nil?
end
return cache
end
def comment_block(txt1,txt2)
s = [""]
start = false
stop = false
return s if @page.nil?
@page.list.each do |item|
if [108,408].include?(item.code)
item_text = item.parameters[0]
case txt1
when Regexp
if item_text =~ txt1
start = true
end
when String
if item_text.include?(txt1)
start = true
end
end
case txt2
when Regexp
if item_text =~ txt2
stop = true
end
when String
if item_text.include?(txt2)
stop = true
end
end
s << item_text
if stop
break
end
end
end
return s.join("")
end
def parse_lfx(txt="")
cache = {}
ary = txt.split(";")
ary.each do |item|
case item
when /fn[ ]*[=]?[ ]*(.*)/i
cache[:filename] = $1.to_s.gsub(">","")
when /fa[ ]*[=]?[ ]*(\d+)[>]?/i
cache[:fadein] = ($1.to_i == 1)
when /fl[ ]*[=]?[ ]*\[[ ]*(\d+)[ ]*,[ ]*(\d+)\][>]?/i
cache[:flicker] = [$1.to_i,$2.to_i]
when /zx[ ]*[=]?[ ]*(\d+)[>]?/i
cache[:zx] = $1.to_i
when /zy[ ]*[=]?[ ]*(\d+)[>]?/i
cache[:zy] = $1.to_i
when /z[ ]*[=]?[ ]*(0|1)[>]?/i
cache[:z] = ($1.to_i == 1)
when /a[ ]*[=]?[ ]*(0|1)[>]?/i
cache[:switch] = ($1.to_i == 1)
when /bl[ ]*[=]?[ ]*(0|1|2)[>]?/i
cache[:blend] = $1.to_i
when /op[ ]*[=]?[ ]*(\d+)[>]?/i
cache[:opacity] = $1.to_i
when /cl[ ]*[=]?[ ]*\[[ ]*(\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)[ ]*[,]?[ ]*(\d+)?\][>]?/i
cache[:color] = [$1.to_i,$2.to_i,$3.to_i]
cache[:color] << $4.to_i unless $4.nil?
when /os[ ]*[=]?[ ]*\[[ ]*([-]?\d+)[ ]*,[ ]*([-]?\d+)\][>]?/i
cache[:offset] = [$1.to_i,$2.to_i]
when /w[ ]*[=]?[ ]*\[[ ]*(\d+)[ ]*,[ ]*(\d+)[ ]*,[ ]*(\d+)[ ]*[,]?[ ]*(\d+)?\][>]?/i
cache[:wave] = [$1.to_i,$2.to_i,$3.to_i]
cache[:wave] << $4.to_i unless $4.nil?
end
end
return cache
end
end
class Sprite_FFXLight < Sprite_Base
attr_reader :charID,:char
attr_accessor :cache,:offset,:flicker
def initialize(viewport, charID)
super(viewport)
@charID = charID
@char = nil
@cache = {}
@offset = [0,0]
@flicker = nil
@go2nil = @to_nil = false
set_char
set_xyz
end
def setup(cache={})
if cache.nil?
@cache = {}
return
end
unless FileTest.exist?(fn="Graphics/Pictures/"+cache[:filename]+".png")
msgbox "File does not exist: "+fn
exit
end
self.bitmap = Cache.picture(cache[:filename]).clone
self.flicker = cache[:flicker] unless cache[:flicker].nil?
self.zoom_x = cache[:zx] unless cache[:zx].nil?
self.zoom_y = cache[:zy] unless cache[:zy].nil?
unless cache[:color].nil?
self.color = Color.new(*cache[:color])
self.color.red = rand(256) if cache[:color][0] == -1
self.color.green = rand(256) if cache[:color][1] == -1
self.color.blue = rand(256) if cache[:color][2] == -1
end
self.blend_type = cache[:blend] unless cache[:blend].nil?
self.offset = cache[:offset] unless cache[:offset].nil?
self.start_wave(*cache[:wave]) unless cache[:wave].nil?
if cache[:fadein]
self.opacity = 0
fadein
if get_char.is_a?(Game_Player)
get_char.light_cache[:fadein] = false
end
else
self.opacity = max_opacity
end
cache[:switch] = true if cache[:switch].nil?
@cache = cache
set_char
end
def max_opacity
result = 170
result = @cache[:opacity] unless @cache[:opacity].nil?
if !$game_switches[FFXLFX::On_Off_Switch]
result = 0 if @cache[:switch]
end
return result
end
def update
super
if @cache != get_cache
set_char
set_cache
if [nil,{}].include?(@cache)
fadeout
end
setup(@char.light_cache)
end
set_xyz
update_fadeinout
update_flicker if !fading
end
def update_fadeinout
fade_time = FFXLFX::Fade_Time
if @fadein
self.opacity = [[self.opacity+fade_time,0].max, max_opacity].min
if self.opacity >= max_opacity
self.opacity = max_opacity
@fadein = false
else
return
end
elsif @fadeout
self.opacity -= fade_time
if self.opacity == 0
if @go2nil
@to_nil = true
end
@fadeout = false
else
return
end
end
end
def update_flicker
if !@flicker.nil?
self.visible = (rand(@flicker[0]) != @flicker[0]-1)
self.opacity = 255-rand(@flicker[1])
self.opacity = max_opacity if self.opacity > max_opacity
else
self.visible = true
self.opacity = max_opacity
end
end
def set_cache
@cache = get_cache
setup(@cache)
end
def get_cache
return @char.light_cache
end
def fadein
@fadeout = false
@fadein = true
end
def fadeout
@fadein = false
@fadeout = true
end
def set_char
@char = get_char
end
def get_char
if @charID.is_a?(Integer)
return $game_map.events[@charID]
elsif @charID == :player
return $game_player
else
p "A light effect is assigned a nil character. Exiting for safety."
exit
end
end
def set_xyz
a = (@char.screen_x.to_f)
b = (@char.screen_y.to_f)
a -= 16+((self.zoom_x-1)*self.width/2)
b -= 32+((self.zoom_y-1)*self.height/2)
if self.width > 32
n1 = (self.width - 32) / 2
a -= n1
elsif self.width < 32
n1 = (32 - self.width) / 2
a += n1
end
if self.height > 32
n2 = (self.height - 32) / 2
b -= n2
elsif self.height < 32
n2 = (32 - self.height) / 2
b += n2
end
a += @offset[0]
b += @offset[1]
self.x = a
self.y = b
fz = @char.screen_z
if @cache[:z]
fz -= 1
else
fz += 1
end
self.z = fz
end
def to_nil?
return @to_nil
end
def fade2nil
@go2nil = true
fadeout
end
def fading
return true if @fadein || @fadeout || @go2nil
return false
end
end
class Game_Interpreter
def remove_lfx(key)
FFXLFX.scene.remove_lfx(key)
end
#~ def add_lfx(x,y,key)
#~ opts = {}
#~ opts[:x] = x
#~ opts[:y] = y
#~ opts[:k] = key
#~ FFXLFX.scene.add_lfx(opts)
#~ end
def player_lfx(preset,fade=false)
FFXLFX.scene.player_lfx(preset,fade)
end
def stop_player_lfx(fade=false)
FFXLFX.scene.stop_player_lfx(fade)
end
end
class Scene_Map < Scene_Base
def refresh_ffxlfx_lights
return if @spriteset.nil?
@spriteset.refresh_ffxlfx
end
def remove_lfx(key)
@spriteset.remove_lfx(key)
end
#~ def add_lfx(opts)
#~ @spriteset.add_lfx(opts)
#~ end
def player_lfx(preset,fade)
$game_player.light_cache = FFXLFX::Presets[preset]
return if $game_player.light_cache.nil?
$game_player.light_cache[:fadein] = fade
@spriteset.player_lfx
end
def stop_player_lfx(fade)
@spriteset.stop_player_lfx(fade)
end
alias pre_transfer_lfx pre_transfer
def pre_transfer(*a,&b)
pre_transfer_lfx(*a,&b)
@spriteset.dispose_ffxlfx
end
alias post_transfer_lfx post_transfer
def post_transfer(*a,&b)
@spriteset.initialize_ffxlfx
post_transfer_lfx(*a,&b)
end
end
Here is the fog script, I ran out of characters in the first post.
#==============================================================================
# ** Victor Engine - Fog Effect
#------------------------------------------------------------------------------
# Author : Victor Sant
#
# Version History:
# v 1.00 - 2011.12.19 > First relase
# v 1.01 - 2011.12.30 > Faster Regular Expressions
# v 1.02 - 2012.01.02 > Fixed fog dispose when changing maps
# v 1.03 - 2012.01.04 > Fixed load fail when fog ON
# v 1.04 - 2012.01.10 > Fixed fog movement y bug
# v 1.05 - 2012.01.14 > Fixed the positive sign on some Regular Expressions
# v 1.06 - 2012.01.15 > Fixed the Regular Expressions problem with "" and “”
# v 1.07 - 2012.01.15 > Fixed fog position in maps with loop
#------------------------------------------------------------------------------
# This script allows to add varied of effects to the maps. Fos are picutres
# placed above the player layer and loops. Differently from pictures the fog
# follows the map movement instead of the screen (this behavior can be changed)
# You can add various fogs to the map.
#------------------------------------------------------------------------------
# Compatibility
# Requires the script 'Victor Engine - Basic Module' v 1.09 or higher
#
# * Alias methods (Default)
# class Game_Screen
# def initialize
# def clear
# def update
#
# class Game_Map
# def setup(map_id)
# def scroll_down(distance)
# def scroll_left(distance)
# def scroll_right(distance)
# def scroll_up(distance)
#
# class Spriteset_Map
# def initialize
# def dispose
# def update
#
# * Alias methods (Basic Module)
# class Game_Interpreter
# def comment_call
#
#------------------------------------------------------------------------------
# Instructions:
# To instal the script, open you script editor and paste this script on
# a new section on bellow the Materials section. This script must also
# be bellow the script 'Victor Engine - Basic'
# The fogs must be placed on the folder "Graphics/Fogs". Create a folder
# named "Fogs" on the Graphics folder.
#
#------------------------------------------------------------------------------
# Maps and Comment calls note tags:
# Tags to be used on the Maps note box in the database or in events
# comment box, works like a script call
#
# <fog effect>
# settings
# </fog effect>
# Create a fog effect on the map, add the following values to the info
# the ID and name must be added, other values are optional.
# id: x : fog ID
# name: "x" : fog graphic filename ("filename")
# opacity: x : fog opacity (0-255)
# move: x : fog screen movement (32 = fog follows the map)
# zoom: x : fog zoom (100 = default size)
# hue: x : fog hue (0-360)
# blend: x : fog blend type (0: normal, 1: add, 2: subtract)
# depth: x : fog Z axis (300 = default value)
#
# <fog opacity id: o, d>
# This tag allows to change the fog opacity gradually
# id : fog ID
# o : new opacity (0-255)
# d : wait until complete change (60 frames = 1 second)
#
# <fog move id: x, y>
# This tag adds fog continuous movement
# id : fog ID
# x : horizontal movement, can be positive or negative
# y : vertical movement, can be positive or negative
#
# <fog tone id: r, g, b, y, d>
# This tag allows to change the fog opacity gradually
# id : fog ID
# r : red tone (0-255, can be negative)
# g : green tone (0-255, can be negative)
# b : blue tone (0-255, can be negative)
# y : gray tone (0-255)
# d : wait until complete change (60 frames = 1 second)
#
#------------------------------------------------------------------------------
# Additional instructions:
#
# Map note tags commands are called right when enters the map, comment calls
# are called during the event process.
#
#==============================================================================
#==============================================================================
# ** Victor Engine
#------------------------------------------------------------------------------
# Setting module for the Victor Engine
#==============================================================================
module Victor_Engine
#--------------------------------------------------------------------------
# * Set fogs visibility on battle
# When true, fogs are visible on battle
#--------------------------------------------------------------------------
VE_BATTLE_FOGS = false
#--------------------------------------------------------------------------
# * required
# This method checks for the existance of the basic module and other
# VE scripts required for this script to work, don't edit this
#--------------------------------------------------------------------------
def self.required(name, req, version, type = nil)
if !$imported[:ve_basic_module]
msg = "The script '%s' requires the script\n"
msg += "'VE - Basic Module' v%s or higher above it to work properly\n"
msg += "Go to http://victorscripts.wordpress.com/ to download this script."
msgbox(sprintf(msg, self.script_name(script), version))
exit
else
self.required_script(name, req, version, type)
end
end
#--------------------------------------------------------------------------
# * script_name
# Get the script name base on the imported value, don't edit this
#--------------------------------------------------------------------------
def self.script_name(name, ext = "VE")
name = name.to_s.gsub("_", " ").upcase.split
name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
name.join(" ")
end
end
$imported ||= {}
$imported[:ve_fog_effects] = 1.07
Victor_Engine.required(:ve_fog_effects, :ve_basic_module, 1.09, :above)
#==============================================================================
# ** Game_Screen
#------------------------------------------------------------------------------
# This class handles screen maintenance data, such as change in color tone,
# flashes, etc. It's used within the Game_Map and Game_Troop classes.
#==============================================================================
class Game_Screen
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :fogs
#--------------------------------------------------------------------------
# * Alias method: initialize
#--------------------------------------------------------------------------
alias :initialize_ve_fog_effects :initialize
def initialize
@fogs = Game_Fogs.new
initialize_ve_fog_effects
end
#--------------------------------------------------------------------------
# * Alias method: clear
#--------------------------------------------------------------------------
alias :clear_ve_fog_effects :clear
def clear
clear_ve_fog_effects
clear_fogs
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_fog_effects :update
def update
update_ve_fog_effects
update_fogs
end
#--------------------------------------------------------------------------
# * New method: fogs
#--------------------------------------------------------------------------
def fogs
@fogs ||= Game_Fogs.new
end
#--------------------------------------------------------------------------
# * New method: clear_fogs
#--------------------------------------------------------------------------
def clear_fogs
fogs.each {|fog| fog.erase }
end
#--------------------------------------------------------------------------
# * New method: update_fogs
#--------------------------------------------------------------------------
def update_fogs
fogs.each {|fog| fog.update }
end
#--------------------------------------------------------------------------
# * New method: create_fog
#--------------------------------------------------------------------------
def create_fog(*args)
fogs[args.first].show(*args)
end
#--------------------------------------------------------------------------
# * New method: set_fog_move
#--------------------------------------------------------------------------
def set_fog_move(id, sx, sy)
fogs[id].start_movement(sx, sy)
end
#--------------------------------------------------------------------------
# * New method: set_fog_tone
#--------------------------------------------------------------------------
def set_fog_tone(id, red, green, blue, gray, duration = 0)
tone = Tone.new(red, green, blue, gray)
fogs[id].start_tone_change(tone, duration)
end
#--------------------------------------------------------------------------
# * New method: set_fog_opacity
#--------------------------------------------------------------------------
def set_fog_opacity(id, opacity, duration = 0)
fogs[id].start_opacity_change(opacity, duration)
end
end
#==============================================================================
# ** Game_Map
#------------------------------------------------------------------------------
# This class handles maps. It includes scrolling and passage determination
# functions. The instance of this class is referenced by $game_map.
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :fog_x
attr_reader :fog_y
#--------------------------------------------------------------------------
# * Alias method: setup
#--------------------------------------------------------------------------
alias :setup_ve_fog_effects :setup
def setup(map_id)
setup_ve_fog_effects(map_id)
setup_fogs_effect
end
#--------------------------------------------------------------------------
# * Alias method: scroll_down
#--------------------------------------------------------------------------
alias :scroll_down_ve_fog_effects :scroll_down
def scroll_down(distance)
last_y = @display_y
scroll_down_ve_fog_effects(distance)
@fog_y += loop_vertical? ? distance : @display_y - last_y
end
#--------------------------------------------------------------------------
# * Alias method: scroll_left
#--------------------------------------------------------------------------
alias :scroll_left_ve_fog_effects :scroll_left
def scroll_left(distance)
last_x = @display_x
scroll_left_ve_fog_effects(distance)
@fog_x += loop_horizontal? ? -distance : @display_x - last_x
end
#--------------------------------------------------------------------------
# * Alias method: scroll_right
#--------------------------------------------------------------------------
alias :scroll_right_ve_fog_effects :scroll_right
def scroll_right(distance)
last_x = @display_x
scroll_right_ve_fog_effects(distance)
@fog_x += loop_horizontal? ? distance : @display_x - last_x
end
#--------------------------------------------------------------------------
# * Alias method: scroll_up
#--------------------------------------------------------------------------
alias :scroll_up_ve_fog_effects :scroll_up
def scroll_up(distance)
last_y = @display_y
scroll_up_ve_fog_effects(distance)
@fog_y += loop_vertical? ? -distance : @display_y - last_y
end
#--------------------------------------------------------------------------
# * New method: setup_fogs_effect
#--------------------------------------------------------------------------
def setup_fogs_effect
@fog_x = 0
@fog_y = 0
create_fog(note)
set_fog_opacity(note)
set_fog_move(note)
set_fog_tone(note)
end
#--------------------------------------------------------------------------
# * New method: create_fog
#--------------------------------------------------------------------------
def create_fog(note)
regexp = /<FOG EFFECT>([^><]*)<\/FOG EFFECT>/im
note.scan(regexp) { setup_fog($1) }
end
#--------------------------------------------------------------------------
# * New method: set_fog_opacity
#--------------------------------------------------------------------------
def set_fog_opacity(note)
regexp = /<FOG OPACITY (\d+): (\d+) *, *(\d+)>/i
note.scan(regexp) do |id, o, d|
@screen.set_fog_opacity(id.to_i, o.to_i, d.to_i)
end
end
#--------------------------------------------------------------------------
# * New method: set_fog_move
#--------------------------------------------------------------------------
def set_fog_move(note)
regexp = /<FOG MOVE (\d+): ([+-]?\d+) *, *([+-]?\d+)>/i
note.scan(regexp) do |id, sx, sy|
@screen.set_fog_move(id.to_i, sx.to_i, sy.to_i)
end
end
#--------------------------------------------------------------------------
# * New method: set_fog_tone
#--------------------------------------------------------------------------
def set_fog_tone(note)
values = "(\\d+) *, *(\\d+) *, *(\\d+) *, *(\\d+)(?: *, *(\\d+))?"
regexp = /<FOG TONE (\d+): #{values}>/i
note.scan(regexp) do |i, r, g, b, a, d|
info = [i.to_i, r.to_i, g.to_i, b.to_i, a.to_i, d ? d.to_i : 0]
@screen.set_fog_tone(*info)
end
end
#--------------------------------------------------------------------------
# * New method: setup_fog
#--------------------------------------------------------------------------
def setup_fog(info)
id = info =~ /ID: (\d+)/i ? $1.to_i : 0
name = info =~ /NAME: #{get_filename}/i ? $1.dup : ""
op = info =~ /OPACITY: (\d+)/i ? $1.to_i : 192
move = info =~ /MOVE: (\d+)/i ? $1.to_i : 32
zoom = info =~ /ZOOM: (\d+)/i ? $1.to_f : 100.0
hue = info =~ /HUE: (\d+)/i ? $1.to_i : 0
blend = info =~ /BLEND: (\d+)/i ? $1.to_i : 0
depth = info =~ /DEPTH: ([+-]?\d+)/i ? $1.to_i : 300
@screen.create_fog(id, name, op, move, zoom, hue, blend, depth)
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Alias method: comment_call
#--------------------------------------------------------------------------
alias :comment_call_ve_fog_effects :comment_call
def comment_call
call_create_fog_effect
comment_call_ve_fog_effects
end
#--------------------------------------------------------------------------
# * New method: call_create_fog_effect
#--------------------------------------------------------------------------
def call_create_fog_effect
$game_map.create_fog(note)
$game_map.set_fog_opacity(note)
$game_map.set_fog_move(note)
$game_map.set_fog_tone(note)
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# Esta classe reune os sprites da tela de mapa e tilesets. Esta classe é
# usada internamente pela classe Scene_Map.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Alias method: initialize
#--------------------------------------------------------------------------
alias :initialize_ve_fog_effects :initialize
def initialize
create_fogs
initialize_ve_fog_effects
end
#--------------------------------------------------------------------------
# * Alias method: dispose
#--------------------------------------------------------------------------
alias :dispose_ve_fog_effects :dispose
def dispose
dispose_ve_fog_effects
dispose_fogs
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_fog_effects :update
def update
update_ve_fog_effects
update_fogs
end
#--------------------------------------------------------------------------
# * New method: create_fogs
#--------------------------------------------------------------------------
def create_fogs
@fog_sprites = []
end
#--------------------------------------------------------------------------
# * New method: dispose_fogs
#--------------------------------------------------------------------------
def dispose_fogs
if @fog_sprites
@fog_sprites.compact.each {|sprite| sprite.dispose }
@fog_sprites.clear
end
end
#--------------------------------------------------------------------------
# * New method: update_fogs
#--------------------------------------------------------------------------
def update_fogs
$game_map.screen.fogs.each do |fog|
@fog_sprites[fog.id] ||= Sprite_Fog.new(@viewport1, fog)
@fog_sprites[fog.id].update
end
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Alias method: initialize
#--------------------------------------------------------------------------
alias :initialize_ve_fog_effects :initialize
def initialize
create_fogs if VE_BATTLE_FOGS
initialize_ve_fog_effects
end
#--------------------------------------------------------------------------
# * Alias method: dispose
#--------------------------------------------------------------------------
alias :dispose_ve_fog_effects :dispose
def dispose
dispose_fogs if VE_BATTLE_FOGS
dispose_ve_fog_effects
end
#--------------------------------------------------------------------------
# * Alias method: update
#--------------------------------------------------------------------------
alias :update_ve_fog_effects :update
def update
update_fogs if VE_BATTLE_FOGS
update_ve_fog_effects
end
#--------------------------------------------------------------------------
# * New method: create_fogs
#--------------------------------------------------------------------------
def create_fogs
@fog_sprites = []
end
#--------------------------------------------------------------------------
# * New method: dispose_fogs
#--------------------------------------------------------------------------
def dispose_fogs
if @fog_sprite
$game_map.screen.fogs.clear
@fog_sprites.compact.each {|sprite| sprite.dispose }
@fog_sprites.clear
end
end
#--------------------------------------------------------------------------
# * New method: update_fogs
#--------------------------------------------------------------------------
def update_fogs
$game_map.screen.fogs.each do |fog|
@fog_sprites[fog.id] ||= Sprite_Fog.new(@viewport1, fog)
@fog_sprites[fog.id].update
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias method: pre_transfer
#--------------------------------------------------------------------------
alias :pre_transfer_ve_fog_effects :pre_transfer
def pre_transfer
pre_transfer_ve_fog_effects
if $game_player.new_map_id != $game_map.map_id
@spriteset.dispose_fogs
$game_map.screen.clear_fogs
$game_map.screen.fogs.clear
end
end
end
#==============================================================================
# ** Game_Fog
#------------------------------------------------------------------------------
# This class handles fog data. This class is used within the Game_Fogs class.
#==============================================================================
class Game_Fog
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :id
attr_reader :name
attr_reader :hue
attr_reader :sx
attr_reader :sy
attr_reader :ox
attr_reader :oy
attr_reader :depth
attr_reader :move
attr_reader :zoom_x
attr_reader :zoom_y
attr_reader :opacity
attr_reader :blend_type
attr_reader :tone
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize(id)
@id = id
init_basic
init_target
init_tone
end
#--------------------------------------------------------------------------
# * init_basic
#--------------------------------------------------------------------------
def init_basic
@name = ""
@depth = 300
@zoom_x = 1.0
@zoom_y = 1.0
@move = 32
@opacity = 255.0
@blend_type = 1
@sx = 0
@sy = 0
@ox = 0
@oy = 0
@hue = 0
@opacity_duration = 0
@tone_duration = 0
end
#--------------------------------------------------------------------------
# * init_target
#--------------------------------------------------------------------------
def init_target
@target_x = @x
@target_y = @y
@target_zoom_x = @zoom_x
@target_zoom_y = @zoom_y
@target_opacity = @opacity
end
#--------------------------------------------------------------------------
# * init_tone
#--------------------------------------------------------------------------
def init_tone
@tone = Tone.new
@tone_target = Tone.new
@tone_duration = 0
end
#--------------------------------------------------------------------------
# * show
#--------------------------------------------------------------------------
def show(id, name, opacity, move, zoom, hue, blend, depth)
@id = id
@name = name
@move = move
@zoom_x = zoom.to_f
@zoom_y = zoom.to_f
@depth = depth
@opacity = opacity.to_f
@blend_type = blend
init_target
init_tone
end
#--------------------------------------------------------------------------
# * start_movement
#--------------------------------------------------------------------------
def start_movement(sx, sy)
@sx = sx
@sy = sy
end
#--------------------------------------------------------------------------
# * start_tone_change
#--------------------------------------------------------------------------
def start_tone_change(tone, duration)
@tone_target = tone.clone
@tone_duration = [duration.to_i, 0].max
@tone = @tone_target.clone if @tone_duration == 0
end
#--------------------------------------------------------------------------
# * start_opacity_change
#--------------------------------------------------------------------------
def start_opacity_change(opacity, duration)
@opacity_target = opacity
@opacity_duration = [duration.to_i, 0].max
@opacity = @opacity_target if @opacity_duration == 0
end
#--------------------------------------------------------------------------
# * erase
#--------------------------------------------------------------------------
def erase
@name = ""
end
#--------------------------------------------------------------------------
# * update
#--------------------------------------------------------------------------
def update
update_move
update_tone
update_opacity
end
#--------------------------------------------------------------------------
# * update_move
#--------------------------------------------------------------------------
def update_move
@ox -= @sx / 16.0
@oy -= @sy / 16.0
end
#--------------------------------------------------------------------------
# * update_opacity
#--------------------------------------------------------------------------
def update_opacity
return if @opacity_duration == 0
d = @opacity_duration
@opacity = (@opacity * (d - 1) + @opacity_target) / d
@opacity_duration -= 1
end
#--------------------------------------------------------------------------
# * update_tone
#--------------------------------------------------------------------------
def update_tone
return if @tone_duration == 0
d = @tone_duration
@tone.red = (@tone.red * (d - 1) + @tone_target.red) / d
@tone.green = (@tone.green * (d - 1) + @tone_target.green) / d
@tone.blue = (@tone.blue * (d - 1) + @tone_target.blue) / d
@tone.gray = (@tone.gray * (d - 1) + @tone_target.gray) / d
@tone_duration -= 1
end
end
#==============================================================================
# ** Game_Fogs
#------------------------------------------------------------------------------
# This class handles fogs. This class is used within the Game_Screen class.
#==============================================================================
class Game_Fogs
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize
@data = []
end
#--------------------------------------------------------------------------
# * []
#--------------------------------------------------------------------------
def [](number)
@data[number] ||= Game_Fog.new(number)
end
#--------------------------------------------------------------------------
# * each
#--------------------------------------------------------------------------
def each
@data.compact.each {|fog| yield fog } if block_given?
end
#--------------------------------------------------------------------------
# * clear
#--------------------------------------------------------------------------
def clear
@data.clear
end
end
#==============================================================================
# ** Sprite_Fog
#------------------------------------------------------------------------------
# This sprite is used to display fgos. It observes a instance of the
# Game_Fog class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Fog < Plane
#--------------------------------------------------------------------------
# * initialize
#--------------------------------------------------------------------------
def initialize(viewport, fog)
super(viewport)
@fog = fog
@x = 0
@y = 0
@old_x = $game_map.round_x($game_map.display_x)
@old_y = $game_map.round_y($game_map.display_y)
update
end
#--------------------------------------------------------------------------
# * dispose
#--------------------------------------------------------------------------
def dispose
bitmap.dispose if bitmap
super
end
#--------------------------------------------------------------------------
# * update
#--------------------------------------------------------------------------
def update
update_bitmap
update_position
update_zoom
update_other
end
#--------------------------------------------------------------------------
# * update bitmap
#--------------------------------------------------------------------------
def update_bitmap
if @fog_name != @fog.name
self.bitmap = Cache.picture(@fog.name)
@fog_name = @fog.name.dup
end
end
#--------------------------------------------------------------------------
# * update_position
#--------------------------------------------------------------------------
def update_position
self.ox = $game_map.fog_x * @fog.move + @fog.ox
self.oy = $game_map.fog_y * @fog.move + @fog.oy
self.z = @fog.depth
end
#--------------------------------------------------------------------------
# * update_zoom
#--------------------------------------------------------------------------
def update_zoom
self.zoom_x = @fog.zoom_x / 100.0
self.zoom_y = @fog.zoom_y / 100.0
end
#--------------------------------------------------------------------------
# * update_other
#--------------------------------------------------------------------------
def update_other
self.opacity = @fog.opacity
self.blend_type = @fog.blend_type
self.tone.set(@fog.tone)
end
end