Chaos Project

RPG Maker => RPG Maker Scripts => Script Requests => Topic started by: Badlands on July 30, 2010, 10:32:32 pm

Title: Fog of War for Blizz ABS
Post by: Badlands on July 30, 2010, 10:32:32 pm
That would be a great feature to add, and a lot of people would find it useful.
Like Berka's Fog of War script, but for RMXP. I mean, almost no lag at all, a really simple system, at least a basic one.
Title: Re: Fog of War for Blizz ABS
Post by: ShadowPierce on July 30, 2010, 11:47:24 pm
->Sorry but I don't really see the point for this system since the characters' visions are already limited & you can't see beyond the main character's scope...  :uhm: But then again, I could be wrong... I'll just wait & watch... Like this:  :O.o:

:haha:


Title: Re: Fog of War for Blizz ABS
Post by: Badlands on July 31, 2010, 01:19:10 am
The character's visions are already limited by the screen size and map scroll, but I'm not scrolling the map as the character walks, I'm scrolling the map with the mouse like strategy games. So, if I scroll the map and left my character behind I should only be able to see the fog of war.
And I dont really see the point in viewing the whole screen as the character's view.
Title: Re: Fog of War for Blizz ABS
Post by: ShadowPierce on July 31, 2010, 02:12:33 am
->You mean you're using Blizz-ABS to make a strategy game of some sort? And you use a mouse script that lets you scroll out of the MC's scope of view? Then that would be a pretty original idea to use BABS for... I approve of this...  :up:


Title: Re: Fog of War for Blizz ABS
Post by: WhiteRose on July 31, 2010, 02:39:40 am
It don't think this would be overly difficult to create. Maybe it could be made through some sort of modification to Blizz-ABSEAL. Of course, right now it bases it on the screen movement rather than character movement, so that would be one change that would have to be made.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on July 31, 2010, 11:00:45 am
Yes, that is what I'm trying to do, and all works great, except that I do not have any fog of war :(
Title: Re: Fog of War for Blizz ABS
Post by: Shalaren on August 01, 2010, 10:06:23 pm
oh man thats a really unique idea.. I could really use something like this too for my game.
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 01, 2010, 10:27:45 pm
It could be evented too :S Just saying. In fact I'll see what I can do tonight.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 02, 2010, 06:55:54 am
There are lots of events involved already with Blizz ABS, mainly enemys and allies. So events are not the best choice.. It would be great if someone can make a simple fow script for Blizz ABS, it will expand its possibilities even more..

This is a good simple example, but it works just for VX D:
Spoiler: ShowHide


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Fog of War 22/05/09
#-------------------------------------------------------------------------------
# ver.0.1 par Berka rgss.2
# http://www.rpgmakervx-fr.com
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Add a Fog of War on the Map
#-------------------------------------------------------------------------------
# Commands:
# Fog.clear_fog(map_id) # clear the bitmap (all black)
# vu_par_hero?(x,y) # chek if [x,y] is viewed by the hero
# $RayonFog = i # modify the hero's view range
#-------------------------------------------------------------------------------
# Features:
# * Switch hides the fog
# * the fog of each map is saved
# * threading system (faster) for fog's borders
# Do not use for large maps: FPS may be down
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

module Berka
module Brouillard
$RayonFog = 3 # View Range: calculs are optimized for 3 or 6
FichFog = "fog.png" # File of fog tileset: only the first pattern is used
# may be placed on: Graphics/System
IDFog = 1 # Switch_Id: if switch == true: hides the fog
ZFog = 300 # fogs 's priorities
Act_GC = true # Garbage Collector managment

# Do not Change !!!!
Tiles={ # fog's tileset indexes
"0"=>2816,"1"=>2824,"12"=>2844,"123"=>2844,"1234"=>2856,"12346"=>2860,
"123467"=>2860,"1234678"=>2862,"12346789"=>2862,"1234679"=>2860,"123468"=>2862,
"1234689"=>2862,"123469"=>2860,"12347"=>2856,"123478"=>2859,"1234789"=>2859,
"123479"=>2857,"12348"=>2859,"123489"=>2859,"12349"=>2857,"1236"=>2854,
"12367"=>2855,"123678"=>2861,"123679"=>2855,"1236789"=>2861,"12368"=>2861,
"123689"=>2861,"12369"=>2854,"1237"=>2845,"12378"=>2849,"123789"=>2849,
"12379"=>2847,"1238"=>2849,"12389"=>2849,"1239"=>2846,"124"=>2856,"1246"=>2860,
"12467"=>2860,"124678"=>2862,"1246789"=>2862,"124679"=>2860,"12468"=>2862,
"124689"=>2862,"12469"=>2860,"1247"=>2856,"12478"=>2859,"124789"=>2859,
"12479"=>2857,"1248"=>2859,"12489"=>2859,"1249"=>2857,"126"=>2854,"1267"=>2855,
"12678"=>2861,"126789"=>2861,"12679"=>2855,"1268"=>2861,"12689"=>2861,"1269"=>2854,
"127"=>2845,"1278"=>2849,"12789"=>2849,"128"=>2849,"1289"=>2849,"129"=>2846,
"13"=>2828,"134"=>2834,"1346"=>2848,"13467"=>2848,"134678"=>2858,"1346789"=>2858,
"134679"=>2848,"13468"=>2858,"134689"=>2858,"13469"=>2848,"1347"=>2834,
"13478"=>2851,"134789"=>2851,"13479"=>2835,"1348"=>2851,"13489"=>2851,
"1349"=>2835,"136"=>2841,"1367"=>2843,"13678"=>2853,"136789"=>2853,"13679"=>2843,
"1368"=>2853,"13689"=>2853,"1369"=>2841,"137"=>2829,"1378"=>2839,"13789"=>2839,
"138"=>2839,"1389"=>2839,"139"=>2830,"14"=>2832,"146"=>2848,"1467"=>2848,
"14678"=>2858,"146789"=>2858,"14679"=>2848,"1468"=>2862,"14689"=>2858,"1469"=>2848,
"147"=>2832,"1478"=>2850,"14789"=>2850,"1479"=>2833,"148"=>2850,"1489"=>2850,
"149"=>2833,"16"=>2841,"167"=>2843,"1678"=>2853,"16789"=>2853,"1679"=>2848,
"168"=>2853,"1689"=>2853,"169"=>2841,"17"=>2825,"178"=>2838,"1789"=>2838,
"179"=>2827,"18"=>2838,"189"=>2838,"19"=>2826,"2"=>2844,"23"=>2844,"234"=>2856,
"2346"=>2860,"23467"=>2860,"234678"=>2862,"2346789"=>2862,"234679"=>2862,
"23468"=>2862,"234689"=>2862,"23469"=>2860,"2347"=>2856,"23478"=>2859,
"234789"=>2859,"23479"=>2857,"2348"=>2859,"23489"=>2859,"2348"=>2859,"236"=>2854,
"2367"=>2855,"23678"=>2861,"236789"=>2861,"23679"=>2855,"2368"=>2861,"23689"=>2861,
"2369"=>2854,"237"=>2845,"2378"=>2849,"23789"=>2849,"2379"=>2847,"238"=>2849,
"2389"=>2849,"239"=>2846,"24"=>2856,"246"=>2860,"2467"=>2860,"24678"=>2862,
"246789"=>2862,"24679"=>2860,"2468"=>2862,"24689"=>2862,"2469"=>2860,"247"=>2856,
"2478"=>2859,"24789"=>2859,"2479"=>2847,"248"=>2859,"2489"=>2859,"249"=>2857,
"26"=>2854,"267"=>2854,"2678"=>2861,"26789"=>2861,"2679"=>2855,"268"=>2861,
"2689"=>2861,"269"=>2854,"27"=>2845,"278"=>2849,"2789"=>2849,"279"=>2847,"28"=>2849,
"289"=>2849,"29"=>2846,"3"=>2820,"34"=>2834,"346"=>2848,"3467"=>2848,"34678"=>2858,
"346789"=>2858,"34679"=>2848,"3468"=>2858,"34689"=>2858,"3469"=>2848,"347"=>2834,
"3478"=>2851,"34789"=>2851,"3479"=>2835,"348"=>2851,"3489"=>2851,"349"=>2835,
"36"=>2840,"367"=>2842,"3678"=>2852,"36789"=>2852,"3679"=>2842,"368"=>2852,
"3689"=>2852,"369"=>2840,"37"=>2821,"378"=>2837,"3789"=>2837,"379"=>2823,
"38"=>2837,"389"=>2837,"39"=>2822,"4"=>2832,"46"=>2848,"467"=>2848,"4678"=>2858,
"46789"=>2858,"4679"=>2848,"468"=>2858,"4689"=>2858,"469"=>2848,"47"=>2832,
"478"=>2850,"4789"=>2850,"479"=>2833,"48"=>2850,"489"=>2850,"49"=>2833,
"6"=>2840,"67"=>2842,"678"=>2852,"6789"=>2852,"679"=>2842,"68"=>2852,
"689"=>2852,"69"=>2840,"7"=>2817,"78"=>2836,"789"=>2836,"79"=>2819,"8"=>2836,
"89"=>2836,"9"=>2818
} # et tu payes ton mal de crâne, pour trouver chaque valeur ^^
end
end
module Fog
def self.clear_fog(id)
$game_temp.br_maps.delete(id)
return if !$scene.is_a?(Scene_Map)
$scene.spriteset.dispose
$scene.spriteset=Spriteset_Map.new
end
end
Win32API.new('kernel32','SetPriorityClass','pi','i').call(
Win32API.new('kernel32','GetCurrentProcess','','i').call,256)
include Berka::Brouillard
class Spriteset_Map
alias :br_create :create_tilemap
alias :br_dispose :dispose_tilemap
alias :br_view :dispose_viewports
alias :br_update :update_tilemap unless $@
alias :br_view_update :update_viewports unless $@
attr_accessor :br_tile,:tilemap
def create_tilemap
br_create
@br_tile=Tilemap.new(@br_view=Viewport.new(0,0,Graphics.width,Graphics.height))
@br_view.z=ZFog
8.times{|i|@br_tile.bitmaps[i]=@tilemap.bitmaps[i].clone}
@br_tile.bitmaps[1]=Cache.system(FichFog)
@br_tile.map_data=Table.new($game_map.width,$game_map.height,3)
clear_fog
end
def clear_fog
w,h=$game_map.width,$game_map.height
if $game_temp.br_maps.has_key?($game_map.map_id)
for x in 0...w;for y in 0...h
if $game_temp.br_maps[$game_map.map_id][x,y]==0
@br_tile.map_data[x,y,1]=2816
a||=true
else
@br_tile.map_data[x,y,1]=0
a||=false
end
end;end
if a
Thread.new{for x in 0...w;for y in 0...h
chk(x,y)
end;end}
end
else
$game_temp.br_maps[$game_map.map_id]||=Table.new(w,h)
for x in 0...w;for y in 0...h
@br_tile.map_data[x,y,1]=2816
$game_temp.br_maps[$game_map.map_id][x,y]=0
end;end
end
end
def dispose_tilemap
br_dispose
@br_tile.dispose
end
def dispose_viewports
br_view
@br_view.dispose
end
def update_tilemap
br_update
if $game_switches[IDFog]
@br_tile.dispose
return
end
GC.start if !$game_player.moving?&&Act_GC
return if !$game_temp.br_maps.has_key?($game_map.map_id)
br_obscurcis
x,y=$game_map.display_x/8,$game_map.display_y/8
return if x==@br_tile.ox&&y==@br_tile.oy
@br_tile.ox,@br_tile.oy=x,y
@br_tile.update
end
def br_obscurcis
x,y=$game_player.x,$game_player.y
rx,ry=(x-$RayonFog-2..x+$RayonFog+2).to_a,(y-$RayonFog-2..y+$RayonFog+2).to_a
for tx in rx
for ty in ry
r=Math.sqrt(((x-tx)**2+(y-ty)**2))
chk(tx,ty)if r.between?($RayonFog,$RayonFog+2)
next if !tx.between?(rx[0],rx[-1])
if r<=$RayonFog
@br_tile.map_data[tx,ty,1]=0
$game_temp.br_maps[$game_map.map_id][tx,ty]=1
end
end
end
end
def chk(x,y)
return if !$game_temp.br_maps.has_key?($game_map.map_id)||x.nil?||y.nil?||
$game_temp.br_maps[$game_map.map_id][x,y]==1
d=@br_tile.map_data
l=[]
l<<1 if d[x-1,y+1,1]==0
l<<2 if d[x,y+1,1]==0
l<<3 if d[x+1,y+1,1]==0
l<<4 if d[x-1,y,1]==0
l<<6 if d[x+1,y,1]==0
l<<9 if d[x+1,y-1,1]==0
l<<8 if d[x,y-1,1]==0
l<<7 if d[x-1,y-1,1]==0
l=l.sort.join
return if l.nil?||l==""
@br_tile.map_data[x,y,1]=Tiles[l]
end
def update_viewports
br_view_update
@br_view.update
end
end
class Game_Temp
alias :br_initialize :initialize
attr_accessor :br_maps
def initialize
br_initialize
@br_maps={}
end
end
def vu_par_hero?(x,y)
Math.sqrt((($game_player.x-x)**2+($game_player.y-y)**2))<=$RayonFog
end
class Scene_Map<Scene_Base # correctif: màj spriteset 1/frame
attr_accessor :spriteset
def update_basic
Graphics.update
Input.update
$game_map.update
end
end
class Scene_File<Scene_Base
alias :br_write_save :write_save_data
alias :br_read_save :read_save_data
def write_save_data(file)
br_write_save(file)
Marshal.dump($game_temp.br_maps,file)
end
def read_save_data(file)
br_read_save(file)
$game_temp.br_maps=Marshal.load(file)
end
end

Title: Re: Fog of War for Blizz ABS
Post by: Blizzard on August 02, 2010, 07:08:52 am
I've seen RMXP Fog of War scripts a long time ago. Try googling.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 02, 2010, 07:18:38 am
Yeah I've seen them too, and they are laggy, they create a new instance of Tilemap class (Wachunga's one does not even work with the ABS).. So, your ABS + Laggy FoW = Crappy Gameplay.

Is it too difficult to script a simple one for your ABS, Blizzard?
Title: Re: Fog of War for Blizz ABS
Post by: SBR* on August 02, 2010, 07:22:44 am
Quote from: Badlands on August 02, 2010, 07:18:38 am
Yeah I've seen them too, and they are laggy, they create a new instance of Tilemap class (Wachunga's one does not even work with the ABS).. So, your ABS + Laggy FoW = Crappy Gameplay.

Is it too difficult to script a simple one for your ABS, Blizzard?


Lol, I keep on ROFL-ing when people ask Blizzard for new scripts :D.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 02, 2010, 07:54:36 am
omfg I'm not asking Blizzard to script it, I've asked if its difficult to script one for his ABS.
Title: Re: Fog of War for Blizz ABS
Post by: SBR* on August 02, 2010, 08:05:30 am
Quote from: Badlands on August 02, 2010, 07:54:36 am
omfg I'm not asking Blizzard to script it, I've asked if its difficult to script one for his ABS.


