<Limited Item Use>
<January 23th 2011>
SummaryI 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.
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?
Oops, I linked to the wrong script... Sorry ^ _ ^;; The script is below in the spoiler.
[spoiler]#============================================================================
# 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[/spoiler]
I forgot whose this is, but I believe it is Modern Algebras (the coding god).
No, not me. That script was written by TDS
Thank you for this script ! It works very well. But I'm looking for a script working during battles too :S
Can't believe I missed a script request that's using the request template.
This one should do it.
#============================================================================
# ** 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.
DISABLE_USE: # # # # # #
# = The ID of the classes you want to disable the item for.
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.
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 ;) !
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.
I created a demo containing all of my scripts. Here is the link:
http://www.megaupload.com/?d=8HP05FV0 (http://www.megaupload.com/?d=8HP05FV0)
I can't open it without the password.
Sorry. Here is another one:
http://www.megaupload.com/?d=H6ODJPF0 (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.)
That one is also password protected...
Just tell me the password to open it, so I can fix it.
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.