Yami's PCTB giving error message

I am using Yami's Predicted Charge Turn Battle script which can be found here.

Everything works as expected - unless an enemy is killed by a counter attack. The game then crashes with this error message.

pctb error message.PNG


This happens even in a New Game.

The line of script being referred to is here:
Code:
# alias method: execute_action
#--------------------------------------------------------------------------
alias scene_battle_execute_action_pctb execute_action
def execute_action
scene_battle_execute_action_pctb
unless BattleManager.action_forced?
@subject.last_obj = @subject.current_action.item unless @subject.last_obj
end
end

with the culprit line being
@subject.last_obj = @subject.current_action.item unless @subject.last_obj

This seems to indicate definitively that it is the fact that the enemy has died that is causing the problem, as it is the last object.

Can anyone see a solution to this?
Thank you.
Without knowing the whole workflow, what if you change the line into something like this?
Code:
@subject.last_obj = @subject.current_action.item if @subject.current_action && [email protected]_obj
@TheoAllen That appears to have solved it. The enemy died without causing a game crash. Thank you very much indeed. I am deeply grateful for your help.

I shall leave this thread open in case something emerges with a mor prolonged play test, but I am hopeful that all will be well.

Original thread: https://forums.rpgmakerweb.com/threads/yamis-pctb-giving-error-message.107036/