I fail to see how 10-15 EntityDistance() calls every 4 seconds would consume any CPU time whatsoever.
But I'll throw some psuedu towards ya anyways... Break your map up into grids.. these grids can be waypoints, nodes or single pivots with a distance entity around them..
Your turrents would then only check the grids in it's location therefore not having to check every targetable mesh on the map.
ie: if targetable=turrentgridrange then ;preform check
A simple equation can be used to automatically break your worldspace into grid chunks based on max x,z... Y should'nt filter into grid locales unless you have very high stacking maps.
But I'll throw some psuedu towards ya anyways... Break your map up into grids.. these grids can be waypoints, nodes or single pivots with a distance entity around them..
Your turrents would then only check the grids in it's location therefore not having to check every targetable mesh on the map.
ie: if targetable=turrentgridrange then ;preform check
A simple equation can be used to automatically break your worldspace into grid chunks based on max x,z... Y should'nt filter into grid locales unless you have very high stacking maps.