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.
[REQUEST] Limited Item Use

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 82
<Limited Item Use>
<January 23th 2011>



Summary
I need a script that makes certain items unusable by actors of a certain class. The "Custom Item Abilities" script made by Yanfly can add this functionnality to my game but it has compatibility issues with the Sideview Battle System. Here is an example of what I would like: the item "Potion" has the tag "unable_x" where x is the ID of the class unable to use this item.

Features Desired
  • Disable the use of an item by a certain class with a tag in the "note field" of the item

What other scripts are you using?
  • Limited Inventory - Modern Algebra
  • Learning from everyone - Leongon
  • Sideview Battle System



Did you search?
Of course I searched first.

Where did you search?
  • Google
  • Other RPG Maker Forums such as RPGMakerVX.com

Hope someone can help me out ! And sorry, my english isn't perfect.
« Last Edit: January 23, 2011, 06:37:40 PM by maniawill »

**
Rep: +0/-0Level 75
Hello everyone ^_^
Modern Algebra made a script that will do this (for me ^_^) (it has more features, but you can choose not to use them) called "Actor Specific Item Effects"

http://rmrk.net/index.php/topic,39954.0.html

all you have to do is put a tag in the item's note box that says "CAN_USE: # # # #" (without the quotes), where "#" means the ACTOR ID

i.e. If you want the item to be used by the first and third actor ID's only, put "CAN_USE: 1 3" (again, without the quotes). Simple enough?
RPMG2k forever!

**
Rep: +0/-0Level 75
Hello everyone ^_^
Oops, I linked to the wrong script... Sorry ^ _ ^;; The script is below in the spoiler.

Spoiler for:
Code: [Select]
#============================================================================
# This makes it so certain items can be used ON specific characters.
# This works outside of battle only.
#============================================================================

#============================================================================
# **how to use
#----------------------------------------------------------------------------
# place <CAN_USE: # # # # # #> in the note of an item, where # is
# a character id
#
# e.g. CAN_USE: 1 2 3
# this item can be used by characters 1, 2, and 3 only
#============================================================================

#============================================================================
#============================================================================

#============================================================================
# ** RPG::Item Module
#----------------------------------------------------------------------------
# This module handles item information.
#============================================================================   

module RPG
    class Item < UsableItem
    #-------------------------------------------------------------------------
    # * Make Item Usability Array
    #-------------------------------------------------------------------------
    def usable_by?
      self.note[/CAN_USE: (.*)/]         
      # Return false if match is nil or collected array of ID's
      return $1 == nil ? false : $1.split.collect! {|id| id.to_i}
    end         
  end
end

#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
#  This class performs the item screen processing.
#==============================================================================

class Scene_Item < Scene_Base
  #--------------------------------------------------------------------------
  # * Update Target Selection
  #--------------------------------------------------------------------------
  alias tds_item_restriction_scene_item_update_target_selection update_target_selection
  def update_target_selection
    # If input trigger C
    if Input.trigger?(Input::C)     
      # If item does not have any usability limitations
      if @item.usable_by? != true
        # If Item is not usable by the selected character                   
        if !@item.usable_by?.include?($game_party.members[@target_window.index].id)
          # Play Buzzer SE
          Sound.play_buzzer
          return
        end
      end   
    end
    tds_item_restriction_scene_item_update_target_selection   
  end
end

I forgot whose this is, but I believe it is Modern Algebras (the coding god).
RPMG2k forever!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature 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
No, not me. That script was written by TDS

**
Rep: +0/-0Level 82
Thank you for this script ! It works very well. But I'm looking for a script working during battles too :S

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Can't believe I missed a script request that's using the request template.

This one should do it.

Code: [Select]
#============================================================================
# ** RPG::Item
#----------------------------------------------------------------------------
# This module handles item information.
#============================================================================ 

module RPG
  class Item < UsableItem
  #--------------------------------------------------------------------------
  # * Get Array of clas ID's that cannot use the item
  #--------------------------------------------------------------------------
  def unusable_by_class?(class_id)
    # Check for classes that cannot use item
    self.note[/DISABLE_USE: (.*[0-9])/i]
    # Return false if match is nil (Default)
    return false if $1 == nil
    # Return true if matched array includes class id
    return true if $1.split.collect! {|id| id.to_i}.include?(class_id)   
    # Return false by default
    return false
    end
  end
end


#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias tds_item_class_use_scene_battle_update_item_selection update_item_selection
  #--------------------------------------------------------------------------
  # * Update Item Selection
  #--------------------------------------------------------------------------
  def update_item_selection
    # If input trigger C
    if Input.trigger?(Input::C)     
      # Get Item
      item = @item_window.item
      # If Item is not nil and it's not usable by class
      if item != nil and item.unusable_by_class?(@active_battler.class_id)
        # Play Buzzer SE
        return Sound.play_buzzer
      end
    end
    # Run Original Method
    tds_item_class_use_scene_battle_update_item_selection
  end
end

Pretty much the same as the other script, except that it uses this in the note tag.

Code: [Select]
DISABLE_USE: # # # # # #

# = The ID of the classes you want to disable the item for.

Code: [Select]
DISABLE_USE: 1 2 3 4

I did not see any links to the "Sideview Battle System" , so I have no idea if this will be compatible with it.

Let me know if it works out for you and if you need anything added or removed.

Have a nice day.

**
Rep: +0/-0Level 82
Thank you for making this script ! But I have an error message when I select an item during battle:
"Script 'Disable Item Use' line 46: NoMethodError occured. undefined method `class_id' for nil:NilClass"

Hope you can correct it ;) !

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
Well, like I said before without the battle system I don't know if it will be compatible or not.

Please provide the battle system you are using so I can test it out.

Or make a small demo with the scripts you are using to make it compatible. Please make sure that the demo can be tested.

**
Rep: +0/-0Level 82
I created a demo containing all of my scripts. Here is the link:
http://www.megaupload.com/?d=8HP05FV0

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
I can't open it without the password.

**
Rep: +0/-0Level 82
Sorry. Here is another one:
http://www.megaupload.com/?d=H6ODJPF0

(In the script list, I inserted a * in front of the scripts which may have a link with the error, so you can save time.)

pokeball TDSOffline
***
Rep:
Level 84
-T D S-
Silver - GIAW 11 (Hard)Silver - Game In A Week VII
That one is also password protected...

Just tell me the password to open it, so I can fix it.

**
Rep:
Level 81
Um, if you use Yanfly's Battle Engine Melody and use the SBS option, you shouldn't run into an incompatibility issue with Yanfly's "Custom Item Abilities" script.
Current Project - Storybook Chronicles
Story - 100%
Graphics - 65%
    - editing Kaduki's cut-in pics and facesets
    - creating custom menu graphics
    - creating custom title graphics
    - creating custom HP/MP bars
    - creating custom ATB bars
    - creating custom EXP bars
    - editing monster sprites
Eventing - 60%
Dungeons - 40%
Town Maps - 55%
Town Outskirts Maps - 75%