Good day everyone,
I wrote a mod for Yanfly's Learn Skills Engine. https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/learn-skill-engine/
It does what I want, but has one issue that I'm not sure how to make work.
Basically I wrote a mod so that I could set the skill being learned, to only be shown when the actor was at a specific level.
Now this feature is in the script originally, however I'm trying to make the level requirement different for each actor.
The script by default lets you use
<learn require level: 2>
My mod adds on
<learn require actor level: 2, 3> (actor.id, actor.level)
Letting you able to put in multiple of the checks.
<learn require actor level: 2, 3>
<learn require actor level: 1, 2>
The issue is that when the script reads the first line, it stops reading any other conditions.
So in this instance actor 2 will learn the skill at level 3, but actor 1 does not learn the skill at all. It does not show up in the list for the actor.
What I need is for my mod to make the script continue checking so that it would apply it for any actor with conditions.
Here is my mod
*EDIT - Script fixed and working.
Now supports
V1.2
<learn require subclass level: 2, 3> (subclass.id, subclass.level)
Letting you able to put in multiple of the checks.
<learn require subclass level: 2, 3>
<learn require subclass level: 1, 2>
Can now support subclasses with yanfly class script and fixed showing all skills for classes(subclass) you can add on.
The default system made every skill that was specified in the class note-tag to be shown in the learn skill window.
Now it will only show the skills for the classes selected.
Interesting glitch
I wrote a mod for Yanfly's Learn Skills Engine. https://yanflychannel.wordpress.com/rmvxa/gameplay-scripts/learn-skill-engine/
It does what I want, but has one issue that I'm not sure how to make work.
Basically I wrote a mod so that I could set the skill being learned, to only be shown when the actor was at a specific level.
Now this feature is in the script originally, however I'm trying to make the level requirement different for each actor.
The script by default lets you use
<learn require level: 2>
My mod adds on
<learn require actor level: 2, 3> (actor.id, actor.level)
Letting you able to put in multiple of the checks.
<learn require actor level: 2, 3>
<learn require actor level: 1, 2>
The issue is that when the script reads the first line, it stops reading any other conditions.
So in this instance actor 2 will learn the skill at level 3, but actor 1 does not learn the skill at all. It does not show up in the list for the actor.
What I need is for my mod to make the script continue checking so that it would apply it for any actor with conditions.
Here is my mod
*EDIT - Script fixed and working.
Code:
#==============================================================================
#
# ▼ Yanfly Engine Ace - Learn Skill Engine v1.00 - addon
# -- Last Updated: 2012.01.08
# -- Level: Normal, Hard
# -- Requires: n/a
# # Mod by Roninator2
# scan code by TheoAllen
# scan check by Sixth
#==============================================================================
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019.04.16 - Mod addon
# 2019.04.18 - Completed
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# an alternative for actors to learn skills outside of leveling,
# Skills can be hidden until certain requirements are met
#==============================================================================
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skill notebox in the database.
# -----------------------------------------------------------------------------
# <learn require actor level: x, y>
# x = actor ID, y = actor level
# Sets the skill to require the actor x's current level to be y before the skill
# will show up in the actor's skill learning window.
#==============================================================================
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :learn_require_actor_level
#--------------------------------------------------------------------------
# common cache: load_notetags_lse
#--------------------------------------------------------------------------
alias r2_load_notetags_r2_skill_927 load_notetags_lse
def load_notetags_lse
r2_load_notetags_r2_skill_927
@learn_require_actor_level = {}
note.split(/[\r\n]+/).each do |line|
if line =~ /<learn require actor level\s*:\s*(\d+)\s*,\s*(\d+)>/i
@learn_require_actor_level[$1.to_i] = $2.to_i
end
end
end
end # RPG::Skill
class Window_LearnSkillList < Window_SkillList
#--------------------------------------------------------------------------
# meet_requirements?
#--------------------------------------------------------------------------
def meet_requirements?(item)
return false if @actor.nil?
return false unless meet_level_requirements?(item)
return false unless meet_actor_level_requirements?(item)
return false unless meet_skill_requirements?(item)
return false unless meet_switch_requirements?(item)
return false unless meet_eval_requirements?(item)
return true
end
#--------------------------------------------------------------------------
# meet_level_requirements?
#--------------------------------------------------------------------------
def meet_actor_level_requirements?(item)
return false unless item.learn_require_actor_level[@actor.id]
return @actor.level >= item.learn_require_actor_level[@actor.id]
end
end
Now supports
V1.2
<learn require subclass level: 2, 3> (subclass.id, subclass.level)
Letting you able to put in multiple of the checks.
<learn require subclass level: 2, 3>
<learn require subclass level: 1, 2>
Ruby:
#==============================================================================
#
# ▼ Yanfly Engine Ace - Learn Skill Engine v1.20 - addon
# -- Last Updated: 2012.01.08
# -- Level: Normal, Hard
# -- Requires: n/a
# # Mod by Roninator2
# scan code by TheoAllen
# scan check by Sixth
#==============================================================================
#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2019.04.16 - Mod addon
# 2019.04.18 - Completed
# 2020.04.24 - Added support for yanfly class
# 2020.04.26 - Fixed issue for seeing all skills for subclasses
#==============================================================================
# ▼ Known potential loop holes
# If class 1 is the primary class and class 2 is the subclass
# when subclass 2 is able to learn a skill and the note-tag has both classes
# listed in it, then class 1 can still learn the skill even with the class 2
# removed. It will also use class 2's JP (if that's what you use)
# however if the skill is learnable for both classes, then the JP points
# can be used from either class.
# only skills listed from the class will be in the list.
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# an alternative for actors to learn skills outside of leveling,
# Skills can be hidden until certain requirements are met
#==============================================================================
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skill notebox in the database.
# -----------------------------------------------------------------------------
# <learn require actor level: x, y>
# <learn require subclass level: x, y> # yanfly class support
# x = actor ID, y = actor level
# Sets the skill to require the actor x's current level to be y before the skill
# will show up in the actor's skill learning window.
#==============================================================================
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# public instance variables
#--------------------------------------------------------------------------
attr_accessor :learn_require_actor_level
attr_accessor :learn_require_subclass_level
attr_accessor :learn_require_actor_id
attr_accessor :learn_require_subclass_id
#--------------------------------------------------------------------------
# common cache: load_notetags_lse
#--------------------------------------------------------------------------
alias r2_load_notetags_r2_skill_927 load_notetags_lse
def load_notetags_lse
r2_load_notetags_r2_skill_927
@learn_require_actor_level = {}
@learn_require_subclass_level = {}
@learn_require_actor_id = {}
@learn_require_subclass_id = {}
note.split(/[\r\n]+/).each do |line|
if line =~ /<learn require actor level\s*:\s*(\d+)\s*,\s*(\d+)>/i
@learn_require_actor_level[$1.to_i] = $2.to_i
@learn_require_actor_id[$1.to_i] = $1.to_i
end
if line =~ /<learn require subclass level\s*:\s*(\d+)\s*,\s*(\d+)>/i
@learn_require_subclass_level[$1.to_i] = $2.to_i
@learn_require_subclass_id[$1.to_i] = $1.to_i
end
end
end
end # RPG::Skill
class Window_LearnSkillList < Window_SkillList
#--------------------------------------------------------------------------
# meet_requirements?
#--------------------------------------------------------------------------
def meet_requirements?(item)
return false if @actor.nil?
return false unless meet_level_requirements?(item)
return false unless meet_actor_level_requirements?(item)
return false unless meet_skill_requirements?(item)
return false unless meet_switch_requirements?(item)
return false unless meet_eval_requirements?(item)
return true
end
#--------------------------------------------------------------------------
# meet_level_requirements?
#--------------------------------------------------------------------------
def meet_actor_level_requirements?(item)
if $imported["YEA-ClassSystem"]
actor = @actor
if actor.subclass.nil?
# actor alone
return false if item.learn_require_actor_id.empty? &&
!item.learn_require_subclass_id.empty?
return true if item.learn_require_actor_id.empty? &&
actor.class.learn_skills.include?(item.id) &&
!item.learn_require_subclass_id.empty?
return true if item.learn_require_actor_id.empty? &&
actor.class.learn_skills.include?(item.id) && !item.learn_cost.empty?
return false unless item.learn_require_actor_level[@actor.id]
return @actor.level >= item.learn_require_actor_level[@actor.id]
else
# actor with subclass
return true if item.learn_require_actor_id.empty? &&
actor.class.learn_skills.include?(item.id) &&
item.learn_require_subclass_id.empty?
# subclass
return true if item.learn_require_subclass_id.empty? &&
actor.subclass.learn_skills.include?(item.id)
return true if item.learn_require_subclass_id.empty? &&
actor.subclass.learn_skills.include?(item.id) &&
item.learn_require_actor_id.empty?
return true if item.learn_require_actor_id.empty? &&
item.learn_require_subclass_id.empty? && item.learn_cost.empty?
sublevel = actor.class_level(actor.subclass.id)
# combined
if !item.learn_require_actor_level[@actor.id].nil?
return @actor.level >= item.learn_require_actor_level[@actor.id]
end
if !item.learn_require_subclass_level[actor.subclass.id].nil?
return sublevel >= item.learn_require_subclass_level[actor.subclass.id]
end
end
end
end
end
Can now support subclasses with yanfly class script and fixed showing all skills for classes(subclass) you can add on.
The default system made every skill that was specified in the class note-tag to be shown in the learn skill window.
Now it will only show the skills for the classes selected.
Interesting glitch
Code:
# ▼ Known potential loop holes
# If class 1 is the primary class and class 2 is the subclass
# when subclass 2 is able to learn a skill and the note-tag has both classes
# listed in it, then class 1 can still learn the skill even with the class 2
# removed. It will also use class 2's JP (if that's what you use)
# however if the skill is learnable for both classes, then the JP points
# can be used from either class.
# only skills listed from the class will be in the list.