Advertisement
Dekita

$D13x - Skill Requirements v1.9

May 30th, 2013
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.18 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Learn Skill Requirements
  5. # -- Author : Dekita
  6. # -- Version : 1.9
  7. # -- Level : Easy / Normal
  8. # -- Requires : $D13x - Statistic Control
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:Skill_Reqs]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 22/o5/2o13 - Small Temp Bugfix, (constant reducing exp)
  21. # 21/o5/2o13 - Compatability, ($D13x ISPDS)
  22. # 2o/o5/2o13 - Compatability, ($D13x Atk & Def Lvs)
  23. # 19/o5/2o13 - Small Re-write, (v1.6 details below)
  24. # 17/o5/2o13 - Small Update,
  25. # 14/o5/2o13 - Update, (Skill/Skill Level Requirements)
  26. # - Bugfix, (eval notetag)
  27. # 26/o3/2o13 - Compatibility, (Elements Control)
  28. # 23/o3/2o13 - Bugfix, (forgetting skills when negative HRG/MRG/TRG)
  29. # 21/o3/2o13 - Fixed typo in notetag info section,
  30. # 13/o3/2o13 - Finished,
  31. # 1o/o3/2o13 - Started
  32. #
  33. #===============================================================================
  34. # ☆ Introduction
  35. #-------------------------------------------------------------------------------
  36. # This script enables additional requirements for learning skills.
  37. # other than the default level requirement, you are now allowed
  38. # requirements based on almost all other statistics,
  39. # Such as param / x-param / s-param / atk element rate / def element rate :p
  40. # simply use notetags in the CLASS Skill Learn Notebox !!
  41. #
  42. # You can also allow for skills to be forgotten if the requirements
  43. # are no longer met.
  44. # eg. removed equipment / leveled down ...
  45. #
  46. # Note : all param requirements must be an integer value, eg. 1, 2, 3, 4
  47. # all x/sparam requirements must be a float value, eg. 0.1, 0.5, 1.6
  48. #
  49. # v1.6+ completely changes the frequency of which skills are learned,
  50. # instead of skills being learned/forgot upon level up/down,
  51. # they are now refreshed constantly (every few seconds)
  52. # This is to enable skills being learned as soon as their requirements are met,
  53. # and forgotten as soon as they are not.
  54. # Also added a FPS fix for this feature, as constantly checking params/xparams
  55. # sparams/atk ele/def ele causes SEVERE FPS drop (60 > 52(ish) every few seconds)
  56. #
  57. #===============================================================================
  58. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  59. #===============================================================================
  60. # 1. You MUST give credit to "Dekita" !!
  61. # 2. You are NOT allowed to repost this script.(or modified versions)
  62. # 3. You are NOT allowed to convert this script.
  63. # 4. You are NOT allowed to use this script for Commercial games.
  64. # 5. ENJOY!
  65. #
  66. # "FINE PRINT"
  67. # By using this script you hereby agree to the above terms and conditions,
  68. # if any violation of the above terms occurs "legal action" may be taken.
  69. # Not understanding the above terms and conditions does NOT mean that
  70. # they do not apply to you.
  71. # If you wish to discuss the terms and conditions in further detail you can
  72. # contact me at http://dekitarpg.wordpress.com/
  73. #
  74. #===============================================================================
  75. # ☆ Instructions
  76. #-------------------------------------------------------------------------------
  77. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  78. # Place Under My $D13x - Staistic Control Script.
  79. #
  80. #===============================================================================
  81. # ☆ Notetags ( default )
  82. # For use with Class Skill Learn noteboxes only !
  83. #-------------------------------------------------------------------------------
  84. # <stat req: value>
  85. # stat req = mhp, mmp, agi, luk, cri ect...
  86. # value = the value for that skill, for that class
  87. # e.g
  88. # <agi req: 4> would make the skill unlearnable until the actor has 4 agi
  89. # <cri req: 0.04> unlearnable until 4% crit rate
  90. #
  91. # you can also use switches, variables and even define your own code for
  92. # requisites using the eval method.
  93. #
  94. # v1.2 introduces the ability to have elemental attack and defence requirements
  95. # IF used with my $D13x Elements Control script.
  96. # The notetags for these requirements are :
  97. # <atk ele req: id, value>
  98. # <def ele req: id, value>
  99. #
  100. # v1.3 introduces the ability to have skill / skill level requirements.
  101. # eg.. need skill 5 before learning skill 6
  102. # or need skill 6 @ level 10 before learning skill 7 ect..
  103. # This could of course be done by using the <eval: X> notetag like this...
  104. # <eval req: skills_lv(6) < 10 > (TESTED and works 100%)
  105. #
  106. # NOTE:
  107. # eval notetag return FALSE if eval condition is TRUE,
  108. # eg.. the above notetag would return false if the skill 6's level is < 10
  109. #
  110. # you could also do things like equip requirements or actor name requirements
  111. # or playtime requirements or whatever by using the eval notetag,
  112. # this, of course, requires basic scripting knowledge.
  113. #
  114. #===============================================================================
  115. # ☆ HELP
  116. #-------------------------------------------------------------------------------
  117. # PARAMS :
  118. # mhp, mmp, atk, def, mat, mdf, agi, luk
  119. # XPARAMS
  120. # hit, eva, cri, cev, mev, mrf, cnt, hrg, mrg, trg
  121. # SPARAMS
  122. # tgr, grd, rec, pha, mcr, tcr, pdr, mdr, fdr, exr
  123. #
  124. #-------------------------------------------------------------------------------
  125. # Remember :
  126. # All Params work with integer values, eg. 1, 5, 123, 653, 198123 .
  127. # All x/s-Params work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01 .
  128. # All Elemental Values work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01 .
  129. # 1.0 = 100%, 0.01 = 1%,
  130. #
  131. # ALSO:
  132. # If you want to have multiple requirements for learning skills,
  133. # simply seperate the notetags with \n
  134. # this will trigger a new note to be read :)
  135. #===============================================================================
  136. module Skill_Reqz
  137. #===============================================================================
  138.  
  139. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  140. # ☆ General Settings
  141. #--------------------------------------------------------------------------
  142. # Remove skills if requirement are no longer met.
  143. Remove_Skills = false
  144.  
  145. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  146. # ☆ Notetag Settings
  147. #--------------------------------------------------------------------------
  148. Notes={}
  149. Notes[:mhp] = /<mhp req:(.*)>/i
  150. Notes[:mmp] = /<mmp req:(.*)>/i
  151. Notes[:atk] = /<atk req:(.*)>/i
  152. Notes[:def] = /<def req:(.*)>/i
  153. Notes[:mat] = /<mat req:(.*)>/i
  154. Notes[:mdf] = /<mdf req:(.*)>/i
  155. Notes[:agi] = /<agi req:(.*)>/i
  156. Notes[:luk] = /<luk req:(.*)>/i
  157. Notes[:hit] = /<hit req:(.*)>/i
  158. Notes[:eva] = /<eva req:(.*)>/i
  159. Notes[:cri] = /<cri req:(.*)>/i
  160. Notes[:cev] = /<cev req:(.*)>/i
  161. Notes[:mev] = /<mev req:(.*)>/i
  162. Notes[:mrf] = /<mrf req:(.*)>/i
  163. Notes[:cnt] = /<cnt req:(.*)>/i
  164. Notes[:hrg] = /<hrg req:(.*)>/i
  165. Notes[:mrg] = /<mrg req:(.*)>/i
  166. Notes[:trg] = /<trg req:(.*)>/i
  167. Notes[:tgr] = /<tgr req:(.*)>/i
  168. Notes[:grd] = /<grd req:(.*)>/i
  169. Notes[:rec] = /<rec req:(.*)>/i
  170. Notes[:pha] = /<pha req:(.*)>/i
  171. Notes[:mcr] = /<mcr req:(.*)>/i
  172. Notes[:tcr] = /<tcr req:(.*)>/i
  173. Notes[:pdr] = /<pdr req:(.*)>/i
  174. Notes[:mdr] = /<mdr req:(.*)>/i
  175. Notes[:fdr] = /<fdr req:(.*)>/i
  176. Notes[:exr] = /<exr req:(.*)>/i
  177. Notes[:swi] = /<switch req:(.*)>/i # <switch req: switch_id>
  178. Notes[:var] = /<variable req:(.*),(.*)>/i # <variable req: vari_id, value>
  179. Notes[:eval]= /<eval req:(.*)>/i # <eval req: 'string of code to be evaluated'>
  180. Notes[:atk_ele]= /<atk ele req:(.*),(.*)>/
  181. Notes[:def_ele]= /<def ele req:(.*),(.*)>/
  182. Notes[:atk_lvl]= /<atk lvl req:(.*)>/
  183. Notes[:def_lvl]= /<def lvl req:(.*)>/
  184. Notes[:skills] = [/<skill req:(.*),(.*)>/i,/<skill req:(.*)>/i]
  185. Notes[:spds_stat] = /<spds stat req:(.*),(.*)>/i # <spds stat req: stat id, val>
  186.  
  187. #####################
  188. # CUSTOMISATION END #
  189. end #####################
  190. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  191. # #
  192. # http://dekitarpg.wordpress.com/ #
  193. # #
  194. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  195. # The following code is protected under the 2013 Dekita Data Protection Act. #
  196. # Ie. The “Do Not Fucking Look” Law. #
  197. # Breaking This One And Only Rule WILL Result in SEVERE BRAIN FREEZE. #
  198. # That is all ! #
  199. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  200. #===============================================================================
  201. module DataManager
  202. #===============================================================================
  203. #--------------------------------------------------------------------------
  204. # Alias List
  205. #--------------------------------------------------------------------------
  206. class << self
  207. alias :load_database_skillreqz :load_database
  208. end
  209. #--------------------------------------------------------------------------
  210. # Load Database
  211. #--------------------------------------------------------------------------
  212. def self.load_database
  213. load_database_skillreqz
  214. load_notetags_skillreqz
  215. end
  216. #--------------------------------------------------------------------------
  217. # Load Notetags
  218. #--------------------------------------------------------------------------
  219. def self.load_notetags_skillreqz
  220. for obj in $data_classes
  221. next if obj.nil?
  222. obj.load_skill_requirements
  223. end
  224. end
  225.  
  226. end # DataManager
  227.  
  228. #===============================================================================
  229. class RPG::Class < RPG::BaseItem
  230. #===============================================================================
  231. #--------------------------------------------------------------------------
  232. # Load All Learnable Skills Requirements
  233. #--------------------------------------------------------------------------
  234. def load_skill_requirements
  235. @learnings.each { |l| l.load_skill_requirements }
  236. end
  237.  
  238. end # RPG::Class
  239.  
  240. #===============================================================================
  241. class RPG::Class::Learning
  242. #===============================================================================
  243. #--------------------------------------------------------------------------
  244. # Pi Variables
  245. #--------------------------------------------------------------------------
  246. attr_accessor :param_req
  247. attr_accessor :xpars_req
  248. attr_accessor :spars_req
  249. attr_accessor :swtch_req
  250. attr_accessor :varis_req
  251. attr_accessor :evals_req
  252. attr_accessor :atk_ele_req
  253. attr_accessor :def_ele_req
  254. attr_accessor :atl_dfl_req
  255. attr_accessor :skill_req
  256. attr_accessor :spds_stats_req
  257. #--------------------------------------------------------------------------
  258. # Load All Skill Requirements
  259. #--------------------------------------------------------------------------
  260. def load_skill_requirements
  261. @param_req = [0] * 8
  262. @xpars_req = [0] * 10
  263. @spars_req = [0] * 10
  264. @swtch_req = []
  265. @varis_req = []
  266. @evals_req = []
  267. @skill_req = []
  268. @atk_ele_req = [-2.0] * $data_system.elements.size
  269. @def_ele_req = [-2.0] * $data_system.elements.size
  270. @atl_dfl_req = [0] * 2
  271. @spds_stats_req = [0] * 8
  272. @spds_stats_req = [0] * SPDS::Commands.size if $D13x[:ISPDS]
  273. 3.times {|i| @xpars_req[i+7] = -1.0 }
  274. self.note.split(/\\n/i).each do |line|
  275. case line
  276. when Skill_Reqz::Notes[:mhp] then @param_req[0] = $1.to_i
  277. when Skill_Reqz::Notes[:mmp] then @param_req[1] = $1.to_i
  278. when Skill_Reqz::Notes[:atk] then @param_req[2] = $1.to_i
  279. when Skill_Reqz::Notes[:def] then @param_req[3] = $1.to_i
  280. when Skill_Reqz::Notes[:mat] then @param_req[4] = $1.to_i
  281. when Skill_Reqz::Notes[:mdf] then @param_req[5] = $1.to_i
  282. when Skill_Reqz::Notes[:agi] then @param_req[6] = $1.to_i
  283. when Skill_Reqz::Notes[:luk] then @param_req[7] = $1.to_i
  284. when Skill_Reqz::Notes[:hit] then @xpars_req[0] = $1.to_f
  285. when Skill_Reqz::Notes[:eva] then @xpars_req[1] = $1.to_f
  286. when Skill_Reqz::Notes[:cri] then @xpars_req[2] = $1.to_f
  287. when Skill_Reqz::Notes[:cev] then @xpars_req[3] = $1.to_f
  288. when Skill_Reqz::Notes[:mev] then @xpars_req[4] = $1.to_f
  289. when Skill_Reqz::Notes[:mrf] then @xpars_req[5] = $1.to_f
  290. when Skill_Reqz::Notes[:cnt] then @xpars_req[6] = $1.to_f
  291. when Skill_Reqz::Notes[:hrg] then @xpars_req[7] = $1.to_f
  292. when Skill_Reqz::Notes[:mrg] then @xpars_req[6] = $1.to_f
  293. when Skill_Reqz::Notes[:trg] then @xpars_req[7] = $1.to_f
  294. when Skill_Reqz::Notes[:tgr] then @spars_req[0] = $1.to_f
  295. when Skill_Reqz::Notes[:grd] then @spars_req[1] = $1.to_f
  296. when Skill_Reqz::Notes[:rec] then @spars_req[2] = $1.to_f
  297. when Skill_Reqz::Notes[:pha] then @spars_req[3] = $1.to_f
  298. when Skill_Reqz::Notes[:mcr] then @spars_req[4] = $1.to_f
  299. when Skill_Reqz::Notes[:tcr] then @spars_req[5] = $1.to_f
  300. when Skill_Reqz::Notes[:pdr] then @spars_req[6] = $1.to_f
  301. when Skill_Reqz::Notes[:mdr] then @spars_req[7] = $1.to_f
  302. when Skill_Reqz::Notes[:fdr] then @spars_req[6] = $1.to_f
  303. when Skill_Reqz::Notes[:exr] then @spars_req[7] = $1.to_f
  304. when Skill_Reqz::Notes[:swi] then @swtch_req << $1.to_i
  305. when Skill_Reqz::Notes[:var] then @varis_req << [$1.to_i,$2.to_i]
  306. when Skill_Reqz::Notes[:eval] then @evals_req << $1.to_s
  307. when Skill_Reqz::Notes[:atk_ele] then @atk_ele_req[$1.to_i] = $2.to_f
  308. when Skill_Reqz::Notes[:def_ele] then @def_ele_req[$1.to_i] = $2.to_f
  309. when Skill_Reqz::Notes[:atk_lvl] then @atl_dfl_req[0] = $1.to_f
  310. when Skill_Reqz::Notes[:def_lvl] then @atl_dfl_req[1] = $1.to_f
  311. when Skill_Reqz::Notes[:skills][0] then @skill_req << [$1.to_i, $2.to_i]
  312. when Skill_Reqz::Notes[:skills][1] then @skill_req << [$1.to_i, 1]
  313. when Skill_Reqz::Notes[:spds_stat] then @spds_stats_req[$1.to_i] = $2.to_i
  314. end
  315. end
  316. end
  317.  
  318. end # RPG::Class::Learning
  319.  
  320. #===============================================================================
  321. class Game_BattlerBase
  322. #===============================================================================
  323. #--------------------------------------------------------------------------
  324. # Alias List
  325. #--------------------------------------------------------------------------
  326. alias :sd13x_FPS_fixx_II :initialize
  327. alias :param_FPS_fix_II :param
  328. alias :xparam_FPS_fix_II :xparam if $D13x[:Stats_Control]
  329. alias :sparam_FPS_fix_II :sparam if $D13x[:Stats_Control]
  330. alias :atk_ele_FPS_fix_II :atk_element_rate if $D13x[:Elems_Control]
  331. alias :def_ele_FPS_fix_II :element_rate if $D13x[:Elems_Control]
  332. #--------------------------------------------------------------------------
  333. # Initialize Data
  334. #--------------------------------------------------------------------------
  335. def initialize
  336. @param_fix_II = [0] * 8
  337. @xparam_fix_II = [0] * 10
  338. @sparam_fix_II = [0] * 10
  339. @def_ele_fix_II = [0] * $data_system.elements.size
  340. @atk_ele_fix_II = [0] * $data_system.elements.size
  341. sd13x_FPS_fixx_II
  342. end
  343. #--------------------------------------------------------------------------
  344. # Get Parameter
  345. #--------------------------------------------------------------------------
  346. def param(param_id)
  347. @param_fix_II[param_id] = param_FPS_fix_II(param_id)
  348. @param_fix_II[param_id]
  349. end
  350. if $D13x[:Stats_Control]
  351. #--------------------------------------------------------------------------
  352. # Get Ex-Parameter
  353. #--------------------------------------------------------------------------
  354. def xparam(xparam_id)
  355. @xparam_fix_II[xparam_id] = xparam_FPS_fix_II(xparam_id)
  356. @xparam_fix_II[xparam_id]
  357. end
  358. #--------------------------------------------------------------------------
  359. # Get Sp-Parameter
  360. #--------------------------------------------------------------------------
  361. def sparam(sparam_id)
  362. @sparam_fix_II[sparam_id] = sparam_FPS_fix_II(sparam_id)
  363. @sparam_fix_II[sparam_id]
  364. end
  365. end
  366. if $D13x[:Elems_Control]
  367. #--------------------------------------------------------------------------
  368. # Get Def Element Rate
  369. #--------------------------------------------------------------------------
  370. def element_rate(element_id)
  371. @def_ele_fix_II[element_id] = def_ele_FPS_fix_II(element_id)
  372. @def_ele_fix_II[element_id]
  373. end
  374. #--------------------------------------------------------------------------
  375. # Get Atk Element Rate
  376. #--------------------------------------------------------------------------
  377. def atk_element_rate(element_id)
  378. @atk_ele_fix_II[element_id] = atk_ele_FPS_fix_II(element_id)
  379. @atk_ele_fix_II[element_id]
  380. end
  381. end
  382.  
  383. end # class Game_BattlerBase
  384.  
  385. #===============================================================================
  386. class Game_Actor < Game_Battler
  387. #===============================================================================
  388. #--------------------------------------------------------------------------
  389. # Alias List
  390. #--------------------------------------------------------------------------
  391. alias :refresh_SKILL_DATA :refresh
  392. alias :lv_dwn_xtra_reqzz__sD13x :lv_down_extra
  393. alias :ls_reqzz__sD13x :learn_skill_conditions_met?
  394. #--------------------------------------------------------------------------
  395. # Refresh
  396. #--------------------------------------------------------------------------
  397. def refresh
  398. refresh_SKILL_DATA
  399. check_skill_data
  400. end
  401. #--------------------------------------------------------------------------
  402. # Check Skills Data
  403. #--------------------------------------------------------------------------
  404. def check_skill_data
  405. skill = skills.clone
  406. self.class.learnings.each do |lning|
  407. can_learn = learn_skill_conditions_met?(lning)
  408. if Skill_Reqz::Remove_Skills && (can_learn == false)
  409. forget_skill(lning.skill_id)
  410. end
  411. learn_skill( lning.skill_id) if can_learn
  412. end
  413. if skill != skills
  414. new_skills = (skills - skill)
  415. new_skills.each do |skll|
  416. $game_message.add(sprintf(Vocab::ObtainSkill, skll.name))
  417. end
  418. old_skills = (skill - skills)
  419. old_skills.each do |skll|
  420. $game_message.add(sprintf(Vocab::ForgetSkill, skll.name))
  421. end
  422. end
  423. end
  424. #--------------------------------------------------------------------------
  425. # Get Learning Skill Conditions
  426. #--------------------------------------------------------------------------
  427. def learn_skill_conditions_met?(learning, mult = 1.0 )
  428. 8.times do |i|
  429. return false if @param_fix_II[i] < (learning.param_req[i] * mult).to_i
  430. end
  431. if $D13x[:Stats_Control]
  432. 10.times do |i|
  433. return false if @xparam_fix_II[i] < (learning.xpars_req[i] * mult).to_f
  434. return false if @sparam_fix_II[i] < (learning.spars_req[i] * mult).to_f
  435. end
  436. end
  437. learning.swtch_req.each do |switch|
  438. return false if !$game_switches[ switch ]
  439. end
  440. learning.varis_req.each do |vari|
  441. return false if $game_variables[ vari[0] ] < (vari[1] * mult).to_i
  442. end
  443. learning.evals_req.each do |evl|
  444. return false if eval( evl.to_s )
  445. end
  446. if $D13x[:Elems_Control]
  447. $data_system.elements.size.times do |i|
  448. return false if @def_ele_fix_II[i] < learning.def_ele_req[i]
  449. return false if @atk_ele_fix_II[i] < learning.atk_ele_req[i]
  450. end
  451. end
  452. if $D13x[:Atk_Def_Lvs]
  453. 2.times do |i|
  454. return false if @atl_dfl_prefix[i] < learning.atl_dfl_req[i]
  455. end
  456. end
  457. if $D13x[:ISPDS]
  458. SPDS::Commands.each do |i|
  459. return false if parent_stat(i) < learning.spds_stats_req[i]
  460. end
  461. end
  462. learning.skill_req.each do |skil|
  463. return false if !skills.include?($data_skills[skil[0]])
  464. return false if skills_lv(skil[0]) < skil[1] if $D13x[:Skill_Lv]
  465. end
  466. return ls_reqzz__sD13x(learning, mult)
  467. end
  468.  
  469. end # Game_Actor
  470.  
  471. #==============================================================================#
  472. # http://dekitarpg.wordpress.com/ #
  473. #==============================================================================#
  474. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement