Would you be willing to share that extension? That's basically what I'm trying to do. I guess I thought that the absRegion modes would only take affect if there were no enemies nearby. I'll give that a shot!
So under Game_Event.prototype.aiMoveExtension in SRPG_MoveMethod.js add the following code (edit to your liking). This code has 10% chance for enemy to move to nearest opponents, otherwise it will check if a region X tile is available and if so it will move towards region X, if its already on region X it will stay there (stand) and if all region X tiles are occupied it will move towards nearest opponent.
//<aiMove:'guard x'> //Move to region, if all region spots occupied then move to enemy
else if (meta.match(/guard\s+(\d+)/i)){
var region = meta.match(/guard\s+(\d+)/i)[1];
var occupied = [];
$gameMap.returnRegionXy(region).forEach(function(a) {
$gameMap.eventsXy(a[0], a[1]).forEach(function(b) {
if(b._srpgEventType == "actor" || b._srpgEventType == "enemy" || b._srpgEventType == "unitEvent") {
occupied.push([a[0], a[1]]);
}
});
});
if(Math.random() > 0.9) {
return 'nearestOpponent';
} else if($gameMap.returnRegionXy(region).length <= occupied.length && this.regionId() !== region) {
return 'nearestOpponent';
} else if(this.regionId() == region) {
return 'stand';
} else {
return 'absRegion ' + region;
}
}
It uses a new function called $gameMap.returnRegionXy
So plop this code anywhere below any script:
Game_Map.prototype.returnRegionXy = function (id) {
var arr = [];
for (var i = 0; i < $gameMap.width(); i++) {
for (j = 0; j < $gameMap.height(); j++) {
if ($gameMap.regionId(i, j) == id) {
arr.push([i, j]);
}
}
}
return arr;
}