Enemy Stat Variance
Version: 1.1
Author: modern algebra
Date: September 26, 2008
Version History
- <Version 1.1> 09/26/08 Added the ability to use random percentile
- <Version 1.0> 09/08/08 Original Release
Description
This script allows you to attach a variance to each enemy stat, so that enemy instances aren't all just clones of each other but can have stat differences.
Features
- Enemies of the same type aren't just clones of each other.
- Allows you to set variance for each of the stats of each enemy individually
- Allows you to use percentile increase in addition to definite numbers
- Intuitive configuration
Screenshots
N/A
Instructions
See inside Script Header
Script
#==============================================================================
# Enemy Stat Variance
# Version: 1.1
# Author: modern algebra
# Date: September 26, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# Just place the code for each of the stat variances you want into the notes
# box of the Enemy. The possible codes are:
#
# \variance_hp[x]
# \variance_mp[x]
# \variance_atk[x]
# \variance_def[x]
# \variance_spi[x]
# \variance_agi[x]
# \variance_hp%[x]
# \variance_mp%[x]
# \variance_atk%[x]
# \variance_def%[x]
# \variance_spi%[x]
# \variance_agi%[x]
#
# Each of the codes will give a variance of x to the stat chosen. A variance
# x means that the enemy will have a random number between 0 and x added to
# its base stat. So, if the base stat set in the database is 120, and x is
# set to 30, then that stat will be between 120 and 150 for any instance of
# that enemy. So, if you are fighting two slimes, then one of them could have
# that stat be 127 while the other has it at 142, for example.
#
# If the codes have a percentage to them, then it will take a random number
# between 0 and x and add that percentage of the stat to the enemy's stat. So,
# if an enemy's max HP is 200 and you set \variance_hp%[10], then the script
# will choose a random number between 0 and 10. In this case, let's say it
# chooses 6, then .06*200 will be added to the enemy's HP, resulting in that
# enemy having 212 HP
#==============================================================================
# ** Game_Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased method - initialize
#==============================================================================
class Game_Enemy < Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_varystat_enmy_init_9hd4 initialize
def initialize (index, enemy_id)
modalg_varystat_enmy_init_9hd4 (index, enemy_id)
# Add to stats according to variance in notes
text = enemy.note.dup
# Dissect Note
while text[/\\variance_.*\[\d+\]/i]
text.sub!(/\\variance_(.*)\[(\d+)\]/i) { "" }
random_num = rand ($2.to_i)
case $1.to_s
when /HP%/i then @maxhp_plus += ((random_num.to_f / 100.0)*self.maxhp).to_i
when /MP%/i then @maxmp_plus += ((random_num.to_f / 100.0)*self.maxmp).to_i
when /ATK%/i then @atk_plus += ((random_num.to_f / 100.0)*self.atk).to_i
when /DEF%/i then @def_plus += ((random_num.to_f / 100.0)*self.def).to_i
when /SPI%/i then @spi_plus += ((random_num.to_f / 100.0)*self.spi).to_i
when /AGI%/i then @agi_plus += ((random_num.to_f / 100.0)*self.agi).to_i
when /HP/i then @maxhp_plus += random_num
when /MP/i then @maxmp_plus += random_num
when /ATK/i then @atk_plus += random_num
when /DEF/i then @def_plus += random_num
when /SPI/i then @spi_plus += random_num
when /AGI/i then @agi_plus += random_num
end
end
@hp = maxhp
@mp = maxmp
end
end
Credit
Support
Please post in this topic at rmrk.net for any support you may need. Also, if you have any suggestions, then please tell me - I am always looking for ways to improve my scripts.
Known Compatibility Issues
No known compatibility issues.
Demo
Not useful or necessary.
I've always loved your scripts, modern algebra, and this is no exception. This replaces a similar script I used for RMXP functionality back in the day... kudos, good sir.
umm you have an error on line 46...
/SP <=should be /MP right?
and also maxsp_plus should be maxmp_plus
right? I was just trying it out and it crashed on a battle test where I was adding mp to monsters
Ah, yes you are correct
Thanks for pointing it out
Can you add an option that allows you to use percentages in addition to the current script for variance?
Sure. Give me a second.
EDIT::
After class - I got distracted. I will write the extension for you in an hour or two.
Thanks =D
oh, and it's done. I forgot to announce that :-X
Awesome script. ;)
Umm you used the SP instead of MP again
[spoiler]
#==============================================================================
# Enemy Stat Variance
# Version: 1.1
# Author: modern algebra
# Date: September 26, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Instructions:
# Just place the code for each of the stat variances you want into the notes
# box of the Enemy. The possible codes are:
#
# \variance_hp[x]
# \variance_mp[x]
# \variance_atk[x]
# \variance_def[x]
# \variance_spi[x]
# \variance_agi[x]
# \variance_hp%[x]
# \variance_mp%[x]
# \variance_atk%[x]
# \variance_def%[x]
# \variance_spi%[x]
# \variance_agi%[x]
#
# Each of the codes will give a variance of x to the stat chosen. A variance
# x means that the enemy will have a random number between 0 and x added to
# its base stat. So, if the base stat set in the database is 120, and x is
# set to 30, then that stat will be between 120 and 150 for any instance of
# that enemy. So, if you are fighting two slimes, then one of them could have
# that stat be 127 while the other has it at 142, for example.
#
# If the codes have a percentage to them, then it will take a random number
# between 0 and x and add that percentage of the stat to the enemy's stat. So,
# if an enemy's max HP is 200 and you set \variance_hp%[10], then the script
# will choose a random number between 0 and 10. In this case, let's say it
# chooses 6, then .06*200 will be added to the enemy's HP, resulting in that
# enemy having 212 HP
#==============================================================================
# ** Game_Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Summary of Changes:
# aliased method - initialize
#==============================================================================
class Game_Enemy < Game_Battler
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_varystat_enmy_init_9hd4 initialize
def initialize (index, enemy_id)
modalg_varystat_enmy_init_9hd4 (index, enemy_id)
# Add to stats according to variance in notes
text = enemy.note.dup
# Dissect Note
while text[/\\variance_.*\[\d+\]/i]
text.sub!(/\\variance_(.*)\[(\d+)\]/i) { "" }
random_num = rand ($2.to_i)
case $1.to_s
when /HP%/i then @maxhp_plus += ((random_num.to_f / 100.0)*self.maxhp).to_i
when /MP%/i then @maxmp_plus += ((random_num.to_f / 100.0)*self.maxmp).to_i
when /ATK%/i then @atk_plus += ((random_num.to_f / 100.0)*self.atk).to_i
when /DEF%/i then @def_plus += ((random_num.to_f / 100.0)*self.def).to_i
when /SPI%/i then @spi_plus += ((random_num.to_f / 100.0)*self.spi).to_i
when /AGI%/i then @agi_plus += ((random_num.to_f / 100.0)*self.agi).to_i
when /HP/i then @maxhp_plus += random_num
when /MP/i then @maxmp_plus += random_num
when /ATK/i then @atk_plus += random_num
when /DEF/i then @def_plus += random_num
when /SPI/i then @spi_plus += random_num
when /AGI/i then @agi_plus += random_num
end
end
@hp = maxhp
@mp = maxmp
end
end
[/spoiler]
I just changed all the sp to mp XD
You're right. I'm too stuck in RMXP :(
Can we get this to work with gold and experience from the enemy?
It would be very easy, but for exp it might not be prudent, as it possibly results in harder enemies giving less exp and easy enemies giving more. It might make more sense to develop an algorithm based on the pluses given.