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] Drop Options

0 Members and 2 Guests are viewing this topic.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Drop Options
Version: 1.1.0
Author: modern algebra
Date: 23 September 2012

Version History


  • <Version 1.1.0> 2012.09.23 - Added switch conditions and repeat shortcuts. I also fixed a bug where the amount of gold reported differed from the amount of gold received by the party.
  • <Version 1.0> 2011.12.19 - Original Release

Description


This script is designed to make enemy item drops a little less static in a few ways. It allows you to make an enemy that drops more than three types of items, allows you to set a range of gold that can drop rather than a fixed number, and permits you to limit the number of these extra drops that can fall from a single enemy, so you can set a monster to drop any of a number of potential items without running the risk that one enemy will drop every single one of them.

Features

  • More than three drops per enemy
  • Can place switch conditions such that something will only drop if a specified switch is on (useful for fetch quests)
  • Can cap the amount of extra drops, allowing you, for instance, to ensure that a boss that will drop one of three rare items, but only one
  • For the extra drops, you can set the chance by percentile (25%) rather than by denominator (1 in 4)
  • Can randomize the amount of gold dropped by an enemy.
  • Easy notebox configuration

Instructions

Paste this script into its own slot in the Script Editor, above Main but below Materials. It should also be below all other custom scripts.

Please see the header for instructions on configuring the script in more detail, but I will give a sample setup for one enemy, using all three new notebox codes. Say this is one enemy who is setup in the database with a 1 in 10 chance to drop a potion and will drop 5 gold when it is killed. Add this into its notebox

    \drop[w5, 10, s4]\drop[i21, 15%]*2\drop[a6, 22%]
    \max_drops[1]
    \gold[7]

What that will do is give the monster an additional 1 in 10 chance to drop the weapon with ID 5 (but only if switch 4 is ON), two additional 15% chances to drop the item with ID 21, and an additional 22% chance to drop the armor with ID 6. However, the max drops code will limit it to 1 drop, so of those three items, only one can ever drop. That does not limit the potion set up in the default way though, as that is unaffected. So you could get one potion and one of those three items from the same enemy.

Finally, the \gold[7] code will mean that the enemy will drop an additional amount of gold between 0 and 7. Since the enemy is already set to drop 5 gold, this means that any time you kill this enemy, it will drop between 5 and 12 gold.

Script


