아이템 화면 확장(수동에서도Ver) RGSS2 DAIpage v2.3
● 기능과 사용법
· 디폴트로 정의되었던 아이템의 정보를 수정합니다.
이 스크립트를 쓰면, 아이템을 드랍한 순서로 정렬합니다.
·아이템을 정렬할 수도 있습니다.
아이템 화면에서 취소 버튼을 누르면 커멘드 윈도우 커멘드가 실행하게되고, 아이템 일람, 정돈
을 할 수 있는 커멘드 윈도우가 액티브 상태 설정되며, 한번 더 누르면 메뉴로 돌아오게됩니다.
·소트 기능은 아이템을 무기, 방어구, 장식품 순서로 정렬되며,
게임중에 언제라도 실행할 수 있습니다.
● 스크립트 삽입 부분
Scene_Item,Game_Party 보다 상단에 놓아두십시요.
Game_Temp에 한번더 선언을하게됩니다.
(중간에 게임 템프에 추가해야할 인스턴스 변수가 있습니다. 주의하세요)
● 스크립트
#==============================================================================
# ■ 커스터마이즈 항목
#==============================================================================
module DAI_ITEM
# 귀중품 판별 문자열(메모란에 이 문자열이 있으면 귀중품)
VAl = "중요한 것"
# 소지 아이템 일람을 나타내는 커멘드명과 헬프에 표시하는 텍스트
C_1 = "아이템"
C_1_H = "소지하고 있는 아이템의 일람입니다."
# 늘어놓아 바꾸어를 나타내는 커멘드명과 헬프에 표시하는 텍스트
C_2 = "정돈"
C_2_H = "소지하고 있는 아이템을 늘어놓아 바꿉니다."
# 귀중품을 나타내는 커멘드명과 헬프에 표시하는 텍스트
C_3 = "중요한 것"
C_3_H = "귀중품의 일람입니다."
# 아이템 우선 소트의 커멘드명과 헬프에 표시하는 텍스트
S_1 = "아이템 우선"
S_1_H = "아이템 우선으로 나란해질 수 있는 바꾸어를 합니다."
# 무기 우선 소트의 커멘드명과 헬프에 표시하는 텍스트
S_2 = "무기를 우선"
S_2_H = "무기 우선으로 나란해질 수 있는 바꾸어를 합니다."
# 방어구 우선 소트의 커멘드명과 헬프에 표시하는 텍스트
S_3 = "방어구를 우선"
S_3_H = "방어구 우선으로 나란해질 수 있는 바꾸어를 합니다."
# 오십음순서 소트의 커멘드명과 헬프에 표시하는 텍스트
S_4 = "오십음순서"
S_4_H = "오십음순서에 늘어놓아 바꾸어를 합니다."
end
module INDEX_2
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
def initialize(x, y, w, h)
super(x, y, w, h)
@index_2_window = Window_Selectable.new(self.x, self.y, self.width, self.height)
@index_2_window.opacity, @index_2_window.active = 0, false
@index_2_window.contents_opacity = 180
@index_2_window.index = -1
end
#--------------------------------------------------------------------------
# ● 커서 위치의 취득
#--------------------------------------------------------------------------
def index_2
return @index_2_window.index
end
#--------------------------------------------------------------------------
# ● 커서 배치
#--------------------------------------------------------------------------
def index_2=(index)
@index_2_window.index = index
if index == -1
@index_2_window.cursor_rect.empty
else
@index_2_window.x, @index_2_window.y = self.x, self.y
@index_2_window.cursor_rect = self.cursor_rect
end
end
#--------------------------------------------------------------------------
# ● 선두의 행의 설정
#--------------------------------------------------------------------------
def top_row=(row)
super
oy = @index_2_window.oy
@index_2_window.oy = self.oy
@index_2_window.cursor_rect.y -= self.oy - oy
end
#--------------------------------------------------------------------------
# ● 해방
#--------------------------------------------------------------------------
def dispose
@index_2_window.dispose
super
end
#--------------------------------------------------------------------------
# ● X좌표
#--------------------------------------------------------------------------
def x=(n)
super
@index_2_window.x = self.x unless @index_2_window.nil?
end
#--------------------------------------------------------------------------
# ● Y좌표
#--------------------------------------------------------------------------
def y=(n)
super
@index_2_window.y = self.y unless @index_2_window.nil?
end
#--------------------------------------------------------------------------
# ● 가시 상태
#--------------------------------------------------------------------------
def visible=(b)
@index_2_window.visible = b
super
end
end
#==============================================================================
# ■ Game_Temp
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# ● 공개 인스턴스 변수
#--------------------------------------------------------------------------
attr_accessor:dai_items_sort_type
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias dai_item_initialize initialize
def initialize
dai_item_initialize
@dai_items_sort_type = 0
end
end
#==============================================================================
# ■ Game_Party
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# ● 공개 인스턴스 변수
#--------------------------------------------------------------------------
attr_reader :all_items
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias dai_item_initialize initialize
def initialize
dai_item_initialize
@all_items = []
@result = []
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 초기화
#--------------------------------------------------------------------------
def items_clear
@result, @all_items = [], []
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 소트 배열 생성
#--------------------------------------------------------------------------
def item_sort
for i in @items.keys.sort
a = $data_items[i]
next if item_number(a) == 0
@all_items.push([0, a.id, item_number(a)]) if item_number(a) > 0
next if a.note.include?(DAI_ITEM::VAl)
@result.push(a)
end
end
#--------------------------------------------------------------------------
# ● 무기 오브젝트의 소트 배열 생성
#--------------------------------------------------------------------------
def weapon_sort
for i in @weapons.keys.sort
a = $data_weapons[i]
next if item_number(a) == 0
@all_items.push([1, a.id, item_number(a)]) if item_number(a) > 0
next if a.note.include?(DAI_ITEM::VAl)
@result.push(a)
end
end
#--------------------------------------------------------------------------
# ● 방어구 오브젝트의 소트 배열 생성
#--------------------------------------------------------------------------
def armor_sort
for kind in 0..3
for i in @armors.keys.sort
a = $data_armors[i]
if @armors[i] > 0 && a.kind == kind
next if item_number(a) == 0
@all_items.push([2, a.id, item_number(a)]) if item_number(a) > 0
next if a.note.include?(DAI_ITEM::VAl)
@result.push(a)
end
end
end
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 취득 (재정의)
#--------------------------------------------------------------------------
def items
return items_0 if $game_temp.dai_items_sort_type == 0
return items_1 if $game_temp.dai_items_sort_type == 1
return items_2 if $game_temp.dai_items_sort_type == 2
return items_3 if $game_temp.dai_items_sort_type == 3
return items_4 if $game_temp.dai_items_sort_type == 4
return items_5 if $game_temp.dai_items_sort_type == 5
end
#--------------------------------------------------------------------------
# ● 전투 테스트용 파티의 셋업
#--------------------------------------------------------------------------
alias dai_item_setup_battle_test_members setup_battle_test_members
def setup_battle_test_members
dai_item_setup_battle_test_members
for i in 1...$data_items.size
a = $data_items[i]
if a.battle_ok?
@all_items.push([0, a.id, 99]) unless a.name.empty?
end
end
end
#--------------------------------------------------------------------------
# ● 기본이 되는 아이템 오브젝트의 배열 취득(이전에 간 소트 + 취득순서)
#--------------------------------------------------------------------------
def items_0
@result = []
return @result if @all_items == []
for i in @all_items
next if i == nil or i[0] == nil or i[1] == nil or i[2] == nil
case i[0]
when 0 ; a = $data_items[i[1]]
when 1 ; a = $data_weapons[i[1]]
when 2 ; a = $data_armors[i[1]]
end
next if a.note.include?(DAI_ITEM::VAl)
@result.push(a) if i[2] >= 1
@all_items.delete(i) if i[2] <= 0
end
return @result
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 취득(아이템 우선)
#--------------------------------------------------------------------------
def items_1
items_clear ; item_sort ; weapon_sort ; armor_sort
return @result
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 취득(무기 우선)
#--------------------------------------------------------------------------
def items_2
items_clear ; weapon_sort ; armor_sort ; item_sort
return @result
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 취득(방어구 우선)
#--------------------------------------------------------------------------
def items_3
items_clear ; armor_sort ; weapon_sort ; item_sort
return @result
end
#--------------------------------------------------------------------------
# ● 아이템 오브젝트의 배열 취득(오십음순서)
#--------------------------------------------------------------------------
def items_4
items_clear ; armor_sort ; weapon_sort ; item_sort
@result.sort!{|a, b| a.name <=> b.name}
@all_items = []
for i in @result
next if i == nil
case i
when RPG::Item ; a, b = 0, item_number($data_items[i.id])
when RPG::Weapon ; a, b = 1, item_number($data_weapons[i.id])
when RPG::Armor ; a, b = 2, item_number($data_armors[i.id])
end
@all_items.push([a, i.id, b])
end
return @result
end
#--------------------------------------------------------------------------
# ● 귀중품의 배열 취득
#--------------------------------------------------------------------------
def items_5
@result = []
for i in @items.keys.sort
a = $data_items[i]
next unless a.note.include?(DAI_ITEM::VAl)
@result.push(a) if item_number(a) > 0
end
for i in @weapons.keys.sort
a = $data_weapons[i]
next unless a.note.include?(DAI_ITEM::VAl)
@result.push(a) if item_number(a) > 0
end
for kind in 0..3
for i in @armors.keys.sort
a = $data_armors[i]
if @armors[i] > 0 && a.kind == kind
next unless a.note.include?(DAI_ITEM::VAl)
@result.push(a) if item_number(a) > 0
end
end
end
return @result
end
#--------------------------------------------------------------------------
# ● 아이템의 증가 (감소)
#--------------------------------------------------------------------------
alias dai_item_gain_item gain_item
def gain_item(item, n, include_equip = false)
dai_item_gain_item(item, n, include_equip)
v_update
case item
when RPG::Item ; a, b = 0, item_number($data_items[item.id])
when RPG::Weapon ; a, b = 1, item_number($data_weapons[item.id])
when RPG::Armor ; a, b = 2, item_number($data_armors[item.id])
end
for i in @all_items
next if i == nil or i[0] == nil or i[1] == nil or i[2] == nil
if i[0] == a && i[1] == item.id
i[2] = b
@all_items.delete(i) if i[2] <= 0
f = true
end
end
@all_items.push [a, item.id, b] unless f
end
#--------------------------------------------------------------------------
# ● 아이템의 소모
#--------------------------------------------------------------------------
alias dai_item_consume_item consume_item
def consume_item(item)
dai_item_consume_item(item)
v_update
a = item_number($data_items[item.id])
if item.is_a?(RPG::Item) and item.consumable
for i in @all_items
next if i == nil
if i[1] == item.id && i[0] == 0
i[2] = a
@all_items.delete(i) if a <= 0
end
end
end
end
#--------------------------------------------------------------------------
# ● 수동에 의한 아이템의 위치 교환
#--------------------------------------------------------------------------
def change_item(item_1,item_2)
a = 0
for i in @all_items
if i == item_1
@all_items[a] = item_2
a += 1
next
end
if i == item_2
@all_items[a] = item_1
a += 1
next
end
a += 1
end
end
#--------------------------------------------------------------------------
# ● 도입전의 데이터 조정
#--------------------------------------------------------------------------
def v_update
items_1 if @all_items == nil or @all_items == []
end
end
#==============================================================================
# ■ Window_Item
#==============================================================================
class Window_Item < Window_Selectable
include INDEX_2
#--------------------------------------------------------------------------
# ● 오브젝트 초기화
#--------------------------------------------------------------------------
alias dai_item_initialize initialize
def initialize(x, y, width, height)
$game_temp.dai_items_sort_type = 0
dai_item_initialize(x, y, width, height)
end
end
#==============================================================================
# ■ Scene_Item
#==============================================================================
class Scene_Item < Scene_Base
#--------------------------------------------------------------------------
# ● 개시 처리(재정의)
#--------------------------------------------------------------------------
def start
super
v_update
$game_temp.dai_items_sort_type = 0
create_menu_background
@viewport = Viewport.new(0, 0, 544, 416)
@help_window = Window_Help.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.index, @item_window.index_2, @item_window.active = 0, -1, false
@target_window = Window_MenuStatus.new(0, 0)
hide_target_window
create_command_window
create_sort_window
@command_index, @sort_index = 0, 0
end
#--------------------------------------------------------------------------
# ● 종료 처리(앨리어스(alias))
#--------------------------------------------------------------------------
alias dai_item_terminate terminate
def terminate
dai_item_terminate
@command_window.dispose
@sort_window.dispose
end
#--------------------------------------------------------------------------
# ● 커멘드 윈도우의 작성
#--------------------------------------------------------------------------
def create_command_window
s = [DAI_ITEM::C_1, DAI_ITEM::C_2, DAI_ITEM::C_3]
@command_window = Window_Command.new(544, s, 3)
@command_window.index = 0
@command_window.y = 56
@command_window.viewport = @viewport
@command_window.active = false
@command_window.contents_opacity = 180
@command_window.refresh
end
#--------------------------------------------------------------------------
# ● 소트 선택 윈도우의 작성
#--------------------------------------------------------------------------
def create_sort_window
s = [DAI_ITEM::S_1, DAI_ITEM::S_2, DAI_ITEM::S_3, DAI_ITEM::S_4]
@sort_window = Window_Command.new(160, s)
@sort_window.index = 0
@sort_window.x = (Graphics.width - @sort_window.width) / 2
@sort_window.y = 112
@sort_window.viewport = @viewport
@sort_window.active, @sort_window.visible = false, false
end
#--------------------------------------------------------------------------
# ● 프레임 갱신(재정의)
#--------------------------------------------------------------------------
def update
super
update_menu_background
@help_window.update
@item_window.update
@target_window.update
@command_window.update
@sort_window.update
if @command_window.active
unless @command_window.index == @command_index
update_help
update_item_window
end
end
if @sort_window.active
update_help unless @sort_window.index == @sort_index
end
if @item_window.active
update_item_selection
elsif @target_window.active
@item_window.index_2 = -1 unless @item_window.index_2 == -1
update_target_selection
elsif @command_window.active
@item_window.index_2 = -1 unless @item_window.index_2 == -1
update_command_selection
elsif @sort_window.active
update_sort_selection
end
end
#--------------------------------------------------------------------------
# ● 아이템 선택의 갱신(재정의)
#--------------------------------------------------------------------------
def update_item_selection
if Input.trigger?(Input::B)
Sound.play_cancel
if @item_window.index_2 == -1
@item_window.active, @item_window.index = false, 0
@command_window.active = true
contents_opacity_c
update_help
else
@item_window.index_2 = -1
end
elsif Input.trigger?(Input::C)
if @item_window.index_2 == -1
Sound.play_decision
@item_window.index_2, @item_2 = @item_window.index, @item_window.item
elsif @item_window.index_2 == @item_window.index
@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
a = @item_window.index
determine_item
@item_window.index, @item_window.index_2 = a, -1
else
Sound.play_buzzer
end
else
Sound.play_decision
item_1, item_2 = item_data(@item_window.item), item_data(@item_2)
$game_party.change_item(item_1,item_2)
@item_window.index_2 = -1
@item_window.refresh
end
end
end
#--------------------------------------------------------------------------
# ● 아이템 정보의 취득
#--------------------------------------------------------------------------
def item_data(item)
case item
when RPG::Item ; a, b = 0, $game_party.item_number($data_items[item.id])
when RPG::Weapon ; a, b = 1, $game_party.item_number($data_weapons[item.id])
when RPG::Armor ; a, b = 2, $game_party.item_number($data_armors[item.id])
end
return [a, item.id, b]
end
#--------------------------------------------------------------------------
# ● 커멘드 선택의 갱신
#--------------------------------------------------------------------------
def update_command_selection
@item_window.index = 0
if Input.trigger?(Input::B)
Sound.play_cancel
return_scene
elsif Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0 ; @item_window.active, @command_window.active = true, false
contents_opacity_c
when 1 ; window_c_s
when 2 ; @item_window.active, @command_window.active = true, false
contents_opacity_c
end
end
end
#--------------------------------------------------------------------------
# ● 소트 선택의 갱신
#--------------------------------------------------------------------------
def update_sort_selection
if Input.trigger?(Input::B)
Sound.play_cancel
window_c_s
update_help
elsif Input.trigger?(Input::C)
Sound.play_decision
case @sort_window.index
when 0 ; $game_temp.dai_items_sort_type = 1
when 1 ; $game_temp.dai_items_sort_type = 2
when 2 ; $game_temp.dai_items_sort_type = 3
when 3 ; $game_temp.dai_items_sort_type = 4
end
contents_opacity_c
update_sort_selection_next
end
end
#--------------------------------------------------------------------------
# ● 윈도우 내용의 투명도 변환
#--------------------------------------------------------------------------
def contents_opacity_c
if @item_window.contents_opacity == 255
@item_window.contents_opacity = 128
@command_window.contents_opacity = 255
else
@item_window.contents_opacity = 255
@command_window.contents_opacity = 180
end
@item_window.refresh
@command_window.refresh
end
#--------------------------------------------------------------------------
# ● 소트 윈도우와 커멘드 윈도우의 변환
#--------------------------------------------------------------------------
def window_c_s
@sort_window.active ^= true
@sort_window.visible ^= true
@command_window.active ^= true
end
#--------------------------------------------------------------------------
# ● 소트 선택 후의 갱신
#--------------------------------------------------------------------------
def update_sort_selection_next
@item_window.refresh
@item_window.index, @item_window.active, @command_window.index = 0, true, 0
@sort_window.active, @sort_window.visible = false, false
$game_temp.dai_items_sort_type = 0
end
#--------------------------------------------------------------------------
# ● 아이템 윈도우의 변환
#--------------------------------------------------------------------------
def update_item_window
@item_window.index = 0
if @command_window.active && @command_window.index == 2
$game_temp.dai_items_sort_type = 5
update_item_window_next
elsif @command_window.active
$game_temp.dai_items_sort_type = 0
update_item_window_next
end
end
#--------------------------------------------------------------------------
# ● 아이템 윈도우의 변환 후의 갱신
#--------------------------------------------------------------------------
def update_item_window_next
@item_window.refresh
@command_index = @command_window.index
end
#--------------------------------------------------------------------------
# ● 타겟의 결정
#--------------------------------------------------------------------------
alias dai_item_determine_target determine_target
def determine_target
@item_window.refresh
dai_item_determine_target
end
#--------------------------------------------------------------------------
# ● 헬프 텍스트 갱신
#--------------------------------------------------------------------------
def update_help
if @command_window.active
case @command_window.index
when 0 ; @help_window.set_text(DAI_ITEM::C_1_H)
when 1 ; @help_window.set_text(DAI_ITEM::C_2_H)
when 2 ; @help_window.set_text(DAI_ITEM::C_3_H)
end
@command_index = @command_window.index
elsif @sort_window.active
case @sort_window.index
when 0 ; @help_window.set_text(DAI_ITEM::S_1_H)
when 1 ; @help_window.set_text(DAI_ITEM::S_2_H)
when 2 ; @help_window.set_text(DAI_ITEM::S_3_H)
when 3 ; @help_window.set_text(DAI_ITEM::S_4_H)
end
@sort_index = @sort_window.index
end
end
#--------------------------------------------------------------------------
# ● 도입전의 데이터 조정
#--------------------------------------------------------------------------
def v_update
if $game_party.all_items == nil or $game_party.all_items == []
$game_party.items_1
end
end
end
ㅇㅂㅇ?머지