Easy Item Charges
By: FamilyGamer7
IntroductionBy: FamilyGamer7
Features
Screenshots
Script
Ruby:
#==============================================================================
# Title: Easy Item Charges
# Author: FamilyGamer7 (FG7)
# Version: 1.3
# Engine: RPG Maker VX Ace
#==============================================================================
# ** Description |
# ----------------
# The "easiest" way to implement an Item Charge type effect on items.
#==============================================================================
# ** Change Log |
# ---------------
# 1.0 => Created Script
# 1.1 => Removed "Alias" method as it caused issues with the project
# 1.2 => Removed item charge limit (Flexible for any game/project)
# 1.3 => Added Item Charges switch for ON/OFF functionality
#==============================================================================
# ** Terms of Use |
# -----------------
# * Free to use in non-commercial projects and commercial projects
# * Feel free to modify and improve the script. Credit is still required.
# * Credit FamilyGamer7
#==============================================================================
# ** Script(s) Required |
# -----------------------
# Hime - Instance Items:
# (http://himeworks.com/redirect.php?type=script&name=Instance_Items)
#
# Place this script below "Hime - Instance Items" script.
#==============================================================================
# ** Usage |
# ----------
# * Plug & Play (See notes below for more information)
#==============================================================================
# ** Notes |
# ----------
# Just need to add "ANY" number value on the end of your item name.
#
# Ex: "Potion 3"
# Ex: "Antidote 76"
# Ex: "Elixir 6"
#
# -----------------
# | Script calls: |
# -----------------
# - To turn script off:
# $game_system.item_charges_switch_off(true)
#
# - To turn script on:
# $game_system.item_charges_switch_off(false)
#
# * This script is ON by default, so the turn script on call is not needed
# unless you used the turn off script.
#==============================================================================
#==============================================================================
# ** Required Script Checker
#------------------------------------------------------------------------------
# Ensures Required Script is in place. If not, Game will close down.
#==============================================================================
$imported = {} if $imported.nil?
unless $imported["TH_InstanceItems"]
msgbox("Required 'Hime - Instance Items' is not detected - Closing Game")
exit
end
#==============================================================================
# ** Module: FG7::Easy_Item_Charges
#------------------------------------------------------------------------------
# This modules creates a static variable to be used within the script.
#==============================================================================
module FG7
module Easy_Item_Charges
#==============================================================================
# -------------------- ALLOWED TO EDIT BELOW THIS LINE ---------------------- #
#==============================================================================
# Sets the switch number used for the Item Charges script
# (Feel free to change switch number for your project)
Item_Charge_Switch = 1001
#==============================================================================
# ---------- DO NOT EDIT BELOW THIS LINE (FOR ADVANCED USERS) --------------- #
#==============================================================================
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system data. It saves the disable state of saving and
# menus. Instances of this class are referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * New Method: Item Charges Switch - To turn OFF/ON
# (By default the switch is off = the script is turned "ON" working)
#--------------------------------------------------------------------------
def item_charges_switch_off(string)
$game_switches[FG7::Easy_Item_Charges::Item_Charge_Switch] = string
end
end
#==============================================================================
# ** Scene_ItemBase
#------------------------------------------------------------------------------
# This class performs common processing for the item screen and skill screen.
#==============================================================================
class Scene_ItemBase < Scene_MenuBase
#--------------------------------------------------------------------------
# * Alias Method: Use Item (Modified to simulate "Item Charges" on items)
#--------------------------------------------------------------------------
alias :fg7_easy_item_charges_use_item :use_item
def use_item
# Checks if switch is turned on to use item charges for items
if $game_switches[FG7::Easy_Item_Charges::Item_Charge_Switch] == false
play_se_for_item
# Checks if a number is in the items name
if item.name =~ /\d/
# Separates the number from item.name and subtracts to equal new number
$item_name = item.name
$original_charge = $item_name.gsub(/[^0-9]/, '')
$reduced_charge = $original_charge.to_i - 1
$item_name = $item_name.gsub!(/\d+/,"") + $reduced_charge.to_s
# If item charge equals 1 - remove the "1" number value on item name
if $reduced_charge.to_s == "1"
$item_name = $item_name.gsub!(/\d+/,"")
end
# Places item variable back into "item.name"
item.name = $item_name
@category_window.activate
# When no number in item name - treat item as normal usage
else
user.use_item(item)
# If consuming last item in list, move cursor to top of list
@item_window.select(0) if item == nil
end
use_item_to_actors
check_common_event
check_gameover
@actor_window.refresh
# Added to provide a true item charge usage feel
@actor_window.deactivate.unselect
else
# If switch is turned off - perform original use_item call
fg7_easy_item_charges_use_item
end
end
end
How to Use
Terms of Use