Advertisement
Dekita

$D13x Learn Skill Requirements 1.2

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