12-01-2005, 01:00 PM
(This post was last modified: 07-22-2017, 04:07 AM by DerVVulfman.)
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
:note: Well, you can sort:
- Alphabetically
- By cost
- By Size(read on)
- By weight(read on)
- Show only items
- Show only weapons
- Show only armors
- Show only shields
- Show only helmets
- Show only Accessories
- Show only keyitems(read on)
Interested? Call 1800-JITEM NOW
(j/k)
Here's the script and instructions for installing. It will take A LONG time to set up, ESPECIALLY if you have alot of items, weapons and armors...
So sit back and listen :icon_jook:
Put THESE scripts in new spots above main:
Item METHODS
Code:
class Game_Item
def size(item)
case item
when RPG::Item
for i in 0...SIZES.size
if item.element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
when RPG::Weapon
for i in 0...SIZES.size
if item.element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
when RPG::Armor
for i in 0...SIZES.size
if item.guard_element_set.include?(SIZES[i][2])
return SIZES[i]
end
end
end
return SIZES[DEFAULT[0]]
end
def weight(item)
case item
when RPG::Item
for i in 0...WEIGHTS.size
if item.element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
when RPG::Weapon
for i in 0...WEIGHTS.size
if item.element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
when RPG::Armor
for i in 0...WEIGHTS.size
if item.guard_element_set.include?(WEIGHTS[i][2])
return WEIGHTS[i]
end
end
end
return WEIGHTS[DEFAULT[1]]
end
def keyitem(item)
case item
when RPG::Item
return item.element_set.include?(KEY_ITEM)
when RPG::Weapon
return item.element_set.include?(KEY_ITEM)
when RPG::Armor
return item.guard_element_set.include?(KEY_ITEM)
end
end
end
Constans and Instructions
Code:
#What is this?
#KEY_ITEM
#Any item given this attribute is automatically considered a "Key item" and
#it will be not be shown by selecting the "Key Items" choice, in addition to it's type choice.
#SIZES
#This hash contains a few predefined sizes, to add a size of your own, copy the last one,
#add 1 to the second number(24) and change the name/size(first number) as you want.
#You'll then have to increment all "WEIGHTS" numbers as well.
#the word-->What will be displayed in the "size" box when the item is selected.
#the first number-->How big the item is, 1 is smallest, your imagination chooses the largest...
#the second number-->What attribute will be used for choosing the size of the item.
#This goes for Weights as well, with minor (and obvious) modifications.
KEY_ITEM=17
SIZES=[["Tiny",1,18],["Small",2,19],["Medium",3,20],["Large",4,21],["Very large",6,22],["Huge",9,23],["Gargantuan",15,24]]
WEIGHTS=[["-None-",0,25],["Light",1,26],["Medium",2,27],["Heavy",4,28],["Very heavy",6,29]]
DEFAULT=[2,2]#The default item size and weigth, the 2's are the "medium" choices of both.
Sorting Window
Code:
class Window_ItemSort<Window_Selectable
def initialize
super(0,64,640,64)
self.contents=Bitmap.new(width-32,height-32)
self.contents.font.name="Tahoma"
self.contents.font.size=22
@item_max = 12
@column_max = 12
@index = -1
end
def update
super
self.contents.clear
self.contents.draw_text(16,0,32,32,"Abc",1)
self.contents.draw_text(16+50*1,0,32,32,"$",1)
self.contents.draw_text(16+50*2,0,32,32,"Size")
self.contents.draw_text(16+50*3,0,32,32,"Weight")
bitmap = RPG::Cache.icon("041-Item10")
self.contents.blt(16+50*4, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("001-Weapon01")
self.contents.blt(16+50*5, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("013-Body01")
self.contents.blt(16+50*6, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("009-Shield01")
self.contents.blt(16+50*7, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("010-Head01")
self.contents.blt(16+50*8, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("017-Accessory02")
self.contents.blt(16+50*9, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("037-Item06")
self.contents.blt(16+50*10, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("032-Item01")
self.contents.blt(16+50*11, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
end
def update_cursor_rect
# カーソル位置が 0 未満の場合
if @index < 0
self.cursor_rect.empty
return
end
# 現在の行を取得
row = @index / @column_max
# 現在の行が、表示されている先頭の行より前の場合
if row < self.top_row
# 現在の行が先頭になるようにスクロール
self.top_row = row
end
# 現在の行が、表示されている最後尾の行より後ろの場合
if row > self.top_row + (self.page_row_max - 1)
# 現在の行が最後尾になるようにスクロール
self.top_row = row - (self.page_row_max - 1)
end
# カーソルの幅を計算
cursor_width = (self.width-32) / @column_max
# カーソルの座標を計算
x = @index % @column_max * (cursor_width)+3
y = @index / @column_max * 32 - self.oy
# カーソルの矩形を更新
self.cursor_rect.set(x, y, cursor_width, 32)
end
end
class Window_SortMode<Window_Selectable
def initialize
super(12,128,64,96)
self.contents=Bitmap.new(width-32,height-32)
bitmap = RPG::Cache.icon("048-Skill05")
self.contents.blt(4, 4, bitmap, Rect.new(0, 0, 24, 24), 255)
bitmap = RPG::Cache.icon("047-Skill04")
self.contents.blt(4, 36, bitmap, Rect.new(0, 0, 24, 24), 255)
@item_max=2
@column_max=1
end
end
Then, either replace or, prefferably, add above main, the following scripts:
Scene_Item
Code:
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# アイテム画面の処理を行うクラスです。
#==============================================================================
class Scene_Item
#--------------------------------------------------------------------------
# ● メイン処理
#--------------------------------------------------------------------------
def main
# ヘルプウィンドウ、アイテムウィンドウを作成
@help_window = Window_Help.new
@item_window = Window_Item.new
# ヘルプウィンドウを関連付け
@item_window.help_window = @help_window
# ターゲットウィンドウを作成 (不可視・非アクティブに設定)
@target_window = Window_Target.new
@target_window.visible = false
@target_window.active = false
@target_window.z=120
@command_window=Window_ItemSort.new
@command_window.active=false
@command_window.index=0
@sort_window=Window_SortMode.new
@sort_window.z=110
@sort_window.active=false
@sort_window.visible=false
@sort_window.index=0
@item_window.active=true
# トランジション実行
Graphics.transition
# メインループ
loop do
# ゲーム画面を更新
Graphics.update
# 入力情報を更新
Input.update
# フレーム更新
update
# 画面が切り替わったらループを中断
if $scene != self
break
end
end
# トランジション準備
Graphics.freeze
# ウィンドウを解放
@help_window.dispose
@item_window.dispose
@target_window.dispose
@command_window.dispose
@sort_window.dispose
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
# ウィンドウを更新
@help_window.update
@item_window.update
@target_window.update
@command_window.update
@sort_window.update
# アイテムウィンドウがアクティブの場合: update_item を呼ぶ
if @command_window.active
update_sort
return
end
if @item_window.active
update_item
return
end
# ターゲットウィンドウがアクティブの場合: update_target を呼ぶ
if @target_window.active
update_target
return
end
end
#--------------------------------------------------------------------------
# ● フレーム更新 (アイテムウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_sort
case @command_window.index
when 0
@sort_window.visible=true
@sort_window.active=true
@sort_window.x=12
when 1
@sort_window.visible=true
@sort_window.active=true
@sort_window.x=62
when 2
@sort_window.visible=true
@sort_window.active=true
@sort_window.x=112
when 3
@sort_window.visible=true
@sort_window.active=true
@sort_window.x=162
else
@sort_window.visible=false
@sort_window.active=false
end
if Input.trigger?(Input::A)
$game_system.se_play($data_system.buzzer_se)
@item_window.active=true
@sort_window.active=false
@sort_window.visible=false
@command_window.active=false
return
end
if Input.trigger?(Input::B)
$game_system.se_play($data_system.buzzer_se)
@item_window.active=true
@sort_window.active=false
@sort_window.visible=false
@command_window.active=false
return
end
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
$sort=@command_window.index
$method=@sort_window.index
@item_window.index=0
@item_window.update
@item_window.refresh
end
end
def update_item
if Input.trigger?(Input::A)
@command_window.active=true
@item_window.active=false
$game_system.se_play($data_system.decision_se)
return
end
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# メニュー画面に切り替え
$scene = Scene_Menu.new(0)
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムウィンドウで現在選択されているデータを取得
@item = @item_window.item
# 使用アイテムではない場合
unless @item.is_a?(RPG::Item)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 使用できない場合
unless $game_party.item_can_use?(@item.id)
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# 効果範囲が味方の場合
if @item.scope >= 3
# ターゲットウィンドウをアクティブ化
@item_window.active = false
@target_window.x = (@item_window.index + 1) % 2 * 304
@target_window.visible = true
@target_window.active = true
# 効果範囲 (単体/全体) に応じてカーソル位置を設定
if @item.scope == 4 || @item.scope == 6
@target_window.index = -1
else
@target_window.index = 0
end
# 効果範囲が味方以外の場合
else
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$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
#--------------------------------------------------------------------------
# ● フレーム更新 (ターゲットウィンドウがアクティブの場合)
#--------------------------------------------------------------------------
def update_target
# B ボタンが押された場合
if Input.trigger?(Input::B)
# キャンセル SE を演奏
$game_system.se_play($data_system.cancel_se)
# アイテム切れなどで使用できなくなった場合
unless $game_party.item_can_use?(@item.id)
# アイテムウィンドウの内容を再作成
@item_window.refresh
end
# ターゲットウィンドウを消去
@item_window.active = true
@target_window.visible = false
@target_window.active = false
return
end
# C ボタンが押された場合
if Input.trigger?(Input::C)
# アイテムを使い切った場合
if $game_party.item_number(@item.id) == 0
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
return
end
# ターゲットが全体の場合
if @target_window.index == -1
# パーティ全体にアイテムの使用効果を適用
used = false
for i in $game_party.actors
used |= i.item_effect(@item)
end
end
# ターゲットが単体の場合
if @target_window.index >= 0
# ターゲットのアクターにアイテムの使用効果を適用
target = $game_party.actors[@target_window.index]
used = target.item_effect(@item)
end
# アイテムを使った場合
if used
# アイテムの使用時 SE を演奏
$game_system.se_play(@item.menu_se)
# 消耗品の場合
if @item.consumable
# 使用したアイテムを 1 減らす
$game_party.lose_item(@item.id, 1)
# アイテムウィンドウの項目を再描画
@item_window.draw_item(@item_window.index)
end
# ターゲットウィンドウの内容を再作成
@target_window.refresh
# 全滅の場合
if $game_party.all_dead?
# ゲームオーバー画面に切り替え
$scene = Scene_Gameover.new
return
end
# コモンイベント ID が有効の場合
if @item.common_event_id > 0
# コモンイベント呼び出し予約
$game_temp.common_event_id = @item.common_event_id
# マップ画面に切り替え
$scene = Scene_Map.new
return
end
end
# アイテムを使わなかった場合
unless used
# ブザー SE を演奏
$game_system.se_play($data_system.buzzer_se)
end
return
end
end
end
Window_Item
Code:
#==============================================================================
# ■ Window_Item
#------------------------------------------------------------------------------
# アイテム画面、バトル画面で、所持アイテムの一覧を表示するウィンドウです。
#==============================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 352)
@column_max = 2
refresh
self.index = 0
# 戦闘中の場合はウィンドウを画面中央へ移動し、半透明にする
if $game_temp.in_battle
self.y = 64
self.height = 256
self.back_opacity = 160
end
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
return @data[self.index]
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def reset
@data=[]
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
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
return
end
def refresh
if self.contents != nil
self.contents.dispose
self.contents = nil
end
if @datt != nil
@data=@datt
else
@data=[]
# アイテムを追加
for i in 1...$data_items.size
if $game_party.item_number(i) > 0
@data.push($data_items[i])
end
end
# 戦闘中以外なら武器と防具も追加
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
# 項目数が 0 でなければビットマップを作成し、全項目を描画
case $sort
when 0#alphabetical
case $method
when 0
@data.sort!{|a,b|a.name<=>b.name}
when 1
@data.sort!{|a,b|b.name<=>a.name}
end
when 1#costwise
case $method
when 0
@data.sort!{|a,b|a.price<=>b.price}
when 1
@data.sort!{|a,b|b.price<=>a.price}
end
when 2#sizewise
case $method
when 0
@data.sort!{|a,b|$game_item.size(a)[1]<=>$game_item.size(b)[1]}
when 1
@data.sort!{|a,b|$game_item.size(b)[1]<=>$game_item.size(a)[1]}
end
when 3#weightwise
case $method
when 0
@data.sort!{|a,b|$game_item.weight(a)[1]<=>$game_item.weight(b)[1]}
when 1
@data.sort!{|a,b|$game_item.weight(b)[1]<=>$game_item.weight(a)[1]}
end
when 4#Items ONLY
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Item)}
@data=@data2
@datt=@data
when 5#Weapons ONLY
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Weapon)}
@data=@data2
@datt=@data
when 6#Armor only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==2}
@data=@data2
end
@datt=@data
when 7#shield only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==0}
@data=@data2
end
@datt=@data
when 8#helmet only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==1}
@data=@data2
end
@datt=@data
when 9#acc only
reset
@data2=[]
@data.each{|a|@data2.push(a) if a.is_a?(RPG::Armor)}
@data=@data2
@data2=[]
if @data.size>0
@data.each{|a|@data2.push(a) if a.kind==3}
@data=@data2
end
@datt=@data
when 10#Keyitems
reset
@data2=[]
@data.each{|a|@data2.push(a) if $game_item.keyitem(a)}
@data=@data2
@datt=@data
when 11
reset
end
@item_max = @data.size
if @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = $defaultfonttype # "Items" window font
self.contents.font.size = $defaultfontsize
for i in 0...@item_max
draw_item(i)
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
# index : 項目番号
#--------------------------------------------------------------------------
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
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
end
end
Well, done... NOT :icon_fU:
If you want a "lighter" version that doesn't take as long to setup, scroll down a bit. You still have to start the game with the call script, but the only dtabase work needed is for keyitems.
UPDATE:
Fixed the glitch with the cursor staying in position even if there isn't an item there after sorting, just copy Scene_Item again. Some unneccesary methods in Item METHODS were removed as well.