XP 스크립트



#==============================================================================
# Item Inventory
#--------------------------------------------------------------------------
# Created By SephirothSpawn (12.02.05)
# Last Updated: 12.03.05
# Updated: Added Icons and Numbers to Windows
#==============================================================================

#==============================================================================
# ** Window_RefreshCommand
#==============================================================================
class Window_RefreshCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width, commands)
# Compute window height from command quantity
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh(commands = @commands)
@commands = commands
@item_max = commands.size
if self.contents != nil
self.contents.dispose
self.contents = nil
end
self.contents = Bitmap.new(width - 32, @item_max * 32)
for i in 0...@item_max
draw_item(i, normal_color)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
item = @commands[index]
if item.is_a?(RPG::Item) || item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)
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
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(4, 32 * index + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(32, 32 * index, self.contents.width - 8, 32, item.name)
self.contents.draw_text(4, 32 * index, self.contents.width - 8, 32, number.to_s, 2)
else
self.contents.draw_text(0, 32 * index, self.contents.width - 8, 32, item, 1)
end
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end

#==============================================================================
# ** Game_Party
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :items
attr_accessor :weapons
attr_accessor :armors
attr_accessor :inventory_items
#--------------------------------------------------------------------------
# * Alias Initialization
#--------------------------------------------------------------------------
alias inventory_int initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
inventory_int
@inventory_items = []
end
#--------------------------------------------------------------------------
# * Move to Inventory
#--------------------------------------------------------------------------
def move_to_inventory(type, item_id)
case type
when 0
@inventory_items.push($data_items[item_id])
lose_item(item_id, 1)
when 1
@inventory_items.push($data_weapons[item_id])
lose_weapon(item_id, 1)
when 2
@inventory_items.push($data_armors[item_id])
lose_armor(item_id, 1)
end
update_inventory
end
#--------------------------------------------------------------------------
# * Remove from Inventory
#--------------------------------------------------------------------------
def remove_from_inventory(index)
item = @inventory_items[index]
@inventory_items.delete_at(index)
case item
when RPG::Item
gain_item(item.id, 1)
when RPG::Weapon
gain_weapon(item.id, 1)
when RPG::Armor
gain_armor(item.id, 1)
end
update_inventory
end
#--------------------------------------------------------------------------
# * Update Inventory
#--------------------------------------------------------------------------
def update_inventory
items, weapons, armors = [], [], []
for item in @inventory_items
case item
when RPG::Item
items.push(item)
when RPG::Weapon
weapons.push(item)
when RPG::Armor
armors.push(item)
end
end
items.sort! {|a, b| a.id<=>b.id}
weapons.sort! {|a, b| a.id<=>b.id}
armors.sort! {|a, b| a.id<=>b.id}
@inventory_items.clear
@inventory_items << items << weapons << armors
@inventory_items.flatten!
end
end

#==============================================================================
# ** Scene_Inventory_Items
#==============================================================================
class Scene_Inventory_Items
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make sprite set
@spriteset = Spriteset_Map.new
# Help Window
@help_window = Window_Help.new
@help_window.set_text("Select Item to Transfer", 1)
@help_window.opacity = 175
# Items Window
@items_window = Window_RefreshCommand.new(272, get_item_commands)
@items_window.x, @items_window.y = 32, 80
@items_window.opacity = 175
@items_window.height = 384
# Inventory Window
@inventory_window = Window_RefreshCommand.new(272, get_inventory_commands)
@inventory_window.x, @inventory_window.y = 336, 80
@inventory_window.opacity = 175
@inventory_window.height = 384
@inventory_window.active = false
# Scene Objects
@objects = [@spriteset, @help_window, @items_window, @inventory_window]
@cmd_windows = [@items_window, @inventory_window]
# Transition run
Graphics.transition
# Main loop
while $scene == self
# Update game screen
Graphics.update
# Update input information
Input.update
# Updates Objects
@objects.each {|x| x.update unless x == @items_window || x == @inventory_window}
@cmd_windows.each {|x| x.update if x.active}
# Frame update
update
end
# Prepare for transition
Graphics.freeze
# Disposes Objects
@objects.each {|x| x.dispose}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Updates Help Window
if @items_window.active
@help_window.set_text("Select Item to Transfer", 1)
else
@help_window.set_text("Select Item to Withdraw", 1)
end
# Return to Map
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
elsif Input.trigger?(Input::L) || Input.trigger?(Input::R) ||
Input.trigger?(Input::LEFT) || Input.trigger?(Input::RIGHT)
@items_window.active = @items_window.active ? false : true
@inventory_window.active = @inventory_window.active ? false : true
elsif Input.trigger?(Input::C)
if @items_window.active
item = @commands[@items_window.index]
if item == "Back"
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
else
$game_system.se_play($data_system.decision_se)
case item
when RPG::Item
type = 0
when RPG::Weapon
type = 1
else
type = 2
end
$game_party.move_to_inventory(type, item.id)
@items_window.refresh(get_item_commands)
@inventory_window.refresh(get_inventory_commands)
end
else
if @inventory_window.index == @inventory_size - 1
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Map.new
else
$game_party.remove_from_inventory(@inventory_window.index)
@items_window.refresh(get_item_commands)
@inventory_window.refresh(get_inventory_commands)
end
end
end
end
#--------------------------------------------------------------------------
# * Get Item Commands
#--------------------------------------------------------------------------
def get_item_commands
# Commands For Selecting
@commands = []
$game_party.items.each_key {|item| $game_party.items[item].times {@commands.push($data_items[item])}}
$game_party.weapons.each_key {|item| $game_party.weapons[item].times {@commands.push($data_weapons[item])}}
$game_party.armors.each_key {|item| $game_party.armors[item].times {@commands.push($data_armors[item])}}
@commands.push("Back")
return @commands
end
#--------------------------------------------------------------------------
# * Get Inventory Commands
#--------------------------------------------------------------------------
def get_inventory_commands
commands = []
$game_party.inventory_items.each {|item| commands.push(item)}
commands.push("Back")
@inventory_size = commands.size
return commands
end
end


사용법

$scene = Scene_Inventory_Items.new

출저:RMXP.net

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '1'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
881 전투 펫 시스템(ABS 3.4v포함) 23 file 백호 2009.02.22 3458
880 메뉴 자작 메뉴 스크립트들(L's Simple CMS and menu scenes) (SDK 호환?) 10 Alkaid 2010.09.02 3455
879 미니맵 스크립트 이용하여 미니맵 만들기 16 file 아방스 2007.11.09 3451
878 전투 CTB by Charlie Fleed 3.2 - FF10 스타일의 전투 시스템 7 Alkaid 2010.10.14 3447
877 능력치 올리기 스크립트 21 file 아방스 2007.11.09 3447
876 미니맵 던전용 미니맵 스크립트[사용법 추가] 16 file 배포 2008.03.02 3443
875 이동 및 탈것 3D 캐릭 스크립트 7 백호 2009.02.22 3442
874 HUD 맵이름표시 ps인간 2009.01.23 3441
873 미니맵 미니맵(중복률100%? 한글번역!) 17 백호 2009.02.21 3423
872 메시지 ◆메세지 윈도우 개조 -KGC_MessageAlter◆ 3 백호 2009.02.22 3422
871 기타 FPLE 2 - First Person Labyrinth Explorer by MGC 1 Alkaid 2012.01.17 3415
870 이동 및 탈것 멈췄을때 행동. 17 file Bera 2010.10.17 3408
869 메뉴 스탯올리기 시스템 (액알가능) 27 file 백호 2009.02.22 3403
868 기타 한글 입력 스크립트 입니다. (vx -> xp) 23 file 헤르코스 2009.04.18 3396
867 메뉴 [자작]명성치 사용 스크립트 16 Rainsy 2009.03.22 3390
866 전투 ATB전투 5 백호 2009.02.22 3369
865 파티 [최강전사님 제공] 파티가 따라오게 하는 스크립트 24 file 아방스 2007.11.09 3365
» 아이템 아이템 인벤토리 2 file 백호 2009.02.22 3354
863 이동 및 탈것 최단경로 찾아가기 - (마우스 사용) 18 file 허걱 2009.02.02 3351
862 스탯 포인트 시스템 3차수정 ( ' 백호 ' 님이 올리신 자료 수정.) 26 카이어덱터 2010.01.04 3344
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52