Jump to content
New account registrations are disabed. This website is now an archive. Read more here.
  • 0
Sign in to follow this  
Leetfaction

Level Required Equipment Script?

Question

I'm trying to find a script that allows you to make it so that your character and your party members need to be a certain level in order to equip armor and weapons. For example, you could equip a bronze plate at level 1, but you cannot equip a steel plate until you reach level 10. All I could find is weapon leveling scripts that make your weapon stronger as you continue to use them, but that wasn't what I was looking for. If there is a script like this, please let me know. :)

Edited by Leetfaction

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

See if this works for you. Just make sure you fill the arrays to completion for each armor, weapon, accessory you have. If you have any issues, please let me know. NOTE: All numbers are random except for the first one, which should be left as one, or lower.

 

#===============================================================================
# Equipment Level Requirements
# By Descendant of Orr
# Version 1.0
#-------------------------------------------------------------------------------
# This script adds the ability to give weapons, armors. and accessories a level
# requirement.  It rewrites Scene_Equip's update_item method. If another script
# you use calls this method, there may be compatibility issues.
#-------------------------------------------------------------------------------
# This script is free to publish, repurpose, reuse, and change, but please give
# credit when due
#-------------------------------------------------------------------------------
# Begin Scene_Equip
#-------------------------------------------------------------------------------
class Scene_Equip
 #-----------------------------------------------------------------------------
 #FINAL VARIABLES  
 # Requirements for weapons/armors/accessories
 #-----------------------------------------------------------------------------
 WEAPON_REQ =  [   1,  # LEVEL REQUIREMENT TO UNEQUIP - LEAVE AS IS
                   10, # LEVEL REQUIREMENT FOR WEAPON ID 1
                   5,  # LEVEL REQUIREMENT FOR WEAPON ID 2
                   6,  # LEVEL REQUIREMENT FOR WEAPON ID 3
                   5   # ETC
                   ]
 ARMOR_REQ =   [   1,  # LEVEL REQUIREMENT TO UNEQUIP - LEAVE AS IS
                   1,  # LEVEL REQUIREMENT FOR ARMOR ID 1
                   5,  # LEVEL REQUIREMENT FOR ARMOR ID 2
                   6,  # LEVEL REQUIREMENT FOR ARMOR ID 3
                   5   # ETC
                   ]
 ACC_REQ =     [   1,  # LEVEL REQUIREMENT TO UNEQUIP - LEAVE AS IS
                   3,  # ETC
                   7,
                   6,
                   9
                   ]          
   #---------------------------------------------------------------------------
   # Scene_Equip.update_item
   #---------------------------------------------------------------------------
   # As update_item from the default scene equip, except compares selected
   # actors level to the requirements set in the variables above
   #---------------------------------------------------------------------------
   def update_item
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Activate right window
     @right_window.active = true
     @item_window.active = false
     @item_window.index = -1
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Get currently selected data on the item window
     item = @item_window.item
     # Compares actor level to requirement returned by get_req
     if @actor.level < get_req(@right_window.index, item == nil ? 0 : item.id)
       # Play buzzer SE
       $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Play equip SE
     $game_system.se_play($data_system.equip_se)      
     # Change equipment
     @actor.equip(@right_window.index, item == nil ? 0 : item.id)
     # Activate right window
     @right_window.active = true
     @item_window.active = false
     @item_window.index = -1
     # Remake right window and item window contents
     @right_window.refresh
     @item_window.refresh
     return
   end
   #---------------------------------------------------------------------------
   # get_req(equipment_type, equipment_id
   #---------------------------------------------------------------------------
   # Returns level requirement from given id's respective array
   #---------------------------------------------------------------------------
   def get_req(equip_type, id)
     case equip_type
     when 0  # Weapon
       if id == 0 or $game_party.weapon_number(id) > 0
         return (WEAPON_REQ[id] == nil) ? 1 : WEAPON_REQ[id]
       end
     when 1  # Shield
       if id == 0 or $game_party.armor_number(id) > 0
         return (ARMOR_REQ[id] == nil) ? 1 : ARMOR_REQ[id]
       end
     when 2  # Head
       if id == 0 or $game_party.armor_number(id) > 0
         return (ARMOR_REQ[id] == nil) ? 1 : ARMOR_REQ[id]
       end
     when 3  # Body
       if id == 0 or $game_party.armor_number(id) > 0
         return (ARMOR_REQ[id] == nil) ? 1 : ARMOR_REQ[id]
       end
     when 4  # Accessory
       if id == 0 or $game_party.armor_number(id) > 0
         return (ACC_REQ[id] == nil) ? 1 : ACC_REQ[id]
       end
     end
   end
 end
end
#-------------------------------------------------------------------------------
# End Scene_Equip
#-------------------------------------------------------------------------------

 

EDIT: I changed the code so that if you do not define a level requirement for any given piece of equipment, instead of receiving ARRAY_INDEX_OUT_OF_BOUNDS, the script assumes a level requirement of 1

Edited by Descendant of Orr

Share this post


Link to post
Share on other sites
  • 0

gave you a +1 for a nice, simple script.

 

@Joman: That would require a bit more scripting tahn waht he put. I would, but I don't know how to change item colors in scripts. Most I can do is script a window to open. I have been workin on my own CMS, but so far, NG.

Share this post


Link to post
Share on other sites
  • 0

It would be pretty easy, however it would involve making the level required constants in a module or make them accessible from within the scene itself. If you need it I can do it, if not I am sure descendant will have an answer when he is online again :)

Share this post


Link to post
Share on other sites
  • 0

Here is version 1.1. It grays out all pieces of equipment that do not have their requirements met. It also fixes a bug that would have been inadvertently caused by Accessories using the same IDs as Armors (since I thought they were different for some reason -.-)

 

Please report all bugs:

 

 

#===============================================================================
# Equipment Level Requirements
# By Descendant of Orr
# Version 1.1
# 4/17/11
#-------------------------------------------------------------------------------
# This script adds the ability to give weapons and armors level requirement.  It
# rewrites Scene_Equip's update_item method and Window_EquipItem's refresh
# method. If another script you use calls these methods, there may be
# compatibility issues to address.
#-------------------------------------------------------------------------------
# This script is free to publish, repurpose, reuse, and change, but please give
# credit when due
#-------------------------------------------------------------------------------
# Begin Scene_Equip
#-------------------------------------------------------------------------------
class Scene_Equip        
 #---------------------------------------------------------------------------
 # Scene_Equip.update_item
 #---------------------------------------------------------------------------
 # As update_item from the default Scene_Equip, except compares selected
 # actors level to the requirements set in the variables above
 #---------------------------------------------------------------------------
 def update_item
   # If B button was pressed
   if Input.trigger?(Input::B)
     # Play cancel SE
     $game_system.se_play($data_system.cancel_se)
     # Activate right window
     @right_window.active = true
     @item_window.active = false
     @item_window.index = -1
     return
   end
   # If C button was pressed
   if Input.trigger?(Input::C)
     # Get currently selected data on the item window
     item = @item_window.item
     # Checks to see if @actor meets requirement returned by @item_windows'
     # meets_req method
     if !@item_window.meets_req(@actor, item)
       # Play buzzer SE
      $game_system.se_play($data_system.buzzer_se)
       return
     end
     # Play equip SE
     $game_system.se_play($data_system.equip_se)      
     # Change equipment
     @actor.equip(@right_window.index, item == nil ? 0 : item.id)
     # Activate right window
     @right_window.active = true
     @item_window.active = false
     @item_window.index = -1
     # Remake right window and item window contents
     @right_window.refresh
     @item_window.refresh
     return
   end
 end
end
#-------------------------------------------------------------------------------
# End Scene_Equip
#-------------------------------------------------------------------------------
# Begin Window_EquipItem
#-------------------------------------------------------------------------------
class Window_EquipItem < Window_Selectable
 #-----------------------------------------------------------------------------
 # FINAL VARIABLES  
 # Requirements for weapons/armors
 #-----------------------------------------------------------------------------
 WEAPON_REQ =  [   1,  # LEVEL REQUIREMENT TO UNEQUIP - LEAVE AS IS
                   1,  # LEVEL REQUIREMENT FOR WEAPON ID 1
                   5,  # LEVEL REQUIREMENT FOR WEAPON ID 2
                   6,  # LEVEL REQUIREMENT FOR WEAPON ID 3
                   5   # ETC
                   ]
 ARMOR_REQ =   [   1,  # LEVEL REQUIREMENT TO UNEQUIP - LEAVE AS IS
                   1,  # LEVEL REQUIREMENT FOR ARMOR ID 1
                   5,  # LEVEL REQUIREMENT FOR ARMOR ID 2
                   6,  # LEVEL REQUIREMENT FOR ARMOR ID 3
                   5   # ETC
                   ]
 #---------------------------------------------------------------------------
 # Window_EquipItem.refresh
 #---------------------------------------------------------------------------
 # As refresh from the default Window_EquipItem, except sends the newly defined
 # draw_item whether or not each item is equipable
 #---------------------------------------------------------------------------                    
 def refresh
   if self.contents != nil
     self.contents.dispose
     self.contents = nil
   end
   @data = []
   # Add equippable weapons
   if @equip_type == 0
     weapon_set = $data_classes[@actor.class_id].weapon_set
     for i in 1...$data_weapons.size
       if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
         @data.push($data_weapons[i])
       end
     end
   end
   # Add equippable armor
   if @equip_type != 0
     armor_set = $data_classes[@actor.class_id].armor_set
     for i in 1...$data_armors.size
       if $game_party.armor_number(i) > 0 and armor_set.include?(i)
         if $data_armors[i].kind == @equip_type-1
           @data.push($data_armors[i])
         end
       end
     end
   end
   # Add blank page
   @data.push(nil)
   # Make a bit map and draw all items
   @item_max = @data.size
   self.contents = Bitmap.new(width - 32, row_max * 32)
   for i in 0...@item_max-1
     draw_item(i, meets_req(@actor, @data[i]))
   end
 end
 #---------------------------------------------------------------------------
 # Window_EquipItem.meets_req(actor, item)
 #---------------------------------------------------------------------------
 # Returns whether actor meets requirement from given item
 #---------------------------------------------------------------------------
 def meets_req(actor, item)
   case item
   when RPG::Weapon
     r_value = (WEAPON_REQ[item.id] == nil) ? 1 : WEAPON_REQ[item.id]
   when RPG::Armor
     r_value = (ARMOR_REQ[item.id] == nil) ? 1 : ARMOR_REQ[item.id]    
   else    
     r_value = 0
   end
   return actor.level >= r_value
 end  
 #---------------------------------------------------------------------------
 # Window_EquipItem.draw_item(item_index, equipable)
 #---------------------------------------------------------------------------
 # As draw_item from the default Window_EquipItem, except colors items grey
 # for which the given actor does not meet the requirements
 #---------------------------------------------------------------------------    
 def draw_item(index, equipable)
   item = @data[index]
   x = 4 + index % 2 * (288 + 32)
   y = index / 2 * 32
   case item
   when RPG::Weapon
     number = $game_party.weapon_number(item.id)
   when RPG::Armor
     number = $game_party.armor_number(item.id)
   end
   bitmap = RPG::Cache.icon(item.icon_name)
   self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
   if equipable
     self.contents.font.color = normal_color
   else
     self.contents.font.color = disabled_color
   end
   self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
   self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
   self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
 end
end
#-------------------------------------------------------------------------------
# End Window_EquipItem
#-------------------------------------------------------------------------------

 

Share this post


Link to post
Share on other sites
  • 0

This is a brilliant piece of work right here! Nice job, I love it! :) (Six month late response ftw?)

Edited by Leetfaction

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...