This script requires the Adding Attributes system (insert below Scene_Debug)
[rgss]#==============================================================================
# ** Adding Attributes Easy
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.1
# 2009-02-02 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History:
#
# Version 1.0 -------------------------------------------------- (2009-01-21)
# Version 1.1 ------------------------------------------------- (2009-02-02)
# - Fix: Fixed add_stat default hash setup. Changed to object_to_string.
#------------------------------------------------------------------------------
# * Description:
#
# This script was designed to allow you to give any object (usually data
# structure objects) stats, either with a set stat or a stat that grows
# (stat is a hash, with "level" as the key and stat value as the "value")
# via the Curve Generator module. If you wish to use this for a object class,
# there must be an instance @id specified to read the stats.
#------------------------------------------------------------------------------
# * Instructions:
#
# Place the script anywhere above Main and any scripts that use it.
#------------------------------------------------------------------------------
# * Terms & Conditions:
#
# Copyright (C) 2009 SephirothSpawn (Timothy Hoffman)
# Free for non-commercial & commercial use.
# Any modifications to the system are not to be re-distributed without my
# consent.
#==============================================================================
#==============================================================================
# ** Module
#==============================================================================
class Module
#--------------------------------------------------------------------------
# * Add Stat
#--------------------------------------------------------------------------
private
def add_stat(stat_name, hash_settings)
# Create method
s = "def #{stat_name};"
s += " settings = #{object_to_string(hash_settings)};"
s += " settings.default = #{object_to_string(hash_settings.default)};"
s += " return settings[@id];"
s += "end;"
# Eval method
module_eval (s)
end
#--------------------------------------------------------------------------
# * Add Stat Curve
#--------------------------------------------------------------------------
private
def add_stat_curve(stat_name, hash_settings)
# Create method
s = "def #{stat_name};"
s += ' @gen_stats = {} if @gen_stats == nil;'
s += " if @gen_stats['#{stat_name}'] == nil;"
s += " @gen_stats['#{stat_name}'] = {};"
s += " end;"
s += " if @gen_stats['#{stat_name}'].has_key?(@id);"
s += " return @gen_stats['#{stat_name}'][@id];"
s += " end;"
s += " settings = #{object_to_string(hash_settings)};"
s += " settings.default = #{object_to_string(hash_settings.default)};"
s += " curve = Curve_Generator.generate_curve(*hash_settings[@id]);"
s += " @gen_stats['#{stat_name}'][@id] = curve;"
s += " return @gen_stats['#{stat_name}'][@id];"
s += "end;"
# Eval method
module_eval (s)
end
#--------------------------------------------------------------------------
# * Object to String
#--------------------------------------------------------------------------
def object_to_string(object)
case object
when Array
object.collect! {|value| object_to_string(value)}
return "[#{object.join(',')}]"
when Hash
s = '{'
object.each do |key, value|
s += "#{object_to_string(key)}=>#{object_to_string(value)},"
end
s += '}'
return s
else
return object.to_s
end
end
end
[/rgss]
Then insert this script below that:
[rgss]#==============================================================================
# ** Commands Use Items
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1.0
# 2009-02-11 (Year-Month-Day)
#------------------------------------------------------------------------------
# * Version History:
#
# Version 1.0 -------------------------------------------------- (2009-02-11)
#------------------------------------------------------------------------------
# * Description:
#
# This script was designed to make attacks (with weapons) and skill use
# use items. If you do not have enough of an item to attack or skill, the
# command is disabled.
#------------------------------------------------------------------------------
# * Requirements:
#
# Adding Attributes 1.1 or greater
#------------------------------------------------------------------------------
# * Instructions:
#
# Place the script anywhere above Main and any scripts that use it.
#------------------------------------------------------------------------------
# * Terms & Conditions:
#
# Copyright (C) 2009 SephirothSpawn (Timothy Hoffman)
# Free for non-commercial use.
# 10 USD commercial license (Contact
SephirothSpawn@hotmail.com)
# Any modifications to the system are not to be re-distributed without my
# consent.
#==============================================================================
#==============================================================================
# ** Commands_Use_Items
#==============================================================================
module Commands_Use_Items
#--------------------------------------------------------------------------
# * Weapon's Item Use
#
# weapon_id => {[item_type, item_id] => number_used, ...}
#
# item_type: 0-Item, 1-Weapon, 2-Armor
#--------------------------------------------------------------------------
Weapons_Item_Use = {}
Weapons_Item_Use[1] = {[0, 1] => 1}
#--------------------------------------------------------------------------
# * Skills's Item Use
#
# skill_id => {[item_type, item_id] => number_used, ...}
#
# item_type: 0-Item, 1-Weapon, 2-Armor
#--------------------------------------------------------------------------
Skill_Item_Use = {}
# Do not modify
Weapons_Item_Use.default = {}
Skill_Item_Use.default = {}
end
#==============================================================================
# ** RPG::Weapon
#==============================================================================
class RPG::Weapon
add_stat('item_use', Commands_Use_Items::Weapons_Item_Use)
end
#==============================================================================
# ** RPG::Skill
#==============================================================================
class RPG::Skill
add_stat('item_use', Commands_Use_Items::Weapons_Item_Use)
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
#--------------------------------------------------------------------------
alias_method :seph_commandsuseitems_ae, :attack_effect
def attack_effect(attacker)
# If attacker is actor
if attacker.is_a?(Game_Actor)
# If weapon equipped
if $data_weapons[attacker.weapon_id] != nil
# Gets item use
item_use = $data_weapons[attacker.weapon_id].item_use
# Checks each item
item_use.each do |item, number|
# Branch by item type
case item[0]
when 0 # Items
$game_party.lose_item(item[1], number)
when 1 # Weapons
$game_party.lose_weapon(item[1], number)
when 2 # Armors
$game_party.lose_armor(item[1], number)
end
end
end
end
# Original Attack Effects
seph_commandsuseitems_ae(attacker)
end
#--------------------------------------------------------------------------
# * Applying Normal Attack Effects
#--------------------------------------------------------------------------
alias_method :seph_commandsuseitems_se, :skill_effect
def skill_effect(user, skill)
# Gets original result
effective = seph_commandsuseitems_se(user, skill)
# If effective
if effective
# If user is actor
if user.is_a?(Game_Actor)
# Gets item use
item_use = skill.item_use
# Checks each item
item_use.each do |item, number|
# Branch by item type
case item[0]
when 0 # Items
$game_party.lose_item(item[1], number)
when 1 # Weapons
$game_party.lose_weapon(item[1], number)
when 2 # Armors
$game_party.lose_armor(item[1], number)
end
end
end
end
# Return original result
return effective
end
end
#==============================================================================
# ** Game_Actor
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# * Can Attack?
#--------------------------------------------------------------------------
def can_attack?
# If weapon equipped
if $data_weapons[@weapon_id] != nil
# Gets item use
item_use = $data_weapons[@weapon_id].item_use
# Checks each item
item_use.each do |item, number|
# Branch by item type
case item[0]
when 0 # Items
return false if $game_party.item_number(item[1]) < number
when 1 # Weapons
return false if $game_party.weapon_number(item[1]) < number
when 2 # Armors
return false if $game_party.armor_number(item[1]) < number
end
end
end
return true
end
#--------------------------------------------------------------------------
# * Determine if Skill can be Used
#--------------------------------------------------------------------------
alias_method :seph_commandsuseitems_scu?, :skill_can_use?
def skill_can_use?(skill_id)
# If skill exist
if $data_skills[skill_id] != nil
# Gets skill use
item_use = $data_skills[skill_id].item_use
# Checks each item
item_use.each do |item, number|
# Branch by item type
case item[0]
when 0 # Items
return false if $game_party.item_number(item[1]) < number
when 1 # Weapons
return false if $game_party.weapon_number(item[1]) < number
when 2 # Armors
return false if $game_party.armor_number(item[1]) < number
end
end
end
# Return original test
return seph_commandsuseitems_scu?(skill_id)
end
end
#==============================================================================
# ** Window_Command
#==============================================================================
class Window_Command < Window_Selectable
#--------------------------------------------------------------------------
# * Enable Item
#--------------------------------------------------------------------------
def enable_item(index)
draw_item(index, normal_color)
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Actor Command Window Setup
#--------------------------------------------------------------------------
alias_method :seph_commandsuseitems_p3scw, :phase3_setup_command_window
def phase3_setup_command_window
# Original Setup
seph_commandsuseitems_p3scw
# If cannot attack
unless @active_battler.can_attack?
@actor_command_window.disable_item(0)
else
@actor_command_window.enable_item(0)
end
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : basic command)
#--------------------------------------------------------------------------
alias_method :seph_commandsuseitems_up3bc, :update_phase3_basic_command
def update_phase3_basic_command
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by actor command window cursor position
case @actor_command_window.index
when 0 # attack
# If cannot attack
unless @active_battler.can_attack?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
end
end
# Original Basic Command
seph_commandsuseitems_up3bc
end
end
[/rgss]
To add a weapon item cost:
- Below Weapons_Item_Use = {} add:
Weapons_Item_Use[weapon_id] = {[item_type, item_id] => number, ...}
To add a skill item cost:
- Below Skill_Item_Use = {} add:
Skill_Item_Use[skill_id] = {[item_type, item_id] => number, ...}
For both, replace item_type with: 0-Item, 1-Weapon, 2-Armor
Let me know if you need any help setting it up.