Actor Bonuses

24 de julho de 2011

Um script que foi desenvolvido por SephirothSpawn em 2006, para permitir que seus personagens ganhem bônus adicionais para as suas estatísticas e ranks elemental/state. Ele permite que você obtenha bônus baseados em: id de ator, id de classe, equipamentos ou habilidades (passivas). Você pode controlar o bônus para serem ganhos diretos ou porcentagens (exceto modificações de ranks de elemento e estado). Se um ganho direto e porcentagem existirem, o ganho direto será realizado primeiro, e depois múltiplicado pelo cento.

Para o script funcionar, coloque-o embaixo do SDK e em cima do Main. Para customizar seus bônus, dê uma olhada nas instruções de customização.

#==============================================================================
# ** Actor Bonuses
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 2
# 2006-09-20
#------------------------------------------------------------------------------
# * Description :
#
#   This Script was designed to allow your characters to gain additional
#   bonuses to their stats and elemental/state ranks. It allows you to gain
#   bonuses based off : actor id, class id, equipment or skills (passive).
#   You can control the bonuses to be either direct gains or percents (except
#   element and state ranks modificatsion). If an direct and percent gain
#   exist, the direct gain will take place first, then multiple by the percent.
#------------------------------------------------------------------------------
# * Instructions :
#
#   Place The Script Below the SDK and Above Main.
#   To Customize your bonuses, refer to the customization instructions.
#------------------------------------------------------------------------------
# * Customization :
#
#    = {  => { stat_bonus => bonus, ... } ... }
#
#   The Following are list of constants and description of the bonus
#
#   ActorBonuses_Direct / ActorBonuses_Percent
#    - Description : Gains Bonuses Based Off Actor ID
#    - Key : Actor ID
#
#   ClassBonuses_Direct / ClassBonuses_Percent
#    - Description : Gains Bonuses Based Off Class ID
#    - Key : Class ID
#
#   SkillBonuses_Direct / SkillBonuses_Percent
#    - Description : Gains Bonuses Based Off Skill ID
#    - Key : Skill ID
#
#   WeaponBonuses_Direct / WeaponBonuses_Percent
#    - Description : Gains Bonuses Based Off Weapon ID
#    - Key : Weapon ID
#
#   ArmorBonuses_Direct / ArmorBonuses_Percent
#    - Description : Gains Bonuses Based Off Armor ID
#    - Key : Armor ID
#
# ** Normal Stat Modifers
#
#   'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int', 'atk', 'pdef', 'mdef',
#   'eva', 'exp', 'gold'
#  
# ** Special Modifers
#   'element' => { element_id => bonus }
#   'state'   => { state_id   => bonus }
#------------------------------------------------------------------------------
# * Syntax :
#
#   Collect Bonus Gain For a Certain Stat
#     Actor_Stat_Bonuses.calculate_bonus(, 'stat_name', base_value)
#
#     or
#
#     .seph_asb__bonus
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Actor Bonuses', 'SephirothSpawn', 1, '2006-03-12')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Actor Bonuses')

#==============================================================================
# ** Actor_Stat_Bonuses
#==============================================================================
  
module Actor_Stat_Bonuses
  #--------------------------------------------------------------------------
  # * Stat Bonuses
  #
  #  ~ Normal Stat Modifers
  #    'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int', 'atk', 'pdef', 'mdef',
  #    'eva', 'exp', 'gold'
  #  
  #  ~ Special Modifers (Note that there is no % bonus for element & states)
  #    'element' => { element_id => bonus }
  #    'state'   => { state_id   => bonus }
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Actor Bonuses
  #
  #  ~ actor_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  ActorBonuses_Direct = {
  }
  ActorBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Class Bonuses
  #
  #  ~ class_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  ClassBonuses_Direct = {
  }
  ClassBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Skill Bonuses (Passive)
  #
  #  ~ skill_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  SkillBonuses_Direct = {
  }
  SkillBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Weapon Bonuses
  #
  #  ~ weapon_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  WeaponBonuses_Direct = {
  }
  WeaponBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Armor Bonuses
  #
  #  ~ armor_id => { stat_bonus => bonus, ... }
  #--------------------------------------------------------------------------
  ArmorBonuses_Direct = {
  }
  ArmorBonuses_Percent = {
  }
  #--------------------------------------------------------------------------
  # * Get Normal Bonuses (Direct)
  #--------------------------------------------------------------------------
  def self.get_normal_bonus_direct(actor, bonus_string)
    # Starts Bonus Count
    n = 0
    # Checks Actor ID
    if ActorBonuses_Direct.has_key?(id = actor.id)
      if ActorBonuses_Direct[id].has_key?(bonus_string)
        n += ActorBonuses_Direct[id][bonus_string]
      end
    end
    # Checks Actor Class
    if ClassBonuses_Direct.has_key?(class_id = actor.class_id)
      if ClassBonuses_Direct[class_id].has_key?(bonus_string)
        n += ClassBonuses_Direct[class_id][bonus_string]
      end
    end
    # Checks Actor Skills
    for skill_id in actor.skills
      if SkillBonuses_Direct.has_key?(skill_id)
        if SkillBonuses_Direct[skill_id].has_key?(bonus_string)
          n += SkillBonuses_Direct[skill_id][bonus_string]
        end
      end
    end
    # Checks Actor Weapon
    if WeaponBonuses_Direct.has_key?(weapon_id = actor.weapon_id)
      if WeaponBonuses_Direct[weapon_id].has_key?(bonus_string)
        n += WeaponBonuses_Direct[weapon_id][bonus_string]
      end
    end
    # Checks Actor Equipment
    for i in 1..4
      if ArmorBonuses_Direct.has_key?(id = (eval "actor.armor#{i}_id"))
        if ArmorBonuses_Direct[id].has_key?(bonus_string)
          n + ArmorBonuses_Direct[id][bonus_string]
        end
      end
    end
    # Returns Bonus
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Normal Bonuses (Percent)
  #--------------------------------------------------------------------------
  def self.get_normal_bonus_percent(actor, bonus_string)
    # Starts Bonus Count
    n = 0
    # Checks Actor ID
    if ActorBonuses_Percent.has_key?(id = actor.id)
      if ActorBonuses_Percent[id].has_key?(bonus_string)
        n += ActorBonuses_Percent[id][bonus_string]
      end
    end
    # Checks Actor Class
    if ClassBonuses_Percent.has_key?(class_id = actor.class_id)
      if ClassBonuses_Percent[class_id].has_key?(bonus_string)
        n += ClassBonuses_Percent[class_id][bonus_string]
      end
    end
    # Checks Actor Skills
    for skill_id in actor.skills
      if SkillBonuses_Percent.has_key?(skill_id)
        if SkillBonuses_Percent[skill_id].has_key?(bonus_string)
          n += SkillBonuses_Percent[skill_id][bonus_string]
        end
      end
    end
    # Checks Actor Weapon
    if WeaponBonuses_Percent.has_key?(weapon_id = actor.weapon_id)
      if WeaponBonuses_Percent[weapon_id].has_key?(bonus_string)
        n += WeaponBonuses_Percent[weapon_id][bonus_string]
      end
    end
    # Checks Actor Equipment
    for i in 1..4
      if ArmorBonuses_Percent.has_key?(id = (eval "actor.armor#{i}_id"))
        if ArmorBonuses_Percent[id].has_key?(bonus_string)
          n + ArmorBonuses_Percent[id][bonus_string]
        end
      end
    end
    # Returns Bonus
    return n
  end
  #--------------------------------------------------------------------------
  # * Calculate Special Bonuses
  #--------------------------------------------------------------------------
  def self.calculate_special_bonus(actor, bonus_string, id)
    # Starts Bonus Count
    n = 0
    # Checks Actor ID
    if ActorBonuses_Direct.has_key?(id = actor.id)
      if ActorBonuses_Direct[id].has_key?(bonus_string)
        ActorBonuses_Direct[id][bonus_string].each do |ob_id|
          if ob_id == id
            n += ActorBonuses_Direct[id][bonus_string][ob_id]
          end
        end
      end
    end
    # Checks Actor Class
    if ClassBonuses_Direct.has_key?(class_id = actor.class_id)
      if ClassBonuses_Direct[class_id].has_key?(bonus_string)
        ClassBonuses_Direct[class_id][bonus_string].each do |ob_id|
          if ob_id == id
            n += ClassBonuses_Direct[class_id][bonus_string][ob_id]
          end
        end
      end
    end
    # Checks Actor Skills
    for skill_id in actor.skills
      if SkillBonuses_Direct.has_key?(skill_id)
        if SkillBonuses_Direct[skill_id].has_key?(bonus_string)
          SkillBonuses_Direct[skill_id][bonus_string].each do |ob_id|
            if ob_id == id
              n += SkillBonuses_Direct[skill_id][bonus_string][ob_id]
            end
          end
        end
      end
    end
    # Checks Actor Weapon
    if WeaponBonuses_Direct.has_key?(weapon_id = actor.weapon_id)
      if WeaponBonuses_Direct[weapon_id].has_key?(bonus_string)
        WeaponBonuses_Direct[weapon_id][bonus_string].each do |ob_id|
          if ob_id == id
            n += WeaponBonuses_Direct[weapon_id][bonus_string][ob_id]
          end
        end
      end
    end
    # Checks Actor Equipment
    for i in 1..4
      if ArmorBonuses_Direct.has_key?(a_id = (eval "actor.armor#{i}_id"))
        if ArmorBonuses_Direct[a_id].has_key?(bonus_string)
          ArmorBonuses_Direct[a_id][bonus_string].each do |ob_id|
            if ob_id == id
              n += ArmorBonuses_Direct[a_id][bonus_string][ob_id]
            end
          end
        end
      end
    end
    # Returns Bonus
    return n
  end
  #--------------------------------------------------------------------------
  # * Calculate Bonus
  #--------------------------------------------------------------------------
  def self.calculate_bonus(actor, bonus_string, base_value)
    # Collects Direct Bonus
    direct_bonus = self.get_normal_bonus_direct(actor, bonus_string)
    # Collects Percent Bonus
    percent_bonus = self.get_normal_bonus_percent(actor, bonus_string)
    # Return Bonus
    return Integer( ( base_value + direct_bonus ) * 
                    ( (100 + percent_bonus) / 100.0 ) ) - base_value
  end
end
  
#==============================================================================
# ** Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias seph_statbonus_gmactr_bmaxhp base_maxhp
  alias seph_statbonus_gmactr_bmaxsp base_maxsp
  alias seph_statbonus_gmactr_bstr   base_str
  alias seph_statbonus_gmactr_bdex   base_dex
  alias seph_statbonus_gmactr_bagi   base_agi
  alias seph_statbonus_gmactr_bint   base_int
  alias seph_statbonus_gmactr_batk   base_atk
  alias seph_statbonus_gmactr_bpdef  base_pdef
  alias seph_statbonus_gmactr_bmdef  base_mdef
  alias seph_statbonus_gmactr_beva   base_eva
  alias seph_statbonus_gmactr_er     element_rate
  alias seph_statbonus_gmactr_sr     state_ranks
  alias seph_statbonus_gmactr_exp=   exp=
  #--------------------------------------------------------------------------
  # * Maxhp Bonus
  #--------------------------------------------------------------------------
  def seph_asb_maxhp_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'maxhp', 
      seph_statbonus_gmactr_bmaxhp)
  end
  #--------------------------------------------------------------------------
  # * Base Maxsp Bonus
  #--------------------------------------------------------------------------
  def seph_asb_maxsp_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'maxsp', 
      seph_statbonus_gmactr_bmaxsp)
  end
  #--------------------------------------------------------------------------
  # * Base Str Bonus
  #--------------------------------------------------------------------------
  def seph_asb_str_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'str', 
      seph_statbonus_gmactr_bstr)
  end
  #--------------------------------------------------------------------------
  # * Base Dex Bonus
  #--------------------------------------------------------------------------
  def seph_asb_dex_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'dex', 
      seph_statbonus_gmactr_bstr)
  end
  #--------------------------------------------------------------------------
  # * Base Agi Bonus
  #--------------------------------------------------------------------------
  def seph_asb_agi_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'agi', 
      seph_statbonus_gmactr_bagi)
  end
  #--------------------------------------------------------------------------
  # * Base Int Bonus
  #--------------------------------------------------------------------------
  def seph_asb_int_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'int', 
      seph_statbonus_gmactr_bint)
  end
  #--------------------------------------------------------------------------
  # * Base Atk Bonus
  #--------------------------------------------------------------------------
  def seph_asb_atk_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'atk', 
      seph_statbonus_gmactr_batk)
  end
  #--------------------------------------------------------------------------
  # * Base PDef Bonus
  #--------------------------------------------------------------------------
  def seph_asb_pdef_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'pdef', 
      seph_statbonus_gmactr_bpdef)
  end
  #--------------------------------------------------------------------------
  # * Base MDef Bonus
  #--------------------------------------------------------------------------
  def seph_asb_mdef_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'mdef', 
      seph_statbonus_gmactr_bmdef)
  end
  #--------------------------------------------------------------------------
  # * Base Eva Bonus
  #--------------------------------------------------------------------------
  def seph_asb_eva_bonus
    return Actor_Stat_Bonuses.calculate_bonus(self, 'eva', 
      seph_statbonus_gmactr_beva)
  end
  #--------------------------------------------------------------------------
  # * Get Maximum HP
  #--------------------------------------------------------------------------
  def base_maxhp
    # Gets Orginal Maxhp Value
    n = seph_statbonus_gmactr_bmaxhp
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'maxhp', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Maximum SP
  #--------------------------------------------------------------------------
  def base_maxsp
    # Gets Orginal Maxsp Value
    n = seph_statbonus_gmactr_bmaxsp
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'maxsp', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Strength
  #--------------------------------------------------------------------------
  def base_str
    # Gets Orginal Str Value
    n = seph_statbonus_gmactr_bstr
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'str', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Dexterity
  #--------------------------------------------------------------------------
  def base_dex
    # Gets Orginal Dex Value
    n = seph_statbonus_gmactr_bdex
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'dex', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Agility
  #--------------------------------------------------------------------------
  def base_agi
    # Gets Orginal Agi Value
    n = seph_statbonus_gmactr_bagi
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'agi', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Intelligence
  #--------------------------------------------------------------------------
  def base_int
    # Gets Orginal Int Value
    n = seph_statbonus_gmactr_bint
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'int', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Attack Power
  #--------------------------------------------------------------------------
  def base_atk
    # Gets Orginal Int Value
    n = seph_statbonus_gmactr_batk
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'atk', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Physical Defense
  #--------------------------------------------------------------------------
  def base_pdef
    # Gets Orginal Physical Defense Value
    n = seph_statbonus_gmactr_bpdef
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'pdef', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Magic Defense
  #--------------------------------------------------------------------------
  def base_mdef
    # Gets Orginal Magic Defense Value
    n = seph_statbonus_gmactr_bmdef
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'mdef', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Basic Evasion Correction
  #--------------------------------------------------------------------------
  def base_eva
    # Gets Orginal Evasion Value
    n = seph_statbonus_gmactr_beva
    # Add Bonus
    n += Actor_Stat_Bonuses.calculate_bonus(self, 'eva', n)
    return n
  end
  #--------------------------------------------------------------------------
  # * Get Element Revision Value
  #--------------------------------------------------------------------------
  def element_rate(element_id)
    # Get Original Element Rate
    n = seph_statbonus_gmactr_er(element_id)
    # Adds Bonus
    n += Actor_Stat_Bonuses.calculate_special_bonus(self, 'element', 
      element_id)
    # Return Result
    return n
  end
  #--------------------------------------------------------------------------
  # * Get State Effectiveness
  #--------------------------------------------------------------------------
  def state_ranks(state_id)
    # Get Original Element Rate
    n = seph_statbonus_gmactr_sr(state_id)
    # Adds Bonus
    n += Actor_Stat_Bonuses.calculate_special_bonus(self, 'state', 
      state_id)
    # Return Result
    return n
  end
  #--------------------------------------------------------------------------
  # * Change EXP
  #--------------------------------------------------------------------------
  def exp=(exp)
    # If Gaining Exp
    if (exp_gain = exp - @exp) > 0
      # Collect Exp Bonus
      # Add Bonus
      exp += Actor_Stat_Bonuses.calculate_bonus(self, 'exp', exp_gain)
    end
    # Original Exp Set
    self.seph_statbonus_gmactr_exp=(exp)
  end
end

#==============================================================================
# ** Window_BattleResult
#==============================================================================

class Window_BattleResult < Window_Base
  attr_accessor :gold
end

#==============================================================================
# ** Scene_Battle
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # * Start After Battle Phase
  #--------------------------------------------------------------------------
  alias seph_asb_scnbtl_sp5 start_phase5
  def start_phase5
    # Original Start Battle Phase 5
    seph_asb_scnbtl_sp5
    # Read Gold Gained
    gold = @result_window.gold
    # Start Gold Gain Counters
    direct_gain = 0
    percent_gain = 0
    for actor in $game_party.actors
      unless actor.dead?
        direct_gain += Actor_Stat_Bonuses.get_normal_bonus_direct(actor, 
          'gold')
        percent_gain += Actor_Stat_Bonuses.get_normal_bonus_percent(actor, 
          'gold')
      end
    end
    # Calculate Gold Increase
    gold = Integer( ( gold + direct_gain ) * 
                    ( (100 + percent_gain) / 100.0 ) )
    # Reset Gold Gain
    @result_window.gold = gold
    # Refresh Result Window
    @result_window.refresh
  end
end

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

Informações adicionais

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!