Raising ATK stat when character levels up.

citruskoala

Villager
Member
Joined
Jan 3, 2019
Messages
14
Reaction score
1
First Language
English
Primarily Uses
RMXP
Hi, i'm a total newbie to all this RPG Maker stuff, and I was wondering if I can raise my characters unarmed atk stat, NOT my strength stat, that would add on to the atk stat of the characters weapon equipped, when my character levels up.
 
Last edited:

kovak

Silverguard
Veteran
Joined
Apr 3, 2016
Messages
1,263
Reaction score
1,565
First Language
PT - EN
Primarily Uses
RMMV
You'd need a plugin for that feature.
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
TWO actually, both from 2006.... The one by Trickster is a mathematical curve generator. The other by SephirothSpawn takes the curve generator and allows you to use it to generate stat values.

They were written to *cough* require the RMXP SDK, but Seph almost never wrote anything that blatantly needed the SDK, and Trickster's script is actually a math module. Both have been un-SDKed for a bit more easy of use.

First:
Code:
#==============================================================================
# ** Trickster's Curve Generator
#------------------------------------------------------------------------------
# Trickster
# Version 2
# 2006-10-22
#------------------------------------------------------------------------------
# * Version History :
#
#   Version 1 ---------------------------------------------------- (2006-07-28)
#   Version 2 ---------------------------------------------------- (2006-10-22)
#    - Update : Updated Formulas
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to generate a curve of numbers given certain
#   values : min level, max level, min value (at min level), max value (at
#   max level), early inflation & late inflation. The curve will be
#   returned as an array of values.
#
#   ** Update to 2.0 : Updated Formulas To Fix Bugs
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#
#   Generating Curve :
#
#    - curve = Curve_Calculator.generate_curve(min_level, max_level, min_value,
#                max_value, early_inflation, late_inflation)
#
#   NOTE : Will not generate negative curves because it returns values as an
#          array.
#==============================================================================



#==============================================================================
# ** Curve_Calculator
#==============================================================================

module Curve_Calculator
  #--------------------------------------------------------------------------
  # * Generate Curve
  #--------------------------------------------------------------------------
  def self.generate_curve(min_level, max_level, min_value, max_value,
                          early = 1.0, late = 1.0)
    # Creates Curve Array
    curve = []
    # Passes To Max Level
    for i in 0..max_level
      # Assigns Value
      curve[i] = self.calculate_value(i, min_level.to_f, max_level.to_f,
                            min_value.to_f, max_value.to_f, early, late.to_f)
    end
    # Returns Curve
    return curve
  end
  #--------------------------------------------------------------------------
  # * Late Curve
  #--------------------------------------------------------------------------
  def self.late_curve(level, min_level, max_level, min, max)
    diff = min_level - max_level
    stat = min - max
    num = stat * level ** 2 - 2 * min_level * stat * level + min_level ** 2 *
          max - 2 * min_level * max_level * min + min * min_level ** 2
    denom = diff ** 2
    return num / denom
  end
  #--------------------------------------------------------------------------
  # * Early Curve
  #--------------------------------------------------------------------------
  def self.early_curve(level, min_level, max_level, min, max)
    diff = max_level - min_level
    stat = max - @min
    num = -stat * level ** 2 + 2 * max_level * stat * level + min_level **
          2 * max - 2 * min_level * max_level * max + min * max_level ** 2
    denom = diff ** 2
    return num / denom  
  end
  #--------------------------------------------------------------------------
  # * Steady Curve
  #--------------------------------------------------------------------------
  def self.steady_curve(level, min_level, max_level, min, max)
    ch_level = max_level - min_level
    ch_stat = max - min
    base = ch_stat / ch_level * level
    mod = max * min_level - min * max_level
    base2 = mod / ch_level
    return base - base2
  end
  #--------------------------------------------------------------------------
  # * Calculate Value
  #--------------------------------------------------------------------------
  def self.calculate_value(level, min_level, max_level, min, max,
                           early, late)
    return min if level < min_level
    return max if max_level < level
    if early == late
      stat = self.steady_curve(level, min_level, max_level, min, max)
    else
      early_ = self.early_curve(level, min_level, max_level, min, max)
      late_ = self.late_curve(level, min_level, max_level, min, max)
      stat = (early * early_ + late * late_) / (early + late)
    end
    stat = Integer([[stat, min].max, max].min)
    return stat
  end
