Aldeia RPG

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

Suporte ao desenvolvimento de jogos


+3
Nietore
Valentine
LeonM²
7 participantes

    Fog Of War

    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    Fog Of War Empty Fog Of War

    Mensagem por LeonM² Ter Out 25, 2011 10:05 am

    Informações/Intruções
    Script feito por Jet, faz o efeito de "mapas inexplorados" como famosos jogos de estratégia. Esse efeito pode ser ativado e desativado através de uma switch que poderá ser configurada na linha : 51

    FOG_OFF_SWITCH = 99
    onde estiver 99 você coloca o número da switch que vai fazer o efeito ser ligado/desligado

    O limite de visão pode ser facilmente alterado também na linha 47
    PLAYER_DEFAULT_RANGE = 4
    Imagens
    Spoiler:
    Spoiler:
    Script
    Código:
     #===============================================================================
    # Fog Of War
    # By Jet10985 (Jet)
    #===============================================================================
    # This script will created a Fog Of War effect, which marks parts of the map
    # as "visible", "explored", and "unexplored". Details further down.
    # This script has: 4 customization options.
    #===============================================================================
    # Overwritten Methods:
    # None
    #-------------------------------------------------------------------------------
    # Aliased methods:
    # Spriteset_Map: update, initialize, dispose
    # Game_Temp: initialize
    # Game_System: initialize
    # Game_Character: transparent
    #===============================================================================
    =begin
    Fog Of War Explanation:

    With the Fog Of War, there are 3 parts of a map, "visible", "explored" and
    "unexplored".
    Visible parts you can see everything as one normally would.
    Explored you see the generall area, like tiles and maybe events.
    Unexplored is pure lack space, which nothing can be seen.

    Areas are marked as "explored" as soon as it becomes "visible" by the player.
    --------------------------------------------------------------------------------
    Depending on the value of EVENT_TRANSPARENCY in the configuration below, this
    comment will have a specific event do the opposite:

    IGNORE FOW

    So, if EVENT_TRANSPARENCY is true, then the event WILL NOT become invisible,
    but if EVENT_TRANSPARENCY is false, then it WILL become invisible.
    --------------------------------------------------------------------------------
    To change the player's range of site, use this in an event "Script..." command:

    change_fow_range(new_fow_range)

    replace new_fow_range with a number, like 4.
    =end

    module JetFOW
     
      # This is how far the player's Fog Of War visible range is by default.
      PLAYER_DEFAULT_RANGE = 4
     
      # This is the switch id of the switch which when turned off, will turn off
      # the Fog Of War effect.
      FOG_OFF_SWITCH = 99
     
      # Should events outside the player's "visible" range become invisible?
      EVENT_TRANSPARENCY = true
     
      # Do you want to pre-cache map's fogs while the player is playing?
      PRE_CACHE_MAPS = true
     
    end

    #===============================================================================
    # DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
    #===============================================================================
    class Game_Temp
     
      attr_accessor :map_fog_sprites
     
      alias jet6754_initialize initialize unless $@
      def initialize(*args, &block)
        @map_fog_sprites = {}
        jet6754_initialize(*args, &block)
      end
    end

    class Game_System
     
      attr_accessor :exposed_tiles, :player_fow_range
     
      alias jet2834_initialize initialize unless $@
      def initialize(*args, &block)
        @exposed_tiles = {}
        @player_fow_range = JetFOW::PLAYER_DEFAULT_RANGE
        jet2834_initialize(*args, &block)
      end
    end

    class Game_Interpreter
     
      def change_fow_range(t)
        $game_system.player_fow_range = t
      end
    end

    class Spriteset_Map
     
      alias jet1245_initialize initialize unless $@
      def initialize(*args, &block)
        create_fog_of_war
        Thread.new {
          @pre_cached ||= false
          precache_fogs_of_war if JetFOW::PRE_CACHE_MAPS && !@pre_cached
        }
        jet1245_initialize(*args, &block)
      end
     
      alias jet8677_update update unless $@
      def update(*args, &block)
        update_fog_of_war
        jet8677_update(*args, &block)
      end
     
      alias jet8677_dispose dispose unless $@
      def dispose(*args, &block)
        dispose_fog_of_war
        jet8677_dispose(*args, &block)
      end
     
      def precache_fogs_of_war
        @pre_cached = true
        f = load_data("Data/MapInfos.rvdata")
        (f.keys - $game_temp.map_fog_sprites.keys).each {|a|
          $game_temp.map_fog_sprites[a] = {}
          map = load_data(sprintf("Data/Map%03d.rvdata", a))
          width, height = map.width, map.height
          viewport = Viewport.new(0, 0, width * 32, height * 32)
          width.times {|i|
            height.times {|i2|
              bit = Bitmap.new(32, 32)
              bit.fill_rect(bit.rect, Color.new(0, 0, 0))
              sprite = Sprite.new(viewport)
              sprite.bitmap = bit
              viewport.z = 9999
              sprite.visible = false
              $game_temp.map_fog_sprites[a][[i, i2]] = sprite
            }
          }
        }
        GC.start
      end
     
      def create_fog_of_war(*args, &block)
        if $game_temp.map_fog_sprites[$game_map.map_id].nil?
          @making_fow = true
          $game_temp.map_fog_sprites[$game_map.map_id] = {}
          width, height = $game_map.width, $game_map.height
          viewport = Viewport.new(0, 0, width * 32, height * 32)
          width.times {|i|
            height.times {|i2|
              bit = Bitmap.new(32, 32)
              bit.fill_rect(bit.rect, Color.new(0, 0, 0))
              sprite = Sprite.new(viewport)
              sprite.bitmap = bit
              viewport.z = 9999
              $game_temp.map_fog_sprites[$game_map.map_id][[i, i2]] = sprite
            }
          }
          @making_fow = false
        end
        if $game_system.exposed_tiles[$game_map.map_id].nil?
          $game_system.exposed_tiles[$game_map.map_id] = []
        end
        $game_system.exposed_tiles[$game_map.map_id].each {|a|
          $game_temp.map_fog_sprites[$game_map.map_id][a].opacity = 128
        }
      end
     
      def update_fog_of_war(*args, &block)
        @did_first_move ||= false
        @did_fow_first ||= false
        @fow_invis ||= false
        if $game_switches[JetFOW::FOG_OFF_SWITCH] && !@fow_invis
          $game_temp.map_fog_sprites[$game_map.map_id].each {|a, b|
            b.visible = false unless !b.visible
            @fow_invis = true
          }
          return
        else
          @fow_invis = false
        end
        if (!$game_player.stopping? && !@did_first_move) || !@did_fow_first
          @did_first_move = true
          @did_fow_first = true unless @did_fow_first || @making_fow
          $game_temp.map_fog_sprites[$game_map.map_id].each {|a, b|
            b.visible = true unless b.visible
            b.x = a[0] * 32 - ($game_map.display_x + 255) / 256 * 32
            b.y = a[1] * 32 - ($game_map.display_y + 255) / 256 * 32
            x = ($game_player.x - a[0]).abs
            y = ($game_player.y - a[1]).abs
            dist = x + y
            if dist <= $game_system.player_fow_range
              b.opacity = 0 unless b.opacity == 0
              if !$game_system.exposed_tiles[$game_map.map_id].include?(a)
                $game_system.exposed_tiles[$game_map.map_id].push(a)
              end
            elsif $game_system.exposed_tiles[$game_map.map_id].include?(a)
              b.opacity = 128 unless b.opacity == 128
            else
              b.opacity = 255 unless b.opacity == 255
            end
          }
        end
        if $game_player.stopping? && @did_first_move
          @did_first_move = false
        end
      end
     
      def dispose_fog_of_war(*args, &block)
        $game_temp.map_fog_sprites[$game_map.map_id].each {|a, b|
          b.visible = false unless !b.visible
        }
      end
    end

    class Game_Character
     
      alias jet4567_transparent transparent unless $@
      def transparent(*args, &block)
        if !$game_switches[JetFOW::FOG_OFF_SWITCH] && !within_range_fow?
          if JetFOW::EVENT_TRANSPARENCY
            return true unless self.is_a?(Game_Event) && ignore_fow_comment?
          end
        end
        return jet4567_transparent(*args, &block)
      end
     
      def within_range_fow?(*args, &block)
        a, b = $game_player, self
        return true if b == a
        if ((b.x - a.x).abs + (b.y - a.y).abs) <= $game_system.player_fow_range
          return true
        end
        return false
      end
    end

    class Game_Event
     
      def ignore_fow_comment?(*args, &block)
        return false if @list.nil? or @list.size <= 0
        for item in @list
          if item.code == 108 or item.code == 408
            if item.parameters[0].match(/IGNORE[ ]*FOW/i)
              return true
            end
          end
        end
        return false
      end
    end
    Créditos
    Warjet - Criador do script
    Patho - Disponibilizar na MRM
    Leon Mega Maker - Por Postar Aki
    Valentine
    Valentine
    Administrador
    Administrador


    Medalhas : Fog Of War ZgLkiRU
    Mensagens : 5336
    Créditos : 1163

    Fog Of War Empty Re: Fog Of War

    Mensagem por Valentine Ter Out 25, 2011 11:11 am

    Parece o sistema do tibia quando ele tinha um gráfico ruim em relação ao fog ;x
    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    Fog Of War Empty Re: Fog Of War

    Mensagem por LeonM² Ter Out 25, 2011 11:20 am

    Marlos Gama escreveu:Parece o sistema do tibia quando ele tinha um gráfico ruim em relação ao fog ;x
    parece mais com AoE mas bem ruim msm
    Nietore
    Nietore
    Lenda
    Lenda


    Medalhas : Fog Of War ZgLkiRU
    Mensagens : 851
    Créditos : 163

    Fog Of War Empty Re: Fog Of War

    Mensagem por Nietore Ter Out 25, 2011 3:46 pm

    Tem tudo aver com o Tibia, tipo abrindo o Mine map...


    _________________
    Fog Of War AIymW

    Eu poderia ser a pessoa mais agradavel do mundo! mas optei por ser eu mesmo.
    Juton
    Juton
    Experiente
    Experiente


    Mensagens : 486
    Créditos : 129

    Fog Of War Empty Re: Fog Of War

    Mensagem por Juton Ter Out 25, 2011 4:40 pm

    Eu tava pensando nesse sistema, enquanto jogava runescape! e quando venho aqui ..."
    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    Fog Of War Empty Re: Fog Of War

    Mensagem por LeonM² Ter Out 25, 2011 8:14 pm

    ninguem gostou ñ?
    TecoKun
    TecoKun
    Membro de Honra
    Membro de Honra


    Mensagens : 1310
    Créditos : 69

    Fog Of War Empty Re: Fog Of War

    Mensagem por TecoKun Qua Out 26, 2011 11:45 am

    Me lembrou do AGE OF EMPIRES II kk,+1 de credito(Pramim)Pra vc xD


    _________________
    Fog Of War 9vqffD0
    Meu fórum de RPG Maker! ainda esta em construção, mas ja tem materias exclusivos! Visite-nos, você vai gostar!
    Status do fórum: PARADO (por enquanto)


    Alguns dos meus textos sobre Rpg, podem te ajudar Wink
    * Contos dos Heróis


    Deem uma olhada Successful 
    FilipeJF
    FilipeJF
    Aldeia Friend
    Aldeia Friend


    Medalhas : Fog Of War Trophy11Fog Of War 94Jxv
    Mensagens : 1859
    Créditos : 134

    Fog Of War Empty Re: Fog Of War

    Mensagem por FilipeJF Qua Out 26, 2011 1:15 pm

    Vo usar no meu jogo de estrátegia, acho que combina.
    Muito bom!

    Té +!

    Edit:
    Como eu faço para usar ele apenas no mapa que eu quero?
    Não em todos, sabe?


    _________________

    Fog Of War Atpqp
    O Equívoco do Sábio - conto na Amazon
    LeonM²
    LeonM²
    Lenda
    Lenda


    Mensagens : 1802
    Créditos : 153

    Fog Of War Empty Re: Fog Of War

    Mensagem por LeonM² Qua Out 26, 2011 7:39 pm

    FilipeJF escreveu:Vo usar no meu jogo de estrátegia, acho que combina.
    Muito bom!

    Té +!

    Edit:
    Como eu faço para usar ele apenas no mapa que eu quero?
    Não em todos, sabe?
    é só desativer a switche no mapa que ñ for usar
    FilipeJF
    FilipeJF
    Aldeia Friend
    Aldeia Friend


    Medalhas : Fog Of War Trophy11Fog Of War 94Jxv
    Mensagens : 1859
    Créditos : 134

    Fog Of War Empty Re: Fog Of War

    Mensagem por FilipeJF Qua Out 26, 2011 8:09 pm

    Leon Mega Maker escreveu:
    FilipeJF escreveu:Vo usar no meu jogo de estrátegia, acho que combina.
    Muito bom!

    Té +!

    Edit:
    Como eu faço para usar ele apenas no mapa que eu quero?
    Não em todos, sabe?
    é só desativer a switche no mapa que ñ for usar

    Ah, obrigado!
    Sou meio novo com eventos e scripts, então não entendo muita coisa.

    Obrigado!


    _________________

    Fog Of War Atpqp
    O Equívoco do Sábio - conto na Amazon

    Conteúdo patrocinado


    Fog Of War Empty Re: Fog Of War

    Mensagem por Conteúdo patrocinado


      Data/hora atual: Qui Mar 28, 2024 12:24 pm