Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #===============================================================================
- # ╔══════════════════════════════════╗
- # ║ ▼ Dark's Item Expiration ║
- # ║ ▼ Author: Nhat Nguyen (Dark Sky) ║
- # ║ ▼ Release Date: March 8th 2016 ║
- # ╚══════════════════════════════════╝
- #-------------------------------------------------------------------------------
- # Version 1.0: Release!
- # Version 1.1: Fix a bug when recive a(n) weapon/ammour.
- #-------------------------------------------------------------------------------
- # ▼ Notetag: <dark_custom_item: {hour},{expired item id}>
- # -> <dark_custom_item: 24,28> : 24 là thời gian item được gán dòng note này
- # sẽ bị hết hạn và nhân vật sẽ nhận được item
- # với id là 28.
- #===============================================================================
- $imported = {} if $imported.nil?
- $imported["DRK-Item-Expiration"] = true
- if $imported["TH_InstanceItems"] != true
- msgbox_p("Instance Item not found! Exiting...")
- exit
- end
- module REGEXP
- TOKEN = /<dark_custom_item:\s*(\w+),\s*(\w+)>/i
- end
- module DataManager
- #--------------------------------------------------------------------------
- # ● Loads the database
- #--------------------------------------------------------------------------
- class << self
- alias_method(:my_load_database, :load_database)
- end
- def self.load_database
- my_load_database
- load_my_notetags
- end
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def self.load_my_notetags
- groups = [$data_items] #, $data_weapons, $data_armors]
- for group in groups
- for obj in group
- next if obj.nil?
- obj.load_my_notetags
- end
- end
- end
- end
- #==========================================================================
- # ■ RPG::Item
- #==========================================================================
- class RPG::Item < RPG::UsableItem
- #--------------------------------------------------------------------------
- # ● Public instance variables
- #--------------------------------------------------------------------------
- attr_accessor :time_nhan
- attr_accessor :qtime_het_han
- attr_accessor :time_het_han
- attr_accessor :co_the_het_han
- attr_accessor :het_han_item
- #--------------------------------------------------------------------------
- # ● Loads the note tags
- #--------------------------------------------------------------------------
- def load_my_notetags
- @note.split(/[\r\n]+/).each do |line|
- if line =~ REGEXP::TOKEN
- @co_the_het_han = true
- @qtime_het_han = $1.to_i
- @het_han_item = $2.to_i
- end
- end
- end
- end
- class Game_Party < Game_Unit
- #-----------------------------------------------------------------------------
- # The gain item method performs various checks on the item that you want to
- # add to the inventory. Namely, it checks whether it is a template item or
- # an instance item, updates the item counts, and so on.
- #-----------------------------------------------------------------------------
- def gain_item(item, amount, include_equip = false)
- # special check for normal items
- if !instance_enabled?(item)
- th_instance_items_gain_item(item, amount, include_equip)
- else
- if item
- if amount > 0
- amount.times do |i|
- new_item = get_instance(item)
- if new_item.is_a?(RPG::Item)
- if new_item.co_the_het_han
- new_item.time_nhan = GameTime.unlimit_hour
- new_item.time_het_han = new_item.time_nhan + new_item.qtime_het_han
- end
- end
- add_instance_item(new_item)
- end
- else
- amount.abs.times do |i|
- item_template = get_template(item)
- if item.is_template?
- # remove using template rules. If an item was lost, then decrease
- # template count by 1.
- lose_template_item(item, include_equip)
- else
- # remove the instance item, and decrease template count by 1
- lose_instance_item(item)
- end
- end
- end
- else
- th_instance_items_gain_item(item, amount, include_equip)
- end
- end
- end
- end
- module GameTime
- class << self
- alias :darkGameTimeUpdate :update
- end
- def self.update
- darkGameTimeUpdate
- $game_party.items.each do |item|
- if item
- if item.co_the_het_han
- if $game_time.unlimited_time >= item.time_het_han
- $game_party.gain_item($data_items[item.het_han_item],1)
- $game_party.gain_item(item,-1)
- end
- end
- end
- end
- end
- def self.unlimit_hour
- return $game_time.unlimited_time
- end
- end
- class GameTime::Current_Time
- attr_accessor :unlimited_time
- alias dark_reset_all_values reset_all_values
- def reset_all_values
- dark_reset_all_values
- @unlimited_time = 0
- end
- alias darkaddhour addhour
- def addhour(h)
- @unlimited_time += h
- darkaddhour(h)
- end
- #~ alias darkaddday addday
- #~ def addday(d)
- #~ @unlimited_time += 24
- #~ darkaddday(d)
- #~ end
- #~ alias darkaddmonth addmonth
- #~ def addmonth(mn)
- #~ @unlimited_time += 24*MONTHS[@month] = 0
- #~ darkaddmonth(mn)
- #~ end
- #~ alias darkaddyear addyear
- #~
- #~ def addyear(y)
- #~ @unlimited_time += 24*get_total_day
- #~ darkaddyear(y)
- #~ end
- #~
- #~ def get_total_day
- #~ total = 0
- #~ MONTHS.each do |day|
- #~ total += day
- #~ end
- #~ return total
- #~ end
- end
Advertisement
Add Comment
Please, Sign In to add comment