Thursday, March 19, 2009

How to create a new map (gat to fld)

The easy guide of How to create a new map .fld ? can be found here 
http://www.openkore.com/wiki/index.php/How_to_create_a_new_.fld_map%3F

edited by penz' - documentation writers team.

=============
I searched, only to find posts *always* telling the person to search, rather than talking a few pecks of the keyboard to explain how to do it (other than jumbling keywords into a short sentence) - let alone offering to do it for the person. I honestly think 90% of the ppl recommending gat2fld have never used it before.

Anyways, how to do it. Forget about any gat2fld zips/etc you find - the one I got was useless. Get a good GRF tool, then install ActivePerl 5.8.8.**. Snatch the gat & rsw files for the map you want out of the grf, and put them in a folder of your choice. In the same folder, create a file called gat2fld.pl with the following text inside (create as txt, then rename to pl):

====================================================================

#!/usr/local/bin/perl 


@dir_list = sort &dir_list("./"); 
foreach $file (@dir_list){ 
  if (-f "./$file" && $file =~ /\.s?gat?$/){ 
  $cnt++; 
  $file =~ s/.gat//; 
  print "$cnt\t$file\n"; 
  gat2fld($file); 
  } 


exit; 

sub dir_list{ 
  opendir(DIR,"$_[0]"); 
  local(@list) = readdir(DIR); 


sub gat2fld { 
  my $file = shift; 

  open IN, $file.".gat"; 
  open OUT, ">".$file.".fld"; 
  binmode(IN); 
  read(IN, $data, 16); 
  print OUT pack("S1", unpack("L1", substr($data, 6,4))); 
  print OUT pack("S1", unpack("L1", substr($data, 10,4))); 
  while (read(IN, $data, 20)) { 
  $temp = unpack("C1", substr($data, 14,1)); 
  if ($temp == 116) { 
  print OUT pack("C", 0x00); 
  } else { 
  print OUT pack("C", unpack("C1", substr($data, 14,1))); 
  } 
  } 
  close IN; 
  close OUT; 


====================================================================

Then dbl-click the pl you created, and it should make a fld file you can put in your bot's fields folder. Credits go to a few ppl on this forum for reposting the code a few times, and to those who kept telling others to search. If you want the peoples names, you can do what they suggested over and over...search  

files I used:
ActivePerl-5.8.8.817-MSWin32-x86-257965.msi (free selfinstaller)
grftool-win32-1.2.0.zip (grf tool)
sdata.grf (gat/rsw maps)

(PS, this *is* meant to jab at the constant rehashing of 'search for it' phrase when the info really isn't in the search in a comprehensible form, or not even there. And FYI, I turned this from a "how do I" to a "how to" thread mid-way since I put 2+2+8+5+148+12+255 [how the info was scatered around the forums] together to get it working)

1 comment:

  1. sir create a file called gat2fld.pl
    how to create such file sir...thanks

    ReplyDelete