Game_Action error message

I am a good hour into a play through and have fought probably 20+ battles without any problem. However, for no obvious reason, I've just got this error message:

upload_2019-4-3_15-10-44.png


Nothing special had just happened. An actor had defeated an enemy using Attack, so it's not a knock-on effect from using a skill.

Does anyone have any idea what might have caused this?

For information's sake, I am using Yami's PCTB script which can be found here.
I guess it's because Yami's PCTB script change turn's order.
So after the enemy get killed, the system still calculate its next action, thus lead to this error?
You can prevent it by insert this script above another custom scripts,
it's not the nicest way but, well
Code:
  #--------------------------------------------------------------------------
  # * Create Target Array
  #--------------------------------------------------------------------------
class Game_Action
  def make_targets
    if !forcing && subject.confusion?
      [confusion_target]
    elsif !item.nil? && item.for_opponent?
      targets_for_opponents
    elsif !item.nil? && item.for_friend?
      targets_for_friends
    else
      []
    end
  end
end
@CrushedMeat I've done about 10 or so battles, and there have been no problems, so it looks like your fix works.

I am extremely grateful to you for this. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/game_action-error-message.107558/