Author Topic: RESOLVED Stat gain based on Class.  (Read 519 times)

Offline Spoofus

  • CP's Lovable Turtle
  • Astral Trancist
  • *****
  • Posts: 818
  • LV: 19
  • Gender: Male
    • View Profile
RESOLVED Stat gain based on Class.
« on: December 14, 2018, 02:01:33 AM »
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.
« Last Edit: May 10, 2019, 04:31:29 PM by Spoofus »


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

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3206
  • LV: 386
  • Gender: Male
  • Choco Octo <3
    • View Profile
Re: Stat gain based on Class.
« Reply #1 on: December 15, 2018, 04:41:41 AM »
A very simple version:
Code: [Select]
#==============================================================================
# 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 AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


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

Join the CP Discord Server!

Offline KK20

  • Master Scripter Fixer
  • Global Moderator
  • Guardian of Chaos
  • ****
  • Posts: 3206
  • LV: 386
  • Gender: Male
  • Choco Octo <3
    • View Profile
Re: RESOLVED Stat gain based on Class.
« Reply #2 on: July 11, 2019, 07:01:59 AM »
Quote from: Spoofus
Would 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
Code: [Select]
#==============================================================================
# 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
« Last Edit: July 12, 2019, 10:05:37 AM by KK20 »



Other Projects
RPG Maker XP AceUpgrade RMXP to RMVXA performance!
XPA TilemapTilemap rewrite with many features, including custom resolution!


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

Join the CP Discord Server!