Reset TP to 0 when changing weapons and shields

Hello,

I'm looking for a script that resets a character's TP to 0 when changing or unequipping their equipped weapons and/or shields. I've searched around couldn't find anything.
How about this script by Tsukihime? Then in the common event use this script: $game_actors[n].tp = 0 (instead of "n" use the ID of the actor)
How about this script by Tsukihime?
I'm fairly sure that using this script will require the scene interpreter script and will require the actor id passed to the common event.
Also the script requires the note tag to be on every equipment that falls into the weapon shield category. Not that practical. I can make something, I'm just not at home at the moment.
I'll be back in three days. When I remember about it, I will probably work on making something. It should be a small script.
Ruby:
# * Equipment TP Reset ACE
# * Overwritten method: Game_Actor#change_equip

class Game_Actor
  def change_equip(slot_id, item)
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
    @tp = 0
    refresh
  end
end
Kyo, you really are a script saint XD
Thanks Kyo! This worked great. I'm using Yanfly's Command Equip script and didn't want the player abusing multi hit weapons to gain TP and then switching to a more powerful single hit weapon to perform skills.

Thanks again!
Hey Kyo,

After doing some further testing, the TP resets to 0 whenever I swap armor (helmet for example) as well. Is there a way for the TP to reset for only the weapon (single and dual wield) and shield slots changing?
Is there a way for the TP to reset for only the weapon (single and dual wield) and shield slots changing?
Of course. That's the only part that @kyonides didn't specify, that it is supposed to be only for weapons and shields.
A simple adjustment would make it work.
Ruby:
# * Equipment TP Reset ACE
# * Overwritten method: Game_Actor#change_equip

class Game_Actor
  def change_equip(slot_id, item)
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
    @tp = 0 if slot_id == (0 || 1)
    refresh
  end
end
Hey Ron,

I tested your edit on a new project and the TP still resets whenever I change armor during battle or through the main menu.
Here's My Latest Version:

Ruby:
# * Equipment TP Reset ACE - Note Version
#   Scripter : Kyonides Arkanthes
# * Overwritten method: Game_Actor#change_equip

# * Instructions * #

# Leave a note in the Actor's Note Box:
# <equip tp reset: As,Many,Positions,As,Deemed,Necessary>

# Nothing will happen if a given Actor has no such note.

class Game_Actor
  TP_RESET_SLOTS_REGEX = /<equip tp reset: (...)>/i
  def change_equip(slot_id, item)
    return unless trade_item_with_party(item, equips[slot_id])
    return if item && equip_slots[slot_id] != item.etype_id
    @equips[slot_id].object = item
    actor.note[TP_RESET_SLOTS_REGEX]
    slot_ids = $1.to_s.split(/,/).map(&:to_i)
    @tp = 0 if slot_ids.include?(slot_id)
    refresh
  end
end

As you may have noticed already, it works with leaving a very specific note in the Actor's note box.
I tested your edit on a new project and the TP still resets whenever I change armor during battle or through the main menu.
That's the thing about ruby code, sometimes it needs to be hand held.
I made a small change. Try either my edit or Kyonides new version.
Hey guys, I really appreciate the help on this. I wasn't expecting a response, let alone get two of them. Ron, not sure what happened with your latest update but the TP no longer resets when changing slot 0 or 1 equipment. Kyo, your latest version works great for what I was looking for. Thanks bros, you're both are so talented!

Original thread: https://forums.rpgmakerweb.com/threads/reset-tp-to-0-when-changing-weapons-and-shields.152315/