Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> [Solved]Yanfly Enemy Levels - Res/Dex growth, Found a glitch :(
Pillanious
post Oct 6 2011, 09:38 AM
Post #1


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Not sure if anyone else noticed, but there is a glitch in this particular script (I just noticed it myself when reviewing my bestiary)

The growth rates for all of the native VX stats work absolutely flawlessly; however, the growth rates for RES and DEX do not work at all.

I tested this by setting a specific base RES for a monster, as well as allowing the formula to set it natively, and checking the monsters' stats at various levels.

Every stat increased except for RES and DEX.

I tried with the enemy level script below the new stats script, and vice-versa, to see if that had any impact - and it didn't.

I've included a copy of both the Enemy levels script, and the New Stats script - if anyone could review it and maybe provide some suggestions, that'd be fabulous smile.gif

Enemy Levels:
CODE
#===============================================================================
#
# Yanfly Engine Melody - Enemy Levels
# Last Date Updated: 2010.05.31
# Level: Normal, Hard
#
# RPG's with enemies that level up with the party enforces the player to stay
# on their toes the whole time. This is both a good and bad thing as it can
# cause the player to stay alert, but can also cause the player to meet some
# roadblocks. This script will not only provide enemies the ability to level up
# but also allow the script's user to go around these roadblocks using various
# tags to limit or slow down the rate of growth across all enemies.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.05.31 - Converted to Yanfly Engine Melody.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Enemy Tags - Insert the following tags into Enemy noteboxes.
# -----------------------------------------------------------------------------
# <min level: x>
# <max level: x>
# This will adjust the minimum and maximum levels for the enemy. By default,
# the minimum level is 1 and the maximum level is whatever is set below in the
# module below as MAX_LEVEL.
#
# <set level: x>
# This will set the enemy's level to exactly x. It a sense, this is just the
# usage of both the min and max level tags together as the same value.
#
# <level type: x>
# Choosing a value from 0 to 4, you can adjust the different leveling rulesets
# for the enemy. View the DEFAULT_LEVEL_TYPE module option to see what kinds of
# rules there are for level types.
#
# <level bonus: +x> or <level bonux: -x>
# This will place the enemy x levels above or below the base level when set. If
# it has a bonus of +10, it will be 10 levels higher than whatever the normal
# ruleset set for the enemy is.
#
# <level random: x>
# This will give the level a random flunctuation in either direction. Set this
# value to 0 if you don't wish to use it. Adjust RANDOM_FLUCTUATION inside the
# module to change the default fluctuation value.
#
# <level state x: y> or <level states x: y,y>
# At level x and higher, the enemy will have the auto states y applied to it.
# Use multiple of these tags to designate different levels and the states the
# enemy will gain at those levels.
#
# <stat: +x per level>  or <stat: -x per level>
# <stat: +x% per level> or <stat: -x% per level>
# This will raise or lower the stat by x or x% per level (depending on the tag
# used). This will override the default growth settings found inside the module
# hash called DEFAULT_GROWTH. You may replace stat with:
# maxhp, maxmp, atk, def, spi, res, dex, agi, gold, exp
#
# <base stat: x>
# This will allow you to manually adjust the base stat to x value if you want a
# value higher than 999. Note that this won't mean much if you don't have a stat
# limit breaker script installed like KGC Limit Breaker. Replace stat with:
# maxhp, maxmp, atk, def, spi, agi
#
# <phrase trait at level: x>
# This will give the enemy a particular trait at level x or higher. Use more of
# these tags to give enemies different traits at different levels. Replace the
# phrase with one of the following:
#   super guard  - Gives the enemy super guard properties.
#   fast attack  - Gives the enemy fast attack properties.
#   dual attack  - Gives the enemy dual attack properties.
#   prevent crit - Prevents the enemy from taking critical hits.
#   half mp cost - Enemy skills will use only half MP.
#
# <doppelganger: x>
# This creates a doppelganger of the actor x in terms of levels and stats. The
# actors skills and such will not be carried over as enemies use an AI set for
# their skills and does not translate over that easily.
#
# -----------------------------------------------------------------------------
# Skill and Item Tags - Insert the following tags into Skill or Item noteboxes.
# -----------------------------------------------------------------------------
# <enemy level: +x> or <enemy level: -x>
# This causes the enemy to raise or drop x levels depending on the tag used.
# The new level will readjust the enemy's stats (including HP and MP).
#
# <enemy level reset>
# This resets the enemy's level back to the typical range it should be plus or
# minus any level fluctuations it was given. This occurs before enemy level +
# and enemy level - tags.
#===============================================================================

$imported = {} if $imported == nil
$imported["EnemyLevels"] = true

module YEM
  module ENEMY_LEVEL
    
    #==========================================================================
=
    # Section I. Basic Settings
    # --------------------------------------------------------------------------
    # These settings adjust the basic rules that govern the whole leveling
    # system for enemies. Adjust them accordingly.
    #==========================================================================
=
    
    # This is how the level text will appear whenever enemy levels are shown.
    LEVEL_TEXT = "LV%d %s"
    
    # This is the maximum level your enemies can achieve. They cannot go higher
    # no exceptions. Adjust this accordingly to fit your game.
    MAX_LEVEL = 100
    
    # These two variables adjust the enemy levels by a set amount and a percent
    # amount respectively. Set amounts will adjust the levels of all enemies by
    # a set number while percentile amounts will adjust the levels by a percent
    # number out of 100. Set values are applied after percentile values.
    SET_VARIABLE = 31
    PER_VARIABLE = 32
    
    # These settings adjust the default growth rates (not the base stat formula)
    # for each stat. These are the values that will exist for each enemy unless
    # defined otherwise by the tags inside their noteboxes.
    DEFAULT_GROWTH ={
    # Stat   => [ +Set, Per%]
      :maxhp => [   0,  15],
      :maxmp => [   0,  13],
      :atk   => [   4,  15],
      :def   => [   4,  20],
      :spi   => [   2,  15],
      :res   => [   8,  30],
      :dex   => [   6,  20],
      :agi   => [   3,  10],
      :gold  => [   0,  10],
      :exp   => [   0,  10],
    } # Do not remove this.
    
    # Default level calculations for your enemies will be adjusted as such.
    # Type 0 - Lowest level of all actors. (not recommended)
    # Type 1 - Lowest level in the Player Party
    # Type 2 - Average level of the Player Party.
    # Type 3 - Highest level of the Player Party.
    # Type 4 - Highest level of all actors.
    DEFAULT_LEVEL_TYPE = 2
    
    # If you want your enemies to have random +/- levels of some degree, change
    # this number to something other than 0. This is the default value.
    RANDOM_FLUCTUATION = 3
    
    #==========================================================================
=
    # Section II. Formula Settings
    # --------------------------------------------------------------------------
    # These are the various base formulas made and set out for each of the base
    # stats. Adjust them as you see fit but only if you know what you're doing.
    #
    #   base  - The base stat from the enemy database.
    #   per   - Growth rate which has not been yet converted to a percent.
    #   set   - Set growth rate. Modified
    #
    # Default:   (base * (100 + (level-1) * per)/100) + (set * (level-1))
    #==========================================================================
=
    
    # The following hash will adjust each of the formulas for each base stat.
    BASE_FORMULAS ={
    # Stat   => "Formula"
      :maxhp => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :maxmp => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :atk   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :def   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :spi   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :res   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :dex   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :agi   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :gold  => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
      :exp   => "(base * (100 + (level-1) * per)/100) + (set * (level-1))",
    } # Do not remove this.
    
    #==========================================================================
=
    # Section III. Compatibility Settings
    # --------------------------------------------------------------------------
    # These settings are used for outside scripts to enable better functionality
    # and compatibility in regards to them.
    #==========================================================================
=
    
    # This is the AI boost per level for the YEM AI and Aggro script. If that
    # script is not installed and not updated, this will have no effect.
    AI_LEVEL_BOOST = 0.25
    
  end # ENEMY_LEVEL  
end # YEM

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

module YEM
module REGEXP
module USABLEITEM
      
  LEVEL_CHANGE = /<(?:ENEMY LEVEL|enemy level):[ ]([\+\-]\d+)>/i
  LEVEL_RESET  = /<(?:ENEMY LEVEL RESET|enemy level reset)>/i
      
end # USABLEITEM
module ENEMY
      
  MIN_LEVEL = /<(?:MIN_LEVEL|min level|minimum level):[ ](\d+)>/i
  MAX_LEVEL = /<(?:MAX_LEVEL|max level|maximum level):[ ](\d+)>/i
  SET_LEVEL = /<(?:SET_LEVEL|set level|permanent level):[ ](\d+)>/i
      
  LEVEL_TYPE = /<(?:LEVEL_TYPE|level type):[ ](\d+)>/i
  GROWTH_SET = /<(.*):[ ]([\+\-]\d+)[ ](?:PER_LEVEL|per level)>/i
  GROWTH_PER = /<(.*):[ ]([\+\-]\d+)([%%])[ ](?:PER_LEVEL|per level)>/i
  BASE_STAT  = /<(?:BASE|original)[ ](.*):[ ](\d+)>/i
      
  ACTOR_CLONE = /<(?:ACTOR_CLONE|actor clone|doppelganger):[ ](\d+)>/i
  LEVEL_BONUS = /<(?:LEVEL|level):[ ]([\+\-]\d+)>/i
  LEVEL_RAND  = /<(?:LEVEL_RANDOM|level random):[ ](\d+)>/i
  LEVEL_TRAIT = /<(.*)[ ](?:TRAIT AT LEVEL|at level):[ ](\d+)>/i
  LEVEL_STATE = /<(?:LEVEL STATE|level states):[ ](\d+):(\d+(?:\s*,\s*\d+)*)>/i
      
end # ENEMY
end # REGEXP
end # YEM

#===============================================================================
# RPG::BaseItem
#===============================================================================

class RPG::UsableItem < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :level_change
  attr_accessor :level_reset
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_baseitem_el
  #--------------------------------------------------------------------------
  def yem_cache_usableitem_el
    return if @cached_usableitem_el; @cached_usableitem_el = true
    @level_change = 0; @level_reset = false
    
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when YEM::REGEXP::USABLEITEM::LEVEL_CHANGE
        @level_change = $1.to_i
      when YEM::REGEXP::USABLEITEM::LEVEL_RESET
        @level_reset = true
      end
    } # end self.note.split
  end # yem_cache_usableitem_el
  
end # RPG::UsableItem

#===============================================================================
# RPG::Enemy
#===============================================================================

