Advertisement
Dekita

$D13x Learn Skill Requirements 1.3

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