KActorSkill XP
#1
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! Shocked 

It is a two step process! Happy with a sweat
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! Shocked
Rinse and repeat for every single actor that you think that should benefit from this! Grinning

You can either preset the skill learning (alias simple recipe) or add it via script call in game. Thinking Interesting, don't you think?

Side Notes
It does NOT include any menu so far... Laughing
This is just a theory but it might work in VX or VX Ace as well. Confused

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! Laughing + Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
KActorSkill XP - by kyonides - 06-03-2020, 05:03 AM
RE: KActorSkill XP - by kyonides - 06-04-2020, 09:27 PM



Users browsing this thread: 2 Guest(s)