I am using this script for equipment level requirements. When I acquire a weapon/armor and not at the required level, the item doesnt appear in my inventory. Is there anyway to make it appear just have it greyed out?
Equipment Level Requirements Fomar
RGSSx Script SupportRemove Game_Battlerbase class and put this in instead
Ruby:
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
return false if @actor.level < item.levelreq
return true
end
end
I've moved this thread to RGSSx Support. Thank you.
Doesn't seem to work: I get a syntax error at 52: unexpected keyword_end, expecting $end.
Here is the code with the modification:
module RPG
#--------------------------------------------------------------------------
# ● Equip Item is inherited by both Weapon and Armor
#--------------------------------------------------------------------------
class EquipItem
def levelreq
if self.note =~ /<levelreq (.*)>/i
return $1.to_i
else
return 0
end
end
end
end
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
return false if @actor.level < item.levelreq
return true
end
end
#--------------------------------------------------------------------------
# ● Check the levels
#--------------------------------------------------------------------------
alias level_equippable? equippable?
def equippable?(item)
return false unless item.is_a?(RPG::EquipItem)
return false if @level < item.levelreq
return level_equippable?(item)
end
end
100% not what I asked you to do. when posting code you should use the code button.
Ruby:
=begin
Equipment Level Requirements
by Fomar0153
Version 1.0
----------------------
Notes
----------------------
Adds a level requirement to equipment.
----------------------
Instructions
----------------------
Notetag the weapons/armors like so:
<levelreq x>
----------------------
Known bugs
----------------------
None
=end
module RPG
#--------------------------------------------------------------------------
# ● Equip Item is inherited by both Weapon and Armor
#--------------------------------------------------------------------------
class EquipItem
def levelreq
if self.note =~ /<levelreq (.*)>/i
return $1.to_i
else
return 0
end
end
end
end
#==============================================================================
# ** Window_EquipItem
#==============================================================================
class Window_EquipItem < Window_ItemList
#--------------------------------------------------------------------------
# * Display in Enabled State?
#--------------------------------------------------------------------------
def enable?(item)
return true if item.nil?
return false if @actor.level < item.levelreq
return true
end
end
Works now! I was confused on where to make the change. thanks
Actually found a bug, when I unequip a weapon or armor and have an empty weapon slot I get an error: line 43: NoMethodError. In debug file: equipment require:43:in `enable?': undefined method `levelreq' for nil:NilClass, NoMethodError
Fixed script above.
Thank you
Original thread: https://forums.rpgmakerweb.com/threads/equipment-level-requirements-fomar.169826/