RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Equipment Requisites

0 Members and 1 Guest are viewing this topic.

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
Equipment Requisites
Version: 2.0
Author: Tsunokiette
Date: June 15, 2008

Version History


  • <Version 1.0> Fulfilled request
  • <Version 2.0> Added option for multiple requisites and level as a requisite

Planned Future Versions

  • No future editions planned unless additions are requested

Description


Allows the game designer to designate requisites for the equipment. Items will not be equipped unless all requisites are met, and will be unequipped if the item they require is unequipped.

Features

  • Items can have a single requisite
  • Items can have multiple requisites
  • Items can also require a level

Screenshots

Screenshots are unnecessary for this type of script :x

Instructions

The instructions are included in the script, but I'll go ahead and include them here.

Spoiler for How to Use:
    #---------------------------------------------------------------------------
    # * Equip Requisites (Tsunokiette | June 15, 2008)
    # ~~~~~~~~~~~~~~~~~~~
    # Example : [[3,1,4,5]]
    # Explanation : '3' is the ID of the item you wish to equip
    #               '1' is the TYPE of the item you wish to equip
    #               '4' is the ID(s) of the item(s) required to equip the item
    #                   - or the level the actor must be to equip
    #               '5' is the TYPE(s) of the item(s) required to equip the item
    #                   - or indicates that a level is required
    # TYPE : 1 = Weapon
    #        2 = Armor 1 (Shield)
    #        3 = Armor 2 (Helmet)
    #        4 = Armor 3 (Body Armor)
    #        5 = Armor 4 (Accessory)
    #        6 = level
    # ~~~~~~~~~~~~~~~~~~~
    # To make multiple requisites, simply separate with a comma :
    # [[3,1,4,5],[4,1,5,2],[1,2,3,4]] ... et cetera
    # To make an item have multiple requisites, simply change the last two
    # numbers into arrays with everything separated by a comma :
    # [[3,1,[2,3,4,5],[1,2,3,4]]]
    # You can make an item require an item AND a level by using the same method
    # as stated above:
    # [[3,1,[2,3,6],[1,2,57]]]
    #---------------------------------------------------------------------------

The requisites themselves are added directly after the instructions you add into Game_Actor

Script



Spoiler for How to "install":
Go to Game_Actor in the Script Editor

Find this in the beginning -

Code: [Select]
  #--------------------------------------------------------------------------
  # * Setup
  #     actor_id : actor ID
  #--------------------------------------------------------------------------
  def setup(actor_id)
    actor = $data_actors[actor_id]
    @actor_id = actor_id
    @name = actor.name
    @character_name = actor.character_name
    @character_index = actor.character_index
    @face_name = actor.face_name
    @face_index = actor.face_index
    @class_id = actor.class_id
    @weapon_id = actor.weapon_id
    @armor1_id = actor.armor1_id
    @armor2_id = actor.armor2_id
    @armor3_id = actor.armor3_id
    @armor4_id = actor.armor4_id

And add this after it

Code: [Select]
    #---------------------------------------------------------------------------
    # * Equip Requisites (Tsunokiette | June 15, 2008)
    # ~~~~~~~~~~~~~~~~~~~
    # Example : [[3,1,4,5]]
    # Explanation : '3' is the ID of the item you wish to equip
    #               '1' is the TYPE of the item you wish to equip
    #               '4' is the ID(s) of the item(s) required to equip the item
    #                   - or the level the actor must be to equip
    #               '5' is the TYPE(s) of the item(s) required to equip the item
    #                   - or indicates that a level is required
    # TYPE : 1 = Weapon
    #        2 = Armor 1 (Shield)
    #        3 = Armor 2 (Helmet)
    #        4 = Armor 3 (Body Armor)
    #        5 = Armor 4 (Accessory)
    #        6 = level
    # ~~~~~~~~~~~~~~~~~~~
    # To make multiple requisites, simply separate with a comma :
    # [[3,1,4,5],[4,1,5,2],[1,2,3,4]] ... et cetera
    # To make an item have multiple requisites, simply change the last two
    # numbers into arrays with everything separated by a comma :
    # [[3,1,[2,3,4,5],[1,2,3,4]]]
    # You can make an item require an item AND a level by using the same method
    # as stated above:
    # [[3,1,[2,3,6],[1,2,57]]]
    #---------------------------------------------------------------------------
    @equip_requirements = []
    #---------------------------------------------------------------------------
    # End of Equip Requisites
    #---------------------------------------------------------------------------

And find this

