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,224
Reaction score
13,760
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,369
Reaction score
1,537
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,369
Reaction score
1,537
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,369
Reaction score
1,537
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,369
Reaction score
1,537
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,369
Reaction score
1,537
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 Posts

Latest Profile Posts

ESAMarathon on Twitch, now streaming "Eat Girl". Yep, that's the title of a game... Apparently it's a Pacman knockoff.... Which is of course the only logical conclusion one would get from a name like "Eat Girl". :kaopride: I can't believe anybody would think anything else! :kaoback:
Super stoked i just finished my first town in my project, by finished i mean i can always add more decorative aesthetics and the NPCs don't talk yet but the mapping is complete and all the important chess pieces are present!
My brain: Hey, I have an idea how to make the transition to the main story quest in The Wastes more natural!
Me: Good!
My brain: You need to remake the hotel you start out in, it's not realistic enough.
Me: Ok... This was unexpected, but I can do it.
My brain: Now make each hotel floor 5 times as large to match the main part. Oh, you also need to make a bunch of new npcs to fill in the space on these maps.
Me: Crap.
Should be able to release Haxe MV/MZ next weekend.
It look that somehow MZ tracks are messed up (for example battle4 is obviously a theme, castle2 is a ship, ship1 is a scene and so on..). Maybe they just named them after with some ambiguity.

Forum statistics

Threads
100,611
Messages
977,827
Members
132,227
Latest member
YourBaka
Top