Galáxia RPG Maker
Gostaria de reagir a esta mensagem? Crie uma conta em poucos cliques ou inicie sessão para continuar.

Script para atacar com o mouse

2 participantes

Ir para baixo

 Script para atacar com o mouse  Empty Script para atacar com o mouse

Mensagem por dl_thunder Sáb Jun 18, 2011 2:17 pm

Script para atacar com o mouse

Olá pessoas que habitam esse site
Vou trazer para vocês um script fácil

Código:
#4################################################
#4############# PATH FINDING #####################
#4################################################
class Game_Player < Game_Character
  def passable?(x, y, d)
    # Selecionar as novas coordenadas
    new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
    new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
    # Se as coordenadas estiverem para fora do mapa
    unless $game_map.valid?(new_x, new_y)
      # Impassável
      return false
    end
    
    # Se o Modo de Depuração estiver ON e a tecla Ctrl for pressioanda
    if $DEBUG and Input.press?(Input::CTRL)
      # Passável
      return true
    end
    
    super
  end
  
end
class Game_Character
    #--------------------------------------------------------------------------
    alias nf_initialize initialize
    alias nf_update update
    #--------------------------------------------------------------------------
    attr_accessor :map
    attr_accessor :runpath
    #--------------------------------------------------------------------------
    def initialize
      nf_initialize
      @map = nil
      @runpath = false
    end
    #--------------------------------------------------------------------------
    def update
      run_path if @runpath == true
      nf_update
    end
    #--------------------------------------------------------------------------
    def run_path
      return if moving?
      step = @map[@x,@y]
      if step == 1
        @map = nil
        @runpath = false
        return
      end
      dir = rand(2)
      case dir
      when 0
        move_right if @map[@x+1,@y] == step - 1 and step != 0
        move_down if @map[@x,@y+1] == step - 1 and step != 0
        move_left if @map[@x-1,@y] == step -1 and step != 0
        move_up if @map[@x,@y-1] == step - 1 and step != 0
      when 1
        move_up if @map[@x,@y-1] == step - 1 and step != 0
        move_left if @map[@x-1,@y] == step -1 and step != 0
        move_down if @map[@x,@y+1] == step - 1 and step != 0
        move_right if @map[@x+1,@y] == step - 1 and step != 0
      end
    end
    #--------------------------------------------------------------------------
    def find_path(x,y)
      sx, sy = @x, @y
      result = setup_map(sx,sy,x,y)
      @runpath = result[0]
      @map = result[1]
      @map[sx,sy] = result[2] if result[2] != nil
    end
    #--------------------------------------------------------------------------
    def clear_path
      @map = nil
      @runpath = false
    end
    #--------------------------------------------------------------------------
    def setup_map(sx,sy,ex,ey)
      map = Table.new($game_map.width, $game_map.height)
      map[ex,ey] = 1
      old_positions = []
      new_positions = []
      old_positions.push([ex, ey])
      depth = 2
      depth.upto(100){|step|
        loop do
          break if old_positions[0] == nil
          x,y = old_positions.shift
          return [true, map, step] if x == sx and y+1 == sy
          if $game_player.passable?(x, y, 2) and map[x,y + 1] == 0
            map[x,y + 1] = step
            new_positions.push([x,y + 1])
          end
          return [true, map, step] if x-1 == sx and y == sy
          if $game_player.passable?(x, y, 4) and map[x - 1,y] == 0
            map[x - 1,y] = step
            new_positions.push([x - 1,y])
          end
          return [true, map, step] if x+1 == sx and y == sy
          if $game_player.passable?(x, y, 6) and map[x + 1,y] == 0
            map[x + 1,y] = step
            new_positions.push([x + 1,y])
          end
          return [true, map, step] if x == sx and y-1 == sy
          if $game_player.passable?(x, y,  and map[x,y - 1] == 0
            map[x,y - 1] = step
            new_positions.push([x,y - 1])
          end
        end
        old_positions = new_positions
        new_positions = []
      }
      return [false, nil, nil]
    end
  end
  
  class Game_Map
    alias pf_game_map_setup setup
    def setup(map_id)
      pf_game_map_setup(map_id)
      $game_player.clear_path
    end
  end
#============================================================================
# * Este código evita os monstros invisíveis
#============================================================================
class Scene_Map
  #--------------------------------------------------------------------------
  alias mrmo_abs_scene_map_update update
  alias mrmo_abs_scene_map_transfer_player transfer_player
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    $ABS.enemies = {} if $game_map.map_id != $game_temp.player_new_map_id
    mrmo_abs_scene_map_transfer_player
  end
end
#----------------------------------------------------------------------------

Espero que gostem
Créditos:Thoorin

Bem,nao tenho muito o que falar do script nea..
dl_thunder
dl_thunder
Moderadores
Moderadores

Engine : RPG Maker VX
Mensagens : 47

Ir para o topo Ir para baixo

 Script para atacar com o mouse  Empty Re: Script para atacar com o mouse

Mensagem por Khronos Sáb Jun 18, 2011 7:45 pm

Nóssa nunca vi esse tipo de Script pra XP =D
Muuito legal ;D

vllw por postar aqui ;D

+Rep

anyway

See yaa'
Khronos
Khronos
Moderadores
Moderadores

Engine : RPG Maker VX
Mensagens : 192
Idade : 29
Localização : Sp

Ir para o topo Ir para baixo

 Script para atacar com o mouse  Empty Re: Script para atacar com o mouse

Mensagem por dl_thunder Qui Jun 23, 2011 7:51 am

Vlw,é bem legal mesmo cara

Vlw pela rep
Minha primeira huhuuuuuuuu
dl_thunder
dl_thunder
Moderadores
Moderadores

Engine : RPG Maker VX
Mensagens : 47

Ir para o topo Ir para baixo

 Script para atacar com o mouse  Empty Re: Script para atacar com o mouse

Mensagem por Conteúdo patrocinado


Conteúdo patrocinado


Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos