Advertisement
Dekita

skill reqs 1.1

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