RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Enemy Stat Variance

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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


Code: [Select]
#==============================================================================
#  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


  • modern algebra

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.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
« Last Edit: February 11, 2010, 09:52:48 PM by Modern Algebra »

**
Rep:
Level 88
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.

**
Rep:
Level 84
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

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Ah, yes you are correct

Thanks for pointing it out

**
Rep:
Level 85
Can you add an option that allows you to use percentages in addition to the current script for variance?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Sure. Give me a second.

EDIT::

After class - I got distracted. I will write the extension for you in an hour or two.
« Last Edit: September 26, 2008, 02:55:31 PM by modern algebra »

**
Rep:
Level 85

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
oh, and it's done. I forgot to announce that  :-X


**
Rep:
Level 84
Umm you used the SP instead of MP again
Spoiler for:
Code: [Select]
#==============================================================================
#  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

I just changed all the sp to mp XD

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
You're right. I'm too stuck in RMXP :(

**
Rep: +0/-0Level 84
Can we get this to work with gold and experience from the enemy?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
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.