SKillGem XP
#1
SKillGem XP
Updated Again!
by Kyonides Arkanthes


Introduction

I had been thinking about skills when I came up with the not so original idea of modifying a skill's stats. This scriptlet would eventually do it via stat modifiers. You better read the comments I included in the script to understand how it actually works! Laughing + Tongue sticking out

Warning!

You will need to parse a TXT file! Happy with a sweat

The Code

Code:
# * SKillGem XP
#   Scripter : Kyonides Arkanthes
#   v0.9.0 - 2019-10-14 (No Custom Scene Menu Included)

# This is the first step of two to let the player modify a hero's skills via
# the consumption of skill gems!

# Create a text file or save the template and name it "skillgem modifiers.txt"
# in your game folder and add as many modifiers as you wish.

# @modifiers.default represents all those skills not defined in the text file
# so modify its default values at will.

# DEBUG Constant values and effects #

# true - parse text file (for games under development)
# false or nil - load rxdata file (for closed demos or finished games)

# * Script Calls * In case you don't want to use the Skill Gem menu

# actor = $game_party.actors[Member_Index]
#   Keeps an actor aka hero in a temporary variable
# actor.skill_level(Skill_ID)
#   Returns a skill's current level
# actor.skill_level_up(Skill_ID)
#   Levels up a skill's level using the brute force method!
#   No skill gems are lost in the process!
# actor.safe_skill_level_up(Skill_ID)
#   Safely levels up a skill's level or returns the current level if failed
#   It consumes skill gems on success!
# actor.enough_skill_gems?(Skill_ID)
#   Checks if there are enough items to level up a skill
#   Returns false if there are no additional levels available!

# $game_party.skill_gems_total
#   Returns the total amount of skill gems the player currently owns.

# * Warning *

# In case you don't include any Title scene script in your game project, REMOVE
# the Scene_Title class contents from my script to prevent your game from
# failing to alias an non existing method. You also need to modify your custom
# script by replacing its own definition of $data_skills with the following:

# $data_skills = SKillGem.skills

module SKillGem
  DEBUG = true
  ITEM_ID = 1 # It should be an item found in the Items Database!
  module Improve
    def modifier() @modifier end
    def modifier=(hash) @modifier = hash end
    def level() @modifier[:level] end
    def level=(lvl) @modifier[:level] = lvl end
    def gems_level(level) @modifier[:gems][level] || 0 end
    def sp_cost() @sp_cost + @modifier[:cost] * @modifier[:level] end
    def power() @power + @modifier[:power] * @modifier[:level] end
    def atk_f() @atk_f + @modifier[:atk] * @modifier[:level] end
    def eva_f() @eva_f + @modifier[:eva] * @modifier[:level] end
    def str_f() @str_f + @modifier[:str] * @modifier[:level] end
    def dex_f() @dex_f + @modifier[:dex] * @modifier[:level] end
    def agi_f() @agi_f + @modifier[:agi] * @modifier[:level] end
    def int_f() @int_f + @modifier[:int] * @modifier[:level] end
    def pdef_f() @pdef_f + @modifier[:pdef] * @modifier[:level] end
    def mdef_f() @mdef_f + @modifier[:mdef] * @modifier[:level] end
  end
  def self.add_skill_gem_data
    skills = load_data("Data/Skills.rxdata")
    return if skills[1].instance_variables.include?('@modifier')
    skills[1..-1].each do |s|
      s.extend Improve
      s.modifier = { :power => 0, :cost => 0, :atk => 0, :eva => 0, :str => 0,
        :dex => 0, :agi => 0, :int => 0, :pdef => 0, :mdef => 0,
        :level => 0, :gems => [0] }
    end
    save_data(skills, "Data/SkillsSG.rxdata")
    skills
  end

  def self.parse_modifiers
    lines = File.readlines('skillgem modifiers.txt')
    lines << "\n"
    total = lines.size
    raise("SKillGem is misconfigured!") if total < 13
    modifiers = {}
    (total / 13).times do
      sid = lines.shift.scan(/\d+/)[0].to_i
      modifiers[sid] = mod = {}
      mod[:gems] = lines.shift.scan(/\d+/).map{|d| d.to_i }
      mod[:cost] = lines.shift.scan(/\d+/)[0].to_i
      mod[:power] = lines.shift.scan(/\d+/)[0].to_i
      mod[:atk] = lines.shift.scan(/\d+/)[0].to_i
      mod[:eva] = lines.shift.scan(/\d+/)[0].to_i
      mod[:str] = lines.shift.scan(/\d+/)[0].to_i
      mod[:dex] = lines.shift.scan(/\d+/)[0].to_i
      mod[:agi] = lines.shift.scan(/\d+/)[0].to_i
      mod[:int] = lines.shift.scan(/\d+/)[0].to_i
      mod[:pdef] = lines.shift.scan(/\d+/)[0].to_i
      mod[:mdef] = lines.shift.scan(/\d+/)[0].to_i
      mod[:level] = 0
      lines.shift
    end
    save_data(modifiers, "Data/SKillGem.rxdata")
    modifiers
  end
  def self.modifiers() @modifiers end
  def self.skills() @skills end
  @skills = DEBUG ? add_skill_gem_data : load_data("Data/SkillsSG.rxdata")
  @modifiers = DEBUG ? parse_modifiers : load_data("Data/SKillGem.rxdata")
  @modifiers.default = {
    :cost => 0, :power => 0, :atk => 0, :eva => 0, :str => 0,
    :dex => 0, :agi => 0, :int => 0, :pdef => 0, :mdef => 0,
    :level => 0, :gems => [0]
  }
