VXAce How/Where do enemies select their targets in battle?

I've been improving enemy AIs recently but I've hit a roadblock for my next steps. I wanted to add a "reconsider" function that will check if the currently selected skill is even worth using against the currently selected target. Then it will reselect a different target if it decides it isn't, or if NO target is worthwhile, it will pick an entirely new skill.
An example of this is if a skill causes Bleeding and the current target is already Bleeding; a bit of a waste of an action, which is what I want to avoid.

My problem, however, is that I can't for the life of me find where or how the enemies decide their target. I could just be being silly but it has eluded me thus far. I've looked around in Game_Battler, Game_Action, and even RPG::Enemy::Action. Probably other places.

I'd greatly appreciate it if anyone can point me in the right direction!
Thanks.
I can't tell you where it is, but I can describe the how.

and that is basically random weighted by target rate.

by default every actor has a target rate of 100 and each has the same chance to be selected.
if you give one actor double the target rate, then that actor would have double the chance of being selected.

example: a party of four with target rates 100, 100, 100, 300
would result in the first actor being selected 100/600 times, the second and third actor would have the same rate while the fourth actor would be selected 300/600 times or every second skill use by the enemy.
IIRC it is in Game_Action, look for "make_targets".
The enemies will choose their skill at the start of the turn (after the player picked their actions), in Game_Enemy at the end of the script you will find these two methods:

Ruby:
class Game_Enemy
    #--------------------------------------------------------------------------
  # * Randomly Select Action
  #     action_list:  RPG::Enemy::Action array
  #     rating_zero:  Rating value to consider as zero
  #--------------------------------------------------------------------------
  def select_enemy_action(action_list, rating_zero)
    sum = action_list.inject(0) {|r, a| r += a.rating - rating_zero }
    return nil if sum <= 0
    value = rand(sum)
    action_list.each do |action|
      return action if value < action.rating - rating_zero
      value -= action.rating - rating_zero
    end
  end
  #--------------------------------------------------------------------------
  # * Create Battle Action
  #--------------------------------------------------------------------------
  def make_actions
    super
    return if @actions.empty?
    action_list = enemy.actions.select {|a| action_valid?(a) }
    return if action_list.empty?
    rating_max = action_list.collect {|a| a.rating }.max
    rating_zero = rating_max - 3
    action_list.reject! {|a| a.rating <= rating_zero }
    @actions.each do |action|
      action.set_enemy_action(select_enemy_action(action_list, rating_zero))
    end
  end
end #Game_Enemy

The target is random and will be decided when it's time to use it (just like random skills from the user) in method use_item from Scene_Battle.

The method called will be make_targets from Game_Action which will then call a random target because none was provided by the enemy.
This is familiar. I think the targets_for_opponents method is what I want, which I get to through make_targets. I'm not sure why I hadn't tried it before, perhaps I just missed it or thought it was for something else, no idea.

Thanks everyone! I'll knuckle down now and give it a go.

Original thread: https://forums.rpgmakerweb.com/threads/how-where-do-enemies-select-their-targets-in-battle.179114/