end
Next:
Code:
#==============================================================================
# ** Unarmed Stats & Development
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-10-22
#------------------------------------------------------------------------------
# * Requirements :
#
#   Trickster's Curve Calculator Module (Dynamic Stat Development)
#------------------------------------------------------------------------------
# * Description
#
#   This script was designed to do allow you to develope actors atk, mdef,
#   pdef and eva in a varitey of ways. A, you can set unarmed growth of your
#   stats, that progresses as your character does, same as other stats. B,
#   you can define unarmed and armed growth of your stats, that will happen
#   with or without equipment. C, you now have access to boost atk, pdef,
#   mdef and eva through script calls. These bonuses will be added after the
#   unarmed / armed grows have been added. As a bonus, this script also grants
#   access to the default stat bonuses, such as maxp, maxsp, str, etc.
#------------------------------------------------------------------------------
# * Instructions
#
#   Place The Script Below the SDK and Above Main.
#   To Customize your stat growths, refer to the customization instructions.
#   To modify actor's stats with call scripts, refer to syntax.
#------------------------------------------------------------------------------
# * Customization
#
#
#   ** Unarmed Stat Growth **
#
#   Stat Growth Type (0 : Basic Slope Formula, 1 : Curve Generated Formula)
#    - Unarmed_Stat_Growth_Type = n
#
#   Stat Growth Setup
#    - Unarmed_Stat_Values = {'stat_name' => {actor_id => <values>, ...}, ...}
#
#    Replace Values With :
#     Type 0 : [base_value, growth_value]
#     Type 1 : [min_value, max_value, early, late]
#
#   ** Normal Stat Growth **
#
#   Stat Growth Type (0 : Basic Slope Formula, 1 : Curve Generated Formula)
#    - Normal_Stat_Growth_Type = n
#
#   Stat Growth Setup
#    - Normal_Stat_Values = {'stat_name' => {actor_id => <values>, ...}, ...}
#
#    Replace Values With :
#     Type 0 : [base_value, growth_value]
#     Type 1 : [min_value, max_value, early, late]
#
#------------------------------------------------------------------------------
# * Syntax :
#
#   Altering Actor's Stat Plus Bonus
#    - actor = $game_actors[<actor_id>]
#      - or -
#      actor = $game_party.actors[index]
#
#      actor.<keyword> <operator> <numberic>
#
#    Replace <keyword> with :
#     - maxhp_plus to change maxhp bonus
#     - maxsp_plus to change maxsp bonus
#     - pdef_plus  to change pdef  bonus
#     - mdef_plus  to change mdef  bonus
#     - str_plus   to change str   bonus
#     - dex_plus   to change dex   bonus
#     - agi_plus   to change agi   bonus
#     - int_plus   to change int   bonus
#     - atk_plus   to change atk   bonus
#     - eva_plus   to change eva   bonus
#
#    Replace <operator> with :
#     - += to add to bonus
#     - -= to subtract bonus
#     - /= to divide bonus
#     - *= to multiple bonus
#     - = to set bonus
#
#    Replace <numberic> with a number
#------------------------------------------------------------------------------
# * Credits :
#
#   Thanks to Trickster For His Curve Generator
#==============================================================================

 
#==============================================================================
# ** Unarmed_Stats
#==============================================================================
 
module Unarmed_Stats
 
  #--------------------------------------------------------------------------
  # * Formulas
  #
  #  ~ Type 0 : Basic Slope Formula
  #      Formula : stat = base_value + growth_value * level
  #
  #  ~ Type 1 : Stat Curve
  #      Formula : See Trickster's Curve Generator
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Unarmed Stat Growth Type
  #
  #  ~ 0 : Basic Slope Formula , 1 : Stat Curve
  #--------------------------------------------------------------------------
  Unarmed_Stat_Growth_Type = 0
  #--------------------------------------------------------------------------
  # * Unarmed Stat Growth
  #
  #  ~ Basic Setup
  #   Unarmed_Stat_Values = {
  #     'stat_name' => {
  #       actor_id => <values>,
  #       ...
  #     },
  #     ...
  #   }
  #
  #  ~ Replace <values> With :
  #     Type 0 : [base_value, growth_value]
  #     Type 1 : [min_value, max_value, early, late]
  #
  #   Use 0 as actor id to act for all actors, unless specified
  #--------------------------------------------------------------------------
  Unarmed_Stat_Values = {
    'atk'  => {1 => [0,1]},
    'pdef' => {},
    'mdef' => {},
    'eva'  => {}
  }
  #--------------------------------------------------------------------------
  # * Normal Stat Growth Type
  #
  #  ~ 0 : Basic Slope Formula , 1 : Stat Curve
  #--------------------------------------------------------------------------
  Normal_Stat_Growth_Type = 0
  #--------------------------------------------------------------------------
  # * Normal Stat Growth
  #
  #  ~ Basic Formula
  #   Normal_Stat_Values = {
  #     'stat_name' => {
  #       actor_id => <values>,
  #       ...
  #     },
  #     ...
  #   }
  #
  #  ~ Replace <values> With :
  #     Type 0 : [base_value, growth_value]
  #     Type 1 : [min_value, max_value, early, late]
  #
  #   Use 0 as actor id to act for all actors, unless specified
  #--------------------------------------------------------------------------
  Normal_Stat_Values = {
    'atk'  => {},
    'pdef' => {},
    'mdef' => {},
    'eva'  => {}
  }
  #--------------------------------------------------------------------------
  # * Generate Slope Curve
  #--------------------------------------------------------------------------
  def self.generate_slope_curve(stat_name, actor_id, type, con)
    # Gets Values
    # If Actor ID Specified
    if con[stat_name].has_key?(actor_id)
      values = con[stat_name][actor_id]
    # If Default 0 Specified
    elsif con[stat_name].has_key?(0)
      values = con[stat_name][0]
    # None Specified
    else
      # Return Blank Array
      return Array.new(100, 0)
    end
    # If Slope Formula
    if type == 0
      # Creates Array of Stats
      curve = [values[0]]
      99.times { curve << (values[1] + curve.last) }
      # Return Curve
      return curve
    # If Stat Curve
    elsif type == 1
      # Return Curve Generated Stats
      return Curve_Calculator.generate_curve(0, 99, values[0],
                                             values[1], values[2], values[3])
    end
    # Return Blank Array
    return Array.new(100, 0)
  end
  #--------------------------------------------------------------------------
  # * Generate Unarmed Slope Curve
  #--------------------------------------------------------------------------
  def self.generate_unarmed_slope_curve(stat_name, actor_id)
    # Return Slope Curve
    return self.generate_slope_curve(stat_name, actor_id,
      Unarmed_Stat_Growth_Type, Unarmed_Stat_Values)
  end
  #--------------------------------------------------------------------------
  # * Generate Normal Slope Curve
  #--------------------------------------------------------------------------
  def self.generate_normal_slope_curve(stat_name, actor_id)
    # Return Slope Curve
    return self.generate_slope_curve(stat_name, actor_id,
      Normal_Stat_Growth_Type, Normal_Stat_Values)
  end
end

#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :maxhp_plus, :maxsp_plus, :str_plus, :dex_plus, :atk_plus
  attr_accessor :pdef_plus,  :mdef_plus,  :agi_plus, :int_plus, :eva_plus
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_unarmedstats_gmactr_setup  setup
  alias seph_unarmedstats_gmactr_bpdef  base_pdef
  alias seph_unarmedstats_gmactr_bmdef  base_mdef
  alias seph_unarmedstats_gmactr_batk   base_atk
  alias seph_unarmedstats_gmactr_beva   base_eva
  #--------------------------------------------------------------------------
  # * Setup
  #--------------------------------------------------------------------------
  def setup(actor_id)
    # Original Setup
    seph_unarmedstats_gmactr_setup(actor_id)
    # Basic Stat Plus Additions
    @atk_plus, @pdef_plus, @mdef_plus, @eva_plus = 0, 0, 0, 0
    # Sets Up Unarmed Stat Curves
    @unarmed_stats_atk = Unarmed_Stats.generate_unarmed_slope_curve('atk',
      @actor_id)
    @unarmed_stats_pdef = Unarmed_Stats.generate_unarmed_slope_curve('pdef',
      @actor_id)
    @unarmed_stats_mdef = Unarmed_Stats.generate_unarmed_slope_curve('mdef',
      @actor_id)
    @unarmed_stats_eva = Unarmed_Stats.generate_unarmed_slope_curve('eva',
      @actor_id)
    # Sets Up Normal Stat Curves
    @normal_stats_atk = Unarmed_Stats.generate_normal_slope_curve('atk',
      @actor_id)
    @normal_stats_pdef = Unarmed_Stats.generate_normal_slope_curve('pdef',
      @actor_id)
    @normal_stats_mdef = Unarmed_Stats.generate_normal_slope_curve('mdef',
      @actor_id)
    @normal_stats_eva = Unarmed_Stats.generate_normal_slope_curve('eva',
      @actor_id)
  end
  #--------------------------------------------------------------------------
  # * Atk
  #--------------------------------------------------------------------------
  def base_atk
    # Gets Original Value
    n = seph_unarmedstats_gmactr_batk
    # If Unarmed
    if @weapon_id == 0
      # Add Unarmed Value
      n += @unarmed_stats_atk[@level]
    end
    # Adds Normal Value
    n += @normal_stats_atk[@level]
    # Adds Atk Plus Bonus
    n += @atk_plus
    # Returns Value
    return n
  end
  #--------------------------------------------------------------------------
  # * Pdef
  #--------------------------------------------------------------------------
  def base_pdef
    # Gets Original Value
    n = seph_unarmedstats_gmactr_bpdef
    # If Unarmed
    if @armor1_id == 0 && @armor2_id == 0 && @armor3_id == 0 &&
       @armor4_id == 0 && @weapon_id == 0
      # Add Unarmed Value
      n += @unarmed_stats_pdef[@level]
    end
    # Adds Normal Value
    n += @normal_stats_pdef[@level]
    # Adds Pdef Plus Bonus
    n += @pdef_plus
    # Returns Value
    return n
  end
  #--------------------------------------------------------------------------
  # * Mdef
  #--------------------------------------------------------------------------
  def base_mdef
    # Gets Original Value
    n = seph_unarmedstats_gmactr_bmdef
    # If Unarmed
    if @armor1_id == 0 && @armor2_id == 0 && @armor3_id == 0 &&
       @armor4_id == 0 && @weapon_id == 0
      # Add Unarmed Value
      n += @unarmed_stats_mdef[@level]
    end
    # Adds Normal Value
    n += @normal_stats_mdef[@level]
    # Adds Mdef Plus Bonus
    n += @mdef_plus
    # Returns Value
    return n
  end
  #--------------------------------------------------------------------------
  # * Eva
  #--------------------------------------------------------------------------
  def base_eva
    # Gets Original Value
    n = seph_unarmedstats_gmactr_beva
    # If Unarmed
    if @armor1_id == 0 && @armor2_id == 0 && @armor3_id == 0 &&
       @armor4_id == 0
      # Add Unarmed Value
      n += @unarmed_stats_eva[@level]
    end
    # Adds Normal Value
    n += @normal_stats_eva[@level]
    # Adds Eva Plus Bonus
    n += @eva_plus
    # Returns Value
    return n
  end
end
I did a minor little tweak, just setting up Aluxes (actor 1) to have an ATK score start with 0 points, but gains 1 per level.... starting at level 1. So unarmed, he has 1 point unarmed, level 2 will be 2 points. This is according to Flat-Rate progression. It can be set for curved rates like the Strength and Dexterity stats too.

After pasting into your project, don't touch Trickster's Curve Generator. It does the whole curve generating for you. It's Seph's script around line 133 is where I made the edit to the ATK score for Aluxes. Please study it and run tests to see how you like it. As you might have gathered, you can do both flat rate gains as well as curved gains. It just depends on how you enter the data for your actor(s).
 

citruskoala

Villager
Member
Joined
Jan 3, 2019
Messages
14
Reaction score
1
First Language
English
Primarily Uses
RMXP
thanks
 
Last edited:

citruskoala

Villager
Member
Joined
Jan 3, 2019
Messages
14
Reaction score
1
First Language
English
Primarily Uses
RMXP
Do you know of any ways to make that unarmed attack stat add on to the attack stat my weapon gives my character?
 

DerVVulfman

Resident Werewolf
Veteran
Joined
Jun 26, 2012
Messages
315
Reaction score
155
First Language
English
Primarily Uses
RMXP
Not sure why Seph has so much extra within his 'base_atk' code in the Game_Actor class, but if you find this:
Code:
    if @weapon_id == 0
      # Add Unarmed Value
      n += @unarmed_stats_atk[@level]
    end
And just turn it into this:
Code:
      # Add Unarmed Value
      n += @unarmed_stats_atk[@level]
Then the hero's stats are raised by both an atk stat calculated with or without the weapon, and whatever weapon is used... if any.

And I would guess the same would go to the other methods that follow in Seph's script.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,062
Members
137,575
Latest member
akekaphol101
Top