Preventing player from unequipping certain equipment under specific conditions

I have a variable that determines what kind of encounter the player will have depending on its number. Similar to a gauge so if the number is too low it affects the types of enemies that will show up. That being said, I have an accessory that you can equip and it increases the value of that variable, however, I would like to keep the player from equipping and unequipping at will once the value is below 25 to prevent messing with the encounters and exploiting the conditions based on that variable's value.

Is it possible to do with a script or would it require a plugin? Most of the search I've done related to this problem did not include the condition part it was mostly a lock/unlock equip
My first thought is to use Waynee OnEquipEval. If you can't outright stop the player from unequipping it you can use a script to make them reequip it if the variable is <25.
you can use the trait "lock equip" to prevent the player from changing the equipment.

since it will not be a permanent lock, you either need to use a state to apply the lock-trait, or use a plugin for dynamic traits to add and remove the trait.

going with the state does not need any plugin, but will require some logic to get the state reapplied after for example death.

Original thread: https://forums.rpgmakerweb.com/threads/preventing-player-from-unequipping-certain-equipment-under-specific-conditions.175058/