Right now, I’ve got a script that categorizes items in the overworld. However it does not categorize items in battle. Basically, I want to make it so when I click on the Inventory button, it opens another menu that shows me more buttons for opening the item categories, including key items. But I do not know how to do that.
Here’s a small script that adds a category window to the battle item menu, with Items and Key Items. Open the Script Editor (F11) and paste it into a new slot under ▼ Materials, below your item category script:
class Window_BattleItemCategory < Window_ItemCategory
def col_max
return 2
end
def make_command_list
add_command(Vocab::item, :item)
add_command(Vocab::key_item, :key_item)
end
end
class Window_BattleItem < Window_ItemList
def include?(item)
super && (@category == :key_item || $game_party.usable?(item))
end
end
class Scene_Battle < Scene_Base
alias item_category_create_all_windows create_all_windows
def create_all_windows
item_category_create_all_windows
create_item_category_window
end
def create_item_category_window
@item_category_window = Window_BattleItemCategory.new
@item_category_window.y = @help_window.height
@item_category_window.help_window = @help_window
@item_category_window.hide.deactivate
@item_category_window.set_handler(:ok, method(:on_item_category_ok))
@item_category_window.set_handler(:cancel, method(:on_item_category_cancel))
@item_category_window.item_window = @item_window
@item_window.y += @item_category_window.height
@item_window.height -= @item_category_window.height
end
def command_item
@item_window.refresh
@item_window.show
@item_window.unselect
@item_category_window.show.activate
end
def on_item_category_ok
@item_window.activate
@item_window.select_last
end
def on_item_category_cancel
@item_category_window.hide
@item_window.hide
@actor_command_window.activate
end
def on_item_cancel
@item_window.unselect
@item_category_window.activate
end
alias item_category_next_command next_command
def next_command
@item_category_window.hide
item_category_next_command
end
end
When you pick Inventory in battle, the categories come up first and the list underneath switches as you move between them. Regular items still only show if they can be used in battle. Key items always show, just grayed out if they can’t be used.
If your overworld script adds its own categories and you want those in battle too, let me know which script it is and I can take a look.
Baz my goat is back at it again
I love you
I would like to use my own categories, yes please.
I am using this script. The seiryuki item scene.
[VXA] Categorize Item Scene
It seems to index (or whatever it’s called) the categories, and then a notetag is used on the items to put them in the categories.
That script already sorts everything with its notetags, so the battle window can just borrow its category list. Swap the script from before for this one, still below the Categorize Item Scene script:
class Window_BattleItemCategory < Window_ItemCategory
HIDDEN = [:weapon, :armor]
def col_max
[item_max, 1].max
end
def make_command_list
ICAT::VISIBLE_CATEGORY_INDEX.each do |symbol, label|
add_command(label, symbol) unless HIDDEN.include?(symbol)
end
end
def update_help
i = ICAT::VISIBLE_CATEGORY_INDEX.keys.index(current_symbol)
@help_window.set_text(i ? ICAT::CATEGORY_DESCRIPTION[i] : "")
end
end
class Window_BattleItem < Window_ItemList
def include?(item)
return false unless super
(item.is_a?(RPG::Item) && item.key_item?) || $game_party.usable?(item)
end
end
class Scene_Battle < Scene_Base
alias item_category_create_all_windows create_all_windows
def create_all_windows
item_category_create_all_windows
create_item_category_window
end
def create_item_category_window
@item_category_window = Window_BattleItemCategory.new
@item_category_window.y = @help_window.height
@item_category_window.help_window = @help_window
@item_category_window.hide.deactivate
@item_category_window.set_handler(:ok, method(:on_item_category_ok))
@item_category_window.set_handler(:cancel, method(:on_item_category_cancel))
@item_category_window.item_window = @item_window
@item_window.y += @item_category_window.height
@item_window.height -= @item_category_window.height
end
def command_item
@item_window.refresh
@item_window.show
@item_window.unselect
@item_category_window.show.activate
end
def on_item_category_ok
@item_window.activate
@item_window.select_last
end
def on_item_category_cancel
@item_category_window.hide
@item_window.hide
@actor_command_window.activate
end
def on_item_cancel
@item_window.unselect
@item_category_window.activate
end
alias item_category_next_command next_command
def next_command
@item_category_window.hide
item_category_next_command
end
end
Battle uses the same categories as your VISIBLE_CATEGORY_INDEX list, minus Weapons and Armor since those can’t be used in battle. Each one shows its CATEGORY_DESCRIPTION text in the help window like the item menu does. If you made your own weapon or armor categories, add their symbols to the HIDDEN line at the top so they don’t show up empty in battle.
I feel like a spoiled child every time you give us scripts, thank you so much
Wait, how do I make the item box bigger?
Hey, I noticed when I close out of the item menu, it gets rid of all of the windows and you have to press a button to make them come back. It’s a small thing, but it’s kind of poopy. Executing my actions keeps the categories on screen while everything is happening.
Also, closing out of an item menu not only takes you out of the items, but also goes back in the regular battle menu. I think this is because I’m using the Yanfly battle engine.
Is it going to have to be wraps?
Yanfly’s battle engine has its own steps for when the item menu opens and closes, like hiding the battle menu and bringing it back. My script was replacing those steps instead of adding to them. Swap it for this one, still below the Categorize Item Scene script:
class Window_BattleItemCategory < Window_ItemCategory
HIDDEN = [:weapon, :armor]
def col_max
[item_max, 1].max
end
def make_command_list
ICAT::VISIBLE_CATEGORY_INDEX.each do |symbol, label|
add_command(label, symbol) unless HIDDEN.include?(symbol)
end
end
def update_help
i = ICAT::VISIBLE_CATEGORY_INDEX.keys.index(current_symbol)
@help_window.set_text(i ? ICAT::CATEGORY_DESCRIPTION[i] : "")
end
def update
super
self.visible = @item_window.visible if @item_window
end
end
class Window_BattleItem < Window_ItemList
def include?(item)
return false unless super
(item.is_a?(RPG::Item) && item.key_item?) || $game_party.usable?(item)
end
end
class Scene_Battle < Scene_Base
alias item_category_create_all_windows create_all_windows
def create_all_windows
item_category_create_all_windows
create_item_category_window
end
def create_item_category_window
@item_category_window = Window_BattleItemCategory.new
@item_category_window.width = @item_window.width
@item_category_window.refresh
@item_category_window.x = @item_window.x
@item_category_window.y = @item_window.y - @item_category_window.height
@item_category_window.help_window = @help_window
@item_category_window.hide.deactivate
@item_category_window.set_handler(:ok, method(:on_item_category_ok))
@item_category_window.set_handler(:cancel, method(:on_item_cancel))
@item_category_window.item_window = @item_window
@item_window.set_handler(:cancel, method(:on_item_list_cancel))
end
alias item_category_command_item command_item
def command_item
item_category_command_item
@item_window.deactivate
@item_window.unselect
@item_category_window.activate
end
def on_item_category_ok
@item_window.activate
@item_window.select_last
end
def on_item_list_cancel
@item_window.unselect
@item_category_window.activate
end
end
Backing out of the item list goes to the categories, and backing out of the categories goes to the battle menu with everything showing again. The category bar sits right on top of the item list now and hides whenever the list does, so it shouldn’t hang around while actions play out. The list is also back to the same size as the skill list, since it doesn’t shrink to make room anymore.
OMG it works, tysm
I’ve noticed similar issues with menu navigation in games, especially when different plugins affect the battle system. Keeping the category windows visible while actions are being executed would make the gameplay much smoother and save players from having to reopen the menus repeatedly. It would also be helpful if closing an item menu returned players to the expected screen instead of unexpectedly switching back to the main battle menu. Could this be handled with a small plugin adjustment or a compatibility fix?