Lock -Unlocking Equipment

Is there a way to have equipment lock on equip? I'm considering a system where equipment can be only be removed at special locations or for gold. With 20 team members, I don't want the standard procedure to be stacking best equips on the 4 active members. I want multiples of same equip type to be consumed during crafting upgrades. This gives a lot of depth to a hundred base equipments without overloading the database.

Unrelated.... but just wanted to share that XP is only gained by inactive characters to force use of multiple teams.
Is there a way to have equipment lock on equip? I'm considering a system where equipment can be only be removed at special locations or for gold.
It sounds like you could just put a "Lock Equip" trait on each Armor/Weapon?
It sounds like you could just put a "Lock Equip" trait on each Armor/Weapon?
I think what OP meant was to give all equipments "Lock Equip" unless they're at a specific location.

Original Engine Code:
JavaScript:
Game_BattlerBase.prototype.isEquipTypeLocked = function(etypeId) {
    return this.traitsSet(Game_BattlerBase.TRAIT_EQUIP_LOCK).includes(etypeId);
};

Edited Code:
JavaScript:
const _Game_BattlerBase_prototype_isEquipTypeLocked = Game_BattlerBase.prototype.isEquipTypeLocked;
Game_Actor.prototype.isEquipTypeLocked = function(etypeId) { //Made it actor to be safe
    return _Game_BattlerBase_prototype_isEquipTypeLocked.call(this, etypeId) || this.equips()[etypeId - 1];
};
This locks all equipment upon being equipped.

Edited Code + Conditional + Location Info:
JavaScript:
let changeEquipOkay = false;
let changeEquipMaps = [1, 2, 3]; //Put map ids here

const _Game_BattlerBase_prototype_isEquipTypeLocked = Game_BattlerBase.prototype.isEquipTypeLocked;
Game_Actor.prototype.isEquipTypeLocked = function(etypeId) {
    return _Game_BattlerBase_prototype_isEquipTypeLocked.call(this, etypeId) ||
    (changeEquipOkay || changeEquipMaps.includes($gameMap._mapId)) ? false : this.equips()[etypeId - 1];
};
You have to make a plugin command to turn changeEquipOkay to true. But you might be able to using scripts but I never tested changing a plugin variable with a script before.

I want multiples of same equip type to be consumed during crafting upgrades
You're either going to have to make a plugin request or find a plugin online and/or buy it.

Edit: Now that I think about it you probably could just put "Lock Equip" on everything and just make an event to change all equipment items to none.
Other than @LowrellLovelace's mini-plugin, you could do as @caethyril said and then remove the equipment with an event in the locations where it's allowed. That approach won't require any plugin.

If your intent is to make the equip scene only function in certain areas, you could also use a plugin that disables the equip scene, something like this:

JavaScript:
Game_System.prototype.setEquipEnable = function(enable) {
    this._equipEnable = enable;
};
(function(old) {
    Window_MenuCommand.prototype.addMainCommands = function() {
        old.call(this);
        if(!$gameSystem._equipEnable) {
            let equip = this._list.find(cmd => cmd.symbol == 'equip');
            if(equip) equip.enabled = false;
        }
    };
})(Window_MenuCommand.prototype.addMainCommands);

If you install the above as a plugin, you can then use the following script calls to enable or disable the equipment scene:

JavaScript:
$gameSystem.setEquipEnable(true);
$gameSystem.setEquipEnable(false);

Original thread: https://forums.rpgmakerweb.com/threads/lock-unlocking-equipment.182757/