Advertisement
Dekita

$D13x Learn Skill Requirements 1.8

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