Ejemplo n.º 1
0
        public void Init()
        {
            int quantity  = 0;
            int objectUID = 0;

            foreach (BlueSheep.Core.Inventory.Item item in account.Inventory.Items)
            {
                bool isFood = false;

                foreach (Pet pet in account.petsList)
                {
                    foreach (Food food in pet.FoodList)
                    {
                        if (item.UID == food.Informations.UID)
                        {
                            isFood = true;
                            break;
                        }
                    }
                }

                if (isFood)
                {
                    quantity  = item.Quantity;
                    objectUID = item.UID;
                    break;
                }
            }

            if (objectUID == 0)
            {
                account.Running.GettingFoodFromSafe();
                return;
            }

            account.Running.OnLeaving = true;

            ExchangeObjectMoveMessage exchangeObjectMoveMessage =
                new ExchangeObjectMoveMessage(objectUID, quantity);

            using (BigEndianWriter writer = new BigEndianWriter())
            {
                exchangeObjectMoveMessage.Serialize(writer);

                MessagePackaging messagePackaging = new MessagePackaging(writer);

                messagePackaging.Pack((int)exchangeObjectMoveMessage.ProtocolID);

                account.SocketManager.Send(messagePackaging.Writer.Content);
                account.LastPacketID.Clear();
            }
        }
Ejemplo n.º 2
0
        public void Init()
        {
            account.Running.OnGetting = true;

            List <int> foodIndex = Foods.GetFoods(account.petsList[account.Running.CurrentPetIndex].Informations.GID);

            ObjectItem objectItem = null;

            foreach (ObjectItem item1 in account.SafeItems)
            {
                if (foodIndex.Contains(item1.ObjectGID))
                {
                    objectItem = item1;
                }
            }

            if (objectItem == null)
            {
                account.Running.NoFood();
                return;
            }

            int abbleWeight = account.Pods.WeightMax -
                              account.Pods.Weight - 1;
            //return;
            DataClass item         = GameData.GetDataObject(D2oFileEnum.Items, objectItem.ObjectGID);
            int       objectWeight = (int)item.Fields["realWeight"];
            int       quantity     = abbleWeight / objectWeight;

            if (objectItem.Quantity < quantity)
            {
                quantity = objectItem.Quantity;
            }

            ExchangeObjectMoveMessage exchangeObjectMoveMessage =
                new ExchangeObjectMoveMessage(objectItem.ObjectUID, -quantity);

            using (BigEndianWriter writer = new BigEndianWriter())
            {
                exchangeObjectMoveMessage.Serialize(writer);

                MessagePackaging messagePackaging = new MessagePackaging(writer);

                messagePackaging.Pack((int)exchangeObjectMoveMessage.ProtocolID);

                account.SocketManager.Send(messagePackaging.Writer.Content);
                account.LastPacketID.Clear();
            }
        }