#=============================================================================== # # Yanfly Engine RD - Enemy Level Control # Last Date Updated: 2009.06.13 # Level: Normal, Hard # # I actually rewrote this script three times just to make sure I'm doing things # right, and to ensure enemy levels would be a bit more manageable. Oh well... # # For those that would like enemies to grow a little bit here and there in # stats or otherwise, this script will allow for such possibilities. Enemies # will adjust their stats based on your party's levels. The stat growth can # include a set amount per level as well as a percentile amount (of the base # stats) per level. Also, functionality of "Party Level" under the enemy action # lists is now changed to reflect the enemy's current level instead of party's. # #=============================================================================== # Updates: # ---------------------------------------------------------------------------- # o 2009.06.13 - Added auto states for enemies. # o 2009.06.10 - Started script and finished. #=============================================================================== # Instructions #=============================================================================== # # The following tags will go into the enemy noteboxes: # # , , # This will determine the ruleset on how the enemy matches the party's level. # By the script's default setting, it will be adjusted to meet the party' # average level. If any of the above tags exist in the enemy's notebox, the # enemy will match their level to that setting instead. # # # If these tags exist, they will set predetermined max and minimum levels to x. # If this tag does not exist, minimum level will be 1 and maximum level will be # 99 or whatever maximum level you've defined. # # # This will force the enemy to be exactly level x. If you use any max/min level # adjustment tags, this tag will cease proper functionality. # # or # This will adjust the enemy's level by x in comparison to the party's defined # level. For insance, if an enemy has , then the enemy will always # be 5 levels above the party's average level (unless the enemy hits max level). # # or # This will adjust the stat increase per level for the enemy. "stat" needs to # be replaced by maxhp, maxmp, atk, def, spi, agi. If there is a percentage # included in the tag, it will raise the stat by a percentage of the base stats # instead of a set amount. You may use the set and percentile tags together. # To adjust the experience and gold boost, input exp and gold respectively. # # , , , # , # The above add extra traits to the enemies after they have reached level x. # They give the enemies the same functionality they would normally give actors. # # or # The above lets you give enemies auto states after they reach level x. The # auto states are determined by y. To add more auto states per level (I know # there isn't much room in the notebox), add more of the tags or use the second # tag type. # # ---------------------------------------------------------------------------- # # The following tags goes into a skill's notebox. # # # This causes the skill to affect the enemy's level by x amount. Use "+" for a # positive effect and "-" for a negative effect. This will not affect actors. # Enemies with will not be affected by this change. # # # This causes the skill to reset the target enemy's level back to what it # originally was relative to the party's highest level member. This occurs # before any enemy level changes if the same skill changes enemy levels. # #=============================================================================== # # Compatibility # - Alias: Game_Battler: skill_effect # - Alias: Game_Enemy: base_stats, conditions_met? # - Overwrites; Game_Battler: state? # #=============================================================================== $imported = {} if $imported == nil $imported["EnemyLevelControl"] = true module YE module BATTLE module ENEMY # Since there's a whole lot of max level raising scripts out there, this # will allow you to set what max level your enemies can reach. MAX_LEVEL = 99 # The following will determine the way enemies will match levels. # 0 - Matches the lowest level of the party. # 1 - Matches the average level of the party. # 2 - Matches the highest level of the party. LEVEL_MATCH = 2 # The following allows you to adjust the default percentages of growth # for the enemies if you did not give them any growth tags. GROWTH_HP = 10 GROWTH_MP = 10 GROWTH_ATK = 5 GROWTH_DEF = 5 GROWTH_SPI = 5 GROWTH_AGI = 5 # The following will adjust the default percentage increases of exp and # gold growth for the enemies if you did not use any growth tags. GROWTH_EXP = 15 GROWTH_GOLD = 15 # For those using Display Scanned Enemy, use the following to adjust a # text change to display the enemy's level on the general page. # First %s represents level. # Second %s represents enemy name. SCANNED_ENEMY_LEVEL = "Lv%s %s" end # ENEMY end # BATTLE end # YE #=============================================================================== # 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 YE module REGEXP module BASEITEM CHANGE_LEVEL = /<(?:CHANGE_ENEMY_LEVEL|change enemy level)[ ]*([\+\-]\d+)>/i RESET_LEVEL = /<(?:RESET_ENEMY_LEVEL|reset enemy level)[ ]*([\+\-]\d+)>/i end module ENEMY # The following are level-setting tags. LEVEL_SET = /<(?:LEVEL_SET|level set)[ ]*(\d+)>/i LEVEL_MAX = /<(?:LEVEL_MAX|level max)[ ]*(\d+)>/i LEVEL_MIN = /<(?:LEVEL_MIN|level min)[ ]*(\d+)>/i LEVEL_MOD = /<(?:LEVEL_MOD|level mod)[ ]*([\+\-]\d+)>/i LEVEL_LOCK = /<(?:LEVEL_LOCK|level lock)>/i MATCH_HIGH = /<(?:MATCH_HIGHEST_LEVEL|match highest level)>/i MATCH_AVG = /<(?:MATCH_AVERAGE_LEVEL|match average level)>/i MATCH_LOW = /<(?:MATCH_LOWEST_LEVEL|match lowest level)>/i # The following adjusts the growth of stats. GROWTH = /^<(?:GROWTH|stat)[ ]*(.*)[ ]([\+\-]\d+)>/i GROWTHP = /^<(?:GROWTH|stat)[ ]*(.*)[ ]([\+\-]\d+)([%%])>/i # The following adjusts the traits given to the enemies after certain levels. TRAIT_SGUARD = /<(?:SUPER_GUARD_LEVEL|super guard level)[ ]*(\d+)>/i TRAIT_FASTATK = /<(?:FAST_ATTACK_LEVEL|fast attack level)[ ]*(\d+)>/i TRAIT_DUALATK = /<(?:DUAL_ATTACK_LEVEL|dual attack level)[ ]*(\d+)>/i TRAIT_PRECRIT = /<(?:PREVENT_CRI_LEVEL|prevent cri level)[ ]*(\d+)>/i TRAIT_HALFMP = /<(?:HALF_MP_LEVEL|half mp level)[ ]*(\d+)>/i TRAIT_AUTOSTATE = /<(?:AUTO_STATE_LV|auto state lv|auto state level)[ ]*(\d+):(\d+(?:\s*,\s*\d+)*)>/i end end end #=============================================================================== # RPG::BaseItem #=============================================================================== class RPG::BaseItem #-------------------------------------------------------------------------- # Yanfly_Cache_Baseitem_ELC #-------------------------------------------------------------------------- def yanfly_cache_baseitem_elc @change_level = 0; @reset_level = false self.note.split(/[\r\n]+/).each { |line| case line when YE::REGEXP::BASEITEM::CHANGE_LEVEL @change_level = $1.to_i when YE::REGEXP::BASEITEM::RESET_LEVEL @reset_level = $1.to_i end } end #-------------------------------------------------------------------------- # definitions #-------------------------------------------------------------------------- def change_level yanfly_cache_baseitem_elc if @change_level == nil return @change_level end def reset_level yanfly_cache_baseitem_elc if @reset_level == nil return @reset_level end end #=============================================================================== # RPG::Enemy #=============================================================================== class RPG::Enemy #-------------------------------------------------------------------------- # Yanfly_Cache_Enemy_ELC #-------------------------------------------------------------------------- def yanfly_cache_enemy_elc @max_level = YE::BATTLE::ENEMY::MAX_LEVEL; @min_level = 1; @level_mod = 0 @stat_growth ={ :maxhp => 0, :maxmp => 0, :atk => 0, :def => 0, :spi => 0, :agi => 0, :exp => 0, :gold => 0, } @stat_growthp ={ :maxhp => YE::BATTLE::ENEMY::GROWTH_HP, :maxmp => YE::BATTLE::ENEMY::GROWTH_MP, :atk => YE::BATTLE::ENEMY::GROWTH_ATK, :def => YE::BATTLE::ENEMY::GROWTH_DEF, :spi => YE::BATTLE::ENEMY::GROWTH_SPI, :agi => YE::BATTLE::ENEMY::GROWTH_AGI, :exp => YE::BATTLE::ENEMY::GROWTH_EXP, :gold => YE::BATTLE::ENEMY::GROWTH_GOLD, } @level_traits ={ :sguard => @max_level + 1, :fastatk => @max_level + 1, :dualatk => @max_level + 1, :precrit => @max_level + 1, :halfmp => @max_level + 1, } @level_lock = false; @level_match = YE::BATTLE::ENEMY::LEVEL_MATCH @auto_state_level = {} self.note.split(/[\r\n]+/).each { |line| case line when YE::REGEXP::ENEMY::LEVEL_SET @max_level = $1.to_i @min_level = $1.to_i when YE::REGEXP::ENEMY::LEVEL_MAX @max_level = $1.to_i when YE::REGEXP::ENEMY::LEVEL_MIN @min_level = $1.to_i when YE::REGEXP::ENEMY::LEVEL_MOD @level_mod = $1.to_i when YE::REGEXP::ENEMY::LEVEL_LOCK @level_lock = true when YE::REGEXP::ENEMY::MATCH_HIGH @level_match = 2 when YE::REGEXP::ENEMY::MATCH_AVG @level_match = 1 when YE::REGEXP::ENEMY::MATCH_LOW @level_match = 0 when YE::REGEXP::ENEMY::GROWTH case $1.to_s when "maxhp","MAXHP"; @stat_growth[:maxhp] = $2.to_i when "maxmp","MAXMP"; @stat_growth[:maxmp] = $2.to_i when "atk","ATK"; @stat_growth[:atk] = $2.to_i when "def","DEF"; @stat_growth[:def] = $2.to_i when "spi","SPI"; @stat_growth[:spi] = $2.to_i when "agi","AGI"; @stat_growth[:agi] = $2.to_i when "exp","EXP"; @stat_growth[:exp] = $2.to_i when "gold","GOLD"; @stat_growth[:gold] = $2.to_i end when YE::REGEXP::ENEMY::GROWTHP case $1.to_s when "maxhp","MAXHP"; @stat_growthp[:maxhp] = $2.to_i when "maxmp","MAXMP"; @stat_growthp[:maxmp] = $2.to_i when "atk","ATK"; @stat_growthp[:atk] = $2.to_i when "def","DEF"; @stat_growthp[:def] = $2.to_i when "spi","SPI"; @stat_growthp[:spi] = $2.to_i when "agi","AGI"; @stat_growthp[:agi] = $2.to_i when "exp","EXP"; @stat_growthp[:exp] = $2.to_i when "gold","GOLD"; @stat_growthp[:gold] = $2.to_i end when YE::REGEXP::ENEMY::TRAIT_SGUARD @level_traits[:sguard] = $1.to_i when YE::REGEXP::ENEMY::TRAIT_FASTATK @level_traits[:fastatk] = $1.to_i when YE::REGEXP::ENEMY::TRAIT_DUALATK @level_traits[:dualatk] = $1.to_i when YE::REGEXP::ENEMY::TRAIT_PRECRIT @level_traits[:precrit] = $1.to_i when YE::REGEXP::ENEMY::TRAIT_HALFMP @level_traits[:halfmp] = $1.to_i when YE::REGEXP::ENEMY::TRAIT_AUTOSTATE i = $1.to_i @auto_state_level[i] = [] if @auto_state_level[i] == nil $2.scan(/\d+/).each { |num| @auto_state_level[i] += [num.to_i] } end } end #-------------------------------------------------------------------------- # Definitions #-------------------------------------------------------------------------- def max_level yanfly_cache_enemy_elc if @max_level == nil return @max_level end def min_level yanfly_cache_enemy_elc if @min_level == nil return @min_level end def level_mod yanfly_cache_enemy_elc if @level_mod == nil return @level_mod end def level_lock yanfly_cache_enemy_elc if @level_lock == nil return @level_lock end def level_match yanfly_cache_enemy_elc if @level_match == nil return @level_match end def stat_growth yanfly_cache_enemy_elc if @stat_growth == nil return @stat_growth end def stat_growthp yanfly_cache_enemy_elc if @stat_growthp == nil return @stat_growthp end def level_traits yanfly_cache_enemy_elc if @level_traits == nil return @level_traits end def auto_state_level yanfly_cache_enemy_elc if @auto_state_level == nil return @auto_state_level end end # RPG::Enemy #=============================================================================== # Game_Battler #=============================================================================== class Game_Battler #-------------------------------------------------------------------------- # alias skill_effect #-------------------------------------------------------------------------- alias skill_effect_elc skill_effect unless $@ def skill_effect(user, skill) skill_effect_elc(user, skill) if !self.actor? and !self.enemy.level_lock unless @missed or @evaded self.reset_level if skill.reset_level self.set_level += skill.change_level if skill.change_level != 0 end end end #-------------------------------------------------------------------------- # alias remove_state #-------------------------------------------------------------------------- alias remove_state_elc remove_state unless $@ def remove_state(state_id) return if !self.actor? and self.level_auto_states.include?(state_id) remove_state_elc(state_id) end #-------------------------------------------------------------------------- # overwrite state? #-------------------------------------------------------------------------- def state?(state_id) return states.include?($data_states[state_id]) end end # Game_Battler #=============================================================================== # Game_Enemy #=============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :set_level #-------------------------------------------------------------------------- # level #-------------------------------------------------------------------------- def level reset_level if @set_level == nil given_level = [[@set_level, enemy.max_level].min, enemy.min_level].max return given_level end #-------------------------------------------------------------------------- # reset_level #-------------------------------------------------------------------------- def reset_level case enemy.level_match when 0 # Calculate Lowest Level @set_level = YE::BATTLE::ENEMY::MAX_LEVEL for actor in $game_party.members @set_level = actor.level if @set_level > actor.level end when 1 # Calculate Average Party Level @set_level = 0 for actor in $game_party.members @set_level += actor.level end @set_level /= $game_party.members.size else # Calculate Highest Level @set_level = $game_party.max_level end @set_level += enemy.level_mod end #-------------------------------------------------------------------------- # alias base_maxhp #-------------------------------------------------------------------------- alias base_maxhp_elc base_maxhp unless $@ def base_maxhp n = base_maxhp_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:maxhp])) / 100.0 n += ((level - 1) * enemy.stat_growth[:maxhp]) return Integer(n) end #-------------------------------------------------------------------------- # alias base_maxmp #-------------------------------------------------------------------------- alias base_maxmp_elc base_maxmp unless $@ def base_maxmp n = base_maxmp_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:maxmp])) / 100.0 n += ((level - 1) * enemy.stat_growth[:maxmp]) return Integer(n) end #-------------------------------------------------------------------------- # alias base_atk #-------------------------------------------------------------------------- alias base_atk_elc base_atk unless $@ def base_atk n = base_atk_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:atk])) / 100.0 n += ((level - 1) * enemy.stat_growth[:atk]) return Integer(n) end #-------------------------------------------------------------------------- # alias base_def #-------------------------------------------------------------------------- alias base_def_elc base_def unless $@ def base_def n = base_def_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:def])) / 100.0 n += ((level - 1) * enemy.stat_growth[:def]) return Integer(n) end #-------------------------------------------------------------------------- # alias base_spi #-------------------------------------------------------------------------- alias base_spi_elc base_spi unless $@ def base_spi n = base_spi_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:spi])) / 100.0 n += ((level - 1) * enemy.stat_growth[:spi]) return Integer(n) end #-------------------------------------------------------------------------- # alias base_agi #-------------------------------------------------------------------------- alias base_agi_elc base_agi unless $@ def base_agi n = base_agi_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:agi])) / 100.0 n += ((level - 1) * enemy.stat_growth[:agi]) return Integer(n) end #-------------------------------------------------------------------------- # alias exp #-------------------------------------------------------------------------- alias exp_elc exp unless $@ def exp n = exp_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:exp])) / 100.0 n += ((level - 1) * enemy.stat_growth[:exp]) return Integer(n) end #-------------------------------------------------------------------------- # alias gold #-------------------------------------------------------------------------- alias gold_elc gold unless $@ def gold n = gold_elc n *= (100 + ((level - 1) * enemy.stat_growthp[:gold])) / 100.0 n += ((level - 1) * enemy.stat_growth[:gold]) return Integer(n) end #-------------------------------------------------------------------------- # new super_guard #-------------------------------------------------------------------------- def super_guard return true if (level - 1) > enemy.level_traits[:sguard] return super end #-------------------------------------------------------------------------- # new fast_attack #-------------------------------------------------------------------------- def fast_attack return true if (level - 1) > enemy.level_traits[:fastatk] return super end #-------------------------------------------------------------------------- # new dual_attack #-------------------------------------------------------------------------- def dual_attack return true if (level - 1) > enemy.level_traits[:dualatk] return super end #-------------------------------------------------------------------------- # new prevent_critical #-------------------------------------------------------------------------- def prevent_critical return true if (level - 1) > enemy.level_traits[:precrit] return super end #-------------------------------------------------------------------------- # new half_mp_cost #-------------------------------------------------------------------------- def half_mp_cost return true if (level - 1) > enemy.level_traits[:halfmp] return super end #-------------------------------------------------------------------------- # states #-------------------------------------------------------------------------- def states result = super for id in level_auto_states result.push($data_states[id]) unless result.include?($data_states[id]) end result.sort! { |a, b| b.priority <=> a.priority } return result end #-------------------------------------------------------------------------- # level_auto_states #-------------------------------------------------------------------------- def level_auto_states state_ids = [] for key in enemy.auto_state_level if self.level >= key[0] state_ids += key[1] end end return state_ids end #-------------------------------------------------------------------------- # alias conditions_met? #-------------------------------------------------------------------------- alias conditions_met_elc conditions_met? unless $@ def conditions_met?(action) case action.condition_type == 5 when 5 # Change functionality to match level instead. if (level - 1) < action.condition_param1 return false else return true end else return conditions_met_elc(action) end end end # Game_Enemy #=============================================================================== # # END OF FILE # #===============================================================================