class RPG::Enemy
  
  #--------------------------------------------------------------------------
  # new method: min_level
  #--------------------------------------------------------------------------
  attr_accessor :min_level
  attr_accessor :max_level
  attr_accessor :level_type
  attr_accessor :level_bonus
  attr_accessor :level_random
  attr_accessor :level_traits
  attr_accessor :level_states
  attr_accessor :doppelganger
  attr_accessor :growth_set
  attr_accessor :growth_per
  attr_accessor :maxhp
  attr_accessor :maxmp
  attr_accessor :atk
  attr_accessor :def
  attr_accessor :spi
  attr_accessor :agi
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_enemy_el
  #--------------------------------------------------------------------------
  def yem_cache_enemy_el
    return if @cached_enemy_el; @cached_enemy_el = true
    @level_type = [[YEM::ENEMY_LEVEL::DEFAULT_LEVEL_TYPE, 0].max, 4].min
    @growth_set = {}; @growth_per = {}; @checked_new_base_stats = true
    for item in [:maxhp,:maxmp,:atk,:def,:spi,:res,:dex,:agi,:gold,:exp]
      @growth_set[item] = YEM::ENEMY_LEVEL::DEFAULT_GROWTH[item][0]
      @growth_per[item] = YEM::ENEMY_LEVEL::DEFAULT_GROWTH[item][1]
    end
    @level_bonus = 0; @level_random = YEM::ENEMY_LEVEL::RANDOM_FLUCTUATION
    @level_traits = {}; @min_level = 1; @max_level = YEM::ENEMY_LEVEL::MAX_LEVEL
    @level_states = {}; @doppelganger = 0
    
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::ENEMY::MIN_LEVEL
        @min_level = [[$1.to_i, 1].max, YEM::ENEMY_LEVEL::MAX_LEVEL].min
      when YEM::REGEXP::ENEMY::MAX_LEVEL
        @max_level = [[$1.to_i, 1].max, YEM::ENEMY_LEVEL::MAX_LEVEL].min
      when YEM::REGEXP::ENEMY::SET_LEVEL
        @min_level = [[$1.to_i, 1].max, YEM::ENEMY_LEVEL::MAX_LEVEL].min
        @max_level = [[$1.to_i, 1].max, YEM::ENEMY_LEVEL::MAX_LEVEL].min
      #---
      when YEM::REGEXP::ENEMY::LEVEL_TYPE
        @level_type = [[$1.to_i, 0].max, 4].min
      #---
      when YEM::REGEXP::ENEMY::LEVEL_BONUS
        @level_bonus = $1.to_i
      #---
      when YEM::REGEXP::ENEMY::LEVEL_RAND
        @level_random = $1.to_i
      #---
      when YEM::REGEXP::ENEMY::ACTOR_CLONE
        @doppelganger = $1.to_i
      #---
      when YEM::REGEXP::ENEMY::GROWTH_SET
        case $1.upcase
        when "MAXHP"; @growth_set[:maxhp] = $2.to_i
        when "MAXMP"; @growth_set[:maxmp] = $2.to_i
        when "ATK";   @growth_set[:atk] = $2.to_i
        when "DEF";   @growth_set[:def] = $2.to_i
        when "SPI";   @growth_set[:spi] = $2.to_i
        when "RES";   @growth_set[:res] = $2.to_i
        when "DEX";   @growth_set[:dex] = $2.to_i
        when "AGI";   @growth_set[:agi] = $2.to_i
        when "GOLD";  @growth_set[:gold] = $2.to_i
        when "EXP";   @growth_set[:exp] = $2.to_i
        end
      #---
      when YEM::REGEXP::ENEMY::GROWTH_PER
        case $1.upcase
        when "MAXHP"; @growth_per[:maxhp] = $2.to_i
        when "MAXMP"; @growth_per[:maxmp] = $2.to_i
        when "ATK";   @growth_per[:atk] = $2.to_i
        when "DEF";   @growth_per[:def] = $2.to_i
        when "SPI";   @growth_per[:spi] = $2.to_i
        when "RES";   @growth_per[:res] = $2.to_i
        when "DEX";   @growth_per[:dex] = $2.to_i
        when "AGI";   @growth_per[:agi] = $2.to_i
        when "GOLD";  @growth_per[:gold] = $2.to_i
        when "EXP";   @growth_per[:exp] = $2.to_i
        end
      #---
      when YEM::REGEXP::ENEMY::BASE_STAT
        case $1.upcase
        when "MAXHP"; @maxhp = $2.to_i
        when "MAXMP"; @maxmp = $2.to_i
        when "ATK";   @atk = $2.to_i
        when "DEF";   @def = $2.to_i
        when "SPI";   @spi = $2.to_i
        when "AGI";   @agi = $2.to_i
        end
      #---
      when YEM::REGEXP::ENEMY::LEVEL_TRAIT
        case $1.upcase
        when "SUPER GUARD", "SUPERGUARD", "SUPER_GUARD"
          @level_traits[:super_guard] = $2.to_i
        when "FAST ATTACK", "FASTATTACK", "FAST_ATTACK"
          @level_traits[:fast_attack] = $2.to_i
        when "DUAL ATTACK", "DUALATTACK", "DUAL_ATTACK"
          @level_traits[:dual_attack] = $2.to_i
        when "PREVENT CRITICAL", "PREVENT CRIT", "PREVENTCRIT"
          @level_traits[:prevent_critical] = $2.to_i
        when "HALF MP COST", "HALF MP", "HALF_MP_COST"
          @level_traits[:half_mp_cost] = $2.to_i
        end
      #---
      when YEM::REGEXP::ENEMY::LEVEL_STATE
        @level_states[$1.to_i] = [] if @level_states[$1.to_i] == nil
        $2.scan(/\d+/).each { |num| @level_states[$1.to_i] += [num.to_i] }
      #---
      end
    } # end self.note.split
  end # yem_cache_enemy_el
  
end # RPG::Enemy

#===============================================================================
# Scene_Title
#===============================================================================

class Scene_Title < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: load_bt_database
  #--------------------------------------------------------------------------
  alias load_bt_database_el load_bt_database unless $@
  def load_bt_database
    load_bt_database_el
    load_el_cache
  end
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  alias load_database_el load_database unless $@
  def load_database
    load_database_el
    load_el_cache
  end
  
  #--------------------------------------------------------------------------
  # new method: load_el_cache
  #--------------------------------------------------------------------------
  def load_el_cache
    groups = [$data_skills, $data_items, $data_enemies]
    for group in groups
      for obj in group
        next if obj == nil
        obj.yem_cache_usableitem_el if obj.is_a?(RPG::UsableItem)
        obj.yem_cache_enemy_el if obj.is_a?(RPG::Enemy)
      end
    end
  end
  
end # Scene_Title

#===============================================================================
# Game_Battler
#===============================================================================

class Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: item_effect
  #--------------------------------------------------------------------------
  alias item_effect_el item_effect unless $@
  def item_effect(user, item)
    item_effect_el(user, item)
    if !actor? and !@skipped and !@missed and !@evaded
      self.reset_level
      self.level += item.level_change
    end
  end
  
  #--------------------------------------------------------------------------
  # alias method: skill_effect
  #--------------------------------------------------------------------------
  alias skill_effect_el skill_effect unless $@
  def skill_effect(user, skill)
    skill_effect_el(user, skill)
    if !actor? and !@skipped and !@missed and !@evaded
      self.reset_level if skill.level_reset
      self.level += skill.level_change
    end
  end
  
end # Game_Battler

#===============================================================================
# Game_Enemy
#===============================================================================

