11-22-2016, 08:09 PM
Hrm... not the revised one I made, eh?
Well.... it's not the cleanest code, but drop this below your item script:
Remember, you now need to redo your graphics showing "ITEM / WEAPON / ARMOR" to now be "ITEM / WEAPON / ARMOR / MISC"
Well.... it's not the cleanest code, but drop this below your item script:
Code:
#==============================================================================
# Extra ITEM for MOG_Scene_Item V1.3 by Moghunter
# http://www.atelier-rgss.com
#==============================================================================
# Patch by DerVVulfman
#
# NOTE: Requires the end user to rework their "Item_com" graphics to allow
# for a 4th category, the 'Special' item type. The format is:
# Item_com01.png ... To have 4 items, the 1st window "Item" highlighted
# Item_com02.png ... To have 4 items, the 2nd window "Weapon" highlighted
# Item_com03.png ... To have 4 items, the 3rd window "Armor" highlighted
# Item_com04.png ... To have 4 items, the 4th window "Special" highlighted
#
# Special Items are items not visible in the normal Item bag, but are loca-
# ted in the 4th category in the item window. ONLY within the 4th window
# will these items be found.
#
# To define special items, place the IDs of these items within the
# SpecialSelect array inside the MOG module.
#
#
#
#==============================================================================
module MOG
SpecialSelect = [1,2,3] # List if items in the special/4th window
end
#==============================================================================
# ** Window_Item_Ex
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
# A total rewrite, so any other script using Window_Item is NOT compatible.
#==============================================================================
class Window_Item_Ex < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(special=false)
super(250, 50, 295, 350)
@column_max = 1
@special = special
refresh
self.index = 0
return unless $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
# Clear Window Contents / Area
if self.contents != nil
self.contents.dispose
self.contents = nil
end
# Erase Data
@data = []
# Sort through Items
for i in 1...$data_items.size
# And add only if party holds
if $game_party.item_number(i) > 0
# If special data, push only special IDs
if @special == true
@data.push($data_items[i]) if MOG::SpecialSelect.include?(i)
# Otherwise, only push IDs that aren't special
else
@data.push($data_items[i]) unless MOG::SpecialSelect.include?(i)
end
end
end
# Clear Contents
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
case item
when RPG::Item
number = $game_party.item_number(item.id)
end
if item.is_a?(RPG::Item) and
$game_party.item_can_use?(item.id)
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4 + index % 1 * (288 + 32)
y = index / 1 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.font.name = "Georgia"
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 190, 32, item.name, 0)
self.contents.draw_text(x + 215, y, 16, 32, ":", 1)
self.contents.draw_text(x + 230, y, 24, 32, number.to_s, 2)
end
end
class Window_Type < Type_Sel
def initialize
super(0, 0, 0, 0)
@item_max = 4
self.index = 0
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs item screen processing.
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Set the background and overlay images
@back = Plane.new
@back.bitmap = RPG::Cache.picture("MN_BK")
@back.z = 100
@item_lay = Sprite.new
@item_lay.bitmap = RPG::Cache.picture("Item_lay")
@item_lay.z = 100
# Set the initial TYPE graphic
@item_com = Sprite.new
@item_com.bitmap = RPG::Cache.picture("Item_com01")
@item_com.z = 100
# Create the invisible TYPE window (used for item type selection)
@type = Window_Type.new
@type.opacity = 0
@type.visible = false
# Set the help window
@help_window = Window_Help.new
@help_window.y = 405
# Item Window
@item_window = Window_Item_Ex.new
@item_window.help_window = @help_window
@item_window.visible = true
@item_window.active = true
# Weapon Window
@weapon_window = Window_Weapon.new
@weapon_window.help_window = @help_window
@weapon_window.visible = false
@weapon_window.active = true
# Armor Window
@armor_window = Window_Armor.new
@armor_window.help_window = @help_window
@armor_window.visible = false
@armor_window.active = true
# Extra Item Window
@item2_window = Window_Item_Ex.new(true)
@item2_window.help_window = @help_window
@item2_window.visible = false
@item2_window.active = true
# Target Window
@target_window = Window_Target_Item.new
@target_window.x = -300
@target_window.active = false
# Help Window
@help_window.opacity = 0
@help_window.x = -200
@help_window.contents_opacity = 0
# Set Window Opacities
@item_window.opacity = 0
@weapon_window.opacity = 0
@armor_window.opacity = 0
@item2_window.opacity = 0
@target_window.opacity = 0
# Sex Window Positions
@weapon_window.x = 640
@armor_window.x = 640
@item_window.x = 640
@item2_window.x = 640
# Set Window Contents Opacities
@weapon_window.contents_opacity = 0
@armor_window.contents_opacity = 0
@item_window.contents_opacity = 0
@item2_window.contents_opacity = 0
# Execute transition
Graphics.transition(MOG::MNIT, "Graphics/Transitions/" + MOG::MNITT)
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
break if $scene != self
end
# Cycle through windows and hide
for i in 0..10
# Scroll the windows
@weapon_window.x += 25
@armor_window.x += 25
@item_window.x += 25
@item2_window.x += 25
# Lower window opacities
@weapon_window.contents_opacity -= 25
@armor_window.contents_opacity -= 25
@item_window.contents_opacity -= 25
@item2_window.contents_opacity -= 25
# Change item hud display
@item_lay.zoom_x += 0.2
@item_lay.opacity -= 25
@item_com.zoom_y += 0.2
@item_com.opacity -= 25
@target_window.x -= 25
@help_window.contents_opacity -= 25
@back.ox += 2
# Update game screen
Graphics.update
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@item_window.dispose
@item2_window.dispose
@weapon_window.dispose
@armor_window.dispose
@target_window.dispose
@item_lay.dispose
@back.dispose
@item_com.dispose
@type.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Scroll out the target window
if @target_window.active == true
@target_window.visible = true
if @target_window.x < 0
@target_window.x += 30
elsif @target_window.x >= 0
@target_window.x = 0
end
else
if @target_window.x > -300
@target_window.x -= 30
elsif @target_window.x >= -300
@target_window.x = -300
@target_window.visible = false
end
end
# Scroll the help window
if @help_window.x < 0
@help_window.x += 15
@help_window.contents_opacity += 20
elsif @help_window.x >= 0
@help_window.x = 0
@help_window.contents_opacity = 255
end
# Scroll the window types
if @item_window.x > 250
@weapon_window.x -= 30
@armor_window.x -= 30
@item_window.x -= 30
@item2_window.x -= 30
@weapon_window.contents_opacity += 20
@armor_window.contents_opacity += 20
@item_window.contents_opacity += 20
@item2_window.contents_opacity += 20
elsif @item_window.x <= 250
@weapon_window.x = 250
@armor_window.x = 250
@item_window.x = 250
@item2_window.x = 250
@weapon_window.contents_opacity = 250
@armor_window.contents_opacity = 250
@item_window.contents_opacity = 250
@item2_window.contents_opacity = 250
end
# If no target window, allow type window control
if @target_window.active == false
if Input.trigger?(Input::RIGHT) or Input.trigger?(Input::LEFT) or
Input.press?(Input::RIGHT) or Input.press?(Input::LEFT)
@weapon_window.x = 640
@armor_window.x = 640
@item_window.x = 640
@item2_window.x = 640
@weapon_window.contents_opacity = 0
@armor_window.contents_opacity = 0
@item_window.contents_opacity = 0
@item2_window.contents_opacity = 0
end
if Input.trigger?(Input.dir4) or Input.trigger?(Input.dir4) or
Input.trigger?(Input::L) or Input.trigger?(Input::R)
@help_window.x = -200
@help_window.contents_opacity = 0
end
end
# Perform minor background animation (scroll the background 1px right)
@back.ox += 1
# Update the windows
@help_window.update
@item_window.update
@item2_window.update
@weapon_window.update
@armor_window.update
@target_window.update
@type.update
# Branch on window-type
case @type.index
when 0 # Normal ITEM window
@item_com.bitmap = RPG::Cache.picture("Item_com01")
if @target_window.active == true
update_target
@item_window.active = false
@type.active = false
return
else
@item_window.active = true
@type.active = true
end
@weapon_window.active = false
@armor_window.active = false
@item2_window.active = false
@item_window.visible = true
@weapon_window.visible = false
@armor_window.visible = false
@item2_window.visible = false
when 1 # New Weapon window
@item_com.bitmap = RPG::Cache.picture("Item_com02")
@item_window.active = false
@weapon_window.active = true
@armor_window.active = false
@item2_window.active = false
@item_window.visible = false
@weapon_window.visible = true
@armor_window.visible = false
@item2_window.visible = false
when 2 # New Armor window
@item_com.bitmap = RPG::Cache.picture("Item_com03")
@item_window.active = false
@weapon_window.active = false
@armor_window.active = true
@item2_window.active = false
@item_window.visible = false
@weapon_window.visible = false
@armor_window.visible = true
@item2_window.visible = false
when 3 # Extra Items window
@item_com.bitmap = RPG::Cache.picture("Item_com04")
if @target_window.active == true
update_target
@item2_window.active = false
@type.active = false
return
else
@item2_window.active = true
@type.active = true
end
@item_window.active = false
@weapon_window.active = false
@armor_window.active = false
@item_window.visible = false
@weapon_window.visible = false
@armor_window.visible = false
@item2_window.visible = true
end
# Update the appropriate window if active, and exit method
return update_item if @item_window.active
return update_weapon if @weapon_window.active
return update_armor if @armor_window.active
return update_item2 if @item2_window.active
end
#--------------------------------------------------------------------------
# * Frame Update (when special item window is active)
#--------------------------------------------------------------------------
def update_item2
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Menu.new(0)
return
end
if Input.trigger?(Input::C)
@item = @item_window.item
unless @item.is_a?(RPG::Item)
$game_system.se_play($data_system.buzzer_se)
return
end
unless $game_party.item_can_use?(@item.id)
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
if @item.scope >= 3
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 1 * 304
@target_window.active = true
@target_window.x = -350
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
else
if @item.common_event_id > 0
$game_temp.common_event_id = @item.common_event_id
$game_system.se_play(@item.menu_se)
if @item.consumable
$game_party.lose_item(@item.id, 1)
@item_window.draw_item(@item_window.index)
end
$scene = Scene_Map.new
return
end
end
return
end
end
end
Remember, you now need to redo your graphics showing "ITEM / WEAPON / ARMOR" to now be "ITEM / WEAPON / ARMOR / MISC"