Advertisement
Dekita

$D13x Learn Skill Requirements

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