Exemple #1
0
        public static bool UnhandItem(Player player)
        {
            bool isUnhanded = false;

            // Drop mouse item always
            if (player.selectedItem == PlayerItemHelpers.VanillaInventorySelectedSlot)
            {
                PlayerItemHelpers.DropInventoryItem(player, PlayerItemHelpers.VanillaInventorySelectedSlot);
                isUnhanded = true;
            }
            // Preferably select a blank slot
            if (!isUnhanded)
            {
                for (int i = 0; i < player.inventory.Length; i++)
                {
                    if (player.inventory[i] == null || player.inventory[i].IsAir)
                    {
                        player.selectedItem = i;
                        isUnhanded          = true;
                        break;
                    }
                }
            }
            // Otherwise select a non-usable item
            if (!isUnhanded)
            {
                for (int i = 0; i < player.inventory.Length; i++)
                {
                    Item item = player.inventory[i];
                    if (item != null && item.holdStyle == 0 && item.createTile == -1 && !item.potion && item.useStyle == 0)
                    {
                        player.selectedItem = i;
                        isUnhanded          = true;
                        break;
                    }
                }
            }
            // Otherwise select a non-held item
            if (!isUnhanded)
            {
                for (int i = 12; i < player.inventory.Length; i++)
                {
                    Item item = player.inventory[i];
                    if (item != null && item.holdStyle == 0)
                    {
                        player.selectedItem = i;
                        isUnhanded          = true;
                        break;
                    }
                }
            }

            player.noItems = true;

            return(isUnhanded);
        }
Exemple #2
0
 public static void DropInventoryItem(Player player, int slot, int noGrabDelay, out int idx)
 {
     idx = PlayerItemHelpers.DropInventoryItem(player, slot, noGrabDelay);
 }
Exemple #3
0
        public static void DropInventoryItem(Player player, int slot)
        {
            int _;

            PlayerItemHelpers.DropInventoryItem(player, slot, 100, out _);
        }