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.
Gold Drop Variance

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2010 Most Mature Member2010 Favourite Staff Member
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


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


  • modern algebra

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.
« Last Edit: April 23, 2011, 12:37:09 AM by modern algebra »

*
The Hero of Rhyme
Rep:
Level 83
( ͡° ͜ʖ ͡°)
2014 Queen of RMRK2014 Best RPG Maker User - StoryProject of the Year 20142011 Best Newbie2014 Best RPG Maker User - Creativity2014 Kindest Member2013 Queen of RMRKBronze SS AuthorBronze Writing ReviewerSecret Santa 2013 ParticipantFor taking arms in the name of your breakfast.GOOD!For frequently finding and reporting spam and spam bots2012 Best Yuyubabe Smiley2012 Best RPG Maker User (Creativity);o
Wow! What a great idea to add a little spruce to any game. Good job, MA! :)
Spoiler for My Games and Art:
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]


***
Rep:
Level 74
I'm baaack!
greate script

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
If you keep writing awesome scripts, I'll keep having to add to my scripts list.
Damn your creativity and innovative mind! I'm probably using more of your scripts that my own.
But then again, I've only written like 5. And you have slightly more. Just a little.
Another great script MA.
it's like a metaphor or something i don't know

**
Rep: +0/-0Level 74
RMRK Junior
Great script idea, I'm having a problem though. Could you perhaps have the gold round up? After every battle, I've been getting around 23.xxxxxxxxxxx gold.

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2010 Most Mature Member2010 Favourite Staff Member
That's very strange. Are you sure it is from this script or might you have another one that influences gold drop? Because my script already accounts for that here:

Code: [Select]

    if add.is_a? (Float)
      add = ((gld*add) / 100).to_i
    end

the .to_i converts it from a decimal to an integer. In my testing, I was unable to reproduce this error.

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Hey, MA... May I post a VXA port of this? I keep doing your scripts because they're all useful and actually pretty easy, so I may be asking this question a lot over the next couple of weeks ._.
it's like a metaphor or something i don't know

*
Rep:
Level 97
2014 Best RPG Maker User - Engine2014 Most Unsung Member2013 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 Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2010 Most Mature Member2010 Favourite Staff Member
Sure, I wasn't intending to port this one since I incorporated it into Drop Options

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Best IRC Quote2014 Zero to Hero2014 Most Missed Member2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
Oh, haha. I didn't realize that ._.
That does make sense though, now that I think about it. Eh, I guess there's no real point in posting it now. I'll just do something else.
it's like a metaphor or something i don't know