Introduction
This script allows the game developer to create categories within their Items menu, both for the main menu and default battle-system. But not only that, you can hide certain items from display, and define the order in which these categories appear in the menu.
Features
Separation of Items into categories using element tagging
Hide some items using a custom hide element
Define different menus for Field and Battle use
Script
The Script
Code:
#==============================================================================
# ** Fast Item Grouping
#------------------------------------------------------------------------------
# by DerVVulfman
# version 1.2
# 06-12-2023 (MM/DD/YYYY)
# RGSS / RMXP
#==============================================================================
#
# INTRODUCTION:
#
# This script allows the game developer to create categories within their
# Items menu, both for the main menu and default battle-system. But not
# only that, you can hide certain items from display, and define the order
# in which these categories appear in the menu.
#
# It is designed based solely upon the default RPGMaker XP set of scripts,
# has no frills other than what was stated, and performs several rewrites.
#
#------------------------------------------------------------------------------
#
# WHAT IS ELEMENT TAGGING:
#
# It is the process of creating a custom element in the 'System Database',
# and then assigning the element to a piece of inventory, an item, weapon,
# or piece of armor. This script allows you to use the IDs of the elements
# to create the separate groups.
#
#------------------------------------------------------------------------------
#
# Rewrites the following methods:
# * Window_Item : refresh
# * Scene_Battle : update_phase3_item_select
#
# Aliases (Attaches code to) the following methods:
# * Game_Battler : elements_correct
# * Window_Item : initialize
# * Scene_Item : main
# * Scene_Item : update
# * Scene_Item : update_item
# * Scene_Item : update_target
# * Scene_Battle : start_item_select
# * Scene_Battle : end_item_select
#
#------------------------------------------------------------------------------
#
# THANKS AND CREDIT:
#
# Credit goes to CarlosDavilla for noticing issues with the element system
# that inverted healing damage and battle system window cursor control.
#
#------------------------------------------------------------------------------
#
# TERMS OF USE:
#
# Free for use, even in commercial projects. Only due credit is required,
# including those listed within Thanks and Credits.
#
#==============================================================================
module Group
#--------------------------------------------------------------------------
ITEMS = {} # Do not touch
#--------------------------------------------------------------------------
# ITEM GROUP BREAKDOWN
# ---------------------
# Here, you create your individual item groups. Please note that the order
# they appear is based on the 'KEY' for each ITEMS entry in numeric order.
# And note that element -1 is a required weapon element, and element -2 for
# all armor.
#
# Elem Group Name Group Description
# ==== ============ ==================
ITEMS[0] = [ 17, "Heal", "Healing items" ]
ITEMS[1] = [ 18, "Weird", "Weird items" ]
ITEMS[2] = [ -1, "Weapons", "Weapon in inventory" ]
ITEMS[3] = [ -2, "Armor", "Armor being carried" ]
ITEMS[4] = [ 0, "All", "All items" ]
# ITEM ORDER ARRAYS
# -----------------
# The I_MENU setting holds the keys of above ITEMS entries for those groups
# that appear in the main menu Items list. Likewise, the I_BATTLE setting
# holds the keys for ITEMS entries for those groups that appear within the
# default battle system Items menu. The I_BATTLE setting must have values.
#
I_MENU = nil
I_BATTLE = [0,1,4]
# ITEM HIDING ELEMENT
# -------------------
# This setting holds the ID of an element that can be applied to any item
# that the game developer does not want to be visible in inventory.
#
I_HIDE = nil
# ELEMENT EFFECT IGNORE
# ---------------------
# This setting is an array of elements that are being used to group items
# and should not affect any element 'rate' determinations.
#
IGNORE = [17, 18, 19]
end
#==============================================================================
# ** Game_Battler
#------------------------------------------------------------------------------
# This class deals with battlers. It's used as a superclass for the Game_Actor
# and Game_Enemy classes.
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias game_battler_igrouping_elements_correct elements_correct
#--------------------------------------------------------------------------
# * Calculating Element Correction
# element_set : element
#--------------------------------------------------------------------------
def elements_correct(element_set)
# Create a duplicate of the element set
# - Do not erase from the original element set lest tagging is removed
copy_element_set = element_set.dup
# Eliminate the Group Ignore elements from calculations
for i in Group::IGNORE
copy_element_set.delete(i) if copy_element_set.include?(i)
end
# Original call
return game_battler_igrouping_elements_correct(copy_element_set)
end
end
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias window_item_igrouping_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Original call
window_item_igrouping_initialize
# Set new alignment of window
self.y += 64
self.height -= 64
self.index = -1
self.active = false
# Add list of commands
@elements = []
key_list = Group::ITEMS.keys
key_list = Group::I_MENU unless Group::I_MENU.nil?
key_list = Group::I_BATTLE if $game_temp.in_battle
for key in key_list
@elements.push (Group::ITEMS[key][0] )
end
end
#--------------------------------------------------------------------------
# * Item quantity
#--------------------------------------------------------------------------
def item_qty
return @data.size
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
unless self.contents.nil?
self.contents.dispose
self.contents = nil
end
# Add/Refresh item list
refresh_list
# Get item list size
@item_max = @data.size
# Exit if no content
return unless @item_max > 0
# Make a bit map and draw all items
self.contents = Bitmap.new(width - 32, self.row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Refresh List
#--------------------------------------------------------------------------
def refresh_list
# Get element id (individual group or in battle)
element = @elements[$scene.group_id] unless @elements.nil?
e_id = (element.nil?) ? -3 : element
# Set up data array
@data = []
# Add item
for i in 1...$data_items.size
next unless $game_party.item_number(i) > 0
@data.push($data_items[i]) if refresh_test($data_items[i], e_id)
end
for i in 1...$data_weapons.size
next unless $game_party.weapon_number(i) > 0
@data.push($data_weapons[i]) if refresh_test($data_weapons[i], e_id, 1)
end
for i in 1...$data_armors.size
next unless $game_party.armor_number(i) > 0
@data.push($data_armors[i]) if refresh_test($data_armors[i], e_id, 2)
end
end
#--------------------------------------------------------------------------
# * Refresh List
# data : data item
# id : element_id
# flag : type of gear (0=item, 1=weapon, 2=armor)
#--------------------------------------------------------------------------
def refresh_test(data, id, flag=0)
data_set = (flag == 2) ? data.guard_element_set : data.element_set
effective = false
effective = true if data_set.include?(id) # Element ID test
effective = true if flag > 0 && id == (flag * -1) # Armor/Weapon test
effective = true if id == 0 # All Permit
effective = false if data_set.include?(Group::I_HIDE) # Block if hidden
return effective
end
end
#==============================================================================
# ** Window_ItemGroup
#------------------------------------------------------------------------------
# This window allows the targeting of a select group of items.
#==============================================================================
class Window_ItemGroup < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
# Add list of commands
@elements = []
@commands = []
@helps = []
key_list = Group::ITEMS.keys
key_list = Group::I_MENU unless Group::I_MENU.nil?
key_list = Group::I_BATTLE if $game_temp.in_battle
for key in key_list
@elements.push (Group::ITEMS[key][0] )
@commands.push (Group::ITEMS[key][1] )
@helps.push (Group::ITEMS[key][2] )
end
@item_max = @commands.size
@column_max = @commands.size
@item_width = (width - 32) / @commands.size
self.index = 0
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
rect = Rect.new(0, 0, @item_width, 32)
for i in 0...@commands.size
rect.x = @item_width * (i % @column_max)
rect.y = 32 * (i / @column_max)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.color = system_color
self.contents.draw_text(rect, @commands[i], 1)
end
end
#--------------------------------------------------------------------------
# * Update Cursor Rectangle
#--------------------------------------------------------------------------
def update_cursor_rect
return if index == -1
self.cursor_rect.set(@item_width * (index % @column_max),
32 * (index / @column_max), @item_width, 32)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
text = @helps[self.index]
@help_window.set_text(text)
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs item screen processing.
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias scene_item_igrouping_main main
alias scene_item_igrouping_update update
alias scene_item_igrouping_update_item update_item
alias scene_item_igrouping_update_target update_target
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :group_id # index of group item list
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Create group window
@group_window = Window_ItemGroup.new
# Original call
scene_item_igrouping_main
# Delete group window
@group_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Original call
scene_item_igrouping_update
# Update group window
@group_window.update
# Call group window if group window is active
return update_group if @group_window.active
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Erase item / show groupt window
@group_window.active = true
@group_window.visible = true
@item_window.active = false
@item_window.index = -1
# Refresh Input (clears target input)
Input.update
return
end
# Original call
scene_item_igrouping_update_item
end
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# If unable to use because items ran out
unless $game_party.item_can_use?(@item.id)
# Refresh item window
@item_window.refresh #(@group_window.index)
end
# Erase target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
scene_item_igrouping_update_target
end
#--------------------------------------------------------------------------
# * Frame Update (when group window is active)
#--------------------------------------------------------------------------
def update_group
# Update group item based on group index
if @group_id != @group_window.index
# Set group value and refresh
@group_id = @group_window.index
@group_window.help_window = @help_window
@item_window.refresh
end
# Handle player input for cancel / select
return if group_cancel?
return if group_select?
end
#--------------------------------------------------------------------------
# * Frame Update (when exiting group window)
#--------------------------------------------------------------------------
def group_cancel?
# Exit false if B button was pressed
return false unless Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
# Exit true
return true
end
#--------------------------------------------------------------------------
# * Frame Update (when selecting in group window)
#--------------------------------------------------------------------------
def group_select?
# If C button was pressed
return false unless Input.trigger?(Input::C)
# If items are used up
if @item_window.item_qty == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return true
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Erase target window
@item_window.active = true
@item_window.index = 0
@group_window.active = false
return true
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias scene_battle_igrouping_start_item_select start_item_select
alias scene_battle_igrouping_end_item_select end_item_select
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :group_id # index of group item list
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : item selection)
#--------------------------------------------------------------------------
def update_phase3_item_select
# Update Windows
update_phase3_item_select_window
# Update group item based on group index
update_phase3_item_select_group
# Exit if cancel or decidion
return if update_phase3_item_select_cancel?
return if update_phase3_item_select_decision?
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : item group update)
#--------------------------------------------------------------------------
def update_phase3_item_select_window
# Active/inactive decision
if @item_group_select
@item_window.active = false
@item_group_window.active = true
else
@item_window.active = true
@item_group_window.active = false
@item_window.help_window = @help_window
end
# Visibility
@item_window.visible = true
@item_group_window.visible = true
@item_group_window.update
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : item group update)
#--------------------------------------------------------------------------
def update_phase3_item_select_group
# Update window
@item_window.update
# Exit if group is current
return if @group_id == @item_group_window.index
# Set group value and refresh
@group_id = @item_group_window.index
@item_group_window.help_window = @help_window
@item_window.refresh
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : item selection cancellation)
#--------------------------------------------------------------------------
def update_phase3_item_select_cancel?
# Exit false unless B Button was pressed
return false unless Input.trigger?(Input::B)
# Perform cancel SE
$game_system.se_play($data_system.cancel_se)
if @item_group_select
end_item_select
else
@item_group_select = true
@item_window.index = -1
end
return true
end
#--------------------------------------------------------------------------
# * Frame Update (actor command phase : item selection decision)
#--------------------------------------------------------------------------
def update_phase3_item_select_decision?
# Exit false unless C Button was pressed
return false unless Input.trigger?(Input::C)
if @item_group_select
$game_system.se_play($data_system.decision_se)
@item_group_select = false
@item_window.index = 0
else
@item = @item_window.item
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return true
end
$game_system.se_play($data_system.decision_se)
@active_battler.current_action.item_id = @item.id
@item_window.visible = false
if @item.scope == 1
@item_group_window.visible = false
start_enemy_select
elsif @item.scope == 3 or @item.scope == 5
@item_group_window.visible = false
start_actor_select
else
end_item_select
phase3_next_actor
end
end
return true
end
#--------------------------------------------------------------------------
# * Start Item Select
#--------------------------------------------------------------------------
def start_item_select
# Original call
scene_battle_igrouping_start_item_select
# Create Item Group Window
@item_group_window = Window_ItemGroup.new
@item_group_window.back_opacity = 160
@item_group_select = true
@group_id = nil
end
#--------------------------------------------------------------------------
# * End Skill Select
#--------------------------------------------------------------------------
def end_item_select
# Original Call
scene_battle_igrouping_end_item_select
# Item Group dispose
@item_group_window.dispose
@item_group_window = nil
end
end
Instructions
Build into the script.
FAQ
No customization is built into the script other than those listed.
Compatibility
Meant for the default RPGMaker XP system, some methods rewritten and altered.
Thanks and Credits
Credit goes to CarlosDavilla for noticing issues with the element system that inverted healing damage and battle system window cursor control.
Terms and Conditions
Free for use, even in commercial projects. Only due credit is required, including those listed within Thanks and Credits.
After two years, CarlosDavilla notified me of issues with the script. It caused damage when the item meant to heal and the item selection window would not allow the cursor to move when an item was meant to be selected in battle.
For this, the method which dealt with corrected element sets was altered, now merely using attached code instead of a rewrite. And a simple addition of an update command added into the Battle code to fix the window cursor issue was made.
Due credit now goes to CarlosDavilla for notifying me of these issues.