class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias initialize_enemy_el initialize unless $@
  def initialize(index, enemy_id)
    initialize_enemy_el(index, enemy_id)
    create_level
    @hp = maxhp
    @mp = maxmp
  end
  
  #--------------------------------------------------------------------------
  # alias method: transform
  #--------------------------------------------------------------------------
  alias transform_el transform unless $@
  def transform(enemy_id)
    transform_el(enemy_id)
    @base_stats = nil
    create_level
  end
  
  #--------------------------------------------------------------------------
  # new method: reset_level
  #--------------------------------------------------------------------------
  def reset_level
    @base_stats = nil
    create_level
  end
  
  #--------------------------------------------------------------------------
  # new method: create_level
  #--------------------------------------------------------------------------
  def create_level
    @level = nil
    case enemy.level_type
    when 0 # Lowest level of all actors.
      for i in 1..($data_actors.size - 1)
        @level = $game_actors[i].level if @level == nil
        @level = [$game_actors[i].level, @level].min
        break if @level == 1
      end
    when 1 # Lowest level of the party.
      group = $game_party.members
      for actor in group
        @level = actor.level if @level == nil
        @level = [actor.level, @level].min
        break if @level == 1
      end
    when 2 # Average level of the party.
      group = $game_party.members
      @level = 0
      for actor in group; @level += actor.level; end
      @level /= group.size
    when 3 # Highest level of the party.
      group = $game_party.members
      for actor in group
        @level = actor.level if @level == nil
        @level = [actor.level, @level].max
      end
    when 4 # Highest level of all actors.
      for i in 1..($data_actors.size - 1)
        @level = $game_actors[i].level if @level == nil
        @level = [$game_actors[i].level, @level].max
      end
    else # Nothing else.
      @level = 1
    end
    $game_variables[YEM::ENEMY_LEVEL::PER_VARIABLE] = 100 if
      $game_variables[YEM::ENEMY_LEVEL::PER_VARIABLE] <= 0
    @level = @level * $game_variables[YEM::ENEMY_LEVEL::PER_VARIABLE] / 100
    @level += $game_variables[YEM::ENEMY_LEVEL::SET_VARIABLE]
    @level += enemy.level_bonus
    @level += rand(enemy.level_random+1)
    @level -= rand(enemy.level_random+1)
    @level = [[@level, enemy.max_level].min, enemy.min_level].max
    create_doppelganger
  end

  #--------------------------------------------------------------------------
  # new method: level
  #--------------------------------------------------------------------------
  def level
    create_level if @level == nil
    return [[@level, 1].max, YEM::ENEMY_LEVEL::MAX_LEVEL].min
  end
  
  #--------------------------------------------------------------------------
  # new method: level=
  #--------------------------------------------------------------------------
  def level=(value)
    return if value == 0
    return if enemy.doppelganger > 0
    clear_battle_cache if $imported["BattleEngineMelody"]
    last_hp = self.maxhp
    last_mp = self.maxmp
    @level = value
    @base_stats = nil unless enemy.doppelganger > 0
    unless self.dead?
      clear_battle_cache if $imported["BattleEngineMelody"]
      self.hp += self.maxhp - last_hp
      self.mp += self.maxmp - last_mp
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: create_doppelganger
  #--------------------------------------------------------------------------
  def create_doppelganger
    return unless enemy.doppelganger > 0
    actor = $game_actors[enemy.doppelganger]
    return if actor == nil
    @level = actor.level
    @base_stats = {} if @base_stats == nil
    @base_stats[:maxhp]    = actor.base_maxhp
    @base_stats[:maxmp] = actor.base_maxmp
    @base_stats[:atk]   = actor.base_atk
    @base_stats[:def]   = actor.base_def
    @base_stats[:spi]   = actor.base_spi
    @base_stats[:res]   = actor.base_res if $imported["RES Stat"]
    @base_stats[:dex]   = actor.base_dex if $imported["DEX Stat"]
    @base_stats[:agi]   = actor.base_agi
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_maxhp
  #--------------------------------------------------------------------------
  def base_maxhp
    @base_stats = {} if @base_stats == nil
    return @base_stats[:maxhp] if @base_stats[:maxhp] != nil
    @boost_maxhp = 0 if @boost_maxhp == nil
    base = enemy.maxhp + @boost_maxhp
    per = enemy.growth_per[:maxhp]
    set = enemy.growth_set[:maxhp]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:maxhp]))
    @base_stats[:maxhp] = result
    return @base_stats[:maxhp]
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_maxmp
  #--------------------------------------------------------------------------
  def base_maxmp
    @base_stats = {} if @base_stats == nil
    return @base_stats[:maxmp] if @base_stats[:maxmp] != nil
    @boost_maxmp = 0 if @boost_maxmp == nil
    base = enemy.maxmp + @boost_maxmp
    per = enemy.growth_per[:maxmp]
    set = enemy.growth_set[:maxmp]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:maxmp]))
    @base_stats[:maxmp] = result
    return @base_stats[:maxmp]
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_atk
  #--------------------------------------------------------------------------
  def base_atk
    @base_stats = {} if @base_stats == nil
    return @base_stats[:atk] if @base_stats[:atk] != nil
    @boost_atk = 0 if @boost_atk == nil
    base = enemy.atk + @boost_atk
    base = enemy.atk
    per = enemy.growth_per[:atk]
    set = enemy.growth_set[:atk]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:atk]))
    @base_stats[:atk] = result
    return @base_stats[:atk]
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_def
  #--------------------------------------------------------------------------
  def base_def
    @base_stats = {} if @base_stats == nil
    return @base_stats[:def] if @base_stats[:def] != nil
    @boost_def = 0 if @boost_def == nil
    base = enemy.def + @boost_def
    per = enemy.growth_per[:def]
    set = enemy.growth_set[:def]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:def]))
    @base_stats[:def] = result
    return @base_stats[:def]
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_spi
  #--------------------------------------------------------------------------
  def base_spi
    @base_stats = {} if @base_stats == nil
    return @base_stats[:spi] if @base_stats[:spi] != nil
    @boost_spi = 0 if @boost_spi == nil
    base = enemy.spi + @boost_spi
    per = enemy.growth_per[:spi]
    set = enemy.growth_set[:spi]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:spi]))
    @base_stats[:spi] = result
    return @base_stats[:spi]
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: base_agi
  #--------------------------------------------------------------------------
  def base_agi
    @base_stats = {} if @base_stats == nil
    return @base_stats[:agi] if @base_stats[:agi] != nil
    @boost_agi = 0 if @boost_agi == nil
    base = enemy.agi + @boost_agi
    per = enemy.growth_per[:agi]
    set = enemy.growth_set[:agi]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:agi]))
    @base_stats[:agi] = result
    return @base_stats[:agi]
  end
  
  #--------------------------------------------------------------------------
  # alias method: exp
  #--------------------------------------------------------------------------
  alias exp_enemy_el exp unless $@
  def exp
    base = exp_enemy_el
    per = enemy.growth_per[:exp]
    set = enemy.growth_set[:exp]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:exp]))
    return result
  end
  
  #--------------------------------------------------------------------------
  # alias method: gold
  #--------------------------------------------------------------------------
  alias gold_enemy_el gold unless $@
  def gold
    base = gold_enemy_el
    per = enemy.growth_per[:gold]
    set = enemy.growth_set[:gold]
    result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:gold]))
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: states
  #--------------------------------------------------------------------------
  def states
    result = super
    result += level_states
    result.sort! { |state_a,state_b|
      if state_a.priority != state_b.priority
        state_b.priority <=> state_a.priority
      else
        state_a.id <=> state_b.id
      end }
    return result.uniq
  end
  
  #--------------------------------------------------------------------------
  # new method: level_states
  #--------------------------------------------------------------------------
  def level_states
    result = []
    for key in enemy.level_states
      level_requirement = key[0]
      level_state_ids = key[1]
      next unless level >= level_requirement
      for state_id in level_state_ids
        state = $data_states[state_id]
        next if state == nil
        result.push(state) unless result.include?(state)
      end
    end
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: super_guard
  #--------------------------------------------------------------------------
  def super_guard
    if enemy.level_traits.include?(:super_guard)
      return true if level >= enemy.level_traits[:super_guard]
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: fast_attack
  #--------------------------------------------------------------------------
  def fast_attack
    if enemy.level_traits.include?(:fast_attack)
      return true if level >= enemy.level_traits[:fast_attack]
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: dual_attack
  #--------------------------------------------------------------------------
  def dual_attack
    if enemy.level_traits.include?(:dual_attack)
      return true if level >= enemy.level_traits[:dual_attack]
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: prevent_critical
  #--------------------------------------------------------------------------
  def prevent_critical
    if enemy.level_traits.include?(:prevent_critical)
      return true if level >= enemy.level_traits[:prevent_critical]
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: half_mp_cost
  #--------------------------------------------------------------------------
  def half_mp_cost
    if enemy.level_traits.include?(:half_mp_cost)
      return true if level >= enemy.level_traits[:half_mp_cost]
    end
    return super
  end
  
  #--------------------------------------------------------------------------
  # alias method: conditions_met?
  #--------------------------------------------------------------------------
  unless $imported["AggroAI"]
  alias conditions_met_el conditions_met? unless $@
  def conditions_met?(action)
    case action.condition_type == 5
    when 5 # Change functionality to match level instead.
      if (self.level - 1) < action.condition_param1
        return false
      else
        return true
      end
    else
      return conditions_met_el(action)
    end
  end
  end # $imported["AggroAI"]
  
end # Game_Enemy

#===============================================================================
#
# END OF FILE
#
#===============================================================================


New Stats:

CODE
#===============================================================================
#
# Yanfly Engine Melody - New Battle Stats
# Last Date Updated: 2010.06.20
# Level: Normal, Hard
#
# This script offers the functionality to add new battle stats for both actors
# and enemies alike. These stats can be adjusted in the script itself while any
# potential weapons, armours, states, and enemies can have their settings made
# within their respective noteboxes.
#
# - DEX - Dexterity
# Dexterity is a new stat that directly impacts hit rates, evasion rates, and
# critical hit rates. In default VX, there was no growth at all over these three
# stats other than through equipment. Now, actors progressing through the game
# can directly impact the hit rate, evasion rate, and critical hit rate of a
# character upon calculation.
#
# - RES - Resistance
# Resistance is a new stat to provide a magical defense against magical attacks.
# Just like DEF is to ATK, RES is to SPI. In default VX, both magical defense
# and magical attack were found in one stat. Now, they're split across two,
# which frankly makes more sense.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.06.20 - Bugfix update for dex= and res=
# o 2010.06.14 - Compatibility Update for Skill Equip System.
# o 2010.05.31 - Compatibility Update for YEM Enemy Levels.
# o 2010.05.19 - Started Script and Finished.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# Scroll down and set whichever stats you wish to include in your game. More
# instructions are available in each individual section.
#===============================================================================

$imported = {} if $imported == nil

