Advertisement
Dekita

$D13x Equip Requirements v1.2

Mar 26th, 2013
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.90 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # ☆ $D13x - Equipment - Requirements
  4. # -- Author : Dekita
  5. # -- Version : 1.2
  6. # -- Level : Easy
  7. # -- Requires : N/A
  8. # -- Engine : RPG Maker VX Ace.
  9. #
  10. #===============================================================================
  11. # ☆ Import
  12. #-------------------------------------------------------------------------------
  13. $D13x={}if$D13x==nil
  14. $D13x[:Equip_Reqs]=true
  15. #===============================================================================
  16. # ☆ Updates
  17. #-------------------------------------------------------------------------------
  18. # D /M /Y
  19. # 26/o3/2o13 - Compatibility, (Elements Control)
  20. # 23/o3/2o13 - Bugfix, (removing equip when negative HRG/MRG/TRG)
  21. # 21/o3/2o13 - Finished,
  22. # ??/o3/2o13 - Started
  23. #
  24. #===============================================================================
  25. # ☆ Introduction
  26. #-------------------------------------------------------------------------------
  27. # This script enables additional requirements for equipping equipment.
  28. # you are now allowed requirements based on almost all other statistics,
  29. # Such as param / x-param/s-param/atk element rate/def element rate :p
  30. # simply use notetags in the Weapon Notebox !!
  31. #
  32. # Note : all param requirements must be an integer value, eg. 1, 2, 3, 4
  33. # all x/sparam requirements must be a float value, eg. 0.1, 0.5, 1.6
  34. #
  35. #===============================================================================
  36. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  37. #===============================================================================
  38. # 1. You MUST give credit to "Dekita" !!
  39. # 2. You are NOT allowed to repost this script.(or modified versions)
  40. # 3. You are NOT allowed to convert this script.
  41. # 4. You are NOT allowed to use this script for Commercial games.
  42. # 5. ENJOY!
  43. #
  44. # "FINE PRINT"
  45. # By using this script you hereby agree to the above terms and conditions,
  46. # if any violation of the above terms occurs "legal action" may be taken.
  47. # Not understanding the above terms and conditions does NOT mean that
  48. # they do not apply to you.
  49. # If you wish to discuss the terms and conditions in further detail you can
  50. # contact me at http://dekitarpg.wordpress.com/
  51. #
  52. #===============================================================================
  53. # ☆ Instructions
  54. #-------------------------------------------------------------------------------
  55. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  56. #
  57. #===============================================================================
  58. # ☆ Notetags ( default )
  59. # For use in weapons and armor noteboxes !
  60. #-------------------------------------------------------------------------------
  61. # <req stat: value>
  62. # req stat = mhp, mmp, agi, luk, cri ect...
  63. # value = the requirement value for that weapon/armor
  64. # e.g
  65. # <req agi: 4> would make the item un-equipable until the actor has 4 agi
  66. # <req cri: 0.04> item un-equipable until 4% crit rate
  67. #
  68. # you can also use switches, variables and even define your own code for
  69. # requisites using the eval method.
  70. #
  71. # v1.2 introduces the ability to have elemental attack and defence requirements
  72. # IF used with my $D13x Elements Control script.
  73. # The notetags for these requirements are :
  74. # <atk ele req: id, value>
  75. # <def ele req: id, value>
  76. #
  77. #===============================================================================
  78. # ☆ HELP
  79. #-------------------------------------------------------------------------------
  80. # PARAMS :
  81. # mhp, mmp, atk, def, mat, mdf, agi, luk
  82. # XPARAMS
  83. # hit, eva, cri, cev, mev, mrf, cnt, hrg, mrg, trg
  84. # SPARAMS
  85. # tgr, grd, rec, pha, mcr, tcr, pdr, mdr, fdr, exr
  86. #
  87. #-------------------------------------------------------------------------------
  88. # Remember :
  89. # All Params work with integer values, eg. 1, 5, 123, 653, 198123
  90. # All x/s-Params work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01
  91. # All Elemental Values work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01 .
  92. # 1.0 = 100%, 0.01 = 1%,
  93. #
  94. # ALSO:
  95. # You can have multiple switch, variable and eval requirements.
  96. #
  97. #===============================================================================
  98. module Equip_Reqs
  99. #===============================================================================
  100.  
  101. Notes={}#Notetags Customisation
  102. Notes[:lvl] = /<req lvl:(.*)>/i
  103. Notes[:mhp] = /<req mhp:(.*)>/i
  104. Notes[:mmp] = /<req mmp:(.*)>/i
  105. Notes[:atk] = /<req atk:(.*)>/i
  106. Notes[:def] = /<req def:(.*)>/i
  107. Notes[:mat] = /<req mat:(.*)>/i
  108. Notes[:mdf] = /<req mdf:(.*)>/i
  109. Notes[:agi] = /<req agi:(.*)>/i
  110. Notes[:luk] = /<req luk:(.*)>/i
  111. Notes[:hit] = /<req hit:(.*)>/i
  112. Notes[:eva] = /<req eva:(.*)>/i
  113. Notes[:cri] = /<req cri:(.*)>/i
  114. Notes[:cev] = /<req cev:(.*)>/i
  115. Notes[:mev] = /<req mev:(.*)>/i
  116. Notes[:mrf] = /<req mrf:(.*)>/i
  117. Notes[:cnt] = /<req cnt:(.*)>/i
  118. Notes[:hrg] = /<req hrg:(.*)>/i
  119. Notes[:mrg] = /<req mrg:(.*)>/i
  120. Notes[:trg] = /<req trg:(.*)>/i
  121. Notes[:tgr] = /<req tgr:(.*)>/i
  122. Notes[:grd] = /<req grd:(.*)>/i
  123. Notes[:rec] = /<req rec:(.*)>/i
  124. Notes[:pha] = /<req pha:(.*)>/i
  125. Notes[:mcr] = /<req mcr:(.*)>/i
  126. Notes[:tcr] = /<req tcr:(.*)>/i
  127. Notes[:pdr] = /<req pdr:(.*)>/i
  128. Notes[:mdr] = /<req mdr:(.*)>/i
  129. Notes[:fdr] = /<req fdr:(.*)>/i
  130. Notes[:exr] = /<req exr:(.*)>/i
  131. Notes[:var] = /<req variable:(.*),(.*)>/i # <req variable: id, req>
  132. Notes[:swi] = /<req switch:(.*)>/i # <req switch: id>
  133. Notes[:eval]= /<req eval:(.*)>/i # <req eval: 'string of code to be evaluated'>
  134. Notes[:atk_ele]= /<atk ele req:(.*),(.*)>/
  135. Notes[:def_ele]= /<def ele req:(.*),(.*)>/
  136.  
  137. end #####################
  138. # CUSTOMISATION END #
  139. #####################
  140. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  141. # #
  142. # http://dekitarpg.wordpress.com/ #
  143. # #
  144. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  145. #===============================================================================#
  146. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  147. # YES?\.\. #
  148. # OMG, REALLY? \| #
  149. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  150. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  151. #===============================================================================#
  152. if !$D13x[:CORE]
  153. #===============================================================================
  154. module DataManager
  155. #===============================================================================
  156. #---------------------------------------------------------------------------
  157. # Alias List
  158. #---------------------------------------------------------------------------
  159. class << self
  160. alias :lbd_unique_eqpreq :load_database
  161. end
  162. #---------------------------------------------------------------------------
  163. # Load Database (alias)
  164. #---------------------------------------------------------------------------
  165. def self.load_database
  166. lbd_unique_eqpreq
  167. loa_unique_eqpreq
  168. end
  169. #---------------------------------------------------------------------------
  170. # Load Unique Shit
  171. #---------------------------------------------------------------------------
  172. def self.loa_unique_eqpreq
  173. classes = [$data_weapons, $data_armors]
  174. for g in classes
  175. for o in g
  176. next if o == nil
  177. o.load_equip_reqz
  178. end
  179. end
  180. end
  181.  
  182. end # DataManager
  183. end # if $D13x[:CORE]
  184.  
  185. #===============================================================================
  186. class RPG::EquipItem < RPG::BaseItem
  187. #===============================================================================
  188. #---------------------------------------------------------------------------
  189. # Alias List
  190. #---------------------------------------------------------------------------
  191. alias :deki_equip_reqz :load_unique_shit if $D13x[:CORE]
  192. #---------------------------------------------------------------------------
  193. # Pi Variables
  194. #---------------------------------------------------------------------------
  195. attr_accessor :level_req
  196. attr_accessor :param_req
  197. attr_accessor :xpars_req
  198. attr_accessor :spars_req
  199. attr_accessor :varis_req
  200. attr_accessor :swtch_req
  201. attr_accessor :evals_req
  202. attr_accessor :atk_ele_req
  203. attr_accessor :def_ele_req
  204. #---------------------------------------------------------------------------
  205. # Load Unique Shit
  206. #---------------------------------------------------------------------------
  207. def load_unique_shit
  208. deki_equip_reqz if $D13x[:CORE]
  209. load_equip_reqz
  210. end
  211. #---------------------------------------------------------------------------
  212. # Load Equip Requirements
  213. #---------------------------------------------------------------------------
  214. def load_equip_reqz
  215. @level_req = 0
  216. @param_req = [0] * 8
  217. @xpars_req = [0] * 10
  218. @spars_req = [0] * 10
  219. @varis_req = []
  220. @swtch_req = []
  221. @evals_req = []
  222. @atk_ele_req = [-2.0] * $data_system.elements.size
  223. @def_ele_req = [-2.0] * $data_system.elements.size
  224. 3.times {|i| @xpars_req[i+7] = -1.0 }
  225. self.note.split(/[\r\n]+/).each do |line|
  226. case line
  227. when Equip_Reqs::Notes[:lvl] then @level_req = $1.to_i
  228. when Equip_Reqs::Notes[:mhp] then @param_req[0] = $1.to_i
  229. when Equip_Reqs::Notes[:mmp] then @param_req[1] = $1.to_i
  230. when Equip_Reqs::Notes[:atk] then @param_req[2] = $1.to_i
  231. when Equip_Reqs::Notes[:def] then @param_req[3] = $1.to_i
  232. when Equip_Reqs::Notes[:mat] then @param_req[4] = $1.to_i
  233. when Equip_Reqs::Notes[:mdf] then @param_req[5] = $1.to_i
  234. when Equip_Reqs::Notes[:agi] then @param_req[6] = $1.to_i
  235. when Equip_Reqs::Notes[:luk] then @param_req[7] = $1.to_i
  236. when Equip_Reqs::Notes[:hit] then @xpars_req[0] = $1.to_f
  237. when Equip_Reqs::Notes[:eva] then @xpars_req[1] = $1.to_f
  238. when Equip_Reqs::Notes[:cri] then @xpars_req[2] = $1.to_f
  239. when Equip_Reqs::Notes[:cev] then @xpars_req[3] = $1.to_f
  240. when Equip_Reqs::Notes[:mev] then @xpars_req[4] = $1.to_f
  241. when Equip_Reqs::Notes[:mrf] then @xpars_req[5] = $1.to_f
  242. when Equip_Reqs::Notes[:cnt] then @xpars_req[6] = $1.to_f
  243. when Equip_Reqs::Notes[:hrg] then @xpars_req[7] = $1.to_f
  244. when Equip_Reqs::Notes[:mrg] then @xpars_req[6] = $1.to_f
  245. when Equip_Reqs::Notes[:trg] then @xpars_req[7] = $1.to_f
  246. when Equip_Reqs::Notes[:tgr] then @spars_req[0] = $1.to_f
  247. when Equip_Reqs::Notes[:grd] then @spars_req[1] = $1.to_f
  248. when Equip_Reqs::Notes[:rec] then @spars_req[2] = $1.to_f
  249. when Equip_Reqs::Notes[:pha] then @spars_req[3] = $1.to_f
  250. when Equip_Reqs::Notes[:mcr] then @spars_req[4] = $1.to_f
  251. when Equip_Reqs::Notes[:tcr] then @spars_req[5] = $1.to_f
  252. when Equip_Reqs::Notes[:pdr] then @spars_req[6] = $1.to_f
  253. when Equip_Reqs::Notes[:mdr] then @spars_req[7] = $1.to_f
  254. when Equip_Reqs::Notes[:fdr] then @spars_req[6] = $1.to_f
  255. when Equip_Reqs::Notes[:exr] then @spars_req[7] = $1.to_f
  256. when Equip_Reqs::Notes[:swi] then @swtch_req << $1.to_i
  257. when Equip_Reqs::Notes[:var] then @varis_req << [$1.to_i,$2.to_i]
  258. when Equip_Reqs::Notes[:eval] then @evals_req << $1.to_s
  259. when Equip_Reqs::Notes[:atk_ele] then @atk_ele_req[$1.to_i] = $2.to_f
  260. when Equip_Reqs::Notes[:def_ele] then @def_ele_req[$1.to_i] = $2.to_f
  261. end
  262. end
  263. end
  264.  
  265. end # RPG::EquipItem
  266.  
  267. #===============================================================================
  268. class Game_BattlerBase
  269. #===============================================================================
  270. #---------------------------------------------------------------------------
  271. # Alias List
  272. #---------------------------------------------------------------------------
  273. alias :equip_reqz :equippable?
  274. #---------------------------------------------------------------------------
  275. # Can Be Equipped ?
  276. #---------------------------------------------------------------------------
  277. def equippable?(item)
  278. return false unless item.is_a?(RPG::EquipItem)
  279. return false if @level < item.level_req
  280. return false if param(0) < item.param_req[0]
  281. return false if param(1) < item.param_req[1]
  282. return false if param(2) < item.param_req[2]
  283. return false if param(3) < item.param_req[3]
  284. return false if param(4) < item.param_req[4]
  285. return false if param(5) < item.param_req[5]
  286. return false if param(6) < item.param_req[6]
  287. return false if param(7) < item.param_req[7]
  288. return false if xparam(0) < item.xpars_req[0]
  289. return false if xparam(1) < item.xpars_req[1]
  290. return false if xparam(2) < item.xpars_req[2]
  291. return false if xparam(3) < item.xpars_req[3]
  292. return false if xparam(4) < item.xpars_req[4]
  293. return false if xparam(5) < item.xpars_req[5]
  294. return false if xparam(6) < item.xpars_req[6]
  295. return false if xparam(7) < item.xpars_req[7]
  296. return false if xparam(8) < item.xpars_req[8]
  297. return false if xparam(9) < item.xpars_req[9]
  298. return false if sparam(0) < item.spars_req[0]
  299. return false if sparam(1) < item.spars_req[1]
  300. return false if sparam(2) < item.spars_req[2]
  301. return false if sparam(3) < item.spars_req[3]
  302. return false if sparam(4) < item.spars_req[4]
  303. return false if sparam(5) < item.spars_req[5]
  304. return false if sparam(6) < item.spars_req[6]
  305. return false if sparam(7) < item.spars_req[7]
  306. return false if sparam(8) < item.spars_req[8]
  307. return false if sparam(9) < item.spars_req[9]
  308. item.swtch_req.each do |switch|
  309. return false if !$game_switches[ switch ]
  310. end
  311. item.varis_req.each do |vari|
  312. return false if $game_variables[ vari[0] ] < (vari[1]).to_i
  313. end
  314. item.evals_req.each do |evl|
  315. return false if !eval( evl )
  316. end
  317. if $D13x[:Elems_Control]
  318. $data_system.elements.size.times do |i|
  319. return false if element_rate(i) < item.def_ele_req[i]
  320. return false if atk_element_rate(i) < item.atk_ele_req[i]
  321. end
  322. end
  323. return equip_reqz(item)
  324. end
  325.  
  326. end # class Game_BattlerBase
  327. #==============================================================================#
  328. # http://dekitarpg.wordpress.com/ #
  329. #==============================================================================#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement