O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Visão para Chars

Iniciado por LoboShow, 04/12/2012 às 17:37

Visão para Chars

Compativel com: RMVX
Compatibilidade : ?
Facilidade de uso: ?
Lag gerado: ?

[box class=titlebg]
Para que serve o script
[/box]
Esse script serve para que um evento possa "ver" o personagem se aproximar e reagir. Muito útil em batalhas ou fugas de prisão. Ele tem dois tipos de visão, a retangular e a triangular.  Mais detalhes no próprio script.

[box class=titlebg]
Script
[/box]
=begin #########################################################################
################### VISÃO PARA CHARS ##################### V 1.0.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

=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 = $game_map.events[id].x
    y = $game_map.events[id].y
    x2 = $game_player.x
    y2 = $game_player.y
    case $game_map.events[id].direction
    when 2 # Baixo
      for i in 1...(t+1)
        result = (x2 == x and y2 == y+i ? true : result)
      end
    when 4 # Esquerda
      for i in 1...(t+1)
        result = (x2 == x-i and y2 == y ? true : result)
      end
    when 6 # Direita
      for i in 1...(t+1)
        result = (x2 == x+i and y2 == y ? true : result)
      end
    when 8 # Cima
      for i in 1...(t+1)
        result = (x2 == x and y2 == y-i ? true : result)
      end
    end
    return result
  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
    case $game_map.events[id].direction
    when 2 # Baixo
      for i in 1...(t+1)
        if x2 == x and y2 == y+i
          result = true
        end
        for a in 1...i
          if x2 == x-a and y2 == y+i
            result = true
          end
        end
        for a in 1...i
          if x2 == x+a and y2 == y+i
            result = true
          end
        end
      end
    when 4 # Esquerda
      for i in 1...(t+1)
        if x2 == x-i and y2 == y
          result = true
        end
        for a in 1...i
          if x2 == x-i and y2 == y-a
            result = true
          end
        end
        for a in 1...i
          if x2 == x-i and y2 == y+a
            result = true
          end
        end
      end
    when 6 # Direita
      for i in 1...(t+1)
        if x2 == x+i and y2 == y
          result = true
        end
        for a in 1...i
          if x2 == x+i and y2 == y-a
            result = true
          end
        end
        for a in 1...i
          if x2 == x+i and y2 == y+a
            result = true
          end
        end
      end
    when 8 # Cima
      for i in 1...(t+1)
        if x2 == x and y2 == y-i
          result = true
        end
        for a in 1...i
          if x2 == x-a and y2 == y-i
            result = true
          end
        end
        for a in 1...i
          if x2 == x+a and y2 == y-i
            result = true
          end
        end
      end
    end
    return result
  end
end


[box class=titlebg]
Créditos e Avisos
[/box]
Criador : LD