and KSkills BS Add-Ons
Version 1.0.7
by Kyonides-Arkanthos
Introduction
Let me see... Well, it'd let you learn skills from equipment while not impeding you from learning them by leveling up.
IDK if this is revolutionary or not or just one of a thousands of scripts that let you learn skills in unusual ways for the RM, but I don't care. The point is this one shows you how I'd make it possible.
Now you can also learn skills by accumulating points every time you use a skill during battle!
This is available for the standard battle system, ParaDog's CTB (Sideview Battle) and XAS 3.8.
Now you can also increase your stats by using skills! Check the examples to learn how to configure it.
BTW, you'd also forget skills depending on your current level if you level down...
Script
Just copy and paste and then edit the Constants in KSkillsDB module. I left 1 or 2 examples of how this script is supposed to be configured by users.
RAW Version
[rgss]# KSkills - RAW
# by Kyonides-Arkanthos
# v 1.0.7 - 09.11.2010
# v 1.0.0 - 08.30.2010
# Instructions
# Heroes can learn new skills by equipping weapons, armor, accessories...
# If you want your heroes to learn skills by using other weaker skills, you
# should paste the right KSkills battle system add-on below this script
# Skill ID used => Requirement type, Req type ID to be learned, Minimum Quota
# Basic Stats like STR, AGI, INT should include a 4th option
# ** Single Arrays **, those only enclosed by a single pair of [],
# will provide your hero with a single benefit per skill use.
# ** Nested Arrays **, those enclosed by multiple sets of [],
# will provide your hero with multiple benefits per skill use.
module KSkillsDB
SKILLS_1 = {
# Skill 58 allows you to learn Skill 62 if used at least 15 times
58 => [[:skill, 62, 15], [:str, 1, 18, true]],
59 => [:skill, 63, 20],
# Skill 60 allows you to increase your agility by 5 if used at least 20 times
# AGI will increase more than once if the 4th option is set to true
60 => [:agi, 5, 20, true],
}
SKILLS_8 = {
7 => [[:skill, 8, 15], [:agi, 1, 15, true]],
8 => [:skill, 9, 20],
# Skill 9 allows you to increase your intel. by 5 if used at least 15 times
# INT will increase more than once if the 4th option is set to true
9 => [:int, 2, 10, true],
}
# Weapon ID => Skills IDs (Numbers or 1 Range) of skills the hero'd learn
WEAPONS_1 = {
1 => [57],
2 => [57, 58],
3 => [57..59],
4 => [58..60],
}
WEAPONS_8 = {
}
# Actor ID => Ways to learn other skills :
# (Skill Quotas, Equipped Weapons, Shields, Helmets, Armors, Accessories)
ACTORS = {
1 => [SKILLS_1, WEAPONS_1, nil, nil, nil, nil],
8 => [SKILLS_8, WEAPONS_8, nil, nil, nil, nil],
}
@new_skills, @window_enabled = [], false
TABS = ['tabdisabled', 'tabnormal', 'tabhover']
LABELS = ['Level UP', 'Equipment', 'Skills']
ALL_SKILLS = load_data('Data/Skills.rxdata')
def self.skills_window_enabled=(state) @window_enabled = state end
def self.skills_window_enabled?; @window_enabled end
def self.lvlup_skills; @new_skills end
end
module RPG::Cache
def self.face(filename) load_bitmap('Graphics/Faces/', filename) end
end
class Game_Actor
attr_reader :quotas, :lvlup_skills, :equip_skills
def initialize(actor_id)
super()
@equip_skills, @high_lvl_skills = [], []
setup(actor_id)
@lvlup_skills = @skills.dup
create_skills_quotas
equip = [@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id]
5.times {|n| skills_for_current_equipment(n, equip)}
end
def create_skills_quotas
@quotas = {}
return unless KSkillsDB::ACTORS.keys.include?(@actor_id)
skills = KSkillsDB::ACTORS[@actor_id][0]
skills.keys.sort.each {|skill_id|
quotas = skills[skill_id]
value = skills[skill_id][0].is_a?(Array)? Array.new(quotas.size, 0) : 0
@quotas[skill_id] = value
}
end
def check_skill_quotas(skill_id)
return unless KSkillsDB::ACTORS.keys.include?(@actor_id)
conditions = KSkillsDB::ACTORS[@actor_id][0].fetch(skill_id)
return if conditions.nil?
check_conditions(skill_id, conditions) if @quotas[skill_id].is_a?(Integer)
conditions.size.times do |n|
check_conditions(skill_id, conditions[n], n)
end if @quotas[skill_id].is_a?(Array)
end
def check_conditions(skill_id, condition, index=nil)
quota = update_skill_quota(skill_id, condition[2], index)
return unless quota == condition[2]
case condition[0]
when :skill; learn_skill(condition[1]); learned_new_skills(condition[1])
when :hp; @maxhp_plus += condition[1]
when :sp; @maxsp_plus += condition[1]
when :str; @str_plus += condition[1]
when :dex; @dex_plus += condition[1]
when :agi; @agi_plus += condition[1]
when :int; @int_plus += condition[1]
end
return if condition[0] == :skill
update_skill_quota(skill_id, condition[2], index, condition[3])
end
def update_skill_quota(id, minimum, index, clear=nil)
if !index and @quotas[id] < minimum
@quotas[id] = clear ? 0 : @quotas[id] + 1
elsif index and @quotas[id][index] < minimum
@quotas[id][index] = clear ? 0 : @quotas[id][index] + 1
end
end
def learned_new_skills(id)
skill = [@name, $data_skills[id].name, id]
KSkillsDB.lvlup_skills << skill if !KSkillsDB.lvlup_skills.include?(skill)
end
def equip(equip_type, id)
equip = [@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id]
case equip_type
when 0 # Weapon
if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(equip[equip_type], 1)
$game_party.lose_weapon(equip[equip_type] = id, 1)
skills_for_current_equipment(equip_type, equip)
end
when 1..4 # Shield Head Body Accessory
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[equip[equip_type]], $data_armors[id])
$game_party.gain_armor(equip[equip_type], 1)
$game_party.lose_armor(equip[equip_type] = id, 1)
skills_for_current_equipment(equip_type, equip)
end
end
@weapon_id, @armor1_id, @armor2_id, @armor3_id, @armor4_id = equip
end
def skills_for_current_equipment(kind, equip)
# Return if actor is not included
return if KSkillsDB::ACTORS[@class_id].nil?
# Weapon Shield Head Body or Accessory
equipment = KSkillsDB::ACTORS[@class_id][kind+1]
# Return if equipment type for this actor is not included or is empty
return if equipment.nil? or equipment.empty?
equip_ids = equipment.keys
# Iterate through all skills the actor may learn from this equipment
# type and delete those the actor did not also learn in any other way
equip_ids.each {|current_id|
skillset = equipment[current_id]
skillset = skillset[0] if skillset[0].is_a?(Range)
skillset.each {|id|
@equip_skills.delete id
forget_skill(id) if !(@lvlup_skills+@high_lvl_skills).include?(id)
}
} unless @skills.empty?
# Return if the actor did not equip a new weapon or armor, etc.
return if equip[kind] == 0
skills = equipment[equip[kind]]
skills = skills[0] if !skills[0].is_a?(Integer)
skills.each {|id|
learn_skill id
@equip_skills << id if !@equip_skills.include?(id)
} if !skills.nil?
end
def exp=(exp)
@exp = [[exp, 9999999].min, 0].max
lvlup, equip, high = @lvlup_skills, @equip_skills, @high_lvl_skills
while @exp >= @exp_list[@level+1] and @exp_list[@level+1] > 0
@level += 1
$data_classes[@class_id].learnings.each {|skill|
level, id = skill.level, skill.skill_id
next if level != @level or @lvlup_skills.include?(id)
learn_skill id
@lvlup_skills << id
learned_new_skills id
}
end
equip, high = @equip_skills, @high_lvl_skills
while @exp < @exp_list[@level]
@level -= 1
$data_classes[@class_id].learnings.each {|skill|
level, id = skill.level, skill.skill_id
@lvlup_skills.delete(id) if @lvlup_skills.include?(id)
@skills.delete(id) if level > @level and !(equip+high).include?(id)
}
end
@hp = [@hp, self.maxhp].min
@sp = [@sp, self.maxsp].min
end
end
# Modification for Ruby Hash class
class Hash
alias kyon_hash_fetch fetch
def fetch(key) !self[key].nil? ? kyon_hash_fetch(key) : nil end
end
# Modifications for Scene_Equip (default script)
class Scene_Equip
def refresh
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
item1 = @right_window.item
case @right_window.index
when 0; @item_window = @item_window1
when 1; @item_window = @item_window2
when 2; @item_window = @item_window3
when 3; @item_window = @item_window4
when 4; @item_window = @item_window5
end
@left_window.set_new_parameters(nil, nil, nil) if @right_window.active
if @item_window.active
item2 = @item_window.item
# Change equipment & Duplicate actor - Actor won't learn skills if the
# player moves the cursor in the item window or cancels the selection
actor_dup = @actor.dup
actor_dup.equip(@right_window.index, item2.nil? ? 0 : item2.id)
new_atk = actor_dup.atk
new_pdef = actor_dup.pdef
new_mdef = actor_dup.mdef
actor_dup.equip(@right_window.index, item1.nil? ? 0 : item1.id)
@left_window.set_new_parameters(new_atk, new_pdef, new_mdef)
end
end
end
[/rgss]
Default Add-On
[rgss]# KSkills - Default Add-On
# for KSkills v 1.0.7 - 09.05.2010
# For XP Battle System & ParaDog's CTB (Sideview Battle)
# This add-on will let you learn skills by using other skills on the map.
# A help window with a skill icon will appear on screen if one hero or more
# learned skills.
class Scene_Battle
KSkillsDB.lvlup_skills.clear
alias kyon_kskills_scn_battle_msar make_skill_action_result
alias kyon_kskills_scn_battle_sp5 start_phase5
alias kyon_kskills_scn_battle_up_ph5 update_phase5
def make_skill_action_result
kyon_kskills_scn_battle_msar
return if @active_battler.is_a?(Game_Enemy)
return if @active_battler.quotas.empty?
@active_battler.check_skill_quotas(@skill.id)
end
def start_phase5
@skills_wait_count = 80
kyon_kskills_scn_battle_sp5
end
def update_phase5
# If results window is visible and skills wait counter is not zero
if @phase5_wait_count == 0 and @skills_wait_count > 0
@skills_wait_count -= 1
if @skills_wait_count == 0 and !KSkillsDB.lvlup_skills.empty?
# Get Actor & Skill Name at index 0 (first position)
name, skill, id = KSkillsDB.lvlup_skills[0]
@help_window.set_text(name + ' has learned ' + skill, 1)
@help_window.draw_skill_icon(KSkillsDB::ALL_SKILLS[id], 4, 0)
@help_window.draw_skill_icon(KSkillsDB::ALL_SKILLS[id], 584, 0)
@help_window.visible = true
KSkillsDB.lvlup_skills.shift
@skills_wait_count = 80
end
@help_window.visible = false if @skills_wait_count == 0
return
end
kyon_kskills_scn_battle_up_ph5
end
end
class Window_Help
def draw_skill_icon(skill, x, y)
return if skill.nil?
bitmap = RPG::Cache.icon(skill.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
end
end
[/rgss]
XAS 3.8 Add-On
[rgss]# KSkills - XAS 3.8 Add-On
# for KSkills v 1.0.5-7 - 09.05.2010
# This add-on will let you learn skills by using other skills on the map.
# An icon will appear on top of your hero if he or she learns a skill.
class Game_Player
alias kyon_kskills_gm_player_shoot shoot
def shoot(action_id)
kyon_kskills_gm_player_shoot(action_id)
return if $game_party.actors[0].quotas.empty?
$game_party.actors[0].check_skill_quotas(action_id)
end
end
class Spriteset_Map
alias kyon_kskills_gm_player_init initialize
alias kyon_kskills_gm_player_update update
def initialize
@frames = 0
kyon_kskills_gm_player_init
end
def update
kyon_kskills_gm_player_update
if !KSkillsDB.lvlup_skills.empty?
skill, @frames = $data_skills[KSkillsDB.lvlup_skills[0][2]], 80
@skill_sprite = Sprite.new
@skill_sprite.x = ($game_player.x + 0.125) * 32
@skill_sprite.y = ($game_player.y - 1.5) * 32
@skill_sprite.bitmap = RPG::Cache.icon skill.icon_name
@skill_sprite.visible = true
KSkillsDB.lvlup_skills.clear
elsif KSkillsDB.lvlup_skills.empty? and @frames > 0
@frames -= 1
@skill_sprite.x = ($game_player.x + 0.125) * 32
@skill_sprite.y = ($game_player.y - 1.25) * 32
elsif @frames == 0 and !@skill_sprite.nil?
@skill_sprite.visible = false
@skill_sprite.bitmap.dispose
@skill_sprite.dispose
@skill_sprite = nil
end
end
end
[/rgss]
Terms & Conditions
For Non Commercial Use and you should include me in your game credits if you use this script there.