Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

CLASS STAT BONUSES

hey i hate to ask this but i been looking around for alnong time and i still have never found a character class stat bounus script.
like if a character base hp in the database
is 30hp and his current class is fighter and that the fighter class has a +20hp hp bonus so the character's hp would be 50hp instead of 30 so to say
and he changes his class to knight and that class will have a +30hp
so when the class is changed the hp will go to 60hp
i want this to work for all the stats of course
and i need it compatible with rockstar1986's change class script
he said he was gonna do something like this for his but he naver done it from what i can tell
 
thats ok...im just needing something like this for the project im working cause you pick your hero's class at game start and i dont want all class to have the same stats lol
 
I actually wrote this up as part of a plugin I made for Prexus' Job Changing/EXP script. I deleted everything that is not needed from the plugin so that you only have the stat altering portion. This script will alter a character's stats based on class by %s (ie being a knight will give you +20% HP) so your character's stat will be altered by the given percent. There are both stat bonuses and stat decreases, all based on percents. All of these stack, so you can give more than one bonus for the same stat if desired. Hopefully this helps.

Code:
 class Game_Actor < Game_Battler
  #-----------------------------------------------------------------------------
  # * Public Instance Variables
  #-----------------------------------------------------------------------------
  attr_reader   :name                     # name
  attr_reader   :character_name           # character graphic filename
  attr_reader   :character_index          # character graphic index
  attr_reader   :face_name                # face graphic filename
  attr_reader   :face_index               # face graphic index
  attr_reader   :class_id                 # class ID
  attr_reader   :weapon_id                # weapon ID
  attr_reader   :armor1_id                # shield ID
  attr_reader   :armor2_id                # helmet ID
  attr_reader   :armor3_id                # body armor ID
  attr_reader   :armor4_id                # accessory ID
  attr_reader   :level                    # level
  attr_reader   :exp                      # experience
  attr_accessor :last_skill_id            # for cursor memory: Skill
  attr_accessor :held_hp                  # Alter HP
  attr_accessor :held_mp                  # Alter MP
  attr_accessor :held_atk                 # Alter ATK
  attr_accessor :held_def                 # Alter DEF
  attr_accessor :held_spi                 # Alter SPI
  attr_accessor :held_agi                 # Alter AGI
  #-----------------------------------------------------------------------------
  # * Object Initialization
  #     actor_id : actor ID
  #-----------------------------------------------------------------------------
  def initialize(actor_id)
    super()
    setup(actor_id)
    @last_skill_id = 0
    define_stats
  end
 #-----------------------------------------------------------------------------
  # Defines Stats. This Method Is Called When Actors Are Initialized,
  # and Should be Run Just After an Actor's Class is Changed
  #--------------------------------------------------------------------------
  def define_stats
    define_hp
    define_mp
    define_attack
    define_defense
    define_spirit
    define_agility
  end
  #-----------------------------------------------------------------------------
  #*****************Do Not Change Anything Above This Block*********************
  #-----------------------------------------------------------------------------
  
  
  #-----------------------------------------------------------------------------
  # Defines HP Stat By Class. Proper Class Selection (By Class ID):
  # if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  # So if You Want Classes 1 and 3 to have a 5% HP Bonus the Line Would Read
  # "if @class_id == 1 or @class_id == 3"
  #-----------------------------------------------------------------------------
  def define_hp
    @held_hp = actor.parameters[0, @level]
    
    id = @class_id
    if @class_id == 0 # Classes With 5% HP Bonus. Change Only This Line!
      @held_hp = @held_hp*1.05
    else
      @held_hp = @held_hp
    end
    
    id = @class_id
    if @class_id == 0 # Classes With 10% HP Bonus. Change Only This Line!
      @held_hp = @held_hp*1.10
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% HP Bonus. Change Only This Line!
      @held_hp = @held_hp*1.15
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% HP Bonus. Change Only This Line!
      @held_hp = @held_hp*1.20
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% HP Loss. Change Only This Line!
      @held_hp = @held_hp*0.95
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% HP Loss. Change Only This Line!
      @held_hp = @held_hp*0.90
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% HP Loss. Change Only This Line!
      @held_hp = @held_hp*0.85
    else
      @held_hp = @held_hp
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% HP Loss. Change Only This Line!
      @held_hp = @held_hp*0.80
    else
      @held_hp = @held_hp
    end

    @held_hp = @held_hp.ceil
    self.maxhp=(@held_hp)
  end
  #-----------------------------------------------------------------------------
  # Defines MP Stat By Class. Proper Class Selection (By Class ID):
  #  if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  #-----------------------------------------------------------------------------
  def define_mp
    @held_mp = actor.parameters[1, @level]

    id = @class_id
    if @class_id == 0 # Classes With 5% MP Bonus. Change Only This Line!
      @held_mp = @held_mp*1.05
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% MP Bonus. Change Only This Line!
      @held_mp = @held_mp*1.10
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% MP Bonus. Change Only This Line!
      @held_mp = @held_mp*1.15
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% MP Bonus. Change Only This Line!
      @held_mp = @held_mp*1.20
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% MP Loss. Change Only This Line!
      @held_mp = @held_mp*0.95
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% MP Loss. Change Only This Line!
      @held_mp = @held_mp*0.90
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% MP Loss. Change Only This Line!
      @held_mp = @held_mp*0.85
    else
      @held_mp = @held_mp
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% MP Loss. Change Only This Line!
      @held_mp = @held_mp*0.80
    else
      @held_mp = @held_mp
    end

    @held_mp = @held_mp.ceil
    self.maxmp=(@held_mp)
  end
  #-----------------------------------------------------------------------------
  # Defines ATK Stat By Class. Proper Class Selection (By Class ID):
  # if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  #-----------------------------------------------------------------------------
  def define_attack
    @held_atk = actor.parameters[2, @level]

    id = @class_id
    if @class_id == 0 # Classes With 5% ATK Bonus. Change Only This Line!
      @held_atk = @held_atk*1.05
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% ATK Bonus. Change Only This Line!
      @held_atk = @held_atk*1.10
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% ATK Bonus. Change Only This Line!
      @held_atk = @held_atk*1.15
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% ATK Bonus. Change Only This Line!
      @held_atk = @held_atk*1.20
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% ATK Loss. Change Only This Line!
      @held_atk = @held_atk*0.95
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% ATK Loss. Change Only This Line!
      @held_atk = @held_atk*0.90
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% ATK Loss. Change Only This Line!
      @held_atk = @held_atk*0.85
    else
      @held_atk = @held_atk
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% ATK Loss. Change Only This Line!
      @held_atk = @held_atk*0.80
    else
      @held_atk = @held_atk
    end

    @held_atk = @held_atk.ceil
    self.atk=(@held_atk)
  end
  #-----------------------------------------------------------------------------
  # Defines DEF Stat By Class. Proper Class Selection (By Class ID):
  # if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  #-----------------------------------------------------------------------------
  def define_defense
    @held_def = actor.parameters[3, @level]
    
    id = @class_id
    if @class_id == 0 # Classes With 5% DEF Bonus. Change Only This Line!
      @held_def = @held_def*1.05
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% DEF Bonus. Change Only This Line!
      @held_def = @held_def*1.10
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% DEF Bonus. Change Only This Line!
      @held_def = @held_def*1.15
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% DEF Bonus. Change Only This Line!
      @held_def = @held_def*1.20
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% DEF Loss. Change Only This Line!
      @held_def = @held_def*0.95
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% DEF Loss. Change Only This Line!
      @held_def = @held_def*0.90
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% DEF Loss. Change Only This Line!
      @held_def = @held_def*0.85
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% DEF Loss. Change Only This Line!
      @held_def = @held_def*0.80
    else
      @held_def = @held_def
    end

    @held_def = @held_def.ceil
    self.definitely_defense=(@held_def)
  end
  #-----------------------------------------------------------------------------
  # Defines SPI Stat By Class. Proper Class Selection (By Class ID):
  # if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  #-----------------------------------------------------------------------------
  def define_spirit
    @held_spi = actor.parameters[4, @level]

    id = @class_id
    if @class_id == 0 # Classes With 5% SPI Bonus. Change Only This Line!
      @held_spi = @held_spi*1.05
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% SPI Bonus. Change Only This Line!
      @held_spi = @held_spi*1.10
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% SPI Bonus. Change Only This Line!
      @held_spi = @held_spi*1.15
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% SPI Bonus. Change Only This Line!
      @held_spi = @held_spi*1.20
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% SPI Loss. Change Only This Line!
      @held_spi = @held_spi*0.95
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% SPI Loss. Change Only This Line!
      @held_spi = @held_spi*0.90
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% SPI Loss. Change Only This Line!
      @held_spi = @held_spi*0.85
    else
      @held_spi = @held_spi
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% SPI Loss. Change Only This Line!
      @held_spi = @held_spi*0.80
    else
      @held_spi = @held_spi
    end

    @held_spi = @held_spi.ceil
    self.spi=(@held_spi)
  end
  #-----------------------------------------------------------------------------
  # Defines AGI Stat By Class. Proper Class Selection (By Class ID):
  # if @class_id == 1 or @class_id == 3 or @class_id == etc. etc.
  #-----------------------------------------------------------------------------
  def define_agility
    @held_agi = actor.parameters[5, @level]

    id = @class_id
    if @class_id == 0 # Classes With 5% AGI Bonus. Change Only This Line!
      @held_agi = @held_agi*1.05
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% AGI Bonus. Change Only This Line!
      @held_agi = @held_agi*1.10
    else
      @held_agi = @held_agi
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% AGI Bonus. Change Only This Line!
      @held_agi = @held_agi*1.15
    else
      @held_agi = @held_agi
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% AGI Bonus. Change Only This Line!
      @held_agi = @held_agi*1.20
    else
      @held_def = @held_def
    end

    id = @class_id
    if @class_id == 0 # Classes With 5% AGI Loss. Change Only This Line!
      @held_agi = @held_agi*0.95
    else
      @held_agi = @held_agi
    end

    id = @class_id
    if @class_id == 0 # Classes With 10% AGI Loss. Change Only This Line!
      @held_agi = @held_agi*0.90
    else
      @held_agi = @held_agi
    end

    id = @class_id
    if @class_id == 0 # Classes With 15% AGI Loss. Change Only This Line!
      @held_agi = @held_agi*0.85
    else
      @held_agi = @held_agi
    end

    id = @class_id
    if @class_id == 0 # Classes With 20% AGI Loss. Change Only This Line!
      @held_agi = @held_agi*0.80
    else
      @held_agi = @held_agi
    end

    @held_agi = @held_agi.ceil
    self.agi=(@held_agi)
  end
