#==============================================================================
# ** Dynamic Enemies
#------------------------------------------------------------------------------
# SephirothSpawn
# Version 3.01
# 2007-05-11
# SDK : Version 2.0+, Part 1
#------------------------------------------------------------------------------
# * Version History :
#
# Version 1 ---------------------------------------------------- (2006-08-06)
# Version 2 ---------------------------------------------------- (2006-10-07)
# - Update : Updated to work with Trickster's Curve Generator Module
# Version 3 ---------------------------------------------------- (2007-02-28)
# - Update : Rescripted entire system
# Version 3.01 ------------------------------------------------ (2007-05-11)
# - Bug Fix : Fixed Extremely Minor Base Stat Level Error
#------------------------------------------------------------------------------
# * Requirements :
#
# Method & Class Library 2.1+
#------------------------------------------------------------------------------
# * Description
#
# This script was designed to allow your game to have enemies that develope
# as your actors do. No longer will you encounter the same old boring enemy
# each time. As the developer, you can control the development of each stat
# for each enemy. The script assigns the enemy a semi-random and controled
# level depending on the party's average level. The stats are then pulled
# from a generated curve based of your definitions.
#------------------------------------------------------------------------------
# * Instructions
#
# Place The Script Below the SDK and Above Main.
# To Customize your enemy stats, refer to the customization instructions.
#------------------------------------------------------------------------------
# * Customization
#
# Setting unaffected enemies
# - Unaffected_Enemies = [enemy_id, enemy_id, ...]
#
# Setting enemy stats
# - Stats = {
# enemy_id => { <stat_name> => [ generator_type, *args ], ... }
# , ...
# }
#
# Stat Names : 'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int', 'atk',
# 'pdef', 'mdef', 'eva', 'hit', 'exp', 'gold'
#
# ** Refer to Curve Generator System for type and args specification.
#
# Enemy Min & Max Level
# - Min_Levels = { enemy_id => min_level, ... }
# - Max_Levels = { enemy_id => max_level, ... }
#
# Default Min & Max Level (For all non-defined enemies)
# - Min_Levels.default = min_level
# - Max_Levels.default = max_level
#
# Range For Enemy Levels Off Party Level
# - Level_Ranges = { enemy_id => (min_v..max_v), ... }
#
# Range For Enemy Levels Off Party Level (For all non-defined enemies)
# - Level_Ranges.default = (min_v..max_v)
#--------------------------------------------------------------------------
# * Syntax :
#
# Enemy Level
# - <game_enemy>.level
#
# Dynamic Enemies
# - <game_enemy>.is_dynamic?
#==============================================================================
#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Dynamic Enemies', 'SephirothSpawn', 3.01, '2007-05-11')
SDK.check_requirements(2.0, [], {'Method & Class Library' => 2.1})
#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.enabled?('Dynamic Enemies')
#==============================================================================
# ** Dynamic_Enemies
#==============================================================================
module Dynamic_Enemies
#--------------------------------------------------------------------------
# * Saves Curves
#
# ~ @cache = { <generator_setup> => <curve>, ... }
#--------------------------------------------------------------------------
@cache = {}
#--------------------------------------------------------------------------
# * Unaffected Enemies
#
# ~ Unaffected_Enemies = [enemy_id, enemy_id, ...]
#--------------------------------------------------------------------------
Unaffected_Enemies = []
#--------------------------------------------------------------------------
# * Stats
#
# ~ enemy_id => { <stat_name> => [ generator_type, *args ], ... }
#
# Stat Names : 'maxhp', 'maxsp', 'str', 'dex', 'agi', 'int', 'atk',
# 'pdef', 'mdef', 'eva', 'hit', 'exp', 'gold'
#
# ** Refer to Curve Generator System for type and args specification.
#--------------------------------------------------------------------------
Stats = {
2 => {
'maxhp' => [0, 1, 99, 500, 150], 'maxsp' => [0, 1, 99, 200, 75], 'str' => [0, 1, 99, 50, 10],
'dex' => [0, 1, 99, 50, 10], 'agi' => [0, 1, 99, 50, 10], 'int' => [0, 1, 99, 50, 10]
}
}
#--------------------------------------------------------------------------
# * Defaults : BE CAREFUL WITH ALTERATION
#--------------------------------------------------------------------------
Stats.default = {}
# Default For All Non-Defined Stats
Stats.default.default = [0, 1, 99, 500, 220]
Stats.values.each do |stat_settings|
# Default For All Non-Defined Stats For Defined Enemies
stat_settings.default = [0, 1, 99, 500, 220]
end
#--------------------------------------------------------------------------
# * Level Specifications
#
# Enemy Min & Max Level
# - Min_Levels = { enemy_id => min_level, ... }
# - Max_Levels = { enemy_id => max_level, ... }
#
# Default Min & Max Level (For all non-defined enemies)
# - Min_Levels.default = min_level
# - Max_Levels.default = max_level
#
# Range For Enemy Levels Off Party Level
# - Level_Ranges = { enemy_id => (min_v..max_v), ... }
#
# Range For Enemy Levels Off Party Level (For all non-defined enemies)
# - Level_Ranges.default = (min_v..max_v)
#--------------------------------------------------------------------------
Min_Levels = {}
Max_Levels = {}
Level_Ranges = {}
Min_Levels.default = 1
Max_Levels.default = 99
Level_Ranges.default = (-3..3)
#--------------------------------------------------------------------------
# * Get Base Stat
#--------------------------------------------------------------------------
def self.get_base_stat(enemy_id, stat_name, level)
# Gets Curve Data
curve_data = Stats[enemy_id][stat_name]
# Checks For Pre-defined Curve
if @cache.has_key?(curve_data)
return @cache[curve_data][level]
end
# Creates Curve Data
curve = Curve_Generator.generate_curve(*curve_data)
# Save Curve
@cache[curve_data] = curve
# Return Stat
return curve[level]
end
#--------------------------------------------------------------------------
# * Generate Level
#--------------------------------------------------------------------------
def self.generate_level(enemy_id)
# Collect Average Party Level
level = 0
$game_party.actors.each {|a| level += a.level}
level /= $game_party.actors.size
# Cap Level
level = [[level, Min_Levels[enemy_id]].max, Max_Levels[enemy_id]].min
# Modifies Level
level += Level_Ranges[enemy_id].random
# Return Level Data
return level
end
end
#==============================================================================
# ** Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :level
#--------------------------------------------------------------------------
# * Alias Listings
#--------------------------------------------------------------------------
alias_method :seph_dynenemies_gmenmy_init, :initialize
alias_method :seph_dynenemies_gmenmy_maxhp, :base_maxhp
alias_method :seph_dynenemies_gmenmy_maxsp, :base_maxhp
alias_method :seph_dynenemies_gmenmy_str, :base_str
alias_method :seph_dynenemies_gmenmy_dex, :base_dex
alias_method :seph_dynenemies_gmenmy_agi, :base_agi
alias_method :seph_dynenemies_gmenmy_int, :base_int
alias_method :seph_dynenemies_gmenmy_atk, :base_atk
alias_method :seph_dynenemies_gmenmy_eva, :base_eva
alias_method :seph_dynenemies_gmenmy_pdef, :base_pdef
alias_method :seph_dynenemies_gmenmy_mdef, :base_mdef
alias_method :seph_dynenemies_gmenmy_exp, :exp
alias_method :seph_dynenemies_gmenmy_gold, :gold
#--------------------------------------------------------------------------
# * Is Dynamic
#--------------------------------------------------------------------------
def is_dynamic?(enemy_id = @enemy_id)
return Dynamic_Enemies::Stats.has_key?(enemy_id)
end
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(troop_id, member_index)
# Gets Enemy ID
enemy_id = $data_troops[troop_id].members[member_index].enemy_id
# Set Level
@level = Dynamic_Enemies.generate_level(enemy_id)
# Setup Dynamic Enemy
setup_dynamic_enemy(enemy_id) if is_dynamic?(enemy_id)
# Original Initialization
seph_dynenemies_gmenmy_init(troop_id, member_index)
end
#--------------------------------------------------------------------------
# * Setup Dynamic Enemy
#--------------------------------------------------------------------------
def setup_dynamic_enemy(enemy_id)
# Set Dynamic Stats
@dyn_base_maxhp = Dynamic_Enemies.get_base_stat(enemy_id, 'hp', @level)
@dyn_base_maxsp = Dynamic_Enemies.get_base_stat(enemy_id, 'sp', @level)
@dyn_base_str = Dynamic_Enemies.get_base_stat(enemy_id, 'str', @level)
@dyn_base_dex = Dynamic_Enemies.get_base_stat(enemy_id, 'dex', @level)
@dyn_base_agi = Dynamic_Enemies.get_base_stat(enemy_id, 'agi', @level)
@dyn_base_int = Dynamic_Enemies.get_base_stat(enemy_id, 'int', @level)
@dyn_base_atk = Dynamic_Enemies.get_base_stat(enemy_id, 'atk', @level)
@dyn_base_eva = Dynamic_Enemies.get_base_stat(enemy_id, 'eva', @level)
@dyn_base_pdef = Dynamic_Enemies.get_base_stat(enemy_id, 'pdef', @level)
@dyn_base_mdef = Dynamic_Enemies.get_base_stat(enemy_id, 'mdef', @level)
@dyn_gold = Dynamic_Enemies.get_base_stat(enemy_id, 'gold', @level)
@dyn_exp = Dynamic_Enemies.get_base_stat(enemy_id, 'exp', @level)
end
#--------------------------------------------------------------------------
# * Get Basic Maximum HP
#--------------------------------------------------------------------------
def base_maxhp
return is_dynamic? ? @dyn_base_maxhp : seph_dynenemies_gmenmy_maxhp
end
#--------------------------------------------------------------------------
# * Get Basic Maximum SP
#--------------------------------------------------------------------------
def base_maxsp
return is_dynamic? ? @dyn_base_maxsp : seph_dynenemies_gmenmy_maxsp
end
#--------------------------------------------------------------------------
# * Get Basic Strength
#--------------------------------------------------------------------------
def base_str
return is_dynamic? ? @dyn_base_str : seph_dynenemies_gmenmy_str
end
#--------------------------------------------------------------------------
# * Get Basic Dexterity
#--------------------------------------------------------------------------
def base_dex
return is_dynamic? ? @dyn_base_dex : seph_dynenemies_gmenmy_dex
end
#--------------------------------------------------------------------------
# * Get Basic Agility
#--------------------------------------------------------------------------
def base_agi
return is_dynamic? ? @dyn_base_agi : seph_dynenemies_gmenmy_agi
end
#--------------------------------------------------------------------------
# * Get Basic Intelligence
#--------------------------------------------------------------------------
def base_int
return is_dynamic? ? @dyn_base_int : seph_dynenemies_gmenmy_int
end
#--------------------------------------------------------------------------
# * Get Basic Attack Power
#--------------------------------------------------------------------------
def base_atk
return is_dynamic? ? @dyn_base_atk : seph_dynenemies_gmenmy_atk
end
#--------------------------------------------------------------------------
# * Get Basic Physical Defense
#--------------------------------------------------------------------------
def base_pdef
return is_dynamic? ? @dyn_base_pdef : seph_dynenemies_gmenmy_pdef
end
#--------------------------------------------------------------------------
# * Get Basic Magic Defense
#--------------------------------------------------------------------------
def base_mdef
return is_dynamic? ? @dyn_base_mdef : seph_dynenemies_gmenmy_mdef
end
#--------------------------------------------------------------------------
# * Get Basic Evasion
#--------------------------------------------------------------------------
def base_eva
return is_dynamic? ? @dyn_base_eva : seph_dynenemies_gmenmy_eva
end
#--------------------------------------------------------------------------
# * Exp
#--------------------------------------------------------------------------
def exp
return is_dynamic? ? @dyn_exp : seph_dynenemies_gmenmy_exp
end
#--------------------------------------------------------------------------
# * Gold
#--------------------------------------------------------------------------
def gold
return is_dynamic? ? @dyn_gold : seph_dynenemies_gmenmy_gold
end
end
#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end