I just threw this together, and I know it's done sloppily, but it works 100% correctly
Feel free to revise and repost if you can clean it up a bit
EDIT
Revised code after help from Kataang
Code:
public static void removeAreaObjects(int areaTopLeftX, int areaTopLeftY, int areaBottomRightX, int areaBottomRightY) {
for(int x = areaTopLeftX; x <= areaBottomRightX; x++) {
for(int y = areaBottomRightY; y <= areaTopLeftY; y++) {
ReplaceObject(x, y, 6951, -1, 10);
}
}
}
Here's the original if anyone wants
Code:
public void removeAreaObjects(int areaTopLeftX, int areaTopLeftY, int areaBottomRightX, int areaBottomRightY) { //Made by MerzA
areaTopLeftY+=2;
int replaceX = 0, replaceY = 0, boundsX = areaBottomRightX - areaTopLeftX, boundsY = areaTopLeftY - areaBottomRightY, totalReplace = (areaBottomRightX - areaTopLeftX)*(areaTopLeftY - areaBottomRightY)+5;
for (int replacing = (areaBottomRightX - areaTopLeftX)*(areaTopLeftY - areaBottomRightY) + 5; replacing > 0; replacing--) {
if (boundsY >= 0) {
if (boundsX >= 0) {
replaceX = areaBottomRightX - boundsX;
replaceY = areaTopLeftY - boundsY;
} else if (boundsX < 0) {
boundsX = areaBottomRightX - areaTopLeftX;
boundsY--;
replaceX = areaBottomRightX - boundsX;
replaceY = areaTopLeftY - boundsY;
}
}
ReplaceObject(areaBottomRightX - boundsX, areaTopLeftY - boundsY, 6951, -1, 10);
boundsX--;
//misc.println("Removing " + replaceX + ", " + replaceY + " - " + ((totalReplace-replacing) + 1) + "/"+ totalReplace);
}
}
Put the methods with your defined parameters wherever you create or destroy global objects (heck you can even throw them all in your case 121 if you want)
If you use this, please post :]
NOTE: I would only use this for small areas where objects are located side by side in a grid (ie fields of cabbage?). Using this in areas with excessive empty tiles is unadvised