← Back to all addons

"Add Range" Action for commands + Min-Max Chest Loot!

Posted by Soho on Jun 10, 2025 at 6:41 AM

FeatureEditor
💡 3 eyesshaking 1

See comments for Chest loot implementation

Creates an “Add Range” option in actions to Add or Remove Item and Add or Remove Money commands!

For example, in my projects case and in the example photo below, cutting trees and mining ores gives a range of 1-3 resources.

*Note: The inspector always shows Quanity, Min and Max despite your selection, but these are only enabled based on the action selected. I’m unsure how to nest these.. I plan on extending this further with percentage changes as well, once I learn some more and can tidy things up I’ll create a package and share it here

In EAction.cs Create AddRange

using System;

namespace Gyvr.Mythril2D
{
    [Serializable]
    public enum EAction
    {
        Add,
        Remove,
        AddRange
    }
}

For AddOrRemoveItem.cs, add:

        [SerializeField] private int m_minQuantity; 
        [SerializeField] private int m_maxQuantity; 

… ``` case EAction.AddRange: int randomQuantity = UnityEngine.Random.Range(m_minQuantity, m_maxQuantity + 1); GameManager.InventorySystem.AddToBag(m_item, randomQuantity, EItemTransferType.Command); break; }


For **AddOrRemoveMoney.cs**, add:
```csharp
        [SerializeField] private int m_minAmount; 
        [SerializeField] private int m_maxAmount; 

                case EAction.AddRange:
                    int randomAmount = UnityEngine.Random.Range(m_minAmount, m_maxAmount + 1);
                    GameManager.InventorySystem.AddMoney(randomAmount);
                    break;
            }

That’s all! You can now add a touch of luck to your entities 🙂

“Add Range” Action for commands + Min-Max Chest Loot!

Min-Max Chest Loot! Note: This uses an alternative approach and removes the quanity option entirely from chests. If you want a specific amount to drop, simply set the min and max as the same value.

Replace Chest.cs and ChestLoot.cs

If anyone has a tidier approach please let me know 🙂

📜 Scripts

💬 Comments (2)

MrMystery Jul 15, 2025 at 03:04 PM
This was great, awesome inspiration - but you asked so check out <#1394477177721979010> - one SO can be used on Monsters and Chests (there’s a related post) … but allows min/max - as well as level based loot tables - weighted loot tables - scaling gold based on character/monster level … etc… check it out!
🔥 1
Soho Jul 16, 2025 at 03:55 AM
Much better approach! Lovely stuff as always. I’ll take this down soon 🙂 cheers

Want to continue the conversation?