module WD_itemsynthesis
def i_recipe_switch_on(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
$game_system.i_rcp_sw[id] = true
end
def i_recipe_switch_off(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
$game_system.i_rcp_sw[id] = false
end
def i_recipe_switch_on?(id)
$game_system.i_rcp_sw = [] if $game_system.i_rcp_sw == nil
$game_system.i_rcp_sw[id] = false if $game_system.i_rcp_sw[id] == nil
return $game_system.i_rcp_sw[id]
end
def i_recipe_all_switch_on
for i in 1..$data_items.size
i_recipe_switch_on(i)
end
end
def i_recipe_all_switch_off
for i in 1..$data_items.size
i_recipe_switch_off(i)
end
end
def w_recipe_switch_on(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
$game_system.w_rcp_sw[id] = true
end
def w_recipe_switch_off(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
$game_system.w_rcp_sw[id] = false
end
def w_recipe_switch_on?(id)
$game_system.w_rcp_sw = [] if $game_system.w_rcp_sw == nil
$game_system.w_rcp_sw[id] = false if $game_system.w_rcp_sw[id] == nil
return $game_system.w_rcp_sw[id]
end
def w_recipe_all_switch_on
for i in 1..$data_weapons.size
w_recipe_switch_on(i)
end
end
def w_recipe_all_switch_off
for i in 1..$data_weapons.size
w_recipe_switch_off(i)
end
end
def a_recipe_switch_on(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
$game_system.a_rcp_sw[id] = true
end
def a_recipe_switch_off(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
$game_system.a_rcp_sw[id] = false
end
def a_recipe_switch_on?(id)
$game_system.a_rcp_sw = [] if $game_system.a_rcp_sw == nil
$game_system.a_rcp_sw[id] = false if $game_system.a_rcp_sw[id] == nil
return $game_system.a_rcp_sw[id]
end
def a_recipe_all_switch_on
for i in 1..$data_armors.size
a_recipe_switch_on(i)
end
end
def a_recipe_all_switch_off
for i in 1..$data_armors.size
a_recipe_switch_off(i)
end
end
def recipe_all_switch_on
i_recipe_all_switch_on
w_recipe_all_switch_on
a_recipe_all_switch_on
end
def recipe_all_switch_off
i_recipe_all_switch_off
w_recipe_all_switch_off
a_recipe_all_switch_off
end
end
class Game_Interpreter
include WD_itemsynthesis
end
class Game_System
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :i_rcp_sw
attr_accessor :w_rcp_sw
attr_accessor :a_rcp_sw
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias wd_orig_initialize004 initialize
def initialize
wd_orig_initialize004
@i_rcp_sw = []
@w_rcp_sw = []
@a_rcp_sw = []
end
end
@recipe = @list_window.recipe(@item)
for i in [email protected]
kind = @recipe[0]
id = @recipe[1]
num = @recipe[2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
$game_party.lose_item(item, num*number)
end
end
#--------------------------------------------------------------------------
# ● 個数入力の終了
#--------------------------------------------------------------------------
def end_number_input
@number_window.hide
activate_list_window
end
#--------------------------------------------------------------------------
# ● 最大購入可能個数の取得
#--------------------------------------------------------------------------
def max_buy
max = $game_party.max_item_number(@item) - $game_party.item_number(@item)
@recipe = @list_window.recipe(@item)
for i in [email protected]
kind = @recipe[0]
id = @recipe[1]
num = @recipe[2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if num > 0
max_buf = $game_party.item_number(item)/num
else
max_buf = 999
end
max = [max, max_buf].min
end
buying_price == 0 ? max : [max, money / buying_price].min
end
#--------------------------------------------------------------------------
# ● 所持金の取得
#--------------------------------------------------------------------------
def money
@gold_window.value
end
#--------------------------------------------------------------------------
# ● 通貨単位の取得
#--------------------------------------------------------------------------
def currency_unit
@gold_window.currency_unit
end
#--------------------------------------------------------------------------
# ● 合成費用の取得
#--------------------------------------------------------------------------
def buying_price
@list_window.price(@item)
end
end
class Window_ItemSynthesisList < Window_Selectable
include WD_itemsynthesis
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :status_window # ステータスウィンドウ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@shop_goods = []
@shop_recipes = []
for i in 1..WD_itemsynthesis_ini::I_recipe.size
recipe = WD_itemsynthesis_ini::I_recipe
if recipe
good = [0, i, recipe[0]]
if i_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
for i in 1..WD_itemsynthesis_ini::W_recipe.size
recipe = WD_itemsynthesis_ini::W_recipe
if recipe
good = [1, i, recipe[0]]
if w_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
for i in 1..WD_itemsynthesis_ini::A_recipe.size
recipe = WD_itemsynthesis_ini::A_recipe
if recipe
good = [2, i, recipe[0]]
if a_recipe_switch_on?(i)
@shop_goods.push(good)
@shop_recipes.push(recipe)
end
end
end
@Money = 0
refresh
select(0)
end
#--------------------------------------------------------------------------
# ● ウィンドウ幅の取得
#--------------------------------------------------------------------------
def window_width
return 304
end
#--------------------------------------------------------------------------
# ● 項目数の取得
#--------------------------------------------------------------------------
def item_max
@data ? @data.size : 1
end
#--------------------------------------------------------------------------
# ● アイテムの取得
#--------------------------------------------------------------------------
def item
@data[index]
end
#--------------------------------------------------------------------------
# ● 所持金の設定
#--------------------------------------------------------------------------
def money=(money)
@money = money
refresh
end
#--------------------------------------------------------------------------
# ● 選択項目の有効状態を取得
#--------------------------------------------------------------------------
def current_item_enabled?
enable?(@data[index])
end
#--------------------------------------------------------------------------
# ● 合成費用を取得
#--------------------------------------------------------------------------
def price(item)
@price[item]
end
#--------------------------------------------------------------------------
# ● 合成可否を取得
#--------------------------------------------------------------------------
def enable?(item)
@makable[item]
end
#--------------------------------------------------------------------------
# ● レシピを取得
#--------------------------------------------------------------------------
def recipe(item)
@recipe[item]
end
#--------------------------------------------------------------------------
# ● アイテムを許可状態で表示するかどうか
#--------------------------------------------------------------------------
def have_mat?(recipe)
flag = true
if @money >= recipe[0]
for i in 1...recipe.size
kind = recipe[0]
id = recipe[1]
num = recipe[2]
if kind == "I"
item = $data_items[id]
elsif kind == "W"
item = $data_weapons[id]
elsif kind == "A"
item = $data_armors[id]
end
if $game_party.item_number(item) < [num, 1].max
flag = false
end
end
else
flag = false
end
return flag
end
#--------------------------------------------------------------------------
# ● カテゴリの設定
#--------------------------------------------------------------------------
def category=(category)
return if @category == category
@category = category
refresh
end
#--------------------------------------------------------------------------
# ● リフレッシュ
#--------------------------------------------------------------------------
def refresh
make_item_list
create_contents
draw_all_items
end
#--------------------------------------------------------------------------
# ● アイテムをリストに含めるかどうか
#--------------------------------------------------------------------------
def include?(item)
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item?
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
when :key_item
item.is_a?(RPG::Item) && item.key_item?
else
false
end
end
#--------------------------------------------------------------------------
# ● アイテムリストの作成
#--------------------------------------------------------------------------
def make_item_list
@data = []
@price = {}
@makable = {}
@recipe = {}
for i in 0...@shop_goods.size
goods = @shop_goods
recipe = @shop_recipes
case goods[0]
when 0; item = $data_items[goods[1]]
when 1; item = $data_weapons[goods[1]]
when 2; item = $data_armors[goods[1]]
end
if item
if include?(item)
@data.push(item)
@price[item] = goods[2]
@makable[item] = have_mat?(recipe)
@recipe[item] = recipe
end
end
end
end
#--------------------------------------------------------------------------
# ● 項目の描画
#--------------------------------------------------------------------------
def draw_item(index)
item = @data[index]
rect = item_rect(index)
draw_item_name(item, rect.x, rect.y, enable?(item))
rect.width -= 4
draw_text(rect, price(item), 2) if WD_itemsynthesis_ini::Cost_view
end
#--------------------------------------------------------------------------
# ● ステータスウィンドウの設定
#--------------------------------------------------------------------------
def status_window=(status_window)
@status_window = status_window
call_update_help
end
#--------------------------------------------------------------------------
# ● 素材ウィンドウの設定
#--------------------------------------------------------------------------
def material_window=(material_window)
@material_window = material_window
call_update_help
end
#--------------------------------------------------------------------------
# ● ヘルプテキスト更新
#--------------------------------------------------------------------------
def update_help
@help_window.set_item(item) if @help_window
@status_window.item = item if @status_window
@material_window.set(item, recipe(item)) if @material_window
end
#--------------------------------------------------------------------------
# ● ←→ ボタン(表示切替)が押されたときの処理
#--------------------------------------------------------------------------
def process_change_window
Sound.play_cursor
Input.update
call_handler(:change_window)
end
#--------------------------------------------------------------------------
# ● 決定やキャンセルなどのハンドリング処理
#--------------------------------------------------------------------------
def process_handling
super
if active
return process_change_window if handle?(:change_window) && Input.trigger?(:X)
return process_change_window if handle?(:change_window) && Input.trigger?(:Y)
end
end
end
class Window_ItemSynthesisCategory < Window_ItemCategory
#--------------------------------------------------------------------------
# ● 桁数の取得
#--------------------------------------------------------------------------
def col_max
i = 0
i += 1 if WD_itemsynthesis_ini::Category_i
i += 1 if WD_itemsynthesis_ini::Category_w
i += 1 if WD_itemsynthesis_ini::Category_a
i += 1 if WD_itemsynthesis_ini::Category_k
return i
end
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
def make_command_list
add_command(Vocab::item, :item) if WD_itemsynthesis_ini::Category_i
add_command(Vocab::weapon, :weapon) if WD_itemsynthesis_ini::Category_w
add_command(Vocab::armor, :armor) if WD_itemsynthesis_ini::Category_a
add_command(Vocab::key_item, :key_item) if WD_itemsynthesis_ini::Category_k
end
end