Core/SmartAI: Implement SMART_TARGET_CLOSEST_FRIENDLY.

Parameter is distance to search for.

Closes #10521