Advertisement
Dekita

$D13x Equip Requirements v1.4

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