Code: [Select]
  #--------------------------------------------------------------------------
  # * Change Equipment (designate object)
  #     equip_type : Equip region (0..4)
  #     item       : Weapon or armor (nil is used to unequip)
  #     test       : Test flag (for battle test or temporary equipment)
  #--------------------------------------------------------------------------
  def change_equip(equip_type, item, test = false)
    last_item = equips[equip_type]
    unless test
      return if $game_party.item_number(item) == 0 if item != nil
      $game_party.gain_item(last_item, 1)
      $game_party.lose_item(item, 1)
    end
    item_id = item == nil ? 0 : item.id
    case equip_type
    when 0  # Weapon
      @weapon_id = item_id
      unless two_hands_legal?             # If two hands is not allowed
        change_equip(1, nil, test)        # Unequip from other hand
      end
    when 1  # Shield
      @armor1_id = item_id
      unless two_hands_legal?             # If two hands is not allowed
        change_equip(0, nil, test)        # Unequip from other hand
      end
    when 2  # Head
      @armor2_id = item_id
    when 3  # Body
      @armor3_id = item_id
    when 4  # Accessory
      @armor4_id = item_id
    end
  end

And replace it with this:

Code: [Select]
  #--------------------------------------------------------------------------
  # * Change Equipment (designate object)
  #     equip_type : Equip region (0..4)
  #     item       : Weapon or armor (nil is used to unequip)
  #     test       : Test flag (for battle test or temporary equipment)
  #--------------------------------------------------------------------------
  def change_equip(equip_type, item, test = false)
    last_item = equips[equip_type]
   
    #---------------------------------------------------------------------------
    # * Don't allow equip if requirement is not met
    #---------------------------------------------------------------------------
    @equip_requirements.each do |requisite1|
      if requisite1[0] == item.id
        if requisite1[2].is_a?(Array)
          for i in 0...requisite1[2].size
            case requisite1[3][i]
            when 1
              return change_equip(equip_type,last_item,test) if @weapon_id != requisite1[2][i]
            when 2
              return change_equip(equip_type,last_item,test) if @armor1_id != requisite1[2][i]
            when 3
              return change_equip(equip_type,last_item,test) if @armor2_id != requisite1[2][i]
            when 4
              return change_equip(equip_type,last_item,test) if @armor3_id != requisite1[2][i]
            when 5
              return change_equip(equip_type,last_item,test) if @armor4_id != requisite1[2][i]
            when 6
              return change_equip(equip_type,last_item,test) if @level < requisite1[2][i]
            end
          end
        else
          case requisite1[3]
          when 1
            return change_equip(equip_type,last_item,test) if @weapon_id != requisite1[2]
          when 2
            return change_equip(equip_type,last_item,test) if @armor1_id != requisite1[2]
          when 3
            return change_equip(equip_type,last_item,test) if @armor2_id != requisite1[2]
          when 4
            return change_equip(equip_type,last_item,test) if @armor3_id != requisite1[2]
          when 5
            return change_equip(equip_type,last_item,test) if @armor4_id != requisite1[2]
          when 6
            return change_equip(equip_type,last_item,test) if @level < requisite[2]
          end
        end
      end
    end
    #---------------------------------------------------------------------------
    # End Equip Requisites (Equip Legal? Function)
    #---------------------------------------------------------------------------
   
    unless test
      return if $game_party.item_number(item) == 0 if item != nil
      $game_party.gain_item(last_item, 1)
      $game_party.lose_item(item, 1)
    end
    item_id = item == nil ? 0 : item.id
    case equip_type
    when 0  # Weapon
      @weapon_id = item_id
      unless two_hands_legal?             # If two hands is not allowed
        change_equip(1, nil, test)        # Unequip from other hand
      end
    when 1  # Shield
      @armor1_id = item_id
      unless two_hands_legal?             # If two hands is not allowed
        change_equip(0, nil, test)        # Unequip from other hand
      end
    when 2  # Head
      @armor2_id = item_id
    when 3  # Body
      @armor3_id = item_id
    when 4  # Accessory
      @armor4_id = item_id
    end
   
    #---------------------------------------------------------------------------
    # * If an item is unequiped, unequip any items that required it
    #---------------------------------------------------------------------------
    @equip_requirements.each do |requisite2|
      if requisite2[2].is_a?(Array)
        for i in 0...requisite2[2].size
          if requisite2[2][i] == last_item.id
            case requisite2[1]
            when 1
              change_equip(0,nil,test) if @weapon_id == requisite2[0] and last_item.id != item_id
            when 2
              change_equip(1,nil,test) if @armor1_id == requisite2[0] and last_item.id != item_id
            when 3
              change_equip(2,nil,test) if @armor2_id == requisite2[0] and last_item.id != item_id
            when 4
              change_equip(3,nil,test) if @armor3_id == requisite2[0] and last_item.id != item_id
            when 5
              change_equip(4,nil,test) if @armor4_id == requisite2[0] and last_item.id != item_id
            when 6
              p "How the heck did you equip this if your level was too low?" if @level < requisite2[2][i]
            end
          end
        end
      else
        if requisite2[2] == last_item.id
          case requisite2[1]
          when 1
            change_equip(0,nil,test) if @weapon_id == requisite2[0] and last_item.id != item_id
          when 2
            change_equip(1,nil,test) if @armor1_id == requisite2[0] and last_item.id != item_id
          when 3
            change_equip(2,nil,test) if @armor2_id == requisite2[0] and last_item.id != item_id
          when 4
            change_equip(3,nil,test) if @armor3_id == requisite2[0] and last_item.id != item_id
          when 5
            change_equip(4,nil,test) if @armor4_id == requisite2[0] and last_item.id != item_id
          when 6
            p "How the heck did you equip this if your level was too low?" if @level < requisite2[2]
          end
        end
      end
    end
    #---------------------------------------------------------------------------
    # End Equip Requisites (Unquip Function)
    #---------------------------------------------------------------------------
   
  end

Credit


  • Tsunokiette

Thanks

  • Modern Algebra 2 (because he's cool and he helped me realize a mistake I made during early production)
  • lorehunter for requesting the script

Support


If you encounter any errors, please let me know :x

Known Compatibility Issues

This script overwrites the change_equip method in Game_Actor. If another script modifies this, it will be overwritten and one of the two won't work. If this occurs then post the method, and I'll try to customize it for you.

Author's Notes


If a piece of equipment requires something, please include that fact in the description.
i.e. "A throwing star. Requires ninja gloves and level 57 to equip"
Otherwise the player will end up throwing a fit because he can't equip certain items and doesn't know why lol.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

********
Shadow Knight
Rep:
Level 91
Ruin that brick wall!
Project of the Month winner for October 2008
Nice script!
I never thought of something like this. ;8
+rep
Be kind, everyone you meet is fighting a hard battle.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Nice job Tsuno. I didn't realize you had added level requirements until I already wrote a script that did it. Sorry about that. I think the two scripts are compatible anyway though, and the main focus of my script is stat requirements, not other equipment requirements, so though there is a little overlap, I don't think it's a big deal.

Anyway, good job with this script.

EDIT::

Damn, our scripts aren't compatible. :( I'd like to integrate the scripts if that's okay with you. You'd get co-author credits of course.
« Last Edit: June 27, 2008, 06:30:27 PM by modern algebra II »

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
That's fine by me, sounds cool.  :)
If the RGSS 2.0 was divided into a more detailed hierarchy then this could have been done with a simple alias lol.

EDIT : I like how you wrote your version, much easier to use lol. I've still got a lot to learn, but that's okay. I recently took out an old C++ book I have and am trying to learn it again seeing as I'm a bit older and it should be much easier to learn it.
« Last Edit: June 27, 2008, 09:09:04 PM by Tsunicorn Fish »
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I just noticed the Notes section a little while ago - it's the reason I wrote the script up :P

***
Rep:
Level 89
... I got nothing.
Would this work for guns? Like, for example, You can't fire the gun unless you have bullets?

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
The only thing this script does is keep you from equipping something if the thing(s) it requires are not equipped. And unequips whenever the required item is unequipped.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

**
Rep: +0/-0Level 82
When is there gonna be a script to where you gotta be a specific actor/class in order to use the item/equipment?  >_>; 

*
Full Metal Mod - He will pillage your women!
Rep:
Level 93
The RGSS Dude
That's easy enough to do without a script. The database editor already allows you to decide which classes can use which equipment. As for specific actors... just make a duplicate of the class which is exactly the same and just add the piece of equipment to the list of equipment that class can use. That way you can't tell the difference between that character's class and another character who has the same class, but at the same time only that character can use the piece of equipment.
"The wonderful thing about Tiggers
Is Tiggers are wonderful things
Their tops are made out of rubber
Their bottoms are made out of springs

They’re bouncy, trouncy, flouncy, pouncy
Fun, fun, fun, fun, fun!
But the most wonderful thing about Tiggers
Is I’m the only one, I’m the only one."

*
Rep: +0/-0Level 81
it says error at line 475: NoMethodError occurred. undefined method 'each' for nil:NilClass when i try to use this