Lol, okay. But it sounded like you were asking him to do it :P.
Title: Re: Fog of War for Blizz ABS
Post by: Blizzard on August 02, 2010, 08:07:20 am
It shouldn't be much of a problem. The FOWs that I've seen work on a tileset basis like maps. Since Blizz-ABS doesn't actually do anything to maps in a visual way, they should work fine.
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 02, 2010, 10:31:37 am
Really all you need is to have a big black square to cover the screen.  A transparent circle right in the center. Set 2 variables
Variable 1 = Player Screen X # Not x, screen x
Variable 2 = PLayer screen y # same as above
Show Picture: Big black square with circle # Set the origin to center

Put that in a parallel process and wa-la you have a fog of war.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 02, 2010, 07:35:11 pm
I cant use that, I've said that I'm scrolling the maps with the mouse, the pic stay with the main character, so I see its borders. That is not cool at all.
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 02, 2010, 08:15:21 pm
Then enter this in a script call.
$game_variables[id] = $mouse.x
$game_variables[id] = $mouse.y
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 02, 2010, 10:10:05 pm
I think you're not getting the point of it, if I set the variables to the mouse's x and y pos it will move it with the screen, as the scroll of the map is by mouse, the idea is not to see the rest of the map if your character does not walk there.
Did you play Age of Empires? You cant scroll the map to see it if it is not explored by a unit, imagine the unit is the rpg character in this case.
Title: Re: Fog of War for Blizz ABS
Post by: Jek on August 02, 2010, 10:49:26 pm
1 way to script it (I can't script, so im not scripting it) is just to remember what tiles have been explored, and for each unexplored tile, it shows a picture over it. A blurred black circle to be specific.
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 03, 2010, 12:26:13 am
Well now that I know what she's talking about, I didnt quote understand what she meant, I could easily script this :3 If and when I'll do it? I dunno. I've got projects I'm working on.
Title: Re: Fog of War for Blizz ABS
Post by: Blizzard on August 03, 2010, 04:46:42 am
Why don't you try? It's not that hard.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 03, 2010, 07:09:56 am
Yes! I will be very grateful if you guys help me out with this one, it's been a pain for a month..

Quotewhat he meant

It is hard to be female in this world :(
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 03, 2010, 10:51:26 am
Sorry didn't notice. :( Also I started on it. The whole map gets covered by black. :o And right now theres only area around the player that is seeable. Still working on erasing parts teh player has explored. Though it shouldn't be too hard.

EDIT: Also read my last post.:)
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 09, 2010, 11:15:26 am
I'm glad you're helping me.. How is this going?
Thanks for correcting that  :D
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 09, 2010, 03:59:31 pm
Its about done actually haven't had much time to work on it.
Title: Re: Fog of War for Blizz ABS
Post by: Shalaren on August 12, 2010, 08:52:39 am
is this what you are looking for?
Spoiler: ShowHide
=begin


  Fog of War System(FOW) V1.0 by Samo, the Thief

  Instructions:
  -------------
 
  1-Put this Script Above Main
 
  2- Add in Scene_Title the lines Between ADDED:
 
  $game_map.update
  #-----------ADDED------------------------
    $game_fog_of_war    = Game_Fog_Of_War.new
  #-----------ADDED------------------------
 
  3- The Same in Scene_Map the with this:
 
    @message_window.update
  #---------------------------------ADDED-------------
    if wait(20)
      $game_fog_of_war.update
      @spriteset.update_tilemap
    end 
    #---------------------------------ADDED-------------
   
  4- Go to your tilesets and put with counter 1 the tiles you don't want
  to be seen through, like walls or trees.
 
  5- Enjoy!
 
  Feautures:
  ----------
  -YOu can't see thorugh some tiles depending on where you are
  -The tiles you revealed and you are not seeing are semi-revealed
  -It is cool!
 
=end


class Game_Fog_Of_War
#--------------------------------------------------------------------
  attr_accessor :map_grid
  SIGHTNESS = 9
#--------------------------------------------------------------------
  def initialize
    @map_grid = {}
      for i in 1..$map_infos.size
        data = load_data(sprintf("Data/Map%03d.rxdata", i))
        @map_grid[i] = Array.new(data.width, 0)
        for j in 0..data.width
          @map_grid[i][j] = Array.new(data.height, 0)
        end
      end
      $map_grid_wall = Array.new($game_map.width, 0)
      for j in 0..$game_map.width
        $map_grid_wall[j] = Array.new($game_map.height, 0)
      end
      refresh_grid
      @last_fow = []
  end
#-------------------------------------------------------------------------
  def setup_map(map_id)
    data = load_data(sprintf("Data/Map%03d.rxdata", map_id))
    @map_grid[i] = Array.new(data.width, 0)
    for j in 0..data.width
      @map_grid[i][j] = Array.new(data.height, 0)
    end
  end
  #--------------------------------------
  def refresh_grid
    $map_grid_wall = Array.new($game_map.width, 0)
    for j in 0..$game_map.width
      $map_grid_wall[j] = Array.new($game_map.height, 0)
    end
    for i in 0..$game_map.width
      for j in 0..$game_map.height
        if $game_map.terrain_tag(i,j) == 1
          $map_grid_wall[i][j] = 1
        end
      end
    end
  end
#----------------------------------------------------------------------
  def update
    in_range_tiles
  end
  #-----------------------------------------------------
  def circle_of_view(x,y,sightness)
    coords = []
    fow = []
    fx1 = x + sightness
    fx2 = x - sightness
    fy1 = y + sightness
    fy2 = y - sightness
    coords += line(fx1,y,x,fy1)
    coords += line(x-1,fy1-1,fx2,y)
    coords += line(fx2+1,y-1,x,fy2)
    coords += line(x+1,fy2+1,fx1-1,y-1)
    for coord in coords
      fow = fow | line_fow(x,y,coord[0],coord[1]) #Weird Method je,je
    end
    for coord in fow
      if coord[0] < 0 or coord[0] > $game_map.width or coord[1] < 0 or coord[1] > $game_map.height
        next
      end
      @map_grid[$game_map.map_id][coord[0]][coord[1]] = 2
    end
    return fow
  end
#------------------------------------------------------------------------
  def in_range_tiles
    fow = circle_of_view($game_player.x,$game_player.y,SIGHTNESS)
    for coord in @last_fow
      x = coord[0]
      y = coord[1]
      if x < 0 or x > $game_map.width or y < 0 or y > $game_map.height
        next
      end 
      if @map_grid[$game_map.map_id][x][y] == 2
        if fow.include?([x,y]) == false
          @map_grid[$game_map.map_id][x][y] = 1
        end
      end
    end
    @last_fow = fow.clone
  end
#---------------------------------------------------------------------------- 
end


class Spriteset_Map
  alias old_initialize initialize
  def initialize
    #=================
    old_initialize
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport4.z = 5004
    @fow_tilemap = Tilemap.new(@viewport4)
    @fow_tilemap.tileset = RPG::Cache.picture("FOW")
    @fow_tilemap.autotiles[0] = RPG::Cache.autotile("FOW0")
    data = Table.new($game_map.width, $game_map.height, 3)
    @fow_tilemap.map_data = data
    priorities = Table.new(424)
    # set to highest priority to ensure everything is covered
    for i in 0...424
    priorities[i] = 5
    end
    @fow_tilemap.priorities = priorities
     for x in 0...$game_map.width
        for y in 0...$game_map.height
          if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 0
            if @fow_tilemap.map_data[x,y,2] != 384
              @fow_tilemap.map_data[x,y,2] = 384
            end
          end
          if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 1
            if @fow_tilemap.map_data[x,y,2] != 385
              @fow_tilemap.map_data[x,y,2] = 385
            end
          end
          if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 2
            if @fow_tilemap.map_data[x,y,2] != 386
              @fow_tilemap.map_data[x,y,2] = 386
            end
          end
        end
      end
    #=================
    update
  end 
  alias old_dispose dispose
  def dispose
    old_dispose
    @fow_tilemap.tileset.dispose
    @fow_tilemap.autotiles[0].dispose
    @fow_tilemap.dispose
    @viewport4.dispose
  end
    #--------------------------------------------------------------------------
  def update_tilemap
  for x in 0...$game_map.width
    for y in 0...$game_map.height
      if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 0
        if @fow_tilemap.map_data[x,y,2] != 384
          @fow_tilemap.map_data[x,y,2] = 384
        end
      end
      if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 1
        if @fow_tilemap.map_data[x,y,2] != 385
      @fow_tilemap.map_data[x,y,2] = 385
      end
      end
      if $game_fog_of_war.map_grid[$game_map.map_id][x][y] == 2
        if @fow_tilemap.map_data[x,y,2] != 386
          @fow_tilemap.map_data[x,y,2] = 386
      end
      end
    end
  end
end
#---------------------------------------------------
  alias old_update update
  def update
    old_update
    @fow_tilemap.ox = $game_map.display_x / 4
    @fow_tilemap.oy = $game_map.display_y / 4
    @fow_tilemap.update
    @viewport4.update
  end
end

def wait(frames)
  if Graphics.frame_count % (frames) == 0
    return true
  end 
end



def line(a,b,c,d)
  coords = []
     u = c - a
     v = d - b
     d1x = sgn(u)
     d1y = sgn(v)
     d2x = sgn(u)
     d2y = 0
     m = ABS(u)
     n  = ABS(v)
     if not m > n
        d2x  = 0
        d2y  = sgn(v)
        m  = ABS(v)
        n  = ABS(u)
     end
     s  = m / 2
     for i in 0..m
          coords.push([a,b])
          s  = s + n
          if not (s<m)
               s = s - m
               a = a + d1x
               b = b + d1y
          else
              a = a + d2x
              b = b + d2y
          end
        end   
    return coords
  end
  #-------------------------------
def line_fow(a,b,c,d)
  coords = []
     u = c - a
     v = d - b
     d1x = sgn(u)
     d1y = sgn(v)
     d2x = sgn(u)
     d2y = 0
     m = ABS(u)
     n  = ABS(v)
     if not m > n
        d2x  = 0
        d2y  = sgn(v)
        m  = ABS(v)
        n  = ABS(u)
     end
     s  = m / 2
     for i in 0..m
          coords.push([a,b])
          if a >= 0 and a <= $game_map.width and b >= 0 and b <= $game_map.height
            break if $map_grid_wall[a][b] == 1
          end
          s  = s + n
          if not (s<m)
               s = s - m
               a = a + d1x
               coords.push([a,b])
               b = b + d1y
          else
              a = a + d2x
              coords.push([a,b])
              b = b + d2y
          end
        end   
    return coords
  end
def sgn(a)
  return sgn = +1 if a>0
  return sgn = -1 if a<0
  return sgn = 0 if a==0
end

def ABS(a)
  return a if a > 0
  return a * -1 if a < 0
  return 0
end 


#========================================
#Game_Map
#--------------------------------------------------------------------------
# Setting functions for the Map
#========================================
class Game_Map

def name
$map_infos[@map_id]
end
end

#========================================
#Window_Title
#--------------------------------------------------------------------------
# Setting functions for the Title
#========================================
class Scene_Title
$map_infos = load_data("Data/MapInfos.rxdata")
for key in $map_infos.keys
$map_infos[key] = $map_infos[key].name
end
end

1-Put this Script Above Main

2- Add in Scene_Title the lines Between ADDED:

$game_map.update
#-----------ADDED------------------------
$game_fog_of_war = Game_Fog_Of_War.new
#-----------ADDED------------------------

3- The Same in Scene_Map the with this:

@message_window.update
#---------------------------------ADDED-------------
if wait(20)
$game_fog_of_war.update
@spriteset.update_tilemap
end
#---------------------------------ADDED-------------

4- Go to your tilesets and put with counter 1 the tiles you don't want
to be seen through, like walls or trees.
Title: Re: Fog of War for Blizz ABS
Post by: Badlands on August 12, 2010, 10:00:17 am
Thanks but no, that is laggy and complex (at least not as laggy as wachunga's one), I do not want passability tiles or anything like that, I just want a simple, non laggy script to work exclusively for BlizzABS like the Berka's one I mentioned in my first post. Here it is
Spoiler: ShowHide


#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Fog of War 22/05/09
#-------------------------------------------------------------------------------
# ver.0.1 par Berka rgss.2
# http://www.rpgmakervx-fr.com
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Add a Fog of War on the Map
#-------------------------------------------------------------------------------
# Commands:
# Fog.clear_fog(map_id) # clear the bitmap (all black)
# vu_par_hero?(x,y) # chek if [x,y] is viewed by the hero
# $RayonFog = i # modify the hero's view range
#-------------------------------------------------------------------------------
# Features:
# * Switch hides the fog
# * the fog of each map is saved
# * threading system (faster) for fog's borders
# Do not use for large maps: FPS may be down
#=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

module Berka
module Brouillard
$RayonFog = 3 # View Range: calculs are optimized for 3 or 6
FichFog = "fog.png" # File of fog tileset: only the first pattern is used
# may be placed on: Graphics/System
IDFog = 1 # Switch_Id: if switch == true: hides the fog
ZFog = 300 # fogs 's priorities
Act_GC = true # Garbage Collector managment

# Do not Change !!!!
Tiles={ # fog's tileset indexes
"0"=>2816,"1"=>2824,"12"=>2844,"123"=>2844,"1234"=>2856,"12346"=>2860,
"123467"=>2860,"1234678"=>2862,"12346789"=>2862,"1234679"=>2860,"123468"=>2862,
"1234689"=>2862,"123469"=>2860,"12347"=>2856,"123478"=>2859,"1234789"=>2859,
"123479"=>2857,"12348"=>2859,"123489"=>2859,"12349"=>2857,"1236"=>2854,
"12367"=>2855,"123678"=>2861,"123679"=>2855,"1236789"=>2861,"12368"=>2861,
"123689"=>2861,"12369"=>2854,"1237"=>2845,"12378"=>2849,"123789"=>2849,
"12379"=>2847,"1238"=>2849,"12389"=>2849,"1239"=>2846,"124"=>2856,"1246"=>2860,
"12467"=>2860,"124678"=>2862,"1246789"=>2862,"124679"=>2860,"12468"=>2862,
"124689"=>2862,"12469"=>2860,"1247"=>2856,"12478"=>2859,"124789"=>2859,
"12479"=>2857,"1248"=>2859,"12489"=>2859,"1249"=>2857,"126"=>2854,"1267"=>2855,
"12678"=>2861,"126789"=>2861,"12679"=>2855,"1268"=>2861,"12689"=>2861,"1269"=>2854,
"127"=>2845,"1278"=>2849,"12789"=>2849,"128"=>2849,"1289"=>2849,"129"=>2846,
"13"=>2828,"134"=>2834,"1346"=>2848,"13467"=>2848,"134678"=>2858,"1346789"=>2858,
"134679"=>2848,"13468"=>2858,"134689"=>2858,"13469"=>2848,"1347"=>2834,
"13478"=>2851,"134789"=>2851,"13479"=>2835,"1348"=>2851,"13489"=>2851,
"1349"=>2835,"136"=>2841,"1367"=>2843,"13678"=>2853,"136789"=>2853,"13679"=>2843,
"1368"=>2853,"13689"=>2853,"1369"=>2841,"137"=>2829,"1378"=>2839,"13789"=>2839,
"138"=>2839,"1389"=>2839,"139"=>2830,"14"=>2832,"146"=>2848,"1467"=>2848,
"14678"=>2858,"146789"=>2858,"14679"=>2848,"1468"=>2862,"14689"=>2858,"1469"=>2848,
"147"=>2832,"1478"=>2850,"14789"=>2850,"1479"=>2833,"148"=>2850,"1489"=>2850,
"149"=>2833,"16"=>2841,"167"=>2843,"1678"=>2853,"16789"=>2853,"1679"=>2848,
"168"=>2853,"1689"=>2853,"169"=>2841,"17"=>2825,"178"=>2838,"1789"=>2838,
"179"=>2827,"18"=>2838,"189"=>2838,"19"=>2826,"2"=>2844,"23"=>2844,"234"=>2856,
"2346"=>2860,"23467"=>2860,"234678"=>2862,"2346789"=>2862,"234679"=>2862,
"23468"=>2862,"234689"=>2862,"23469"=>2860,"2347"=>2856,"23478"=>2859,
"234789"=>2859,"23479"=>2857,"2348"=>2859,"23489"=>2859,"2348"=>2859,"236"=>2854,
"2367"=>2855,"23678"=>2861,"236789"=>2861,"23679"=>2855,"2368"=>2861,"23689"=>2861,
"2369"=>2854,"237"=>2845,"2378"=>2849,"23789"=>2849,"2379"=>2847,"238"=>2849,
"2389"=>2849,"239"=>2846,"24"=>2856,"246"=>2860,"2467"=>2860,"24678"=>2862,
"246789"=>2862,"24679"=>2860,"2468"=>2862,"24689"=>2862,"2469"=>2860,"247"=>2856,
"2478"=>2859,"24789"=>2859,"2479"=>2847,"248"=>2859,"2489"=>2859,"249"=>2857,
"26"=>2854,"267"=>2854,"2678"=>2861,"26789"=>2861,"2679"=>2855,"268"=>2861,
"2689"=>2861,"269"=>2854,"27"=>2845,"278"=>2849,"2789"=>2849,"279"=>2847,"28"=>2849,
"289"=>2849,"29"=>2846,"3"=>2820,"34"=>2834,"346"=>2848,"3467"=>2848,"34678"=>2858,
"346789"=>2858,"34679"=>2848,"3468"=>2858,"34689"=>2858,"3469"=>2848,"347"=>2834,
"3478"=>2851,"34789"=>2851,"3479"=>2835,"348"=>2851,"3489"=>2851,"349"=>2835,
"36"=>2840,"367"=>2842,"3678"=>2852,"36789"=>2852,"3679"=>2842,"368"=>2852,
"3689"=>2852,"369"=>2840,"37"=>2821,"378"=>2837,"3789"=>2837,"379"=>2823,
"38"=>2837,"389"=>2837,"39"=>2822,"4"=>2832,"46"=>2848,"467"=>2848,"4678"=>2858,
"46789"=>2858,"4679"=>2848,"468"=>2858,"4689"=>2858,"469"=>2848,"47"=>2832,
"478"=>2850,"4789"=>2850,"479"=>2833,"48"=>2850,"489"=>2850,"49"=>2833,
"6"=>2840,"67"=>2842,"678"=>2852,"6789"=>2852,"679"=>2842,"68"=>2852,
"689"=>2852,"69"=>2840,"7"=>2817,"78"=>2836,"789"=>2836,"79"=>2819,"8"=>2836,
"89"=>2836,"9"=>2818
} # et tu payes ton mal de crâne, pour trouver chaque valeur ^^
end
end
module Fog
def self.clear_fog(id)
$game_temp.br_maps.delete(id)
return if !$scene.is_a?(Scene_Map)
$scene.spriteset.dispose
$scene.spriteset=Spriteset_Map.new
end
end
Win32API.new('kernel32','SetPriorityClass','pi','i').call(
Win32API.new('kernel32','GetCurrentProcess','','i').call,256)
include Berka::Brouillard
class Spriteset_Map
alias :br_create :create_tilemap
alias :br_dispose :dispose_tilemap
alias :br_view :dispose_viewports
alias :br_update :update_tilemap unless $@
alias :br_view_update :update_viewports unless $@
attr_accessor :br_tile,:tilemap
def create_tilemap
br_create
@br_tile=Tilemap.new(@br_view=Viewport.new(0,0,Graphics.width,Graphics.height))
@br_view.z=ZFog
8.times{|i|@br_tile.bitmaps[i]=@tilemap.bitmaps[i].clone}
@br_tile.bitmaps[1]=Cache.system(FichFog)
@br_tile.map_data=Table.new($game_map.width,$game_map.height,3)
clear_fog
end
def clear_fog
w,h=$game_map.width,$game_map.height
if $game_temp.br_maps.has_key?($game_map.map_id)
for x in 0...w;for y in 0...h
if $game_temp.br_maps[$game_map.map_id][x,y]==0
@br_tile.map_data[x,y,1]=2816
a||=true
else
@br_tile.map_data[x,y,1]=0
a||=false
end
end;end
if a
Thread.new{for x in 0...w;for y in 0...h
chk(x,y)
end;end}
end
else
$game_temp.br_maps[$game_map.map_id]||=Table.new(w,h)
for x in 0...w;for y in 0...h
@br_tile.map_data[x,y,1]=2816
$game_temp.br_maps[$game_map.map_id][x,y]=0
end;end
end
end
def dispose_tilemap
br_dispose
@br_tile.dispose
end
def dispose_viewports
br_view
@br_view.dispose
end
def update_tilemap
br_update
if $game_switches[IDFog]
@br_tile.dispose
return
end
GC.start if !$game_player.moving?&&Act_GC
return if !$game_temp.br_maps.has_key?($game_map.map_id)
br_obscurcis
x,y=$game_map.display_x/8,$game_map.display_y/8
return if x==@br_tile.ox&&y==@br_tile.oy
@br_tile.ox,@br_tile.oy=x,y
@br_tile.update
end
def br_obscurcis
x,y=$game_player.x,$game_player.y
rx,ry=(x-$RayonFog-2..x+$RayonFog+2).to_a,(y-$RayonFog-2..y+$RayonFog+2).to_a
for tx in rx
for ty in ry
r=Math.sqrt(((x-tx)**2+(y-ty)**2))
chk(tx,ty)if r.between?($RayonFog,$RayonFog+2)
next if !tx.between?(rx[0],rx[-1])
if r<=$RayonFog
@br_tile.map_data[tx,ty,1]=0
$game_temp.br_maps[$game_map.map_id][tx,ty]=1
end
end
end
end
def chk(x,y)
return if !$game_temp.br_maps.has_key?($game_map.map_id)||x.nil?||y.nil?||
$game_temp.br_maps[$game_map.map_id][x,y]==1
d=@br_tile.map_data
l=[]
l<<1 if d[x-1,y+1,1]==0
l<<2 if d[x,y+1,1]==0
l<<3 if d[x+1,y+1,1]==0
l<<4 if d[x-1,y,1]==0
l<<6 if d[x+1,y,1]==0
l<<9 if d[x+1,y-1,1]==0
l<<8 if d[x,y-1,1]==0
l<<7 if d[x-1,y-1,1]==0
l=l.sort.join
return if l.nil?||l==""
@br_tile.map_data[x,y,1]=Tiles[l]
end
def update_viewports
br_view_update
@br_view.update
end
end
class Game_Temp
alias :br_initialize :initialize
attr_accessor :br_maps
def initialize
br_initialize
@br_maps={}
end
end
def vu_par_hero?(x,y)
Math.sqrt((($game_player.x-x)**2+($game_player.y-y)**2))<=$RayonFog
end
class Scene_Map<Scene_Base # correctif: màj spriteset 1/frame
attr_accessor :spriteset
def update_basic
Graphics.update
Input.update
$game_map.update
end
end
class Scene_File<Scene_Base
alias :br_write_save :write_save_data
alias :br_read_save :read_save_data
def write_save_data(file)
br_write_save(file)
Marshal.dump($game_temp.br_maps,file)
end
def read_save_data(file)
br_read_save(file)
$game_temp.br_maps=Marshal.load(file)
end
end


I really trust game_guy this one, like my last hope   :^_^':
Title: Re: Fog of War for Blizz ABS
Post by: G_G on August 12, 2010, 10:24:23 am
Sorry I've been busy, trying to finish it but :(