KActorSkill XP - kyonides - 06-03-2020
KActorSkill XP
by Kyonides Arkanthes
Introduction
Are you tired of just including skills your heroes can learn only if they picked a certain class or job?
Are you feeling an urge to add actor specific skills?
Now you can do it!
It is a two step process!
You first add some sort of skill recipe that only includes ID and some default conditions like level or number of items or amount of gold and you are done!
Rinse and repeat for every single actor that you think that should benefit from this!
You can either preset the skill learning (alias simple recipe) or add it via script call in game. Interesting, don't you think?
Side Notes
It does NOT include any menu so far...
This is just a theory but it might work in VX or VX Ace as well.
Script
Code: # * KActorSkill XP
# Scripter : Kyonides Arkanthes
# 2020-06-03
# This scriptlet has a specific goal, to let your heroes learn skills that are
# not linked to their current job or class. You could call them...
# Actor Specific Learnable Skills - It is a two step process!
# Step 1: Get a "recipe" for a specific skill
# Step 2: Finally learn the skill if you met the requirements
# KActorSkill.add_learn script call shows you all of the available options.
# Currently there are two ways to add such skill learning.
# Method 1: You setup the SKILLS constant found in the KActorSkill module.
# Method 2: You use the KActorSkill.add_learn script call in game.
# * Script Call *
# KActorSkill.add_learn(ActorID, SkillID, Options)
# Allows an Actor to add a skill learning to his list of learnable skills
# Options can be one of these combos:
# :level => SomeLevel
# :gold => SomeAmount
# :item => ItemID, :total => SomeNumber
module KActorSkill
SKILLS = {} # Do Not Touch This Line!
# Examples - You can add more than one Skill ID for any actor!
# SKILLS[ActorID] = { SkillID => { condition }, etc. }
# SKILLS[1] = { 1 => { :level => 3 } }
# SKILLS[2] = { 2 => { :gold => 300 } }
# SKILLS[3] = { 3 => { :item => 3, :total => 5 } }
SKILLS[1] = { 1 => { :level => 1 } }
class Setup
@@default_values = { :level => 1, :gold => 10 , :item => 1, :total => 0 }
def initialize(settings=@@default_values)
@level = settings.delete(:level) || 0
@gold = settings.delete(:gold) || 0
@item = settings.delete(:item) || 0
@total = settings.delete(:total) || 0
end
attr_reader :level, :gold, :item, :total
end
def self.add_learn(actor_id, skill_id, setup={})
actor = $game_actors[actor_id]
return if actor.learned_skill?(skill_id)
actor.set_learning(skill_id, setup)
end
end
class Game_Actor
alias :kyon_kskillsetup_gm_actor_setup :setup
alias :kyon_kskillsetup_gm_actor_exp= :exp=
def check_learn_skill(sid)
learn = @learnings[skill_id]
return unless learn
if learn.item > 0 and item_number(learn.item) >= learn.total
learn_extra_skill(sid)
$game_party.lose_item(learn.item, learn.total)
elsif learn.gold > 0 and @gold > learn.gold + 1
learn_extra_skill(sid)
$game_party.lose_gold(learn.gold)
end
end
def exp=(new_exp)
kyon_kskillsetup_gm_actor_exp=(new_exp)
learn = @learnings.dup
learn.each{|lid, ln| learn_extra_skill(lid) if ln.level <= @level }
end
def setup(actor_id)
kyon_kskillsetup_gm_actor_setup(actor_id)
@learnings = {}
KActorSkill::SKILLS[@actor_id].each do |sid, set|
next if set[:level] == 0
set[:level] <= @level ? learn_extra_skill(sid) : set_learning(sid, set)
end
end
def learn_extra_skill(sid)
@skills << sid
@skills = @skills.uniq
@learnings.delete(sid)
end
def learned_skill?(sid) @learnings[skill_id] or @skills.include?(skill_id) end
def set_learning(sid, set) @learnings[sid] = KActorSkill::Setup.new(set) end
attr_reader :learnings
end
class Game_Party
def learn_actor_skill(actor_id, skill_id)
@actors[actor_id].check_learn_skill(skill_id)
end
end
Terms & Conditions
For now it might be free for use in non commercial games.
Give me a free copy of your completed game if you include at least 2 of my scripts!
RE: KActorSkill XP - kyonides - 06-04-2020
KActorSkill XP Menu Script
I can't say it's ready for deployment but you can get a picture of how it would look like when finished.
You may report issues or make minor feature requests.
Code: # * KActorSkill XP Menu
# Scripter : Kyonides Arkanthes
# 2020-06-04
# $scene = KActorSkillMenu.new(ActorIndex)
# ActorIndex's default value: 0 (Aluxes)
# (ActorIndex) can be omitted if you start with the team leader.
module KActorSkill
PLACE_GOLD_SYMBOL = :first
ACTOR_NAME_AS_TITLE = true
PENDING_SKILLS_LABEL = "%s's Pending Skills"
SKILL_NAME_LABEL = "Learn %s"
NO_LEARNING = "No skill found!"
end
class KActorSkillWindow < Window_Selectable
def initialize
super(0, 64, 320, 192)
self.contents = Bitmap.new(width - 32, height - 32)
end
def list=(new_list)
@list = new_list
refresh
end
def refresh
contents.clear
if @list.empty?
contents.draw_text(0, 0, width - 32, 28, KActorSkill::NO_LEARNING, 1)
return
end
@label = KActorSkill::SKILL_NAME_LABEL
@symbol_first = KActorSkill::PLACE_GOLD_SYMBOL == :first
@symbol = $data_system.words.gold
ly = 0
@ids = @list.keys.sort
@ids.each do |sid|
draw_skill(sid)
ly += 28
end
end
def draw_skill(sid)
skill = $data_skills[sid]
name = sprintf(@label, skill.name)
skill = @list[sid]
lvl = "LVL " + skill.level.to_s
gold = skill.gold.to_s
gold = @symbol_first ? @symbol + gold : gold + @symbol
item = $data_items[skill.item].name
total = "#{$game_party.item_number(skill.item)}/#{skill.total}"
contents.draw_text(0, ly, width - 32, 28, name)
contents.draw_text(120, ly, 160, 28, lvl)
contents.draw_text(0, ly + 24, 160, 28, gold)
contents.draw_text(120, ly + 24, width - 152, 28, item)
contents.draw_text(240, ly + 24, width - 272, 28, total)
end
attr_reader :ids
end
class KActorSkillMenu
def initialize(pos=0) @index = pos end
def main
@name_only = KActorSkill::ACTOR_NAME_AS_TITLE
@title = KActorSkill::PENDING_SKILLS_LABEL
@actors = $game_party.actors
@name_window = Window_Help.new
@skill_window = KActorSkillWindow.new
update_actor_data
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@skill_window.dispose
end
def update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
return $scene = Scene_Map.new
elsif Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
elsif Input.trigger?(Input::L)
$game_system.se_play($data_system.cursor_se)
@index = (@index - 1) % @actors.size
update_actor_data
return
elsif Input.trigger?(Input::R)
$game_system.se_play($data_system.cursor_se)
@index = (@index + 1) % @actors.size
update_actor_data
end
end
def update_actor_data
actor = @actors[@index]
label = @name_only ? actor.name : sprintf(@title, actor.name)
@name_window.set_text(label, 1)
@skill_window.list = actor.learnings
end
end
The terms and conditions are the same as those found on the first post.
|