Save-Point
SkillUpgrade - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+--- Thread: SkillUpgrade (/thread-8836.html)



SkillUpgrade - kyonides - 10-25-2023

SkillUpgrade
XP
version 0.2.0

by Kyonides

Introduction

This script allows you to quickly setup a specific list of skills that can be upgraded by the heroes during gameplay. The more they use their skills the faster the upgrades can take place.

It is supposed to be as simple as possible. This might mean bad news for you for I could easily reject any of your future feature requests, guys. Tongue sticking out

No GUI is included! Tongue sticking out 

It requires the creation of a template file, basically a TXT file.
You can find the default one right below the script.

The Script - Alpha Stage

Code:
# * SkillUpgrade XP * #
#  Scripter : Kyonides Arkanthes
#  v0.2.0 - 2023-10-24

# This script allows you to quickly setup a specific list of skills that can be
# upgraded by the heroes during gameplay. The more they use their skills the
# faster the upgrades can take place.

# Create a new text file. It should have the same name as the value of the
# TEMPLATE_NAME constant you can find below.
# That file will be used as a template.
# Optionally, you could use and carefully edit the default template instead.

module SkillUp
  TEMPLATE_NAME = "skill_upgrades.txt"

  class Require
    def initialize(*args)
      @uses = args[0] || 0
      @target_id = args[1] || 0
      @keep = args[2]
    end

    def setup(hash)
      @target_id = hash[:target] || 0
      @keep = hash[:keep]
    end

    def ignore?
      @target_id == 0
    end
    attr_accessor :uses, :target_id, :keep
  end

  COMMENT_SYM = "#"
  BASE_UPGRADES = {}
  extend self
  def set(skill_id)
    data = BASE_UPGRADES[skill_id] || {}
    req = Require.new
    req.setup(data)
    req
  end
end

class String
  def scan_int
    scan(/\d+/).map{|n| n.to_i }
  end
end

module SkillUp
  def parse
    if File.exist?(TEMPLATE_NAME)
      lines = File.readlines(TEMPLATE_NAME)
    else
      lines = []
    end
    list = BASE_UPGRADES
    lines.delete_if {|line| line[0] == COMMENT_SYM }
    lines.each do |line|
      next if line.chomp.empty?
      skill_id, total, target = line.scan_int
      keep = line[/keep/i] != nil
      list[skill_id] = { :use_max => total, :target => target, :keep => keep }
    end
  end
  parse
end

class RPG::Skill
  def use_max
    @requirement ||= SkillUp::BASE_UPGRADES[@id] || { :use_max => 0 }
    @requirement[:use_max]
  end
end

class Game_Actor
  alias :kyon_skill_up_gm_act_init :initialize
  def initialize(actor_id)
    kyon_skill_up_gm_act_init(actor_id)
    @skill_up = {}
    @skills.each {|sid| set_skill_upgrade(sid) }
  end

  def set_skill_upgrade(skill_id)
    @skill_up[skill_id] = SkillUp.set(skill_id)
  end

  def skill_upgrade(skill_id)
    @skill_up[skill_id]
  end
  attr_reader :skill_up
end

The Template

This file should always have a blank line at the very end. Never ever forget this! Serious

Code:
# How to Use?
# Skill Number: uses Number, learn ID, delete
# Skill Number: uses Number, learn ID, keep

Skill 1:   uses 25, learn 2, delete
Skill 2:   uses 50, learn 3, delete
Skill 3:   uses 75, learn 4, keep
Skill 57:  uses 30, learn 58, delete
Skill 58:  uses 60, learn 59, delete
Skill 59:  uses 30, learn 60, delete
Skill 60:  uses 60, learn 61, keep
Skill 65:  uses 70, learn 66, delete
Skill 70:  uses 100, learn 71, keep

FAQ

Q: Will the script be ported to X engine?
A: I don't know for sure. Who Knows?

Terms & Conditions

I haven't defined any specific conditions for this script as of today because it's still in alpha stage. Happy with a sweat
To be continued... or updated. Laughing