end

class Game_Battler
  alias :kyon_skill_gem_skill_effect :skill_effect
  def skill_effect(user, skill)
    skill = user.gem_skills[skill.id] if user.class == Game_Actor
    kyon_skill_gem_skill_effect(user, skill)
  end
end

class Game_Actor
  attr_reader :gem_skills
  alias :kyon_skill_gem_gm_actor_setup :setup
  def setup(actor_id)
    @gem_skills = {}
    kyon_skill_gem_gm_actor_setup(actor_id)
    @skills.each{|n| @gem_skills[n] = setup_gem_skill(n) }
  end

  def setup_gem_skill(sid)
    skill = SKillGem.skills[sid].dup
    skill.extend SKillGem::Improve
    skill.modifier = SKillGem.modifiers[sid].dup
    skill
  end

  def learn_skill(skill_id)
    return if skill_id == 0 or skill_learn?(skill_id)
    @gem_skills[skill_id] = setup_gem_skill(skill_id)
    @skills.push(skill_id)
    @skills.sort!
  end

  def forget_skill(skill_id)
    @gem_skills.delete(skill_id)
    @skills.delete(skill_id)
  end

  def enough_skill_gems?(sid)
    skill_lvl = @gem_skills[sid].level + 1
    gems_level = SKillGem.skills[sid].gems_level(skill_lvl)
    return false if gems_level == 0
    return $game_party.skill_gems_total >= gems_level
  end

  def safe_skill_level_up(sid)
    skill_lvl = @gem_skills[sid].level
    gems_level = SKillGem.skills[sid].gems_level(skill_lvl + 1)
    total = $game_party.skill_gems_total
    return skill_lvl if gems_level == 0 or total < gems_level
    $game_party.lose_item(SKillGem::ITEM_ID, gems_level)
    skill_level_up(sid)
  end
  def skill_level_up(sid) @gem_skills[sid].level = @skill_levels[sid] end
  def skill_level(sid) @gem_skills[sid].level end
  def skill_next_level(sid) @gem_skills[sid].level + 1 end
end

class Game_Party
  def skill_gems_total() @items[SKillGem::ITEM_ID] || 0 end
end

# Scene_Title Modification - For games that do include that script only!
class Scene_Title
  alias :kyon_skill_gem_scn_title_main :main
  def main
    kyon_skill_gem_scn_title_main
    $data_skills = SKillGem.skills
  end
end

Template
Code:
Skill ID: 1
Gems per Level: 0, 5
Cost: -5
Power: 5
Attack: 0
Evasion: 0
Strength: 0
Dexterity: 0
Agility: 0
Intelligence: 0
P. Defense: 0
M. Defense: 0

Feel free to add as many skills as needed, but always leave a blank line after each skill data!

Notes

I might add it has reached some level of maturity so it should not fail to run on fresh projects (with no save files).

Terms & Conditions

You must include my nickname and the current website's URL in your game credits.
Since this scriptlet is under development and I need (beta) testers, it's for free as in beer and speech.
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 }
#2
I Need Brains!? Confused
No, wait a second! Shocked I just need some Skill Gems! Happy with a sweat 

Today I have revisited this scriptlet to add more features that will make it look usable already! Laughing 

I added skill gem levels to let you ask the player to start collecting skill gems! Tongue sticking out 

Obviously you'll let them level up their skills! Laughing 

You can manually do so via script calls! Laughing + Tongue sticking out

Just promise me you won't EVER dare to level up Aluxes's skills ever! Confused 

I also posted a template so you can use it in your game projects.

Happy Pumped Up Skills! Laughing 

Side notes

I won't be held responsible for overpowering your heroes! 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 }
#3
Important Script Update

I needed to update my script once again because I noticed there could be an issue with editing a game with the default RMXP editor. The root cause was that the editor always tries to read the default RPG::Skill class definition without any later modifications. Saving the new data in the Skills.rxdata file would make the editor crash so I had to add some extra code to save it in a different file, namely SkillsSG.rxdata to make sure you could use vanilla Game.exe or HiddenChest or anything similar and the default editor at any time.

What that also means is that I had to further change other stuff like the Game_Actor class, the class that represents a hero in RM series, to let it fully update the extra skill info I added in my script. The save files will be a little bit larger than before, but that isn't supposed to be a real surprise, don't you think? Laughing 

Don't forget! Happy with a sweat Keep deleting old save files before you update scripts that modify heroes or enemies or vehicles and save such data in binary format! Shocked

By the way, I consider my script has reached the 0.9.0 milestone already, unless you come up with bug reports that force me to fix it. Laughing + Tongue sticking out The only thing that it still lacks would be a menu scene. Laughing
"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 }




Users browsing this thread: 3 Guest(s)