RPG Maker VX Ace: Trying to stop same accessory stacking.

Right, so I'm using a script that allows me to have multiple of the same slots, like multiple head armor, body armor, weapon, etc. But not the point.

What I'm trying to do is create a way so that when you equip a specific item, the others won't let that said item from being equipped, this to avoid only stacking powerful items and ignore a proper build for the game, thus overpowering every enemy on the way.

Here's an example:

Imagine that I have 3 slots for weapons.

I want to make it so that if I use, let's call it a "Sand Sword" in slot 1, the other 2 slots won't let the player equip the same item. And same if I equip in slot 2 and makes the others locked, but don't want to keep the weapon locked because players might want to replace those items. So what I want is a way or a script that allows me to lock slots from equipping specific items. Something like locking them by accessory number on equip?
Try this plugin:


Then add the following inside the notebox of that weapon/armor

<Equip Requirement>
unique only
</Equip Requirement>
Try this plugin:


Then add the following inside the notebox of that weapon/armor

<Equip Requirement>
unique only
</Equip Requirement>
Oh wait, just saw that you use VXAce... but theres probably another plugin from yanfly for VXAce.
Hopefully someone will link me up. Not much fun setting up enemies to be strong enough for an average combat without the need to grind, while maintaining the challenge for someone to just go and buy the same strongest item and one shot everything.

So it will be handy then.
By default the only way around it is to give each slot its own item. You will need a script otherwise.

I've moved this thread to Script Requests. Thank you.

My bad then. Will see if anything pops up.
If it's of any help, here's the script I use to create the same of multiple slots, hopefully there's anything that can be changed in the code to realize my request?

Spoiler: The code
=begin
Custom Equipment Slots Script
by Fomar0153
Version 1.2
----------------------
Notes
----------------------
No requirements
Allows you to customise what equipment characters can equip
e.g. add new slots or increase the number of accessories.
----------------------
Instructions
----------------------
You will need to edit the script in two locations both are near
the top of the script look for:
Slots[7] = "Spell Tomes"
return [0,0,2,3,4,4,4,7] if dual_wield?
and follow the instructions where they are.
----------------------
Changle Log
----------------------
1.0 -> 1.1 : Fixed a bug that caused a crash when equipping a weapon.
1.1 -> 1.2 : Fixed a bug with optimisation and remove all
Increased compatibility
----------------------
Known bugs
----------------------
None
=end
#--------------------------------------------------------------------------
# ● New Module Extra_Slots
#--------------------------------------------------------------------------
module Extra_Slots

Slots = []
# Edit here to add new slot types
# Slots[armour_type_id] = "name"
# I know it is named in the database but I don't believe you can access
# that name through Vocab
Slots[7] = "Spell Tomes"

end

class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● Rewrites equip_slots
#--------------------------------------------------------------------------
# Edit here to change what slots are available to your characters
# 0 - Weapon
# 1 - Shield
# 2 - Head
# 3 - Body
# 4 - Accessory
# 5+ a custom slot
def equip_slots
return [0,4,1,1,1,1,1] if dual_wield?
return [0,4,1,1,1,1,1]
end
end

class Window_EquipSlot < Window_Selectable
#--------------------------------------------------------------------------
# ● Rewrites slot_name
#--------------------------------------------------------------------------
def slot_name(index)
if @actor.equip_slots[index] >= 5
Extra_Slots::Slots[@actor.equip_slots[index]]
else
@actor ? Vocab::etype(@actor.equip_slots[index]) : ""
end
end
end

class Scene_Equip < Scene_MenuBase
#--------------------------------------------------------------------------
# ● Aliases create_slot_window
#--------------------------------------------------------------------------
alias custom_slots_create_slot_window create_slot_window
def create_slot_window
custom_slots_create_slot_window
@slot_window.create_contents
@slot_window.refresh
end
#--------------------------------------------------------------------------
# ● Aliases on_actor_change
#--------------------------------------------------------------------------
alias custom_slots_on_actor_change on_actor_change
def on_actor_change
custom_slots_on_actor_change
@slot_window.create_contents
@slot_window.refresh
end
end

module RPG
class Armor
#--------------------------------------------------------------------------
# ● I wish I'd done this originally.
#--------------------------------------------------------------------------
def etype_id
if Extra_Slots::Slots[self.atype_id] == nil
return @etype_id
else
return self.atype_id
end
end
end
end
I seriously need help with this, otherwise would hear alternatives.
Code:
Game_Actor.class_eval do
  alias_method(:tlb_change_equip, :change_equip)
  def change_equip(slot_id, item)
    return if @equips.any? { |equip| equip.object == item }
    tlb_change_equip(slot_id, item)
  end
end

That should prevent equipping the same piece of equipment in a slot if you already have it equipped.
Code:
Game_Actor.class_eval do
  alias_method(:tlb_change_equip, :change_equip)
  def change_equip(slot_id, item)
    return if @equips.any? { |equip| equip.object == item }
    tlb_change_equip(slot_id, item)
  end
end

That should prevent equipping the same piece of equipment in a slot if you already have it equipped.

Where do I place this code specifically? Or do I have to make a new script tab?
Create a new script above main.
It looks like a charm. If I try to equip the same of two items, it lets me try, but never works. I owe you big time! 😀

Any staff can call this problem solved.
One thing to note is that this'll also prevent a dual wielding character from having the same weapon equipped in both hands, so if that's a thing in your game the script will need tweaking slightly.
One thing to note is that this'll also prevent a dual wielding character from having the same weapon equipped in both hands, so if that's a thing in your game the script will need tweaking slightly.

It's fine, none of my characters dual wield.

Besides, I can circumvent that by making two of the same thing, one for left hand and one for right hand, so it just complicates matters a bit, but still manages to work.
this'll also prevent a dual wielding character from having the same weapon equipped in both hands
And what would that look like?
Ruby:
Game_Actor.class_eval do
  alias_method(:tlb_change_equip, :change_equip)
  def change_equip(slot_id, item)
    return if @equips.any? { |equip| equip.object == item } unless slot_id == 1
    tlb_change_equip(slot_id, item)
  end
end
And what would that look like?
Ruby:
Game_Actor.class_eval do
  alias_method(:tlb_change_equip, :change_equip)
  def change_equip(slot_id, item)
    return if @equips.any? { |equip| equip.object == item } unless slot_id == 1
    tlb_change_equip(slot_id, item)
  end
end

I would probably go with "unless item.is_a?(RPG::Weapon)" instead.
I would probably go with "unless item.is_a?(RPG::Weapon)" instead.
Thanks. I was not wrong then, but your procedure is probably better.
Might be an option to use the slot_id if you needed it for another part.
I have two rings slots (one for each hand), so if I wanted to prevent the same ring from being equipped twice, then this would work for that too.
Yeah, slot_id would also work, though for dual wielding checks it'd be better to use index_to_etype_id(slot_id) so that it applies to both weapon slots.

Original thread: https://forums.rpgmakerweb.com/threads/rpg-maker-vx-ace-trying-to-stop-same-accessory-stacking.123751/