module YEM
  module STATS
    module DEX
      
      #=========================================================================
      # - DEX - Dexterity
      # -----------------------------------------------------------------------
      # Dexterity is a new stat that directly impacts hit rates, evasion rates,
      # and critical hit rates. In default VX, there was no growth at all over
      # these three stats other than through equipment. Now, actors progressing
      # through the game can directly impact the hit rate, evasion rate, and
      # critical hit rate of a character upon calculation.
      #
      # -----------------------------------------------------------------------
      # Item Tags - For Items only.
      # -----------------------------------------------------------------------
      # <dex growth: +x>  or  <dex growth: -x>
      # This raises or lowers the target's base DEX by x amount.
      #
      # -----------------------------------------------------------------------
      # Equipment Tags - For Weapons and Armours only.
      # -----------------------------------------------------------------------
      # <dex: +x>  or  <dex: -x>
      # <dex: +x%> or  <dex: -x%>
      # This allows the weapon or armour to increase DEX for the actor wearing
      # it by x amount or x%. Using the tag without the percentage will raise
      # the amount by a set value while using the percentage will increase the
      # base DEX of the actor by a percentile value.
      #
      # -----------------------------------------------------------------------
      # State Tags - For Status Effects only.
      # -----------------------------------------------------------------------
      # <dex: x%>  or  <dex: +x>  or  <dex: -x>
      # This adjusts the DEX stat in battle by x percentile or a set x amount.
      # If multiple of these tags are used, it will be calculated based on the
      # order of operations. Stackable.
      #
      # -----------------------------------------------------------------------
      # Enemy Tags - For Enemies only.
      # -----------------------------------------------------------------------
      # <base dex: x>
      # This sets the enemy's base DEX to x. The base dex would be the enemy's
      # unaltered DEX value. If this tag isn't present, the enemy's base DEX
      # will be calculated based on the formula provided by the module.
      #=========================================================================
      
      # This changes whether or not the DEX stat will be used at all. Set it
      # to true if you wish to use the DEX stat. False if otherwise.
      $imported["DEX Stat"] = true
      
      # This is the ingame vocabulary for the DEX stat.
      VOCAB = "DEX"
      
      # This hash allows you to edit each actor's base DEX formula and the rate
      # of growth for DEX as levels progress. Note that actor 0 will be used if
      # the actor's ID does not appear on this list.
      ACTOR_BASE ={
      # ID => Formula
         0 => "actor.parameters[2,@level]/2+actor.parameters[5,@level]/2",
         4 => "@level * 6 + 20",
         1 => "@level * 7 + 35",
         2 => "@level * 2 + 16",
         3 => "@level * 2 + 12",
      } # Do not remove this.
      
      # This is the formula used for the base DEX of an enemy if not specific
      # base DEX has been defined by the <base dex: x> tag.
      ENEMY_BASE = "@atk * 4 + @agi * 4 / 3"
      
      # These are the formulas used to convert DEX bonuses for each of the
      # varying stats. These bonuses are added onto the previously calculated
      # HIT, EVA, and CRI values.
      DEX_TO_HIT = "self.dex * 0.10"
      DEX_TO_EVA = "self.dex * 0.03"
      DEX_TO_CRI = "self.dex * 0.09"
      
    end # DEX
    module RES
      
      #=========================================================================
      # - RES - Resistance
      # -----------------------------------------------------------------------
      # Resistance is a new stat to provide a magical defense against magical
      # attacks. Just like DEF is to ATK, RES is to SPI. In default VX, both
      # magical defense and magical attack were found in one stat. Now, they're
      # split across two, which frankly makes more sense.
      #
      # -----------------------------------------------------------------------
      # Item Tags - For Items only.
      # -----------------------------------------------------------------------
      # <res growth: +x>  or  <res growth: -x>
      # This raises or lowers the target's base RES by x amount.
      #
      # -----------------------------------------------------------------------
      # Equipment Tags - For Weapons and Armours only.
      # -----------------------------------------------------------------------
      # <res: +x>  or  <res: -x>
      # <res: +x%> or  <res: -x%>
      # This allows the weapon or armour to increase RES for the actor wearing
      # it by x amount or x%. Using the tag without the percentage will raise
      # the amount by a set value while using the percentage will increase the
      # base RES of the actor by a percentile value.
      #
      # -----------------------------------------------------------------------
      # State Tags - For Status Effects only.
      # -----------------------------------------------------------------------
      # <res: x%>  or  <res: +x>  or  <res: -x>
      # This adjusts the RES stat in battle by x percentile or a set x amount.
      # If multiple of these tags are used, it will be calculated based on the
      # order of operations. Stackable.
      #
      # -----------------------------------------------------------------------
      # Enemy Tags - For Enemies only.
      # -----------------------------------------------------------------------
      # <base res: x>
      # This sets the enemy's base RES to x. The base res would be the enemy's
      # unaltered RES value. If this tag isn't present, the enemy's base RES
      # will be calculated based on the formula provided by the module.
      #=========================================================================
      
      # This changes whether or not the RES stat will be used at all. Set it
      # to true if you wish to use the RES stat. False if otherwise.
      $imported["RES Stat"] = true
      
      # This is the ingame vocabulary for the RES stat.
      VOCAB = "RES"
      
      # This hash allows you to edit each actor's base RES formula and the rate
      # of growth for RES as levels progress. Note that actor 0 will be used if
      # the actor's ID does not appear on this list.
      ACTOR_BASE ={
      # ID => Formula
         0 => "actor.parameters[3,@level]/2+actor.parameters[4,@level]/2",
         4 => "@level * 4 + 20",
         1 => "@level * 2 + 20",
         2 => "@level * 6 + 30",
         3 => "@level * 7 + 34",
      } # Do not remove this.
      
      # This is the formula used for the base RES of an enemy if not specific
      # base RES has been defined by the <base res: x> tag.
      ENEMY_BASE = "@def * 4 + spi * 4 / 2 + 96"
      
    end # RES
  end # STATS
end # YEM

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

module YEM
  module REGEXP
  module BASEITEM
    
    STAT_PER  = /<(.*):[ ]*([\+\-]\d+)([%%])>/i
    STAT_SET  = /<(.*):[ ]*([\+\-]\d+)>/i
    
  end # BASEITEM
  module ITEM
    
    STAT_GROW = /<(.*)[ ](?:BOOST|growth):[ ]([\+\-]\d+)>/i
    
  end # ITEM
  module STATE
    
    STAT_PER  = /<(.*):[ ]*(\d+)([%%])>/i
    STAT_SET  = /<(.*):[ ]*([\+\-]\d+)>/i
    
  end # STATE
  module ENEMY
    
    BASE_STAT = /<(?:BASE|basic)[ ](.*):[ ]*(\d+)>/i
    
  end # ENEMY
  end # REGEXP
end # YEM

#===============================================================================
# module Vocab
#===============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # self.dex
  #--------------------------------------------------------------------------
  def self.dex; return YEM::STATS::DEX::VOCAB; end
  
  #--------------------------------------------------------------------------
  # self.res
  #--------------------------------------------------------------------------
  def self.res; return YEM::STATS::RES::VOCAB; end
    
end

#===============================================================================
# RPG::BaseItem
#===============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex
  attr_accessor :dex_per
  attr_accessor :res
  attr_accessor :res_per
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_baseitem_nbs
  #--------------------------------------------------------------------------
  def yem_cache_baseitem_nbs
    return if @cached_state_nbs; @cached_state_nbs = true
    @dex = 0
    @res = 0
    @dex_per = 0
    @res_per = 0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::BASEITEM::STAT_PER
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_per = $2.to_i
        when "RES", "RESISTANCE"
          @res_per = $2.to_i
        end
      #---
      when YEM::REGEXP::BASEITEM::STAT_SET
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex = $2.to_i
        when "RES", "RESISTANCE"
          @res = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_baseitem_nbs
  
end # RPG::BaseItem

#===============================================================================
# RPG::Item
#===============================================================================

class RPG::Item < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :stat_growth
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_item_nbs
  #--------------------------------------------------------------------------
  def yem_cache_item_nbs
    return if @cached_item_nbs; @cached_item_nbs = true
    @stat_growth = {} if @stat_growth == nil
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::ITEM::STAT_GROW
        case $1.upcase
        when "DEX", "DEXTERITY"
          type = :dex
        when "RES", "RESISTANCE"
          type = :res
        else; next
        end
        @stat_growth[type] = $2.to_i
      end
    } # self.note.split
  end # yem_cache_item_nbs
  
end # RPG::Item

#===============================================================================
# RPG::State
#===============================================================================

class RPG::State
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex_rate
  attr_accessor :dex_set
  attr_accessor :res_rate
  attr_accessor :res_set
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_state_nbs
  #--------------------------------------------------------------------------
  def yem_cache_state_nbs
    return if @cached_state_nbs; @cached_state_nbs = true
    @dex_rate = 100
    @res_rate = 100
    @dex_set = 0
    @res_set = 0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::STATE::STAT_PER
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_rate = $2.to_i
        when "RES", "RESISTANCE"
          @res_rate = $2.to_i
        end
      #---
      when YEM::REGEXP::STATE::STAT_SET
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_set = $2.to_i
        when "RES", "RESISTANCE"
          @res_set = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_state_nbs
  
end # RPG::State

#===============================================================================
# RPG::Enemy
#===============================================================================

class RPG::Enemy
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex
  attr_accessor :res
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_enemy_nbs
  #--------------------------------------------------------------------------
  def yem_cache_enemy_nbs
    return if @cached_enemy_nbs; @cached_enemy_nbs = true
    @dex = eval(YEM::STATS::DEX::ENEMY_BASE)
    @res = eval(YEM::STATS::RES::ENEMY_BASE)
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::ENEMY::BASE_STAT
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex = $2.to_i
        when "RES", "RESISTANCE"
          @res = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_state_nbs
  
end # RPG::Enemy

#===============================================================================
# Vocab
#===============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # new method: self.dex
  #--------------------------------------------------------------------------
  def self.dex; return YEM::STATS::DEX::VOCAB; end
    
  #--------------------------------------------------------------------------
  # new method: self.res
  #--------------------------------------------------------------------------
  def self.res; return YEM::STATS::RES::VOCAB; end
  
end # Vocab

#===============================================================================
# Scene_Title
#===============================================================================

class Scene_Title < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: load_bt_database
  #--------------------------------------------------------------------------
  alias load_bt_database_nbs load_bt_database unless $@
  def load_bt_database
    load_bt_database_nbs
    load_nbs_cache
  end
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  alias load_database_nbs load_database unless $@
  def load_database
    load_database_nbs
    load_nbs_cache
  end
  
  #--------------------------------------------------------------------------
  # new method: load_nbs_cache
  #--------------------------------------------------------------------------
  def load_nbs_cache
    groups = [$data_skills, $data_items, $data_weapons, $data_armors,
      $data_enemies, $data_states]
    for group in groups
      for obj in group
        next if obj == nil
        obj.yem_cache_baseitem_nbs if obj.is_a?(RPG::BaseItem)
        obj.yem_cache_item_nbs if obj.is_a?(RPG::Item)
        obj.yem_cache_state_nbs if obj.is_a?(RPG::State)
        obj.yem_cache_enemy_nbs if obj.is_a?(RPG::Enemy)
      end
    end
  end
  
end # Scene_Title

#===============================================================================
# Game_Battler
#===============================================================================

