Advertisement
Dekita

$D13x Equip Requirements v1.7

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