// set the unit ID of the target
.@target_id = XXXXX;
// get the location of the target (change TYPE to PC/MOB/...)
getmapxy(.@map$, .@x, .@y, UNITTYPE_{{TYPE}}, .@target_id);
// get all mobs within a 3 cell radius around the target
.@count = getunits(BL_MOB, .@units[0], false, .@map$, max(0, .@x - 3), max(0, .@y - 3), .@x + 3, .@y + 3);
// iterate over the mob units
for (.@i = 0; .@i < .@count; ++.@i) {
.@unit = .@units[.@i];
// ... do something with your .@unit
}