Actor inventory error

I have in my project a script by Hime that give to every actor a personal inventory, also in battle.
When i use an item called "bomb" that damages every enemy it pops an error: "undefined method 'last item' for nil:NilClass", but if the item is single target it goes fine. The script is this one.
Code:
class Window_BattleItem < Window_ItemList
  #--------------------------------------------------------------------------
  # * Include in Item List?
  #--------------------------------------------------------------------------
  def include?(item)
    @actor ? @actor.usable?(item) : false
  end
end

class Scene_Battle < Scene_Base

  alias :th_actor_inventory_command_item :command_item
  def command_item
    @item_window.actor = BattleManager.actor
    th_actor_inventory_command_item
  end

  alias :th_actor_inventory_on_item_ok :on_item_ok
  def on_item_ok
    th_actor_inventory_on_item_ok
    BattleManager.actor.last_item.object = @item
  end
end
It add the "multiple inventory" to the battle.
Do you know where is the error?
If you needthe other scripts tell me.
Thanks.

EDIT: If I comment this line:
Code:
    BattleManager.actor.last_item.object = @item
It seems to go well. Is this line necessary?
It seems to go well. Is this line necessary?
yes and no

all "last-used" variables are basically placeholders for information, and it depends on what you do after if you need that information or not.
For example the force action event command holds the option "last target", that can of course only function if the engine stores that "last ... " information.
But if you don't use that event command, that storage is never used.

same with this case - if there is anything later that needs to check which item was last used, it will cause problems if the line is commented out.

Additionally, removing lines is almost never a way to solve problems - that would be like saying "my car reports an oil problem - would it solve the problem if I remove all oil from it?" - no, running the car without oil will damage or destroy the engine.

In this case however it might be a script conflict - If I remember correctly, the last-item option was added by one of Tsukihime's script and is not part of the default engine, so it might be that this is simply a script order problem.
So what i should do? Can you show me an example when is used last item, becouse i'm a bit confused. Sorry I'm not very good in scripting.

And, do you have any idea about why it pops only if the item is multiple target?

I've moved this thread to RGSS3 Script Support. Thank you.

Moved to: RGSS3 Script Support
thank you i'll pay more attenction
It means there is not an actor. You've done something wrong and it's trying to assign the item used as the 'last item used' for an actor that doesn't exist. So it's not the script that's the problem - it's just a symptom of something else you've done wrong.

Any chance you deleted actors from the Actors tab to remove them from your starting party?
It means there is not an actor. You've done something wrong and it's trying to assign the item used as the 'last item used' for an actor that doesn't exist. So it's not the script that's the problem - it's just a symptom of something else you've done wrong.

Any chance you deleted actors from the Actors tab to remove them from your starting party?

in my game there's no starting party becouse the starting scene is a black screen whit dialog. The actor is added after this scene with "chenge group" function.
The game has multiple protagonist, it means that at a certain point the party removes and begin a parallel story with another actor. I don't know if the problem is connecter to this.
The error pops only if the item targets all the enemies, with single target is fine.
How did you make it so that there's no starting party? Back to my original question - did you delete actors from the Actors tab?
How did you make it so that there's no starting party? Back to my original question - did you delete actors from the Actors tab?
no, i still have the defaul actors (unused) and 5 of mine. What do you mean?

Original thread: https://forums.rpgmakerweb.com/threads/actor-inventory-error.129580/