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.
[VXA] 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.0
Author: modern algebra
Date: January 4, 2012

Version History


  • <Version 1.0> 2012.01.04 - 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

  • Each individual battler of an enemy can have varying stats
  • Can set variance either directly or by percentile

Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials.

Script


Code: [Select]
#==============================================================================
#    Enemy Stat Variance
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: January 4, 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  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.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Paste this script into its own slot in the Script Editor, above Main but
#   below Materials.
#
#    Just place the code for each of the stat variances you want into the notes
#   box of the Enemy in the Database. The possible codes are:

#      \vary_hp[x]
#      \vary_mp[x]
#      \vary_atk[x]
#      \vary_def[x]
#      \vary_mat[x]
#      \vary_mdf[x]
#      \vary_agi[x]
#      \vary_luk[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, instead of being added on, you want the variance to be by percentage,
#   then all you need to do is add a percentile sign:
#
#      \vary_hp[x%]
#      \vary_mp[x%]
#      \vary_atk[x%]
#      \vary_def[x%]
#      \vary_mat[x%]
#      \vary_mdf[x%]
#      \vary_agi[x%]
#      \vary_luk[x%]
#
#   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
#
#    Additionally, it should be noted that these are stackable; it would be
#   valid, for instance to have one enemy have this in its notebox:
#      \vary_hp[10%]\vary_hp[30]
#==============================================================================

$imported = {} unless $imported
$imported[:MA_EnemyStatVariance] = true

#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new public instance variable - maesv_add_params
#    new method - initialize_maesv_data
#==============================================================================

class RPG::Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :maesv_add_params
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Initialize Enemy Stat Variance Data
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize_maesv_data
    @maesv_add_params = []
    # Scan note for Variance Codes
    note.scan(/\\VARY[ _](.+?)\[(\d+)(%?)\]/i) {|param_n, value, percent|
      param_id = ["HP", "MP", "ATK", "DEF", "MAT", "MDF", "AGI", "LUK"].index(param_n.upcase)
      @maesv_add_params << [param_id, value.to_i + 1, !percent.empty?] if param_id
    }
  end
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - initialize; all_features
#==============================================================================

class Game_Enemy < Game_Battler
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maesv_initialze_4gj1 initialize
  def initialize(*args, &block)
    @maesv_percent_params = [] # Initialize Percentile Params array
    maesv_initialze_4gj1(*args, &block)
    # Add to stats according to variance in notes
    enemy.initialize_maesv_data unless enemy.maesv_add_params
    enemy.maesv_add_params.each {|param_id, value, percent_true|
      if percent_true # Percentile
        @maesv_percent_params << RPG::BaseItem::Feature.new(FEATURE_PARAM,
          param_id, 1.0 + (rand(value).to_f / 100.0))
      else            # Add the randomized value to the parameter
        add_param(param_id, rand(value))
      end
    }
    recover_all # Ensure the enemy is at full strength
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * All Features
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias maesv_allfeatrs_5jk6 all_features
  def all_features(*args, &block)
    result = maesv_allfeatrs_5jk6(*args, &block) # Run Original Method
    result + @maesv_percent_params
  end
end

Credit


  • modern algebra

Support


Please report any bugs or make any suggestions with respect to this script in this topic at RMRK.

Known Compatibility Issues

Any bestiary will likely not reflect the potential variance in stats unless it is specifically coded in.
« Last Edit: January 06, 2012, 02:58:41 AM by modern algebra »

****
Rep:
Level 69
This is very nice for changing up battle a little bit.

"Why doesn't this freaking toad die! ..and why is it doing so much damage!!!" G_G

Edit: Is there any way you could make a 'master control' of stats, like a stat controller for each stat that changes stats for all mobs? Like if I were to set variation of strength from, let's say +10-30 then all mobs would have that variation?
« Last Edit: April 16, 2012, 05:30:50 AM by Scalinger2 »