The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on August 29, 2009, 02:44:56 AM

Title: Learn Skills By Use 2.0
Post by: modern algebra on August 29, 2009, 02:44:56 AM
Learn Skills By Use
Version: 2.0c
Author: modern algebra
Date: October 19, 2011

Version History



Description

 

This script allows you to have actors learn skills by using other skills. For instance, you could set it so that an actor will learn Fire II only after he has used Fire 50 times. You can also set it so that there can be multiple paths to learning a skill and multiple skill requirements. For instance, that same actor could also learn Fire II if he has used Flame 60 times and Flame II 25 times. However, you can also set class prohibitions and level requirements, so if you never want a Paladin to learn Fire II no matter how many times he uses its root skills, then it is easy to set that up, and if you don't want Fire II to be learned by any actor until they are at least level 7, then that can be setup too. You may also set it up so that it is like an upgrade - Fire becomes obsolete once Fire II is learned, and so you can simply forget Fire once you have Fire II

Also, you can set it so that the actor either learns the new skill immediately upon meeting use requirements, or at his/her next level.

Further, this doesn't interfere with the regular skill learning system, so if you set it that a mage will learn Fire II at level 6 in the Class Tab of the database, than the mage will learn Fire II at level 6 no matter if she has met the use requirements of its root skills, and no matter what the class prohibitions or level requirements are.

Features


Instructions

Please see the header for instructions and read them carefully, as there are features you might miss if you do not.

If using the Learn Skill immediately upon meeting requirements option, then you NEED to have Zeriab's Dialog System (http://rmrk.net/index.php/topic,24828.0.html)!

Script


Code: [Select]
#==============================================================================
#    Learn Skills By Use
#    Version: 2.0c
#    Author: modern algebra (rmrk.net)
#    Date: October 19, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  NB: If you wish to use the learn immediately option of the script, then
#   Zeriab's Dialog System is required and he should be credited. You can find
#   it here: http://rmrk.net/index.php/topic,24828.0.html
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to have actors learn skills by using other skills.
#   For instance, you could set it so that an actor will learn Fire II only
#   after he has used Fire 50 times. You can also set it so that there can be
#   multiple paths to learning a skill and multiple skill requirements. For
#   instance, that same actor could also learn Fire II if he has used Flame
#   60 times and Flame II 25 times. However, you can also set class
#   prohibitions and level requirements, so if you never want a Paladin to
#   learn Fire II no matter how many times he uses its root skills, then it is
#   easy to set that up, and if you don't want Fire II to be learned by any
#   actor until they are at least level 7, then that can be setup too. You may
#   also set it up so that it is like an upgrade - Fire becomes obsolete once
#   Fire II is learned, and so you can simply forget Fire once you have Fire II
#   It also has two options of ways to show the number of times you've used a
#   skill.
#
#    Also, you can set it so that the actor either learns the new skill
#   immediately upon meeting use requirements, or at his/her next level.
#
#    Further, this doesn't interfere with the regular skill learning system, so
#   if you set it that a mage will learn Fire II at level 6 in the Class Tab
#   of the database, than the mage will learn Fire II at level 6 no matter if
#   she has met the use requirements of its root skills, and no matter what
#   the class prohibitions or level requirements are.
#
#    There are also a number of options you can set regarding how to show the
#   number of uses in the help window, and you can do it by either pressing a
#   button or it will show up at the same time as the description. There is
#   also a new set of mastery options.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials in the Editor. It should
#   also be below any custom levelup scripts you may have. If set to learn
#   immediately, then Zeriab's Dialog System is required above this script:
#       http://rmrk.net/index.php/topic,24828.0.html
#
#    To set up a skill to be learned through use, you must use this code in a
#   notes box:
#
#      \ROOT_SKILL[skill_id, number_of_uses, <supplement_skills>, forget]
#        skill_id : The ID of the root skill that leads to this skill.
#        number_of_uses : An integer - the number of times the root skill has
#          be used before it teaches this skill.
#        <supplement_skills> : a list of skill IDs that also have to have their
#          root requirements fulfilled before the skill will be learned. It is
#          of the format: <x, y, z> where x, y, and z are the IDs of the other
#          skills that must have usage requirements met. You can have as many
#          as you like. Note, however, that you must set up one of these
#          requirements notes for each of the other skills as well, and you
#          must cross-reference the skills in this path. Defaults to <>,
#          meaning that the only usage requirements needed to be filled is this
#          one
#        forget : If this is set to 1, then the root skills will be forgotten
#          once this skill is learned. If left blank or set to any other digit,
#          than the root skills will be retained.
#
#  EXAMPLE A:
#
#    This code in the notebox of a skill:
#
#      \ROOT_SKILL[9, 100]
#
#    There is only one path to learning this skill:
#      (i) Use the skill with ID 9 at least 100 times.
#
#    No skill is forgotten
#
#  EXAMPLE B:
#
#    These codes in the notebox of a skill:
#
#      \ROOT_SKILL[1, 20, 1]
#      \ROOT_SKILL[4, 15, <5>]
#      \ROOT_SKILL[5, 8, <4>]
#
#    With these codes, there are two paths to learning this skill.
#      (i)  Use the skill with ID 1 at least 20 times.
#      (ii) Use the skill with ID 4 at least 15 times and use the skill with
#         ID 5 at least 8 times.
#
#    No matter which path is taken to the skill, the skill with ID 1 will be
#   forgotten as soon as the new skill is learned.
#
#  EXAMPLE C:
#
#    The following codes in the notebox of a skill:
#
#      \ROOT_SKILL[6, 100]
#      \ROOT_SKILL[7, 100]
#      \ROOT_SKILL[6, 20, <7, 8>]
#      \ROOT_SKILL[7, 25, <6, 8>]
#      \ROOT_SKILL[8, 15, <6, 7>]
#
#    With these codes, there are three paths to learning this skill.
#      (i)   Use the skill with ID 6 at least 100 times
#      (ii)  Use the skill with ID 7 at least 100 times
#      (iii) Use the skill with ID 6 at least 20 times, the skill with ID 7 at
#          least 25 times, and the skill with ID 8 at least 15 times.
#
#    No matter which path is taken, no skills will be forgotten.
#
#    To prohibit a class from learning a skill through usage requirements,
#   put this code in a notebox of a skill:
#
#      \PROHIBIT_CLASS[class_id]
#        class_id : ID of class not allowed to learn this skill through use
#
#    To set a minimum level for learning a skill through usage requirements,
#   put this code in the notebox of a skill:
#
#      \MIN_LEVEL[x]
#        x : an integer that is the minimum level. An actor cannot learn
#          the skill until his level is at least equal to x.
#   
#  Next, you may want to setup if and how the use count is displayed. To, set the text that you
#  want to signify the count under LSU_VOCAB_USECOUNT at line 159, and you can
#  set the color of the text at line 165 - LSU_COUNT_FONTCOLOR. If this is an
#  integer, it takes the color from the windowskin palette. You could also set
#  it as an array of the form: [red, green, blue, alpha].
#   Alternatively, you could set it up to only show the skill count if the
#  player presses a specified button. You would not get to choose the color in
#  that case, but would get to specify alignment.
#
#   Lastly, there is now an option to show "Mastery". You can specify a number
#  of uses to meet this threshold. When showing use count, it will show up as
#  # of uses / mastery threshold, and once reached, it will be replaced by any
#  text you choose. Those options are between lines 162 and 168. To set the
#  threshold for a skill individually, use the following code:
#      \MASTER[x]
#        x : the number of uses to reach mastery.
#==============================================================================

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LSU_LEARN_IMMEDIATELY = true # Whether to learn the skill immediately upon
                             #  meeting usage requirements or to wait for level
                             #  If true, you MUST have Zeriab's Dialog System:
                             #  http://rmrk.net/index.php/topic,24828.0.html
LSU_VOCAB_OBTAIN_SKILL = "%n has learned %s!" # The message shown when an actor
                             # learns a new skill if immediate and not on level
LSU_SE_OBTAIN_SKILL = "Skill" # The SE that plays when an actor learns a new
                             # skill. Again, only applies if on immediate.
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_USE = true          # Whether or not to show use count at all in the
                             #  the help window.
LSU_VOCAB_USECOUNT = "Used: " # Text to label skill count
LSU_BUTTONSHOW = false       # Whether or not it shows up with the description
                             #  or is drawn only when pressing a button
  LSU_BUTTON = Input::SHIFT  # If LSU_BUTTONSHOW is true, what button needs to
                             #  be pressed to show the skill use count
  LSU_SHOWCOUNT_ALIGN = 0    # Alignment of text if LSU_BUTTONSHOW is true
LSU_COUNT_FONTCOLOR = 16     # Font color if LSU_BUTTONSHOW is false
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_MASTERY = false     # Whether or not to show some the word for mastery
                             #  when a script has been used to its maximum
                             #  efficiency or to a stated goal.
LSU_DEFAULT_MASTERY = 100    # The default number of uses for mastery
LSU_VOCAB_MASTERY = "[MASTERED]" # The word to show once skill use reaches goal
LSU_MASTER_REPLACE = true    # Whether to replace the Used: x text or simply be
                             #  placed after it.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////

if LSU_LEARN_IMMEDIATELY
#==============================================================================
# ** Dialog_DiscoverFavourite
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class processes when a favourite item is discovered
#==============================================================================

