I need a script that limits whether or not a weapon can be equipped multiple times. For instance, pistols and small melee weapons in one of my projects can be dual wielded if you have the dual wield trait. Yanfly's equip engine adds a second weapon equip slot, but you can't limit what weapons can and can't be dual wielded. I want to make it so that larger melee weapons and things like assault rifles can only be equipped once, even if you have the dual wield trait. Currently, you can dual wield any weapons with the system, and that is a big problem.
Script that limits how many weapons you can have equipped.
RGSS3 Script RequestsIs there any particular reason not to have the two handed weapon seal the other slot?
I can't seal the slot, because due to the Yanfly's equip engine, it literally makes another weapon slot. If I try to seal it, I can't use either weapon slot.
You can try this:
Code:
=begin
#==============================================================================#
# AMN YEA Solo Equips
# Version 1.01
# Author: AMoonlessNight
# Date: 11 Oct 2019
# Latest: 11 Oct 2019
#==============================================================================#
# UPDATE LOG
#------------------------------------------------------------------------------#
# 11 Oct 2019 - created the script
#==============================================================================#
# TERMS OF USE
#------------------------------------------------------------------------------#
# - Please credit AMoonlessNight or A-Moonless-Night
# - Free for non-commercial use
# - Contact for commercial use
# - I'd love to see your game if you end up using one of my scripts
#==============================================================================#
This script makes it so that you can have equipment that seals other slots of
the same type (if you have multiple slots of the same type), e.g. a large sword
that seals other weapon slots.
This is made to work with Yanfly Engine Ace - Ace Equip Engine and probably
won't work without it.
Use the following in an item's notes:
<solo equip>
=end
#==============================================================================
# Please do not edit below this point unless you know what you are doing.
#==============================================================================
class RPG::BaseItem
SOLO_EQUIP = /<solo[ -_]*equip>/i
def is_solo?
return false unless self.is_a?(RPG::EquipItem)
note =~ SOLO_EQUIP
end
end
class Game_Actor < Game_Battler
alias amn_solo_gameactor_equipchangeok equip_change_ok?
def equip_change_ok?(slot_id)
return false if any_other_solo_equips?(slot_id)
amn_solo_gameactor_equipchangeok(slot_id)
end
def any_other_solo_equips?(slot_id)
other_like_equips(slot_id).keys.collect {|i| equips[i]}.compact.any? {|i| i.is_solo? }
end
def equip_slots_hash
Hash[equip_slots.map.with_index { |etype_id, slot_id| [slot_id, etype_id] }]
end
def other_like_equips(slot_id)
equip_slots_hash.select do |s_id, e_id|
equip_slots[slot_id] == e_id && s_id != slot_id
end
end
alias amn_solo_gameactor_changeequip change_equip
def change_equip(slot_id, item)
amn_solo_gameactor_changeequip(slot_id, item)
if !item.nil? && item.is_a?(RPG::EquipItem)
if item.is_solo? || any_other_solo_equips?(slot_id)
other_like_equips(slot_id).keys.each { |i| change_equip(i, nil) }
end
end
end
end
Thank you! This works exactly how I needed it to!
Original thread: https://forums.rpgmakerweb.com/threads/script-that-limits-how-many-weapons-you-can-have-equipped.114059/