Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Level Tiling Fixer (https://forums.graalonline.com/forums/showthread.php?t=134258450)

cbk1994 03-21-2010 08:30 AM

Level Tiling Fixer
 
Many servers use tiles that are supposed to be used in a block pattern, but often are destroyed by levelers who don't pay attention to such things. This script fixes it.

It turns this:

http://img689.imageshack.us/img689/119/oldw.png

into this:

http://img339.imageshack.us/img339/2056/newmt.png

I find it most useful on grass. It works on individual levels or GMAPs.

Note that you may have to download and reupload the levels because updateBoard2 doesn't always change the file modification time, which can result in old levels being shown for some players.

Example usage:
PHP Code:

FloodFiller.fill("my_map.gmap""water");

// or

FloodFiller.fillMultiple("mylevel.nw", {"water""road""grass"}); 

PHP Code:

// DBNPC FloodFiller
function onCreated() {
  
// pattern to fill; lay it out in rows
  
this.pattern.grass.pattern = {
                                {
102410251026102710281029},
                                {
104010411042104310441045},
                                {
105610571058105910601061},
                                {
107210731074107510761077},
                                {
108810891090109110921093},
                                {
110411051106110711081109}
                              };
  
  
// tiles to fill even if not in pattern
  //   (for filling blank levels with grass, etc)
  
this.pattern.grass.exceptions = {0};
  
  
  
  
// pattern to fill; lay it out in rows
  
this.pattern.water.pattern = {
                                 {
6465},
                                 {
8081}
                               };
  
  
// tiles to fill even if not in pattern
  //   (for filling blank levels with grass, etc)
  
this.pattern.water.exceptions = {};
}

public function 
floodMultiple(levelNamepatternNames) {
  for (
temp.patternName patternNames) {
    
flood(levelNamepatternName);
    
sleep(0.1);
  }
}

public function 
flood(levelNamepatternName) {
  
temp.floodLevel findLevel(levelName);
  
  if (
floodLevel == null) {
    return echo(
"Level Flood: Level '" levelName "' not found!");
  }
  
  
temp.pattern this.pattern.(@ patternName).pattern;
  
temp.exceptions this.pattern.(@ patternName).exceptions;
  
  if (
pattern == null) {
    return echo(
"Level Flood: Pattern '" patternName "' has no defined pattern!");
  }
  
  
this.maxlooplimit 100000// 100,000
  
sleep(0.1); // make the max loop limit take effect
  
  
this.loopCount 0;
  
  
temp.possibleTiles exceptions;
  
  for (
temp.row pattern) {
    for (
temp.tile row) {
      
possibleTiles.add(tile);
      
this.nextLoop();
    }
    
    
this.nextLoop();
  }
  
  for (
temp.0floodLevel.width++) {
    for (
temp.0floodLevel.height++) {
      for (
temp.layer floodLevel.tilelayers) {
        
temp.tile layer.tiles[xy];
        
        if (
tile in possibleTiles) {
          
// replace tile
          
          
temp.row pattern[row.size()];
          
layer.tiles[xy] = row[row.size()];
        }
        
        
this.nextLoop();
      }
      
      
this.nextLoop();
    }
    
    
this.nextLoop();
  }
  
  
floodLevel.updateBoard2(00floodLevel.widthfloodLevel.height);
  
  echo(
"Level Flood: Successfully applied pattern '" patternName "' to level '" floodLevel.name "'!");
}

// increase number of loops; do I need to wait?
function nextLoop() {
  
this.loopCount ++;
  
  if (
this.loopCount >= this.maxlooplimit 1) {
    
this.loopCount 0;
    echo(
"Level Flood: Working...");
    
sleep(0.1);
  }


It should work fine with layers (it checks each layer individually for tiles that need to be replaced), but I haven't tested it.

It might be a good idea to back the levels up first since I haven't tested this in some situations.

Clockwork 03-21-2010 12:05 PM

"You must spread repuation before...."

:(

Very nice chris.

Crono 03-21-2010 02:48 PM

Cool, should be useful for servers that use grass/water tiles that are bigger than 1x1. Especially Zone, that was a nightmare.

Inverness 03-21-2010 05:11 PM

Very useful, you got rep.

DrakilorP2P 03-21-2010 07:31 PM

The water looked better before your script touched it. :(

Crow 03-21-2010 08:20 PM

Quote:

Originally Posted by DrakilorP2P (Post 1563892)
The water looked better before your script touched it. :(

That's because the tiles suck :p

LoneAngelIbesu 03-21-2010 10:55 PM

Wow. This is incredibly useful for Valikorlia. I'll add this to my list of LAT tools, whenever I get around to scripting a container for all of them....

gj

adam 03-24-2010 10:31 PM

Quote:

Originally Posted by DrakilorP2P (Post 1563892)
The water looked better before your script touched it. :(

Bad tiles or not, it was better to do it wrong.


but that is a nice script anyway. I like it.


All times are GMT +2. The time now is 11:29 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.