class Game_Battler
  
  #--------------------------------------------------------------------------
  # anti-crash method: clear_battle_cache
  #--------------------------------------------------------------------------
  unless method_defined?(:clear_battle_cache)
  def clear_battle_cache; @cache_params = {}; end
  end # method_defined?(:clear_battle_cache)
    
  #--------------------------------------------------------------------------
  # anti-crash method: parameter_limit
  #--------------------------------------------------------------------------
  unless method_defined?(:parameter_limit)
  def parameter_limit; return 999; end
  end # method_defined?(:parameter_limit)
  
  #--------------------------------------------------------------------------
  # anti-crash method: stack
  #--------------------------------------------------------------------------
  unless method_defined?(:stack)
  def stack(state); return 1; end
  end # method_defined?(:stack)
  
  #--------------------------------------------------------------------------
  # alias method: item_growth_effect
  #--------------------------------------------------------------------------
  alias item_growth_effect_nbs item_growth_effect unless $@
  def item_growth_effect(user, item)
    item_growth_effect_nbs(user, item)
    if item.stat_growth != {}
      for key in item.stat_growth
        stat = key[0]; value = key[1]
        case stat
        when :dex
          @boost_dex += value
        when :res
          @boost_res += value
        end
      end
    end
  end
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: dex
  #--------------------------------------------------------------------------
  def dex
    clear_battle_cache if @cache_params == nil
    if $scene.is_a?(Scene_Battle)
      return @cache_params[:dex] if @cache_params[:dex] != nil
    end
    #---
    @dex_plus = 0 if @dex_plus == nil
    n = [base_dex + @dex_plus, 1].max
    for state in states
      stack(state).times do
        n = n * state.dex_rate / 100.0
      end
    end
    for state in states
      next if state.dex_set == 0
      n += state.dex_set * stack(state)
    end
    #---
    @cache_params[:dex] = [[Integer(n), parameter_limit].min, 1].max
    return @cache_params[:dex]
  end
  
  #--------------------------------------------------------------------------
  # new method: dex=
  #--------------------------------------------------------------------------
  def dex=(value)
    @dex_plus = 0 if @dex_plus == nil
    @dex_plus += value - self.dex
    @dex_plus = [[@dex_plus, -parameter_limit].max, parameter_limit].min
    clear_battle_cache
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]

  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: res
  #--------------------------------------------------------------------------
  def res
    clear_battle_cache if @cache_params == nil
    if $scene.is_a?(Scene_Battle)
      return @cache_params[:res] if @cache_params[:res] != nil
    end
    #---
    @res_plus = 0 if @res_plus == nil
    n = [base_res + @res_plus, 1].max
    for state in states
      stack(state).times do
        n = n * state.res_rate / 100.0
      end
    end
    for state in states
      next if state.res_set == 0
      n += state.res_set * stack(state)
    end
    #---
    @cache_params[:res] = [[Integer(n), parameter_limit].min, 1].max
    return @cache_params[:res]
  end
  
  #--------------------------------------------------------------------------
  # new method: res=
  #--------------------------------------------------------------------------
  def res=(value)
    @res_plus = 0 if @res_plus == nil
    @res_plus += value - self.res
    @res_plus = [[@res_plus, -parameter_limit].max, parameter_limit].min
    clear_battle_cache
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: make_obj_damage_value
  #--------------------------------------------------------------------------
  unless $imported["BattleEngineMelody"]
  def make_obj_damage_value(user, obj)
    damage = obj.base_damage
    if damage > 0
      damage += user.atk * 4 * obj.atk_f / 100
      damage += user.spi * 2 * obj.spi_f / 100
      unless obj.ignore_defense
        damage -= self.def * 2 * obj.atk_f / 100
        damage -= self.res * 1 * obj.spi_f / 100
      end
      damage = 0 if damage < 0
    elsif damage < 0
      damage -= user.atk * 4 * obj.atk_f / 100
      damage -= user.spi * 2 * obj.spi_f / 100
    end
    damage *= elements_max_rate(obj.element_set)
    damage /= 100
    damage = apply_variance(damage, obj.variance)
    damage = apply_guard(damage)
    if obj.damage_to_mp
      @mp_damage = damage
    else
      @hp_damage = damage
    end
  end
  end # $imported["BattleEngineMelody"]
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Battler

#===============================================================================
# Game_Actor
#===============================================================================

class Game_Actor < Game_Battler
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: base_dex
  #--------------------------------------------------------------------------
  def base_dex
    if YEM::STATS::DEX::ACTOR_BASE.include?(@actor_id)
      n = eval(YEM::STATS::DEX::ACTOR_BASE[@actor_id])
    else
      n = eval(YEM::STATS::DEX::ACTOR_BASE[0])
    end
    #---
    percent = 100
    for equip in equips.compact
      percent += equip.dex_per
    end
    n *= percent / 100.0
    #---
    for equip in equips.compact
      n += equip.dex
    end
    #---
    n += equip_skill_stat_bonus(:dex) if $imported["SkillEquipSystem"]
    #---
    @boost_dex = 0 if @boost_dex == nil
    n += @boost_dex
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # alias method: hit
  #--------------------------------------------------------------------------
  alias hit_game_actor_nbs hit unless $@
  def hit
    n = hit_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_HIT)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: eva
  #--------------------------------------------------------------------------
  alias eva_game_actor_nbs eva unless $@
  def eva
    n = eva_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_EVA)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: cri
  #--------------------------------------------------------------------------
  alias cri_game_actor_nbs cri unless $@
  def cri
    n = cri_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_CRI)
    return [Integer(n), 0].max
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]
  
  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: base_res
  #--------------------------------------------------------------------------
  def base_res
    if YEM::STATS::RES::ACTOR_BASE.include?(@actor_id)
      n = eval(YEM::STATS::RES::ACTOR_BASE[@actor_id])
    else
      n = eval(YEM::STATS::RES::ACTOR_BASE[0])
    end
    #---
    percent = 100
    for equip in equips.compact
      percent += equip.res_per
    end
    n *= percent / 100.0
    #---
    for equip in equips.compact
      n += equip.res
    end
    #---
    n += equip_skill_stat_bonus(:res) if $imported["SkillEquipSystem"]
    #---
    @boost_res = 0 if @boost_res == nil
    n += @boost_res
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Actor

#===============================================================================
# Game_Enemy
#===============================================================================

class Game_Enemy < Game_Battler
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: base_dex
  #--------------------------------------------------------------------------
  def base_dex
    @boost_dex = 0 if @boost_dex == nil
    n = Integer(enemy.dex) + @boost_dex
    if $imported["EnemyLevels"]
      base = n
      per = enemy.growth_per[:dex]
      set = enemy.growth_set[:dex]
      result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:dex]))
    end
    return n
  end
  
  #--------------------------------------------------------------------------
  # alias method: hit
  #--------------------------------------------------------------------------
  alias hit_game_enemy_nbs hit unless $@
  def hit
    n = hit_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_HIT)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: eva
  #--------------------------------------------------------------------------
  alias eva_game_enemy_nbs eva unless $@
  def eva
    n = eva_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_EVA)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: cri
  #--------------------------------------------------------------------------
  alias cri_game_enemy_nbs cri unless $@
  def cri
    n = cri_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_CRI)
    return [Integer(n), 0].max
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]
  
  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: base_res
  #--------------------------------------------------------------------------
  def base_res
    @boost_res = 0 if @boost_res == nil
    n = Integer(enemy.res) + @boost_res
    if $imported["EnemyLevels"]
      base = n
      per = enemy.growth_per[:dex]
      set = enemy.growth_set[:dex]
      result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:dex]))
    end
    return n
  end
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Enemy

#===============================================================================
# Window_Base
#===============================================================================

class Window_Base < Window
  
  #--------------------------------------------------------------------------
  # alias method: draw_actor_parameter
  #--------------------------------------------------------------------------
  alias draw_actor_parameter_nbs draw_actor_parameter unless $@
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 4 # RES
      parameter_name = Vocab::res
      parameter_value = actor.res
    when 5 # DEX
      parameter_name = Vocab::dex
      parameter_value = actor.dex
    else
      draw_actor_parameter_nbs(actor, x, y, type)
      return
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, WLH, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, WLH, parameter_value, 2)
  end
  
end # Window_Base

#===============================================================================
# Window_Status
#===============================================================================

class Window_Status < Window_Base
  
  #--------------------------------------------------------------------------
  # alias method: draw_parameters
  #--------------------------------------------------------------------------
  alias draw_parameters_nbs draw_parameters unless $@
  def draw_parameters(x, y)
    draw_parameters_nbs(x, y)
    dy = y+WLH*3
    if $imported["RES Stat"]
      dy += WLH
      draw_actor_parameter(@actor, x, dy, 4)
    end
    if $imported["DEX Stat"]
      dy += WLH
      draw_actor_parameter(@actor, x, dy, 5)
    end
  end
  
end # Window_Status

#===============================================================================
#
# END OF FILE
#
#===============================================================================


This post has been edited by Pillanious: Feb 20 2012, 09:23 PM
Go to the top of the page
 
+Quote Post
   
Pillanious
post Oct 11 2011, 11:06 AM
Post #2


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Bumpy! smile.gif
Go to the top of the page
 
+Quote Post
   
Pillanious
post Oct 16 2011, 11:46 AM
Post #3


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Bumptastic! smile.gif
Go to the top of the page
 
+Quote Post
   
Pillanious
post Nov 3 2011, 04:27 PM
Post #4


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (Pillanious @ Oct 16 2011, 03:46 PM) *
Bumptastic! smile.gif


Another bump!
Go to the top of the page
 
+Quote Post
   
Pillanious
post Dec 19 2011, 01:59 AM
Post #5


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (Pillanious @ Nov 3 2011, 07:27 PM) *
QUOTE (Pillanious @ Oct 16 2011, 03:46 PM) *
Bumptastic! smile.gif


Another bump!


One more bump!
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jan 2 2012, 11:04 AM
Post #6


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (Pillanious @ Dec 19 2011, 04:59 AM) *
QUOTE (Pillanious @ Nov 3 2011, 07:27 PM) *
QUOTE (Pillanious @ Oct 16 2011, 03:46 PM) *
Bumptastic! smile.gif


Another bump!


One more bump!


and another! o_o
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jan 16 2012, 12:28 PM
Post #7


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Thought I'd try one more. I know Yanfly is no longer supporting this script, but it's worth a shot anyway.
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Jan 17 2012, 09:11 PM
Post #8


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




Which Yanfly script are you using? I'm pretty sure ReDux and Zealous handle those differently, and Melody handles this the same as Zealous. If you're using Zealous or Melody, I can try to help. I'm not too familiar with ReDux.
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jan 18 2012, 02:01 AM
Post #9


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (MinoanRoyal @ Jan 18 2012, 12:11 AM) *
Which Yanfly script are you using? I'm pretty sure ReDux and Zealous handle those differently, and Melody handles this the same as Zealous. If you're using Zealous or Melody, I can try to help. I'm not too familiar with ReDux.


I'm using Melody - I attached the script in the first post smile.gif
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Jan 24 2012, 11:44 AM
Post #10


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




Interesting... Are there other scripts you are using other than Melody? It's very possible that one of those scripts could be interfering with these.

Also, are you using the notetags in the enemy notebox? the enemy levels wont function without them.
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jan 24 2012, 04:04 PM
Post #11


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (MinoanRoyal @ Jan 24 2012, 02:44 PM) *
Interesting... Are there other scripts you are using other than Melody? It's very possible that one of those scripts could be interfering with these.

Also, are you using the notetags in the enemy notebox? the enemy levels wont function without them.


I am using notetags to set base res, but I've also set an actual res growth formula in the scripts I listed above. The other scripts I'm using are:

Yami's Custom Hud
Woratana's Minimap
Shanghai's Wereforms
SwapXT
YERD Scan/Bestiary & the patch by GB productions
KGC Largeparty
Icedragon's Random target fix
GB Productions YEM New Functions
-------
Just to add: here are the formulae I'm using

In the YEM Enemy Levels script:
"DEFAULT_GROWTH ={
# Stat => [ +Set, Per%]
:maxhp => [ 0, 13],
:maxmp => [ 0, 10],
:atk => [ 4, 15],
:def => [ 4, 15],
:spi => [ 2, 15],
:res => [ 8, 15],
:dex => [ 6, 10],
:agi => [ 3, 10],
:gold => [ 0, 5],
:exp => [ 5, 10],"

and because it wasn't working, I set the formula in the YEM New Battle Stats script as follows to compensate:

# This is the formula used for the base DEX of an enemy if not specific
# base DEX has been defined by the <base dex: x> tag.
ENEMY_BASE = "@atk * 4 + @agi * 4 / 3"
# This is the formula used for the base RES of an enemy if not specific
# base RES has been defined by the <base res: x> tag.
ENEMY_BASE = "@def * 4 + spi * 4 / 2 + 96"
------------

Hope that all helps!

This post has been edited by Pillanious: Jan 24 2012, 04:13 PM
Go to the top of the page
 
+Quote Post
   
Pillanious
post Jan 28 2012, 03:17 AM
Post #12


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




I did some more looking into the script itself and tried making some changes - I noticed another couple of things that really confused me - and may lead to solving this whole debaucle.

First off: I have the formula for RES growth set as:

(@def * 4 + @spi * 4) / 2 + 96

Thusly, a level 1 monster with 15 def and 15 spi should have a total res of 156.

A level 16 monster (with the appropriate growth formulas I've set) would have 78 def and 108 spi
when we plug everything in,

(78 * 4 + 108 * 4) / 2 + 96

we're left with a base RES of 468

I set off to test this in the game, and found that even at level 27, the monster's base res was 156.

The conclusion I can draw from this is that for whatever reason, enemy levels are not being factored into the dex/res script.

Looking over the script I saw a few other things - Firstly:

" #--------------------------------------------------------------------------
# new method: base_res
#--------------------------------------------------------------------------
def base_res
@boost_res = 0 if @boost_res == nil
n = Integer(enemy.res) + @boost_res
if $imported["EnemyLevels"]
base = n
per = enemy.growth_per[:dex]
set = enemy.growth_set[:dex]
result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:dex]))
end
return n"

For some reason, :dex is used instead of :res - I'm not sure why, but maybe it's an oversight on Yanfly's part. Changing the text from :dex to :res doesn't seem to have any effect on anything whatsoever, though.

I also noticed that if I set the dex/res growth formulae to, for example, @level * 4 - I get an error message citing: "Undefined method '*' for nil:NilClass"

I'm assuming this is because you're trying to multiply by something that doesn't exist.

It should be noted that there's no growth issue for actors, though, from what I've noticed.

I also noted the formula at the beginning of the script for actors is listed as:
"module YEM
module REGEXP
module BASEITEM

STAT_PER = /<(.*):[ ]*([\+\-]\d+)([%%])>/i
STAT_SET = /<(.*):[ ]*([\+\-]\d+)>/i

end # BASEITEM
module ITEM

STAT_GROW = /<(.*)[ ](?:BOOST|growth):[ ]([\+\-]\d+)>/i

end # ITEM
module STATE

STAT_PER = /<(.*):[ ]*(\d+)([%%])>/i
STAT_SET = /<(.*):[ ]*([\+\-]\d+)>/i

end # STATE
module ENEMY

BASE_STAT = /<(?:BASE|basic)[ ](.*):[ ]*(\d+)>/i

end # ENEMY
end # REGEXP
end # YEM"

..It seems different for Enemies than it does for any of the others. I'm not sure if this has anything to do with what's going on, either.

This also stuck out at me in the Enemy Levels script:

when YEM::REGEXP::ENEMY::BASE_STAT
case $1.upcase
when "MAXHP"; @maxhp = $2.to_i
when "MAXMP"; @maxmp = $2.to_i
when "ATK"; @atk = $2.to_i
when "DEF"; @def = $2.to_i
when "SPI"; @spi = $2.to_i
when "AGI"; @agi = $2.to_i"

- RES and DEX aren't listed there, despite there being customization options for growth rates.

Hopefully this new information is helpful smile.gif

This post has been edited by Pillanious: Jan 28 2012, 03:33 AM
Go to the top of the page
 
+Quote Post
   
Pillanious
post Feb 10 2012, 01:15 PM
Post #13


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




Friendly little bump smile.gif
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Feb 14 2012, 12:25 PM
Post #14


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




hmmm... a dilemma worthy of gods! lol.

Let's see... the first thing i would like to ask is what exactly you are wanting to do with that formula. Are you wanting the formula to divide by the sum of the 2 and 96, or just the 2 and THEN add 96? Dependent on your answer to that would mean an addition of parentheses.

also, I would check to see that the result of the formula is getting pushed into the RES or DEX variables that are actually used in the battle scene. if it isn't then for some reason Yanfly decided to mess with us, lol. I doubt this is the problem though.

and yes, the NilClass error means something you did doesn't exist in any previous script. if you suspect that may be the problem, look into the base scripts for, say, the level variable, to use in the formulae. that is a possibility.

I'm sorry if my response is a little vague. I'm not currently at my own computer as i type this.

][EDIT][

OHH!!!!!! I didn't see the enemy levels part in your post. Yeah, with the RES/DEX values not in the script, you are most likely going to have to add them yourself, it looks like. Then hopefully they would work and solve the problem.

This post has been edited by MinoanRoyal: Feb 14 2012, 12:28 PM
Go to the top of the page
 
+Quote Post
   
Pillanious
post Feb 14 2012, 01:13 PM
Post #15


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




QUOTE (MinoanRoyal @ Feb 14 2012, 03:25 PM) *
hmmm... a dilemma worthy of gods! lol.

Let's see... the first thing i would like to ask is what exactly you are wanting to do with that formula. Are you wanting the formula to divide by the sum of the 2 and 96, or just the 2 and THEN add 96? Dependent on your answer to that would mean an addition of parentheses.

also, I would check to see that the result of the formula is getting pushed into the RES or DEX variables that are actually used in the battle scene. if it isn't then for some reason Yanfly decided to mess with us, lol. I doubt this is the problem though.

and yes, the NilClass error means something you did doesn't exist in any previous script. if you suspect that may be the problem, look into the base scripts for, say, the level variable, to use in the formulae. that is a possibility.

I'm sorry if my response is a little vague. I'm not currently at my own computer as i type this.

][EDIT][

OHH!!!!!! I didn't see the enemy levels part in your post. Yeah, with the RES/DEX values not in the script, you are most likely going to have to add them yourself, it looks like. Then hopefully they would work and solve the problem.


Whew, lots to answer with! biggrin.gif

First: I tried with and without parenthesis - It, essentially, only uses the enemy's base stats without taking their level into consideration either way. (Meaning that if the stats show as, say, 300 because the monster is level 30, but they're 10 at level 1 - it takes the level 1 stats into consideration, and not the level 30)

Also: I tried adding the correct variables for res/dex in the enemy levels script (simply copying the format Yanfly had used before), and had no such luck sad.gif

I'm thinking it may be some other kind of issues sad.gif
Go to the top of the page
 
+Quote Post
   
MinoanRoyal
post Feb 19 2012, 01:10 PM
Post #16


Level 1
Group Icon

Group: Member
Posts: 13
Type: Developer
RM Skill: Beginner




Hmm... Here's a relatively simple suggestion that will probably make us both look like an idiot, if it fixes the issue.

Back to the notetags. which ones are you using? are there notetags for the enemies you're testing with?

It's looking to me, from what you've posted, that the only tag you've used is the <base stat: x> tag. If that's the case you need to add corresponding <stat: ±x per level> or <stat: ±x% per level> tags. otherwise it looks like it will always use that <base stat: x> in the calculations.

I'd be amused to see if that is what does it.

