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

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
Drop Options
Version: 1.1
Author: modern algebra
Date: September 11, 2010

Version History


  • <Version 1.1> 09.11.2010 - Simplified the setup by using words for the type rather than numbers, and added a new option to limit the amount of notebox drops any one enemy can drop.
  • <Version 1.0> 09.07.2010 - Original Release

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 two 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 (the limit only applies to drops set up in the note box, not to ones setup in the default way); and (c) you can randomize the amount of gold dropped by setting a range within which it can fall.

Features

  • Infinite number of drops
  • Can set likelihood of drop either by denominator or by percentage
  • Can set a limit on how many of these extra drops any given enemy can drop, thus allowing you to do things like have a boss able to drop many different rare items, but ensure that it only drops one of them
  • Can randomize the amount of gold dropped by an enemy

Instructions

Paste this script into its own slot in the Script Editor, somewhere above Main but below the default scripts. See the header of the script for instructions on how to add the special properties to the enemies.

Script


Code: [Select]
#==============================================================================
#    Drop Options
#    Version: 1.1
#    Author: modern algebra (rmrk.net)
#    Date: September 11, 2010
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  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 two 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; and
#   (c) 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 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.
#
#    This script may not work with some custom battle systems, particularly
#   ones that do not use troops.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  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 Item, Weapon, or Armor. Armour is also
#                     accepted.
#        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[Item 1, 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[armor 5, 8]
#          This will mean that the armor with ID 5 (Mithril Shield by default)
#         will drop 1/8 times you kill this enemy.
#
#    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[weapon 20, 100%]
#      \drop[weapon 21, 100%]
#      \max_drop[1]
#    Then that means that the enemy will definitely drop either Weapon 20
#   (Mythril Spear) or Weapon 21 (Mythril Blade), 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.
#==============================================================================

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

class RPG::Enemy
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Gold
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_drpopt_gold_2go9 gold unless self.method_defined? (:ma_drpopt_gold_2go9)
  def gold (*args)
    return (rand (random_gold + 1)) + ma_drpopt_gold_2go9 (*args)
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Random Gold
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def random_gold
    (@rand_gold = self.note[/\\GOLD\[(\d+)\]/i] != nil ? $1.to_i : 0) if !@rand_gold
    return @rand_gold
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Extra Drops
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def extra_drops
    if @extra_drops.nil?
      @extra_drops = []
      self.note.gsub (/\\DROP\[(item|weapon|armou?r)\s*(\d+),?\s*(\d+)(%?)\]/i) {
        drop = RPG::Enemy::DropItem.new
        case $1.downcase
        when "item"
          drop.kind = 1
          drop.item_id = $2.to_i
        when "weapon"
          drop.kind = 2
          drop.weapon_id = $2.to_i
        else
          drop.kind = 3
          drop.armor_id = $2.to_i
        end
        drop.denominator = $4.empty? ? $3.to_i : $3.to_f
        @extra_drops.push (drop)
      }
    end
    return @extra_drops
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Max Drops
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def max_drops
    if !@max_drops
      @max_drops = self.note[/\\MAX[ _]DROPS?\[(\d+)\]/i].nil? ? 999 : $1.to_i
    end
    return @max_drops
  end
  # If using Note Editor
  if self.method_defined? (:ma_reset_note_values)
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    # * Reset Note Values
    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    alias mala_nedo_restnte_9yn2 ma_reset_note_values
    def ma_reset_note_values (*args)
      mala_nedo_restnte_9yn2 (*args) # Run Original Method
      @rand_gold, @extra_drops, @max_drops = nil, nil, nil
    end
  end
end

#==============================================================================
# ** Game_Troop
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - make_drop_items
#==============================================================================

class Game_Troop
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Create Array of Dropped Items
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mlgb_drpop_mkeitm_4rx1 make_drop_items
  def make_drop_items (*args)
    drop_items = mlgb_drpop_mkeitm_4rx1 (*args)
    for enemy in dead_members
      ie_drops = []
      for di in enemy.enemy.extra_drops
        next if di.kind == 0
        if di.denominator.is_a? (Float)
          next if rand (100) > di.denominator
        else
          next if rand(di.denominator) != 0
        end
        case di.kind
        when 1 then ie_drops.push($data_items[di.item_id])
        when 2 then ie_drops.push($data_weapons[di.weapon_id])
        when 3 then ie_drops.push($data_armors[di.armor_id])
        end
      end
      while ie_drops.size > enemy.enemy.max_drops
        ie_drops.delete_at (rand (ie_drops.size))
      end
      drop_items += ie_drops
    end
    return drop_items
  end
end

Credit


  • modern algebra

Support


Please post in this topic at RMRK if you encounter any problems with this script or have any suggestions for improvement. Do not PM me, no matter how old the topic is.

Known Compatibility Issues

It will likely not work with some custom battle systems, particularly ones that do not use troops.

Also, bestiary scripts or others that show loot information on enemies will not accurately reflect the properties this script adds. If you want it to, then please post a link to the script you are using and I will see if I can modify it to show the effects of this script.
« Last Edit: September 11, 2010, 07:00:10 PM by modern algebra »

*
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
Updated to Version 1.1

In this version, I changed the way that notes are set up. Instead of:

\drop[type, id, percent], where type is either 0, 1, or 2, I changed it so that you use the word instead. So, where you would have written:

\drop[1, 5, 50%]

you would write:
\drop[weapon 5, 50%]

I think that makes it simpler. In addition, I have added a new feature where you can limit the amount of extra drops (\max_drop[x]). This allows you to do things like have a boss able to drop many different rare items, but ensure that it only drops one of them. Thus, if you have a notebox like the following:

Code: [Select]
\drop[weapon 20, 100%]
\drop[weapon 21, 100%]
\max_drop[1]
Then that means that the enemy will definitely drop either Weapon 20 (Mythril Spear) or Weapon 21 (Mythril Blade), but will not drop both since the \max_drop code prevents it from dropping more than one of the notebox drops.

The limit only applies to drops set up in the note field, not drops set up in the normal way.

**
Rep:
Level 84
0.o hmm this looks nice.
I was using kgc's extra item drop script but yours has a max drop feature.
I like yours better lol.

I made 3 test enemies using kgc's drop and ended up with 13 items lol.
That s too many for 1 kill session since they were all using a 1/15 chance to be an extra drop. 2 main items and 3 with the script lol. (Even though the rest of the tests dropped less items.)
Built in gold randomizer is a plus too.

I might switch to this one lol. I love your scripts.

Testing this now lol.
I do not plan to use and bestiary/item type scripts. (Figure it out yourselves lol! Actually I had originally thought of using one but I would have to put too many hide tags in the notes field lol.)
« Last Edit: September 17, 2010, 06:24:49 AM by wsensor »

*
Rep: +0/-0Level 25
Hey, I love the script but I'm trying to use a bestiary and I really want to use this script and the bestiary in the game. Can you make a patch or a fix for these scripts please?
Scripts are:

Fantasy Bestiary v3.7 by Shadowmaster9000
            http://www.crimson-castle.co.uk/rpgmakerscripts/FantasyBestiaryV3-7.txt
Word Wrapping Message Boxes by KilloZapit (Needed for bestiary script)
            http://www.rpgmakercentral.com/topic/6964-word-wrapping-message-boxes/

Sorry that I can't put the scripts here, the Fantasy Bestiary script is really big for some reason.

Thank you very much!