Gold Drop Variance
Version: 1.0
Author: modern algebra
Date: April 22, 2011
Version History
- <Version 1.0> 04.23.2011 - Original Release
Description
Gold drops in RMVX are static by default, with every creature always dropping the exact same amount every time you kill them. This script allows you to change that by making them drop a random amount between values that you choose.
Features
- Creatures don't always drop the same amount
- Can set a default variance globally and tweak it for individual creatures, if you desire
- Can set it by percentage or by a set amount
- Very easy to configure
Instructions
Paste this script into its own slot in the Script Editor (F11), above Main but below any other custom scripts. For instructions on how to use it, please see the header of the script.
Script
#==============================================================================
# Gold Drop Variance
# Version: 1.0
# Author: modern algebra (rmrk.net)
# Date: April 22, 2011
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
#
# Gold drops in RMVX are static by default, with every creature always
# dropping the exact same amount every time you kill them. This script allows
# you to change that by making them drop a random amount between values that
# you choose.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
#
# Paste this script into its own slot in the Script Editor (F11), above Main
# and below other custom scripts.
#
# To set this script up, go to line 42 and set the default variance. That is
# the default amount the gold drops could vary by when you kill a monster. If
# you want it so that the variance is different for specific monsters, then
# all you need to do is put the following code in those monster's note box:
#
# \var_gold[x]
#
# Where x is the integer you want the drop to vary by. That will set it so
# that the drop for that monster will vary between the normal drop and the
# normal drop + x. So, if it is 10 and the enemy is set to 20, then it will
# drop between 20 and 29 gold. You could also set it by percent with the code:
#
# \var_gold[y%]
#
# Where y is the percent you want it to vary by. That will set it so the
# monster will drop between the normal drop and the normal drop + y%. So, if
# it is set to 25 and the enemy is set to 20, then it will drop between 20 and
# 24 gold (since 25% of 20 is 5).
#
# If you want to change the note box code, go to line 50.
#==============================================================================
#\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
# EDITABLE REGION
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# MAGDV_DEFAULT_VARIANCE - This is the default amount gold drops will vary by.
# If it is an integer, then it will vary between the set amount and this. If
# you make it a float (20.0 rather than 20), then it will vary by that percent
# of the set amount (ie. if the set amount is 160 and this value is set to 20.0,
# then the amount dropped will be between 160 and 191. (since 20% of 160 is 32)
# If you want some enemies to have a different variance, you just need to tag
# it in their noteboxes (see lines 19 - 35).
MAGDV_DEFAULT_VARIANCE = 20.0
# MAGDV_REGEXP - You shouldn't need to modify this; all this does is allow you
# to change the notebox code which you can use to change the specific variance
# for enemies. The default value is "VAR_GOLD", meaning the code \var_gold[x]
# will be the notebox code. If you change it to "VG", for instance, the code
# would be \vg[x]. It is up to you.
MAGDV_REGEXP = "VAR_GOLD"
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# END EDITABLE REGION
#//////////////////////////////////////////////////////////////////////////////
$imported = {} if !$imported
$imported["MAGoldDropVariance"] = true
#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - gold
#==============================================================================
class RPG::Enemy
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Gold
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mlgb_luk_gld_9og1 gold unless self.method_defined? (:mlgb_luk_gld_9og1)
def gold (*args, &block)
gld = mlgb_luk_gld_9og1 (*args, &block) # Run Original Method
add = gold_variance
if add.is_a? (Float)
add = ((gld*add) / 100).to_i
end
return gld + (rand (add))
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Gold Variance
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def gold_variance
if !@gold_variance
@gold_variance = MAGDV_DEFAULT_VARIANCE
if self.note[/#{MAGDV_REGEXP}\[(\d+)(%?)\]/i] != nil
@gold_variance = $2.empty? ? $1.to_i : $1.to_f
end
end
return @gold_variance
end
end
Credit
Support
If you have any suggestions or need support for this script, please post in this thread on RMRK, no matter how old it is. I will do my best to assist you.
Author's Notes
This is the first script I decided to use the $imported convention. It's also probably the least likely to ever need special compatibility measures taken for it. Oh well! It's a good idea to use it and I probably should have started earlier.