class Dialog_LearnSkill < Dialog
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * A show method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize(actor, skill)
    @actor = actor
    @skill = skill
    begin
      (RPG::SE.new (*skill.ma_learn_se)).play
    rescue
      (RPG::SE.new ("Skill")).play
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_window
    text = help_text
    tw = [@background_sprite.bitmap.text_size (text).width + 40, Graphics.width].min
    @learn_window = Window_Help.new
    @learn_window.width = tw
    @learn_window.create_contents
    @learn_window.x = (Graphics.width - tw) / 2
    @learn_window.y = (Graphics.height - @learn_window.height) / 2
    @learn_window.z = STARTING_Z_VALUE + 1
    @learn_window.set_text (text, 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def help_text
    text = LSU_VOCAB_OBTAIN_SKILL.gsub (/%s/) { @skill.name }
    text.gsub! (/%n/) { @actor.name }
    return text
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_dispose
    @learn_window.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    if Input.trigger?(Input::B) || Input.trigger?(Input::C)
      mark_to_close
      self.value = false
    end
  end
end
end

#==============================================================================
# ** Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public variables - ma_root_skills; ma_descendant_skills;
#      ma_level_requirement; ma_prohibited classes
#    new methods - ma_learn_se; ma_cache_lsu_skill_stats
#==============================================================================

class RPG::Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :ma_root_skills
  attr_accessor :ma_descendant_skills
  attr_accessor :ma_level_requirement
  attr_accessor :ma_prohibited_classes
  attr_accessor :ma_master_uses
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_learn_se
    # Not cached because it will only rarely be accessed. Better to use RAM
    if self.note[/\\LEARN_SE\[(.+?),?\s*(\d*?),?\s*(\d*?)\]/i] != nil
      learn_se = [$1.to_s]
      learn_se.push ($2.to_i) unless $2.empty?
      learn_se.push ($3.to_i) unless $3.empty?
    else
      return LSU_SE_OBTAIN_SKILL
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Cache LSU stats
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_cache_lsu_skill_stats
    # Get skill paths and descendants
    @ma_root_skills, @ma_prohibited_classes = [], []
    @ma_descendant_skills = [] if @ma_descendant_skills.nil?
    @ma_master_uses, @ma_level_requirement = LSU_DEFAULT_MASTERY, 1
    # Level Requirements
    @ma_level_requirement = $1.to_i if self.note[/\\MIN_LEVEL\[(\d+)\]/i] != nil
    @ma_master_uses = $1.to_i if self.note[/\\MASTERY?\[(\d+)\]/i] != nil && $1.to_i > 0
    root_paths = {}
    root_skills = []
    (self.note.scan (/\\ROOT_SKILL\[(\d+),?\s*(\d*),?\s*?<?([\d ,;:]*?)>?,?\s*?([F1]?)\]/i)).each { |match|
    id = match[0].to_i
    n = match[1].to_i
    supplement_skills = []
    (match[2].scan (/\d+/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?
    forget = !match[3].empty?
      root_skills.push ([id, n, forget, supplement_skills])
    }
    root_skills.each { |array|
      key = ([array[0]] + array[3]).sort
      root_paths[key] = [] if !root_paths[key]
      root_paths[key].push (array[0, 3])
    }
    root_paths.each { |key, path|
      if path.size < key.size
        key.each { |key2|
          exists = false
          path.each { |array| exists = true if path[0] == key2 }
          path.push ([key2, 0, false]) if !exists
        }
      end
      path.sort! { |a, b| a[0] <=> b[0] }
      @ma_root_skills.push (path)
    }
    @ma_root_skills.each { |path|
      path.each { |d_id, n, forget|
        $data_skills[d_id].ma_descendant_skills = [] if $data_skills[d_id].ma_descendant_skills.nil?
        d_skills = $data_skills[d_id].ma_descendant_skills
        d_skills.push (self.id) unless d_skills.include? (self.id)
      }
    }
    # Prohibited Classes
    (self.note.scan (/\\PROHIBIT_CLASS\[(\d+)\]/i)).each { |id|
      @ma_prohibited_classes.push (id[0].to_i)
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Compatibility with Note Editor + General Compatibility Patch
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias malg_lsu_rsetnote_8uk2 ma_reset_note_values
    def ma_reset_note_values (*args)
      malg_lsu_rsetnote_8uk2 (*args) # Run Original Method
      @ma_root_skills.each { |path|
        path.each { |a| $data_skills[a[0]].ma_descendant_skills.delete (self.id) }
      }
      ma_cache_lsu_skill_stats       # Recache skill stats for LSU
    end
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - initialize; level_up
#    new method - lsu_skill_requirements_met?; learn_skill_by_use; skill_count;
#      increase_skill_count; skill_mastered?
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_brnchskill_stp_1xc3 setup
  def setup (*args)
    @lsbu_skill_count = []
    # Run Original Method
    modalg_brnchskill_stp_1xc3(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Level Up
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_skl_brnches_byuse_lvlplus_0kb2 level_up
  def level_up (*args)
    # Run Original Method
    malg_skl_brnches_byuse_lvlplus_0kb2 (*args)
    # Check all skills to see if requirements have been met to learn the skill
    skills.each { |skill|
      skill.ma_descendant_skills.each { |descendant_id|
        descen = $data_skills[descendant_id]
        if !@skills.include? (descen.id) && lsu_skill_requirements_met? (descen)
          # Learn Skill
          learn_skill_by_use (descen.id)
        end
      }
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if this actor meets requirements to learn skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_skill_requirements_met? (skill)
    return false if skill.ma_prohibited_classes.include? (@class_id)
    return false if @level < skill.ma_level_requirement
    skill.ma_root_skills.each { |path|
      path_complete = true
      path.each { |reqs|
        if skill_count (reqs[0]) < reqs[1]
          path_complete = false
          break
        end
      }
      return true if path_complete        # If all requirements met
    }
    return false
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn Skill By Use
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def learn_skill_by_use (skill_id)
    forgets = []
    $data_skills[skill_id].ma_root_skills.each { |path|
      path.each { |reqs| forgets.push (reqs[0]) if reqs[2] }
    }
    forgets.each { |forget_id| forget_skill (forget_id) }
    learn_skill (skill_id)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Retrieve Skill Count
  #    skill_id : ID of skill checked
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_count (skill_id)
    @lsbu_skill_count[skill_id] = 0 if @lsbu_skill_count[skill_id].nil?
    return @lsbu_skill_count[skill_id]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Increase Skill Count
  #    skill_id : ID of skill increased
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def increase_skill_count (skill_id)
    @lsbu_skill_count[skill_id] = skill_count (skill_id) + 1
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Mastered?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_mastered? (skill)
    return skill_count (skill.id) >= skill.ma_master_uses
  end
end

#==============================================================================
# ** Window_Help
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - lsu_set_secondary_text
#==============================================================================

class Window_Help
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Secondary Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_insert_secondary_text (text, align = 2)
    # Check if real text has changed
    if (@lsu_changed_text != @text) || (@lsu_changed_align != @align)
      if LSU_COUNT_FONTCOLOR.is_a? (Integer)
        self.contents.font.color = text_color (LSU_COUNT_FONTCOLOR)
      else
        self.contents.font.color = Color.new (*LSU_COUNT_FONTCOLOR)
      end
      self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
      @lsu_changed_text, @lsu_changed_align = @text, @align
    end
  end
end

#==============================================================================
# ** Window_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - update_help
#==============================================================================

class Window_Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_lsu_updhelp_uses_8kh2 update_help
  def update_help (*args)
    if LSU_BUTTONSHOW
      if Input.press? (LSU_BUTTON) && @actor
        @help_window.set_text  (ma_use_text, LSU_SHOWCOUNT_ALIGN)
      else
        ma_lsu_updhelp_uses_8kh2 (*args)
      end
    else
      ma_lsu_updhelp_uses_8kh2 (*args)
      return unless @actor && skill
      @help_window.lsu_insert_secondary_text (ma_use_text)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Use Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_use_text
    add = ""
    if LSU_SHOW_MASTERY
      if @actor.skill_mastered? (skill)
        return LSU_VOCAB_MASTERY if LSU_MASTER_REPLACE
        add = LSU_VOCAB_MASTERY
      else
        add = " / #{skill.ma_master_uses}"
      end
    end
    return LSU_VOCAB_USECOUNT + @actor.skill_count(skill.id).to_s + add
  end
end

#==============================================================================
# ** Scene_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - lsu_advance_skill_count
#==============================================================================

class Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Advance Skill Count
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_advance_skill_count (user, skill)
    # Increase skill count
    user.increase_skill_count (skill.id)
    if LSU_LEARN_IMMEDIATELY
      new_skills = []
      skill.ma_descendant_skills.each { |descendant_id|
        descendant = $data_skills[descendant_id]
        # Check requirements
        if !user.skill_learn? (descendant) && user.lsu_skill_requirements_met? (descendant)
          new_skills.push (descendant)
        end
      }
      for new_skill in new_skills
        user.learn_skill_by_use (new_skill.id)
        Dialog_LearnSkill.show (user, new_skill)
      end
    end
  end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - load_database; load_bt_database
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malsu_lddata_5yj7 load_database
  def load_database (*args)
    malsu_lddata_5yj7 (*args) # Run Original Method
    $data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Battle Test Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_lsu_btdat_6yh1 load_bt_database
  def load_bt_database (*args)
    malg_lsu_btdat_6yh1 (*args) # Run Original Method
    $data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
  end
end

#==============================================================================
# ** Scene_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - use_skill_nontarget
#==============================================================================

class Scene_Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Skill Nontarget
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_lsu_uskll_7uj2 use_skill_nontarget
  def use_skill_nontarget (*args)
    ma_lsu_uskll_7uj2 (*args)                # Run Original Method
    lsu_advance_skill_count (@actor, @skill) # Advance Skill Count
  end
end

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - execute_action_skill
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrnalg_exctskl_lsbu_4nv2 execute_action_skill
  def execute_action_skill (*args)
    mdrnalg_exctskl_lsbu_4nv2 (*args) # Run Original Method
    # Increase User's skill count if actor
    lsu_advance_skill_count (@active_battler, @active_battler.action.skill) if @active_battler.actor?
  end
end

Credit



Support


Please post in this topic if you encounter any problems with the script.

Known Compatibility Issues

Will not work with exotic CBSes that are outside Scene_Battle. It should be placed below any levelup display scripts.
Title: Re: Learn Skills By Use 1.0
Post by: Grafikal on August 29, 2009, 02:47:22 AM
Very cool MA!
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on August 29, 2009, 01:28:40 PM
Thanks grafikal.

Anyway, minor undocumented update - when I posted it last night, I forgot to add the part of the script that updates skill use count outside of battle. It's there now though.
Title: Re: Learn Skills By Use 1.0
Post by: Sponge on August 31, 2009, 11:03:19 PM
Awesome job, I might try this out later depending on if I can finish off a couple of things first.
Title: Re: Learn Skills By Use 1.0
Post by: Gryphon on December 28, 2009, 07:43:44 PM
I love this script! It was so easy to get working. Just one questions though. Would it be possible to add a progress bar that would sit just under the skills that are being worked on. I think it would be awesome to be able to see how far you have left to learn the next skill.
Maybe at the end of the progress bar have the name of the next skill.
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on December 29, 2009, 03:05:11 PM
Well, it would certainly be possible. But, it would sort of be limited to only if you use one skill tracks. It would be a little odd though, since the requirements are kept in the new skills, and there is no reference to it from the old skills.

In any case, it's possible, but it would look weird once they're all finished. I might look into it if I can find the time though.
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on January 19, 2010, 04:22:52 PM
I created an addon for this script at the request of Kail200X. It will show the number of times a skill has been used in the upper right corner of the help window when looking at skills. It's included right below the main script
Title: Re: Learn Skills By Use 1.0
Post by: heyoka on February 20, 2010, 09:46:46 AM
:blizj: your scripts are as always awsome :blizj:
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on February 20, 2010, 06:46:53 PM
I'm glad you like them :)
Title: Re: Learn Skills By Use 1.0
Post by: Cascading Dragon on May 28, 2010, 09:23:20 PM
Just like I though, this isn't compatible with Melody. I have been going through scripts I like, and seeing if they work. So...I got it working, but I think its a bad work around.
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on May 28, 2010, 10:21:27 PM
Really? What goes wrong when you add it? Is it below all the melody scripts?

EDIT::

I just tested it; I didn't encounter any incompatibilities.
Title: Re: Learn Skills By Use 1.0
Post by: Cascading Dragon on May 28, 2010, 10:34:39 PM
It just doesn't work. I put in the tag, set it up for 1 use, use it once, and it doesn't appear, even though I use it 4 or 5 times.  I will check again though
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on May 28, 2010, 11:26:15 PM
Well, the script is designed so that you only gain the new skill once you level up, since that way it can take advantage of any level up display scripts people use.
Title: Re: Learn Skills By Use 1.0
Post by: Cascading Dragon on May 29, 2010, 12:22:55 AM
Oh. That may be why. I customized the way actors level up. I will go through your script and find what I need to make it work. Thanks for clearing that up
Title: Re: Learn Skills By Use 1.0
Post by: Aromatic on June 02, 2010, 02:05:45 AM
Hi modern algebra!  I love your scripts and how easy they are to use/understand.  I was wondering if this script is compatible with your Skill Teaching Equipment & Items script?
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on June 02, 2010, 02:09:01 AM
Probably. Try it out and see.
Title: Re: Learn Skills By Use 1.0
Post by: doomed2die on July 08, 2010, 06:36:11 AM
Hey, thanks so much for this script, I really like it (as well as many of your others) and I'm using it in my project. But one quick question:

I'm using this script (http://"http://wiki.pockethouse.com/index.php?title=Equipment_Skills") and I was wondering,

Could I make it so that... (using examples)

Stick of fire: Teaches fire when equipped
Fire: Learned after 30 uses.

When, with stick of fire equipped (as it's the only way to get the skill), you cast fire 30 times, at level up, you gain fire as a permenant skill with or without the stick of fire equipped?

If so, how?
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on July 08, 2010, 01:59:48 PM
Yeah, sort of, but not in a way built in by the script. You can do it like this though:

Code: [Select]
@>Conditional Branch: Script: $game_actors[actor_id].skill_count (skill_id) >= 30
  @>Change Skills: Learn skill_id
 : Branch End

Now, you can figure out where to put that event. It will need to be updated fairly frequently, after anytime the actor has the opportunity to use the skill at least.
Title: Re: Learn Skills By Use 1.0
Post by: doomed2die on July 10, 2010, 05:04:20 AM
Ah, through eventing? Thanks so much :D

EDIT: Is it possible to run the event as a parallel? (Make a common event and run it through as a parallel in every map and battle?)
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on July 10, 2010, 01:15:06 PM
well, in every map yeah, but common events don't run in battle. If you're doing that though, make sure you put a few wait frames into the event. It doesn't need to run 60 times a second.
Title: Re: Learn Skills By Use 1.0
Post by: doomed2die on July 11, 2010, 06:21:23 AM
Thanks :D
Title: Re: Learn Skills By Use 1.0
Post by: jdillon88 on July 29, 2010, 08:48:29 PM
I love this script! But can someone help me modify it so that my characters learn the skills after battle instead of on level up?
Title: Re: Learn Skills By Use 1.0
Post by: doomed2die on August 01, 2010, 05:08:04 AM
So, I tried the parallel events process you told me about. I have it running as a parallel event in my little "sandbox." Since it's my little sand box, I'm having it run without wait frames.

@conditional branch: Script: $game_actors[01].skill_count (29) >= 3
  @Change Skills [Gerard], + [Double Stab]
  @Text: Double stab has been learned.
@else
branch end

However, it doesn't seem to be working :( Could you help me configure this please? Or should I put this in support?
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on August 05, 2010, 01:58:25 PM
Well, it should be $game_actors[1], not $game_actors[01], and if it's a common event the switch that activates it must be on.

However, I don't think the former would cause the issue necessarily. If you are using another skill script, it might overwrite the method used to update the skill count. Try putting this script below any other skii-related scripts you have.
Title: Re: Learn Skills By Use 1.0
Post by: Joshua.Bellmore on August 07, 2010, 06:20:22 PM
 ;8 Ohmigosh, dude! I don't think I can contain myself. YOU ROCK! This is a great script.
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on August 11, 2010, 02:11:57 AM
I was wondering the same thing as jdillon88. Is it possible for you to edit the script so you learn the skill after battle, instead of at a level up?

Also, I am using Modern Algebra's Skill Teaching Equipment & Items Version 2.0b. I am trying to make it possible for weapons to teach skills when equipped and permanently learned after X amount of skill uses. I am trying to pair both the Skill Teaching Equipment script with the Learn Skills by Use script to achieve this. Is this the best way to do this?

Any advice would be appreciated.
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on August 15, 2010, 07:42:41 PM
*BUMP*

If this is impossible, just let me know. LOL. Thanks!
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on August 15, 2010, 08:12:08 PM
No, it's not impossible - are you using default battle system?
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on August 16, 2010, 02:13:42 AM
I am using Tankentai Sideview Battle System 3.4d & ATB 1.1i. I have done a little MOD-ing to the script but, for the most part, it is the same as it was intended by its creators (great script, by the way). Let me know if my requests are compatible. I hope they are! LOL. Thanks for responding to this post, Modern Algebra!
Title: Re: Learn Skills By Use 1.0
Post by: willee02 on August 19, 2010, 03:06:20 AM
I think you don't really need a script if you want to get a skill after a battle you can set conditions for it using an event unless you want to learn skills for every battle.
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on August 30, 2010, 04:58:12 AM
Preferably, I would like to learn skills after every battle. I can't wait until level up to learn a skill later in the game. It would even be cool if right when you met the requirement for the skill uses, you would learn it (in the midst of battle). Just an idea but after each battle would be awesome. Thanks for any help.
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on August 30, 2010, 01:51:30 PM
Well, I can do it, but it'll require Zeriab's Dialog System
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on August 31, 2010, 01:18:27 AM
Done. Got it archived. Just tell me what I need to do and I will do it. Thank you very much for the time you are putting into this.
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on September 07, 2010, 01:45:47 AM
Just checking on the status of this request. I know you are busy MA  :)

Also, I am using your "Show Skill Count in Help Window" script. Right now it displays:

Used: X amount of times

Is there a way to make it display:

Used: X amount of times / X amount of times to master (ex. 4/15)

And then after you master the skill, it would display:

MASTERED

Just an idea...hehe. Thanks!
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on September 16, 2010, 04:49:40 AM
Bump. Please and thank you. Let me now if there is anything I can do to help :)
Title: Re: Learn Skills By Use 1.0
Post by: Terra-chan on September 16, 2010, 08:01:37 AM
camelmenow has nice taste I think. it would be a nice option if you could have a string that could be input into the menu information upon Completion. it could be "MASTERED" or "MAX" or "FULL" or whatever someone wants. And knowing how far until the next level is also a nice features :3
Title: Re: Learn Skills By Use 1.0
Post by: modern algebra on September 16, 2010, 12:12:52 PM
I don't know; I don't really like the idea as it unnecessarily limits the script. It would really only make sense when skills are built linearly. This script allows for multiple skills to contribute to the same path, among other things. For most people who use the script, the "mastery" could make no effectual difference if the next level of the skill, for instance, required another skill. Secondly, what would deem the upper limit of "mastery" if the skill itself could potentially contribute to two new skills, each requiring a different number of uses. What about for skills that do not lead to another skill? Would they be "mastered" as soon as you learn them or would there be some artificial limit.

As a player, I would prefer to not see how many times I needed to use a skill in any case.

I don't know, I'll probably add it since it won't be that hard with the changes I am making to it already, but it will only be a useful feature in very limited applications of this script.
Title: Re: Learn Skills By Use 1.0
Post by: camelmenow on September 16, 2010, 07:51:31 PM
Well, for my project, I have it set up (or would like to have it set up) so weapons have skills attached to them and those skill are mastered after a certain amount of uses. I don't have any skills leading to another skill. I have been experimenting with a view different scripts. I like the ease of this one best. However, I do like the KGC skill mastery script. I just don't like the way it distributes the TP per battle. You don't have to even use the skill to master it. What sense does that make? LOL.

A lot of these requests vary depending on the project. I applaud Modern Algebra for being so congenial.
Title: Re: Learn Skills By Use 1.0
Post by: Terra-chan on September 16, 2010, 08:41:38 PM
You may be into the Remodel MA's looking into for me which is Level Skills By Use then. Since those finer details would count for something there.
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on September 22, 2010, 05:53:21 PM
Updated to version 2.0. It now has the option of teaching the skill immediately upon meeting usage requirements (rather than waiting for level up) and the show skill use addon was integrated into the actual script. I also included the mastery option that was requested. Tell me if anything goes wrong.
Title: Re: Learn Skills By Use 2.0
Post by: camelmenow on September 23, 2010, 05:01:56 AM
HOLY SCH-NIKES! INCREDIBLE! I have been battle testing for a little while now and everything is working great! I will report any bugs/problems if I find any. Thank you so much for tackling this request and doing a top-notch job.
Title: Re: Learn Skills By Use 2.0
Post by: Samisgay on October 29, 2010, 03:31:44 AM
Hello, thankyou for this amazing script!!

However, I have found a major flaw in this script...
For some odd reason the dialogue
"ACTOR has learned NEW SKILL" keeps reaapearing even after the new skill is learned.

This is what I am seeing:
Ralph has skill "Double Strike". In order for him to learn "Triple Strike" he must do this skill twice,
in the note section of Double Strike is as follows : "\ROOT_SKILL[1, 2]"
After Ralph has done Double Strike twice, a message pops up saying that he has learned
"Triple Strike" and it functions fine up until this point.
However, when Ralph decides to do Double Strike again, the same message saying that
he has learned "Triple Strike" keeps reaapearing. This effect is not unique to this battle
and the message keeps reaapearing everytime "Double Strike" is used.

I have opened up a new clean project with only this script and the dialogue system and
the same thing keeps happening. I have not modded any of the preexisting script that
comes with the new project.

I'm hoping it's not some mistake I'm making...
Let me know if you need more information or if I was unclear in my explanation.
Thanks!!
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 29, 2010, 11:31:14 AM
Nah, that's almost certainly my fault. I will fix it immediately.

EDIT:: You can now get the fixed script from the first post.
Title: Re: Learn Skills By Use 2.0
Post by: Samisgay on October 29, 2010, 06:21:08 PM
Thanks for the quick fix!
It works perfectly!
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 02, 2011, 09:10:17 PM
The game keeps finding this line as an error:
LSU_SHOWCOUNT_ALIGN = 0 # Alignment of text if LSU_BUTTONSHOW is true

I have checked the Zeriab bolean to false. Do I still need Zeriab's dialog?

Oh and thanks for making all of these great scripts!
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on February 02, 2011, 11:00:09 PM
That doesn't really make sense for there to be an error there, and no you don't need the Dialog script if you aren't using it. Copy all that configuration stuff you have in your project and paste it in a codebox for me to look at. It's probably a syntax mistake.
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 03:14:17 AM
Uh boy codeboxes:

I have it in a blank new project too and it still doesn't work:

Code: [Select]
#==============================================================================
# Learn Skills By Use
# Version: 2.0b
# Author: modern algebra (rmrk.net)
# Date: October 29, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# NB: If you wish to use the learn immediately option of the script, then
# Zeriab's Dialog System is required and he should be credited. You can find
# it here: http://rmrk.net/index.php/topic,24828.0.html
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script allows you to have actors learn skills by using other skills.
# For instance, you could set it so that an actor will learn Fire II only
# after he has used Fire 50 times. You can also set it so that there can be
# multiple paths to learning a skill and multiple skill requirements. For
# instance, that same actor could also learn Fire II if he has used Flame
# 60 times and Flame II 25 times. However, you can also set class
# prohibitions and level requirements, so if you never want a Paladin to
# learn Fire II no matter how many times he uses its root skills, then it is
# easy to set that up, and if you don't want Fire II to be learned by any
# actor until they are at least level 7, then that can be setup too. You may
# also set it up so that it is like an upgrade - Fire becomes obsolete once
# Fire II is learned, and so you can simply forget Fire once you have Fire II
# It also has two options of ways to show the number of times you've used a
# skill.
#
# Also, you can set it so that the actor either learns the new skill
# immediately upon meeting use requirements, or at his/her next level.
#
# Further, this doesn't interfere with the regular skill learning system, so
# if you set it that a mage will learn Fire II at level 6 in the Class Tab
# of the database, than the mage will learn Fire II at level 6 no matter if
# she has met the use requirements of its root skills, and no matter what
# the class prohibitions or level requirements are.
#
# There are also a number of options you can set regarding how to show the
# number of uses in the help window, and you can do it by either pressing a
# button or it will show up at the same time as the description. There is
# also a new set of mastery options.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Place this script above Main and below Materials in the Editor. It should
# also be below any custom levelup scripts you may have. If set to learn
# immediately, then Zeriab's Dialog System is required above this script:
# http://rmrk.net/index.php/topic,24828.0.html
#
# To set up a skill to be learned through use, you must use this code in a
# notes box:
#
# \ROOT_SKILL[skill_id, number_of_uses, <supplement_skills>, forget]
# skill_id : The ID of the root skill that leads to this skill.
# number_of_uses : An integer - the number of times the root skill has
# be used before it teaches this skill.
# <supplement_skills> : a list of skill IDs that also have to have their
# root requirements fulfilled before the skill will be learned. It is
# of the format: <x, y, z> where x, y, and z are the IDs of the other
# skills that must have usage requirements met. You can have as many
# as you like. Note, however, that you must set up one of these
# requirements notes for each of the other skills as well, and you
# must cross-reference the skills in this path. Defaults to <>,
# meaning that the only usage requirements needed to be filled is this
# one
# forget : If this is set to 1, then the root skills will be forgotten
# once this skill is learned. If left blank or set to any other digit,
# than the root skills will be retained.
#
# EXAMPLE A:
#
# This code in the notebox of a skill:
#
# \ROOT_SKILL[9, 100]
#
# There is only one path to learning this skill:
# (i) Use the skill with ID 9 at least 100 times.
#
# No skill is forgotten
#
# EXAMPLE B:
#
# These codes in the notebox of a skill:
#
# \ROOT_SKILL[1, 20, 1]
# \ROOT_SKILL[4, 15, <5>]
# \ROOT_SKILL[5, 8, <4>]
#
# With these codes, there are two paths to learning this skill.
# (i) Use the skill with ID 1 at least 20 times.
# (ii) Use the skill with ID 4 at least 15 times and use the skill with
# ID 5 at least 8 times.
#
# No matter which path is taken to the skill, the skill with ID 1 will be
# forgotten as soon as the new skill is learned.
#
# EXAMPLE C:
#
# The following codes in the notebox of a skill:
#
# \ROOT_SKILL[6, 100]
# \ROOT_SKILL[7, 100]
# \ROOT_SKILL[6, 20, <7, 8>]
# \ROOT_SKILL[7, 25, <6, 8>]
# \ROOT_SKILL[8, 15, <6, 7>]
#
# With these codes, there are three paths to learning this skill.
# (i) Use the skill with ID 6 at least 100 times
# (ii) Use the skill with ID 7 at least 100 times
# (iii) Use the skill with ID 6 at least 20 times, the skill with ID 7 at
# least 25 times, and the skill with ID 8 at least 15 times.
#
# No matter which path is taken, no skills will be forgotten.
#
# To prohibit a class from learning a skill through usage requirements,
# put this code in a notebox of a skill:
#
# \PROHIBIT_CLASS[class_id]
# class_id : ID of class not allowed to learn this skill through use
#
# To set a minimum level for learning a skill through usage requirements,
# put this code in the notebox of a skill:
#
# \MIN_LEVEL[x]
# x : an integer that is the minimum level. An actor cannot learn
# the skill until his level is at least equal to x.

# Next, you may want to setup if and how the use count is displayed. To, set the text that you
# want to signify the count under LSU_VOCAB_USECOUNT at line 159, and you can
# set the color of the text at line 165 - LSU_COUNT_FONTCOLOR. If this is an
# integer, it takes the color from the windowskin palette. You could also set
# it as an array of the form: [red, green, blue, alpha].
# Alternatively, you could set it up to only show the skill count if the
# player presses a specified button. You would not get to choose the color in
# that case, but would get to specify alignment.
#
# Lastly, there is now an option to show "Mastery". You can specify a number
# of uses to meet this threshold. When showing use count, it will show up as
# # of uses / mastery threshold, and once reached, it will be replaced by any
# text you choose. Those options are between lines 162 and 168. To set the
# threshold for a skill individually, use the following code:
# \MASTER[x]
# x : the number of uses to reach mastery.
#==============================================================================

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LSU_LEARN_IMMEDIATELY = false # Whether to learn the skill immediately upon
# meeting usage requirements or to wait for level
# If true, you MUST have Zeriab's Dialog System:
# http://rmrk.net/index.php/topic,24828.0.html
LSU_VOCAB_OBTAIN_SKILL = "%n has learned %s!" # The message shown when an actor
# learns a new skill if immediate and not on level
LSU_SE_OBTAIN_SKILL = "Skill" # The SE that plays when an actor learns a new
# skill. Again, only applies if on immediate.
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_USE = true # Whether or not to show use count at all in the
# the help window.
LSU_VOCAB_USECOUNT = "Used: " # Text to label skill count
LSU_BUTTONSHOW = false # Whether or not it shows up with the description
# or is drawn only when pressing a button
LSU_BUTTON = Input::SHIFT # If LSU_BUTTONSHOW is true, what button needs to
# be pressed to show the skill use count
LSU_SHOWCOUNT_ALIGN = 0 # Alignment of text if LSU_BUTTONSHOW is true
LSU_COUNT_FONTCOLOR = 16 # Font color if LSU_BUTTONSHOW is false
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_MASTERY = false # Whether or not to show some the word for mastery
# when a script has been used to its maximum
# efficiency or to a stated goal.
LSU_DEFAULT_MASTERY = 100 # The default number of uses for mastery
LSU_VOCAB_MASTERY = "[MASTERED]" # The word to show once skill use reaches goal
LSU_MASTER_REPLACE = true # Whether to replace the Used: x text or simply be
# placed after it.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////

if LSU_LEARN_IMMEDIATELY
#==============================================================================
# ** Dialog_DiscoverFavourite
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This class processes when a favourite item is discovered
#==============================================================================

class Dialog_LearnSkill < Dialog
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * A show method
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize(actor, skill)
@actor = actor
@skill = skill
begin
(RPG::SE.new (*skill.ma_learn_se)).play
rescue
(RPG::SE.new ("Skill")).play
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Create the windows
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def main_window
text = help_text
tw = [@background_sprite.bitmap.text_size (text).width + 40, Graphics.width].min
@learn_window = Window_Help.new
@learn_window.width = tw
@learn_window.create_contents
@learn_window.x = (Graphics.width - tw) / 2
@learn_window.y = (Graphics.height - @learn_window.height) / 2
@learn_window.z = STARTING_Z_VALUE + 1
@learn_window.set_text (text, 1)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Help Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def help_text
text = LSU_VOCAB_OBTAIN_SKILL.gsub (/%s/) { @skill.name }
text.gsub! (/%n/) { @actor.name }
return text
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Dispose the windows
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def main_dispose
@learn_window.dispose
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Frame Update
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def update
if Input.trigger?(Input::B) || Input.trigger?(Input::C)
mark_to_close
self.value = false
end
end
end
end

#==============================================================================
# ** Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new public variables - ma_root_skills; ma_descendant_skills;
# ma_level_requirement; ma_prohibited classes
# new methods - ma_learn_se; ma_cache_lsu_skill_stats
#==============================================================================

class RPG::Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :ma_root_skills
attr_accessor :ma_descendant_skills
attr_accessor :ma_level_requirement
attr_accessor :ma_prohibited_classes
attr_accessor :ma_master_uses
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Learn SE
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_learn_se
# Not cached because it will only rarely be accessed. Better to use RAM
if self.note[/\\LEARN_SE\[(.+?),?\s*(\d*?),?\s*(\d*?)\]/i] != nil
learn_se = [$1.to_s]
learn_se.push ($2.to_i) unless $2.empty?
learn_se.push ($3.to_i) unless $3.empty?
else
return LSU_SE_OBTAIN_SKILL
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Cache LSU stats
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_cache_lsu_skill_stats
# Get skill paths and descendants
@ma_root_skills, @ma_prohibited_classes = [], []
@ma_descendant_skills = [] if @ma_descendant_skills.nil?
@ma_master_uses, @ma_level_requirement = LSU_DEFAULT_MASTERY, 1
# Level Requirements
@ma_level_requirement = $1.to_i if self.note[/\\MIN_LEVEL\[(\d+)\]/i] != nil
@ma_master_uses = $1.to_i if self.note[/\\MASTERY?\[(\d+)\]/i] != nil && $1.to_i > 0
root_paths = {}
root_skills = []
(self.note.scan (/\\ROOT_SKILL\[(\d+),?\s*(\d*),?\s*?<?([\d ,;:]*?)>?,?\s*?([F1]?)\]/i)).each { |match|
id = match[0].to_i
n = match[1].to_i
supplement_skills = []
(match[2].scan (/\d+?/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?
forget = !match[3].empty?
root_skills.push ([id, n, forget, supplement_skills])
}
root_skills.each { |array|
key = ([array[0]] + array[3]).sort
root_paths[key] = [] if !root_paths[key]
root_paths[key].push (array[0, 3])
}
root_paths.each { |key, path|
if path.size < key.size
key.each { |key2|
exists = false
path.each { |array| exists = true if path[0] == key2 }
path.push ([key2, 0, false]) if !exists
}
end
path.sort! { |a, b| a[0] <=> b[0] }
@ma_root_skills.push (path)
}
@ma_root_skills.each { |path|
path.each { |d_id, n, forget|
$data_skills[d_id].ma_descendant_skills = [] if $data_skills[d_id].ma_descendant_skills.nil?
d_skills = $data_skills[d_id].ma_descendant_skills
d_skills.push (self.id) unless d_skills.include? (self.id)
}
}
# Prohibited Classes
(self.note.scan (/\\PROHIBIT_CLASS\[(\d+)\]/i)).each { |id|
@ma_prohibited_classes.push (id[0].to_i)
}
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Compatibility with Note Editor + General Compatibility Patch
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if self.method_defined? (:ma_reset_note_values)
alias malg_lsu_rsetnote_8uk2 ma_reset_note_values
def ma_reset_note_values (*args)
malg_lsu_rsetnote_8uk2 (*args) # Run Original Method
@ma_root_skills.each { |path|
path.each { |a| $data_skills[a[0]].ma_descendant_skills.delete (self.id) }
}
ma_cache_lsu_skill_stats # Recache skill stats for LSU
end
end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - initialize; level_up
# new method - lsu_skill_requirements_met?; learn_skill_by_use; skill_count;
# increase_skill_count; skill_mastered?
#==============================================================================

class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_brnchskill_stp_1xc3 setup
def setup (*args)
@lsbu_skill_count = []
# Run Original Method
modalg_brnchskill_stp_1xc3(*args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Level Up
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_skl_brnches_byuse_lvlplus_0kb2 level_up
def level_up (*args)
# Run Original Method
malg_skl_brnches_byuse_lvlplus_0kb2 (*args)
# Check all skills to see if requirements have been met to learn the skill
skills.each { |skill|
skill.ma_descendant_skills.each { |descendant_id|
descen = $data_skills[descendant_id]
if !@skills.include? (descen.id) && lsu_skill_requirements_met? (descen)
# Learn Skill
learn_skill_by_use (descen.id)
end
}
}
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Check if this actor meets requirements to learn skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def lsu_skill_requirements_met? (skill)
return false if skill.ma_prohibited_classes.include? (@class_id)
return false if @level < skill.ma_level_requirement
skill.ma_root_skills.each { |path|
path_complete = true
path.each { |reqs|
if skill_count (reqs[0]) < reqs[1]
path_complete = false
break
end
}
return true if path_complete # If all requirements met
}
return false
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Learn Skill By Use
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def learn_skill_by_use (skill_id)
forgets = []
$data_skills[skill_id].ma_root_skills.each { |path|
path.each { |reqs| forgets.push (reqs[0]) if reqs[2] }
}
forgets.each { |forget_id| forget_skill (forget_id) }
learn_skill (skill_id)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Retrieve Skill Count
# skill_id : ID of skill checked
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def skill_count (skill_id)
@lsbu_skill_count[skill_id] = 0 if @lsbu_skill_count[skill_id].nil?
return @lsbu_skill_count[skill_id]
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Increase Skill Count
# skill_id : ID of skill increased
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def increase_skill_count (skill_id)
@lsbu_skill_count[skill_id] = skill_count (skill_id) + 1
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Skill Mastered?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def skill_mastered? (skill)
return skill_count (skill.id) >= skill.ma_master_uses
end
end

#==============================================================================
# ** Window_Help
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - lsu_set_secondary_text
#==============================================================================

class Window_Help
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Set Secondary Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def lsu_insert_secondary_text (text, align = 2)
# Check if real text has changed
if (@lsu_changed_text != @text) || (@lsu_changed_align != @align)
if LSU_COUNT_FONTCOLOR.is_a? (Integer)
self.contents.font.color = text_color (LSU_COUNT_FONTCOLOR)
else
self.contents.font.color = Color.new (*LSU_COUNT_FONTCOLOR)
end
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
@lsu_changed_text, @lsu_changed_align = @text, @align
end
end
end

#==============================================================================
# ** Window_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - update_help
#==============================================================================

class Window_Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Update Help Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_lsu_updhelp_uses_8kh2 update_help
def update_help (*args)
if LSU_BUTTONSHOW
if Input.press? (LSU_BUTTON) && @actor
@help_window.set_text (ma_use_text, LSU_SHOWCOUNT_ALIGN)
else
ma_lsu_updhelp_uses_8kh2 (*args)
end
else
ma_lsu_updhelp_uses_8kh2 (*args)
return unless @actor && skill
@help_window.lsu_insert_secondary_text (ma_use_text)
end
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Get Use Text
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def ma_use_text
add = ""
if LSU_SHOW_MASTERY
if @actor.skill_mastered? (skill)
return LSU_VOCAB_MASTERY if LSU_MASTER_REPLACE
add = LSU_VOCAB_MASTERY
else
add = " / #{skill.ma_master_uses}"
end
end
return LSU_VOCAB_USECOUNT + @actor.skill_count(skill.id).to_s + add
end
end

#==============================================================================
# ** Scene_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - lsu_advance_skill_count
#==============================================================================

class Scene_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Advance Skill Count
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def lsu_advance_skill_count (user, skill)
# Increase skill count
user.increase_skill_count (skill.id)
if LSU_LEARN_IMMEDIATELY
new_skills = []
skill.ma_descendant_skills.each { |descendant_id|
descendant = $data_skills[descendant_id]
# Check requirements
if !user.skill_learn? (descendant) && user.lsu_skill_requirements_met? (descendant)
new_skills.push (descendant)
end
}
for new_skill in new_skills
user.learn_skill_by_use (new_skill.id)
Dialog_LearnSkill.show (user, new_skill)
end
end
end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - load_database; load_bt_database
#==============================================================================

class Scene_Title
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Load Database
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malsu_lddata_5yj7 load_database
def load_database (*args)
malsu_lddata_5yj7 (*args) # Run Original Method
$data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Load Battle Test Database
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_lsu_btdat_6yh1 load_bt_database
def load_bt_database (*args)
malg_lsu_btdat_6yh1 (*args) # Run Original Method
$data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
end
end

#==============================================================================
# ** Scene_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - use_skill_nontarget
#==============================================================================

class Scene_Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Use Skill Nontarget
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias ma_lsu_uskll_7uj2 use_skill_nontarget
def use_skill_nontarget (*args)
ma_lsu_uskll_7uj2 (*args) # Run Original Method
lsu_advance_skill_count (@actor, @skill) # Advance Skill Count
end
end

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - execute_action_skill
#==============================================================================

class Scene_Battle
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Execute Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mdrnalg_exctskl_lsbu_4nv2 execute_action_skill
def execute_action_skill (*args)
mdrnalg_exctskl_lsbu_4nv2 (*args) # Run Original Method
# Increase User's skill count if actor
lsu_advance_skill_count (@active_battler, @active_battler.action.skill) if @active_battler.actor?
end
end
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on February 03, 2011, 04:37:17 AM
When does it occur? I just tried it in a new project and didn't get an error. Just tell me how to recreate it and I will find and fix it
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 04:52:50 AM
When I start the game it does it before anything loads.

Error

Scrit Mod_Learn line 164 syntax error occoured.
Title: Re: Learn Skills By Use 2.0
Post by: pacdiggity on February 03, 2011, 05:03:07 AM
You've probably accidentally just put an unnecessary character in the line. This is what it should be, if I am not mistaken:

Code: [Select]
  LSU_SHOWCOUNT_ALIGN = 0    # Alignment of text if LSU_BUTTONSHOW is true

You could change the 0 to any other number (I would keep it default though) but don't change anything else. Make sure that the line is right, with no [s or {s or =s or # etc etc.
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 05:10:01 AM
Nope, but I think I'm on to what's wrong. When doing a bolean, you can't have a #tag or space after it.

Edit: Nope, that doesn't seem to be it. Maybe when I copied and posted the code it came out wrong. I seem to have great difficulty copying and pasting the code from this site.
Title: Re: Learn Skills By Use 2.0
Post by: pacdiggity on February 03, 2011, 05:19:00 AM
Try toggling LSU_BUTTONSHOW. You never know.
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on February 03, 2011, 06:10:09 AM
No. But I copied the script you gave into a new project and there was no syntax error anywhere. Try giving me the demo of the new project you created to test it. Just compress game data (don't encrypt it though) and attach it to a post. To attach, you have to be doing a regular reply (not quick) and go to additional options to find the place to add attachments. Otherwise, you could also do it via an uploading site like sendspace.
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 04:23:22 PM
Its a new default project. Let me make a new default project and see if anything strange happens. Still same thing.

Anyway, I went through line by line and if I have a space in front of a #line then it would give me an error. So hope this helps someone else. Remove the spaces in front of #s.

Edit: Thank you both for your help and thank you Modern for making the script in the first place. I've used an older version, so I look forward to seeing what the upgrade brings.
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 05:15:09 PM
On second thought it didn't fully work. Now there's a problem when I go into an actor's skill menu via the main menu or via the battle menu. It gets some kind of stack error. Le Sigh. Maybe it has to do with this?

#============================================================
#    Show Skill Count in Help
#      (Addon to Learn Skills By Use 1.0)
#    Version: 1.1
#    Author: modern algebra (rmrk.net)
#    Date: January 23, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on February 03, 2011, 07:26:54 PM
No, those are comments; there's no way that would cause an error, nor would it cause an error by having #s instead of # s. They aren't causing any errors. Like I said, give me a demo of the project and tell me how to recreate the error and I will try and fix it.
Title: Re: Learn Skills By Use 2.0
Post by: ShortStar on February 03, 2011, 07:34:19 PM
Well yes those were comments. Having spaces before the # did matter. This new problem seems to be something different, probably a script conflict with something else I'm using, because it this script works with my new default game that has no scripts.
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on February 03, 2011, 07:49:32 PM
Well, no; you are not correct. You may have inadvertently fixed whatever was wrong when you were going through the script, but I am 100% positive that wasn't the problem.

Anyway, it may very well be a script conflict, but again, I can't help you without seeing a demo with the error recreated.
Title: Re: Learn Skills By Use 2.0
Post by: merryjest on May 19, 2011, 06:32:42 AM
The script is beautiful, simply beautiful! However,  is there any way to make it work with Gubid's Tactical Combat? I've been trying to think of how it might be made compatible with it.
Title: Re: Learn Skills By Use 2.0
Post by: Infinate X on June 18, 2011, 02:38:54 AM
Is it possible to make a menu option that calls Scene_Skill but when you open the menu it shows and experience bar where the description should be without much edits?
Title: Re: Learn Skills By Use 2.0
Post by: enrique_AVI on June 23, 2011, 02:14:29 AM
Hi, I tried to make this work but I just couldn't work it. I keep getting an error that says
"Script 'Learn Skills By Use' line 404: NoMethodError occurred.
undefined method '[]' for nil:NilClass"

I don't understand why it's not working. I hope it's not one of the other scripts i got
I need some help please and thank you.
Title: Re: Learn Skills By Use 2.0
Post by: J. Moreno on July 14, 2011, 11:53:30 PM
This script is great, very usefull, my only question is...

Im using the skill learn by equipment, so i dont want to for example:

Ice Sword teaches = Ice Strike

I dont want that in the right corner of the skills screen at the menu appears the "used count" because there is NO upgrade for that movement, what can i do to delete the "used count" for the Ice Strike? i dont want to give fake expectations to the players... also i dont want all my skills be upgraded. Can anyone help me with that?
Title: Re: Learn Skills By Use 2.0
Post by: stucko on August 27, 2011, 01:10:40 PM
hey, just wondering if someone could help me with this script. I've put it in below all the other scripts that i've got, and set all the tags, but when i go to test my game, it pops up with this error message
line 308 : NoMethodError occurred
undefined method 'ma_descendant_skills' for Nil:NilClass
i've got it set so the skills are learned on level up. Would be awesome if someone could give me a hand. Thanks in advance
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on August 27, 2011, 09:45:45 PM
Hmm, well it sounds like maybe you said one of the root skills was either 0 or an ID exceeding the last skill in the database.

You can fix it by pasting the following line directly above line 308:

Code: [Select]
        next if $data_skills[d_id].nil?

So that part would look like:
Code: [Select]
    @ma_root_skills.each { |path|
      path.each { |d_id, n, forget|
        next if $data_skills[d_id].nil?
        $data_skills[d_id].ma_descendant_skills = [] if $data_skills[d_id].ma_descendant_skills.nil?
        d_skills = $data_skills[d_id].ma_descendant_skills
        d_skills.push (self.id) unless d_skills.include? (self.id)
      }

But bear in mind that since the error is occuring, you likely have a tag set up wrong somewhere, so you should take a look at them.
Title: Re: Learn Skills By Use 2.0
Post by: stucko on August 28, 2011, 11:09:02 AM
found the problem. it was a wrong tag. everything works fine now. thanks heap for the help  ;D
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 05, 2011, 02:09:46 AM
Ok, this is what I'm trying to do.. 

I'm creating a "Spellsword" class, and I want the actor to learn the skills by use, right now I have it set up like this:

 The starting abilities you gain by leveling up are:

Fire Sword
Ice Sword
Lightning Sword
Earth Sword

I created 4 states one for each element, and 4 common events that look like this:

I have it set that when you use Fire Sword it triggers a common event:
Change Skills:[Valdraek], - Lightning Strike
Change Skills:[Valdraek], - Electroshock      (These get rid of all the skills of the opposite swords and then add the skills appropriate.)
Change Skills:[Valdraek], + Fire Charge
etc.

Now these common events work perfectly.. so when you use the sword elements it gets rid of skills that dontt apply to the elements as shown above.

My problem is that if I set conditional modifiers to make it so that he won't learn it to certain levels even when he levels it won't display the message that he actually learned it..

So this is my theory..

I wanted to use this script to make it so that when he uses "Fire Sword" or "Ice Sword, etc..  say like 50 times, or mre, or whatever.. he will learn the skill..  I read in some of the above comments that it only learns the skill at a level up, but i want it to be minimum level to learnn the skill, not necessarily only when the actor levels.. like:

If Fire Sword is used 50 times and actor is at least level 17.. learn "Fire Charge".

Now here is the big problem..  now when the character learns the skill.. it will be displayed as learned.. and appear in thhe menu.. which I don't want..  I only want the skills to be displayed when you use the appropriate Elemental Sword skill..  like I have it said in my common event..  I don't mean to be a pain in the ass but can this be done with your script? 

Oh.. also I tried to play around with this script and I'm getting an error:

Script 'Learn Skill By Use' line 185: TypeError occured.

undefined superclass 'Dialog'


Copied the code directly, what do you think the problem can be?




Title: Re: Learn Skills By Use 2.0
Post by: pacdiggity on October 05, 2011, 02:17:36 AM
Oh.. also I tried to play around with this script and I'm getting an error:

Script 'Learn Skill By Use' line 185: TypeError occured.

undefined superclass 'Dialog'


Copied the code directly, what do you think the problem can be?
If using the Learn Skill immediately upon meeting requirements option, then you NEED to have Zeriab's Dialog System (http://rmrk.net/index.php/topic,24828.0.html)!
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 05, 2011, 02:18:40 AM
Ok, I needed Zeriab's script to make it work, got that down.. now its just making it so that the skills dont show up when the proper elemental sword is not in use (this  is controlled by a state and a common event like I stated above.)
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 06, 2011, 05:22:04 PM
Bump.

Any ideas? This is really stumping me, I need this class to work right, its crucial for my game.  Understand the problem? Let me know please!
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 07, 2011, 08:51:19 PM
OK, well with the Dialog script which you now have and:

LSU_LEARN_IMMEDIATELY = true

then the skill is learned immediately.

As for the minimum level:

Quote from: Instructions in the Header of the Script
Code: [Select]
#    To set a minimum level for learning a skill through usage requirements,
#   put this code in the notebox of a skill:
#
#      \MIN_LEVEL[x]
#        x : an integer that is the minimum level. An actor cannot learn
#          the skill until his level is at least equal to x.

So, in the notebox of your "Fire Charge" skill, if you set it up so that you need to use the root skill of Fire Sword 50 times and then put:

Code: [Select]
\MIN_LEVEL[17]

then you would need to use Fire Sword 50 times and you would only learn Fire Charge if you were level 17 or higher.

Now I don't understand this part of your post at all:

Quote
Now here is the big problem..  now when the character learns the skill.. it will be displayed as learned.. and appear in thhe menu.. which I don't want..  I only want the skills to be displayed when you use the appropriate Elemental Sword skill..  like I have it said in my common event..  I don't mean to be a pain in the ass but can this be done with your script?

Namely, I don't understand how the character is learning the skill without using the appropriate Element Sword Skill. With my script, if you set it to require 50 uses of Fire Sword, it won't be learned until Fire Sword is used 50 times. As long as your event works and you remove Fire Sword when the right sword isn't equipped, then Fire Charge won't be learned when you use the other skills.

Furthermore, with this script, Fire Charge would only be learned directly after using Fire Sword the 50th time (or else upon levelling to the minimum level if Fire Sword had already been used 50 times prior to obtaining that level). So it wouldn't be learned when you used Electric Strike the 50th time, so ostensibly, it would only appear after having used the "appropriate Elemental Sword skill."

The only way that I understand that part of your post is if, in trying to set a minimum level, you are actually setting the character to learn Fire Charge at level 17 through the regular database way. That is incorrect unless you want the character to learn Fire Charge at level 17 whether he's used Fire Sword enough times or not. You should just get rid of it and go through the \min_level route described above.

I might have misunderstood that, so if I did, please clarify.

I hope that answers all your questions. Be sure to read the instructions of scripts from now on. They do have a purpose after all, and it's to help you use the script. In this case, as long as I have not misunderstood your problem, reading the Instructions would have solved both of your problems and a lot faster than it took to provoke a response from Pacman and I.

By the way, thanks for helping out Pacman.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 08, 2011, 03:32:57 PM
Ok, here is the situation.  I'm able to make your script work perfectly. I think I need some kind of edit however.

I'm going to try to explain this as plainly as possible.... here goes!

I'm making a "Spellsword" class.

The way the I want the Spellsword to work is he learns skills the more he imbues his sword with elemental type magic... so he learns abilities such as Fire Sword and Ice Sword from normal leveling..  now I use your script so if he uses Fire Sword 20 times he learns "Flaming Charge"....


CONSIDER:

The Spellsword can only use the abilities from that type of element he casts on his sword.

EXAMPLE:

Valdraek casts Fire Sword!

Now in the skill menu it should now give him his abilities for that type of element:

(http://i52.tinypic.com/2qltlzt.jpg)

Notice how when you use Fire Sword you have access to two abilities:
Flaming Charge, and Blazing Whirlwind

Now.... if you cast Ice Sword:

(http://i53.tinypic.com/21kkynr.jpg)

THe two fire abilities are removed and are replaced with the abilities of ice:
Freezing Rain, Glacial Blast


And this works fine with common eventing, every event just makes the actor forget the abilities, I even went as far as creating a state for the two element sword types.

DILEMMA:

Now that I have incorporated your awesome script.. 

I iearn the ability of Fire Sword, and it stays with you,  if I use Ice Sword the ability is forgotten like normal, however when I use Fire Sword again, it says "Valdraek has learned Fiery Charge"  which isn't necassarily a bad thing.. but the problem I'm having.. is using my common events to change between the element types.  It should be something like this:


*Using FireSword*
If Valdraek has used Fire Sword 20 times:  Learn Flaming Charge
If Valdraek has used Fire Sword 60 times:  Learn Blazing Whirlwind
Forget Ice Abilities  (And all other elemental types once I add them there will be 8 in all I think.)

The way I have this system is with a common event, but I don't know how to make it so that when you use the elemental sword type, it actually calls the learned abilities from the script..


So if Valdraek is Level 17.. and posesses Flaming Charge:  He would only learn flaming charge:
And not the other Fire abilities..

I don't know if I'm explaining this right.. but it is very important system for my game. The COmmon event system looks like this right now..

Trigger Common Event When Use of Fire Sword

Change Skills:[Valdraek], - Glacial Blast
Change Skills:[Valdraek], - Freezing Rain      (These get rid of all the skills of the opposite swords and then add the skills appropriate.)
Change Skills:[Valdraek], + Flaming Charge
Change Skills:[Valdraek], + Blazing Whirlwind
etc.

Now I think it should look like this but I don't know how to make it happen:
 
Trigger Common Event When Use of Fire Sword

Change Skills:[Valdraek], - Glacial Blast
Change Skills:[Valdraek], - Freezing Rain      (These get rid of all the skills of the opposite swords and then add the skills appropriate.)
Conditional Branch:  If Valdraek has used [Fire Sword] 20 times, and is at least level 17:
Change Skills:[Valdraek], + Flaming Charge
Conditional Branch:  If Valdraek has used [Fire Sword] 60 times, and is at least level 22:
Change Skills:[Valdraek], + Blazing Whirlwind
etc.


This I think would work perfectly and if you can, I would like you to make this an addon for your script, or at least tell me how to get it done.  I hope that this was a bit for clarifying for you, please let me know if you don't understnad a part of this.


Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 08, 2011, 04:16:20 PM
Alright, thanks. That is a helpful clarification. All you would need to do is use the script field of conditional branch and input the following code:

Code: [Select]
actor.lsu_skill_requirements_met? (skill)

where:
    actor is a Game_Actor object
    skill is a RPG::Skill

So, that will require IDs of Valdraek and the skills, which I obviously don't know, but it will end up looking like this:

Code: [Select]
$game_actors[5].lsu_skill_requirements_met? ($data_skills[22])

where Valdraek is the actor with ID 5 and Flaming Charge is the skill with ID 22. So replace the 5 in the above code with the actual ID of Valdraek and the 22 with the actual ID of Flaming Charge and you'll be all set.

Overall, the event would look like this:

@>Conditional Branch: Script: $game_actors[5].lsu_skill_requirements_met? ($data_skills[22])
    @>Change Skills: [Valdraek], + [Flaming Charge]
    @>
 :  Branch End


etc. for each of the skills you add.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 08, 2011, 10:47:16 PM
Thank you so much as always, MA. It works SUPERBLY. THANK YOU THANK YOU! :V
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 09, 2011, 07:26:40 AM
I reached a point in which Im stuck.. perhaps Im just not setting it up correctly. I want to make it that whenu you use fire sword and ice sword 8 times each you will learn Earth sword.. i have this in the note for earth sword:

\ROOT_SKILL[167, 8, <174>]
\ROOT_SKILL[174, 8, <167>]

What am I doing wrong?
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 09, 2011, 11:34:58 AM
As long as 167 and 174 refer to Fire Sword and Ice Sword, then what you have seems right. In what way is it not working?
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 09, 2011, 03:33:20 PM
Well, I used Fire Sword 8 times and learned it without using ice sword at all.. I'm pretty sure everything is set up right..  I want the character to have to use fire sword and ice sword 8 times each before earth sword is unlocked.. 
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 09, 2011, 05:02:13 PM
Maybe recreate the error in a demo and send it to me. I will check it out.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 11, 2011, 12:59:48 AM
How do I upload a demo for you? :-/

I made it..
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 13, 2011, 02:52:26 PM
bump
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 13, 2011, 03:00:51 PM
Well, first make it into an executable or rar it or something.

Then, when you are making a reply, there is an option at the bottom that says: Attachments and Other Options. Click that and you will see a Browse bar where you can select the file and upload it.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 13, 2011, 04:42:38 PM
Here it is.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 16, 2011, 04:32:56 AM
Have you had a chance to look at it yet? I've tried looking it over.. perhaps it has something to do with another script im using?
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 19, 2011, 06:08:22 PM
bump
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 19, 2011, 10:05:36 PM
Alright, I took a look. Go to line 286 and you ought to see:

Code: [Select]
    (match[2].scan (/\d+?/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?

Change that line to:

Code: [Select]
    (match[2].scan (/\d+/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?


Thanks for the error report. That was a major problem.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 20, 2011, 01:51:13 AM
No problem, I'm glad I could help.


----

However, I'm still running into the same problem..
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 27, 2011, 02:18:24 AM
Don't know if you've seen this yet, MA.  But it's still having the same problem as before even with the fix.. am I doing something wrong?
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 27, 2011, 08:42:05 PM
Well, I tested in the demo you provided and it works when I made that fix. So... I'm not sure what the problem is. That is the only change I made, but try recopying the script from the first post and replace the one you have in case you modified the wrong line. Then give it a test.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 28, 2011, 01:54:22 AM
Tryed it, I'm so hopeless.. -.-;  Heres the code, I dont see anything wrong..  not even that important anymore, I'll just do it the normal way without that feature I guess.

Code: [Select]
#==============================================================================
#    Learn Skills By Use
#    Version: 2.0b
#    Author: modern algebra (rmrk.net)
#    Date: October 29, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  NB: If you wish to use the learn immediately option of the script, then
#   Zeriab's Dialog System is required and he should be credited. You can find
#   it here: http://rmrk.net/index.php/topic,24828.0.html
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to have actors learn skills by using other skills.
#   For instance, you could set it so that an actor will learn Fire II only
#   after he has used Fire 50 times. You can also set it so that there can be
#   multiple paths to learning a skill and multiple skill requirements. For
#   instance, that same actor could also learn Fire II if he has used Flame
#   60 times and Flame II 25 times. However, you can also set class
#   prohibitions and level requirements, so if you never want a Paladin to
#   learn Fire II no matter how many times he uses its root skills, then it is
#   easy to set that up, and if you don't want Fire II to be learned by any
#   actor until they are at least level 7, then that can be setup too. You may
#   also set it up so that it is like an upgrade - Fire becomes obsolete once
#   Fire II is learned, and so you can simply forget Fire once you have Fire II
#   It also has two options of ways to show the number of times you've used a
#   skill.
#
#    Also, you can set it so that the actor either learns the new skill
#   immediately upon meeting use requirements, or at his/her next level.
#
#    Further, this doesn't interfere with the regular skill learning system, so
#   if you set it that a mage will learn Fire II at level 6 in the Class Tab
#   of the database, than the mage will learn Fire II at level 6 no matter if
#   she has met the use requirements of its root skills, and no matter what
#   the class prohibitions or level requirements are.
#
#    There are also a number of options you can set regarding how to show the
#   number of uses in the help window, and you can do it by either pressing a
#   button or it will show up at the same time as the description. There is
#   also a new set of mastery options.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials in the Editor. It should
#   also be below any custom levelup scripts you may have. If set to learn
#   immediately, then Zeriab's Dialog System is required above this script:
#       http://rmrk.net/index.php/topic,24828.0.html
#
#    To set up a skill to be learned through use, you must use this code in a
#   notes box:
#
#      \ROOT_SKILL[skill_id, number_of_uses, <supplement_skills>, forget]
#        skill_id : The ID of the root skill that leads to this skill.
#        number_of_uses : An integer - the number of times the root skill has
#          be used before it teaches this skill.
#        <supplement_skills> : a list of skill IDs that also have to have their
#          root requirements fulfilled before the skill will be learned. It is
#          of the format: <x, y, z> where x, y, and z are the IDs of the other
#          skills that must have usage requirements met. You can have as many
#          as you like. Note, however, that you must set up one of these
#          requirements notes for each of the other skills as well, and you
#          must cross-reference the skills in this path. Defaults to <>,
#          meaning that the only usage requirements needed to be filled is this
#          one
#        forget : If this is set to 1, then the root skills will be forgotten
#          once this skill is learned. If left blank or set to any other digit,
#          than the root skills will be retained.
#
#  EXAMPLE A:
#
#    This code in the notebox of a skill:
#
#      \ROOT_SKILL[9, 100]
#
#    There is only one path to learning this skill:
#      (i) Use the skill with ID 9 at least 100 times.
#
#    No skill is forgotten
#
#  EXAMPLE B:
#
#    These codes in the notebox of a skill:
#
#      \ROOT_SKILL[1, 20, 1]
#      \ROOT_SKILL[4, 15, <5>]
#      \ROOT_SKILL[5, 8, <4>]
#
#    With these codes, there are two paths to learning this skill.
#      (i)  Use the skill with ID 1 at least 20 times.
#      (ii) Use the skill with ID 4 at least 15 times and use the skill with
#         ID 5 at least 8 times.
#
#    No matter which path is taken to the skill, the skill with ID 1 will be
#   forgotten as soon as the new skill is learned.
#
#  EXAMPLE C:
#
#    The following codes in the notebox of a skill:
#
#      \ROOT_SKILL[6, 100]
#      \ROOT_SKILL[7, 100]
#      \ROOT_SKILL[6, 20, <7, 8>]
#      \ROOT_SKILL[7, 25, <6, 8>]
#      \ROOT_SKILL[8, 15, <6, 7>]
#
#    With these codes, there are three paths to learning this skill.
#      (i)   Use the skill with ID 6 at least 100 times
#      (ii)  Use the skill with ID 7 at least 100 times
#      (iii) Use the skill with ID 6 at least 20 times, the skill with ID 7 at
#          least 25 times, and the skill with ID 8 at least 15 times.
#
#    No matter which path is taken, no skills will be forgotten.
#
#    To prohibit a class from learning a skill through usage requirements,
#   put this code in a notebox of a skill:
#
#      \PROHIBIT_CLASS[class_id]
#        class_id : ID of class not allowed to learn this skill through use
#
#    To set a minimum level for learning a skill through usage requirements,
#   put this code in the notebox of a skill:
#
#      \MIN_LEVEL[x]
#        x : an integer that is the minimum level. An actor cannot learn
#          the skill until his level is at least equal to x.
#   
#  Next, you may want to setup if and how the use count is displayed. To, set the text that you
#  want to signify the count under LSU_VOCAB_USECOUNT at line 159, and you can
#  set the color of the text at line 165 - LSU_COUNT_FONTCOLOR. If this is an
#  integer, it takes the color from the windowskin palette. You could also set
#  it as an array of the form: [red, green, blue, alpha].
#   Alternatively, you could set it up to only show the skill count if the
#  player presses a specified button. You would not get to choose the color in
#  that case, but would get to specify alignment.
#
#   Lastly, there is now an option to show "Mastery". You can specify a number
#  of uses to meet this threshold. When showing use count, it will show up as
#  # of uses / mastery threshold, and once reached, it will be replaced by any
#  text you choose. Those options are between lines 162 and 168. To set the
#  threshold for a skill individually, use the following code:
#      \MASTER[x]
#        x : the number of uses to reach mastery.
#==============================================================================

#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
#  EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
LSU_LEARN_IMMEDIATELY = true # Whether to learn the skill immediately upon
                             #  meeting usage requirements or to wait for level
                             #  If true, you MUST have Zeriab's Dialog System:
                             #  http://rmrk.net/index.php/topic,24828.0.html
LSU_VOCAB_OBTAIN_SKILL = "%n has learned %s!" # The message shown when an actor
                             # learns a new skill if immediate and not on level
LSU_SE_OBTAIN_SKILL = "Skill" # The SE that plays when an actor learns a new
                             # skill. Again, only applies if on immediate.
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_USE = true          # Whether or not to show use count at all in the
                             #  the help window.
LSU_VOCAB_USECOUNT = "Used: " # Text to label skill count
LSU_BUTTONSHOW = false       # Whether or not it shows up with the description
                             #  or is drawn only when pressing a button
  LSU_BUTTON = Input::SHIFT  # If LSU_BUTTONSHOW is true, what button needs to
                             #  be pressed to show the skill use count
  LSU_SHOWCOUNT_ALIGN = 0    # Alignment of text if LSU_BUTTONSHOW is true
LSU_COUNT_FONTCOLOR = 16     # Font color if LSU_BUTTONSHOW is false
#``````````````````````````````````````````````````````````````````````````````
LSU_SHOW_MASTERY = false     # Whether or not to show some the word for mastery
                             #  when a script has been used to its maximum
                             #  efficiency or to a stated goal.
LSU_DEFAULT_MASTERY = 100    # The default number of uses for mastery
LSU_VOCAB_MASTERY = "[MASTERED]" # The word to show once skill use reaches goal
LSU_MASTER_REPLACE = true    # Whether to replace the Used: x text or simply be
                             #  placed after it.
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
#  END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////

if LSU_LEARN_IMMEDIATELY
#==============================================================================
# ** Dialog_DiscoverFavourite
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This class processes when a favourite item is discovered
#==============================================================================

class Dialog_LearnSkill < Dialog
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * A show method
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize(actor, skill)
    @actor = actor
    @skill = skill
    begin
      (RPG::SE.new (*skill.ma_learn_se)).play
    rescue
      (RPG::SE.new ("Skill")).play
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_window
    text = help_text
    tw = [@background_sprite.bitmap.text_size (text).width + 40, Graphics.width].min
    @learn_window = Window_Help.new
    @learn_window.width = tw
    @learn_window.create_contents
    @learn_window.x = (Graphics.width - tw) / 2
    @learn_window.y = (Graphics.height - @learn_window.height) / 2
    @learn_window.z = STARTING_Z_VALUE + 1
    @learn_window.set_text (text, 1)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def help_text
    text = LSU_VOCAB_OBTAIN_SKILL.gsub (/%s/) { @skill.name }
    text.gsub! (/%n/) { @actor.name }
    return text
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose the windows
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def main_dispose
    @learn_window.dispose
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def update
    if Input.trigger?(Input::B) || Input.trigger?(Input::C)
      mark_to_close
      self.value = false
    end
  end
end
end

#==============================================================================
# ** Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public variables - ma_root_skills; ma_descendant_skills;
#      ma_level_requirement; ma_prohibited classes
#    new methods - ma_learn_se; ma_cache_lsu_skill_stats
#==============================================================================

class RPG::Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :ma_root_skills
  attr_accessor :ma_descendant_skills
  attr_accessor :ma_level_requirement
  attr_accessor :ma_prohibited_classes
  attr_accessor :ma_master_uses
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn SE
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_learn_se
    # Not cached because it will only rarely be accessed. Better to use RAM
    if self.note[/\\LEARN_SE\[(.+?),?\s*(\d*?),?\s*(\d*?)\]/i] != nil
      learn_se = [$1.to_s]
      learn_se.push ($2.to_i) unless $2.empty?
      learn_se.push ($3.to_i) unless $3.empty?
    else
      return LSU_SE_OBTAIN_SKILL
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Cache LSU stats
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_cache_lsu_skill_stats
    # Get skill paths and descendants
    @ma_root_skills, @ma_prohibited_classes = [], []
    @ma_descendant_skills = [] if @ma_descendant_skills.nil?
    @ma_master_uses, @ma_level_requirement = LSU_DEFAULT_MASTERY, 1
    # Level Requirements
    @ma_level_requirement = $1.to_i if self.note[/\\MIN_LEVEL\[(\d+)\]/i] != nil
    @ma_master_uses = $1.to_i if self.note[/\\MASTERY?\[(\d+)\]/i] != nil && $1.to_i > 0
    root_paths = {}
    root_skills = []
    (self.note.scan (/\\ROOT_SKILL\[(\d+),?\s*(\d*),?\s*?<?([\d ,;:]*?)>?,?\s*?([F1]?)\]/i)).each { |match|
    id = match[0].to_i
    n = match[1].to_i
    supplement_skills = []
        (match[2].scan (/\d+/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?
    forget = !match[3].empty?
      root_skills.push ([id, n, forget, supplement_skills])
    }
    root_skills.each { |array|
      key = ([array[0]] + array[3]).sort
      root_paths[key] = [] if !root_paths[key]
      root_paths[key].push (array[0, 3])
    }
    root_paths.each { |key, path|
      if path.size < key.size
        key.each { |key2|
          exists = false
          path.each { |array| exists = true if path[0] == key2 }
          path.push ([key2, 0, false]) if !exists
        }
      end
      path.sort! { |a, b| a[0] <=> b[0] }
      @ma_root_skills.push (path)
    }
    @ma_root_skills.each { |path|
      path.each { |d_id, n, forget|
        $data_skills[d_id].ma_descendant_skills = [] if $data_skills[d_id].ma_descendant_skills.nil?
        d_skills = $data_skills[d_id].ma_descendant_skills
        d_skills.push (self.id) unless d_skills.include? (self.id)
      }
    }
    # Prohibited Classes
    (self.note.scan (/\\PROHIBIT_CLASS\[(\d+)\]/i)).each { |id|
      @ma_prohibited_classes.push (id[0].to_i)
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Compatibility with Note Editor + General Compatibility Patch
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  if self.method_defined? (:ma_reset_note_values)
    alias malg_lsu_rsetnote_8uk2 ma_reset_note_values
    def ma_reset_note_values (*args)
      malg_lsu_rsetnote_8uk2 (*args) # Run Original Method
      @ma_root_skills.each { |path|
        path.each { |a| $data_skills[a[0]].ma_descendant_skills.delete (self.id) }
      }
      ma_cache_lsu_skill_stats       # Recache skill stats for LSU
    end
  end
end

#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - initialize; level_up
#    new method - lsu_skill_requirements_met?; learn_skill_by_use; skill_count;
#      increase_skill_count; skill_mastered?
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_brnchskill_stp_1xc3 setup
  def setup (*args)
    @lsbu_skill_count = []
    # Run Original Method
    modalg_brnchskill_stp_1xc3(*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Level Up
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_skl_brnches_byuse_lvlplus_0kb2 level_up
  def level_up (*args)
    # Run Original Method
    malg_skl_brnches_byuse_lvlplus_0kb2 (*args)
    # Check all skills to see if requirements have been met to learn the skill
    skills.each { |skill|
      skill.ma_descendant_skills.each { |descendant_id|
        descen = $data_skills[descendant_id]
        if !@skills.include? (descen.id) && lsu_skill_requirements_met? (descen)
          # Learn Skill
          learn_skill_by_use (descen.id)
        end
      }
    }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Check if this actor meets requirements to learn skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_skill_requirements_met? (skill)
    return false if skill.ma_prohibited_classes.include? (@class_id)
    return false if @level < skill.ma_level_requirement
    skill.ma_root_skills.each { |path|
      path_complete = true
      path.each { |reqs|
        if skill_count (reqs[0]) < reqs[1]
          path_complete = false
          break
        end
      }
      return true if path_complete        # If all requirements met
    }
    return false
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Learn Skill By Use
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def learn_skill_by_use (skill_id)
    forgets = []
    $data_skills[skill_id].ma_root_skills.each { |path|
      path.each { |reqs| forgets.push (reqs[0]) if reqs[2] }
    }
    forgets.each { |forget_id| forget_skill (forget_id) }
    learn_skill (skill_id)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Retrieve Skill Count
  #    skill_id : ID of skill checked
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_count (skill_id)
    @lsbu_skill_count[skill_id] = 0 if @lsbu_skill_count[skill_id].nil?
    return @lsbu_skill_count[skill_id]
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Increase Skill Count
  #    skill_id : ID of skill increased
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def increase_skill_count (skill_id)
    @lsbu_skill_count[skill_id] = skill_count (skill_id) + 1
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Skill Mastered?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def skill_mastered? (skill)
    return skill_count (skill.id) >= skill.ma_master_uses
  end
end

#==============================================================================
# ** Window_Help
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - lsu_set_secondary_text
#==============================================================================

class Window_Help
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Set Secondary Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_insert_secondary_text (text, align = 2)
    # Check if real text has changed
    if (@lsu_changed_text != @text) || (@lsu_changed_align != @align)
      if LSU_COUNT_FONTCOLOR.is_a? (Integer)
        self.contents.font.color = text_color (LSU_COUNT_FONTCOLOR)
      else
        self.contents.font.color = Color.new (*LSU_COUNT_FONTCOLOR)
      end
      self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
      @lsu_changed_text, @lsu_changed_align = @text, @align
    end
  end
end

#==============================================================================
# ** Window_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - update_help
#==============================================================================

class Window_Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Help Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_lsu_updhelp_uses_8kh2 update_help
  def update_help (*args)
    if LSU_BUTTONSHOW
      if Input.press? (LSU_BUTTON) && @actor
        @help_window.set_text  (ma_use_text, LSU_SHOWCOUNT_ALIGN)
      else
        ma_lsu_updhelp_uses_8kh2 (*args)
      end
    else
      ma_lsu_updhelp_uses_8kh2 (*args)
      return unless @actor && skill
      @help_window.lsu_insert_secondary_text (ma_use_text)
    end
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Get Use Text
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_use_text
    add = ""
    if LSU_SHOW_MASTERY
      if @actor.skill_mastered? (skill)
        return LSU_VOCAB_MASTERY if LSU_MASTER_REPLACE
        add = LSU_VOCAB_MASTERY
      else
        add = " / #{skill.ma_master_uses}"
      end
    end
    return LSU_VOCAB_USECOUNT + @actor.skill_count(skill.id).to_s + add
  end
end

#==============================================================================
# ** Scene_Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - lsu_advance_skill_count
#==============================================================================

class Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Advance Skill Count
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def lsu_advance_skill_count (user, skill)
    # Increase skill count
    user.increase_skill_count (skill.id)
    if LSU_LEARN_IMMEDIATELY
      new_skills = []
      skill.ma_descendant_skills.each { |descendant_id|
        descendant = $data_skills[descendant_id]
        # Check requirements
        if !user.skill_learn? (descendant) && user.lsu_skill_requirements_met? (descendant)
          new_skills.push (descendant)
        end
      }
      for new_skill in new_skills
        user.learn_skill_by_use (new_skill.id)
        Dialog_LearnSkill.show (user, new_skill)
      end
    end
  end
end

#==============================================================================
# ** Scene_Title
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - load_database; load_bt_database
#==============================================================================

class Scene_Title
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malsu_lddata_5yj7 load_database
  def load_database (*args)
    malsu_lddata_5yj7 (*args) # Run Original Method
    $data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Load Battle Test Database
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_lsu_btdat_6yh1 load_bt_database
  def load_bt_database (*args)
    malg_lsu_btdat_6yh1 (*args) # Run Original Method
    $data_skills.each { |skill| skill.ma_cache_lsu_skill_stats if !skill.nil? }
  end
end

#==============================================================================
# ** Scene_Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - use_skill_nontarget
#==============================================================================

class Scene_Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Use Skill Nontarget
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_lsu_uskll_7uj2 use_skill_nontarget
  def use_skill_nontarget (*args)
    ma_lsu_uskll_7uj2 (*args)                # Run Original Method
    lsu_advance_skill_count (@actor, @skill) # Advance Skill Count
  end
end

#==============================================================================
# ** Scene Battle
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - execute_action_skill
#==============================================================================

class Scene_Battle
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Execute Skill
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mdrnalg_exctskl_lsbu_4nv2 execute_action_skill
  def execute_action_skill (*args)
    mdrnalg_exctskl_lsbu_4nv2 (*args) # Run Original Method
    # Increase User's skill count if actor
    lsu_advance_skill_count (@active_battler, @active_battler.action.skill) if @active_battler.actor?
  end
end
Title: Re: Learn Skills By Use 2.0
Post by: modern algebra on October 28, 2011, 11:33:09 PM
So, in the demo you gave me, you tried replacing 2.0b with 2.0c and it didn't work? It works perfectly fine in the demo you gave me (I've attached it to this post). For that matter, I pasted the version of the script you just posted with the changes you made manually and it worked fine.

I don't know what else I can tell you. I'm not experiencing that error at all.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on October 29, 2011, 04:22:58 PM
Oddly it works now after I copied from the demo! Thank you so much, MA.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on April 03, 2012, 07:07:40 PM
New problem! :D :D:D

The system that I had explained previously has been implemented in my game and works flawlessly.. but there is a small aesthetic error.. since I am technically relearning the skills over and over depending on the sword that I cast, it constantly shows "Valdraek learned Flaming Charge" Over and over again, everytime he changes stances, I was wondering if there was any way it would stop doing that, and not show up in the level up screen because I noticed that it shows up in there every level level up.  Thanks MA.
Title: Re: Learn Skills By Use 2.0
Post by: thanatos2k1 on April 17, 2012, 03:40:41 AM
Was wondering if you had seen this yet?