Advertisement
Dekita

$D13x Equip Requirements v1.3

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