-
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 (http://rmrk.net/index.php/topic,24828.0.html)!
Script
#==============================================================================
# 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.
-
Very cool MA!
-
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.
-
Awesome job, I might try this out later depending on if I can finish off a couple of things first.
-
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.
-
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.
-
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
-
:blizj: your scripts are as always awsome :blizj:
-
I'm glad you like them :)
-
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.
-
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.
-
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
-
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.
-
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
-
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?
-
Probably. Try it out and see.
-
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?
-
Yeah, sort of, but not in a way built in by the script. You can do it like this though:
@>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.
-
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?)
-
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.
-
Thanks :D
-
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?
-
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?
-
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.
-
;8 Ohmigosh, dude! I don't think I can contain myself. YOU ROCK! This is a great script.
-
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.
-
*BUMP*
If this is impossible, just let me know. LOL. Thanks!
-
No, it's not impossible - are you using default battle system?
-
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!
-
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.
-
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.
-
Well, I can do it, but it'll require Zeriab's Dialog System
-
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.
-
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!
-
Bump. Please and thank you. Let me now if there is anything I can do to help :)
-
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
-
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.
-
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.
-
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.
-
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.
-
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.
-
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!!
-
Nah, that's almost certainly my fault. I will fix it immediately.
EDIT:: You can now get the fixed script from the first post.
-
Thanks for the quick fix!
It works perfectly!
-
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!
-
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.
-
Uh boy codeboxes:
I have it in a blank new project too and it still doesn't work:
#==============================================================================
# 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
-
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
-
When I start the game it does it before anything loads.
Error
Scrit Mod_Learn line 164 syntax error occoured.
-
You've probably accidentally just put an unnecessary character in the line. This is what it should be, if I am not mistaken:
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.
-
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.
-
Try toggling LSU_BUTTONSHOW. You never know.
-
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.
-
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.
-
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
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-
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.
-
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.
-
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.
-
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.
-
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?
-
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.
-
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?
-
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
-
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:
next if $data_skills[d_id].nil?
So that part would look like:
@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.
-
found the problem. it was a wrong tag. everything works fine now. thanks heap for the help ;D
-
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?
-
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)!
-
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.)
-
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!
-
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:
# 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:
\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:
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.
-
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:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi52.tinypic.com%2F2qltlzt.jpg&hash=53901828764f7bca1f2170e761a08db4c99f48d6)
Notice how when you use Fire Sword you have access to two abilities:
Flaming Charge, and Blazing Whirlwind
Now.... if you cast Ice Sword:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi53.tinypic.com%2F21kkynr.jpg&hash=e6e116e66ae7af1c90c208c71071d8af9a4bc679)
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.
-
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:
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:
$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.
-
Thank you so much as always, MA. It works SUPERBLY. THANK YOU THANK YOU! :V
-
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?
-
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?
-
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..
-
Maybe recreate the error in a demo and send it to me. I will check it out.
-
How do I upload a demo for you? :-/
I made it..
-
bump
-
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.
-
Here it is.
-
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?
-
bump
-
Alright, I took a look. Go to line 286 and you ought to see:
(match[2].scan (/\d+?/)).each { |id2| supplement_skills.push (id2.to_i) } unless match[2].empty?
Change that line to:
(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.
-
No problem, I'm glad I could help.
----
However, I'm still running into the same problem..
-
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?
-
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.
-
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.
#==============================================================================
# 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
-
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.
-
Oddly it works now after I copied from the demo! Thank you so much, MA.
-
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.
-
Was wondering if you had seen this yet?