iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

Keep an eye out for the upcoming 3rd Quarter Contest!
 
Reply to this topicStart new topic
> VX Script Request: Skills Consume Items
Geosage
post Mar 27 2010, 07:29 PM
Post #1



Group Icon


Type: Undisclosed




Does anyone have a script for skills to consume items? Basically, what I need is for a skill to require some items before that particular skill can be used, and for the skill to consume those items after use. Also, if the required items are not in the player's inventory, then the the skill will be unusable.

There's a script for this for RPG Maker XP, but sadly, I am using RPG Maker VX.
Go to the top of the page
 
+Quote Post
   
RPGI
post Mar 27 2010, 08:55 PM
Post #2


NA
Group Icon


Type: Coder
Alignment: Chaotic Good




This script here allows you to create skills that require only one type of item, unless you wish to make skills that require multiple types. In which case I'll edit it in for you.
Spoiler:
CODE
#==============================================================================
# ** Skill Consume Items by RPGI
#------------------------------------------------------------------------------
#  This scrip allows the creation of skills that require items to use and
#  consume the items when used.
#
#  How to use:
#    To define a skill that consumes an item, place in it's notebox:
#      <requireitem=ID,N>     where  N = the number required
#                                   ID = the ID of the item required
#
#==============================================================================

class Game_Actor < Game_Battler
  alias ri_skill_can_use? skill_can_use? unless $@
  def skill_can_use?(skill)
    return false unless have_skill_items?(skill)
    ri_skill_can_use?(skill)
  end
  def have_skill_items?(skill)
    data = skill.requireitem
    return true if data.empty?
    return true if $game_party.item_number($data_items[data[0]]) >= data[1]
  end
end

class Scene_Battle < Scene_Base
  alias ri_execute_action_skill execute_action_skill
  def execute_action_skill
    req_item_data = @active_battler.action.skill.requireitem
    unless req_item_data.empty?
      $game_party.gain_item($data_items[req_item_data[0]], -req_item_data[1])
    end
    ri_execute_action_skill
  end
end

class RPG::UsableItem
  def requireitem
    result = []
    if self.note[/<requireitem=(.+)>/] != nil then
      result = $1.split(",").map { |data| data.to_i }
    end
    return result
  end
end


--------------------
Variables don't work? Get the fix here!

- Beginners click here!
Go to the top of the page
 
+Quote Post
   
Geosage
post Mar 27 2010, 09:23 PM
Post #3



Group Icon


Type: Undisclosed




QUOTE (RPGI @ Mar 27 2010, 08:55 PM) *
This script here allows you to create skills that require only one type of item, unless you wish to make skills that require multiple types. In which case I'll edit it in for you.
CODE

#==============================================================================
# ** Skill Consume Items by RPGI
#------------------------------------------------------------------------------
# This scrip allows the creation of skills that require items to use and
# consume the items when used.
#
# How to use:
# To define a skill that consumes an item, place in it's notebox:
# <requireitem=N,ID> where N = the number required
# ID = the ID of the item required
#
#==============================================================================

class Game_Actor < Game_Battler
alias ri_skill_can_use? skill_can_use? unless $@
def skill_can_use?(skill)
return false unless have_skill_items?(skill)
ri_skill_can_use?(skill)
end
def have_skill_items?(skill)
data = skill.requireitem
return true if data.empty?
return true if $game_party.item_number($data_items[data[0]]) >= data[1]
end
end

class Scene_Battle < Scene_Base
alias ri_execute_action_skill execute_action_skill
def execute_action_skill
req_item_data = @active_battler.action.skill.requireitem
unless req_item_data.empty?
$game_party.gain_item($data_items[req_item_data[0]], -req_item_data[1])
end
ri_execute_action_skill
end
end

class RPG::UsableItem
def requireitem
result = []
if self.note[/<requireitem=(.+)>/] != nil then
result = $1.split(",").map { |data| data.to_i }
end
return result
end
end



Will your script allow the skill to consume 2 items of the same type? For example, will it be able to consume 2 Potions? From reading the comment part, I'm assuming it does, but I want to be sure anyway. I'll try it and see if it's compatible with the other scripts that I'm currently using.

EDIT: For some reason, whenever I copy-paste your code into Notepad or Script Editor, it pastes it without Carriage Return, so I just get a long line of text. Do you know what I'm doing wrong?

This post has been edited by Geosage: Mar 27 2010, 09:27 PM
Go to the top of the page
 
+Quote Post
   
Mithran
post Mar 28 2010, 06:31 AM
Post #4


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




Copy the script from a quoted reply (or edit your post, copy from there), or paste into a word processing program first before moving into the editor. I'll go back and fix the post to use a spoiler + code instead of a codebox too.


--------------------
Go to the top of the page
 
+Quote Post
   
relnor
post Aug 23 2010, 05:40 AM
Post #5



Group Icon


Type: Undisclosed




hello, i was wondering. is there a way for the skill to be disabled when the required item ran out or not enough?
well i dont know, maybe i screwed up on that script or something.
Go to the top of the page
 
+Quote Post
   
Mithran
post Aug 23 2010, 07:56 AM
Post #6


Scripter
Group Icon


Type: Coder
Alignment: True Neutral




If there are not enough of the required item, the skill should be automatically disabled. If it isn't, then you are likely using a conflicting script.


--------------------
Go to the top of the page
 
+Quote Post
   
relnor
post Aug 23 2010, 03:06 PM
Post #7



Group Icon


Type: Undisclosed




oh darn. im not good at scripts. i guess this is conflict with Shanghai Simple Script - Equipment Skills. well while using the skill on the item.
i just wanted some sort of quick gun like weapon on the misc slot or a shoulder mounted launcher XD.
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd August 2014 - 06:38 AM

RPGMakerVX.net is an Privacy Policy, Legal.