RESOLVED Stat gain based on Class.

Started by Spoofus, December 13, 2018, 07:01:33 pm

Previous topic - Next topic

Spoofus

December 13, 2018, 07:01:33 pm Last Edit: May 10, 2019, 10:31:29 am by Spoofus
Heyo,
I am looking to get a script made for Rmxp
It is for character stat gain at level up, and depending
on that characters class it will determine what stats are gained

Example:
Say the character was a warrior class and it's stats per level are like HP:10, SP:3, STR:4, Dex:2,Int:1, and AG:1.
Now say the same character changes their class to mage
It's stat gains would be HP:4, SP:13, STR:1, Dex:1, Int:7, and AG:3
The stat gains from class to class when leveling up would be permanent and not lost when classes are changed.

This would also have to be compatible with the RO Job/Skill learning script, keep in mind I am not using the class bonus stats feature found in this script.


My Blog site I am working on: http://spoofus.weebly.com/

KK20

A very simple version:

#==============================================================================
# Job-based Level Up Stats                                            Ver 1.0
# By KK20                                                             Dec 14 18
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each stat in the
    # array indicates how much that stat will increase per level up.
    #-------------------------------------------------------------------------
    when 1 # Fighter
      [7, 2, 5, 2, 3, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [3, 3, 3, 3, 3, 3]
    end
  end
end

class Game_Actor
  alias job_level_up_stats_level level=
  def level=(val)
    start_level = @level
    job_level_up_stats_level(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    self.maxhp += stat_array[0] * level_difference
    self.maxsp += stat_array[1] * level_difference
    self.str   += stat_array[2] * level_difference
    self.dex   += stat_array[3] * level_difference
    self.agi   += stat_array[4] * level_difference
    self.int   += stat_array[5] * level_difference
  end
 
  alias job_level_up_stats_exp exp=
  def exp=(val)
    start_level = @level
    job_level_up_stats_exp(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    self.maxhp += stat_array[0] * level_difference
    self.maxsp += stat_array[1] * level_difference
    self.str   += stat_array[2] * level_difference
    self.dex   += stat_array[3] * level_difference
    self.agi   += stat_array[4] * level_difference
    self.int   += stat_array[5] * level_difference
  end
end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

KK20

July 11, 2019, 01:01:59 am #2 Last Edit: July 12, 2019, 04:05:37 am by KK20
Quote from: SpoofusWould it be to hard do a version of it where instead of basing it on the actor level, have it instead based on class level based from RO job/skill script?
I am trying something with balancing actor and enemy stats


Untested

#==============================================================================
# Job-based Level Up Stats (RO Edit)                                    Ver 1.0
# By KK20                                                             Jul 10 19
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Place below RO Job/Skill System.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each stat in the
    # array indicates how much that stat will increase per level up.
    #-------------------------------------------------------------------------
    when 1 # Fighter
      [7, 2, 5, 2, 3, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [3, 3, 3, 3, 3, 3]
    end
  end
end

class Game_Actor
  def level_up_stat_gain(levels, class_id)
    stat_array = JobLevelUp.level_up_stats(class_id)
    self.maxhp += stat_array[0] * levels
    self.maxsp += stat_array[1] * levels
    self.str   += stat_array[2] * levels
    self.dex   += stat_array[3] * levels
    self.agi   += stat_array[4] * levels
    self.int   += stat_array[5] * levels
  end

  #----------------------------------------------------------------------------
  # job_level_change
  #  val  - new level value
  #  id   - class ID
  #  flag - determines whether EXP should be updated or not
  #  This method processes change of a job level.
  #----------------------------------------------------------------------------
  alias get_job_level_change_diff job_level_change
  def job_level_change(val, id = @class_id, flag = true)
    old_level = job_level(id)
    get_job_level_change_diff(val, id, flag)
    level_diff = job_level(id) - old_level
    level_up_stat_gain(level_diff, id)
  end

end

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Spoofus

Is there a chance a edit of both versions of this could be done where you can set a stat range increases?
i.e. at level up hp increase 1-5, mp 1-4, str. 1-3, etc., etc. instead of set numbers for each actor?
I am trying to do some balancing and trying to see what would work best, and using this method would keep each actor on par with one another but still allow for their stats to still be varied enough for their respective roles.

the regular  based on actor level version
Spoiler: ShowHide
#==============================================================================
# Job-based Level Up Stats                                            Ver 1.0
# By KK20                                                             Dec 14 18
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each stat in the
    # array indicates how much that stat will increase per level up.
    #-------------------------------------------------------------------------
    when 1 # Fighter
      [7, 2, 5, 2, 3, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [3, 3, 3, 3, 3, 3]
    end
  end
end

class Game_Actor
  alias job_level_up_stats_level level=
  def level=(val)
    start_level = @level
    job_level_up_stats_level(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    self.maxhp += stat_array[0] * level_difference
    self.maxsp += stat_array[1] * level_difference
    self.str   += stat_array[2] * level_difference
    self.dex   += stat_array[3] * level_difference
    self.agi   += stat_array[4] * level_difference
    self.int   += stat_array[5] * level_difference
  end
 
  alias job_level_up_stats_exp exp=
  def exp=(val)
    start_level = @level
    job_level_up_stats_exp(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    self.maxhp += stat_array[0] * level_difference
    self.maxsp += stat_array[1] * level_difference
    self.str   += stat_array[2] * level_difference
    self.dex   += stat_array[3] * level_difference
    self.agi   += stat_array[4] * level_difference
    self.int   += stat_array[5] * level_difference
  end
end



based on class level (for the RO script)
Spoiler: ShowHide
#==============================================================================
# Job-based Level Up Stats (RO Edit)                                    Ver 1.0
# By KK20                                                             Jul 10 19
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Place below RO Job/Skill System.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each stat in the
    # array indicates how much that stat will increase per level up.
    #-------------------------------------------------------------------------
    when 1 # Fighter
      [7, 2, 5, 2, 3, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [3, 3, 3, 3, 3, 3]
    end
  end
end

class Game_Actor
  def level_up_stat_gain(levels, class_id)
    stat_array = JobLevelUp.level_up_stats(class_id)
    self.maxhp += stat_array[0] * levels
    self.maxsp += stat_array[1] * levels
    self.str   += stat_array[2] * levels
    self.dex   += stat_array[3] * levels
    self.agi   += stat_array[4] * levels
    self.int   += stat_array[5] * levels
  end

  #----------------------------------------------------------------------------
  # job_level_change
  #  val  - new level value
  #  id   - class ID
  #  flag - determines whether EXP should be updated or not
  #  This method processes change of a job level.
  #----------------------------------------------------------------------------
  alias get_job_level_change_diff job_level_change
  def job_level_change(val, id = @class_id, flag = true)
    old_level = job_level(id)
    get_job_level_change_diff(val, id, flag)
    level_diff = job_level(id) - old_level
    level_up_stat_gain(level_diff, id)
  end

end



My Blog site I am working on: http://spoofus.weebly.com/

Jaiden

How do you want to manage this? Do you want a configuration where you set each actor to get 1-5 points per stat per level?

Spoofus

August 23, 2019, 10:12:07 am #5 Last Edit: August 23, 2019, 10:14:06 am by Spoofus
QuoteHow do you want to manage this? Do you want a configuration where you set each actor to get 1-5 points per stat per level?


pretty much as you just said, but depending on what class the actor is currently, the random stat ranges would be varied

class: hp/sp/str/dex/agi/int       

Warrior gains: 3-6/1-3/4-8/1-4/2-5/1-4
Wizard gains: 1-3/4-7/1-3/2-4/2-5/4-8

basically I am looking to have it is that when a actor gains a level or class level depending on the version used,
the ranges set, would give a random stat increase, like if the actor is a warrior his HP would increase randomly based on the
set number range shown above   say one level the actor gained 4 hp at level/class up, and the next gained 3 hp, then 6 hp upon the third level up
this way the player will never know how much stats would increase, much like those of the old SNES rpg days.


My Blog site I am working on: http://spoofus.weebly.com/

Jaiden

August 23, 2019, 10:32:42 am #6 Last Edit: August 23, 2019, 12:50:54 pm by Jaiden
Alright, took a crack at it. Range config is a little bit ugly, but it should do the job.

I can't test it, so let me know how it works out:

Regular
Spoiler: ShowHide

#==============================================================================
# Job-based Level Up Stats                                            Ver 1.0
# By KK20                                                             Dec 14 18
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each range in the
    # array indicates a random value in which the stat will increase per level up.
    #
    # When a single integer is used, it will select between 1 and the value selected
    # Otherwise, use a range. For example:
    # [2..5, 3, 5..7, 4, 8, 3..10]
    # On level up, they'll get between 2 and 5 HP points, 1 and 3 SP points...etc.
    #-------------------------------------------------------------------------
    #  MAX_HP   MAX_SP   STR      DEX      AGI      INT
    # [low..hi, low..hi, low..hi, low..hi, low..hi, low..hi]
    # If a low value is ommited, selects a value between
    when 1 # Fighter
      [2..7, 2, 3..5, 2..6, 3..8, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [5, 5, 5, 5, 5, 5]
    end
  end
end

class Game_Actor
  alias job_level_up_stats_level level=
  def level=(val)
    start_level = @level
    job_level_up_stats_level(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    level_difference.times {
        self.maxhp += stat_array[0].is_a?(Range) ? rand(stat_array[0]) : stat_array[0]
        self.maxsp += stat_array[1].is_a?(Range) ? rand(stat_array[1]) : stat_array[1]
        self.str   += stat_array[2].is_a?(Range) ? rand(stat_array[2]) : stat_array[2]
        self.dex   += stat_array[3].is_a?(Range) ? rand(stat_array[3]) : stat_array[3]
        self.agi   += stat_array[4].is_a?(Range) ? rand(stat_array[4]) : stat_array[4]
        self.int   += stat_array[5].is_a?(Range) ? rand(stat_array[5]) : stat_array[5]
    }
  end
 
  alias job_level_up_stats_exp exp=
  def exp=(val)
    start_level = @level
    job_level_up_stats_exp(val)
    level_difference = @level - start_level
   
    stat_array = JobLevelUp.level_up_stats(self.class_id)
    level_difference.times {
        self.maxhp += stat_array[0].is_a?(Range) ? rand(stat_array[0]) : stat_array[0]
        self.maxsp += stat_array[1].is_a?(Range) ? rand(stat_array[1]) : stat_array[1]
        self.str   += stat_array[2].is_a?(Range) ? rand(stat_array[2]) : stat_array[2]
        self.dex   += stat_array[3].is_a?(Range) ? rand(stat_array[3]) : stat_array[3]
        self.agi   += stat_array[4].is_a?(Range) ? rand(stat_array[4]) : stat_array[4]
        self.int   += stat_array[5].is_a?(Range) ? rand(stat_array[5]) : stat_array[5]
    }
  end
end


RO Edit
Spoiler: ShowHide

#==============================================================================
# Job-based Level Up Stats (RO Edit)                                    Ver 1.0
# By KK20                                                             Jul 10 19
#------------------------------------------------------------------------------
# Purpose:
#  Allows actors to gain bonus stats based on their class/job upon leveling up.
#  For example, a Warrior gains more STR and Max HP while Mages gain more INT
#  and Max MP.
#
# Instructions:
#  Place below default scripts but above Main (the usual). The lower the better.
#  Place below RO Job/Skill System.
#  Configure the stat bonuses below (instructions provided there).
#
#==============================================================================
module JobLevelUp
  def self.level_up_stats(id)
    case id
    #-------------------------------------------------------------------------
    # Configure:
    #
    #   when CLASS_ID
    #     [MAX_HP, MAX_SP, STR, DEX, AGI, INT]
    #
    # where CLASS_ID is the database index of the class and each range in the
    # array indicates a random value in which the stat will increase per level up.
    #
    # When a single integer is used, it will select between 1 and the value selected
    # Otherwise, use a range. For example:
    # [2..5, 3, 5..7, 4, 8, 3..10]
    # On level up, they'll get between 2 and 5 HP points, 1 and 3 SP points...etc.
    #-------------------------------------------------------------------------
    #  MAX_HP   MAX_SP   STR      DEX      AGI      INT
    # [low..hi, low..hi, low..hi, low..hi, low..hi, low..hi]
    # If a low value is ommited, selects a value between
    when 1 # Fighter
      [2..7, 2, 3..5, 2..6, 3..8, 2]
    when 2 # Lancer
      [8, 3, 4, 3, 2, 3]
    when 3 # Warrior
      [10, 1, 7, 1, 4, 1]
    when 4 # Thief
      [4, 3, 2, 6, 6, 4]
    else # Classes not defined will use this default value
      [5, 5, 5, 5, 5, 5]
    end
  end
end

class Game_Actor
  def level_up_stat_gain(levels, class_id)
    stat_array = JobLevelUp.level_up_stats(class_id)
    # Perform random selection per level gained
    levels.times {
        self.maxhp += stat_array[0].is_a?(Range) ? rand(stat_array[0]) : stat_array[0]
        self.maxsp += stat_array[1].is_a?(Range) ? rand(stat_array[1]) : stat_array[1]
        self.str   += stat_array[2].is_a?(Range) ? rand(stat_array[2]) : stat_array[2]
        self.dex   += stat_array[3].is_a?(Range) ? rand(stat_array[3]) : stat_array[3]
        self.agi   += stat_array[4].is_a?(Range) ? rand(stat_array[4]) : stat_array[4]
        self.int   += stat_array[5].is_a?(Range) ? rand(stat_array[5]) : stat_array[5]
    }
  end

  #----------------------------------------------------------------------------
  # job_level_change
  #  val  - new level value
  #  id   - class ID
  #  flag - determines whether EXP should be updated or not
  #  This method processes change of a job level.
  #----------------------------------------------------------------------------
  alias get_job_level_change_diff job_level_change
  def job_level_change(val, id = @class_id, flag = true)
    old_level = job_level(id)
    get_job_level_change_diff(val, id, flag)
    level_diff = job_level(id) - old_level
    level_up_stat_gain(level_diff, id)
  end

end




Spoofus



My Blog site I am working on: http://spoofus.weebly.com/

Jaiden

First, stick this in a blank script above the two I sent you:

Spoiler: ShowHide

alias old_rand rand
def rand(max = 0)
  if max.is_a?(Range)
    diff = max.last - max.first + (max.exclude_end? ? 0 : 1)
    old_rand(diff) + max.first
  else
    old_rand(max)
  end
end


And I've edited my original post, so update the scripts with those.