First of all I am aware of an extension along the lines of advanced direction object. However, for two reasons this is not a path I want to take.
1. I have already fully coded some of the objects I wish to use this function for, as active objects. To change them would mean having to completely code them again from the ground up.
2. People told me that I needed to download advanced movement extensions to make accurate collisions but I was able to code them myself with a bit of time. The latter was far more rewarding and my last game truly felt like something I created because of it.
So, the question remains: How do you create a system to select the nearest object of a type to the active object you want to identify?
To be more specific, here's an example of what I'm trying to do.
An enemy is disarmed, and it's looking to pick up a weapon on the ground. There are two swords: Sword A and Sword B — Both are an instance of the same thing. One is farther away, one is closer.
What would you do to make the enemy's AI recognize the closer weapon as the most viable option, such that in the same scenario should Sword A be closer than Sword B, the enemy would go for Sword A; and vice versa, with potentially many more swords.
If this is complicated, I'm willing to learn. I'd rather understand what I'm doing than wing it off of other people's creations, with no disrespect to their skill or talent.