Advertisement
Dekita

itmlbreak 1.1

Feb 11th, 2013
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.84 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.1
  3. ★ Item Limits™ ★
  4.  
  5. ================================================================================
  6. Script Information:
  7. ====================
  8.  
  9. This is a simple script to enable different max item limits for different items
  10. via notetags.
  11.  
  12. ================================================================================
  13. ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  14. ================================================================================
  15. 1. You must give credit to "Dekita"
  16. 2. You are NOT allowed to repost this script.(or modified versions)
  17. 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
  18. 4. You are NOT allowed to use this script for Commercial games.
  19. 5. ENJOY!
  20.  
  21. "FINE PRINT"
  22. By using this script you hereby agree to the above terms and conditions,
  23. if any violation of the above terms occurs "legal action" may be taken.
  24. Not understanding the above terms and conditions does NOT mean that
  25. they do not apply to you.
  26. If you wish to discuss the terms and conditions in further detail you can
  27. contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com
  28.  
  29. ================================================================================
  30. History:
  31. =========
  32. D /M /Y
  33. 11/o2/2o13 - added script calls to change item limits,(requested by jragyn)
  34. 08/10/2o12 - Started/Finished Script,
  35.  
  36. ================================================================================
  37. INSTRUCTIONS:
  38. ==============
  39. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  40.  
  41. ================================================================================
  42. SCRIPT CALLS:
  43. ==============
  44. $game_party.change_item_limit(item, amount)
  45.  
  46. item must be one of the following
  47. $data_items[item_id]
  48. $data_weapons[item_id]
  49. $data_armors[item_id]
  50.  
  51. i would do this script call like this... ( all in the one script call )
  52.  
  53. item = $data_items[1]
  54. amount = 500000
  55. $game_party.change_item_limit(item, amount)
  56. ================================================================================
  57. =end #######################
  58. # CUSTOMISATION BEGIN #
  59. #######################
  60.  
  61. module Dekita__Item_Amount
  62.  
  63. Default_Limit = 99
  64.  
  65. Notetag = /<max amnt: (.*)>/i
  66.  
  67. end # module Dekita__Item_Amount
  68. #####################
  69. # CUSTOMISATION END #
  70. #####################
  71. #===============================================================================#
  72. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  73. # YES?\.\. #
  74. # OMG, REALLY? #
  75. # WELL SLAP MY FACE AND CALL ME A DRAGON.\..\.. #
  76. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  77. #===============================================================================#
  78.  
  79. $imported = {} if $imported.nil?
  80. $imported["DPB-Item-Limits"] = true
  81.  
  82. #==============================================================================
  83. module DataManager
  84. #==============================================================================
  85.  
  86. class <<self; alias load_database_item_count load_database; end
  87. def self.load_database
  88. load_database_item_count
  89. load_notetags_item_count
  90. end
  91.  
  92. def self.load_notetags_item_count
  93. groups = [$data_weapons, $data_armors, $data_items]
  94. for group in groups
  95. for obj in group
  96. next if obj.nil?
  97. obj.load_notetags_item_count
  98. end
  99. end
  100. end
  101.  
  102. end # DataManager
  103.  
  104. #==============================================================================
  105. class RPG::Item < RPG::UsableItem
  106. #==============================================================================
  107.  
  108. attr_accessor :max_item_amount_DPBz
  109.  
  110. def load_notetags_item_count
  111. @max_item_amount_DPBz = Dekita__Item_Amount::Default_Limit
  112. self.note.split(/[\r\n]+/).each { |line|
  113. case line
  114. when Dekita__Item_Amount::Notetag
  115. @max_item_amount_DPBz = $1.to_i
  116. end
  117. } # self.note.split
  118. end
  119.  
  120.  
  121. end # RPG::Item < RPG::UsableItem
  122.  
  123. #==============================================================================
  124. class RPG::EquipItem < RPG::BaseItem
  125. #==============================================================================
  126.  
  127. attr_accessor :max_item_amount_DPBz
  128.  
  129. def load_notetags_item_count
  130. @max_item_amount_DPBz = Dekita__Item_Amount::Default_Limit
  131. self.note.split(/[\r\n]+/).each { |line|
  132. case line
  133. when Dekita__Item_Amount::Notetag
  134. @max_item_amount_DPBz = $1.to_i
  135. end
  136. } # self.note.split
  137. end
  138.  
  139.  
  140. end # RPG::EquipItem < RPG::BaseItem
  141.  
  142. #==============================================================================
  143. class Game_Party < Game_Unit
  144. #==============================================================================
  145.  
  146. attr_reader :item_limits
  147.  
  148. alias :init_item_limz :initialize
  149. def initialize
  150. init_item_limz
  151. init_item_limits
  152. end
  153.  
  154. def init_item_limits
  155. @item_limits = {}
  156. @item_limits[:items] = [Dekita__Item_Amount::Default_Limit] * 999
  157. @item_limits[:weapons] = [Dekita__Item_Amount::Default_Limit] * 999
  158. @item_limits[:armors] = [Dekita__Item_Amount::Default_Limit] * 999
  159. end
  160.  
  161. def get_item_limits(item = nil)
  162. if item.is_a?(RPG::Item)
  163. @item_limits[:items][item.id] = item.max_item_amount_DPBz
  164. elsif item.is_a?(RPG::Weapon)
  165. @item_limits[:weapons][item.id] = item.max_item_amount_DPBz
  166. elsif item.is_a?(RPG::Armor)
  167. @item_limits[:armors][item.id] = item.max_item_amount_DPBz
  168. end
  169. end
  170.  
  171. def check_item_limit(item)
  172. if item.is_a?(RPG::Item)
  173. return @item_limits[:items][item.id]
  174. elsif item.is_a?(RPG::Weapon)
  175. return @item_limits[:weapons][item.id]
  176. elsif item.is_a?(RPG::Armor)
  177. return @item_limits[:armors][item.id]
  178. end
  179. end
  180.  
  181. def change_item_limit(item, amount)
  182. if item.is_a?(RPG::Item)
  183. @item_limits[:items][item.id] = amount
  184. elsif item.is_a?(RPG::Weapon)
  185. @item_limits[:weapons][item.id] = amount
  186. elsif item.is_a?(RPG::Armor)
  187. @item_limits[:armors][item.id] = amount
  188. end
  189. end
  190.  
  191. alias :gain_itmlimz :gain_item
  192. def gain_item(item, amount, include_equip = false)
  193. get_item_limits(item) if !has_item?(item, include_equip)
  194. gain_itmlimz(item, amount, include_equip = false)
  195. end
  196.  
  197. def max_item_number(item)
  198. return check_item_limit(item)
  199. # return item.max_item_amount_DPBz
  200. end
  201.  
  202. end # end class Game_Party
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement