예제 #1
0
        public bool RemoveItem(int objectId, out Item item)
        {
            if (!State.RemoveItem(objectId, out item))
            {
                return(false);
            }

            Broadcast(session => {
                session.Send(FieldPacket.PickupItem(objectId, session.FieldPlayer.ObjectId));
                session.Send(FieldPacket.RemoveItem(objectId));
            });
            return(true);
        }
        public override void Handle(GameSession session, PacketReader packet)
        {
            int objectId = packet.ReadInt();

            bool foundItem = session.FieldManager.State.TryGetItem(objectId, out IFieldObject <Item> fieldItem);

            if (foundItem)
            {
                switch (fieldItem.Value.Id)
                {
                case 90000004:
                case 90000011:
                case 90000015:
                case 90000016:
                case 90000020:
                    session.Player.Account.Meret.Modify(fieldItem.Value.Amount);
                    break;

                case 90000008:
                    session.Player.Levels.GainExp(fieldItem.Value.Amount);
                    break;

                case 90000009:
                    session.Player.RecoverSp(fieldItem.Value.Amount);
                    break;

                case 90000010:
                    session.Player.RecoverStamina(fieldItem.Value.Amount);
                    break;

                default:
                    // TODO: This will be bugged when you have a full inventory, check inventory before looting
                    fieldItem.Value.Slot = -1;     // add to first empty slot
                    InventoryController.Add(session, fieldItem.Value, true);
                    break;
                }

                if (session.FieldManager.RemoveItem(objectId, out Item item))
                {
                    session.FieldManager.BroadcastPacket(FieldPacket.PickupItem(objectId, item, session.FieldPlayer.ObjectId));
                    session.FieldManager.BroadcastPacket(FieldPacket.RemoveItem(objectId));
                }
            }

            int countExtra = packet.ReadByte();

            for (int i = 0; i < countExtra; i++)
            {
            }
        }
예제 #3
0
        public override void Handle(GameSession session, PacketReader packet)
        {
            int objectCount = packet.ReadByte();

            for (int i = 0; i < objectCount; i++)
            {
                int objectId = packet.ReadInt();

                bool foundItem = session.FieldManager.State.TryGetItem(objectId, out IFieldObject <Item> fieldItem);
                if (foundItem && fieldItem.Value.Id >= 90000001 && fieldItem.Value.Id <= 90000003)
                {
                    session.Player.Wallet.Meso.Modify(fieldItem.Value.Amount);
                    if (session.FieldManager.RemoveItem(objectId, out Item item))
                    {
                        session.FieldManager.BroadcastPacket(FieldPacket.PickupItem(objectId, item, session.FieldPlayer.ObjectId));
                        session.FieldManager.BroadcastPacket(FieldPacket.RemoveItem(objectId));
                    }
                }
            }
        }