PM me with the result. :3

][EDIT][

I took a quick look at the YEM Enemy Levels script for the case function you quoted earlier, and mine has DEX and RES already. if the above doesn't work, try downloading that script from Yanfly's blog site. That might fix it as well.

][EDIT_2][

Issue has been fixed over PM. Here is the altered script for review:

CODE
#===============================================================================
#
# Yanfly Engine Melody - New Battle Stats
# Last Date Updated: 2010.06.20
# Level: Normal, Hard
#
# This script offers the functionality to add new battle stats for both actors
# and enemies alike. These stats can be adjusted in the script itself while any
# potential weapons, armours, states, and enemies can have their settings made
# within their respective noteboxes.
#
# - DEX - Dexterity
# Dexterity is a new stat that directly impacts hit rates, evasion rates, and
# critical hit rates. In default VX, there was no growth at all over these three
# stats other than through equipment. Now, actors progressing through the game
# can directly impact the hit rate, evasion rate, and critical hit rate of a
# character upon calculation.
#
# - RES - Resistance
# Resistance is a new stat to provide a magical defense against magical attacks.
# Just like DEF is to ATK, RES is to SPI. In default VX, both magical defense
# and magical attack were found in one stat. Now, they're split across two,
# which frankly makes more sense.
#
#===============================================================================
# Updates
# -----------------------------------------------------------------------------
# o 2010.06.20 - Bugfix update for dex= and res=
# o 2010.06.14 - Compatibility Update for Skill Equip System.
# o 2010.05.31 - Compatibility Update for YEM Enemy Levels.
# o 2010.05.19 - Started Script and Finished.
#===============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials but above ▼ Main. Remember to save.
#
# Scroll down and set whichever stats you wish to include in your game. More
# instructions are available in each individual section.
#===============================================================================

$imported = {} if $imported == nil

module YEM
  module STATS
    module DEX
      
      #=========================================================================
      # - DEX - Dexterity
      # -----------------------------------------------------------------------
      # Dexterity is a new stat that directly impacts hit rates, evasion rates,
      # and critical hit rates. In default VX, there was no growth at all over
      # these three stats other than through equipment. Now, actors progressing
      # through the game can directly impact the hit rate, evasion rate, and
      # critical hit rate of a character upon calculation.
      #
      # -----------------------------------------------------------------------
      # Item Tags - For Items only.
      # -----------------------------------------------------------------------
      # <dex growth: +x>  or  <dex growth: -x>
      # This raises or lowers the target's base DEX by x amount.
      #
      # -----------------------------------------------------------------------
      # Equipment Tags - For Weapons and Armours only.
      # -----------------------------------------------------------------------
      # <dex: +x>  or  <dex: -x>
      # <dex: +x%> or  <dex: -x%>
      # This allows the weapon or armour to increase DEX for the actor wearing
      # it by x amount or x%. Using the tag without the percentage will raise
      # the amount by a set value while using the percentage will increase the
      # base DEX of the actor by a percentile value.
      #
      # -----------------------------------------------------------------------
      # State Tags - For Status Effects only.
      # -----------------------------------------------------------------------
      # <dex: x%>  or  <dex: +x>  or  <dex: -x>
      # This adjusts the DEX stat in battle by x percentile or a set x amount.
      # If multiple of these tags are used, it will be calculated based on the
      # order of operations. Stackable.
      #
      # -----------------------------------------------------------------------
      # Enemy Tags - For Enemies only.
      # -----------------------------------------------------------------------
      # <base dex: x>
      # This sets the enemy's base DEX to x. The base dex would be the enemy's
      # unaltered DEX value. If this tag isn't present, the enemy's base DEX
      # will be calculated based on the formula provided by the module.
      #=========================================================================
      
      # This changes whether or not the DEX stat will be used at all. Set it
      # to true if you wish to use the DEX stat. False if otherwise.
      $imported["DEX Stat"] = true
      
      # This is the ingame vocabulary for the DEX stat.
      VOCAB = "DEX"
      
      # This hash allows you to edit each actor's base DEX formula and the rate
      # of growth for DEX as levels progress. Note that actor 0 will be used if
      # the actor's ID does not appear on this list.
      ACTOR_BASE ={
      # ID => Formula
         0 => "actor.parameters[2,@level]/2+actor.parameters[5,@level]/2",
         4 => "@level * 6 + 20",
         1 => "@level * 7 + 35",
         2 => "@level * 2 + 16",
         3 => "@level * 2 + 12",
      } # Do not remove this.
      
      # This is the formula used for the base DEX of an enemy if not specific
      # base DEX has been defined by the <base dex: x> tag.
      ENEMY_BASE = "@atk * 4 + @agi * 4 / 3"
      
      # These are the formulas used to convert DEX bonuses for each of the
      # varying stats. These bonuses are added onto the previously calculated
      # HIT, EVA, and CRI values.
      DEX_TO_HIT = "self.dex * 0.10"
      DEX_TO_EVA = "self.dex * 0.03"
      DEX_TO_CRI = "self.dex * 0.09"
      
    end # DEX
    module RES
      
      #=========================================================================
      # - RES - Resistance
      # -----------------------------------------------------------------------
      # Resistance is a new stat to provide a magical defense against magical
      # attacks. Just like DEF is to ATK, RES is to SPI. In default VX, both
      # magical defense and magical attack were found in one stat. Now, they're
      # split across two, which frankly makes more sense.
      #
      # -----------------------------------------------------------------------
      # Item Tags - For Items only.
      # -----------------------------------------------------------------------
      # <res growth: +x>  or  <res growth: -x>
      # This raises or lowers the target's base RES by x amount.
      #
      # -----------------------------------------------------------------------
      # Equipment Tags - For Weapons and Armours only.
      # -----------------------------------------------------------------------
      # <res: +x>  or  <res: -x>
      # <res: +x%> or  <res: -x%>
      # This allows the weapon or armour to increase RES for the actor wearing
      # it by x amount or x%. Using the tag without the percentage will raise
      # the amount by a set value while using the percentage will increase the
      # base RES of the actor by a percentile value.
      #
      # -----------------------------------------------------------------------
      # State Tags - For Status Effects only.
      # -----------------------------------------------------------------------
      # <res: x%>  or  <res: +x>  or  <res: -x>
      # This adjusts the RES stat in battle by x percentile or a set x amount.
      # If multiple of these tags are used, it will be calculated based on the
      # order of operations. Stackable.
      #
      # -----------------------------------------------------------------------
      # Enemy Tags - For Enemies only.
      # -----------------------------------------------------------------------
      # <base res: x>
      # This sets the enemy's base RES to x. The base res would be the enemy's
      # unaltered RES value. If this tag isn't present, the enemy's base RES
      # will be calculated based on the formula provided by the module.
      #=========================================================================
      
      # This changes whether or not the RES stat will be used at all. Set it
      # to true if you wish to use the RES stat. False if otherwise.
      $imported["RES Stat"] = true
      
      # This is the ingame vocabulary for the RES stat.
      VOCAB = "RES"
      
      # This hash allows you to edit each actor's base RES formula and the rate
      # of growth for RES as levels progress. Note that actor 0 will be used if
      # the actor's ID does not appear on this list.
      ACTOR_BASE ={
      # ID => Formula
         0 => "actor.parameters[3,@level]/2+actor.parameters[4,@level]/2",
         4 => "@level * 4 + 20",
         1 => "@level * 2 + 20",
         2 => "@level * 6 + 30",
         3 => "@level * 7 + 34",
      } # Do not remove this.
      
      # This is the formula used for the base RES of an enemy if not specific
      # base RES has been defined by the <base res: x> tag.
      ENEMY_BASE = "(@def * 4 + @spi * 4) / 2 + 96"
      
    end # RES
  end # STATS
end # YEM

#===============================================================================
# Editting anything past this point may potentially result in causing computer
# damage, incontinence, explosion of user's head, coma, death, and/or halitosis.
# Therefore, edit at your own risk.
#===============================================================================

module YEM
  module REGEXP
  module BASEITEM
    
    STAT_PER  = /<(.*):[ ]*([\+\-]\d+)([%%])>/i
    STAT_SET  = /<(.*):[ ]*([\+\-]\d+)>/i
    
  end # BASEITEM
  module ITEM
    
    STAT_GROW = /<(.*)[ ](?:BOOST|growth):[ ]([\+\-]\d+)>/i
    
  end # ITEM
  module STATE
    
    STAT_PER  = /<(.*):[ ]*(\d+)([%%])>/i
    STAT_SET  = /<(.*):[ ]*([\+\-]\d+)>/i
    
  end # STATE
  module ENEMY
    
    BASE_STAT = /<(?:BASE|basic)[ ](.*):[ ]*(\d+)>/i
    
  end # ENEMY
  end # REGEXP
end # YEM

#===============================================================================
# module Vocab
#===============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # self.dex
  #--------------------------------------------------------------------------
  def self.dex; return YEM::STATS::DEX::VOCAB; end
  
  #--------------------------------------------------------------------------
  # self.res
  #--------------------------------------------------------------------------
  def self.res; return YEM::STATS::RES::VOCAB; end
    
end

#===============================================================================
# RPG::BaseItem
#===============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex
  attr_accessor :dex_per
  attr_accessor :res
  attr_accessor :res_per
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_baseitem_nbs
  #--------------------------------------------------------------------------
  def yem_cache_baseitem_nbs
    return if @cached_state_nbs; @cached_state_nbs = true
    @dex = 0
    @res = 0
    @dex_per = 0
    @res_per = 0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::BASEITEM::STAT_PER
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_per = $2.to_i
        when "RES", "RESISTANCE"
          @res_per = $2.to_i
        end
      #---
      when YEM::REGEXP::BASEITEM::STAT_SET
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex = $2.to_i
        when "RES", "RESISTANCE"
          @res = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_baseitem_nbs
  
end # RPG::BaseItem

#===============================================================================
# RPG::Item
#===============================================================================

class RPG::Item < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :stat_growth
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_item_nbs
  #--------------------------------------------------------------------------
  def yem_cache_item_nbs
    return if @cached_item_nbs; @cached_item_nbs = true
    @stat_growth = {} if @stat_growth == nil
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::ITEM::STAT_GROW
        case $1.upcase
        when "DEX", "DEXTERITY"
          type = :dex
        when "RES", "RESISTANCE"
          type = :res
        else; next
        end
        @stat_growth[type] = $2.to_i
      end
    } # self.note.split
  end # yem_cache_item_nbs
  
end # RPG::Item

#===============================================================================
# RPG::State
#===============================================================================

class RPG::State
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex_rate
  attr_accessor :dex_set
  attr_accessor :res_rate
  attr_accessor :res_set
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_state_nbs
  #--------------------------------------------------------------------------
  def yem_cache_state_nbs
    return if @cached_state_nbs; @cached_state_nbs = true
    @dex_rate = 100
    @res_rate = 100
    @dex_set = 0
    @res_set = 0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::STATE::STAT_PER
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_rate = $2.to_i
        when "RES", "RESISTANCE"
          @res_rate = $2.to_i
        end
      #---
      when YEM::REGEXP::STATE::STAT_SET
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex_set = $2.to_i
        when "RES", "RESISTANCE"
          @res_set = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_state_nbs
  
end # RPG::State

#===============================================================================
# RPG::Enemy
#===============================================================================

class RPG::Enemy
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :dex
  attr_accessor :res
  
  #--------------------------------------------------------------------------
  # common cache: yem_cache_enemy_nbs
  #--------------------------------------------------------------------------
  def yem_cache_enemy_nbs
    return if @cached_enemy_nbs; @cached_enemy_nbs = true
    @dex = eval(YEM::STATS::DEX::ENEMY_BASE)
    @res = eval(YEM::STATS::RES::ENEMY_BASE)
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEM::REGEXP::ENEMY::BASE_STAT
        case $1.upcase
        when "DEX", "DEXTERITY"
          @dex = $2.to_i
        when "RES", "RESISTANCE"
          @res = $2.to_i
        end
      #---
      end
    } # self.note.split
  end # yem_cache_state_nbs
  
end # RPG::Enemy

#===============================================================================
# Vocab
#===============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # new method: self.dex
  #--------------------------------------------------------------------------
  def self.dex; return YEM::STATS::DEX::VOCAB; end
    
  #--------------------------------------------------------------------------
  # new method: self.res
  #--------------------------------------------------------------------------
  def self.res; return YEM::STATS::RES::VOCAB; end
  
end # Vocab

#===============================================================================
# Scene_Title
#===============================================================================

class Scene_Title < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: load_bt_database
  #--------------------------------------------------------------------------
  alias load_bt_database_nbs load_bt_database unless $@
  def load_bt_database
    load_bt_database_nbs
    load_nbs_cache
  end
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  alias load_database_nbs load_database unless $@
  def load_database
    load_database_nbs
    load_nbs_cache
  end
  
  #--------------------------------------------------------------------------
  # new method: load_nbs_cache
  #--------------------------------------------------------------------------
  def load_nbs_cache
    groups = [$data_skills, $data_items, $data_weapons, $data_armors,
      $data_enemies, $data_states]
    for group in groups
      for obj in group
        next if obj == nil
        obj.yem_cache_baseitem_nbs if obj.is_a?(RPG::BaseItem)
        obj.yem_cache_item_nbs if obj.is_a?(RPG::Item)
        obj.yem_cache_state_nbs if obj.is_a?(RPG::State)
        obj.yem_cache_enemy_nbs if obj.is_a?(RPG::Enemy)
      end
    end
  end
  
