Stats Baseado Em Classes No RPG Maker XP

24 de julho de 2012

Class Based Stats é um script desenvolvido pelo SephirothSpawn que permite, em um projeto do RPG Maker XP, dar boost nos actor stats baseados em sua classe.

Ele permite que você personalize o valor de cada nível para cada stat através do início, final e inflation values. Se você quiser, você pode definir os actor stats no banco de dados para 0 e usar estas configurações, ao invés.

Instruções

Atenção: este script precisa do Trickster’s Curve Calculator Module, e do SDK.

Copie e cole o código do script abaixo do SDK e acima do Main. Para personalizar os stats das classes, dê uma lida nas instruções de customização “Customization“, comentadas no código.

É aconselhavel adicionar este script acima de quaisquer outros que dão bonus para actor stats, a não ser que você queira que estes sejam aplicados antes.

#==============================================================================
# ** Class Based Stats
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 1
# 2006-08-27
#------------------------------------------------------------------------------
# * Requirements :
#
#   Trickster's Curve Calculator Module
#------------------------------------------------------------------------------
# * Description :
#
#   This script was designed to give actors stat boost based off their class.
#   It allows you to customize each level's value for each stat through
#   starting, finishing and inflation values. If you wanted, you could set the
#   actors stats in the database to 0 and use these settings instead.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Customize your clas stats, refer to the customization instructions.
#
#   ** NOTE : It is advised to put this script above any scripts that give
#   bonuses to actor stat, unless you want these to be aplied after
#   those bonuses take place.
#------------------------------------------------------------------------------
# * Customization :
#
#   Setting Lowest & Highest Levels
#    - Lowest_Level = X
#    - Highest_Level = Y
#
#   Setting Default Value at Lowest & Highest Level
#    - Default_Min_Max = [x_value, y_value]
#
#   Setting Default Early & Late Inflation Values
#    - Default_Inflation = [early_inflation, late_inflation]
#
#   Setting Defined Min & Max Values For Specific Stats & Classes
#    - Automatic_Stats_Min_Max = {
#        'stat_name' => {
#          class_id => [min, max], ...
#        },
#        ...
#      }
#
#   Setting Defined Early & Late Inflation Values For Specific Stats & Class
#    - Automatic_Stats_Inflation_Early_Late = {
#        'stat_name' => {
#          class_id => [early, late], ...
#        },
#        ...
#      }
#
#   Setting Defined Table of Stats For Specific Stats & Classes
#    - Preset_Stats = {
#        'stat_name' => {
#          class_id => [level_1, level_2, level_3, ..., level_max], ...
#        },
#        ...
#      }
#------------------------------------------------------------------------------
# * Syntax :
#
#   Retrieving Class Bonuses at specific level
#    - <data_class>.base_<stat_name>_bonus(<level>)
#
#   Stat Name Modifers
#   'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int', 'atk', 'pdef', 'mdef', 'eva'
#------------------------------------------------------------------------------
# * Credits :
#
#   Thanks to Trickster For His Curve Generator
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Class Based Stats', 'SephirothSpawn', 1, '2006-08-27')

#------------------------------------------------------------------------------
# * Curve Generator Test
#------------------------------------------------------------------------------
unless SDK.state('Curve Generator')
  # Print Error
  p 'Curve Generator Module Not Found. Class Based Stats Disabled.'
  # Disable Encounter Control
  SDK.disable('Class Based Stats')
end

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Class Based Stats')

#==============================================================================
# ** Class_Based_Stats
#==============================================================================

