How to apply explosion/magic/grenade damage to detect objects (enemies) within a given radius, and apply AOE damage to each enemy based on its distance?

I saw a couple of questions along these lines but there's differences.

I'm trying to accomplish a couple of things here. One a enemy detection by searching a radius every so often. Second I'd like to use the same sort of function to create an AOE damage effect. I've already created a GetDistance from two objects. From previous RPG games a function was created called GetFirst and GetNext and was very nice and I'd like to replicate that again.

This code would run on a WHILE going through the game objects one at a time till they return to the first one. Inside this I would use my GetDistance to determine if they can be targeted or not (AOE spells). I have a lot of other uses for this as well.

I know how to find objects by name, but is there a way to just go through each object? (running it as code should be pretty quick as its just running a small function (GetDistance).

Thanks

EDIT: Also see this question which expands on the code below, adding tests for whether objects are behind cover.

If your enemies have colliders attached, you can use Physics.OverlapSphere to quickly get your initial list of enemies within a certain radius.

You can then loop through each enemy within this list and determine the relative distance to the player, and apply some level of damage to each enemy within the radius, proportional to its distance.

It would end up looking something like this. It assumes that your enemy objects have both a collider and a script called "Enemy" attached.

In C#:

void AreaDamageEnemies(Vector3 location, float radius, float damage)
{
    Collider[] objectsInRange = Physics.OverlapSphere(location, radius);
    foreach (Collider col in objectsInRange)
    {
        Enemy enemy = col.GetComponent<Enemy>();
        if (enemy != null)
        {
            // linear falloff of effect
            float proximity = (location - enemy.transform.position).magnitude;
            float effect = 1 - (proximity / radius);

            enemy.ApplyDamage(damage * effect);
        }
    }
}

And in Javascript:

function AreaDamageEnemies(location : Vector3, radius : float , damage : float )
{
    var objectsInRange : Collider[] = Physics.OverlapSphere(location, radius);
    for (var col : Collider in objectsInRange)
    {
        var enemy : Enemy = col.GetComponent(Enemy);
        if (enemy != null)
        {
            // linear falloff of effect
            var proximity : float = (location - enemy.transform.position).magnitude;
            var effect : float = 1 - (proximity / radius);

            enemy.ApplyDamage(damage * effect);
        }
    }
}

(untested code, for illustration only!)

Take a look at the reference for the built-in function AddExplosionForce (with JS example, uses also Physics.OverlapSphere).