end

#-------------------------------------------------------------------------------
#******************Do Not Change Anything Below This Block**********************
#-------------------------------------------------------------------------------
class Game_Actor < Game_Battler
  #-----------------------------------------------------------------------------
  # I was Receiving Errors When Using the def=(new_def) Method So I Have 
  # Created a New Method Which Does the Same Thing.
  #-----------------------------------------------------------------------------
  # * Set Defense
  #     new_def : new defense
  #-----------------------------------------------------------------------------
  def definitely_defense=(new_def)
    @def_plus += new_def - self.def
    @def_plus = [[@def_plus, -999].max, 999].min
  end

  #-----------------------------------------------------------------------------
  # Because Stats Are Determined By Level, We Need to Call The Method
  # define_stats Whenever There is A Level Change.
  #-----------------------------------------------------------------------------
  
  #-----------------------------------------------------------------------------
  # * Level Up (As Taken From Prexus' Script)
  #-----------------------------------------------------------------------------
   def level_up
    @level += 1
    define_stats # This is Where We Will Call Our Method
  end
  #-----------------------------------------------------------------------------
  # * Level Down
  #-----------------------------------------------------------------------------
  def level_down
    @level -= 1
    define_stats # This is Where We Will Call Our Method
  end
  #-----------------------------------------------------------------------------
  # * Change Level
  #     level : new level
  #     show  : Level up display flag
  #-----------------------------------------------------------------------------
  def change_level(level, show)
    level = [[level, 99].min, 1].max
    change_exp(@exp_list[level], show)
    define_stats # This is Where We Will Call Our Method
  end
  #-----------------------------------------------------------------------------
end

If you have any problems with this, PMing me would probably be the best method to contact me.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top