Advertisement
Dekita

Perfect equip requirements v1.1

Sep 20th, 2012
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.96 KB | None | 0 0
  1. =begin =========================================================================
  2. Dekita's v1.1
  3. ★ Perfect Equip Requirements™ ★
  4.  
  5. ===============================================================================
  6. ☆ Script Information:
  7. =======================
  8. A simple equipment requirements script, enter notetags into weapon/armor
  9. noteboxes to make item unequippable unless requirements are met.
  10. list of possible requirements is in the customisation.
  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. 19/09/2o12 - Added notetag customisation,
  34. Added atl/dfl requirements,
  35. Improved methods,
  36. 22/08/2o12 - Started and finished.
  37.  
  38. ===============================================================================
  39. ☆ Credit and Thanks to :
  40. ==========================
  41. Fomar0153 - for writing an equip requirements script and showing me how its done.
  42.  
  43. ===============================================================================
  44. ☆ INSTRUCTIONS:
  45. =================
  46. Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
  47.  
  48. ===============================================================================
  49. ☆ NoteTagz:
  50. =============
  51. e.g <reqlvl: 5>
  52. This would make the item unequippable until the actor is level 5.
  53. full list of notetags below.
  54.  
  55. =end #==========================================================================
  56. module DPB ; module EQUIPREQZ
  57. #######################
  58. # CUSTOMISATION BEGIN #
  59. #######################
  60.  
  61. # Here is some customisation for what you type into the notetags
  62. # /<INSERT YOUR NOTETAG VOCAB LIKE THIS: (.*)>/i
  63.  
  64. # <reqlvl: x>
  65. REQ_LVL_NOTE = /<reqlvl: (.*)>/i
  66.  
  67.  
  68. # These notetags require Dekita's - Perfect Stat Point Distribution System
  69.  
  70. # <reqvit: x>
  71. REQ_VIT_NOTE = /<reqvit: (.*)>/i
  72. # <reqstr: x>
  73. REQ_STR_NOTE = /<reqstr: (.*)>/i
  74. # <reqdex: x>
  75. REQ_DEX_NOTE = /<reqdex: (.*)>/i
  76. # <reqmag: x>
  77. REQ_MAG_NOTE = /<reqmag: (.*)>/i
  78.  
  79.  
  80. # These notetags require Dekita's - Perfect Attack and Defence Levels
  81.  
  82. # <reqatl: x>
  83. REQ_ATL_NOTE = /<reqatl: (.*)>/i
  84. # <reqdfl: x>
  85. REQ_DFL_NOTE = /<reqdfl: (.*)>/i
  86.  
  87. #####################
  88. # CUSTOMISATION END #
  89. end ; end #module #####################
  90. #===============================================================================
  91. # ☆ Import:
  92. #===========
  93. $imported = {} if $imported.nil?
  94. $imported["DPB-PEQUIP"] = true
  95. #===============================================================================
  96.  
  97. module DPB ; module REGEXP ; module EQUIPITEM
  98.  
  99. REQ_LVL = DPB::EQUIPREQZ::REQ_LVL_NOTE
  100. REQ_VIT = DPB::EQUIPREQZ::REQ_VIT_NOTE
  101. REQ_STR = DPB::EQUIPREQZ::REQ_STR_NOTE
  102. REQ_DEX = DPB::EQUIPREQZ::REQ_DEX_NOTE
  103. REQ_MAG = DPB::EQUIPREQZ::REQ_MAG_NOTE
  104. REQ_ATL = DPB::EQUIPREQZ::REQ_ATL_NOTE
  105. REQ_DFL = DPB::EQUIPREQZ::REQ_DFL_NOTE
  106.  
  107. end ; end ; end # USEABLEITEMDAMAGE ; REGEXP ; DPB
  108.  
  109. #==============================================================================
  110. module DataManager
  111. #==============================================================================
  112.  
  113. class <<self; alias load_database_req_dpbz load_database; end
  114. def self.load_database
  115. load_database_req_dpbz
  116. load_notetags_req_dpbz
  117. end
  118.  
  119. def self.load_notetags_req_dpbz
  120. groups = [$data_weapons, $data_armors]
  121. for group in groups
  122. for obj in group
  123. next if obj.nil?
  124. obj.load_notetags_req_dpbz
  125. end
  126. end
  127. end
  128.  
  129. end # DataManager
  130.  
  131. #==============================================================================
  132. class RPG::EquipItem < RPG::BaseItem
  133. #==============================================================================
  134.  
  135. attr_accessor :lvlreq
  136. attr_accessor :vitreq
  137. attr_accessor :strreq
  138. attr_accessor :dexreq
  139. attr_accessor :magreq
  140. attr_accessor :atlreq
  141. attr_accessor :dflreq
  142.  
  143. def load_notetags_req_dpbz
  144. @lvlreq = 0
  145. @vitreq = 0
  146. @strreq = 0
  147. @dexreq = 0
  148. @magreq = 0
  149. @atlreq = 0
  150. @dflreq = 0
  151. self.note.split(/[\r\n]+/).each { |line|
  152. case line
  153. when DPB::REGEXP::EQUIPITEM::REQ_LVL
  154. @lvlreq = $1.to_i
  155. when DPB::REGEXP::EQUIPITEM::REQ_VIT
  156. @vitreq = $1.to_i if $imported["DPB-PSPDS"]
  157. when DPB::REGEXP::EQUIPITEM::REQ_STR
  158. @strreq = $1.to_i if $imported["DPB-PSPDS"]
  159. when DPB::REGEXP::EQUIPITEM::REQ_DEX
  160. @dexreq = $1.to_i if $imported["DPB-PSPDS"]
  161. when DPB::REGEXP::EQUIPITEM::REQ_MAG
  162. @magreq = $1.to_i if $imported["DPB-PSPDS"]
  163. when DPB::REGEXP::EQUIPITEM::REQ_ATL
  164. @atlreq = $1.to_i if $imported["DPB-ATLANDDFL"]
  165. when DPB::REGEXP::EQUIPITEM::REQ_DFL
  166. @dflreq = $1.to_i if $imported["DPB-ATLANDDFL"]
  167. end
  168. } # self.note.split
  169. end
  170.  
  171. end # RPG::EquipItem
  172.  
  173. #==============================================================================
  174. class Game_BattlerBase
  175. #==============================================================================
  176.  
  177. alias dpbzequippable? equippable?
  178. def equippable?(item)
  179. return false unless item.is_a?(RPG::EquipItem)
  180. return false if @level < item.lvlreq
  181. return false if reqdpbzstat(0) < item.vitreq if $imported["DPB-PSPDS"]
  182. return false if reqdpbzstat(1) < item.strreq if $imported["DPB-PSPDS"]
  183. return false if reqdpbzstat(2) < item.dexreq if $imported["DPB-PSPDS"]
  184. return false if reqdpbzstat(3) < item.magreq if $imported["DPB-PSPDS"]
  185. return false if reqdpbzformz(0) < item.atlreq if $imported["DPB-ATLANDDFL"]
  186. return false if reqdpbzformz(1) < item.dflreq if $imported["DPB-ATLANDDFL"]
  187. return dpbzequippable?(item)
  188. end
  189.  
  190. def reqdpbzstat(id)
  191. return unless $imported["DPB-PSPDS"]
  192. return dpbzparam(id)
  193. end
  194.  
  195. def reqdpbzformz(id)
  196. return unless $imported["DPB-ATLANDDFL"]
  197. return dpbzformulaz(id)
  198. end
  199.  
  200. end # class Game_BattlerBase
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement