Creation/Dev/Dungeon Generator/Cave Fix

From Graal Bible

If you use the dungeon generator to generate caves for Graal Kingdoms, you will find that it is possible for fast players to glitch on top of the non-walkable space and then walk around on it.

The problem is that the tile definitions used for caves use a non-blocking selection of tiles for outside of the path.

To fix that, place this script in an NPC on your server and run it, being sure to change the GMAP name near the top:

function onCreated() {
  // you can use a level or a GMAP here, just make sure to
  // use the proper extension
  temp.levelToFix = findLevel("mycave.gmap");
  
  // don't change this
  if (levelToFix == null) {
    return echo("Error: Level doesn't exist!");
  }
  
  temp.tilesToChange = {
    {2560, 2818},
    {2561, 2819},
    {2562, 2820},
    {2563, 2821},
    {2576, 2834},
    {2577, 2835},
    {2578, 2836},
    {2579, 2837},
    {2592, 2850},
    {2593, 2851},
    {2594, 2852},
    {2595, 2853},
    {2608, 2866},
    {2609, 2867},
    {2610, 2868},
    {2611, 2869}
  };
  
  // create simple arrays
  temp.changeFrom = null;
  temp.changeTo = null;
  
  // avoid max loop limit
  temp.i = 0;
  this.avoidLimit = function(i) {
    if (i >= (this.maxlooplimit - 1)) {
      sleep(0.1);
      return 0;
    }
    
    return (++ i);
  };
  
  for (temp.tile : tilesToChange) {
    changeFrom.add(tile[0]);
    changeTo.add(tile[1]);
    
    i = this.avoidLimit(i);
  }
  
  // make changes
  for (temp.x = 0; x < levelToFix.width; x ++) {
    for (temp.y = 0; y < levelToFix.height; y ++) {
      temp.currentTile = levelToFix.tiles[x, y];
      temp.fixIndex = changeFrom.index(@ currentTile);
      
      if (fixIndex > (- 1)) {
        temp.newTile = changeTo[fixIndex];
        levelToFix.tiles[x, y] = newTile;
      }
      
      i = this.avoidLimit(i);
    }
    
    i = this.avoidLimit(i);
  }
  
  // save changes
  levelToFix.updateBoard2(0, 0, levelToFix.width, levelToFix.height);
}

Keep in mind that some players will see the old levels until the modified date is changed. To change the modified date so that all players see the fixed levels, download and reupload the modified levels.