Final Fantasy Styled Scene ItemAuthor: Jens of Zanicuud
Version: 1.0
Released on: 15 Dec 2011
Terms of use: Free use, just credit; for commercial use, you have to ask for permission.
Customization: Free, just link the mod version in this topic...
FAQ or help: Feel free to ask for everything.
Installation: Just insert the script in a blank above Main.
Hi everyone again,
this time I have a two-scripts update. One is this Final Fantasy Styled Item Window, which subdivides items into:
-Items;
-Weapons&Armors;
-Key ItemsKey Items can be set through the array with the same name.
Is actually easy to use (or at least, I think so, if it isn't, feel free to complain anytime)...
So, here's the script...
CODE
#==============================================================================
# ** Final Fantasy-styled item window
# -by Jens of Zanicuud, version 1.0
# -free use for non commercial use, just credit.
# -you can find me on www.rpgrevolution.com
#==============================================================================
# ** Window_Item
#------------------------------------------------------------------------------
# This window displays items in possession on the item and battle screens.
#==============================================================================
KEY_ITEMS = [24,6] #Key items list (for example, item n°24 and 6 are set as key items)
ITEMS_STRING = "Items" #Ordinary items string
WEAPONS_ARMORS_STRING = "Weapons and Armors" #Weapons and Armors string
KEY_ITEMS_STRING = "Key Items" #Key Items string
ITEM_WIN_COMMANDS = [ #Complessive array
ITEMS_STRING,
WEAPONS_ARMORS_STRING,
KEY_ITEMS_STRING
]
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(key_items = 0)
super(0, 128, 640, 352)
@column_max = 2
@key_items = key_items
refresh
self.index = 0
# If in battle, move window to center of screen
# and make it semi-transparent
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# * Get Item
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
@data = []
# Add item
if @key_items == 2
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and KEY_ITEMS.include?(i)
@data.push($data_items[i])
end
end
elsif @key_items == 0
for i in 1...$data_items.size
if $game_party.item_number(i) > 0 and
(($game_temp.in_battle and
($data_items[i].occasion == 0 or $data_items[i].occasion == 1)) or
!$game_temp.in_battle) and !KEY_ITEMS.include?(i)
@data.push($data_items[i])
end
end
# Also add weapons and items if outside of battle
elsif @key_items == 1
unless $game_temp.in_battle
for i in 1...$data_weapons.size
if $game_party.weapon_number(i) > 0
@data.push($data_weapons[i])
end
end
for i in 1...$data_armors.size
if $game_party.armor_number(i) > 0
@data.push($data_armors[i])
end
end
end
end
@data.sort! do |a, b|
if a.is_a?(RPG::Item) and !b.is_a?(RPG::Item)
-1
elsif !a.is_a?(RPG::Item) and b.is_a?(RPG::Item)
+1
elsif a.is_a?(RPG::Item) and b.is_a?(RPG::Item) and
(a.occasion == 2 or a.occasion == 0) and (b.occasion == 1 or b.occasion == 3)
-1
elsif a.is_a?(RPG::Item) and b.is_a?(RPG::Item) and
(b.occasion == 2 or b.occasion == 0) and (a.occasion == 1 or a.occasion == 3)
+1
elsif a.is_a?(RPG::Item) and b.is_a?(RPG::Item) and
a.occasion == 1 and b.occasion == 3
-1
elsif a.is_a?(RPG::Item) and b.is_a?(RPG::Item) and
a.occasion == 3 and b.occasion == 1
+1
elsif a.id < b.id
-1
elsif a.id > b.id
+1
end
end
# If item count is not 0, make a bit map and draw all items
@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)
when RPG::Weapon
number = $game_party.weapon_number(item.id)
when RPG::Armor
number = $game_party.armor_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 % 2 * (288 + 32)
y = index / 2 * 32
rect = Rect.new(x, y, self.width / @column_max - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
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, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
end
#--------------------------------------------------------------------------
# * Help Text Update
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
#==============================================================================
# ■ Window_ItemCommand
#------------------------------------------------------------------------------
# バトル画面で、戦うか逃げるかを選択するウィンドウで
。
#==============================================================================
class Window_ItemCommand < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 64, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.size = 24
self.back_opacity = 160
@commands = ITEM_WIN_COMMANDS
@item_max = 3
@column_max = 3
draw_item(0, normal_color)
draw_item(1, normal_color)
draw_item(2, normal_color)
self.active = false
self.visible = true
self.index = 0
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
# color : 文字色
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(80 + index * 160 + 4, 0, 128 - 10, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index], 1)
end
#--------------------------------------------------------------------------
# ● カーソルの矩形更新
#--------------------------------------------------------------------------
def update_cursor_rect
self.cursor_rect.set(80 + index * 160, 0, 128, 32)
end
end
#==============================================================================
# ** Scene_Item
#------------------------------------------------------------------------------
# This class performs item screen processing.
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make help window, item window
@help_window = Window_Help.new
@com_window = Window_ItemCommand.new
@item_window = Window_Item.new(0)
@key_window = Window_Item.new(2)
@battle_window = Window_Item.new(1)
@com_window.active = false
@com_window.index = 0
@key_window.visible = false
@key_window.active = false
@battle_window.visible = false
@battle_window.active = false
# Associate help window
@item_window.help_window = @help_window
@key_window.help_window = @help_window
@battle_window.help_window = @help_window
# Make target window (set ito invisible / inactive)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@help_window.dispose
@item_window.dispose
@target_window.dispose
@key_window.dispose
@battle_window.dispose
@com_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@help_window.update
@item_window.update
@target_window.update
@key_window.update
@battle_window.update
@com_window.update
# If item window is active: call update_item
if @item_window.active
update_item(@item_window)
return
end
if @key_window.active
update_item(@key_window)
return
end
if @battle_window.active
update_item(@battle_window)
return
end
if @com_window.active
update_command
return
end
# If target window is active: call update_target
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_item(window)
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
@help_window.set_text("")
@com_window.active = true
window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
@item = window.item
# If not a use item
unless @item.is_a?(RPG::Item)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If it can't be used
unless $game_party.item_can_use?(@item.id)
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# If effect scope is an ally
if @item.scope >= 3
# Activate target window
window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# Set cursor position to effect scope (single / all)
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# If effect scope is other than an ally
else
# If command event ID is valid
if @item.common_event_id > 0
# Command event call reservation
$game_temp.common_event_id = @item.common_event_id
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Draw item window item
window.draw_item(@item_window.index)
end
# Switch to map screen
$scene = Scene_Map.new
return
end
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when item window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
case @com_window.index
when 0
@item_window.index = 0
@item_window.active = false
@item_window.visible = true
@battle_window.active = false
@battle_window.visible = false
@key_window.active = false
@key_window.visible = false
when 1
@battle_window.index = 0
@battle_window.active = false
@battle_window.visible = true
@key_window.active = false
@key_window.visible = false
@item_window.active = false
@item_window.visible = false
when 2
@key_window.index = 0
@key_window.active = false
@key_window.visible = true
@battle_window.active = false
@battle_window.visible = false
@item_window.active = false
@item_window.visible = false
end
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to menu screen
$scene = Scene_Menu.new(0)
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Get currently selected data on the item window
$game_system.se_play($data_system.decision_se)
@com_window.active = false
case @com_window.index
when 0
@item_window.index = 0
@item_window.active = true
@item_window.visible = true
@battle_window.active = false
@battle_window.visible = false
@key_window.active = false
@key_window.visible = false
when 1
@battle_window.index = 0
@battle_window.active = true
@battle_window.visible = true
@key_window.active = false
@key_window.visible = false
@item_window.active = false
@item_window.visible = false
when 2
@key_window.index = 0
@key_window.active = true
@key_window.visible = true
@battle_window.active = false
@battle_window.visible = false
@item_window.active = false
@item_window.visible = false
return
end
end
end
#--------------------------------------------------------------------------
# * Frame Update (when target window is active)
#--------------------------------------------------------------------------
def update_target
# If B button was pressed
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)
# Remake item window contents
@item_window.refresh
end
# Erase target window
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If items are used up
if $game_party.item_number(@item.id) == 0
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# If target is all
if @target_window.index == -1
# Apply item effects to entire party
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# If single target
if @target_window.index >= 0
# Apply item use effects to target actor
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# If an item was used
if used
# Play item use SE
$game_system.se_play(@item.menu_se)
# If consumable
if @item.consumable
# Decrease used items by 1
$game_party.lose_item(@item.id, 1)
# Redraw item window item
@item_window.draw_item(@item_window.index)
end
# Remake target window contents
@target_window.refresh
# If all party members are dead
if $game_party.all_dead?
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If common event ID is valid
if @item.common_event_id > 0
# Common event call reservation
$game_temp.common_event_id = @item.common_event_id
# Switch to map screen
$scene = Scene_Map.new
return
end
end
# If item wasn't used
unless used
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
I hope this can help...
Jens