Ruby:# ╔═══════════════════════════════════════════════╦════════════════════╗
# ║ Title: Mr Bubble Dismantle Items by Quantity ║ Version: 1.01 ║
# ║ Author: Roninator2 ║ ║
# ╠═══════════════════════════════════════════════╬════════════════════╣
# ║ Function: ║ Date Created ║
# ║ ╠════════════════════╣
# ║ Provide number input option ║ 09 Feb 2025 ║
# ╚═══════════════════════════════════════════════╩════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Requires: ║
# ║ Mr Bubble Dismantle Items ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Brief Description: ║
# ║ Allow multiple of the same item ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Instructions: ║
# ║ Plug and Play ║
# ║ Change the Low Gold text below if you want ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Updates: ║
# ║ 1.00 - 09 Feb 2025 - Script finished ║
# ║ 1.01 - 18 Feb 2025 - Added adjustment for long lists ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Credits and Thanks: ║
# ║ Roninator2 ║
# ║ ║
# ╚════════════════════════════════════════════════════════════════════╝
# ╔════════════════════════════════════════════════════════════════════╗
# ║ Terms of use: ║
# ║ Follow the original Authors terms of use where applicable ║
# ║ - When not made by me (Roninator2) ║
# ║ Free for all uses in RPG Maker except nudity ║
# ║ Anyone using this script in their project before these terms ║
# ║ were changed are allowed to use this script even if it conflicts ║
# ║ with these new terms. New terms effective 03 Apr 2024 ║
# ║ No part of this code can be used with AI programs or tools ║
# ║ Credit must be given ║
# ╚════════════════════════════════════════════════════════════════════╝
module Bubs
#==========================================================================
# ++ Dismantle Shop Settings
#==========================================================================
module Dismantle
#--------------------------------------------------------------------------
# Dismantle Command Vocab
#--------------------------------------------------------------------------
LOW_GOLD = "Not Enough Gold"
end
end
# ╔════════════════════════════════════════════════════════════════════╗
# ║ End of editable region ║
# ╚════════════════════════════════════════════════════════════════════╝
#==============================================================================
# ++ Window_DismantleShopNumber
#==============================================================================
class Window_DismantleNumber < Window_Selectable
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :number # quantity entered
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(x, y, height)
super(x, y, window_width, height)
@max = 1
@number = 1
end
#--------------------------------------------------------------------------
# * Get Window Width
#--------------------------------------------------------------------------
def window_width
return figures * 10 + 36
end
#--------------------------------------------------------------------------
# * Set Item, Max Quantity, Price, and Currency Unit
#--------------------------------------------------------------------------
def set(max)
@max = max
@number = 1
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text(0, 0, cursor_width - 4, line_height, @number, 2)
end
#--------------------------------------------------------------------------
# * update_position
#--------------------------------------------------------------------------
def update_position(index, wy, oy)
self.y = item_rect(index - oy).y + wy
end
#--------------------------------------------------------------------------
# * Get Cursor Width
#--------------------------------------------------------------------------
def cursor_width
figures * 10 + 12
end
#--------------------------------------------------------------------------
# * Get Maximum Number of Digits for Quantity Display
#--------------------------------------------------------------------------
def figures
return 3
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
if active
last_number = @number
update_number
if @number != last_number
Sound.play_cursor
refresh
end
end
end
#--------------------------------------------------------------------------
# * Update Quantity
#--------------------------------------------------------------------------
def update_number
change_number(1) if Input.repeat?(:RIGHT)
change_number(-1) if Input.repeat?(:LEFT)
change_number(10) if Input.repeat?(:UP)
change_number(-10) if Input.repeat?(:DOWN)
end
#--------------------------------------------------------------------------
# * Change Quantity
#--------------------------------------------------------------------------
def change_number(amount)
@number = [[@number + amount, @max].min, 1].max
end
#--------------------------------------------------------------------------
# * Update Cursor
#--------------------------------------------------------------------------
def update_cursor
cursor_rect.set(0, 0, cursor_width, line_height)
end
end # class Window_DismantleNumber
#==============================================================================
# ++ Window_DismantleLowGold
#==============================================================================
class Window_DismantleLowGold < Window_Selectable
#--------------------------------------------------------------------------
# initialize
#--------------------------------------------------------------------------
def initialize(x, y)
super(x, y, window_width, window_height)
refresh
end
#--------------------------------------------------------------------------
# window_width
#--------------------------------------------------------------------------
def window_width
Graphics.width / 2
end
#--------------------------------------------------------------------------
# window_height
#--------------------------------------------------------------------------
def window_height
fitting_height(1)
end
#--------------------------------------------------------------------------
# refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_dismantle_header_text(4, 0)
end
#--------------------------------------------------------------------------
# draw_dismantle_header_text
#--------------------------------------------------------------------------
def draw_dismantle_header_text(x, y)
rect = Rect.new(x, y, contents.width - 4 - x, line_height)
change_color(crisis_color)
draw_text(rect, Bubs::Dismantle::LOW_GOLD, 1)
end
end # class Window_DismantleLowGold
#==============================================================================
# ++ Scene_DismantleShop
#==============================================================================
class Scene_DismantleShop < Scene_MenuBase
#--------------------------------------------------------------------------
# start
#--------------------------------------------------------------------------
alias :r2_dismantle_sceen_number_start :start
def start
r2_dismantle_sceen_number_start
create_number_window
create_low_gold
end
#--------------------------------------------------------------------------
# * Create Quantity Input Window
#--------------------------------------------------------------------------
def create_number_window
wx = @itemlist_window.width
wy = 0
wh = 48
@number_window = Window_DismantleNumber.new(wx, wy, wh)
@number_window.viewport = @viewport
@number_window.set_handler(:ok, method(:on_dismantle_number_ok))
@number_window.set_handler(:cancel, method(:on_dismantle_number_cancel))
@number_window.hide.deactivate
end
#--------------------------------------------------------------------------
# create_low_gold
#--------------------------------------------------------------------------
def create_low_gold
wx = Graphics.width / 4
wy = @category_window.y
@low_gold_window = Window_DismantleLowGold.new(wx, wy)
@low_gold_window.viewport = @viewport
@low_gold_window.set_handler(:ok, method(:on_low_gold_ok))
@low_gold_window.set_handler(:cancel, method(:on_low_gold_cancel))
@low_gold_window.hide
end
#--------------------------------------------------------------------------
# * Quantity Input [OK]
#--------------------------------------------------------------------------
def on_dismantle_number_ok
@number_window.hide.deactivate
@confirm_window.show.activate
end
#--------------------------------------------------------------------------
# * Quantity Input [Cancel]
#--------------------------------------------------------------------------
def on_dismantle_number_cancel
@number_window.hide.deactivate
on_confirm_cancel
end
#--------------------------------------------------------------------------
# * Quantity Input [OK]
#--------------------------------------------------------------------------
def on_low_gold_ok
on_low_gold_cancel
end
#--------------------------------------------------------------------------
# * Quantity Input [Cancel]
#--------------------------------------------------------------------------
def on_low_gold_cancel
@low_gold_window.hide.deactivate
on_confirm_cancel
end
#--------------------------------------------------------------------------
# on_itemlist_ok
#--------------------------------------------------------------------------
def on_itemlist_ok
@confirm_window.deactivate
@item = @itemlist_window.item
$game_party.last_item.object = @item
@info_window.item = @item
@number_window.update_position(@itemlist_window.index, @itemlist_window.y, @itemlist_window.top_row)
@number_window.set($game_party.item_number(@item))
@number_window.show.activate
@number_window.select(0)
end
#--------------------------------------------------------------------------
# process_dismantle
#--------------------------------------------------------------------------
def process_dismantle
return unless @item
num = @number_window.number
if $game_party.gold < num * @item.dismantle_gold_fee
Sound.play_buzzer
@low_gold_window.show.activate
return
end
$game_party.last_item.object = @item
@item.dismantle_counter += num
$game_party.lose_item(@item, num)
$game_party.lose_gold(num * @item.dismantle_gold_fee)
gained_items = determine_dismantled_items
gain_dismantled_items(gained_items)
@results_window.items = gained_items
@results_window.height = @results_window.window_height
@header_window.show
@results_window.open
@results_window.show.activate.select(0)
Sound.play_dismantle
refresh
end
#--------------------------------------------------------------------------
# determine_dismantled_items
#--------------------------------------------------------------------------
def determine_dismantled_items
num = @number_window.number
gained_items = []
num.times do
@item.dismantle_items.each_with_index do |dism_obj, index|
if rand < (dism_obj.chance * 0.01)
gained_items.push(dism_obj.item)
dism_obj.mask = true
end
end
end
return gained_items
end
end # class Scene_DismantleShop