RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Learn Skills By Use 2.0

0 Members and 2 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Learn Skills By Use
Version: 2.0c
Author: modern algebra
Date: October 19, 2011

Version History


  • <Version 2.0c> 19.10.2011 - Fixed an error that would make supplemental skill paths not work if the ID was greater than 9
  • <Version 2.0b> 29.10.2010 - Fixed a bug that would keep showing the learn message when you used a descendant skill.
  • <Version 2.0a> 11.10.2010 - A simple update to make it more alias friendly. It is unnecessary unless you intend to use the Skill Levels addon.
  • <Version 2.0> 22.09.2010 - Release of version 2.0. Now includes an option to learn the skill immediately and incorporates the Show Use Count addon into the main script.
  • <Version 1.0> 27.08.2009 - Original Release

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

  • Allows you to learn skills by using other skills
  • Can set multiple paths to learning a skill
  • Can make paths that require more than one skill to be used however many times
  • Can learn the skill as soon as you meet use requirements or only upon levelup.
  • Can set class and level limitations on skills, so that the skills aren't learned too early or some classes can't get inappropriate skills
  • Can forget root skills once the new skill is learned, if you so desire. By default, root skills are retained when learning a new skill
  • Doesn't interfere with default skill learning system, so classes can still learn skills by levelling with no usage requirements
  • Can show the number of uses in the help window

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!

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


  • modern algebra
  • Zeriab. if using the learn immediately option (it requires his Dialog System)

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.
« Last Edit: October 19, 2011, 10:08:03 PM by modern algebra »

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Very cool MA!

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

**
Rep: +0/-0Level 83
Awesome job, I might try this out later depending on if I can finish off a couple of things first.

**
Rep: +0/-0Level 82
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.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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
« Last Edit: January 19, 2010, 04:27:09 PM by modern algebra »

**
Rep: +0/-0Level 83
...whatever
:blizj: your scripts are as always awsome :blizj:

Which Final Fantasy Character Are You?
Final Fantasy 7

1 thing: my english is very bad because im dislexion and im dutchXD

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
I'm glad you like them :)

****
Rep:
Level 83
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.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.
« Last Edit: May 28, 2010, 10:25:57 PM by modern algebra »

****
Rep:
Level 83
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

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

****
Rep:
Level 83
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

**
Rep: +0/-0Level 79
RMRK Junior
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?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Probably. Try it out and see.

**
Rep:
Level 76
Interested RMKR
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 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?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

**
Rep:
Level 76
Interested RMKR
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?)
« Last Edit: July 10, 2010, 05:50:11 AM by doomed2die »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.

**
Rep:
Level 76
Interested RMKR

*
Rep: +0/-0Level 76
RMRK Junior
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?

**
Rep:
Level 76
Interested RMKR
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?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.
« Last Edit: August 05, 2010, 02:19:00 PM by modern algebra »

**
Rep: +0/-0Level 75
RMRK Junior
 ;8 Ohmigosh, dude! I don't think I can contain myself. YOU ROCK! This is a great script.