Code: [Select]
#==============================================================================
#    Drop Options
#    Version: 1.1.0
#    Author: modern algebra (rmrk.net)
#    Date: 23 September 2012
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script is very simple. All it does is allow you to make item drops a
#   little less static in some very simple ways:
#
#     (a) you can make more than three drops for each enemy, so enemies can 
#       drop a greater variety of loot;
#     (b) you can place a cap on the amount of these extra drops, so if you
#       want a boss to have a 100% chance of dropping one of three items, but 
#       only one, then you can do that;
#     (c) you can use percentile rather than denominator based drops; and
#     (d) you can randomize the amount of gold dropped by setting a range
#       within which it can fall.
#
#    If you are using any scripts that show loot drops of enemies (such as a
#   bestiary), the effects of this script will not be correctly reflected in
#   that without direct modifications. If you are using such a script, please
#   feel free to post a link to it in this script's thread in RMRK and I will
#   write a patch for it.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below any other scripts in the Script
#   Editor (F11).
#
#    All configuration happens in the note boxes of enemies. If you wish to add
#   a new drop, place this code in a note box for the enemy:
#
#      \drop[type id, probability]
#        type        : the type, either I (for Item), W (for Weapon), or A (for
#                     Armor).
#        id          : This is the ID of the item, weapon, or armor.
#        probability : This is the probability the item, weapon, or armor will
#                     drop. If you put a % sign after the number, then it will
#                     drop that percentage of the time. If not, then the number
#                     you put here will be the denominator, same as with
#                     regular drops. The number has to be an integer.
#    EXAMPLES:
#      \drop[i1, 65%]
#          This will mean that the item with ID 1 (Potion by default) will drop
#         65% of the time when you kill this enemy.
#      \drop[a5, 8]
#          This will mean that the armor with ID 5 (Mithril Shield by default)
#         will drop 1/8 times you kill this enemy.
#
#    Those are the mandatory arguments, but you can also make it so that the
#   drop will only be available if a specific switch is on by adding s0 after
#   the probability, where 0 is replaced by the ID of the switch.
#
#      \drop[type id, probability, s0]
#  EXAMPLES:
#
#      \drop[w4, 4, s2]
#          This will mean that the weapon with ID 4 will drop 1/4 times you
#         kill the enemy, but only if switch 2 is currently on. Otherwise, it
#         will never drop.
#
#    Finally, if you want it to be possible that more than one of the same item
#   will drop (with the same conditions), you can simply add *n after the drop
#   code, where n is replaced by the number of items you want it to be possible
#   to drop.
#
#  EXAMPLES:
#      \drop[a2, 10%]*2
#          This gives two chances to get Armor 2 at 10% probability.
#
#    To set a maximum on the number of extra drops (note that this only applies
#   to extra drops set up in the note field - the two default drops are exempt
#   from this cap), you can use the code:
#
#      \max_drop[x]
#         x : the maximum amount of extra drops that you want.
#   EXAMPLE:
#    If an enemy is set up like this:
#      \drop[w3, 100%]
#      \drop[w4, 100%]
#      \max_drop[1]
#    Then that means that the enemy will definitely drop either Weapon 3
#   (Spear) or Weapon 4 (Short Sword), but will not drop both since
#   the \max_drop code prevents it from dropping more than one of the notebox
#   drops.
#
#    To randomize the amount of gold an enemy drops, place the following code
#   in its note box:
#
#      \gold[variance]
#        variance : this is an integer, and the amount of gold dropped is
#          calculated by randomly selecting a number between 0 and this value,
#          and then adding it to the regular gold drop you set in the database.
#    EXAMPLE:
#      If an enemy has 5 gold set as its drop in the database, then the
#     following note:
#        \gold[12]
#      will mean that the enemy will drop anywhere between 5 and 17 gold upon
#     its death.
#==============================================================================

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

#==============================================================================
# ** RPG::Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - gold
#    new method - random_gold; extra_drops; max_drop
#==============================================================================

class RPG::Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Gold
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_drpopt_gold_2go9 gold
  def gold(*args, &block)
    (rand(ma_random_gold + 1)) + ma_drpopt_gold_2go9(*args, &block)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Random Gold
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_random_gold
    (@ma_rand_gold = self.note[/\\GOLD\[(\d+)\]/i] != nil ? $1.to_i : 0) if !@ma_rand_gold
    @ma_rand_gold
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Extra Drops
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_extra_drops
    if @ma_extra_drops.nil?
      @ma_extra_drops = []
      self.note.scan(/\\DROP\[\s*([IWA])\s*(\d+)\s*[,;:]?\s*(\d+)(%?)\s*[,;:]?\s*S?\s*(\d*)\]\*?(\d*)/i).each { |match|
        drop = RPG::Enemy::DropItem.new
        i = ['I', 'W', 'A'].index(match[0].upcase)
        drop.kind = i.nil? ? 0 : i + 1
        drop.data_id = match[1].to_i
        drop.denominator = match[3].empty? ? match[2].to_i : match[2].to_f
        num = match[5].empty? ? 1 : match[5].to_i
        num.times do @ma_extra_drops.push([match[4].to_i, drop]) end
      }
    end
    @ma_extra_drops.select {|di| di[0] == 0 || $game_switches[di[0]] }.collect {|di| di[1] }
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Max Drops
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_max_drops
    if !@ma_max_drops
      @ma_max_drops = self.note[/\\MAX[ _]DROPS?\[(\d+)\]/i].nil? ? 999 : $1.to_i
    end
    @ma_max_drops
  end
end

#==============================================================================
# ** Game_Enemy
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - make_drop_items
#    new method - ma_make_extra_drops
#==============================================================================

