#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆ Learn Skill by State - KGC_StateLearnSkill ◆ VX ◆ #_/ ◇ Last Update: 03/21/2009 #_/ ◆ Written by TOMY #_/ ◆ Translation by Mr. Anonymous #_/ ◆ KGC Site: #_/ ◆ http://ytomy.sakura.ne.jp/ #_/ ◆ Translator's Blog: #_/ ◆ http://mraprojects.wordpress.com #_/---------------------------------------------------------------------------- #_/ This script allows the user to create states which enable skills only when #_/ a battler has that state applied to it. #_/============================================================================ #_/ ◆ Instructions For Usage ◆ #_/ To make use of this function, you must insert the tag into the "Note" box #_/ located in the states section of the database. #_/ For example, you want to create a state called "Endow Fire" that enables #_/ the afflicted battler to use the skill "Fire" while affected by that state. #_/ You'd then insert or in that state's note #_/ box. The number 59, of course, being the number of the default Fire skill. #_/============================================================================ #_/ Install: Insert below KGC_PassiveSkill, if applicable. #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ $imported = {} if $imported == nil $imported["StateLearnSkill"] = true module KGC module StateLearnSkill # Regular expressions module module Regexp # State module module State # State Learn Skill tag string LEARN_SKILL = /<(?:LEARN_SKILL|learn_skill)\s*(\d+(?:\s*,\s*\d+)*)>/i end end end end #-------------------------------------------------------------------------- #============================================================================== # ■ RPG::State #============================================================================== class RPG::State #-------------------------------------------------------------------------- # ○ Generate State Learn Skill Cache #-------------------------------------------------------------------------- def create_state_learn_skill_cache @__learn_skills = [] self.note.each_line { |line| case line # When tag is located in notes list when KGC::StateLearnSkill::Regexp::State::LEARN_SKILL $1.scan(/\d+/).each { |num| skill_id = num.to_i # Add skills to battler's list if the skill exists @__learn_skills << skill_id if $data_skills[skill_id] != nil } end } end #-------------------------------------------------------------------------- # ○ Learn Skills #-------------------------------------------------------------------------- def learn_skills create_state_learn_skill_cache if @__learn_skills == nil return @__learn_skills end end #-------------------------------------------------------------------------- #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● Create skill object array #-------------------------------------------------------------------------- alias skills_KGC_StateLearnSkill skills def skills result = skills_KGC_StateLearnSkill return (result | state_learn_skills).sort_by { |v| v.id } end #-------------------------------------------------------------------------- # ○ Learn additional skills by state #-------------------------------------------------------------------------- def state_learn_skills result = [] self.states.each { |state| state.learn_skills.each { |i| skill = $data_skills[i] result |= [skill] if skill != nil } } # If KGC_PassiveSkill exists, return passive skills effect if $imported["PassiveSkill"] && @__last_state_learn_skills != result @__last_state_learn_skills = result restore_passive_rev end return result end #-------------------------------------------------------------------------- # ● Determine if skill is usable # skill : Skill #-------------------------------------------------------------------------- def skill_can_use?(skill) return super end end