Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- #
- # Shanghai Simple Script - Disassemble Shop Fee Add-on
- # Last Date Updated: 2010.08.12
- # Level: Normal
- # Original Script by: Shanghai
- # Add-on by: Jet Kobayashi Zala
- #
- # This script is an add-on for Shanghai Simple Script - Disassemble Shop. It
- # adds functionality to allow fees to be charged for disassembling items. The
- # script features 4 modes for disassembly in addition to allowing you to specify
- # a specific amount in the item's notebox. This script uses a variable to modify
- # the mode that the shop uses to determine disassembly costs so that you can
- # change it in-game.
- #
- # Fee Determination Modes:
- # 0 - Fee is a flat rate set in the variable specified in the script
- # 1 - Fee is a flat rate determined by the item's type. i.e. Item, Weapon, Armor
- # 2 - Fee is based on number of components and a rate by the component's item type
- # 3 - Same as Mode 2, but fee is a percentage of the item's price by item type
- #
- # As an add-on, this script requires that you have
- # Shanghai Simple Script - Disassemble Shop already installed.
- #
- # This was not made by Shanghai, but by Jet Kobayashi Zala and without
- # Shanghai's consent and so he may end up flayed for this. If you need
- # help regarding this add-on, contact Jet about it, not Shanghai.
- #
- # E-mail: jetkobayashizala@gmail.com
- #
- #===============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below Shanghai Simple Script - Disassemble Shop
- # but above ▼ Main. Remember to save.
- #
- # New notebox tag:
- #
- # <disassemble fee: x>
- # Sets the disassembly fee to x for the item.
- # If not used, the default fee/formula is used.
- #
- # Place this in the notebox of either an item, weapon, or armor and that fee
- # will be charged when disassembling the item.
- #===============================================================================
- $imported = {} if $imported == nil
- $imported["DisassembleShopFeeAddon"] = true
- module SSS
- # Settings for Disassembly Shop Fee Settings
- DISASSEMBLE_FEE = true # Use Disassembly Fee system
- DISASSEMBLE_COST = "Fee" # Text next to disassembly fee
- DISASSEMBLE_FUNDS = "Funds" # Text used for party's money
- # Game Variable used to store the fee determination mode
- # Custom pricing always supersedes this setting
- DISASSEMBLE_VARIABLE = 6
- # 0 - Uses a flat rate set in the DISASSEMBLE_RATE_VARIABLE variable
- # 1 - Fee is based on the item's category
- # 2 - Fee is based on item type of the components
- # that the item disassembles into
- # 3 - Same as 2, but charge is a portion of the cost of
- # the components the unwanted item disassembles into
- # If mode is set to is 0, This is the variable that holds
- # the flat rate for disassembly.
- DISASSEMBLE_RATE_VARIABLE = 7
- # If mode is set to 1, This is the flat rate for
- # disassembly based on the original item's type.
- DISASSEMBLE_CATEGORY_ITEM = 1000
- DISASSEMBLE_CATEGORY_WEAPON = 2000
- DISASSEMBLE_CATEGORY_ARMOR = 2500
- # If mode is set to 2, the fee to disassemble
- # the item is based on what it disassembles into.
- DISASSEMBLE_ITEM_RATE = 100
- DISASSEMBLE_WEAPON_RATE = 200
- DISASSEMBLE_ARMOR_RATE = 250
- # If mode is set to 3, the fee to disassemble the
- # item is based on a percentage of each components's cost.
- DISASSEMBLE_ITEM_PERCENT = 0.10
- DISASSEMBLE_WEAPON_PERCENT = 0.20
- DISASSEMBLE_ARMOR_PERCENT = 0.25
- end
- #==============================================================================
- # RPG::BaseItem
- #==============================================================================
- class RPG::BaseItem
- #--------------------------------------------------------------------------
- # * Get Disassembly Fee
- #--------------------------------------------------------------------------
- def get_disassembly_fee
- # Return custom fee if set
- return disassembled_fee if !disassembled_fee.nil?
- # Otherwise, use formula/rate settings
- fee = 0
- case $game_variables[SSS::DISASSEMBLE_VARIABLE]
- when 0 # Flat Rate
- fee = $game_variables[SSS::DISASSEMBLE_RATE_VARIABLE]
- when 1 # By Original Item Type
- if self.is_a?(RPG::Item)
- fee = SSS::DISASSEMBLE_CATEGORY_ITEM
- elsif self.is_a?(RPG::Weapon)
- fee = SSS::DISASSEMBLE_CATEGORY_WEAPON
- elsif self.is_a?(RPG::Armor)
- fee = SSS::DISASSEMBLE_CATEGORY_ARMOR
- end
- when 2 # By Item - Flat Rate Per Item
- for component in @disassembled_items
- if component.is_a?(RPG::Item)
- fee += SSS::DISASSEMBLE_ITEM_RATE
- elsif component.is_a?(RPG::Weapon)
- fee += SSS::DISASSEMBLE_WEAPON_RATE
- elsif component.is_a?(RPG::Armor)
- fee += SSS::DISASSEMBLE_ARMOR_RATE
- end
- end
- when 3 # By Item - Percentage of item cost
- for component in @disassembled_items
- if component.is_a?(RPG::Item)
- fee += (SSS::DISASSEMBLE_ITEM_PERCENT * component.price)
- elsif component.is_a?(RPG::Weapon)
- fee += (SSS::DISASSEMBLE_WEAPON_PERCENT * component.price)
- elsif component.is_a?(RPG::Armor)
- fee += (SSS::DISASSEMBLE_ARMOR_PERCENT * component.price)
- end
- end
- end
- return fee.to_i
- end
- #--------------------------------------------------------------------------
- # disassembled_fee
- #--------------------------------------------------------------------------
- def disassembled_fee
- return nil if !SSS::DISASSEMBLE_FEE
- self.note.split(/[\r\n]+/).each { |line|
- case line
- when /<(?:DISASSEMBLE_FEE|disassemble fee):[ ]*(\d+)>/i
- return $1.to_i
- end
- }
- return nil
- end
- end
- #==============================================================================
- # ** Window_Disassemble
- #==============================================================================
- class Window_Disassemble < Window_Selectable
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias sss_original_initialize initialize
- def initialize(help_window)
- if $imported["DisassembleShopFeeAddon"] and SSS::DISASSEMBLE_FEE
- yy = help_window.height + help_window.y + (WLH + 32) + 56
- hh = Graphics.height - yy
- super(0, yy, Graphics.width-240, hh)
- self.active = false
- self.index = -1
- @help_window = help_window
- self.item_type = 0
- else
- sss_original_initialize(help_window)
- end
- end
- end
- #==============================================================================
- # ** Window_DisassembleContents
- #==============================================================================
- class Window_DisassembleContents < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- alias sss_original_initialize initialize
- def initialize(body_window)
- if $imported["DisassembleShopFeeAddon"] and SSS::DISASSEMBLE_FEE
- @body_window = body_window
- super(@body_window.width, @body_window.y, 240, @body_window.height)
- refresh
- else
- sss_original_initialize(body_window)
- end
- end
- end
- #==============================================================================
- # ** Window_DisassembleFee
- #==============================================================================
- class Window_DisassembleFee < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(contents_window)
- @item = nil
- super(0, contents_window.y - WLH - 32, Graphics.width, WLH + 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- self.contents.font.color = normal_color
- self.contents.draw_text(0, 0, self.contents.width / 2 - 15, WLH, SSS::DISASSEMBLE_COST)
- self.contents.draw_text(0, 0, self.contents.width / 2 - 15, WLH, get_disassembly_fee.to_s + Vocab::gold, 2)
- self.contents.draw_text(self.contents.width / 2 + 15, 0, self.contents.width / 2 - 15, WLH, SSS::DISASSEMBLE_FUNDS)
- self.contents.draw_text(self.contents.width / 2 + 15, 0, self.contents.width / 2 - 15, WLH, $game_party.gold.to_s + Vocab::gold, 2)
- end
- #--------------------------------------------------------------------------
- # * Get Disassembly Fee
- #--------------------------------------------------------------------------
- def get_disassembly_fee
- # Return 0 if item is nil
- return 0 if @item == nil
- # Return item's disassembly fee
- return @item.get_disassembly_fee
- end
- #--------------------------------------------------------------------------
- # * Set Item
- #--------------------------------------------------------------------------
- def set_item(item)
- @item = item
- refresh
- end
- end
- #==============================================================================
- # ** Scene_Disassemble
- #==============================================================================
- if $imported["DisassembleShopFeeAddon"] and SSS::DISASSEMBLE_FEE
- class Scene_Disassemble < Scene_Base
- #--------------------------------------------------------------------------
- # * Start processing
- #--------------------------------------------------------------------------
- alias sss_original_start start
- def start
- sss_original_start
- @fee_window = Window_DisassembleFee.new(@contents_window)
- end
- #--------------------------------------------------------------------------
- # * Termination Processing
- #--------------------------------------------------------------------------
- alias sss_original_terminate terminate
- def terminate
- sss_original_terminate
- @fee_window.dispose
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- alias sss_original_update update
- def update
- sss_original_update
- @fee_window.set_item(@item_window.item)
- @fee_window.update
- end
- #--------------------------------------------------------------------------
- # * Update Item Selection
- #--------------------------------------------------------------------------
- def update_item_selection
- @item_window.update
- if @last_item_index != @item_window.index
- @last_item_index = @item_window.index
- @contents_window.refresh
- end
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @command_window.active = true
- @item_window.active = false
- elsif Input.repeat?(Input::C)
- disassemble_item = @item_window.item
- if disassemble_item.nil? or $game_party.gold < disassemble_item.get_disassembly_fee
- Sound.play_buzzer
- else
- Sound.play_shop
- $game_party.lose_item(disassemble_item, 1)
- for item in disassemble_item.disassembled_items
- next if item.nil?
- $game_party.gain_item(item, 1)
- end
- $game_party.lose_gold(disassemble_item.get_disassembly_fee)
- @item_window.refresh
- @item_window.index = [@item_window.item_max, @item_window.index].min
- @fee_window.refresh
- @contents_window.refresh
- end
- end
- end
- end
- end
- #===============================================================================
- #
- # END OF FILE
- #
- #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement