Deleting an Actor's equipped items in the middle of battle?

Hi everyone! There's probably a simple work-around to this that I'm not seeing, but I'd like to know how I can have a party member doff an item in the middle of combat and have that item be deleted from their inventory. Imagine someone having their sword break mid-combat or their armor smashed to pieces, for example.

I first tried the built-in "Change Equipment" feature and have the specific item set to "None". This unequipped the item, but it returns the item to the inventory allowing it to be re-equipped later.

Next I figured you could just replace the equipment with a script. I am not too familiar with scripting or Ruby, but I was able to come across something like this and attempted it:

!$game_actors[1].change_equip(1, nil)

But calling this does the same as the built in "Change Equipment" feature I tried before!

Unless there's something more obvious that I don't know about, I think this might require some parameter to record what the equipped item is, then unequip it, and then remove it. Any advice on how I'd go about doing that? Or is there a simpler solution and I'm just nuking it?

Just to be clear, I'd like for this to be flexible, so that it can be used against the player no matter what it is they have equipped. Designing it around a specific item that I know the player would have equipped would be easy enough, but I want it to work on whatever they might have at that moment.

Thank you for your time!
Maybe something like this?
Ruby:
bat = $game_actors[1] #replace this with the proper actor
w = bat.weapons.first #get the first equipped weapon, you can also do bat.weapons[0]
bat.discard_equip(w) if w #remove it if it exists
Unless there's something more obvious that I don't know about
Change Equipment to none followed by
$game_party.lose_item($data_items[n], amount)
Maybe something like this?
Ruby:
bat = $game_actors[1] #replace this with the proper actor
w = bat.weapons.first #get the first equipped weapon, you can also do bat.weapons[0]
bat.discard_equip(w) if w #remove it if it exists
I modified it a bit to specify equips instead of weapons so it could be used for armor as well, but this worked! Thank you so much!

Here's the edited code if anyone in the future needs it:

bat = $game_actors[1]
w = bat.equips[1]
bat.discard_equip(w) if w

Original thread: https://forums.rpgmakerweb.com/threads/deleting-an-actors-equipped-items-in-the-middle-of-battle.182190/