class Game_Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Make Drop Items
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mlg_dropopt_makedrops_5rx9 make_drop_items
  def make_drop_items(*args, &block)
    # Run Original Method and add the new drops
    mlg_dropopt_makedrops_5rx9(*args, &block) + ma_make_extra_drops
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Make Extra Drops
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def ma_make_extra_drops
    result = []
    enemy.ma_extra_drops.each { |di|
      if di.kind > 0
        bool = di.denominator.is_a?(Integer) ? (rand * di.denominator < drop_item_rate) : (rand(100) < (di.denominator * drop_item_rate))
        result.push(item_object(di.kind, di.data_id)) if bool
      end
    }
    while result.size > enemy.ma_max_drops
      result.delete_at(rand(result.size))
    end
    result
  end
end

#==============================================================================
# ** Game_Troop
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - setup; gold_total
#==============================================================================

class Game_Troop
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Setup
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mado_setp_3ra2 setup
  def setup(*args, &block)
    @mado_gold_total = nil # Clear gold total
    mado_setp_3ra2(*args, &block) # Call original method
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Gold Total
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mado_goldtot_2tg5 gold_total
  def gold_total(*args, &block)
    #  Save first calculation to ensure consistency between amount received and
    # amount reported to the player
    @mado_gold_total = mado_goldtot_2tg5(*args, &block) unless @mado_gold_total
    @mado_gold_total # Return the saved total
  end
end

Credit


  • modern algebra

Thanks

  • cozziekuns, for suggesting the switch condition feature
  • wsensor, for suggesting the repeat feature
  • TempusMight, for identifying a bug

Support


Please post in this topic at RMRK if you have any questions, suggestions, or error reports. I will do my best to assist you in a timely manner.
« Last Edit: September 23, 2012, 05:10:04 PM by modern algebra »

*****
Rep:
Level 84
This text is way too personal.
Bronze - GIAW 11 (Hard)Silver - GIAW Halloween
This is really neat MA! One suggestion that I have is to make it so that certain items only drop when a certain condition is met, such as if a switch is on. For instance, there might be a one of a kind legendary sword that you can only get by killing slimes, and you don't want that sword to drop twice.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
That's a good idea. I will add it.

**
Rep:
Level 84
Question about additional drop ideas.

Additional drop options:
Original option from your current script. \drop[i1, 65%]
Suggested change \drop[i1, 65%, Z] where Z is a number lets say its 3 would allow you to have a chance to get up to 3 copies of item 1 at 65% chance on each. (This could be useful instead of people putting 3 of the \drop[i1, 65%] tags to give a chance of getting 3 of said items.

Accessories/weapons/states that when equipped allows for a chance to drop a special item(s) or increase chances of drops.
Tag for on Accessories/Armors/states that when equipped allows to change the max drop # of a mob. IE: /maxdropincrease(#) where # could be 1,2,3 etc.
Tag for on Accessories/Armors/states that when equipped to allow for a chance to increase drops of certain items. IE: Monster can drop potion at a chance of 50% a tag would allow for an additional potion to be dropped at 25% or something like that.

Tag for on Skills/Weapons that when used to kill an enemy there is a chance to gain an item on enemy death or at end of the battle. (Both options would be very cool.)

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Those are good ideas. When I update this script, I will take them into account.

**
Rep: +0/-0Level 81
RMRK Junior
ok so is it actually possible to have some extra drops to be limited (one out of 3) but others unlimited in the same enemy

eg a boss drops one of 3 weapons but also drops several different items

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Kind of. The max drop items only affects the drops that are added through this script, so the three drops you can add in the default way are unaffected. So you could have a one out of three situation for drops you add in the notebox, but then also have the three default methods act independently and possibly drop none or all of them.

I figured that would be enough for most people so that's why I went with that limitation, but it would certainly be possible to rescript it and change the feature so that you can set that kind of limitation only on a few.

**
Rep: +0/-0Level 81
RMRK Junior
ok thx for the response

**
Rep:
Level 73
.
i wonder if there is a chance to add an option.
Like, item will only drop, when certain switch is on, if variable is larger or smaller than something.

example:
\drop[type id, probability, condition[type, switch.id or variable.id with condition]]

\drop[i90, 100%, [1, 5]]
Item with id=90 will always drop if switch with id=5 is on.

\drop[i90, 100%, [2, 6>10]]
Item with id=90 will always drop if variable with id 6 has a value larger than 10.

I came with that idea while playing Gothic II, when you learn how to skin animals, then some enemies will drop their skins/hides.
« Last Edit: March 09, 2012, 08:19:44 PM by B-LAzer »

****
Rep:
Level 69
I like this for randomized gold drop. It would also be nice if there was an experience randomizer too. :police:

*****
my name is Timothy what's yours
Rep:
Level 79
Hello
2014 Most Missed Member2014 Zero to Hero2014 Best IRC Quote2012 Zero To HeroSecret Santa 2012 ParticipantContestant - GIAW 9For frequently finding and reporting spam and spam bots2011 Zero to Hero
I like this for randomized gold drop. It would also be nice if there was an experience randomizer too. :police:
Sorry for taking the storm, MA, but this would do that:
Code: [Select]
class RPG::Enemy < RPG::BaseItem
  alias ma_drpopt_exp_2go9 exp
  def exp(*args, &block)
    (rand(ma_random_exp + 1)) + ma_drpopt_exp_2go9(*args, &block)
  end
  def ma_random_exp
    (@ma_rand_exp = self.note[/\\EXP\[(\d+)\]/i] != nil ? $1.to_i : 0) if !@ma_rand_exp
    @ma_rand_exp
  end
end

Untested, should work. Basically took what MA had for gold and said exp instead :D
it's like a metaphor or something i don't know

****
Rep:
Level 69
I like this for randomized gold drop. It would also be nice if there was an experience randomizer too. :police:
Sorry for taking the storm, MA, but this would do that:
Code: [Select]
class RPG::Enemy < RPG::BaseItem
  alias ma_drpopt_exp_2go9 exp
  def exp(*args, &block)
    (rand(ma_random_exp + 1)) + ma_drpopt_exp_2go9(*args, &block)
  end
  def ma_random_exp
    (@ma_rand_exp = self.note[/\\EXP\[(\d+)\]/i] != nil ? $1.to_i : 0) if !@ma_rand_exp
    @ma_rand_exp
  end
end

Untested, should work. Basically took what MA had for gold and said exp instead :D
I'll test it out.
(Copy, paste, change, that's how I made mods on minecraft.)  :lol:

Edit: It worked, thanks.
« Last Edit: April 16, 2012, 02:28:11 PM by Scalinger2 »

*
Rep: +0/-0Level 70
RMRK Junior
First off, thank you for the great script(s). I've been following your work for ages. ;D

Secondly, I'm not sure if I have ran into a bug or if it is some kind of mistake on my part. On multiple enemies, I've noticed a difference in what the battle messages says for gold drops and what is actually handed out. It appears to be rather minor, but it's a reoccuring issue. Simply put, the battle says I obtained 3G, whilst it gives 2G.

Here are the note tags I used for two of the enemies I had an issue with. I don't know if you need the script, or at least a certain part of the script to check if maybe something is tweaked on my end, but I simply copy/pasted the sucker and let it run. Let me know if so.  ;)

\category[2]
\gold[3]


and...


\category[2]
\gold[2]
\desc{A common pest of undefined ooze. Said to have
\N originated in Gaia.}

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
I updated the script to version 1.1.0. This update adds a feature to put a condition on some drops such that they will only drop if a specified switch is on. Additionally, I added a shortcut where you could easily repeat the same drop by placing *n after the code.

Also, I fixed the bug that TempusMight identified where the reported gold was different from the received gold.

**
Rep: +0/-0Level 81
RMRK Junior
is it possible to add different drops depending on weapon, item, skill, actor or class that kills the enemy?

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Not with this script, no.