1. i was looking at LootConfig json and cs files and was trying to understand why it never gets MaxAmount value on drops, when i looked to this code on compiled oxide files and i think i found why:
    Code:
    public class ItemAmountRanged : ItemAmount
    {
        [...]
        public override float GetAmount()
        {
            if ((this.maxAmount > 0f) && (this.maxAmount > base.amount))
            {
                return Random.Range(base.amount, this.maxAmount); <--- here
            }
            return base.amount;
        }
        [...]
    }public class LootSpawn : ScriptableObject
    {
        [...]
        // Methods
        public void SpawnIntoContainer(ItemContainer container)
        {
            if ((this.subSpawn != null) && (this.subSpawn.Length > 0))
            {
                this.SubCategoryIntoContainer(container);
            }
            else if (this.items != null)
            {
                foreach (ItemAmountRanged ranged in this.items)
                {
                    if (ranged != null)
                    {
                        Item item = ItemManager.CreateByItemID(ranged.itemid, (int) ranged.GetAmount(), 0L); <--- here
                        if ((item != null) && !item.MoveToContainer(container, -1, true))
                        {
                            item.Remove(0f);
                        }
                    }
                }
            }
        }    public Item SpawnRandomItem()
        {
            if ((this.subSpawn != null) && (this.subSpawn.Length > 0))
            {
                return this.SpawnSubCategory();
            }
            if (this.items != null)
            {
                foreach (ItemAmountRanged ranged in this.items)
                {
                    if (ranged != null)
                    {
                        return ItemManager.CreateByItemID(ranged.itemid, (int) ranged.GetAmount(), 0L); <--- here
                    }
                }
            }
            return null;
        }
        [...]
    }
    
    everytime method GetAmount is called, the return will be converted to int as you can see in LootSpawn methods.
    in c# if you try convert 0.9999999 into int, the result will be 0 (zero).
    what that means? if an item have amount value of 1 and maxAmount value of 2, the code will randomize between 1f and 2f, and there will be only a 1/10000000 chance to get 2.

    in my opinion, chances should be 50%/50% in that case.
    to make work that way, and i don't know if this will affect other stuff and should be checked before, the values of min and max on GetAmount could be converted to int before the use of UnityEngine.Random.Range and maxAmount should be passed as maxAmount + 1. that's because UnityEngine.Random.Range max is inclusive for float, but exclusive for int.

    what do you think?
     
  2. Wulf

    Wulf Community Admin

    That would be Rust's code, not Oxide's code.
     
  3. thanks! i didn't knew that!
    i will report to then and see what they think about it. :)