module Class_Based_Stats
  #--------------------------------------------------------------------------
  # * Saved Class Curves
  #
  #  ~ Cache = { class_id => { stat_name => [<stats>], ... }, ... }
  #--------------------------------------------------------------------------
  @cache = {}
  #--------------------------------------------------------------------------
  # ** Automatic Stats 
  #
  #   Stats Will Be Calculated From 4 Values : Lowest Level Value, Highest
  # Level Value, Early Inflation & Late Inflation
  #
  # * Min Max Values (Bases at lowest and highest level)
  #  ~ 'stat_name' => {class_id => [min_stat, max_stat], ...}
  #
  # * Inflation Values (Early & Late Inflation Curves)
  #  ~ 'stat_name' => {class_id => [early_inflation, late_inflation], ...}
  #
  # ** NOTE: Use 0 as class id for all classes. If no 0 is found, will rely
  #    on Default_Min_Max or Default_Inflation
  #--------------------------------------------------------------------------
  Lowest_Level = 1
  Highest_Level = 99
  Default_Min_Max = [0, 0]
  Default_Inflation = [1, 1]
  #--------------------------------------------------------------------------
  Automatic_Stats_Min_Max = {
    'maxhp' => {},
    'maxsp' => {},
    'str' => {},
    'dex' => {},
    'agi' => {},
    'int' => {},
    'atk' => {},
    'mdef' => {},
    'pdef' => {},
    'eva' => {}
  }
  #--------------------------------------------------------------------------
  Automatic_Stats_Inflation_Early_Late = {
    'maxhp' => {},
    'maxsp' => {},
    'str' => {},
    'dex' => {},
    'agi' => {},
    'int' => {},
    'atk' => {},
    'mdef' => {},
    'pdef' => {},
    'eva' => {}
  }
  #--------------------------------------------------------------------------
  # ** Preset Values
  #
  #   Base Stats Will Be Calculated of a preset table you set up. Table will
  # be the size of the characters level range (highest_level).
  #
  # * Preset_Stats
  #  ~ 'stat_name' => [class_id => [level_1, level_2, ..., level_max], ...]
  #--------------------------------------------------------------------------
  Preset_Stats = {
    'maxhp' => {},
    'maxsp' => {},
    'str' => {},
    'dex' => {},
    'agi' => {},
    'int' => {},
    'atk' => {},
    'mdef' => {},
    'pdef' => {},
    'eva' => {}
  }
  #--------------------------------------------------------------------------
  # * Get Base Stat
  #--------------------------------------------------------------------------
  def self.get_base_stat(class_id, stat_name, level)
    # If No Class ID Curve Saved
    unless @cache.has_key?(class_id)
      # Saves Blank Array of Stat Names
      @cache[class_id] = {}
    end
    # If Stat Name Not Saved
    unless @cache[class_id].has_key?(stat_name)
      # If Preset Stat Set
      if Preset_Stats[stat_name].has_key?(class_id)
        @cache[class_id][stat_name] = Preset_Stats[stat_name][class_id]
      # Generate Curve
      else
        min_max = self.get_min_max(class_id, stat_name)
        early_late = self.get_early_late(class_id, stat_name)
        # Retrieves Curve From Curve Generator
        @cache[class_id][stat_name] = Curve_Calculator.generate_curve(
          Lowest_Level, Highest_Level, min_max[0], min_max[1],
          early_late[0], early_late[1])
      end
    end
    # Returns Stat
    return @cache[class_id][stat_name][level]
  end
  #--------------------------------------------------------------------------
  # * Get Min & Max
  #--------------------------------------------------------------------------
  def self.get_min_max(class_id, stat_name)
    if Automatic_Stats_Min_Max[stat_name].has_key?(class_id)
      return Automatic_Stats_Min_Max[stat_name][class_id]
    elsif Automatic_Stats_Min_Max[stat_name].has_key?(0)
      return Automatic_Stats_Min_Max[stat_name][0]
    end
    return Default_Min_Max
  end
  #--------------------------------------------------------------------------
  # * Get Early & Late Inflation
  #--------------------------------------------------------------------------
  def self.get_early_late(class_id, stat_name)
    if Automatic_Stats_Inflation_Early_Late[stat_name].has_key?(class_id)
      return Automatic_Stats_Inflation_Early_Late[stat_name][class_id]
    elsif Automatic_Stats_Inflation_Early_Late[stat_name].has_key?(0)
      return Automatic_Stats_Inflation_Early_Late[stat_name][0]
    end
    return Default_Inflation
  end
end

#==============================================================================
# ** RPG::Class
#==============================================================================

class RPG::Class
  #--------------------------------------------------------------------------
  # * Base Maxhp Bonus
  #--------------------------------------------------------------------------
  def base_maxhp_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'maxhp', level)
  end
  #--------------------------------------------------------------------------
  # * Base Maxsp Bonus
  #--------------------------------------------------------------------------
  def base_maxsp_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'maxsp', level)
  end
  #--------------------------------------------------------------------------
  # * Base Str Bonus
  #--------------------------------------------------------------------------
  def base_str_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'str', level)
  end
  #--------------------------------------------------------------------------
  # * Base Dex Bonus
  #--------------------------------------------------------------------------
  def base_dex_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'dex', level)
  end
  #--------------------------------------------------------------------------
  # * Base Agi Bonus
  #--------------------------------------------------------------------------
  def base_agi_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'agi', level)
  end
  #--------------------------------------------------------------------------
  # * Base Int Bonus
  #--------------------------------------------------------------------------
  def base_int_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'int', level)
  end
  #--------------------------------------------------------------------------
  # * Base Atk Bonus
  #--------------------------------------------------------------------------
  def base_atk_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'atk', level)
  end
  #--------------------------------------------------------------------------
  # * Base Mdef Bonus
  #--------------------------------------------------------------------------
  def base_mdef_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'mdef', level)
  end
  #--------------------------------------------------------------------------
  # * Base Pdef Bonus
  #--------------------------------------------------------------------------
  def base_pdef_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'pdef', level)
  end
  #--------------------------------------------------------------------------
  # * Base Eva Bonus
  #--------------------------------------------------------------------------
  def base_eva_bonus(level = 1)
    return Class_Based_Stats.get_base_stat(@id, 'eva', level)
  end
end

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

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_classbasestat_gmactr_bmaxhp base_maxhp
  alias seph_classbasestat_gmactr_bmaxsp base_maxsp
  alias seph_classbasestat_gmactr_bpdef  base_pdef
  alias seph_classbasestat_gmactr_bmdef  base_mdef
  alias seph_classbasestat_gmactr_bstr   base_str
  alias seph_classbasestat_gmactr_bdex   base_dex
  alias seph_classbasestat_gmactr_bagi   base_agi
  alias seph_classbasestat_gmactr_bint   base_int
  alias seph_classbasestat_gmactr_batk   base_atk
  alias seph_classbasestat_gmactr_beva   base_eva
  #--------------------------------------------------------------------------
  # * Base Maxhp
  #--------------------------------------------------------------------------
  def base_maxhp
    n = seph_classbasestat_gmactr_bmaxhp
    return n + $data_classes[@class_id].base_maxhp_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Maxsp
  #--------------------------------------------------------------------------
  def base_maxsp
    n = seph_classbasestat_gmactr_bmaxsp
    return n + $data_classes[@class_id].base_maxsp_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Str
  #--------------------------------------------------------------------------
  def base_str
    n = seph_classbasestat_gmactr_bstr
    return n + $data_classes[@class_id].base_str_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Dex
  #--------------------------------------------------------------------------
  def base_dex
    n = seph_classbasestat_gmactr_bdex
    return n + $data_classes[@class_id].base_dex_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Agi
  #--------------------------------------------------------------------------
  def base_agi
    n = seph_classbasestat_gmactr_bagi
    return n + $data_classes[@class_id].base_agi_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Int
  #--------------------------------------------------------------------------
  def base_int
    n = seph_classbasestat_gmactr_bint
    return n + $data_classes[@class_id].base_int_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Atk
  #--------------------------------------------------------------------------
  def base_atk
    n = seph_classbasestat_gmactr_batk
    return n + $data_classes[@class_id].base_atk_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base PDef
  #--------------------------------------------------------------------------
  def base_pdef
    n = seph_classbasestat_gmactr_bpdef
    return n + $data_classes[@class_id].base_pdef_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base MDef
  #--------------------------------------------------------------------------
  def base_mdef
    n = seph_classbasestat_gmactr_bmdef
    return n + $data_classes[@class_id].base_mdef_bonus(@level)
  end
  #--------------------------------------------------------------------------
  # * Base Eva
  #--------------------------------------------------------------------------
  def base_eva
    n = seph_classbasestat_gmactr_beva
    return n + $data_classes[@class_id].base_eva_bonus(@level)
  end
end

#------------------------------------------------------------------------------
# * End SDK Enable Test
#------------------------------------------------------------------------------
end

Deixe um comentário

  • Inscreva-se na nossa newsletter!

  • Nos siga nas redes sociais!

  • Páginas

  • Áreas especiais

  • eXTReMe Tracker
    Copyright © 2001 - 2019 Gaming Room. Todos os Direitos Reservados - É expressamente proibida a reprodução total ou parcial deste site sem o consentimento dos autores.