Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- # Multi use items
- # Version 1.25
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
- #
- # Do you think it's strange if hero used up entire potion with one gulp?
- # This script will make item can be used multiple times
- #
- # How To Use
- #
- # For XP
- #
- # There are configuration below
- #
- # For VX
- #
- # Type in Note Editor at tab items
- # Multi Use = X
- #
- # Replace X with number
- #
- # Example
- #
- # Multi Use = 4
- # Then that item can be used 4 times
- #
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- module LiTTleDRAgo
- Show_Use_String = 'Used '
- Show_Times_String = ' times. '
- def self.multi_use_item(id) # Only for XP
- case id
- when 1,2 then 2 # This means potion & high potion can be used twice
- when 3 then 4
- end
- end
- end
- #==============================================================================
- # ** Game_Party
- #------------------------------------------------------------------------------
- # This class handles the party. It includes information on amount of gold
- # and items. The instance of this class is referenced by $game_party.
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # * Constants
- #--------------------------------------------------------------------------
- VX = defined?(Window_BattleMessage)
- name = VX ? "(items, n, include_equip = false)" : "(items, n)"
- eval_text = "
- #--------------------------------------------------------------------------
- # * Gain Items (or lose)
- #--------------------------------------------------------------------------
- def gain_item#{name}
- @multi_use = [] if @multi_use.nil?
- item_id, number = (VX ? items.id : items),item_number(items)
- if item_id > 0
- if multiuse?(item_id) && n > 0
- (0...n).each {|i| @multi_use.push([item_id,multiuse?(item_id)])}
- end
- @items[item_id] = [[number+n,0].max,99].min
- return if !VX
- n += item_number(item_id)
- members.each {|actor|
- while n < 0 && actor.equips.include?(items)
- actor.discard_equip(items); n += 1 end } if include_equip && n < 0
- end
- end
- #--------------------------------------------------------------------------
- # * Lose Items
- #--------------------------------------------------------------------------
- def lose_item#{name}
- @multi_use = [] if @multi_use.nil?
- item_id, i, xer = (VX ? items.id : items),0, n
- if multiuse?(item_id) && have_multiuse?(item_id) && !$scene.is_a?(Scene_Shop)
- @multi_use.sort! {|a,b|a[1]<=> b[1]}
- for item in @multi_use
- if item[0] == item_id
- @multi_use[i][1]-=1
- if @multi_use[i][1] == 0
- @multi_use.delete(item)
- @items[item_id] = [[item_number(items) -1, 0].max, 99].min
- end
- break
- end
- i+=1
- end
- elsif $scene.is_a?(Scene_Shop) && multiuse?(item_id)
- @multi_use.sort! {|a,b|a[1]<=> b[1]}
- for item in @multi_use
- break if xer == 0
- if item[0] == item_id then @multi_use.delete_at(i); xer-=1 end
- i+=1
- end
- @items[item_id] = [[item_number(items) -n, 0].max, 99].min
- else
- n = -n
- gain_item#{name}
- end
- end"
- eval(eval_text)
- #--------------------------------------------------------------------------
- # * Have Multiusables?
- #--------------------------------------------------------------------------
- def have_multiuse?(item_id)
- @multi_use = [] if @multi_use.nil?
- @multi_use.each {|item| return true if item[0] == item_id }
- return false
- end
- #--------------------------------------------------------------------------
- # * Multiusables?
- #--------------------------------------------------------------------------
- def multiuse?(item_id=nil)
- return @multi_use if item_id.nil?
- unless VX
- s = LiTTleDRAgo.multi_use_item(item_id)
- return s ? s.abs : nil
- end
- return LiTTleDRAgo.multi_use_item(item_id) unless VX
- if $data_items[item_id].note =~ /Multi Use = (\d+)/
- return $1.to_i
- end
- end
- end
- if LiTTleDRAgo::Show_Use_String
- #==============================================================================
- # ** Window_Item / Window_ShopSell
- #------------------------------------------------------------------------------
- # This window displays a list of inventory items for the item screen, etc.
- #==============================================================================
- for i in 0..1
- kelas = i == 0 ? "Window_Item" : "Window_ShopSell"
- break if defined?(Window_BattleMessage) && i == 1
- eval_text = "
- class #{kelas} < Window_Selectable
- #------------------------------------------------------------------------
- # * Update Help Text
- #------------------------------------------------------------------------
- def update_help
- if $game_party.multiuse?(self.item.id)
- $game_party.multiuse?.each {|item|
- if item[0] == self.item.id then @uses = item[1]; break end }
- times = LiTTleDRAgo::Show_Times_String
- times = '' if times.nil?
- description = LiTTleDRAgo::Show_Use_String + @uses.to_s + '/' +
- $game_party.multiuse?(self.item.id).to_s
- @help_window.set_text(description + times + self.item.description)
- else
- @help_window.set_text(self.item.nil? ? '' : self.item.description)
- end
- end
- end"
- eval(eval_text)
- end
- end
- $multi_use_items = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement