quarta-feira, 3 de abril de 2013
RPGMAKERVXACE - Khas Awesome Light Effec
#-------------------------------------------------------------------------------
# * [ACE] Khas Awesome Light Effects
#-------------------------------------------------------------------------------
# * Por Khas Arcthunder - arcthunder.site40.net
# * Versão: 1.0 BR
# * Lançada em: 12/01/2012
#
#-------------------------------------------------------------------------------
# * Termos de uso
#-------------------------------------------------------------------------------
# Ao utilizar qualquer script feito por Khas, você concorda com os termos abaixo
# 1. Você deve dar crédito a Khas se estiver usando algum script Khas;
# 2. Todos os scripts Khas estão sob licença Creative Commons;
# 3. Todos os scripts Khas são para projetos não comerciais, se você precisar de
# algum script Khas em seu projeto comercial (aceito pedidos para esse tipo
# de projeto), envie um email para nilokruch@live.com com o pedido;
# 4. Todos os scripts Khas são para uso pessoal, você pode usar e editar para uso
# no seu projeto, porém você não pode postar nenhuma versão modificada;
# 5. Você não pode dar créditos a si próprio por postar algum script Khas;
# 6. Caso queira compartilhar um script Khas, não poste o link direto de
# download, apenas redirecione o usuário para arcthunder.site40.net
#
#-------------------------------------------------------------------------------
# * Características
#-------------------------------------------------------------------------------
# - Efeitos de luz realista
# - Luz real (não passa paredes!)
# - Fontes de luz estática (que não se move)
# - Fonte de luz dinâmica (uma lanterna para o jogador, por exemplo)
# - Efeitos multiplos podem se juntar
# - Fácil configuração
# - Uso por comentário
#
#-------------------------------------------------------------------------------
# * IMPORTANTE - Desempenho
#-------------------------------------------------------------------------------
# Esse script pode vir a ser pesado para processadores muito antigos! O Awesome
# Light Effects foi testado em um Core 2 Duo E4500 e em um Core i5, sem lag.
# Porém, além do processador, há vários fatores que influenciam no desempenho
# do script:
#
# 1. Tamanho do mapa
# Este script analiza o mapa em busca de superfícies para cortar a luz. Em um
# mapa muito grande, esse número de superfícies pode aumentar muito, afetando
# o desempenho da LUZ DINÂMICA. O tamanho do mapa não influência nas luzes
# estáticas.
#
# 2. Quantidade de efeitos
# Este script desenha os efeitos na tela, conforme sua posição. Antes de
# atualizá-los, a sua posição é verificada. Portanto, em mapas muito grandes
# com excesso de efeitos pode a vir ocorrer lag. Note que isso é apenas uma
# previsão, pois nos testes atuais não foi detectado lag.
#
# 3. Tamanho da imagem
# O tamanho da imagem da luz dinâmica influencia diretamente no desempenho.
# O corte de luz é feito linha a linha, quanto maior a resolução da imagem,
# mais tempo será gasto para cortá-la. A recomendação é até 200x200 pixels.
#
#-------------------------------------------------------------------------------
# * IMPORTANTE - Imagens de luz
#-------------------------------------------------------------------------------
# Para o funcionamento correto do script, as imagens de luz DEVEM obedecer
# os seguintes critérios:
#
# 1. O tamanho da imagem DEVE ser par. Exemplo: 150x150
# 2. A imagem DEVE ser quadrada, com dimensões IGUAIS. Exemplo: 156x156
# 3. A imagem DEVE estar com as cores invertidas! Isso é nescessário, pois o
# script inverte as cores para desenhar o efeito na superfície de efeitos.
# Lembre-se que a cor preta ficará transparente!
#
#-------------------------------------------------------------------------------
# * Instruções - 1. Configurando efeitos estáticos
#-------------------------------------------------------------------------------
# Para configurar efeitos estáticos, vá até a configuração (logo abaixo) e
# defina os efeitos dentro da hash Effects. Faça do seguinte modo:
#
# X => [imagem, opacidade, variação, corte], <= Lembre dessa vírgula no final!
#
# Onde:
# Imagem => Nome da imagem na pasta "Graphics/Lights";
# Opacidade => Opacidade da imagem;
# Variação => Variação POSITIVA da opacidade;
# Corte => Coloque true para cortar a imagem e false para não cortar;
# X => É o ID do efeito, para ser usado nos eventos. Use um ID para cada efeito.
#
# Veja os efeitos pré configurados para entender como funciona.
#
#-------------------------------------------------------------------------------
# * Instruções - 2. Usando o efeitos em eventos:
#-------------------------------------------------------------------------------
# Para usar o efeito definido em um evento, coloque o seguinte comentário:
#
# [light x]
#
# Onde x deve ser o ID do efeito configurado.
#
#-------------------------------------------------------------------------------
# * Instruções - 3. Utilizando a luz dinâmica (lanterna)
#-------------------------------------------------------------------------------
# A lanterna é automaticamente inicializada como invisível. Você pode usar os
# seguintes métodos com o comando "Chamar Script":
#
# l = $game_map.lantern
# Adiquire a lanterna em uma variável.
# Você pode usar todos os comandos abaixo com "$game_map.lantern" ao
# invés de adiquirir a lanterna em uma variável, porém tome cuidado, pois
# o comando "Chamar Script" corta o código e pode gerar erros.
#
# l.set_graphic(i)
# Muda o gráfico da lanterna para i, onde i deve ser o nome, entre aspas,
# da imagem na pasta Graphics/Lights
#
# l.set_multiple_graphics(h)
# Muda os gráficos da lanterna para h, onde h deve ser uma Hash com o seguinte
# formato:
#
# h = {2=>"ld",4=>"ll",6=>"lr",8=>"lu"}
#
# Onde:
# "ld" é o nome da imagem quando o portador está virado para baixo;
# "ll" é o nome da imagem quando o portador está virado para esquerda;
# "lr" é o nome da imagem quando o portador está virado para direita;
# "lu" é o nome da imagem quando o portador está virado para cima.
#
# l.change_owner(char)
# Muda o portador da lanterna para char, onde char pode ser:
# $game_player <= O jogador;
# self_event <= O evento em que o comando é chamado;
# $game_map.events[x] <= O evento de ID x do mapa.
#
# l.set_opacity(o,p)
# Ajusta a opacidade da lanterna, onde:
# o é a opacidade padrão;
# p é a variação POSITIVA da opacidade.
#
# l.show
# Depois de configurar a lanterna com os comandos acima, use este comando para
# tornar a lanterna visível.
#
# l.hide
# Use este comando para esconder a lanterna.
#
#-------------------------------------------------------------------------------
# * Instruções - 4. Utilizando a superfície de efeitos (Chamar Script)
#-------------------------------------------------------------------------------
# O Awesome Light Effects desenha os efeitos sobre uma superfície. Para que
# os efeitos estejam visíveis, a superfície de efeitos deve estar visível.
# Para utilizar a superfície de efeitos, utilize os comandos abaixo:
#
# s = $game_map.effect_surface
# Adiquire a superfície em uma variável.
# Você pode usar todos os comandos abaixo com "$game_map.effect_surface" ao
# invés de adiquirir a superfície em uma variável, porém tome cuidado, pois
# o comando "Chamar Script" corta o código e pode gerar erros.
#
# s.set_color(r,g,b)
# Muda a cor da superfície instantâneamente para a cor fornecida:
# r => valor da cor vermelha;
# g => valor da cor verde;
# b => valor da cor azul.
#
# s.set_alpha(a)
# Muda a opacidade da superfície instantâneamente para a.
#
# s.change_color(time,r,g,b)
# Muda SOMENTE a cor da superfície em um certo tempo, onde:
# time => tempo para a mudança (em frames);
# r => valor da cor vermelha;
# g => valor da cor verde;
# b => valor da cor azul.
#
# s.change_color(time,r,g,b,a)
# Muda a cor da superfície e a opacidade em um certo tempo, onde:
# time => tempo para a mudança (em frames);
# r => valor da cor vermelha;
# g => valor da cor verde;
# b => valor da cor azul;
# a => opacidade.
#
# s.change_alpha(time,a)
# Muda a opacidade da superfície em um certo tempo, onde:
# time => tempo para a mudança (em frames);
# a => opacidade.
#
#-------------------------------------------------------------------------------
# * Instruções - 5. Utilizando a superfície de efeitos (Evento)
#-------------------------------------------------------------------------------
# Você pode acessar a superfície de efeitos pelo comando "Tonalidade de Tela",
# para isso, coloque a opção "Surface_UE" (nas configurações) como true. Caso
# queria desabilitar essa opção e ter controle sobre o tom da tela, coloque a
# opção "Surface_UE" como false.
#
# Observe os seguintes detalhes, se for usar esta opção:
# 1. Os valores de cor devem estar entre 0 e 255;
# 2. O tempo é em frames;
# 3. O valor "Cinza" será enviado como a opacidade da superfície.
#
#-------------------------------------------------------------------------------
# * Instruções - 6. Configurando as Tags do mapa
#-------------------------------------------------------------------------------
# Afim de que as luzes sejam cortadas de forma precisa e realista, há 3 tipos
# de comportamento para um tile: telhado, parede e bloco. Pense de maneira
# lógica: um telhado gera sombras como telhado, uma parede como uma parede, e
# assim por diante.
#
# Para isso, as tags do tileset DEVEM ser configuradas. Por padrão, são
# configuradas para 6,7 e 8. Veja a demo para ter noção de como isso funciona.
#
# Note que o script só irá analizar a primeira camada (camada A) do mapa. Certos
# tilesets não irão funcionar caso os tiles não estejam configurados de modo
# correto. Note ainda que este script depende do bom mapeamento para funcionar,
# preste atenção aos detalhes do seu mapa.
#
#-------------------------------------------------------------------------------
# * Configuração
#-------------------------------------------------------------------------------
module Light_Core
Effects = { # Não mude isto!
#-------------------------------------------------------------------------------
# ADICIONE ABAIXO OS SEUS EFEITOS!
#-------------------------------------------------------------------------------
0 => ["light",255,0,true],
1 => ["torch",200,20,true],
2 => ["torch_m",180,30,true],
3 => ["light_s",255,0,true],
#-------------------------------------------------------------------------------
# Fim da configuração de efeitos
#-------------------------------------------------------------------------------
} # Não mude isto!
# Coordenada Z da superfície de efeitos:
Surface_Z = 180
# Habilitar controle da superfície por "Tonalidade da Tela"?
Surface_UE = true
# Tag para a superfície se comportar como "telhado"
Roof_Tag = 5
# Tag para a superfície se comportar como "parede"
Wall_Tag = 6
# Tag para a superfície se comportar como "bloco" (semelhante ao telhado)
Block_Tag = 7
# Constante de correção de ângulo (não altere)
ACC = Math.tan(Math::PI/26)
end
#-------------------------------------------------------------------------------
# Fim da configuração - Início do script
#-------------------------------------------------------------------------------
module Cache
def self.light(filename)
load_bitmap("Graphics/Lights/", filename)
end
end
module Light_Bitcore
include Light_Core
def self.initialize
@@buffer = {}
Effects.values.each { |effect| Light_Bitcore.push(effect[0])}
end
def self::[](key)
return @@buffer[key]
end
def self.push(key)
return if @@buffer.keys.include?(key)
@@buffer[key] = Cache.light(key)
end
end
Light_Bitcore.initialize
class Light_SSource
attr_reader :real_x
attr_reader :real_y
attr_reader :range
attr_accessor :bitmap
attr_reader :w
attr_reader :h
attr_reader :hs
def initialize(char,bitmap,opacity,plus,hs)
sync(char)
@key = bitmap
@bitmap = Light_Bitcore[@key].clone
@range = @bitmap.width/2
@w = @bitmap.width
@h = @bitmap.height
@mr = @range - 16
@opacity = opacity
@plus = plus
@hs = hs
render if @hs
end
def render
tx = x
ty = y
tsx = x + @range
tsy = y + @range
dr = @range*2
for s in $game_map.surfaces
next if !s.visible?(tsx,tsy) || !s.within?(tx,tx+dr,ty,ty+dr)
s.render_shadow(tx,ty,tsx,tsy,@range,@bitmap)
end
end
def restore
return unless @bitmap.nil?
@bitmap = Light_Bitcore[@key].clone
render if @hs
end
def opacity
@plus == 0 ? @opacity : (@opacity + rand(@plus))
end
def sx
return $game_map.adjust_x(@real_x)*32-@mr
end
def sy
return $game_map.adjust_y(@real_y)*32-@mr
end
def sync(char)
@real_x = char.real_x
@real_y = char.real_y
end
def x
return (@real_x*32 - @mr).to_f
end
def y
return (@real_y*32 - @mr).to_f
end
def dispose
return if @bitmap.nil?
@bitmap.dispose
@bitmap = nil
end
end
class Light_DSource < Light_SSource
attr_reader :bitmap
attr_reader :visible
def initialize
@key = nil
@bitmap = nil
@opacity = 255
@plus = 0
@char = $game_player
@visible = false
end
def set_opacity(o,p)
@opacity = o
@plus = p
end
def set_graphic(sb)
dispose
@key = {2=>sb,4=>sb,6=>sb,8=>sb}
Light_Bitcore.push(sb)
@bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
@range = @bitmap[2].width/2
@w = @bitmap[2].width
@h = @bitmap[2].height
@mr = @range - 16
end
def set_multiple_graphics(ba)
dispose
@key = ba
@key.values.each {|key| Light_Bitcore.push(key)}
@bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
@range = @bitmap[2].width/2
@w = @bitmap[2].width
@h = @bitmap[2].height
@mr = @range - 16
end
def get_graphic
return @bitmap[@char.direction].clone
end
def show
return if @bitmap.nil?
@visible = true
end
def hide
@visible = false
end
def restore
return if @key.nil?
@key.values.each {|key| Light_Bitcore.push(key)}
@bitmap = {2=>Light_Bitcore[@key[2]].clone,4=>Light_Bitcore[@key[4]].clone,6=>Light_Bitcore[@key[6]].clone,8=>Light_Bitcore[@key[8]].clone}
end
def dispose
return if @bitmap.nil?
@bitmap.values.each { |b| b.dispose }
@bitmap = nil
end
def change_owner(char)
@char = char
end
def render
end
def sx
return $game_map.adjust_x(@char.real_x)*32-@mr
end
def sy
return $game_map.adjust_y(@char.real_y)*32-@mr
end
def x
return (@char.real_x*32 - @mr).to_f
end
def y
return (@char.real_y*32 - @mr).to_f
end
end
class Light_Surface
def initialize
@ta = @a = 0
@tr = @r = 255
@tg = @g = 255
@tb = @b = 255
@va = @vr = @vg = @vb = 0.0
@timer = 0
end
def refresh
return if @timer == 0
@a += @va
@r += @vr
@g += @vg
@b += @vb
$game_map.light_surface.opacity = @a
@timer -= 1
end
def change_color(time,r,g,b,a=nil)
r = 0 if r < 0; r = 255 if r > 255
g = 0 if g < 0; g = 255 if g > 255
b = 0 if b < 0; b = 255 if b > 255
unless a.nil?
a = 0 if a < 0; a = 255 if a > 255
end
@timer = time
@tr = 255-r
@tg = 255-g
@tb = 255-b
@va = (a.nil? ? 0 : (a-@a).to_f/@timer)
@vr = (@tr - @r).to_f/@timer
@vg = (@tg - @g).to_f/@timer
@vb = (@tb - @b).to_f/@timer
end
def change_alpha(time,a)
a = 0 if a < 0; a = 255 if a > 255
@timer = time
@ta = a
@vr = @vg = @vb = 0.0
@va = (a-@a).to_f/@timer
end
def set_color(r,g,b)
r = 0 if r < 0; r = 255 if r > 255
g = 0 if g < 0; g = 255 if g > 255
b = 0 if b < 0; b = 255 if b > 255
@tr = @r = 255-r
@tg = @g = 255-g
@tb = @b = 255-b
@va = @vr = @vg = @vb = 0.0
@timer = 0
end
def set_alpha(a)
a = 0 if a < 0; a = 255 if a > 255
@ta = @a = a
$game_map.light_surface.opacity = @a
@va = @vr = @vg = @vb = 0.0
@timer = 0
end
def alpha
return @a
end
def color
return Color.new(@r,@g,@b)
end
end
class Game_Map
include Light_Core
attr_accessor :light_surface
attr_accessor :light_sources
attr_accessor :surfaces
attr_accessor :effect_surface
attr_accessor :lantern
alias kbl_setup_events setup_events
alias kbl_initialize initialize
alias kbl_update update
def initialize
kbl_initialize
@effect_surface = Light_Surface.new
@lantern = Light_DSource.new
end
def update(arg)
@effect_surface.refresh if arg
kbl_update(arg)
end
def first_tag(x,y)
tag = tileset.flags[tile_id(x,y,0)] >> 12
return tag > 0 ? tag : 0
end
def setup_events
@light_sources.nil? ? @light_sources = [] : @light_sources.clear
setup_surfaces
merge_surfaces
kbl_setup_events
end
def setup_surfaces
@surfaces = []
for x in 0..(width-1)
for y in 0..(height-1)
tag = first_tag(x,y)
if tag == Wall_Tag
i = tile_id(x,y,0)
if i & 0x02 == 0x02
@surfaces << Block_SD.new(x*32,y*32,x*32+32,y*32)
end
if i & 0x04 == 0x04
@surfaces << Block_WR.new(x*32+31,y*32,x*32+31,y*32+32)
@surfaces << Block_IL.new(x*32+32,y*32,x*32+32,y*32+32)
end
if i & 0x01 == 0x01
@surfaces << Block_IR.new(x*32-1,y*32,x*32-1,y*32+32)
@surfaces << Block_WL.new(x*32,y*32,x*32,y*32+32)
end
elsif tag == Roof_Tag
i = tile_id(x,y,0)
@surfaces << Block_SU.new(x*32,y*32,x*32+32,y*32) if i & 0x02 == 0x02
@surfaces << Block_SR.new(x*32+31,y*32,x*32+31,y*32+32) if i & 0x04 == 0x04
@surfaces << Block_SL.new(x*32,y*32,x*32,y*32+32) if i & 0x01 == 0x01
elsif tag == Block_Tag
f = tileset.flags[tile_id(x,y,0)]
@surfaces << Block_SL.new(x*32,y*32,x*32,y*32+32) if f & 0x02 == 0x02
@surfaces << Block_SR.new(x*32+31,y*32,x*32+31,y*32+32) if f & 0x04 == 0x04
@surfaces << Block_SU.new(x*32,y*32,x*32+32,y*32) if f & 0x08 == 0x08
end
end
end
end
def merge_surfaces
new_surfaces = []
hs = []; vs = []
ws = []; is = []
for surface in @surfaces
if surface.type & 0x05 == 0
hs << surface
else
if surface.type & 0x010 == 0
vs << surface
else
if surface.type & 0x08 == 0
ws << surface
else
is << surface
end
end
end
end
for surface in hs
surface.ready ? next : surface.ready = true
for s in hs
next if s.ready || s.y1 != surface.y1 || surface.type != s.type
if s.x2 == surface.x1
surface.x1 = s.x1
s.trash = true
s.ready = true
surface.ready = false
elsif s.x1 == surface.x2
surface.x2 = s.x2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
hs.each { |s| @surfaces.delete(s) if s.trash}
for surface in vs
surface.ready ? next : surface.ready
for s in vs
next if s.ready || s.x1 != surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
vs.each { |s| @surfaces.delete(s) if s.trash}
for surface in ws
surface.ready ? next : surface.ready
for s in ws
next if s.ready || s.x1 != surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
ws.each { |s| @surfaces.delete(s) if s.trash}
for surface in is
surface.ready ? next : surface.ready
for s in is
next if s.ready || s.x1 != surface.x1
if s.y2 == surface.y1
surface.y1 = s.y1
s.trash = true
s.ready = true
surface.ready = false
elsif s.y1 == surface.y2
surface.y2 = s.y2
s.trash = true
s.ready = true
surface.ready = false
end
end
end
is.each { |s| @surfaces.delete(s) if s.trash}
end
end
class Game_Event < Game_Character
alias kbl_initialize initialize
alias kbl_setup_page setup_page
def initialize(m,e)
@light = nil
kbl_initialize(m,e)
end
def setup_page(np)
kbl_setup_page(np)
setup_light(np.nil?)
end
def setup_light(dispose)
unless @light.nil?
$game_map.light_sources.delete(self)
@light.dispose
@light = nil
end
unless dispose && @list.nil?
for command in @list
if command.code == 108 && command.parameters[0].include?("[light")
command.parameters[0].scan(/\[light ([0.0-9.9]+)\]/)
effect = Light_Core::Effects[$1.to_i]
@light = Light_SSource.new(self,effect[0],effect[1],effect[2],effect[3])
$game_map.light_sources << self
return
end
end
end
end
def draw_light
sx = @light.sx
sy = @light.sy
w = @light.w
h = @light.h
return if sx > 544 && sy > 416 && sx + w < 0 && sy + h < 0
$game_map.light_surface.bitmap.blt(sx,sy,@light.bitmap,Rect.new(0,0,w,h),@light.opacity)
end
def dispose_light
@light.dispose
end
def restore_light
@light.restore
end
end
if Light_Core::Surface_UE
class Game_Interpreter
def command_223
$game_map.effect_surface.change_color(@params[1],@params[0].red,@params[0].green,@params[0].blue,@params[0].gray)
wait(@params[1]) if @params[2]
end
end
end
class Game_Interpreter
def self_event
return $game_map.events[@event_id]
end
end
class Block_Surface
include Light_Core
attr_accessor :x1
attr_accessor :y1
attr_accessor :x2
attr_accessor :y2
attr_accessor :ready
attr_accessor :trash
def initialize(x1,y1,x2,y2)
@x1 = x1
@y1 = y1
@x2 = x2
@y2 = y2
@ready = false
@trash = false
end
def within?(min_x,max_x,min_y,max_y)
return @x2 > min_x && @x1 < max_x && @y2 > min_y && @y1 < max_y
end
end
class Block_SL < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x01
end
def visible?(sx,sy)
return sx < @x1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = sy - @m1*sx
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
for x in @x1..(sx+range)
init = shadow_iy(x)
bitmap.clear_rect(x-phx,init-phy,1,shadow_fy(x)-init+3)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_SR < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x04
end
def visible?(sx,sy)
return sx > @x1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = sy - @m1*sx
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
for x in (sx-range).to_i..@x1
init = shadow_iy(x)
bitmap.clear_rect(x-phx,init-phy,1,shadow_fy(x)-init+3)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_IL < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x019
end
def visible?(sx,sy)
return sx < @x1 && sy > @y1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = @y1 - @m1*@x1
@m2 = (@y2-sy)/(@x2-sx)
@m2 = 0 if @m2 > 0
@n2 = @y2 - @m2*@x2
for x in @x1..(sx+range)
init = shadow_iy(x).floor
bitmap.clear_rect(x-phx,init-3-phy,1,shadow_fy(x)-init+3)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_IR < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x01c
end
def visible?(sx,sy)
return sx > @x1 && sy > @y1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = @y1 - @m1*@x1
@m2 = (@y2-sy)/(@x2-sx)
@m2 = 0 if @m2 < 0
@n2 = @y2 - @m2*@x2
for x in (sx-range).to_i..@x1
init = shadow_iy(x).floor
bitmap.clear_rect(x-phx,init-3-phy,1,shadow_fy(x)-init+3)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_WL < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x011
end
def visible?(sx,sy)
return sx < @x1 && sy < @y2
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = sy - @m1*sx
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
for x in @x1..(sx+range)
init = shadow_iy(x)
bitmap.clear_rect(x-phx,init-phy,1,shadow_fy(x)-init+2)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_WR < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x014
end
def visible?(sx,sy)
return sx > @x1 && sy < @y2
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
@m1 = (@y1-sy)/(@x1-sx)
@n1 = sy - @m1*sx
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
for x in (sx-range).to_i..@x1
init = shadow_iy(x)
bitmap.clear_rect(x-phx,init-phy,1,shadow_fy(x)-init+2)
end
end
def shadow_iy(x)
return @m1*x+@n1
end
def shadow_fy(x)
return @m2*x+@n2
end
end
class Block_SU < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x02
end
def visible?(sx,sy)
return sy < @y1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
if @x1 == sx
@m1 = nil
else
@m1 = (@y1-sy)/(@x1-sx)
@m1 += ACC if @m1 < -ACC
@n1 = @y1 - @m1*@x1
end
if @x2 == sx
@m2 = nil
else
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
end
for y in @y1..(sy+range)
init = shadow_ix(y)
bitmap.clear_rect(init-phx,y-phy,shadow_fx(y)-init+1,1)
end
end
def shadow_ix(y)
return @m1.nil? ? @x1 : (y-@n1)/@m1
end
def shadow_fx(y)
return @m2.nil? ? @x2 : (y-@n2)/@m2
end
end
class Block_SD < Block_Surface
attr_reader :type
def initialize(x1,y1,x2,y2)
super(x1,y1,x2,y2)
@type = 0x08
end
def visible?(sx,sy)
return sy > @y1
end
def render_shadow(phx,phy,sx,sy,range,bitmap)
if @x1 == sx
@m1 = nil
else
@m1 = (@y1-sy)/(@x1-sx)
@m1 -= ACC if @m1 > ACC
@n1 = sy - @m1*sx
end
if x2 == sx
@m2 = nil
else
@m2 = (@y2-sy)/(@x2-sx)
@n2 = sy - @m2*sx
end
for y in (sy-range).to_i..@y1
init = shadow_ix(y)
bitmap.clear_rect(init-phx,y-phy,shadow_fx(y)-init+1,1)
end
end
def shadow_ix(y)
return @m1.nil? ? @x1 : (y-@n1)/@m1
end
def shadow_fx(y)
return @m2.nil? ? @x2 : (y-@n2)/@m2
end
end
class Spriteset_Map
include Light_Core
alias kbl_initialize initialize
alias kbl_update update
alias kbl_dispose dispose
def initialize
setup_lights
kbl_initialize
end
def update
kbl_update
update_lights
end
def dispose
kbl_dispose
dispose_lights
end
def dispose_lights
$game_map.lantern.dispose
$game_map.light_sources.each { |source| source.dispose_light }
$game_map.light_surface.bitmap.dispose
$game_map.light_surface.dispose
$game_map.light_surface = nil
end
def update_lights
$game_map.light_surface.bitmap.clear
$game_map.light_surface.bitmap.fill_rect(0,0,544,416,$game_map.effect_surface.color)
$game_map.light_sources.each { |source| source.draw_light }
return unless $game_map.lantern.visible
@btr = $game_map.lantern.get_graphic
x = $game_map.lantern.x
y = $game_map.lantern.y
r = $game_map.lantern.range
sx = x + r
sy = y + r
dr = r*2
$game_map.surfaces.each { |s| s.render_shadow(x,y,sx,sy,r,@btr) if s.visible?(sx,sy) && s.within?(x,x+dr,y,y+dr) }
$game_map.light_surface.bitmap.blt($game_map.lantern.sx,$game_map.lantern.sy,@btr,Rect.new(0,0,dr,dr),$game_map.lantern.opacity)
end
def setup_lights
@btr = nil
$game_map.lantern.restore
$game_map.light_sources.each { |source| source.restore_light }
$game_map.light_surface = Sprite.new
$game_map.light_surface.bitmap = Bitmap.new(544,416)
$game_map.light_surface.bitmap.fill_rect(0,0,544,416,$game_map.effect_surface.color)
$game_map.light_surface.blend_type = 2
$game_map.light_surface.opacity = $game_map.effect_surface.alpha
$game_map.light_surface.z = Surface_Z
end
end
RPGMAKERVXACE - Khas Self Switches
#-------------------------------------------------------------------------------
# * Khas Self Switches
#-------------------------------------------------------------------------------
# * By Khas Arcthunder
# * Version: 1.0
# * Released on: 11/09/2012
#
# * Blog: http://arcthunder.com/
# * Forum: http://rgssx.com/
# * Twitter: http://twitter.com/arcthunder
# * Youtube: http://youtube.com/user/darkkhas
#
#-------------------------------------------------------------------------------
# Terms of Use | Termos de Uso
#-------------------------------------------------------------------------------
# * ENGLISH
# Read updated terms of use at http://arcthunder.com/terms
#
# * PORTUGUES
# Leia os termos atualizados em http://arcthunder.com/termos
#
#-------------------------------------------------------------------------------
# How to use - English Instructions
#-------------------------------------------------------------------------------
# You can use Call Script with the following commands:
#
# Switch_Core.toggle(event_id,switch)
# Toggle a switch. If it's ON, this command will turn it to OFF. And if it's
# OFF, this command will turn it to ON.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
#
# Switch_Core.toggle(event_id,switch,map_id)
# Toggle a switch. If it's ON, this command will turn it to OFF. And if it's
# OFF, this command will turn it to ON.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
# map_id -> ID of the map
#
# Switch_Core.turn_on(event_id,switch)
# Turn ON command.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
#
# Switch_Core.turn_on(event_id,switch,map_id)
# Turn ON command.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
# map_id -> ID of the map
#
# Switch_Core.turn_off(event_id,switch)
# Turn OFF command.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
#
# Switch_Core.turn_off(event_id,switch,map_id)
# Turn OFF command.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
# map_id -> ID of the map
#
# Switch_Core.set(event_id,switch,value)
# Set command. If value is true, it will be turned ON. If value is false,
# it will be turned OFF.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
# value -> Can be true or false
#
# Switch_Core.set(event_id,switch,value,map_id)
# Set command. If value is true, it will be turned ON. If value is false,
# it will be turned OFF.
# event_id -> The ID of the event
# switch -> Can be "A", "B", "C" or "D"
# value -> Can be true or false
# map_id -> ID of the map
#
#-------------------------------------------------------------------------------
#
# Switch_Core.toggle_all(event_id)
# Toggle all the event's self switches.
# event_id -> The ID of the event
#
# Switch_Core.toggle_all(event_id,map_id)
# Toggle all the event's self switches.
# event_id -> The ID of the event
# map_id -> ID of the map
#
# Switch_Core.turn_on_all(event_id)
# Turn ON all the event's self switches.
# event_id -> The ID of the event
#
# Switch_Core.turn_on_all(event_id,map_id)
# Turn ON all the event's self switches.
# event_id -> The ID of the event
# map_id -> ID of the map
#
# Switch_Core.turn_off_all(event_id)
# Turn OFF all the event's self switches.
# event_id -> The ID of the event
#
# Switch_Core.turn_off_all(event_id,map_id)
# Turn OFF all the event's self switches.
# event_id -> The ID of the event
# map_id -> ID of the map
#
# Switch_Core.set_all(event_id,value)
# Set all command. If value is true, all self switches will be turned ON. If
# value is false, all self switches will be turned OFF.
# event_id -> The ID of the event
# value -> Can be true or false
#
# Switch_Core.set_all(event_id,value,map_id)
# Set all command. If value is true, all self switches will be turned ON. If
# value is false, all self switches will be turned OFF.
# event_id -> The ID of the event
# value -> Can be true or false
# map_id -> ID of the map
#
#-------------------------------------------------------------------------------
# Como usar - Instruções em Português
#-------------------------------------------------------------------------------
# Você pode usar o Chamar Script com os seguintes comandos:
#
# Switch_Core.toggle(event_id,switch)
# Alterna o switch. Se ele estiver ligado, será então desligado. Se ele estiver
# ligado, será então desligado.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
#
# Switch_Core.toggle(event_id,switch,map_id)
# Alterna o switch. Se ele estiver ligado, será então desligado. Se ele estiver
# ligado, será então desligado.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
# map_id -> ID do Mapa
#
# Switch_Core.turn_on(event_id,switch)
# Comando que liga o switch.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
#
# Switch_Core.turn_on(event_id,switch,map_id)
# Comando que liga o switch.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
# map_id -> ID do Mapa
#
# Switch_Core.turn_off(event_id,switch)
# Comando que desliga o switch.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
#
# Switch_Core.turn_off(event_id,switch,map_id)
# Comando que desliga o switch.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
# map_id -> ID do Mapa
#
# Switch_Core.set(event_id,switch,value)
# Comando que ajusta o switch. Se value for true, o switch será ligado. Se
# value for false, o switch será desligado.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
# value -> Pode ser true ou false
#
# Switch_Core.set(event_id,switch,value,map_id)
# Comando que ajusta o switch. Se value for true, o switch será ligado. Se
# value for false, o switch será desligado.
# event_id -> O ID do evento
# switch -> Pode ser "A", "B", "C" ou "D"
# value -> Pode ser true ou false
# map_id -> ID do Mapa
#
#-------------------------------------------------------------------------------
#
# Switch_Core.toggle_all(event_id)
# Alterna todos os switches locais do evento.
# event_id -> O ID do evento
#
# Switch_Core.toggle_all(event_id,map_id)
# Alterna todos os switches locais do evento.
# event_id -> O ID do evento
# map_id -> ID do Mapa
#
# Switch_Core.turn_on_all(event_id)
# Liga todos os switches do evento.
# event_id -> O ID do evento
#
# Switch_Core.turn_on_all(event_id,map_id)
# Liga todos os switches do evento.
# event_id -> O ID do evento
# map_id -> ID do Mapa
#
# Switch_Core.turn_off_all(event_id)
# Desliga todos os switches do evento.
# event_id -> O ID do evento
#
# Switch_Core.turn_off_all(event_id,map_id)
# Desliga todos os switches do evento.
# event_id -> O ID do evento
# map_id -> ID do Mapa
#
# Switch_Core.set_all(event_id,value)
# Ajusta todos os switches do evento.
# event_id -> O ID do evento
# value -> Pode ser true ou false
#
# Switch_Core.set_all(event_id,value,map_id)
# Ajusta todos os switches do evento.
# event_id -> O ID do evento
# value -> Pode ser true ou false
# map_id -> ID do Mapa
#
#-------------------------------------------------------------------------------
# Script
#-------------------------------------------------------------------------------
module Switch_Core
Switch_Array = ["A","B","C","D"]
def self.toggle(ei,si,mi=$game_map.map_id)
$game_self_switches[[mi,ei,si]] = !$game_self_switches[[mi,ei,si]]
end
def self.turn_on(ei,si,mi=$game_map.map_id)
$game_self_switches[[mi,ei,si]] = true
end
def self.turn_off(ei,si,mi=$game_map.map_id)
$game_self_switches[[mi,ei,si]] = false
end
def self.set(ei,si,pi,mi=$game_map.map_id)
$game_self_switches[[mi,ei,si]] = pi
end
def self.toggle_all(ei,mi=$game_map.map_id)
Switch_Array.each {|key| toggle(ei,key,mi)}
end
def self.turn_on_all(ei,mi=$game_map.map_id)
Switch_Array.each {|key| turn_on(ei,key,mi)}
end
def self.turn_off_all(ei,mi=$game_map.map_id)
Switch_Array.each {|key| turn_off(ei,key,mi)}
end
def self.set_all(ei,pi,mi=$game_map.map_id)
Switch_Array.each {|key| set(ei,key,pi,mi)}
end
end
RPGMAKERVXACE - Item Popup
#===============================================================
# Item Popup
# Compativel com RMVXAce
# Autor: Raizen
# Comunidade : www.centrorpg.com
# É permitido postar em outros lugares contanto que não seja mudado
# as linhas dos créditos.
#===============================================================
# Item Popup
# Descrição: O Item Popup, é um efeito que ao receber itens
# no decorrer do jogo, ele será mostrado sobre o personagem
module Raizenpop
#Switch que ativa o script, sempre que não quiser que esteja
#ativado o efeito de popup, basta desligar o switch.
SWITCH = 1
# Ajuste em x, aqui da para posicionar a coordenada inicial que
# o item pop-up fará. Valores menores aproximam o Item popup para a direita.
PX = 40
# Ajuste em y, aqui da para posicionar a coordenada inicial que
# o item pop-up fará. Valores menores aproximam o Item popup para baixo.
PY = 90
# tempo que levará para sumir o item popup, o valor está em frames
# em que 60frames = 1 segundo
TIME = 40
# distancia que subirá o item popup, medido em pixels, sendo que o valor
# 0 desliga o movimento do item popup.
DIST = 50
# mostrar a quantidade de itens recebidos?
Mostrar = true
# Som que tocará quando for ativado o popup, caso não queira som algum coloque
# duas aspas desse modo "" . Caso queira adicionar algum som, colocar na pasta
# SE dentro da pasta Audio do projeto e colocar o nome do arquivo aqui.
SOUND = "Chime2"
# Som do popup de gold
SOUND2 = "Coin"
# Número do icone de gold.
ICON = 361
end
# Aqui começa o script, modifique apenas se sabe o que esta fazendo.
module SceneManager
def self.raizen_initialize(item, n)
@scene.raizen_initialize(item, n, Raizenpop::DIST)
end
def self.raizen_gold(n)
@scene.raizen_gold(n, Raizenpop::DIST)
end
end
class Window_Popup < Window_Base
def initialize(x, y, item, n, jy)
super(x, y, x + 544, y + 416)
self.opacity = 0
refresh(item, n, $game_player.screen_x - Raizenpop::PX, $game_player.screen_y - Raizenpop::PY + jy)
end
def refresh(item, n, x, y)
self.contents.clear
if n != 0
self.contents.font.size = 16
if item != 0 and item != nil
draw_icon(item.icon_index, x, y)
self.contents.draw_text(x + 0, y - 10, 100, 50, item.name, 1)
self.contents.draw_text(x - 66, y + 10, 100, 50, "x", 2) if Raizenpop::Mostrar
self.contents.draw_text(x - 46, y + 10, 100, 50, n, 2) if Raizenpop::Mostrar
else
draw_icon(Raizenpop::ICON, x, y)
self.contents.draw_text(x + 26, y - 10, 100, 50, "x", 0) if Raizenpop::Mostrar
self.contents.draw_text(x + 40, y - 10, 100, 50, n, 0) if Raizenpop::Mostrar
end
end
end
end
class Game_Interpreter
def command_125
value = operate_value(@params[0], @params[1], @params[2])
$game_party.gain_gold_raizen(value)
end
def command_126
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item_raizen($data_items[@params[0]], value)
end
def command_127
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item_raizen($data_weapons[@params[0]], value, @params[4])
end
def command_128
value = operate_value(@params[1], @params[2], @params[3])
$game_party.gain_item_raizen($data_armors[@params[0]], value, @params[4])
end
end
class Game_Party < Game_Unit
def gain_item_raizen(item, amount, include_equip = false)
container = item_container(item.class)
return unless container
last_number = item_number(item)
new_number = last_number + amount
container[item.id] = [[new_number, 0].max, max_item_number(item)].min
container.delete(item.id) if container[item.id] == 0
if include_equip && new_number < 0
discard_members_equip(item, -new_number)
end
$game_map.need_refresh = true
if $game_switches[Raizenpop::SWITCH]
SceneManager.raizen_initialize(item, amount)
RPG::SE.new(Raizenpop::SOUND).play
end
end
def gain_gold_raizen(amount)
@gold = [[@gold + amount, 0].max, max_gold].min
if $game_switches[Raizenpop::SWITCH]
SceneManager.raizen_gold(amount)
RPG::SE.new(Raizenpop::SOUND2).play
end
end
end
class Scene_Map < Scene_Base
alias initializeraizen start
def start
@popup = Window_Popup.new(0, 0, 0, 0, 0)
initializeraizen
end
def raizen_initialize(item, n, jy)
@popup.refresh(item, n, $game_player.screen_x - Raizenpop::PX, $game_player.screen_y - Raizenpop::PY + jy)
@item22 = item ; @n22 = n ; @jy22 = jy
end
def raizen_gold(g, jy)
@popup.refresh(0, g, $game_player.screen_x - Raizenpop::PX, $game_player.screen_y - Raizenpop::PY + jy)
@n22 = g ; @jy22 = jy ; @item22 = 0
end
alias raizen_update update
def update
raizen_update
if @n22 != nil
@jy22 -= 1
@contador22 = 0 if @jy22 == 2
if @jy22 >= 0
raizen_initialize(@item22, @n22, @jy22)
else
@contador22 += 1
if @contador22 <= Raizenpop::TIME
raizen_initialize(@item22, @n22, 0)
else
raizen_initialize(@item22, 0, 0)
@gold = nil
@n22 = nil
@item22 = nil
end
end
end
end
end
RPGMAKERVXACE - Apresenta o um texto em cima do evento.
#==============================================================================
# +++ MOG - Event Text Popup (v1.0) +++
#==============================================================================
# By Moghunter
# http://www.atelier-rgss.com
#==============================================================================
# Apresenta o um texto em cima do evento.
#==============================================================================
# Para ativa basta colocar um comentário com o prefixo:
#
# <Text - X>
#
# X - Texto apresentado no evento.
#
# Exemplo
#
# <Text - Teleport>
# <Text - Save Point>
#
#==============================================================================
module MOG_EVENT_TEXT_POPUP
#Definição da fonte.
FONT_NAME = "Verdana"
FONT_SIZE = 16
FONT_BOLD = true
FONT_COLOR = Color.new(255,255,255)
#Definição da prioridade do Texto
SCREEN_Z = 1
end
#==============================================================================
# ■ Game CharacterBase
#==============================================================================
class Game_CharacterBase
attr_accessor :text
attr_accessor :opacity
attr_accessor :erased
end
#==============================================================================
# ■ Game Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_event_text_initialize initialize
def initialize(map_id, event)
mog_event_text_initialize(map_id, event)
end
#--------------------------------------------------------------------------
# ● Setup Page Setting
#--------------------------------------------------------------------------
alias mog_event_text_setup_page_settings setup_page_settings
def setup_page_settings
mog_event_text_setup_page_settings
setup_event_text
end
#--------------------------------------------------------------------------
# ● Setup Event Text
#--------------------------------------------------------------------------
def setup_event_text
return if @list == nil
for command in @list
if command.code == 108
if command.parameters[0] =~ /<Text = ([^>]*)>/
@text = $1
end
end
end
end
end
#==============================================================================
# ■ Sprite Character Text
#==============================================================================
class Sprite_Character_Text < Sprite_Base
include MOG_EVENT_TEXT_POPUP
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
def initialize(viewport = nil,character,sprite)
super(viewport)
text_size = character.text.to_s.split(//)
w = 32 + (FONT_SIZE / 2) * text_size.size rescue nil
w = 32 if w == nil or w < 32
self.bitmap = Bitmap.new(w,32)
self.bitmap.font.name = FONT_NAME
self.bitmap.font.size = FONT_SIZE
self.bitmap.font.bold = FONT_BOLD
self.bitmap.font.color = FONT_COLOR
self.bitmap.draw_text(0,0,self.width,self.height,character.text.to_s,1) rescue nil
update_position(character,sprite)
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
def dispose
super
self.bitmap.dispose
end
#--------------------------------------------------------------------------
# ● Update Position
#--------------------------------------------------------------------------
def update_position(character,sprite)
if character.erased
self.visible = false
return
end
self.x = character.screen_x - self.width / 2
self.y = character.screen_y - (sprite.height + self.height)
self.z = character.screen_z + SCREEN_Z
self.visible = character.transparent == true ? false : true
self.opacity = character.opacity
end
end
#==============================================================================
# ■ Sprite Character
#==============================================================================
class Sprite_Character < Sprite_Base
#--------------------------------------------------------------------------
# ● Initialize
#--------------------------------------------------------------------------
alias mog_event_text_initialize initialize
def initialize(viewport, character = nil)
mog_event_text_initialize(viewport, character)
@character_text = ""
create_event_text
end
#--------------------------------------------------------------------------
# ● Create Event Text
#--------------------------------------------------------------------------
def create_event_text
return if @character == nil
return if @character.text == nil
return if @character.text == @character_text
dispose_event_text
@event_text = Sprite_Character_Text.new(viewport,@character,self)
@character_text = @character.text
end
#--------------------------------------------------------------------------
# ● Dispose
#--------------------------------------------------------------------------
alias mog_event_text_dispose dispose
def dispose
mog_event_text_dispose
dispose_event_text
end
#--------------------------------------------------------------------------
# ● Dispose Event Text
#--------------------------------------------------------------------------
def dispose_event_text
return if @event_text == nil
@event_text.dispose
@event_text = nil
end
#--------------------------------------------------------------------------
# ● Update
#--------------------------------------------------------------------------
alias mog_event_text_update update
def update
mog_event_text_update
create_event_text
update_event_text
end
#--------------------------------------------------------------------------
# ● Update Event Text
#--------------------------------------------------------------------------
def update_event_text
return if @event_text == nil
@event_text.update_position(@character,self)
end
end
$mog_rgss3_event_text_popup = true
RPGMAKERVXACE - VXAce_SP1
# =================================================
# ■ VXAce_SP1
# -------------------------------------------------
# Eu Corrigido um bug no script pré-definido.
#Usuário material definido script,
# Por favor, lugar abaixo nesta seção como uma regra geral.
# =================================================
# -------------------------------------------------
# [Modificações]
# -------------------------------------------------
# ● em caso alterações de estado de comando,
#a libertação real, ao mesmo tempo, com a adição de um mesmo estado
# Quando a linha, eu reparado um bug que a adição posterior de dois falhar.
# Comando de evento
#● na animação ver a animação, da carta apresentada
# Corrigido um bug que eu não quero para sincronizar fracasso de rolagem.
# ● eu reparado um bug onde a ação de combate automático
#não está selecionado corretamente.
# Equipamento
#● por equipamentos que já não pode ser removido,
#nenhum outro equipamento pode ser equipado com ainda mais
# Quando é, eu reparado um bug que o equipamento enquanto o seu crescimento.
# ● o problema que uma carga extra no comando
#após a execução do evento [Imagem Clear]
# Eu fixo.
# ● Com a opção marcada para rota de migração
#[Se você não pode mover o skip] para
# Se você entrar em contato com o evento de disparo
#[contato do jogador, o evento está em andamento
# Corrigido um bug que eu começar a reservar eu teria sido tão bem.
# ● Corrigido um bug que não reflete a eficácia do Estado
#contra a habilidade mágica que foi refletido
# Eu era.
# ● Mesmo que você tenha ativado as configurações padrão
#em fontes em negrito ou itálico, o estado de tela
# Eu reparado um bug que volta a um estado inválido,
#como quando você mudar a superfície.
# -------------------------------------------------
class Game_Battler
attr_accessor :magic_reflection
#--------------------------------------------------------------------------
# ● A determinação da relação de oposição
#--------------------------------------------------------------------------
alias vxace_sp1_opposite? opposite?
def opposite?(battler)
vxace_sp1_opposite?(battler) || battler.magic_reflection
end
end
#------------------------------------------------------------------------------
class Game_Actor
#--------------------------------------------------------------------------
# ● Remover o material não pode ser equipado com
# item_gain : Equipamento devolvido ao partido que foi removido
#--------------------------------------------------------------------------
alias vxace_sp1_release_unequippable_items release_unequippable_items
def release_unequippable_items(item_gain = true)
loop do
last_equips = equips.dup
vxace_sp1_release_unequippable_items(item_gain)
return if equips == last_equips
end
end
#--------------------------------------------------------------------------
# ● Criar combate automático em combate
#--------------------------------------------------------------------------
def make_auto_battle_actions
@actions.size.times do |i|
@actions[i] = make_action_list.max_by {|action| action.value }
end
end
end
#------------------------------------------------------------------------------
class Game_Player
#--------------------------------------------------------------------------
# ● Iniciando o mapa do evento
# triggers : Matriz de gatilho
# normal : Prioridade ou de outra forma ou [mesmo que de caráter normal]
#--------------------------------------------------------------------------
alias vxace_sp1_start_map_event start_map_event
def start_map_event(x, y, triggers, normal)
return if $game_map.interpreter.running?
vxace_sp1_start_map_event(x, y, triggers, normal)
end
end
#------------------------------------------------------------------------------
class Game_Picture
#--------------------------------------------------------------------------
# ● Imagem clara
#--------------------------------------------------------------------------
alias vxace_sp1_erase erase
def erase
vxace_sp1_erase
@origin = 0
end
end
#------------------------------------------------------------------------------
class Game_Interpreter
#--------------------------------------------------------------------------
# ● Mudança de estado
#--------------------------------------------------------------------------
alias vxace_sp1_command_313 command_313
def command_313
vxace_sp1_command_313
$game_party.clear_results
end
end
#------------------------------------------------------------------------------
class Sprite_Character
#--------------------------------------------------------------------------
# ● Local de atualização
#--------------------------------------------------------------------------
alias vxace_sp1_update_position update_position
def update_position
move_animation(@character.screen_x - x, @character.screen_y - y)
vxace_sp1_update_position
end
#--------------------------------------------------------------------------
# ● Movendo animação
#--------------------------------------------------------------------------
def move_animation(dx, dy)
if @animation && @animation.position != 3
@ani_ox += dx
@ani_oy += dy
@ani_sprites.each do |sprite|
sprite.x += dx
sprite.y += dy
end
end
end
end
#------------------------------------------------------------------------------
class Sprite_Picture
#--------------------------------------------------------------------------
# ● Atualização do bitmap de origem
#--------------------------------------------------------------------------
alias vxace_sp1_update_bitmap update_bitmap
def update_bitmap
if @picture.name.empty?
self.bitmap = nil
else
vxace_sp1_update_bitmap
end
end
end
#------------------------------------------------------------------------------
class Window_Base
#--------------------------------------------------------------------------
# ● Redefinir as configurações de fonte
#--------------------------------------------------------------------------
alias vxace_sp1_reset_font_settings reset_font_settings
def reset_font_settings
vxace_sp1_reset_font_settings
contents.font.bold = Font.default_bold
contents.font.italic = Font.default_italic
end
end
#------------------------------------------------------------------------------
class Scene_Battle
#--------------------------------------------------------------------------
# ● Ativação reflexa da magia
#--------------------------------------------------------------------------
alias vxace_sp1_invoke_magic_reflection invoke_magic_reflection
def invoke_magic_reflection(target, item)
@subject.magic_reflection = true
vxace_sp1_invoke_magic_reflection(target, item)
@subject.magic_reflection = false
end
end
RPGMAKERVXACE - PACOTE DE CORREÇÕES PARA RMVXACE DO YANFLY:
#==============================================================================
# PACOTE DE CORREÇÕES PARA RMVXACE DO YANFLY:
# Pacote com algumas correções básicas para RMVXAce, tirando as modificações e
# possibilidades de customização do script original. Essencial para corrigir
# vários bugs do jogo já presentes na engine padrão do RGSS3;
# Baseado no "Yanfly Engine Ace - Ace Core Engine v1.00 Versão Traduzida".
#
# Todos os créditos vão para:
# - Yanfly (http://yanflychannel.wordpress.com/)
# Tradução do cabeçalho para Português por:
# - Tradutor (http://makercafe.blogspot.com/)
# Edições e adaptações por:
# - Rafael_Sol_Maker (http://www.condadobraveheart.com/)
#
#==============================================================================
#==============================================================================
# INSTRUÇÕES:
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Para instalar este script, abra seu editor de scripts copie e cole este script
# em um slot aberto abaixo de "Scripts Adicionais", mas acima de Main. Lembre-se
# de salvar.
#
#==============================================================================
# COMPATIBILIDADE:
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Este script é feito estritamente para o RPG Maker VX Ace. É improvável que
# seja executado com o RPG Maker VX sem que precise de ajustes.
#
#==============================================================================
#==============================================================================
# CONTEÚDOS DO SCRIPT:
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Correção de Erro: Sobreposição da Animação
# -----------------------------------------------------------------------------
# - É o mesmo erro do VX. Quando uma animação de tela inteira é reproduzida
# contra um grupo de inimigos, o bitmap da animação é na verdade reproduzido
# várias vezes, causando uma extrema sobreposição quando há muitos inimigos na
# tela. Essa correção fará com que a animação se reproduza apenas uma vez.
#
# -----------------------------------------------------------------------------
# Correção de Erro: Correção da Ordem do Turno da Batalha
# -----------------------------------------------------------------------------
# - Mesmo erro do VX. Para aqueles que usam o sistema de batalha padrão, uma vez
# que um turno começou, a ordem de ação se configura e é inalterada durante o
# restante do turno. Quaisquer alterações na AGI do combatente não serão feitas,
# mesmo que o combatente receba um acréscimo ou decréscimo na AGI.
# Essa correção faz com que a AGI seja atualizada corretamente a cada ação.
#
# -----------------------------------------------------------------------------
# Correção de Erro: Correção da Sobreposição dos Medidores
# -----------------------------------------------------------------------------
# - Mesmo erro do VX. Quando algumas variáveis excedem determinados valores, os
# medidores podem extrapolar a largura para a qual eles foram originalmente
# projetados. Essa correção irá evitar que os medidores passem da largura
# máxima. (N.E.: E ainda coloca uma borda em volta deles!)
#
# -----------------------------------------------------------------------------
# Correção de Erro: Rolagem do Menu Segurando L e R
# -----------------------------------------------------------------------------
# - Antes, no VX, você podia navegar através de menus rapidamente pressionando
# os botões L e R (Q e W no teclado). Essa correção recupera a capacidade de
# percorrer os menus dessa forma.
#
# -----------------------------------------------------------------------------
# Correção de Erro: Rolagem no Mapa, Se Menor que a Tela
# -----------------------------------------------------------------------------
# - Uma pequena correção que permita que mapas menores que a tela (17x13, na
# resolução padrão) apresentem erros na hora do movimento da tela , o "scroll".
# É útil principalmente para quem utiliza a resolução de 640x480, e faz mapas
# do tamanho mínimo que o editor permite.
#
#==============================================================================
#==============================================================================
# ¦ BattleManager
#==============================================================================
module BattleManager
#--------------------------------------------------------------------------
# overwrite method: turn_start
#--------------------------------------------------------------------------
def self.turn_start
@phase = :turn
clear_actor
$game_troop.increase_turn
@performed_battlers = []
make_action_orders
end
#--------------------------------------------------------------------------
# overwrite method: next_subject
#--------------------------------------------------------------------------
def self.next_subject
@performed_battlers = [] if @performed_battlers.nil?
loop do
@action_battlers -= @performed_battlers
battler = @action_battlers.shift
return nil unless battler
next unless battler.index && battler.alive?
return battler
end
end
end # BattleManager
#==============================================================================
# ¦ Game_Battler
#==============================================================================
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :pseudo_ani_id
#--------------------------------------------------------------------------
# alias method: clear_sprite_effects
#--------------------------------------------------------------------------
alias game_battler_clear_sprite_effects_ace clear_sprite_effects
def clear_sprite_effects
game_battler_clear_sprite_effects_ace
@pseudo_ani_id = 0
end
end # Game_Battler
#==============================================================================
# ¦ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# overwrite method: setup
#--------------------------------------------------------------------------
def setup(troop_id)
clear
@troop_id = troop_id
@enemies = []
troop.members.each do |member|
next unless $data_enemies[member.enemy_id]
enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
enemy.hide if member.hidden
enemy.screen_x = member.x + (Graphics.width - 544)/2
enemy.screen_y = member.y + (Graphics.height - 416)
@enemies.push(enemy)
end
init_screen_tone
make_unique_names
end
end # Game_Troop
#==============================================================================
# ¦ Game_Map
#==============================================================================
class Game_Map
#--------------------------------------------------------------------------
# overwrite method: scroll_down
#--------------------------------------------------------------------------
def scroll_down(distance)
if loop_vertical?
@display_y += distance
@display_y %= @map.height * 256
@parallax_y += distance
else
last_y = @display_y
dh = Graphics.height > height * 32 ? height : (Graphics.height / 32)
@display_y = [@display_y + distance, (height - dh) * 256].min
@parallax_y += @display_y - last_y
end
end
#--------------------------------------------------------------------------
# overwrite method: scroll_right
#--------------------------------------------------------------------------
def scroll_right(distance)
if loop_horizontal?
@display_x += distance
@display_x %= @map.width * 256
@parallax_x += distance
else
last_x = @display_x
dw = Graphics.width > width * 32 ? width : (Graphics.width / 32)
@display_x = [@display_x + distance, (width - dw) * 256].min
@parallax_x += @display_x - last_x
end
end
end # Game_Map
#==============================================================================
# ¦ Game_Event
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# overwrite method: near_the_screen?
#--------------------------------------------------------------------------
def near_the_screen?(dx = nil, dy = nil)
dx = [Graphics.width, $game_map.width * 256].min/32 - 5 if dx.nil?
dy = [Graphics.height, $game_map.height * 256].min/32 - 5 if dy.nil?
ax = $game_map.adjust_x(@real_x) - Graphics.width / 2 / 32
ay = $game_map.adjust_y(@real_y) - Graphics.height / 2 / 32
ax >= -dx && ax <= dx && ay >= -dy && ay <= dy
end
end # Game_Event
#==============================================================================
# ¦ Sprite_Base
#==============================================================================
class Sprite_Base < Sprite
#--------------------------------------------------------------------------
# new method: start_pseudo_animation
#--------------------------------------------------------------------------
def start_pseudo_animation(animation, mirror = false)
dispose_animation
@animation = animation
return if @animation.nil?
@ani_mirror = mirror
set_animation_rate
@ani_duration = @animation.frame_max * @ani_rate + 1
@ani_sprites = []
end
end # Sprite_Base
#==============================================================================
# ¦ Sprite_Battler
#==============================================================================
class Sprite_Battler < Sprite_Base
#--------------------------------------------------------------------------
# alias method: setup_new_animation
#--------------------------------------------------------------------------
alias sprite_battler_setup_new_animation_ace setup_new_animation
def setup_new_animation
sprite_battler_setup_new_animation_ace
return if @battler.pseudo_ani_id <= 0
animation = $data_animations[@battler.pseudo_ani_id]
mirror = @battler.animation_mirror
start_pseudo_animation(animation, mirror)
@battler.pseudo_ani_id = 0
end
end # Sprite_Battler
#==============================================================================
# ¦ Spriteset_Map
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# overwrite method: create_viewports
#--------------------------------------------------------------------------
def create_viewports
if Graphics.width > $game_map.width * 32 and !$game_map.loop_horizontal?
dx = (Graphics.width - $game_map.width * 32) / 2
else
dx = 0
end
dw = [Graphics.width, $game_map.width * 32].min
dw = Graphics.width if $game_map.loop_horizontal?
if Graphics.height > $game_map.height * 32 and !$game_map.loop_vertical?
dy = (Graphics.height - $game_map.height * 32) / 2
else
dy = 0
end
dh = [Graphics.height, $game_map.height * 32].min
dh = Graphics.height if $game_map.loop_vertical?
@viewport1 = Viewport.new(dx, dy, dw, dh)
@viewport2 = Viewport.new(dx, dy, dw, dh)
@viewport3 = Viewport.new(dx, dy, dw, dh)
@viewport2.z = 50
@viewport3.z = 100
end
end # Spriteset_Map
#==============================================================================
# ¦ Window_Base
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# overwrite method: draw_gauge
#--------------------------------------------------------------------------
def draw_gauge(dx, dy, dw, rate, color1, color2)
dw -= 2
fill_w = [(dw * rate).to_i, dw].min
gauge_h = 6
gauge_y = dy + line_height - 2 - gauge_h
outline_colour = gauge_back_color
outline_colour.alpha = translucent_alpha
contents.fill_rect(dx, gauge_y - 1, dw + 2, gauge_h + 2, outline_colour)
dx += 1
contents.fill_rect(dx, gauge_y, dw, gauge_h, gauge_back_color)
contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
end
end # Window_Base
#==============================================================================
# ¦ Window_Selectable
#==============================================================================
class Window_Selectable < Window_Base
#--------------------------------------------------------------------------
# overwrite method: process_cursor_move
#--------------------------------------------------------------------------
def process_cursor_move
return unless cursor_movable?
last_index = @index
cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN)
cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP)
cursor_right(Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
cursor_left (Input.trigger?(:LEFT)) if Input.repeat?(:LEFT)
cursor_pagedown if !handle?(:pagedown) && Input.repeat?(:R)
cursor_pageup if !handle?(:pageup) && Input.repeat?(:L)
Sound.play_cursor if @index != last_index
end
end # Window_Selectable
#==============================================================================
# ¦ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# overwrite method: show_normal_animation
#--------------------------------------------------------------------------
def show_normal_animation(targets, animation_id, mirror = false)
animation = $data_animations[animation_id]
return if animation.nil?
ani_check = false
targets.each do |target|
if ani_check
target.pseudo_ani_id = animation_id
else
target.animation_id = animation_id
end
target.animation_mirror = mirror
abs_wait_short unless animation.to_screen?
ani_check = true if animation.to_screen?
end
abs_wait_short if animation.to_screen?
end
end # Scene_Battle
#==============================================================================
#
# FIM DO ARQUIVO
#
#==============================================================================