#============================================================================== # ■ RGSS3 CACAO SOFTさんのアイテム合成時に # 倉庫アイテム含有 Ver1.01 by 星潟 #------------------------------------------------------------------------------ # ※アイテム合成スクリプトよりも下にこのスクリプトを配置して下さい。 #------------------------------------------------------------------------------ # Ver1.01 アイテム合成Ver1.1.2用に処理を変更。 #============================================================================== module CAO module ItemMake #倉庫スクリプト併用時、合成時に倉庫のアイテムを #参照する場合のスイッチを指定します。 #指定IDのスイッチがONの場合、倉庫を含みます。 #0を指定すると、無条件で倉庫を参照します。 IKM_SWITCH = 0 #倉庫のアイテムを優先で合成で消費するかを指定します。 #trueで倉庫アイテムを優先消費、falseで所持アイテムを優先消費します。 C_USE = true #倉庫のアイテムを現在の所持数に加算して表示するかどうかを指定します。 #(材料ではなく、完成後のアイテムの所持数の事です) KEEP_PLUS = true end end class Game_Temp attr_accessor :cacao_keep_type #-------------------------------------------------------------------------- # 合成時の、所持アイテムへの倉庫アイテム含有判定 #-------------------------------------------------------------------------- def cacao_im_keep #スイッチIDが0の時は無条件でtrue、そうでない場合はスイッチの状態を参照。 CAO::ItemMake::IKM_SWITCH == 0 ? true : $game_switches[CAO::ItemMake::IKM_SWITCH] end end class Window_ItemMakeStatus < Window_Base #-------------------------------------------------------------------------- # アイテム名の描画 #-------------------------------------------------------------------------- alias draw_item_name_cacao_keep draw_item_name def draw_item_name(imitem, x, y, enabled = true) #アイテム含有判定がtrueの場合は本来の処理を実行。 return draw_item_name_cacao_keep(imitem, x, y, enabled) unless $game_temp.cacao_im_keep #基本は本来の処理を行う。所持アイテム数には倉庫アイテムを含める。 if @recipe.secret icon_index = ICON_SECRET item_name = VACAB_SECRET_NAME number = "#{VACAB_SECRET_NUMBER}(#{VACAB_SECRET_NUMBER})" enabled = true else return unless imitem icon_index = imitem.object.icon_index item_name = imitem.object.name case $game_temp.cacao_keep_type when 1;ex_stock = CAO::ItemMake::KEEP_PLUS ? $game_party.item_keep_number(imitem.object) : 0 when 2;ex_stock = $game_party.item_keep_number(imitem.object) else;ex_stock = 0 end stock = $game_party.item_number(imitem.object) + ex_stock number = sprintf(VOCAB_QUANTITY, imitem.quantity, stock) end draw_icon(icon_index, x, y, enabled) change_color(normal_color, enabled) draw_text(x + 24, y, contents_width - x - 24, line_height, item_name) change_size(NUM_SIZE) do draw_text(contents_width - 48, y + NUM_DOWN, 48, line_height, number, 2) end end #-------------------------------------------------------------------------- # 増やすアイテムの描画 #-------------------------------------------------------------------------- alias draw_plus_items_cacao_keep draw_plus_items def draw_plus_items(y) #アイテム含有判定がtrueの場合は本来の処理を実行。 return draw_plus_items_cacao_keep(y) unless $game_temp.cacao_im_keep #増やすアイテムの描写処理中フラグを立てる。 $game_temp.cacao_keep_type = 1 change_color(system_color) draw_text(0, y, contents_width, line_height, @book.plus_name || VOCAB_PLUS_ITEM) @book.plus_number.times do |i| y += line_height draw_item_name(@recipe.plus_items[i], 8, y) end #増やすアイテムの描写処理中フラグを消去する。 $game_temp.cacao_keep_type = nil end #-------------------------------------------------------------------------- # 減らすアイテムの描画 #-------------------------------------------------------------------------- alias draw_minus_items_cacao_keep draw_minus_items def draw_minus_items(y) #アイテム含有判定がtrueの場合は本来の処理を実行。 return draw_minus_items_cacao_keep(y) unless $game_temp.cacao_im_keep #減らすアイテムの描写処理中フラグを立てる。 $game_temp.cacao_keep_type = 2 #基本は本来の処理を行う。所持アイテム判定を倉庫アイテム数を含めた数で判定。 change_color(system_color) draw_text(0, y, contents_width, line_height, @book.minus_name || VOCAB_MINUS_ITEM) @book.minus_number.times do |i| y += line_height imitem = @recipe.minus_items[i] draw_item_name(imitem, 8, y, imitem && (imitem.quantity <= $game_party.item_number(imitem.object) + $game_party.item_keep_number(imitem.object))) end #減らすアイテムの描写処理中フラグを消去する。 $game_temp.cacao_keep_type = nil end end class << CAO::ItemMake #-------------------------------------------------------------------------- # 合成可能? #-------------------------------------------------------------------------- alias can_change_item_cacao_keep? can_change_item? def can_change_item?(recipe, amount = 1) #アイテム含有判定がtrueの場合は本来の処理を実行。 return can_change_item_cacao_keep?(recipe, amount) unless $game_temp.cacao_im_keep #基本は本来の処理を行う。所持アイテム判定を倉庫アイテム数を含めた数で判定。 return false unless recipe return false if recipe.secret return false unless recipe.price * amount <= $game_party.gold return false unless recipe.minus_items.all? do |item| item.quantity * amount <= ($game_party.item_number(item.object) + $game_party.item_keep_number(item.object)) end return true end #-------------------------------------------------------------------------- # 合成処理 #-------------------------------------------------------------------------- alias change_item_cacao_keep change_item def change_item(recipe, amount = 1) #アイテム含有判定がtrueの場合は本来の処理を実行。 return change_item_cacao_keep(recipe, amount) unless $game_temp.cacao_im_keep #お金を消費する。 $game_party.lose_gold(recipe.price * amount) #C_USEの設定に応じて分岐。 if CAO::ItemMake::C_USE #倉庫優先消費の場合 recipe.minus_items.each do |item| #倉庫に該当アイテムが預けられていない場合は #所持品のみで減らす。 if $game_party.item_keep_number(item.object) == 0 $game_party.lose_item(item.object, item.quantity * amount) #倉庫に該当アイテムが預けられており #なおかつ必要数以上預けられている場合は #倉庫のアイテムを必要数減少させる。 elsif $game_party.item_keep_number(item.object) >= item.quantity * amount $game_party.item_keep_execute(item.object, -item.quantity * amount) #倉庫に該当アイテムが預けられており #なおかつ必要数に満たない数が預けられている場合は #必要数と預けられている数との差異を計算した後 #倉庫のアイテムを消去し、差異の値分そのアイテムの所持数を減少させる。 else q_data = item.quantity * amount - $game_party.item_keep_number(item.object) $game_party.item_keep_execute(item.object, -$game_party.item_keep_number(item.object)) $game_party.lose_item(item.object, q_data) end end else #所持品優先消費の場合 recipe.minus_items.each do |item| #所持数が必要数より少ない場合は #所持数と必要数の差異を計算した後 #所持数を消去し、倉庫のアイテムを #差異の値分そのアイテムの預けている数を減少させる。 if $game_party.item_number(item.object) < item.quantity * amount q_data = item.quantity * amount - $game_party.item_number(item.object) $game_party.item_keep_execute(item.object, -q_data) $game_party.lose_item(item.object, $game_party.item_number(item.object)) #所持数が必要数以上の場合は #所持数から必要数分減少させる。 else $game_party.lose_item(item.object, item.quantity * amount) end end end #以下、本来の処理を行う。 recipe.plus_items.each do |item| $game_party.gain_item(item.object, item.quantity * amount) end recipe.new = true recipe.count += 1 end end