Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if true # << Make true to use this script, false to disable.
- #===============================================================================
- #
- # ☆ $D13x - Learn Skill Requirements
- # -- Author : Dekita
- # -- Version : 1.8
- # -- Level : Easy / Normal
- # -- Requires : $D13x - Statistic Control
- # -- Engine : RPG Maker VX Ace.
- #
- #===============================================================================
- # ☆ Import
- #-------------------------------------------------------------------------------
- $D13x={}if$D13x==nil
- $D13x[:Skill_Reqs]=true
- #===============================================================================
- # ☆ Updates
- #-------------------------------------------------------------------------------
- # D /M /Y
- # 21/o5/2o13 - Compatability, ($D13x ISPDS)
- # 2o/o5/2o13 - Compatability, ($D13x Atk & Def Lvs)
- # 19/o5/2o13 - Small Re-write, (v1.6 details below)
- # 17/o5/2o13 - Small Update,
- # 14/o5/2o13 - Update, (Skill/Skill Level Requirements)
- # - Bugfix, (eval notetag)
- # 26/o3/2o13 - Compatibility, (Elements Control)
- # 23/o3/2o13 - Bugfix, (forgetting skills when negative HRG/MRG/TRG)
- # 21/o3/2o13 - Fixed typo in notetag info section,
- # 13/o3/2o13 - Finished,
- # 1o/o3/2o13 - Started
- #
- #===============================================================================
- # ☆ Introduction
- #-------------------------------------------------------------------------------
- # This script enables additional requirements for learning skills.
- # other than the default level requirement, you are now allowed
- # requirements based on almost all other statistics,
- # Such as param / x-param / s-param / atk element rate / def element rate :p
- # simply use notetags in the CLASS Skill Learn Notebox !!
- #
- # You can also allow for skills to be forgotten if the requirements
- # are no longer met.
- # eg. removed equipment / leveled down ...
- #
- # Note : all param requirements must be an integer value, eg. 1, 2, 3, 4
- # all x/sparam requirements must be a float value, eg. 0.1, 0.5, 1.6
- #
- # v1.6+ completely changes the frequency of which skills are learned,
- # instead of skills being learned/forgot upon level up/down,
- # they are now refreshed constantly (every few seconds)
- # This is to enable skills being learned as soon as their requirements are met,
- # and forgotten as soon as they are not.
- # Also added a FPS fix for this feature, as constantly checking params/xparams
- # sparams/atk ele/def ele causes SEVERE FPS drop (60 > 52(ish) every few seconds)
- #
- #===============================================================================
- # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
- #===============================================================================
- # 1. You MUST give credit to "Dekita" !!
- # 2. You are NOT allowed to repost this script.(or modified versions)
- # 3. You are NOT allowed to convert this script.
- # 4. You are NOT allowed to use this script for Commercial games.
- # 5. ENJOY!
- #
- # "FINE PRINT"
- # By using this script you hereby agree to the above terms and conditions,
- # if any violation of the above terms occurs "legal action" may be taken.
- # Not understanding the above terms and conditions does NOT mean that
- # they do not apply to you.
- # If you wish to discuss the terms and conditions in further detail you can
- # contact me at http://dekitarpg.wordpress.com/
- #
- #===============================================================================
- # ☆ Instructions
- #-------------------------------------------------------------------------------
- # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
- # Place Under My $D13x - Staistic Control Script.
- #
- #===============================================================================
- # ☆ Notetags ( default )
- # For use with Class Skill Learn noteboxes only !
- #-------------------------------------------------------------------------------
- # <stat req: value>
- # stat req = mhp, mmp, agi, luk, cri ect...
- # value = the value for that skill, for that class
- # e.g
- # <agi req: 4> would make the skill unlearnable until the actor has 4 agi
- # <cri req: 0.04> unlearnable until 4% crit rate
- #
- # you can also use switches, variables and even define your own code for
- # requisites using the eval method.
- #
- # v1.2 introduces the ability to have elemental attack and defence requirements
- # IF used with my $D13x Elements Control script.
- # The notetags for these requirements are :
- # <atk ele req: id, value>
- # <def ele req: id, value>
- #
- # v1.3 introduces the ability to have skill / skill level requirements.
- # eg.. need skill 5 before learning skill 6
- # or need skill 6 @ level 10 before learning skill 7 ect..
- # This could of course be done by using the <eval: X> notetag like this...
- # <eval req: skills_lv(6) < 10 > (TESTED and works 100%)
- #
- # NOTE:
- # eval notetag return FALSE if eval condition is TRUE,
- # eg.. the above notetag would return false if the skill 6's level is < 10
- #
- # you could also do things like equip requirements or actor name requirements
- # or playtime requirements or whatever by using the eval notetag,
- # this, of course, requires basic scripting knowledge.
- #
- #===============================================================================
- # ☆ HELP
- #-------------------------------------------------------------------------------
- # PARAMS :
- # mhp, mmp, atk, def, mat, mdf, agi, luk
- # XPARAMS
- # hit, eva, cri, cev, mev, mrf, cnt, hrg, mrg, trg
- # SPARAMS
- # tgr, grd, rec, pha, mcr, tcr, pdr, mdr, fdr, exr
- #
- #-------------------------------------------------------------------------------
- # Remember :
- # All Params work with integer values, eg. 1, 5, 123, 653, 198123 .
- # All x/s-Params work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01 .
- # All Elemental Values work with float values, eg. 1.0, 0.5, 0.1, 0.05, 0.01 .
- # 1.0 = 100%, 0.01 = 1%,
- #
- # ALSO:
- # If you want to have multiple requirements for learning skills,
- # simply seperate the notetags with \n
- # this will trigger a new note to be read :)
- #===============================================================================
- module Skill_Reqz
- #===============================================================================
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ☆ General Settings
- #--------------------------------------------------------------------------
- # Remove skills if requirement are no longer met.
- Remove_Skills = true
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # ☆ Notetag Settings
- #--------------------------------------------------------------------------
- Notes={}
- Notes[:mhp] = /<mhp req:(.*)>/i
- Notes[:mmp] = /<mmp req:(.*)>/i
- Notes[:atk] = /<atk req:(.*)>/i
- Notes[:def] = /<def req:(.*)>/i
- Notes[:mat] = /<mat req:(.*)>/i
- Notes[:mdf] = /<mdf req:(.*)>/i
- Notes[:agi] = /<agi req:(.*)>/i
- Notes[:luk] = /<luk req:(.*)>/i
- Notes[:hit] = /<hit req:(.*)>/i
- Notes[:eva] = /<eva req:(.*)>/i
- Notes[:cri] = /<cri req:(.*)>/i
- Notes[:cev] = /<cev req:(.*)>/i
- Notes[:mev] = /<mev req:(.*)>/i
- Notes[:mrf] = /<mrf req:(.*)>/i
- Notes[:cnt] = /<cnt req:(.*)>/i
- Notes[:hrg] = /<hrg req:(.*)>/i
- Notes[:mrg] = /<mrg req:(.*)>/i
- Notes[:trg] = /<trg req:(.*)>/i
- Notes[:tgr] = /<tgr req:(.*)>/i
- Notes[:grd] = /<grd req:(.*)>/i
- Notes[:rec] = /<rec req:(.*)>/i
- Notes[:pha] = /<pha req:(.*)>/i
- Notes[:mcr] = /<mcr req:(.*)>/i
- Notes[:tcr] = /<tcr req:(.*)>/i
- Notes[:pdr] = /<pdr req:(.*)>/i
- Notes[:mdr] = /<mdr req:(.*)>/i
- Notes[:fdr] = /<fdr req:(.*)>/i
- Notes[:exr] = /<exr req:(.*)>/i
- Notes[:swi] = /<switch req:(.*)>/i # <switch req: switch_id>
- Notes[:var] = /<variable req:(.*),(.*)>/i # <variable req: vari_id, value>
- Notes[:eval]= /<eval req:(.*)>/i # <eval req: 'string of code to be evaluated'>
- Notes[:atk_ele]= /<atk ele req:(.*),(.*)>/
- Notes[:def_ele]= /<def ele req:(.*),(.*)>/
- Notes[:atk_lvl]= /<atk lvl req:(.*)>/
- Notes[:def_lvl]= /<def lvl req:(.*)>/
- Notes[:skills] = [/<skill req:(.*),(.*)>/i,/<skill req:(.*)>/i]
- Notes[:spds_stat] = /<spds stat req:(.*),(.*)>/i # <spds stat req: stat id, val>
- #####################
- # CUSTOMISATION END #
- end #####################
- #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
- # #
- # http://dekitarpg.wordpress.com/ #
- # #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- # The following code is protected under the 2013 Dekita Data Protection Act. #
- # Ie. The “Do Not Fucking Look” Law. #
- # Breaking This One And Only Rule WILL Result in SEVERE BRAIN FREEZE. #
- # That is all ! #
- #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
- #===============================================================================
- module DataManager
- #===============================================================================
- #--------------------------------------------------------------------------
- # Alias List
- #--------------------------------------------------------------------------
- class << self
- alias :load_database_skillreqz :load_database
- end
- #--------------------------------------------------------------------------
- # Load Database
- #--------------------------------------------------------------------------
- def self.load_database
- load_database_skillreqz
- load_notetags_skillreqz
- end
- #--------------------------------------------------------------------------
- # Load Notetags
- #--------------------------------------------------------------------------
- def self.load_notetags_skillreqz
- for obj in $data_classes
- next if obj.nil?
- obj.load_skill_requirements
- end
- end
- end # DataManager
- #===============================================================================
- class RPG::Class < RPG::BaseItem
- #===============================================================================
- #--------------------------------------------------------------------------
- # Load All Learnable Skills Requirements
- #--------------------------------------------------------------------------
- def load_skill_requirements
- @learnings.each { |l| l.load_skill_requirements }
- end
- end # RPG::Class
- #===============================================================================
- class RPG::Class::Learning
- #===============================================================================
- #--------------------------------------------------------------------------
- # Pi Variables
- #--------------------------------------------------------------------------
- attr_accessor :param_req
- attr_accessor :xpars_req
- attr_accessor :spars_req
- attr_accessor :swtch_req
- attr_accessor :varis_req
- attr_accessor :evals_req
- attr_accessor :atk_ele_req
- attr_accessor :def_ele_req
- attr_accessor :atl_dfl_req
- attr_accessor :skill_req
- attr_accessor :spds_stats_req
- #--------------------------------------------------------------------------
- # Load All Skill Requirements
- #--------------------------------------------------------------------------
- def load_skill_requirements
- @param_req = [0] * 8
- @xpars_req = [0] * 10
- @spars_req = [0] * 10
- @swtch_req = []
- @varis_req = []
- @evals_req = []
- @skill_req = []
- @atk_ele_req = [-2.0] * $data_system.elements.size
- @def_ele_req = [-2.0] * $data_system.elements.size
- @atl_dfl_req = [0] * 2
- @spds_stats_req = [0] * SPDS::Commands.size if $D13x[:ISPDS]
- 3.times {|i| @xpars_req[i+7] = -1.0 }
- self.note.split(/\\n/i).each do |line|
- case line
- when Skill_Reqz::Notes[:mhp] then @param_req[0] = $1.to_i
- when Skill_Reqz::Notes[:mmp] then @param_req[1] = $1.to_i
- when Skill_Reqz::Notes[:atk] then @param_req[2] = $1.to_i
- when Skill_Reqz::Notes[:def] then @param_req[3] = $1.to_i
- when Skill_Reqz::Notes[:mat] then @param_req[4] = $1.to_i
- when Skill_Reqz::Notes[:mdf] then @param_req[5] = $1.to_i
- when Skill_Reqz::Notes[:agi] then @param_req[6] = $1.to_i
- when Skill_Reqz::Notes[:luk] then @param_req[7] = $1.to_i
- when Skill_Reqz::Notes[:hit] then @xpars_req[0] = $1.to_f
- when Skill_Reqz::Notes[:eva] then @xpars_req[1] = $1.to_f
- when Skill_Reqz::Notes[:cri] then @xpars_req[2] = $1.to_f
- when Skill_Reqz::Notes[:cev] then @xpars_req[3] = $1.to_f
- when Skill_Reqz::Notes[:mev] then @xpars_req[4] = $1.to_f
- when Skill_Reqz::Notes[:mrf] then @xpars_req[5] = $1.to_f
- when Skill_Reqz::Notes[:cnt] then @xpars_req[6] = $1.to_f
- when Skill_Reqz::Notes[:hrg] then @xpars_req[7] = $1.to_f
- when Skill_Reqz::Notes[:mrg] then @xpars_req[6] = $1.to_f
- when Skill_Reqz::Notes[:trg] then @xpars_req[7] = $1.to_f
- when Skill_Reqz::Notes[:tgr] then @spars_req[0] = $1.to_f
- when Skill_Reqz::Notes[:grd] then @spars_req[1] = $1.to_f
- when Skill_Reqz::Notes[:rec] then @spars_req[2] = $1.to_f
- when Skill_Reqz::Notes[:pha] then @spars_req[3] = $1.to_f
- when Skill_Reqz::Notes[:mcr] then @spars_req[4] = $1.to_f
- when Skill_Reqz::Notes[:tcr] then @spars_req[5] = $1.to_f
- when Skill_Reqz::Notes[:pdr] then @spars_req[6] = $1.to_f
- when Skill_Reqz::Notes[:mdr] then @spars_req[7] = $1.to_f
- when Skill_Reqz::Notes[:fdr] then @spars_req[6] = $1.to_f
- when Skill_Reqz::Notes[:exr] then @spars_req[7] = $1.to_f
- when Skill_Reqz::Notes[:swi] then @swtch_req << $1.to_i
- when Skill_Reqz::Notes[:var] then @varis_req << [$1.to_i,$2.to_i]
- when Skill_Reqz::Notes[:eval] then @evals_req << $1.to_s
- when Skill_Reqz::Notes[:atk_ele] then @atk_ele_req[$1.to_i] = $2.to_f
- when Skill_Reqz::Notes[:def_ele] then @def_ele_req[$1.to_i] = $2.to_f
- when Skill_Reqz::Notes[:atk_lvl] then @atl_dfl_req[0] = $1.to_f
- when Skill_Reqz::Notes[:def_lvl] then @atl_dfl_req[1] = $1.to_f
- when Skill_Reqz::Notes[:skills][0] then @skill_req << [$1.to_i, $2.to_i]
- when Skill_Reqz::Notes[:skills][1] then @skill_req << [$1.to_i, 1]
- when Skill_Reqz::Notes[:spds_stat] then @spds_stats_req[$1.to_i] = $2.to_i
- end
- end
- end
- end # RPG::Class::Learning
- #===============================================================================
- class Game_BattlerBase
- #===============================================================================
- #--------------------------------------------------------------------------
- # Alias List
- #--------------------------------------------------------------------------
- alias :sd13x_FPS_fixx_II :initialize
- alias :param_FPS_fix_II :param
- alias :xparam_FPS_fix_II :xparam if $D13x[:Stats_Control]
- alias :sparam_FPS_fix_II :sparam if $D13x[:Stats_Control]
- alias :atk_ele_FPS_fix_II :atk_element_rate if $D13x[:Elems_Control]
- alias :def_ele_FPS_fix_II :element_rate if $D13x[:Elems_Control]
- #--------------------------------------------------------------------------
- # Initialize Data
- #--------------------------------------------------------------------------
- def initialize
- @param_fix_II = [0] * 8
- @xparam_fix_II = [0] * 10
- @sparam_fix_II = [0] * 10
- @def_ele_fix_II = [0] * $data_system.elements.size
- @atk_ele_fix_II = [0] * $data_system.elements.size
- sd13x_FPS_fixx_II
- end
- #--------------------------------------------------------------------------
- # Get Parameter
- #--------------------------------------------------------------------------
- def param(param_id)
- @param_fix_II[param_id] = param_FPS_fix_II(param_id)
- @param_fix_II[param_id]
- end
- if $D13x[:Stats_Control]
- #--------------------------------------------------------------------------
- # Get Ex-Parameter
- #--------------------------------------------------------------------------
- def xparam(xparam_id)
- @xparam_fix_II[xparam_id] = xparam_FPS_fix_II(xparam_id)
- @xparam_fix_II[xparam_id]
- end
- #--------------------------------------------------------------------------
- # Get Sp-Parameter
- #--------------------------------------------------------------------------
- def sparam(sparam_id)
- @sparam_fix_II[sparam_id] = sparam_FPS_fix_II(sparam_id)
- @sparam_fix_II[sparam_id]
- end
- end
- if $D13x[:Elems_Control]
- #--------------------------------------------------------------------------
- # Get Def Element Rate
- #--------------------------------------------------------------------------
- def element_rate(element_id)
- @def_ele_fix_II[element_id] = def_ele_FPS_fix_II(element_id)
- @def_ele_fix_II[element_id]
- end
- #--------------------------------------------------------------------------
- # Get Atk Element Rate
- #--------------------------------------------------------------------------
- def atk_element_rate(element_id)
- @atk_ele_fix_II[element_id] = atk_ele_FPS_fix_II(element_id)
- @atk_ele_fix_II[element_id]
- end
- end
- end # class Game_BattlerBase
- #===============================================================================
- class Game_Actor < Game_Battler
- #===============================================================================
- #--------------------------------------------------------------------------
- # Alias List
- #--------------------------------------------------------------------------
- alias :refresh_SKILL_DATA :refresh
- alias :lv_dwn_xtra_reqzz__sD13x :lv_down_extra
- alias :ls_reqzz__sD13x :learn_skill_conditions_met?
- #--------------------------------------------------------------------------
- # Refresh
- #--------------------------------------------------------------------------
- def refresh
- refresh_SKILL_DATA
- check_skill_data
- end
- #--------------------------------------------------------------------------
- # Check Skills Data
- #--------------------------------------------------------------------------
- def check_skill_data
- skill = skills.clone
- self.class.learnings.each do |lning|
- forget_skill(lning.skill_id) if !learn_skill_conditions_met?(lning)
- learn_skill( lning.skill_id) if learn_skill_conditions_met?(lning)
- end
- if skill != skills
- new_skills = (skills - skill)
- new_skills.each do |skll|
- $game_message.add(sprintf(Vocab::ObtainSkill, skll.name))
- end
- old_skills = (skill - skills)
- old_skills.each do |skll|
- $game_message.add(sprintf(Vocab::ForgetSkill, skll.name))
- end
- end
- end
- #--------------------------------------------------------------------------
- # Get Learning Skill Conditions
- #--------------------------------------------------------------------------
- def learn_skill_conditions_met?(learning, mult = 1.0 )
- 8.times do |i|
- return false if @param_fix_II[i] < (learning.param_req[i] * mult).to_i
- end
- if $D13x[:Stats_Control]
- 10.times do |i|
- return false if @xparam_fix_II[i] < (learning.xpars_req[i] * mult).to_f
- return false if @sparam_fix_II[i] < (learning.spars_req[i] * mult).to_f
- end
- end
- learning.swtch_req.each do |switch|
- return false if !$game_switches[ switch ]
- end
- learning.varis_req.each do |vari|
- return false if $game_variables[ vari[0] ] < (vari[1] * mult).to_i
- end
- learning.evals_req.each do |evl|
- return false if eval( evl.to_s )
- end
- if $D13x[:Elems_Control]
- $data_system.elements.size.times do |i|
- return false if @def_ele_fix_II[i] < learning.def_ele_req[i]
- return false if @atk_ele_fix_II[i] < learning.atk_ele_req[i]
- end
- end
- if $D13x[:Atk_Def_Lvs]
- 2.times do |i|
- return false if @atl_dfl_prefix[i] < learning.atl_dfl_req[i]
- end
- end
- if $D13x[:ISPDS]
- SPDS::Commands.each do |i|
- return false if @spds_stats_prefix[i] < learning.spds_stats_req[i]
- end
- end
- learning.skill_req.each do |skil|
- return false if !skills.include?($data_skills[skil[0]])
- return false if skills_lv(skil[0]) < skil[1] if $D13x[:Skill_Lv]
- end
- return ls_reqzz__sD13x(learning, mult)
- end
- end # Game_Actor
- #==============================================================================#
- # http://dekitarpg.wordpress.com/ #
- #==============================================================================#
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement