*** XP VERSION ***
# KSkillMax XP
# Scripter : Kyonides-Arkanthos
# v 1.2.13 - 2016-12-05
# Plug & Play Script

# This script allows the game dev to limit the maximum number of skills that a
# hero can use during gameplay. Whenever they have reached this maximum, a new
# menu will show up to tell the player that there is a need to replace some
# skills if they really want to learn new ones.

# The CLEAR_SKILLS_NOT_LEARNED Constant allows the game dev to define whether
# or not the skills heroes will not learn will be discarded before going back
# to the map scene.

# OPTIONAL
# The following script calls may allow the game dev to change the maximum
# number of skills a heroe may remember.

# SCRIPT CALLS

# # INCREASE or DECREASE Maximum Number of Skills #
# $game_party.actors.skill_limit += NUMBER
# $game_party.actors.skill_limit -= NUMBER

# The Following Script Call is optional, you would only use it if you
# want to let the player check and modify their unlearned skills even if
# they didn't learn a new skill by leveling up or by purchasing a skill at
# a skill shop (that would be possible if you add my KSkill Shop XP script
# and place it below KSkillMax XP).
# $scene = Scene_SkillMax.new
module KSkill
# Maximum Number of Skills to be learned by a hero
MAX = 3
# Will the Maximum Number of Skills be increased by Leveling Up?
LVLUPINCREASE = true
# Increase of Skills After reaching specific Levels : Level => Increase
LVLUPMAX = { 10 => 1, 20 => 1, 40 => 2 }
# Replacement Icon Name
OLD_SKILL_ICON = '047-Skill04'
NEW_SKILL_ICON = '048-Skill05'
# Buttons to display Old and New Skill Data Windows
INFOBUTTONID = Input::A
# Delete Skills Heroes did not learn: YES - true, NO - false or nil
CLEAR_SKILLS_NOT_LEARNED = nil
# Help Menu Titles
NOEXTRASKILLS = 'There is no need for any hero to learn new skills'
REACHEDMAX = 'There are heroes that cannot learn more skills'
REPLACESKILLS = 'Which skills do you want to replace with new ones?'
AREYOUSURE = 'Are you really positive about applying these changes?'
REPLACEMENTSLEFT = "Replacement Skills Left: %s"
HEROES = 'Heroes'
LEARNEDSKILLS = 'Learned Skills'
NEWSKILLS = 'New Skills'
EXITOPTIONS =
LABELS = {} # DO NOT EDIT THIS LINE
LABELS = 'None'
LABELS = 'Target'
LABELS = LABELS
LABELS = '1 Enemy'
LABELS = 'Enemies'
LABELS = '1 Ally'
LABELS = 'Allies'
LABELS = 'Dead Ally'
LABELS = 'Dead Allies'
LABELS = 'User'
LABELS = 'Cost' # Costo de Habilidad o Técnica
LABELS = 'Power' # Poder o Fuerza de la Técnica
LABELS = 'STR' # Fuerza de la Técnica
LABELS = 'INT' # Inteligencia de la Técnica
LABELS = 'AGI' # Agilidad de la Técnica
LABELS = 'DEX' # Destreza de la Técnica
LABELS = 'PDEF' # Defensa Física de la Técnica
LABELS = 'MDEF' # Defensa Mágica de la Técnica
LABELS = 'EVA' # Evasión de la Técnica
OCCASIONS = {} # DO NOT EDIT THIS LINE
OCCASIONS = 'Occasion'
OCCASIONS = 'Always'
OCCASIONS = 'In Battle'
OCCASIONS = 'From Menu'
OCCASIONS = 'Never'
# STOP! NO MORE EDITS REQUIRED
@help_actors =
@replacements = 0
LVLUPMAX.default = 0
class << self
attr_accessor :help_actors, :replacements, :open_menu
end
end

class Game_Actor
attr_accessor :pending_skills
attr_reader :skills_not_learned
alias kyon_skill_limit_gm_actor_init initialize
def initialize(actor_id)
@limit_breaker = 0
@skills_not_learned =
kyon_skill_limit_gm_actor_init(actor_id)
end

def learn_skill(sid)
return unless sid > 0 and !skill_learn?(sid)
if @skills.size == KSkill::MAX + @limit_breaker
KSkill.help_actors << @actor_id if !KSkill.help_actors.include?(@actor_id)
@skills_not_learned << sid
@skills_not_learned = @skills_not_learned.uniq.sort
return
end
@skills << sid
@skills.sort!
end

def exp=(exp)
@exp = [.min, 0].max
check_level_up
check_level_down
@hp = .min
@sp = .min
end

def check_level_up
old_size = @skills_not_learned.size
while @exp >= @exp_list and @exp_list > 0
@level += 1
self.skill_limit += KSkill::LVLUPMAX if KSkill::LVLUPINCREASE
$data_classes.learnings.each {|j|
learn_skill(j.skill_id) if j.level == @level }
@pending_skills = old_size < @skills_not_learned.size
end
end

def check_level_down
while @exp < @exp_list
@level -= 1
self.skill_limit -= KSkill::LVLUPMAX if KSkill::LVLUPINCREASE
end
end

def skill_max() KSkill::MAX + @limit_breaker end
def skill_limit() @limit_breaker end
def skill_limit=(int) @limit_breaker = .max end
end

class Window_KSkillHelp < Window_Base
def initialize(width=640)
super(0, 0, width, 64)
self.contents = Bitmap.new(width - 32, height - 32)
end

def set_text(text, align=0)
contents.clear
contents.draw_text(0, 0, self.width - 32, 32, text, align)
end
end

class Window_ActorSelection < Window_Selectable
def initialize
empty = KSkill.help_actors.size == 0
h = 32 + KSkill.help_actors.size * 80
h += 80 if empty
super(0, 128, 120, h)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = KSkill.help_actors.size
self.index = empty ? -2 : 0
refresh unless empty
end

def refresh
self.contents.clear
self.contents.font.bold, self.contents.font.size = true, 18
ny, sy = -80, -64
KSkill.help_actors.each {|id| actor = $data_actors
self.contents.draw_text(0, ny += 80, 88, 28, actor.name, 1)
draw_actor_graphic(actor, 44, ny + 74) }
end

def update_cursor_rect
return if @item_max == 1
self.cursor_rect.set(0, @index * 80, 88, 80)
end
end

class Window_ActorSkills < Window_Selectable
attr_reader :replaced, :replace_index
def initialize
super(120, 128, 260, 288)
@replaced = {}
one_choice = KSkill.help_actors.size == 1
self.index = one_choice ? 0 : -1
end

def replace_skills?() @replaced.size > 0 end
def replace_max() @replaced.size end
def skill_id() @data.id end

def refresh
self.contents.dispose if self.contents
@data =
@actor.skills.size.times {|i| skill = $data_skills[@actor.skills]
@data << skill if skill != nil }
@item_max = @data.size
return unless @item_max > 0
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.size = 20
self.contents.font.bold = true
@item_max.times {|i| draw_item(i) }
end

def actor=(new_actor)
@actor, @actor_id, @index = new_actor, new_actor.id, 0
@replaced ||=
refresh
end

def update_replacement_check
if !@replaced.include?(@index)
if KSkill.replacements == 0
$game_system.se_play($data_system.buzzer_se)
return @replace_index = nil
elsif @replaced.size < @actor.skills_not_learned.size
$game_system.se_play($data_system.decision_se)
@replaced << @index
KSkill.replacements -= 1
@replace_index = @index
else
$game_system.se_play($data_system.buzzer_se)
return @replace_index = nil
end
else
$game_system.se_play($data_system.decision_se)
@replaced.delete(@index)
KSkill.replacements += 1
@replace_index = nil
end
refresh
end

def draw_item(index)
skill, y = @data, index * 32
rect = Rect.new(4, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
if @replaced.include?(index)
bitmap = RPG::Cache.icon(KSkill::OLD_SKILL_ICON)
self.contents.blt(0, y + 4, bitmap, Rect.new(0, 0, 24, 24))
end
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(28, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(60, y, 204, 32, skill.name, 0)
end

def dispose
@replaced.clear
@replaced = nil
super
end
end

class Window_NewSkills < Window_Selectable
attr_reader :selected
attr_writer :replace_max
def initialize(index, skills)
super(380, 128, 260, 288)
self.index = index
@skills = skills
self.active = nil
@replace_max = 0
@selected = {}
@s =
@data =
ds = $data_skills
@skills.each{|d| @s = d.map{|i| [id,ds.icon_name,ds.name]}}
@actor_index = 0 if @skills.size == 1
refresh unless index < 0
end

def skills_size() @item_max end
def skill_ids() @data.map {|values| values } end

def skills(actor_index, new_index, new_skills)
@actor_index = actor_index
self.index = new_index
@skills = new_skills
refresh
end

def update_single_skill
@selected = 0
refresh
end

def update_selection
$game_system.se_play($data_system.decision_se)
reached_max = @replace_max == @selected.compact.size
selected = @selected.include?(@index)
@selected = ((reached_max or selected)? nil : @index)
refresh
end

def refresh
self.contents.dispose if self.contents
@data = @s
@item_max = @data.size
return unless @item_max > 0
@selected ||= Array.new(@item_max, nil)
self.contents = Bitmap.new(width - 32, @item_max * 32)
self.contents.font.size = 20
self.contents.font.bold = true
@item_max.times {|i| draw_item(i) }
end

def draw_item(index)
skill, y = @data, index * 32
rect = Rect.new(4, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
if @selected.include?(index)
bitmap = RPG::Cache.icon(KSkill::NEW_SKILL_ICON)
self.contents.blt(0, y + 4, bitmap, Rect.new(0, 0, 24, 24))
end
bitmap = RPG::Cache.icon(skill)
self.contents.blt(28, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.draw_text(60, y, 204, 32, skill, 0)
end

def dispose
@data.clear
@s.clear
super
end
end

class Window_KSkillData < Window_Selectable
def initialize(new_x, new_y)
super(new_x, new_y, 272, 256)
self.contents = Bitmap.new(width - 32, height - 32)
self.z += 100
@skill = nil
refresh if @skill
end

def skill_id=(new_skill_id)
@skill = $data_skills
refresh
end

def refresh
self.contents.clear
draw_skill_labels
draw_skill_data
end

def draw_skill_labels
labels = KSkill::LABELS
contents.font.color = system_color
contents.draw_text(0, 28, 240, 28, labels)
contents.draw_text(0, 56, 240, 28, KSkill::OCCASIONS)
contents.draw_text(0, 84, 240, 28, labels)
contents.draw_text(124, 84, 240, 28, labels)
contents.draw_text(0, 112, 240, 28, labels)
contents.draw_text(124, 112, 240, 28, labels)
contents.draw_text(0, 140, 240, 28, labels)
contents.draw_text(124, 140, 240, 28, labels)
contents.draw_text(0, 168, 240, 28, labels)
contents.draw_text(124, 168, 240, 28, labels)
contents.draw_text(0, 196, 240, 28, labels)
end

def draw_skill_data
contents.font.color = normal_color
bitmap = RPG::Cache.icon(@skill.icon_name)
contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
contents.draw_text(32, 0, 204, 32, @skill.name, 0)
contents.draw_text(0, 28, 240, 28, KSkill::LABELS, 2)
contents.draw_text(0, 56, 240, 28, KSkill::OCCASIONS, 2)
contents.draw_text(0, 84, 108, 28, @skill.sp_cost.to_s, 2)
contents.draw_text(0, 84, 240, 28, @skill.power.abs.to_s, 2)
contents.draw_text(0, 112, 108, 28, @skill.str_f.to_s, 2)
contents.draw_text(0, 112, 240, 28, @skill.int_f.to_s, 2)
contents.draw_text(0, 140, 108, 28, @skill.agi_f.to_s, 2)
contents.draw_text(0, 140, 240, 28, @skill.dex_f.to_s, 2)
contents.draw_text(0, 168, 108, 28, @skill.pdef_f.to_s, 2)
contents.draw_text(0, 168, 240, 28, @skill.mdef_f.to_s, 2)
contents.draw_text(0, 196, 108, 28, @skill.eva_f.to_s, 2)
end
end

class Interpreter
def command_315
value = operate_value(@parameters, @parameters, @parameters)
iterate_actor(@parameters){|actor| actor.exp += value }
pending = $game_party.actors.select{|actor| actor.pending_skills }.size
KSkill.open_menu = (!KSkill.help_actors.empty? and pending > 0)
$game_party.actors.each {|actor| actor.pending_skills = nil }
return true
end
end

class Scene_Map
alias kyon_kskillmax_scn_map_up update
def update
kyon_kskillmax_scn_map_up
return unless KSkill.open_menu and !$game_temp.message_window_showing
$scene = Scene_KSkillMax.new
end
end

class Scene_Load
alias kyon_kskillmax_scn_load_rsd read_save_data
def read_save_data(file)
kyon_kskillmax_scn_load_rsd(file)
actors = $game_party.actors
actors.each {|a| KSkill.help_actors << a.id if !a.skills_not_learned.empty?}
end
end

class Scene_Battle
def battle_end(result)
$game_temp.in_battle = false
$game_party.clear_actions
$game_party.actors.each {|actor| actor.remove_states_battle }
$game_troop.enemies.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
$scene = KSkill.help_actors.empty? ? Scene_Map.new : Scene_KSkillMax.new
end
end

class Scene_KSkillMax
def initialize
KSkill.open_menu = nil
@skills =
@actors =
actors = $game_party.actors
KSkill.replacements = 0
actors.each {|a| skills = a.skills_not_learned
next if skills.empty?
number = .min
next if number == 0
KSkill.replacements += number
@skills << skills
@actors << a }
end

def main
make_help_windows
make_status_windows
make_skill_windows
@command_window = Window_Command.new(200, KSkill::EXITOPTIONS)
@command_window.x = (640 - @command_window.width) / 2
@command_window.y = (480 - @command_window.height) / 2
@command_window.visible = nil
@command_window.active = nil
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@command_window.dispose
@new_status_window.dispose
@old_status_window.dispose
@replace_window.dispose
@skill_window.dispose
@selection_window.dispose
@help_windows.each {|window| window.dispose }
end

def make_status_windows
@old_status_window = Window_KSkillData.new(368, 128)
@old_status_window.visible = false
@new_status_window = Window_KSkillData.new(108, 128)
@new_status_window.visible = false
end

def make_help_windows
@help_windows =
@help_windows +=
@help_windows = Window_KSkillHelp.new(520)
@help_windows.x = 120
@help_windows.x = 380
@help_windows.x = 120
@help_windows.y = @help_windows.y = @help_windows.y = 64
@help_windows.y = 416
@empty = KSkill.replacements == 0
text = @empty ? KSkill::NOEXTRASKILLS : KSkill::REACHEDMAX
@help_windows.set_text(text, 1)
@help_windows.set_text(KSkill::HEROES, 1)
@help_windows.set_text(KSkill::LEARNEDSKILLS, 1)
@help_windows.set_text(KSkill::NEWSKILLS, 1)
text = sprintf(KSkill::REPLACEMENTSLEFT, KSkill.replacements)
@help_windows.set_text(text, 1)
end

def make_skill_windows
@selection_window = Window_ActorSelection.new
@skill_window = Window_ActorSkills.new
if KSkill.help_actors.size == 1
@selection_window.active = nil
@skill_window.active = true
@skill_window.actor = $game_actors[KSkill.help_actors]
@skill_window.index = 0
@replace_window = Window_NewSkills.new(0, @skills)
@help_windows.set_text(KSkill::REPLACESKILLS, 1)
else
@skill_window.active = nil
@replace_window = Window_NewSkills.new(-1, @skills)
end
end

def update
@help_windows.update
@selection_window.update
@skill_window.update
@replace_window.update
@old_status_window.update
@new_status_window.update
@command_window.update
if @selection_window.active
update_actor_selection
return
elsif @skill_window.active
update_skill_selection
return
elsif @replace_window.active
update_replace_selection
return
elsif @old_status_window.visible
update_old_skills_data
return
elsif @new_status_window.visible
update_new_skills_data
return
elsif @command_window.active
update_exit_selection
return
end
end

def update_skills_info
@help_windows.set_text(KSkill::REPLACESKILLS, 1)
@skill_window.actor = actor = @actors
@replace_window.skills(@selection_window.index, 0, @skills)
@selection_window.active = nil
@skill_window.active = true
@skill_window.index = 0
end

def update_actor_selection
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
if @empty
$scene = Scene_Map.new
return
end
@help_windows.set_text(KSkill::AREYOUSURE, 1)
@selection_window.active = nil
@command_window.active = true
@command_window.visible = true
elsif Input.trigger?(Input::C)
index = @selection_window.index
if @actors.nil?
$scene = Scene_Map.new
return
elsif @actors.skills_not_learned.empty?
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
update_skills_info
end
end

def update_skill_selection
if Input.trigger?(Input::B)
size1 = @skill_window.replaced.values.flatten.size
size2 = @replace_window.selected.values.flatten.compact.size
if size1 != size2
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.cancel_se)
@help_windows.set_text(KSkill::REACHEDMAX, 1)
@skill_window.active = nil
if KSkill.help_actors.size == 1
@help_windows.set_text(KSkill::AREYOUSURE, 1)
@command_window.active = true
@command_window.visible = true
else
@selection_window.active = true
end
@skill_window.index = -1
@replace_window.index = -1
if @skill_window.contents
@skill_window.contents.clear
@replace_window.contents.clear
end
return
elsif Input.trigger?(Input::C)
@skill_window.update_replacement_check
text = sprintf(KSkill::REPLACEMENTSLEFT, KSkill.replacements)
@help_windows.set_text(text, 1)
return
elsif Input.trigger?(KSkill::INFOBUTTONID)
$game_system.se_play($data_system.decision_se)
actor_id = KSkill.help_actors
@actor_skills = $game_actors.skills
@skills_size = @actor_skills.size
@skill_index = @skill_window.index
@old_status_window.skill_id = @skill_window.skill_id
@skill_window.active = false
@old_status_window.visible = true
return
elsif Input.trigger?(Input::L) or Input.trigger?(Input::R)
update_active_window
elsif Input.trigger?(Input::LEFT) or Input.trigger?(Input::RIGHT)
update_active_window
end
end

def update_replace_selection
if Input.trigger?(Input::B) or Input.trigger?(Input::LEFT)
$game_system.se_play($data_system.cancel_se)
@replace_window.active = nil
@skill_window.active = true
return
elsif Input.trigger?(KSkill::INFOBUTTONID)
$game_system.se_play($data_system.decision_se)
@actor_skills = @actors.skills_not_learned
@skills_size = @actor_skills.size
@skill_index = 0
@new_status_window.skill_id = @actor_skills
@replace_window.active = false
@new_status_window.visible = true
elsif Input.trigger?(Input::C)
@replace_window.update_selection
end
end

def update_old_skills_data
if Input.trigger?(Input::B) or Input.trigger?(KSkill::INFOBUTTONID)
$game_system.se_play($data_system.cancel_se)
$game_system
@actor_skills =
@old_status_window.visible = false
@skill_window.active = true
elsif Input.trigger?(Input::UP)
if @skills_size == 1
$game_system.se_play($data_system.cancel_se)
return
end
@skill_index = (@skill_index + @skills_size - 1) % @skills_size
@old_status_window.skill_id = @actor_skills
elsif Input.trigger?(Input::DOWN)
if @skills_size == 1
$game_system.se_play($data_system.cancel_se)
return
end
@skill_index = (@skill_index + 1) % @skills_size
@old_status_window.skill_id = @actor_skills
end
end

def update_new_skills_data
if Input.trigger?(Input::B) or Input.trigger?(KSkill::INFOBUTTONID)
$game_system.se_play($data_system.cancel_se)
@actor_skills =
@new_status_window.visible = false
@replace_window.active = true
elsif Input.trigger?(Input::UP)
if @skills_size == 1
$game_system.se_play($data_system.cancel_se)
return
end
@skill_index = (@skill_index + @skills_size - 1) % @skills_size
@new_status_window.skill_id = @actor_skills
elsif Input.trigger?(Input::DOWN)
if @skills_size == 1
$game_system.se_play($data_system.cancel_se)
return
end
@skill_index = (@skill_index + 1) % @skills_size
@new_status_window.skill_id = @actor_skills
end
end

def update_active_window
$game_system.se_play($data_system.decision_se)
@skill_window.active = nil
@replace_window.replace_max = @skill_window.replace_max
@replace_window.active = true
end

def update_exit_selection
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
case @command_window.index
when 0
actor_index = -1
@actors.each {|actor| id, actor_index = actor.id, actor_index + 1
next if @skill_window.replaced.nil?
index = -1
s = @replace_window.selected.compact
@skill_window.replaced.each {|ix| index += 1
not_learned = @actors.skills_not_learned
@actors.skills = not_learned[s]
not_learned[s] = nil }
@actors.skills_not_learned.compact! }
clear_skills_info
when 1
if @actors.size > 1
@selection_window.active = true
else
update_skills_info
end
@command_window.active = nil
@command_window.visible = nil
when 2 then clear_skills_info end
$scene = Scene_Map.new unless @command_window.index == 1
end
end

def clear_skills_info
KSkill.help_actors.delete_if {|i| $game_actors.skills_not_learned.empty?}
return unless KSkill::CLEAR_SKILLS_NOT_LEARNED
KSkill.help_actors.each {|id| $game_actors.skills_not_learned.clear }
KSkill.help_actors.clear
end
end

*** VX VERSION ***
# * KSkillMax VX
# Scripter : Kyonides-Arkanthos
# VX v 1.2.2 - 2016-12-02
# Plug & Play Script

# This script allows the game dev to limit the maximum number of skills that a
# hero can use during gameplay. Whenever they have reached this maximum, a new
# menu will show up to tell the player that there is a need to replace some
# skills if they really want to learn new ones.

# New Skills that are not going to be learned could be discarded if the
# CLEAR_SKILLS_NOT_LEARNED Constant value is true. If nil, you'll keep them.

# OPTIONAL - Available on Version 1.1.0 and later...

# The following script calls may allow the game dev to change the maximum
# number of skills a heroe may remember.

# Besides the player can now press 1 out of 2 buttons to check out all the
# Old and New Skills data so he or she can carefully take a decision.

# SCRIPT CALLS

# $game_paty.members.increase_skill_limit(NUMBER) ## INCREASE
# $game_paty.members.decrease_skill_limit(NUMBER) ## DECREASE

module KSkill
# Maximum Number of Skills an Actor might learn at the beginning
MAX = 3
# Replaceable Skill Icon
ICON = '047-Skill04'
# Will the Maximum Number of Skills be increased by Leveling Up?
LVLUPINCREASE = true
# Increase of Skills After reaching specific Levels : Level => Increase
LVLUPMAX = { 10 => 1, 20 => 1, 40 => 2 }
# Buttons to open Old and New Skill Info Window
OLDBUTTONID = Input::A
NEWBUTTONID = Input::X
# Delete Unlearned Skills: true - Yes, nil - No
CLEAR_SKILLS_NOT_LEARNED = nil
# Menu Labels
REACHEDMAX = 'Some heroes cannot learn more skills'
REPLACESKILLS = 'Which skills do you want to replace?'
AREYOUSURE = 'Want to apply all changes?'
REPLACEMENTSLEFT = "%s unassigned replacements"
HEROES = 'Heroes'
LEARNEDSKILLS = 'Current Skills'
NEWSKILLS = 'New Skills'
EXITOPTIONS =
LABELS = {} # DO NOT EDIT THIS LINE
LABELS = 'Increase'
LABELS = 'None'
LABELS = 'Target'
LABELS = LABELS
LABELS = 'Single Enemy'
LABELS = 'All Enemies'
LABELS = 'Double vs. Enemy'
LABELS = 'Random Enemy'
LABELS = '2 Random Enemies'
LABELS = '3 Random Enemies'
LABELS = '1 Ally'
LABELS = 'All Allies'
LABELS = '1 Dead Ally'
LABELS = 'Dead Alllies'
LABELS = 'User'
LABELS = 'Success %'
LABELS = 'Speed'
LABELS = 'MAXHP'
LABELS = 'MAXSP'
LABELS = 'Cost'
LABELS = 'Damage'
LABELS = 'P. Power'
LABELS = 'M. Power'
LABELS = 'MP Damage'
LABELS = 'Absorb Dmg'
LABELS = 'Ignore Defense'
OCCASIONS = {} # DO NOT EDIT THIS LINE
OCCASIONS = 'Occasion'
OCCASIONS = 'Always'
OCCASIONS = 'In Battle'
OCCASIONS = 'On Menu'
OCCASIONS = 'Never'
# End Of Section #
@help_actors =
@not_learned = {}
@replacements = 0
LVLUPMAX.default = 0
@open_menu = nil
class << self
attr_accessor :help_actors, :not_learned, :replacements, :open_menu
end
end

class Game_Actor
alias kyon_skill_limit_gm_actor_init initialize
alias kyon_skill_limit_gm_actor_lvlup level_up
alias kyon_skill_limit_gm_actor_lvldown level_down
def initialize(actor_id)
@limit_breaker = 0
KSkill.not_learned =
kyon_skill_limit_gm_actor_init(actor_id)
end

def learn_skill(sid)
return unless sid > 0 and !skill_learn?($data_skills)
if @skills.size == KSkill::MAX + @limit_breaker
KSkill.help_actors << @actor_id
KSkill.help_actors = KSkill.help_actors.uniq.sort
KSkill.not_learned << sid
KSkill.not_learned = KSkill.not_learned.uniq.sort
KSkill.open_menu = true
return
end
@skills << sid
@skills.sort!
end

def level_up
kyon_skill_limit_gm_actor_lvlup
@limit_breaker += KSkill::LVLUPMAX
extra = KSkill::MAX + @limit_breaker - @skills.size
return unless extra > 0 and !KSkill.not_learned.empty?
learn_skill(KSkill.not_learned.shift)
KSkill.help_actors.delete(@actor_id) if KSkill.not_learned.empty?
end

def level_down
kyon_skill_limit_gm_actor_lvldown
@limit_breaker -= KSkill::LVLUPMAX
end

def replace_skill(index, value) @skills = value end
def increase_skill_limit(int) @limit_breaker += int end
def decrease_skill_limit(int) @limit_breaker -= int end
end

class Window_SkillHelp < Window_Base
def initialize(width=544)
super(0, 0, width, 56)
contents = Bitmap.new(width - 32, height - 32)
end

def set_text(text, align=0)
self.contents.clear
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
end
end

class Window_ActorSelection < Window_Selectable
def initialize
super(0, 112, 120, (KSkill.help_actors.size * 68) + 32)
contents = Bitmap.new(width - 32, height - 32)
self.index, @item_max = 0, KSkill.help_actors.size
refresh
end

def refresh
contents.clear
contents.font.bold = true
self.contents.font.size = 18
ny, sy = -72, -56
KSkill.help_actors.each {|id| actor = $data_actors
contents.draw_text(0, ny += 72, 92, 24, actor.name, 1)
draw_actor_graphic(actor, 44, ny + 60) }
end

def item_rect(index)
rect = Rect.new(0, 0, 0, 0)
rect.width = (contents.width + @spacing) / @column_max - @spacing
rect.height = WLH
rect.x = index % @column_max * (rect.width + @spacing)
rect.y = index / @column_max * 72
rect
end
end

class Window_ActorSkills < Window_Selectable
attr_reader :replaced
def initialize
super(120, 112, 212, 248)
@replaced = {}
self.index = KSkill.help_actors.size == 1 ? 0 : -1
end

def skill_id() @data.id end

def refresh
contents.dispose if self.contents
@data = @actor.skills
@item_max = @data.size
return if @item_max == 0
self.contents = Bitmap.new(width - 32, .max)
@item_max.times {|i| draw_item(i) }
end

def actor=(new_actor)
@actor, @actor_id, @index = new_actor, new_actor.id, 0
@replaced ||=
refresh
end

def update_replacement_check
if !@replaced.include?(@index)
if @replaced.size < KSkill.not_learned.size
Sound.play_decision
@replaced << @index
KSkill.replacements -= 1
else
Sound.play_buzzer
return
end
else
Sound.play_decision
@replaced.delete(@index)
KSkill.replacements += 1
end
refresh
end

def draw_item(index)
skill, y = @data, index * WLH
rect = Rect.new(4, y, self.width - 32, 32)
icon_index = !@replaced.include?(index)? skill.icon_index : 143
draw_icon(icon_index, 0, y)
contents.draw_text(32, y, 188, WLH, skill.name, 0)
end

def dispose
@replaced.clear
@replaced = nil
super
end
end

class Window_NewSkills < Window_Base
attr_accessor :index
def initialize(activate)
super(332, 112, 212, 248)
@index = activate ? 0 : -1
refresh if activate
end

def skill_id() @data end

def create_contents
self.contents.dispose
self.contents = Bitmap.new(width - 32, height - 32)
end

def refresh
@data = KSkill.not_learned[KSkill.help_actors].dup
@item_max = @data.size
return unless @item_max > 0
contents.clear if contents
contents = Bitmap.new(width - 32, @item_max * 32)
@item_max.times {|i| draw_item(i) }
end

def draw_item(index)
skill_id, y = @data, index * WLH
rect = Rect.new(4, y, self.width - 32, 32)
draw_icon($data_skills.icon_index, 0, y)
contents.draw_text(32, y, 188, WLH, $data_skills.name, 0)
end
end

class Window_SkillStatusExtended < Window_Base
def initialize(x, y, skill=nil)
super(x, y, 250, 264)
@skill = skill
return unless skill
refresh
end

def skill_id=(new_skill_id)
@skill = $data_skills
refresh
end

def refresh
self.contents.clear
rect = Rect.new(4, 0, self.width - 32, 32)
draw_icon($data_skills.icon_index, 0, 0)
contents.font.color = system_color
contents.font.color.alpha = 255
contents.draw_text(0, 52, 140, 24, KSkill::OCCASIONS)
contents.draw_text(0, 78, 140, 24, KSkill::LABELS)
contents.draw_text(108, 78, 160, 24, KSkill::LABELS)
contents.draw_text(0, 104, 218, 24, KSkill::LABELS)
contents.draw_text(128, 104, 140, 24, KSkill::LABELS)
contents.draw_text(0, 130, 140, 24, KSkill::LABELS)
contents.draw_text(128, 130, 140, 24, KSkill::LABELS)
contents.font.color = normal_color
contents.draw_text(32, 0, 188, 24, @skill.name, 0)
contents.draw_text(0, 26, 218, 24, KSkill::LABELS)
contents.draw_text(0, 52, 218, 24, KSkill::OCCASIONS, 2)
contents.draw_text(88, 78, 120, 24, @skill.mp_cost.to_s)
contents.draw_text(120, 78, 96, 24, @skill.hit.to_s, 2)
contents.draw_text(88, 104, 100, 24, @skill.speed.to_s)
contents.draw_text(88, 104, 128, 24, @skill.base_damage.to_s, 2)
contents.draw_text(88, 130, 128, 24, @skill.atk_f.to_s)
contents.draw_text(88, 130, 128, 24, @skill.spi_f.to_s, 2)
y = 130
symbols =
attr =
attr.size.times {|n| contents.font.color.alpha = attr ? 255 : 120
y += 26
contents.draw_text(0, y, 140, 24, KSkill::LABELS[symbols]) }
end
end

class Scene_Battle
def battle_end(result)
if result == 2 and not $game_troop.can_lose
call_gameover
else
$game_party.clear_actions
$game_party.remove_states_battle
$game_troop.clear
if $game_temp.battle_proc != nil
$game_temp.battle_proc.call(result)
$game_temp.battle_proc = nil
end
unless $BTEST
$game_temp.map_bgm.play
$game_temp.map_bgs.play
end
$scene = KSkill.help_actors.empty? ? Scene_Map.new : Scene_SkillMax.new
@message_window.clear
Graphics.fadeout(30)
end
$game_temp.in_battle = false
end
end

class Scene_SkillMax
def main
start
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.update
Graphics.freeze
@command_window.dispose
@old_status_window.dispose
@new_status_window.dispose
@replace_window.dispose
@skill_window.dispose
@selection_window.dispose
@help_windows.each {|window| window.dispose }
end

def start
KSkill.open_menu = nil
KSkill.replacements = KSkill.not_learned.values.flatten.size
@help_windows =
@help_windows +=
@help_windows << Window_SkillHelp.new(424)
@help_windows.x = 120
@help_windows.x = 332
@help_windows.x = 120
@help_windows.y = 56
@help_windows.y = 56
@help_windows.y = 56
@help_windows.y = 360
@help_windows.set_text(KSkill::REACHEDMAX, 1)
@help_windows.set_text(KSkill::HEROES, 1)
@help_windows.set_text(KSkill::LEARNEDSKILLS, 1)
@help_windows.set_text(KSkill::NEWSKILLS, 1)
text = sprintf(KSkill::REPLACEMENTSLEFT, KSkill.replacements)
@help_windows.set_text(text, 1)
@selection_window = Window_ActorSelection.new
@skill_window = Window_ActorSkills.new
if KSkill.help_actors.size == 1
@skill_window.actor = $game_actors[KSkill.help_actors]
@selection_window.active = nil
else
@skill_window.active = nil
end
@replace_window = Window_NewSkills.new(KSkill.help_actors.size == 1)
@old_status_window = Window_SkillStatusExtended.new(36, 96)
@old_status_window.visible = false
@new_status_window = Window_SkillStatusExtended.new(292, 96)
@new_status_window.visible = false
@command_window = Window_Command.new(200, KSkill::EXITOPTIONS)
@command_window.x = (544 - @command_window.width) / 2
@command_window.y = (412 - @command_window.height) / 2
@command_window.visible = @command_window.active = nil
end

def update
@help_windows.update
@selection_window.update
@skill_window.update
@replace_window.update
@old_status_window.update
@new_status_window.update
@command_window.update
if @selection_window.active
update_actor_selection
elsif @skill_window.active
update_skill_selection
elsif @command_window.active
update_exit_selection
elsif @old_status_window.visible
update_old_skills_info
elsif @new_status_window.visible
update_new_skills_info
end
end

def update_actor_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@help_windows.set_text(KSkill::AREYOUSURE, 1)
@selection_window.active = nil
@command_window.active = @command_window.visible = true
elsif Input.trigger?(Input::C)
Sound.play_decision
@help_windows.set_text(KSkill::REPLACESKILLS, 1)
id = KSkill.help_actors
@skill_window.actor = $game_actors
@replace_window.index = @selection_window.index
@replace_window.refresh
@skill_window.active, @selection_window.active = true, nil
@skill_window.index = 0
end
end

def update_skill_selection
if Input.trigger?(Input::B)
Sound.play_cancel
@help_windows.set_text(KSkill::REACHEDMAX, 1)
@skill_window.active, @selection_window.active = nil, true
@skill_window.index = -1
@skill_window.contents.clear
@replace_window.contents.clear
return
elsif Input.trigger?(Input::C)
@skill_window.update_replacement_check
text = sprintf(KSkill::REPLACEMENTSLEFT, KSkill.replacements)
@help_windows.set_text(text, 1)
elsif Input.trigger?(KSkill::OLDBUTTONID)
Sound.play_decision
actor_id = KSkill.help_actors
@actor_skills = $game_actors.skills
@skills_size = @actor_skills.size
@skill_index = @actor_skills.index(@skill_window.skill_id)
@old_status_window.skill_id = @skill_window.skill_id
@skill_window.active = false
@old_status_window.visible = true
elsif Input.trigger?(KSkill::NEWBUTTONID)
Sound.play_decision
actor_id = KSkill.help_actors
@actor_skills = KSkill.not_learned
@skills_size = @actor_skills.size
@skill_index = 0
@new_status_window.skill_id = @actor_skills
@skill_window.active = false
@new_status_window.visible = true
end
end

def update_old_skills_info
if Input.trigger?(Input::B) or Input.trigger?(KSkill::OLDBUTTONID)
Sound.play_cancel
@actor_skills.clear
@old_status_window.visible = false
@skill_window.active = true
elsif Input.trigger?(Input::UP)
if @skills_size == 1
Sound.play_cancel
return
end
@skill_index = (@skill_index + @skills_size - 1) % @skills_size
@old_status_window.skill_id = @actor_skills
elsif Input.trigger?(Input::DOWN)
if @skills_size == 1
Sound.play_cancel
return
end
@skill_index = (@skill_index + 1) % @skills_size
@old_status_window.skill_id = @actor_skills
end
end

def update_new_skills_info
if Input.trigger?(Input::B) or Input.trigger?(KSkill::NEWBUTTONID)
Sound.play_cancel
@actor_skills = nil
@new_status_window.visible = false
@skill_window.active = true
elsif Input.trigger?(Input::UP)
if @skills_size == 1
Sound.play_cancel
return
end
@skill_index = (@skill_index + @skills_size - 1) % @skills_size
@new_status_window.skill_id = @actor_skills
elsif Input.trigger?(Input::DOWN)
if @skills_size == 1
Sound.play_cancel
return
end
@skill_index = (@skill_index + 1) % @skills_size
@new_status_window.skill_id = @actor_skills
end
end

def update_exit_selection
if Input.trigger?(Input::C)
Sound.play_decision
case @command_window.index
when 0
KSkill.help_actors.each {|id| index = -1
next if @skill_window.replaced.nil?
@skill_window.replaced.each {|ix| index += 1
skill_id = KSkill.not_learned
$game_actors.replace_skill(ix, skill_id) } }
clear_skills_info
when 1
@selection_window.active = true
@command_window.active = @command_window.visible = nil
when 2 : clear_skills_info
end
$scene = Scene_Map.new unless @command_window.index == 1
end
end

def clear_skills_info
return unless KSkill::CLEAR_SKILLS_NOT_LEARNED
KSkill.help_actors.each {|id| KSkill.not_learned.clear }
KSkill.help_actors.clear
end
end

class Scene_Map
alias kyon_skill_limit_scn_map_up update
def update
kyon_skill_limit_scn_map_up
if KSkill.open_menu and !$game_message.visible
$scene = Scene_SkillMax.new
return
end
end
end