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

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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?
 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,225
Reaction score
13,777
First Language
English
Primarily Uses
RMVXA
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. Please be sure to post your threads in the correct forum next time. Thank you.

 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
My bad then. Will see if anything pops up.
 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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?

=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
 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
I seriously need help with this, otherwise would hear alternatives.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,379
Reaction score
1,559
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,379
Reaction score
1,559
First Language
English
Primarily Uses
RMMV
Create a new script above main.
 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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! :D

Any staff can call this problem solved.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,379
Reaction score
1,559
First Language
English
Primarily Uses
RMMV
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.
 

JayHog1992

Villager
Member
Joined
Jul 7, 2020
Messages
8
Reaction score
0
First Language
Portuguese
Primarily Uses
RMVXA
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.
 
Last edited:

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,402
Reaction score
499
First Language
English
Primarily Uses
RMVXA
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
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,379
Reaction score
1,559
First Language
English
Primarily Uses
RMMV
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.
 

Roninator2

Gamer
Veteran
Joined
May 22, 2016
Messages
2,402
Reaction score
499
First Language
English
Primarily Uses
RMVXA
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.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,379
Reaction score
1,559
First Language
English
Primarily Uses
RMMV
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.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

And back. Trying to work online with no internet for 1.5 days was...interesting. I felt like a character in a old Sierra game trying to find internet due to all the hoops I had to jump through just to get online for work.
grief... if MV didn't have certain plugins already, I think I'd upgrade to MZ. seeing like 10 MV plugins in 1 MZ one is hilariously convenient lol.
Have you already checkes out my mapping tutorial on the blog? I would love to hear your feedback and things you'd like to see in the future!

one of character for my upcoming game idk how to design o_O

Designing patches that can 'augmented' to clothing based armor. Such good fun. A bit time consuming due to the need to create image displays, but the patches are limited so it's not too tiring.
Note: lol, posting this made me find a couple mistakes.

Forum statistics

Threads
100,737
Messages
978,948
Members
132,359
Latest member
PhilKeepItReal
Top