#===============================================================================
#
# Pacman Advanced Creative (PAC) Engine - Item Scene
# 26/5/2011
# Type: Menu
# Installation: Optional stuff.
# Level: Average
# With: Cozziekuns (apissted by Modern Algebra)
#
#===============================================================================
#
# Description:
# This is an inventory screen that sorts your items into categories and displays
# them neatly. It's super sexy, I promise.
#
#===============================================================================
#
# Instructions
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
# Change the modules to your liking. The "hard" parts have instructions of their
# own.
#
#===============================================================================
$imported = {} if $imported == nil
$imported["PACItems"] = true
module PAC
module SYSTEM
DISPLAY_TEXT = "Currently Displayed:"
#===============================================================================
# Extra Item Categories (Inspired by Modern Algebra)
# ------------------------------------------------------------------------------
# How should I go about explaining something like this? Well, basically, each
# item in the hash represents a certain category. For example, the first hash we
# see here is:
#
# 0 => [144, "All", false]
#
# The syntax of this is:
#
# Category ID => [Icon Number, Text, Prime]
#
# Probably the most important part, the category ID is the number you want to
# put into the notebox that the item contains. For example, if you wanted to
# make the item "World Map" into a key item, simply add the text:
#
# \item_category[4]
#
# into the notebox. Note that numbers 0, 1, 2, and 3 are special. They're prime
# categories. Sound special right? Not really, this just means you have to have
# them in the inventory for this script to work. I could've gotten rid of them,
# but that would've just given more work on your part (and mine), so bear with
# them, please. Icon Numbers and Text are pretty self explanatory.
#
# Last, but not least, is the "Prime" function (inspired by Kyraiki). Setting
# this to "true" means that anything in the prime category will not show up in
# the item, weapon or armour categories. You can set if you want it to show up
# in all.
#===============================================================================
ITEM_CATEGORIES = {
0 => [144, "All", false],
1 => [64, "Items", false],
2 => [26, "Weapons", false],
3 => [40, "Armours", false],
4 => [80, "Key Items", true],
5 => [90, "Filler", false],
6 => [92, "Scrolling", false],
7 => [32, "Scrolling", false],
}
ITEM_CATEGORY_WIDTH = 300 # How wide you want your text window.
KYRIAKI_ALL_CATEOGRY_PRIME = false # If you want prime key items to show up
# in the all window.
MAX_ITEM_ICONS = (544 - ITEM_CATEGORY_WIDTH) / 54 # The maximum
# number of icons that will fit.
end
end
#==============================================================================
# ** RPG::BaseItem
#------------------------------------------------------------------------------
# The superclass of all states.
#==============================================================================
class RPG::BaseItem
#--------------------------------------------------------------------------
# * Cozziekuns Category Index
#--------------------------------------------------------------------------
def pac_inv_category_index
@pac_inv_category_index = 0
if self.note[/\\item_category\[(\d+)]/i] != nil
@pac_inv_category_index = $1.to_i
end
return @pac_inv_category_index
end
end
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays a list of inventory items for the item screen, etc.
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
alias pac_inv_pis_refresh refresh
def refresh(sort_index = 0)
@sort_index = sort_index
pac_inv_pis_refresh
end
#--------------------------------------------------------------------------
# * Whether or not to include in item list
# item : item
#--------------------------------------------------------------------------
alias pac_inv_pis_include? include?
def include?(item)
val = pac_inv_pis_include?(item)
return false if !val
return case @sort_index
when 0
unless PAC::SYSTEM::KYRIAKI_ALL_CATEOGRY_PRIME
if PAC::SYSTEM::ITEM_CATEGORIES[item.pac_inv_category_index][2]
return false
else
return true
end
else
return true
end
when 1
if PAC::SYSTEM::ITEM_CATEGORIES[item.pac_inv_category_index][2]
return false
else
return item.is_a?(RPG::Item)
end
when 2
if PAC::SYSTEM::ITEM_CATEGORIES[item.pac_inv_category_index][2]
return false
else
return item.is_a?(RPG::Weapon)
end
when 3
if PAC::SYSTEM::ITEM_CATEGORIES[item.pac_inv_category_index][2]
return false
else
return item.is_a?(RPG::Armor)
end
when 4..999
return item.pac_inv_category_index == @sort_index
end
end
end
#==============================================================================
# ** Window_ItemCategory
#------------------------------------------------------------------------------
# This window displays what type of item is being displayed.
#==============================================================================
class Window_ItemCategory < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, WLH + 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(sort_index = 0)
@sort_index = sort_index
@item_categories = PAC::SYSTEM::ITEM_CATEGORIES
@item_categories_width = PAC::SYSTEM::ITEM_CATEGORY_WIDTH
@category_string = PAC::SYSTEM::DISPLAY_TEXT
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @category_string, 0)
self.contents.font.color = normal_color
for i in 0...@item_categories.size
if @sort_index == i
self.contents.draw_text(4, 0, @item_categories_width - 40, WLH, @item_categories[i][1], 2)
end
end
end
end
#==============================================================================
# ** Window_ItemSort
#------------------------------------------------------------------------------
# This window displays what type of item is being displayed.
#==============================================================================
class Window_ItemSort < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
# x : window X coordinate
# y : window Y coordinate
#--------------------------------------------------------------------------
def initialize(x, y, width)
super(x, y, width, WLH + 32)
@ox = 0
if PAC::SYSTEM::MAX_ITEM_ICONS < PAC::SYSTEM::ITEM_CATEGORIES.size
self.contents = Bitmap.new(self.width - 32 + ((PAC::SYSTEM::ITEM_CATEGORIES.size - PAC::SYSTEM::MAX_ITEM_ICONS) * 54), self.height - 32)
end
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(sort_index = 0)
@sort_index = sort_index
@item_categories = PAC::SYSTEM::ITEM_CATEGORIES
@item_categories_width = PAC::SYSTEM::ITEM_CATEGORY_WIDTH
self.contents.clear
for i in 0...@item_categories.size
@icon_x = 0 + (i * ((544 - @item_categories_width) / @item_categories.size))
if @item_categories.size < PAC::SYSTEM::MAX_ITEM_ICONS
draw_item(i)
else
draw_items(i)
end
if @sort_index == i
if @item_categories.size < PAC::SYSTEM::MAX_ITEM_ICONS
draw_icon(@item_categories[i][0], @icon_x, 0, true)
else
draw_icon(@item_categories[i][0], i * 54, 0, true)
end
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
icons_x = (544 - @item_categories_width) / @item_categories.size
draw_icon(@item_categories[index][0], index * icons_x, 0, false)
end
#--------------------------------------------------------------------------
# * Draw Items
# index : item number
#--------------------------------------------------------------------------
def draw_items(index)
draw_icon(@item_categories[index][0], index * 54, 0, false)
end
end
#==============================================================================
# ** Window_PACItemHelp
#------------------------------------------------------------------------------
# This window shows skill and item explanations along with actor status and
# graphics fit for PAC scripts.
#==============================================================================
class Window_PACItemHelp < Window_Base
def initialize
super(0, 56, 544, WLH + 32)
end
def set_text(text, align = 0)
if text != @text or align != @align
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
@text = text
@align = align
end
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs the item screen procepisng.
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# * Start procepisng
#--------------------------------------------------------------------------
def start
super
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_PACItemHelp.new
@help_window.viewport = @viewport
@item_window = Window_Item.new(0, 112, 544, 304)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.active = false
@category_width = PAC::SYSTEM::ITEM_CATEGORY_WIDTH
@category_window = Window_ItemCategory.new(544 - @category_width, 0, @category_width)
@sort_window = Window_ItemSort.new(0, 0, 544 - @category_width)
@target_window = Window_MenuStatus.new(0, 0)
@sort_index = 0
@item_categories = PAC::SYSTEM::ITEM_CATEGORIES
hide_target_window
end
#--------------------------------------------------------------------------
# * Termination Procepisng
#--------------------------------------------------------------------------
alias pac_pis_terminate terminate
def terminate
super
pac_pis_terminate
@sort_window.dispose
@category_window.dispose
end
#--------------------------------------------------------------------------
# * Update Frame
#--------------------------------------------------------------------------
alias pac_pis_update update
def update
super
pac_pis_update
@sort_window.update
@category_window.update
end
#--------------------------------------------------------------------------
# * Update Item Selection
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
@item = @item_window.item
if @item != nil
$game_party.last_item_id = @item.id
end
if $game_party.item_can_use?(@item)
Sound.play_decision
determine_item
else
Sound.play_buzzer
end
elsif Input.trigger?(Input::X)
@sort_index -= 1
@sort_index %= @item_categories.size
if @sort_index + 1 == @item_categories.size
@sort_window.ox += 54 * (@item_categories.size - PAC::SYSTEM::MAX_ITEM_ICONS)
else
if @item_categories.size > PAC::SYSTEM::MAX_ITEM_ICONS and @sort_index > PAC::SYSTEM::MAX_ITEM_ICONS - 2
@sort_window.ox -= 54
end
end
@category_window.refresh(@sort_index)
@sort_window.refresh(@sort_index)
@item_window.refresh(@sort_index)
@item_window.index = 0
Sound.play_cursor
elsif Input.trigger?(Input::Y)
@sort_index += 1
@sort_index %= @item_categories.size
if @sort_index != 0
if @item_categories.size > PAC::SYSTEM::MAX_ITEM_ICONS and @sort_index > PAC::SYSTEM::MAX_ITEM_ICONS - 1
@sort_window.ox += 54
end
else
@sort_window.ox = 0
end
@category_window.refresh(@sort_index)
@sort_window.refresh(@sort_index)
@item_window.refresh(@sort_index)
@item_window.index = 0
Sound.play_cursor
elsif Input.trigger?(Input::A)
@sort_index -= 1
@sort_index %= @item_categories.size
if @sort_index + 1 == @item_categories.size
@sort_window.ox += 54 * (@item_categories.size - PAC::SYSTEM::MAX_ITEM_ICONS)
else
if @item_categories.size > PAC::SYSTEM::MAX_ITEM_ICONS and @sort_index > PAC::SYSTEM::MAX_ITEM_ICONS - 2
@sort_window.ox -= 54
end
end
@category_window.refresh(@sort_index)
@sort_window.refresh(@sort_index)
@item_window.refresh(@sort_index)
@item_window.index = 0
Sound.play_cursor
end
end
end
#===============================================================================
#
# END OF SCRIPT
#
#=================================400 yay=======================================