#============================================================================== # ■ RGSS3 白の魔さんのアイテム合成時に # 倉庫アイテム含有 Ver1.00 by 星潟 #------------------------------------------------------------------------------ # ※アイテム合成スクリプトよりも下にこのスクリプトを配置して下さい。 #============================================================================== module WD_itemsynthesis_ini #倉庫スクリプト併用時、合成時に倉庫のアイテムを #参照する場合のスイッチを指定します。 #指定IDのスイッチがONの場合、倉庫を含みます。 #0を指定すると、無条件で倉庫を参照します。 IKM_SWITCH = 0 #倉庫のアイテムを優先で合成で消費するかを指定します。 #trueで倉庫アイテムを優先消費、falseで所持アイテムを優先消費します。 W_USE = true end class Game_Temp #-------------------------------------------------------------------------- # 合成時の、所持アイテムへの倉庫アイテム含有判定 #-------------------------------------------------------------------------- def wd_im_keep #スイッチIDが0の時は無条件でtrue、そうでない場合はスイッチの状態を参照。 WD_itemsynthesis_ini::IKM_SWITCH == 0 ? true : $game_switches[WD_itemsynthesis_ini::IKM_SWITCH] end end class Scene_ItemSynthesis < Scene_MenuBase #-------------------------------------------------------------------------- # 合成の実行 #-------------------------------------------------------------------------- alias do_syntetic_wd do_syntetic def do_syntetic(number) #アイテム含有判定がtrueの場合は本来の処理を実行。 return do_syntetic_wd(number) unless $game_temp.wd_im_keep #基本は本来の処理を行う。素材の所持アイテム数には倉庫アイテムを含める。 $game_party.lose_gold(number * buying_price) $game_party.gain_item(@item, number) @recipe = @list_window.recipe(@item) for i in 1...@recipe.size kind = @recipe[i][0] id = @recipe[i][1] num = @recipe[i][2] if kind == "I" item = $data_items[id] elsif kind == "W" item = $data_weapons[id] elsif kind == "A" item = $data_armors[id] end true_num = num * number #W_USEの設定に応じて分岐。 if WD_itemsynthesis_ini::W_USE #倉庫優先消費の場合 #倉庫に該当アイテムが預けられていない場合は #所持品のみで減らす。 if $game_party.item_keep_number(item) == 0 $game_party.lose_item(item, true_num) #倉庫に該当アイテムが預けられており #なおかつ必要数以上預けられている場合は #倉庫のアイテムを必要数減少させる。 elsif $game_party.item_keep_number(item) >= true_num $game_party.item_keep_execute(item, -true_num) #倉庫に該当アイテムが預けられており #なおかつ必要数に満たない数が預けられている場合は #必要数と預けられている数との差異を計算した後 #倉庫のアイテムを消去し、差異の値分そのアイテムの所持数を減少させる。 else q_data = true_num - $game_party.item_keep_number(item) $game_party.item_keep_execute(item, -$game_party.item_keep_number(item)) $game_party.lose_item(item, q_data) end else #所持品優先消費の場合 #所持数が必要数より少ない場合は #所持数と必要数の差異を計算した後 #所持数を消去し、倉庫のアイテムを #差異の値分そのアイテムの預けている数を減少させる。 if $game_party.item_number(item) < num*number q_data = true_num - $game_party.item_number(item) $game_party.item_keep_execute(item, -q_data) $game_party.lose_item(item, $game_party.item_number(item)) #所持数が必要数以上の場合は #所持数から必要数分減少させる。 else $game_party.lose_item(item, true_num) end end end end #-------------------------------------------------------------------------- # 最大購入可能個数の取得 #-------------------------------------------------------------------------- alias max_buy_wd max_buy def max_buy #アイテム含有判定がtrueの場合は本来の処理を実行。 return max_buy_wd unless $game_temp.wd_im_keep #基本は本来の処理を行う。素材の所持アイテム数には倉庫アイテムを含める。 max = $game_party.max_item_number(@item) - $game_party.item_number(@item) @recipe = @list_window.recipe(@item) for i in 1...@recipe.size kind = @recipe[i][0] id = @recipe[i][1] num = @recipe[i][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) + $game_party.item_keep_number(item)) / num else max_buf = 999 end max = [max, max_buf].min end buying_price == 0 ? max : [max, money / buying_price].min end end class Window_ItemSynthesisList < Window_Selectable #-------------------------------------------------------------------------- # アイテムを許可状態で表示するかどうか #-------------------------------------------------------------------------- alias have_mat_wd? have_mat? def have_mat?(recipe) #アイテム含有判定がtrueの場合は本来の処理を実行。 return have_mat_wd?(recipe) unless $game_temp.wd_im_keep #基本は本来の処理を行う。素材の所持アイテム数には倉庫アイテムを含める。 flag = true if @money >= recipe[0] for i in 1...recipe.size kind = recipe[i][0] id = recipe[i][1] num = recipe[i][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) + $game_party.item_keep_number(item) < [num, 1].max flag = false end end else flag = false end return flag end end class Window_ItemSynthesisMaterial < Window_Base #-------------------------------------------------------------------------- # 素材情報の描画 #-------------------------------------------------------------------------- alias draw_material_info_wd draw_material_info def draw_material_info(x, y) #アイテム含有判定がtrueの場合は本来の処理を実行。 return draw_material_info_wd(x, y) unless $game_temp.wd_im_keep #基本は本来の処理を行う。素材の所持アイテム数には倉庫アイテムを含める。 rect = Rect.new(x, y, contents.width, line_height) change_color(system_color) contents.font.size = 18 draw_text(rect, "必要素材", 0) if @recipe for i in 1...@recipe.size kind = @recipe[i][0] id = @recipe[i][1] num = @recipe[i][2] if kind == "I" item = $data_items[id] elsif kind == "W" item = $data_weapons[id] elsif kind == "A" item = $data_armors[id] end rect = Rect.new(x, y + line_height*i, contents.width, line_height) enabled = true enabled = false if [num*@make_number, 1].max > ($game_party.item_number(item) + $game_party.item_keep_number(item)) draw_item_name(item, rect.x, rect.y, enabled) change_color(normal_color, enabled) if num > 0 draw_text(rect, "#{num*@make_number}/#{($game_party.item_number(item) + $game_party.item_keep_number(item))}", 2) end end end change_color(normal_color) contents.font.size = 24 end end