diff --git a/DropHelper.cs b/DropHelper.cs
index 3ca55a60b6..cc80348cb2 100644
--- a/DropHelper.cs
+++ b/DropHelper.cs
@@ -10,6 +10,7 @@ namespace CalamityMod
{
public class DropHelper
{
+ #region Extra Boss Bags
///
/// The number of extra loot bags bosses drop when Revengeance Mode is active.
///
@@ -29,11 +30,14 @@ namespace CalamityMod
/// The number of extra loot bags bosses drop when Armageddon is active.
///
public static int ArmageddonExtraBags = 5;
+ #endregion
+ #region Defiled Drop Chance Boost
///
/// This is the value that Defiled Rune boosts certain drop chances to (a decimal number <= 1.0).
///
public static float DefiledChanceBoost = 0.05f;
+ #endregion
#region Boss Bag Drop Helper
///
@@ -95,7 +99,7 @@ namespace CalamityMod
return bagsDropped;
}
-#endregion
+ #endregion
#region NPC Item Drops 100% Chance
///
@@ -107,7 +111,7 @@ namespace CalamityMod
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItem(NPC npc, int itemID, bool dropPerPlayer = false, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItem(NPC npc, int itemID, bool dropPerPlayer, int minQuantity = 1, int maxQuantity = 0)
{
int quantity;
@@ -153,11 +157,11 @@ namespace CalamityMod
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
/// Whether the drop should be "instanced" (each player gets their own copy).
- /// The chance that the items will drop. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will drop. A decimal number <= 1.0.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemChance(NPC npc, int itemID, bool dropPerPlayer = false, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(NPC npc, int itemID, bool dropPerPlayer, float chance, int minQuantity = 1, int maxQuantity = 0)
{
// If you fail the roll to get the drop, stop immediately.
if (Main.rand.NextFloat() > chance)
@@ -171,11 +175,11 @@ namespace CalamityMod
///
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
- /// The chance that the items will drop. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will drop. A decimal number <= 1.0.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemChance(NPC npc, int itemID, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(NPC npc, int itemID, float chance, int minQuantity = 1, int maxQuantity = 0)
{
return DropItemChance(npc, itemID, false, chance, minQuantity, maxQuantity);
}
@@ -188,11 +192,11 @@ namespace CalamityMod
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
/// Whether the drop should be "instanced" (each player gets their own copy).
- /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemChance(NPC npc, int itemID, bool dropPerPlayer = false, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(NPC npc, int itemID, bool dropPerPlayer, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
// If you fail the roll to get the drop, stop immediately.
if (Main.rand.Next(oneInXChance) != 0)
@@ -206,11 +210,11 @@ namespace CalamityMod
///
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
- /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemChance(NPC npc, int itemID, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(NPC npc, int itemID, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
return DropItemChance(npc, itemID, false, oneInXChance, minQuantity, maxQuantity);
}
@@ -227,7 +231,7 @@ namespace CalamityMod
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer = false, bool condition = true, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer, bool condition, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItem(npc, itemID, dropPerPlayer, minQuantity, maxQuantity) : 0;
}
@@ -241,7 +245,7 @@ namespace CalamityMod
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool condition = true, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool condition, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItem(npc, itemID, false, minQuantity, maxQuantity) : 0;
}
@@ -253,11 +257,11 @@ namespace CalamityMod
/// The ID of the item(s) to drop.
/// Whether the drop should be "instanced" (each player gets their own copy).
/// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
- /// The chance that the items will drop. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will drop. A decimal number <= 1.0.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer = false, bool condition = true, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer, bool condition, float chance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(npc, itemID, dropPerPlayer, chance, minQuantity, maxQuantity) : 0;
}
@@ -268,11 +272,11 @@ namespace CalamityMod
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
/// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
- /// The chance that the items will drop. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will drop. A decimal number <= 1.0.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool condition = true, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool condition, float chance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(npc, itemID, false, chance, minQuantity, maxQuantity) : 0;
}
@@ -284,11 +288,11 @@ namespace CalamityMod
/// The ID of the item(s) to drop.
/// Whether the drop should be "instanced" (each player gets their own copy).
/// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
- /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer = false, bool condition = true, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool dropPerPlayer, bool condition, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(npc, itemID, dropPerPlayer, oneInXChance, minQuantity, maxQuantity) : 0;
}
@@ -299,11 +303,11 @@ namespace CalamityMod
/// The NPC which should drop the item(s).
/// The ID of the item(s) to drop.
/// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
- /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to drop. Defaults to 1.
/// The maximum number of items to drop. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items dropped.
- public static int DropItemCondition(NPC npc, int itemID, bool condition = true, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(NPC npc, int itemID, bool condition, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(npc, itemID, false, oneInXChance, minQuantity, maxQuantity) : 0;
}
@@ -335,15 +339,15 @@ namespace CalamityMod
}
///
- /// Spawns a stack of one or more items for the given player.
+ /// At a chance, spawns a stack of one or more items for the given player.
///
/// The player which should receive the item(s).
/// The ID of the item(s) to spawn.
- /// The chance that the items will spawn. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will spawn. A decimal number <= 1.0.
/// The minimum number of items to spawn. Defaults to 1.
/// The maximum number of items to spawn. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items spawned.
- public static int DropItemChance(Player p, int itemID, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(Player p, int itemID, float chance, int minQuantity = 1, int maxQuantity = 0)
{
// If you fail the roll to get the drop, stop immediately.
if (Main.rand.NextFloat() > chance)
@@ -353,15 +357,15 @@ namespace CalamityMod
}
///
- /// Spawns a stack of one or more items for the given player.
+ /// At a chance, spawns a stack of one or more items for the given player.
///
/// The player which should receive the item(s).
/// The ID of the item(s) to spawn.
- /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to spawn. Defaults to 1.
/// The maximum number of items to spawn. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items spawned.
- public static int DropItemChance(Player p, int itemID, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemChance(Player p, int itemID, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
// If you fail the roll to get the drop, stop immediately.
if (Main.rand.Next(oneInXChance) != 0)
@@ -381,7 +385,7 @@ namespace CalamityMod
/// The minimum number of items to spawn. Defaults to 1.
/// The maximum number of items to spawn. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items spawned.
- public static int DropItemCondition(Player p, int itemID, bool condition = true, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(Player p, int itemID, bool condition, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItem(p, itemID, minQuantity, maxQuantity) : 0;
}
@@ -392,11 +396,11 @@ namespace CalamityMod
/// The player which should receive the item(s).
/// The ID of the item(s) to spawn.
/// Any arbitrary Boolean condition to gate this spawn. If false, nothing is spawned.
- /// The chance that the items will spawn. A decimal number <= 1.0. Defaults to 1.0.
+ /// The chance that the items will spawn. A decimal number <= 1.0.
/// The minimum number of items to spawn. Defaults to 1.
/// The maximum number of items to spawn. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items spawned.
- public static int DropItemCondition(Player p, int itemID, bool condition = true, float chance = 1f, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(Player p, int itemID, bool condition, float chance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(p, itemID, chance, minQuantity, maxQuantity) : 0;
}
@@ -407,14 +411,282 @@ namespace CalamityMod
/// The player which should receive the item(s).
/// The ID of the item(s) to spawn.
/// Any arbitrary Boolean condition to gate this spawn. If false, nothing is spawned.
- /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance. Defaults to 1.
+ /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance.
/// The minimum number of items to spawn. Defaults to 1.
/// The maximum number of items to spawn. Defaults to 0, meaning the minimum quantity is always used.
/// The number of items spawned.
- public static int DropItemCondition(Player p, int itemID, bool condition = true, int oneInXChance = 1, int minQuantity = 1, int maxQuantity = 0)
+ public static int DropItemCondition(Player p, int itemID, bool condition, int oneInXChance, int minQuantity = 1, int maxQuantity = 0)
{
return condition ? DropItemChance(p, itemID, oneInXChance, minQuantity, maxQuantity) : 0;
}
#endregion
+
+ #region NPC Item Set Drops
+ ///
+ /// Chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSet(NPC npc, bool dropPerPlayer, params int[] itemIDs)
+ {
+ // Can't choose anything from an empty array.
+ if (itemIDs is null || itemIDs.Length == 0)
+ return false;
+
+ // Choose which item to drop.
+ int itemID = Main.rand.Next(itemIDs);
+
+ // If the drop is supposed to be instanced, drop it as such.
+ if (dropPerPlayer)
+ {
+ npc.DropItemInstanced(npc.position, npc.Size, itemID);
+ }
+ else
+ {
+ Item.NewItem(npc.Hitbox, itemID);
+ }
+
+ return true;
+ }
+
+ ///
+ /// Chooses an item from an array and drops it from the given NPC.
+ ///
+ /// The NPC which should drop the item.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSet(NPC npc, params int[] itemIDs)
+ {
+ return DropItemFromSet(npc, false, itemIDs);
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// The chance that the items will drop. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(NPC npc, bool dropPerPlayer, float chance, params int[] itemIDs)
+ {
+ // If you fail the roll to get the drop, stop immediately.
+ if (Main.rand.NextFloat() > chance)
+ return false;
+
+ return DropItemFromSet(npc, dropPerPlayer, itemIDs);
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and drops it from the given NPC.
+ ///
+ /// The NPC which should drop the item.
+ /// The chance that the items will drop. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(NPC npc, float chance, params int[] itemIDs)
+ {
+ return DropItemFromSetChance(npc, false, chance, itemIDs);
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(NPC npc, bool dropPerPlayer, int oneInXChance, params int[] itemIDs)
+ {
+ // If you fail the roll to get the drop, stop immediately.
+ if (Main.rand.Next(oneInXChance) != 0)
+ return false;
+
+ return DropItemFromSet(npc, dropPerPlayer, itemIDs);
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and drops it from the given NPC.
+ ///
+ /// The NPC which should drop the item.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(NPC npc, int oneInXChance, params int[] itemIDs)
+ {
+ return DropItemFromSetChance(npc, false, oneInXChance, itemIDs);
+ }
+ #endregion
+
+ #region NPC Item Set Drops Conditional
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool dropPerPlayer, bool condition, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSet(npc, dropPerPlayer, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool condition, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSet(npc, false, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will drop. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool dropPerPlayer, bool condition, float chance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(npc, dropPerPlayer, chance, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will drop. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool condition, float chance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(npc, false, chance, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Whether the drop should be "instanced" (each player gets their own copy).
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool dropPerPlayer, bool condition, int oneInXChance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(npc, dropPerPlayer, oneInXChance, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition, chooses an item from an array and drops it from the given NPC. Optionally spawns one copy of this drop per player.
+ ///
+ /// The NPC which should drop the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will drop is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ public static bool DropItemFromSetCondition(NPC npc, bool condition, int oneInXChance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(npc, false, oneInXChance, itemIDs) : false;
+ }
+ #endregion
+
+ #region Player Item Set Spawns
+ ///
+ /// Chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSet(Player p, params int[] itemIDs)
+ {
+ // Can't choose anything from an empty array.
+ if (itemIDs is null || itemIDs.Length == 0)
+ return false;
+
+ // Choose which item to drop.
+ int itemID = Main.rand.Next(itemIDs);
+
+ p.QuickSpawnItem(itemID);
+ return true;
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// The chance that the items will spawn. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(Player p, float chance, params int[] itemIDs)
+ {
+ // If you fail the roll to get the drop, stop immediately.
+ if (Main.rand.NextFloat() > chance)
+ return false;
+
+ return DropItemFromSet(p, itemIDs);
+ }
+
+ ///
+ /// At a chance, chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was dropped.
+ public static bool DropItemFromSetChance(Player p, int oneInXChance, params int[] itemIDs)
+ {
+ // If you fail the roll to get the drop, stop immediately.
+ if (Main.rand.Next(oneInXChance) != 0)
+ return false;
+
+ return DropItemFromSet(p, itemIDs);
+ }
+ #endregion
+
+ #region Player Item Set Spawns Conditional
+ ///
+ /// With a condition, chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was spawned.
+ public static bool DropItemFromSetCondition(Player p, bool condition, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSet(p, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition and at a chance, chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will spawn. A decimal number <= 1.0.
+ /// The array of items to choose from. If it's null or empty, nothing will be dropped.
+ /// Whether an item was spawned.
+ public static bool DropItemFromSetCondition(Player p, bool condition, float chance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(p, chance, itemIDs) : false;
+ }
+
+ ///
+ /// With a condition and at a chance, chooses an item from an array and spawns it for the given player.
+ ///
+ /// The player which should receive the item.
+ /// Any arbitrary Boolean condition to gate this drop. If false, nothing is dropped.
+ /// The chance that the items will spawn is 1 in this number. For example, 5 gives a 1 in 5 chance.
+ /// The array of items to choose from. If it's null or empty, nothing will be spawned.
+ /// Whether an item was spawned.
+ public static bool DropItemFromSetCondition(Player p, bool condition, int oneInXChance, params int[] itemIDs)
+ {
+ return condition ? DropItemFromSetChance(p, oneInXChance, itemIDs) : false;
+ }
+ #endregion
}
}