Replace Skill
Version: 1.0
Author: modern algebra
Date: October 29, 2010
Version History
- <Version 1.0> 10.29.2010 - Original Release
Description
This script is very simple. It allows you to specify skills to forget when a certain skill is learned. As a corollary, you also will not learn a new skill if you already have a skill that would have replaced it.
Sounds useless? Kind of. But it can be helpful if, say, you want to give the impression of a skill levelling up. Say you have a series of skills: Heal I is learned at level 2, Heal II is learned at level 14, and Heal III is learned at level 32. With this script, you can set it so that Heal I is forgotten when you learn Heal II, and Heal II is forgotten when you learn Heal III.
Also, since it was designed with consideration to the idea that it would be used to give the illusion that skills were levelling, a conditional branch check to see if a skill is learned will return true as long as you have either the skill asked for or any skill that would cause you to forget the skill asked for. So, if your conditional branch is checking for the Heal I skill, it will return true if you have Heal I, Heal II, or Heal III.
Features
- Allows you to forget specific skills when you learn a new one, thus giving the appearance of levelling the skill
- Conditional branches on skill learned will return true as long as you have either the skill being checked or a skill that would cause you to forget the skill being learned
- Will not allow an actor to learn a skill if one of the skills he/she already has would cause that skill to be forgotten
Instructions
Place the script above Main and below Materials in the Script Editor. If using my Note Editor script with the General Compatibility Patch, then this script must be placed below that. If you encounter any problems, try placing this script below every other custom script you are using. If it is still troublesome, then find the topic at RMRK.net and report it.
The script is easy to setup: all you need to do is put the following code into the notebox of a skill:
\forget[x, y, ..., z]
where: x-z are the IDs of the skills you want to forget when this skill is learned. It allows for multiples so that, with serial skills, you can ensure that all lower levels will not be learnable when you have a higher level of that skil. So, for the Heal I, II, III example (and let's say the ID of Heal I is 34, the ID of Heal II is 35, and the ID of Heal II is 36 - they don't have to be sequential, but they are those by default):
Heal I would be empty;
Heal II would have the code: \forget[34]
Heal III would have the code: \forget[34, 35]
Script
#==============================================================================
# Replace Skill
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: October 29, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# This script is very simple. It allows you to specify skills to forget when
# a certain skill is learned. As a corollary, you also will not learn a new
# skill if you already have a skill that would have replaced it.
#
# Sounds useless? Kind of. But it can be helpful if, say, you want to give
# the impression of a skill levelling up. Say you have a series of skills:
# Heal I is learned at level 2, Heal II is learned at level 14, and Heal III
# is learned at level 32. With this script, you can set it so that Heal I is
# forgotten when you learn Heal II, and Heal II is forgotten when you learn
# Heal III.
#
# Also, since it was designed with consideration to the idea that it would
# be used to give the illusion that skills were levelling, a conditional
# branch check to see if a skill is learned will return true as long as you
# have either the skill asked for or any skill that would cause you to forget
# the skill asked for. So, if your conditional branch is checking for the
# Heal I skill, it will return true if you have Heal I, Heal II, or Heal III.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Place the script above Main and below Materials in the Script Editor. If
# using my Note Editor script with the General Compatibility Patch, then this
# script must be placed below that. If you encounter any problems, try
# placing this script below every other custom script you are using. If it
# is still troublesome, then find the topic at RMRK.net and report it.
#
# The script is easy to setup: all you need to do is put the following code
# into the notebox of a skill:
#
# \forget[x, y, ..., z]
#
# where: x-z are the IDs of the skills you want to forget when this skill is
# learned. It allows for multiples so that, with serial skills, you can ensure
# that all lower levels will not be learnable when you have a higher level of
# that skil. So, for the Heal I, II, III example (and let's say the ID of Heal
# I is 34, the ID of Heal II is 35, and the ID of Heal II is 36 - they don't
# have to be sequential, but they are those by default):
# Heal I would be empty;
# Heal II would have the code: \forget[34]
# Heal III would have the code: \forget[34, 35]
#==============================================================================
#==============================================================================
# ** RPG::Skill
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - mars_forget_skills
#==============================================================================
class RPG::Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Forget Skills
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def mars_forget_skills
if !@mars_forget_skills
@mars_forget_skills = []
if self.note[/\\FORGET\[(.+?)\]/i] != nil
$1.scan (/\d+/).each { |id| @mars_forget_skills.push (id.to_i) }
end
end
return @mars_forget_skills
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Compatibility with Note Editor + General Compatibility Patch
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if self.method_defined? (:ma_reset_note_values)
alias morlg_relcskl_reset_6hw1 ma_reset_note_values
def ma_reset_note_values (*args)
morlg_relcskl_reset_6hw1 (*args) # Run Original Method
@mars_forget_skills = nil
end
end
end
#==============================================================================
# ** Game_Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - learn_skill; skill_learn?
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Skill Learn?
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malab_replce_skllrn_8uj3 skill_learn?
def skill_learn? (skill, *args)
(@skills - skill.mars_forget_skills).each { |s_id|
return true if $data_skills[s_id].mars_forget_skills.include? (skill.id)
}
return malab_replce_skllrn_8uj3 (skill, *args)
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Learn Skill
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mlg_rplskl_lernskl_7yh3 learn_skill
def learn_skill (skill_id, *args)
mlg_rplskl_lernskl_7yh3 (skill_id, *args) # Run Original method
$data_skills[skill_id].mars_forget_skills.each { |s_id| forget_skill (s_id) } if @skills.include? (skill_id)
end
end
Credit
Thanks
- Dimosthenos, for the request
Support
If you encounter any bugs with this script, please report it in this topic. Remember to look at the
Script Troubleshooting for the Non-Scripter tutorial first and see if anything in there helps. Even if it does and you are able to fix the problem, please alert me to the issue.
Known Compatibility Issues
If using the Note Editor and General Compatibility Patch, then this script must be placed below it.