Dismantle Items

● ARCHIVED · READ-ONLY
Started by Mr. Bubble 20 posts View original ↗
  1. Dismantle Items

    Script by Mr. Bubble





    Summary

    This script is based off the Dismantling mechanic from Final Fantasy 13. However, copying that exact system isn’t very fun so I added a few extra optional features. You can also define the chance for items to be dismantled from the original item. Item dismantle information can also be masked until the player dismantles the item.

    Script

    Can be found here: http://wp.me/PxlCT-mg

    Installation

    Paste this script into its own page within the "Materials" section in the script editor of your project.

    How to Use

    This script utilizes notetags. Please read the comments thoroughly.

    Compatibility

    This script aliases some default VXA methods. There are no default method overwrites.

    Requests for compatibility with other scripts are encouraged and welcome.

    Terms and Conditions

    Free for non-commercial use.

    If you wish to use this for commercial games, contact me first.

    Please feel free to post coding and efficiency suggestions, script features suggestions, and bug reports.
  2. is this compatible to YanFly's scripts?

    btw, really nice idea...
  3. adiktuzmiko said:
    is this compatible to YanFly's scripts?
    You can test it yourself. I never bother testing my scripts with other scripts unless I say I did in the Compatibility notes. No point in looking for compatibility issues when I can just let users find them for me. I can then just tackle the issue directly.

    This script is a self-contained system so there should be no foreseeable issues.
  4. Fixed some major stuff pertaining to saved data.

    • v1.2Bugfix: Custom sound effects should no longer crash the game.
    • "Times Dismantled" values are now properly saved.
    • Dismantle mask flags are now properly saved. 
    • Dismantle scene script call has changed for consistency. The old script call can still be used though. (4/05/2013)
  5. Minor update to v1.3.

    I would like to work on this script again so if anyone has suggestions, let me know.
  6. Hi Mr. Bubble

    Could you add to this script a function that when i dismantle a weapon, for example i will receive an amount of item A, not just one piece of item A ?

    I think this would be very usefull.
  7. kensoloko said:
    Could you add to this script a function that when i dismantle a weapon, for example i will receive an amount of item A, not just one piece of item A ?
    No need, it's already there (even in the example of the original blog post where you get the script):
    Simply place an item line multiple times into the dismante info
  8. Sorry for reviving this zombie, but does someone happen to have this script around? The script link is dead.

    Cheers!
  9. Wyrelade said:
    let me post the question there also.
    That was the answer not where to ask the question.:kaosigh:
  10. Roninator2 said:
    That was the answer not where to ask the question.:kaosigh:
    Oh yeah what I meant is, I checked that thread already, it's 98% dead thread by now and only has 4 pages everyone asking about other scripts than this one xD So might aswell ask there anyways so it could/would get posted there. :p


    EDIT: I actually got the script from there thanks to someone posting it for my question.

    My plan was a success >:)
  11. Wyrelade said:
    it's 98% dead thread
    What are you talking about? The link on the first post has Archeia's directory list off all the scripts that have been saved from people uploading them.
    Wyrelade said:
    I actually got the script from there thanks to someone posting it for my question
    And that link is to the archive in the first post. Someone just made it simple for you, so you didn't have to look.
  12. Hi, just a small request, is it possible to add a feature to dismantle more than one item at a time?
  13. DOTP_DREAMWALKER said:
    Hi, just a small request, is it possible to add a feature to dismantle more than one item at a time?
    Do you mean multiple different items or multiple of the same item?
  14. Roninator2 said:
    Do you mean multiple different items or multiple of the same item?
    Multiple of one particular item.
  15. Dismantle multiple counts of items at the same time, not different items.
    Multiple item count
    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
  16. NoMethodError: undefined method `[]' for #<DismantleObj:0x1479d588>.
    Backtrace:
    Mr Bubble Dismantle Items Number Items:317:in `block (2 levels) in determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:316:in `each'
    Mr Bubble Dismantle Items Number Items:316:in `each_with_index'
    Mr Bubble Dismantle Items Number Items:316:in `block in determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:315:in `times'
    Mr Bubble Dismantle Items Number Items:315:in `determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:298:in `process_dismantle'
    Roninator2 said:
    Dismantle multiple counts of items at the same time, not different items.
  17. DOTP_DREAMWALKER said:
    NoMethodError: undefined method `[]' for #<DismantleObj:0x1479d588>.
    Backtrace:
    Mr Bubble Dismantle Items Number Items:317:in `block (2 levels) in determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:316:in `each'
    Mr Bubble Dismantle Items Number Items:316:in `each_with_index'
    Mr Bubble Dismantle Items Number Items:316:in `block in determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:315:in `times'
    Mr Bubble Dismantle Items Number Items:315:in `determine_dismantled_items'
    Mr Bubble Dismantle Items Number Items:298:in `process_dismantle'
    Have you put Mr Bubble's original Dismantle Items script above Roninator's in your script editor?
  18. Yes, did I mess something up? :eswt2:
    Trihan said:
    Have you put Mr Bubble's original Dismantle Items script above Roninator's in your script editor?