=begin #########################################################################
################### VISÃO PARA CHARS ##################### V 1.1.3 #############
################################################################################
################### POR: LB - ReinoRPG.com #####################################
################################################################################
INSTRUÇÕES:
Crie um evento e coloque-o em processo paralelo. Coloque seu movimento como
preferir. Depois adicione um comentário que deve conter:
"retangulo" OU "triangulo"
- retangulo:
@ ####
- triangulo:
#
##
###
@ ####
###
##
#
Depois desse comentário com o tipo de visão adicione outro comentário, nele
coloque o tamanho dessa visão. Depois dos dois comentários coloque os comandos
que serão executados se o personagem for visto pelo evento. Lembre-se de
trocar de pagina logo após esses comandos, para que não sejam executados
novamente. Exemplos:
1-
Comentário: triangulo
Comentário: 5
<Comandos>
#
##
###
####
@ ##### << cinco tiles de visão
####
###
##
#
2-
Comentário: retangulo
Comentário: 7
<Comandos>
@ ####### << sete tiles de visão
Em caso de bloqueio, na visão retangular:
Comentário: retangulo
Comentário: 7
<Comandos>
@ ###| << a visão é interrompida apartir do obstáculo
na visão triangular:
Comentário: triangulo
Comentário: 5
<Comandos>
#
##
##
#|
@ #### << o bloqueio interrompe a visão também em formato triangular
####
###
##
#
=end
class Game_Interpreter
alias cont execute_command
def execute_command
if @list[0].code == 108 and @list[1].code == 108
if @list[0].parameters[0] == "retangulo" or @list[0].parameters[0] == "triangulo"
if eval("!"+@list[0].parameters[0]+"("+@event_id.to_s+","+@list[1].parameters[0]+")")
command_end
return true
end
end
end
cont
end
def retangulo(id,t)
result = false
x, y = $game_map.events[id].x, $game_map.events[id].y
x2, y2 = $game_player.x, $game_player.y
case $game_map.events[id].direction
when 2 # Baixo
for i in 1...(t+1)
break if !$game_map.passable?(x, y+i)
result = (x2 == x and y2 == y+i ? true : result)
end
when 4 # Esquerda
for i in 1...(t+1)
break if !$game_map.passable?(x-i, y)
result = (x2 == x-i and y2 == y ? true : result)
end
when 6 # Direita
for i in 1...(t+1)
break if !$game_map.passable?(x+i, y)
result = (x2 == x+i and y2 == y ? true : result)
end
when 8 # Cima
for i in 1...(t+1)
break if !$game_map.passable?(x, y-i)
result = (x2 == x and y2 == y-i ? true : result)
end
end
return result
end
def triblock(x, y, t, invisible)
x2 = $game_player.x
y2 = $game_player.y
for i2 in 1...(t+1)
invisible << [x, y+i2] if x2 == x and y2 == y+i2
for a2 in 1...i2
invisible << [x-a2, y+i2] if x2 == x-a2 and y2 == y+i2
end
for a2 in 1...i2
invisible << [x+a2, y+i2] if x2 == x+a2 and y2 == y+i2
end
end
end
def triangulo(id,t)
result = false
x = $game_map.events[id].x
y = $game_map.events[id].y
x2 = $game_player.x
y2 = $game_player.y
invisible = []
case $game_map.events[id].direction
when 2 # Baixo
for i in 1...(t+1)
result = [x, y+i] if x2 == x and y2 == y+i
triblock(x, y+i, t, invisible) if !$game_map.passable?(x, y+i)
for a in 1...i
result = [x-a, y+i] if x2 == x-a and y2 == y+i
triblock(x-a, y+i, t, invisible) if !$game_map.passable?(x-a, y+i)
end
for a in 1...i
result = [x+a, y+i] if x2 == x+a and y2 == y+i
triblock(x+a, y+i, t, invisible) if !$game_map.passable?(x+a, y+i)
end
end
when 4 # Esquerda
for i in 1...(t+1)
result = true if x2 == x-i and y2 == y
triblock(x-i, y, t, invisible) if !$game_map.passable?(x-i, y)
for a in 1...i
result = true if x2 == x-i and y2 == y-a
triblock(x-i, y-a, t, invisible) if !$game_map.passable?(x-i, y-a)
end
for a in 1...i
result = true if x2 == x-i and y2 == y+a
triblock(x-i, y+a, t, invisible) if !$game_map.passable?(x-i, y+a)
end
end
when 6 # Direita
for i in 1...(t+1)
result = true if x2 == x+i and y2 == y
triblock(x+i, y, t, invisible) if !$game_map.passable?(x+i, y)
for a in 1...i
result = true if x2 == x+i and y2 == y-a
triblock(x+i, y-a, t, invisible) if !$game_map.passable?(x+i, y-a)
end
for a in 1...i
result = true if x2 == x+i and y2 == y+a
triblock(x+i, y+a, t, invisible) if !$game_map.passable?(x+i, y+a)
end
end
when 8 # Cima
for i in 1...(t+1)
result = true if x2 == x and y2 == y-i
triblock(x, y-i, t, invisible) if !$game_map.passable?(x, y-i)
for a in 1...i
result = true if x2 == x-a and y2 == y-i
triblock(x-a, y-i, t, invisible) if !$game_map.passable?(x-a, y-i)
end
for a in 1...i
result = true if x2 == x+a and y2 == y-i
triblock(x+a, y-i, t, invisible) if !$game_map.passable?(x+a, y-i)
end
end
end
return (!invisible.include?(result) and result)
end
end