end # Scene_Title

#===============================================================================
# Game_Battler
#===============================================================================

class Game_Battler
  
  #--------------------------------------------------------------------------
  # anti-crash method: clear_battle_cache
  #--------------------------------------------------------------------------
  unless method_defined?(:clear_battle_cache)
  def clear_battle_cache; @cache_params = {}; end
  end # method_defined?(:clear_battle_cache)
    
  #--------------------------------------------------------------------------
  # anti-crash method: parameter_limit
  #--------------------------------------------------------------------------
  unless method_defined?(:parameter_limit)
  def parameter_limit; return 999; end
  end # method_defined?(:parameter_limit)
  
  #--------------------------------------------------------------------------
  # anti-crash method: stack
  #--------------------------------------------------------------------------
  unless method_defined?(:stack)
  def stack(state); return 1; end
  end # method_defined?(:stack)
  
  #--------------------------------------------------------------------------
  # alias method: item_growth_effect
  #--------------------------------------------------------------------------
  alias item_growth_effect_nbs item_growth_effect unless $@
  def item_growth_effect(user, item)
    item_growth_effect_nbs(user, item)
    if item.stat_growth != {}
      for key in item.stat_growth
        stat = key[0]; value = key[1]
        case stat
        when :dex
          @boost_dex += value
        when :res
          @boost_res += value
        end
      end
    end
  end
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: dex
  #--------------------------------------------------------------------------
  def dex
    clear_battle_cache if @cache_params == nil
    if $scene.is_a?(Scene_Battle)
      return @cache_params[:dex] if @cache_params[:dex] != nil
    end
    #---
    @dex_plus = 0 if @dex_plus == nil
    n = [base_dex + @dex_plus, 1].max
    for state in states
      stack(state).times do
        n = n * state.dex_rate / 100.0
      end
    end
    for state in states
      next if state.dex_set == 0
      n += state.dex_set * stack(state)
    end
    #---
    @cache_params[:dex] = [[Integer(n), parameter_limit].min, 1].max
    return @cache_params[:dex]
  end
  
  #--------------------------------------------------------------------------
  # new method: dex=
  #--------------------------------------------------------------------------
  def dex=(value)
    @dex_plus = 0 if @dex_plus == nil
    @dex_plus += value - self.dex
    @dex_plus = [[@dex_plus, -parameter_limit].max, parameter_limit].min
    clear_battle_cache
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]

  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: res
  #--------------------------------------------------------------------------
  def res
    clear_battle_cache if @cache_params == nil
    if $scene.is_a?(Scene_Battle)
      return @cache_params[:res] if @cache_params[:res] != nil
    end
    #---
    @res_plus = 0 if @res_plus == nil
    n = [base_res + @res_plus, 1].max
    for state in states
      stack(state).times do
        n = n * state.res_rate / 100.0
      end
    end
    for state in states
      next if state.res_set == 0
      n += state.res_set * stack(state)
    end
    #---
    @cache_params[:res] = [[Integer(n), parameter_limit].min, 1].max
    return @cache_params[:res]
  end
  
  #--------------------------------------------------------------------------
  # new method: res=
  #--------------------------------------------------------------------------
  def res=(value)
    @res_plus = 0 if @res_plus == nil
    @res_plus += value - self.res
    @res_plus = [[@res_plus, -parameter_limit].max, parameter_limit].min
    clear_battle_cache
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: make_obj_damage_value
  #--------------------------------------------------------------------------
  unless $imported["BattleEngineMelody"]
  def make_obj_damage_value(user, obj)
    damage = obj.base_damage
    if damage > 0
      damage += user.atk * 4 * obj.atk_f / 100
      damage += user.spi * 2 * obj.spi_f / 100
      unless obj.ignore_defense
        damage -= self.def * 2 * obj.atk_f / 100
        damage -= self.res * 1 * obj.spi_f / 100
      end
      damage = 0 if damage < 0
    elsif damage < 0
      damage -= user.atk * 4 * obj.atk_f / 100
      damage -= user.spi * 2 * obj.spi_f / 100
    end
    damage *= elements_max_rate(obj.element_set)
    damage /= 100
    damage = apply_variance(damage, obj.variance)
    damage = apply_guard(damage)
    if obj.damage_to_mp
      @mp_damage = damage
    else
      @hp_damage = damage
    end
  end
  end # $imported["BattleEngineMelody"]
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Battler

#===============================================================================
# Game_Actor
#===============================================================================

class Game_Actor < Game_Battler
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: base_dex
  #--------------------------------------------------------------------------
  def base_dex
    if YEM::STATS::DEX::ACTOR_BASE.include?(@actor_id)
      n = eval(YEM::STATS::DEX::ACTOR_BASE[@actor_id])
    else
      n = eval(YEM::STATS::DEX::ACTOR_BASE[0])
    end
    #---
    percent = 100
    for equip in equips.compact
      percent += equip.dex_per
    end
    n *= percent / 100.0
    #---
    for equip in equips.compact
      n += equip.dex
    end
    #---
    n += equip_skill_stat_bonus(:dex) if $imported["SkillEquipSystem"]
    #---
    @boost_dex = 0 if @boost_dex == nil
    n += @boost_dex
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # alias method: hit
  #--------------------------------------------------------------------------
  alias hit_game_actor_nbs hit unless $@
  def hit
    n = hit_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_HIT)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: eva
  #--------------------------------------------------------------------------
  alias eva_game_actor_nbs eva unless $@
  def eva
    n = eva_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_EVA)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: cri
  #--------------------------------------------------------------------------
  alias cri_game_actor_nbs cri unless $@
  def cri
    n = cri_game_actor_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_CRI)
    return [Integer(n), 0].max
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]
  
  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: base_res
  #--------------------------------------------------------------------------
  def base_res
    if YEM::STATS::RES::ACTOR_BASE.include?(@actor_id)
      n = eval(YEM::STATS::RES::ACTOR_BASE[@actor_id])
    else
      n = eval(YEM::STATS::RES::ACTOR_BASE[0])
    end
    #---
    percent = 100
    for equip in equips.compact
      percent += equip.res_per
    end
    n *= percent / 100.0
    #---
    for equip in equips.compact
      n += equip.res
    end
    #---
    n += equip_skill_stat_bonus(:res) if $imported["SkillEquipSystem"]
    #---
    @boost_res = 0 if @boost_res == nil
    n += @boost_res
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Actor

#===============================================================================
# Game_Enemy
#===============================================================================

class Game_Enemy < Game_Battler
  
  if $imported["DEX Stat"]
  #--------------------------------------------------------------------------
  # new method: base_dex
  #--------------------------------------------------------------------------
  def base_dex
    @boost_dex = 0 if @boost_dex == nil
    n = Integer(enemy.dex) + @boost_dex
    if $imported["EnemyLevels"]
      base = n
      per = enemy.growth_per[:dex]
      set = enemy.growth_set[:dex]
      result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:dex]))
    end
    return Integer(n)
  end
  
  #--------------------------------------------------------------------------
  # alias method: hit
  #--------------------------------------------------------------------------
  alias hit_game_enemy_nbs hit unless $@
  def hit
    n = hit_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_HIT)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: eva
  #--------------------------------------------------------------------------
  alias eva_game_enemy_nbs eva unless $@
  def eva
    n = eva_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_EVA)
    return [Integer(n), 0].max
  end
  
  #--------------------------------------------------------------------------
  # alias method: cri
  #--------------------------------------------------------------------------
  alias cri_game_enemy_nbs cri unless $@
  def cri
    n = cri_game_enemy_nbs
    n += eval(YEM::STATS::DEX::DEX_TO_CRI)
    return [Integer(n), 0].max
  end
  #--------------------------------------------------------------------------
  end # imported["DEX Stat"]
  
  if $imported["RES Stat"]
  #--------------------------------------------------------------------------
  # new method: base_res
  #--------------------------------------------------------------------------
  def base_res
    @boost_res = 0 if @boost_res == nil
    n = Integer(enemy.res) + @boost_res
    if $imported["EnemyLevels"]
      base = n
      per = enemy.growth_per[:dex]
      set = enemy.growth_set[:dex]
      result = Integer(eval(YEM::ENEMY_LEVEL::BASE_FORMULAS[:dex]))
    end
    return Integer(n)
  end
  #--------------------------------------------------------------------------
  end # imported["RES Stat"]
  
end # Game_Enemy

#===============================================================================
# Window_Base
#===============================================================================

class Window_Base < Window
  
  #--------------------------------------------------------------------------
  # alias method: draw_actor_parameter
  #--------------------------------------------------------------------------
  alias draw_actor_parameter_nbs draw_actor_parameter unless $@
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 4 # RES
      parameter_name = Vocab::res
      parameter_value = actor.res
    when 5 # DEX
      parameter_name = Vocab::dex
      parameter_value = actor.dex
    else
      draw_actor_parameter_nbs(actor, x, y, type)
      return
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, WLH, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, WLH, parameter_value, 2)
  end
  
end # Window_Base

#===============================================================================
# Window_Status
#===============================================================================

class Window_Status < Window_Base
  
  #--------------------------------------------------------------------------
  # alias method: draw_parameters
  #--------------------------------------------------------------------------
  alias draw_parameters_nbs draw_parameters unless $@
  def draw_parameters(x, y)
    draw_parameters_nbs(x, y)
    dy = y+WLH*3
    if $imported["RES Stat"]
      dy += WLH
      draw_actor_parameter(@actor, x, dy, 4)
    end
    if $imported["DEX Stat"]
      dy += WLH
      draw_actor_parameter(@actor, x, dy, 5)
    end
  end
  
end # Window_Status

#===============================================================================
#
# END OF FILE
#
#=============================================================================


I myself didn't alter the script, the result was PM'd to me by Pillanious. I am reviewing it to find the changes.

This post has been edited by MinoanRoyal: Feb 20 2012, 07:40 PM
Go to the top of the page
 
+Quote Post
   
Pillanious
post Feb 20 2012, 09:23 PM
Post #17


Level 8
Group Icon

Group: Revolutionary
Posts: 125
Type: Musician
RM Skill: Beginner




This has been fixed - I'll post the fully edited script in submissions - This topic can be closed smile.gif

And also, a HUGE "Thank you" to MinoanRoyal for his assistance - as well as my friend Chris for isolating and fixing the issue =)

This post has been edited by Pillanious: Feb 20 2012, 10:22 PM
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 23rd May 2013 - 07:28 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker