This tutorial explains what Drop Item Sets are and how they can be used to create unique conditions for obtaining item drops from enemies.
Script: Drop Item Sets
What is it?
A “Drop Item Set” (or simply, “drop set”) is an object that manages drop items.
- What drops can be obtained from an enemy, and
- What conditions must be met to obtain these drops
A single enemy can have multiple drop sets, each with different items and different conditions. This allows you to control when and how conditions are dropped based on any type of conditions that you can imagine.
Creating a drop set
It is easy to create a drop set. Simply note-tag an enemy with
<drop-item set> drops: 1, 2, 3 priority: 1 condition: your_formula </drop-item set>
`drops` specifies which drop items will be assigned to that set. The numbers are based on the enemy’s list of drop items, 1 being the first drop item on the list (ie: Potion). You can assign the same drop multiple times to a set, allowing the player to receive the same item multiple times.
`priority` determines the order that drop sets are checked. When a battle is won, the game will pick one valid drop set to reward drops from. Higher priority sets are checked before lower priority sets, so you can use the priority to determine which sets should be checked first.
`condition` is used to determine whether a drop set is valid. A drop set is valid only if the condition is met. If there is no condition, then it is valid. The condition is any valid ruby formula that returns true or false. There are special variables available for your formulas; refer to the script for more information.
Example: Quest Drops
Suppose you are designing a quest where you are asked to collect some Slime Pudding that are dropped by Slime monsters. You want these slimes to be regular monsters in a dungeon that you can encounter at any time, but you also want the slimes to drop the Slime Pudding only when the quest is activated (Switch 14 is ON)
You have decided that the slimes will drop two items normally: Potions, and Hi-Potions. You also want these slimes to drop the puddings with a 100% droprate when the quest is active.
So here are the slime’s drops and their droprates:
- Potion – 50%
- Hi-Potion – 25%
- Slime Pudding – 100%
The slime has a 100% chance to drop the pudding, which means if you have to collect 20 puddings, then you only have to find and defeat 20 slimes. However, if the pudding has a droprate of 100%, how can you control it so that they only drop when Switch 14 is ON?
Using Drop Item Conditions
A nice solution is to use Drop Item Sets and attach conditions to them. You can create two groups of drops: the first group is the normal drops that you receive whenever you defeat a slime. The second group is used when the quest is activated. Here is a possible setup
Group 1: Potion, Hi-Potion
<drop-item set> drops: 1, 2 priority: 1 </drop-item set>
Group 2: Potion, Hi-Potion, Slime Pudding
<drop-item set> drops: 1, 2, 3 priority: 10 condition: s == true </drop-item set>
There are two things to notice in our setup.
First, is the priority. When the quest is active, we want to receive slime puddings whenever a slime is defeated. Because the drop sets are checked in order of priority, we want the second group to be checked first so that the game doesn’t randomly choose the first group that doesn’t have any pudding.
Second, is the condition. In our second group, we have the condition that Switch 14 must be ON. This means that if switch 14 was not ON (ie: the quest hasn’t started, or is finished), then we will never receive Slime Puddings from the slimes because the second drop set will never be picked.
This example assumes you can only collect Slime Pudding from Slime enemies, but you can use the same setup to have multiple enemies drop Slime Pudding easily. For example, maybe you have five different Slime-type monsters and you want all of them to drop Slime Puddings when the quest is active.
As demonstrated above, drop item sets allow you to accurately describe what drops should be available under certain circumstances. By using powerful formulas, you can create a variety of unique events in your game that could not be done before without putting a lot of effort into finding workarounds.