public override void Handle(NecClient client, NecPacket packet)
        {
            ItemZoneType zone     = (ItemZoneType)packet.data.ReadByte();
            byte         bag      = packet.data.ReadByte();
            short        slot     = packet.data.ReadInt16();
            ulong        saleGold = packet.data.ReadUInt64(); //irrelevant, check sale price server side
            byte         quantity = packet.data.ReadByte();

            ItemLocation location    = new ItemLocation(zone, bag, slot);
            ItemService  itemService = new ItemService(client.character);
            int          error       = 0;

            try
            {
                //ulong currentGold = itemService.Sell(location, quantity);
                ulong currentGold = itemService.AddGold(saleGold);
                RecvSelfMoneyNotify recvSelfMoneyNotify = new RecvSelfMoneyNotify(client, currentGold);
                router.Send(recvSelfMoneyNotify);

                ItemInstance   itemInstance   = itemService.Remove(new ItemLocation(zone, bag, slot), quantity);
                RecvItemRemove recvItemRemove = new RecvItemRemove(client, itemInstance);
                router.Send(recvItemRemove);
            }
            catch (ItemException e)
            {
                error = (int)e.type;
            }

            RecvShopSell recvShopSell = new RecvShopSell(client, error);

            router.Send(recvShopSell);
        }
Beispiel #2
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            ItemZoneType zone     = (ItemZoneType)packet.data.ReadByte();
            byte         bag      = packet.data.ReadByte();
            short        slot     = packet.data.ReadInt16();
            byte         quantity = packet.data.ReadByte();

            ItemLocation location    = new ItemLocation(zone, bag, slot);
            ItemService  itemService = new ItemService(client.character);
            int          error       = 0;

            try
            {
                ItemInstance   item           = itemService.Remove(location, quantity);
                RecvItemRemove recvItemRemove = new RecvItemRemove(client, item);
                router.Send(recvItemRemove);
            }
            catch (ItemException e)
            {
                error = (int)e.type;
            }

            RecvItemDrop recvItemDrop = new RecvItemDrop(client, error);

            router.Send(recvItemDrop);
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            client.map.deadBodies.TryGetValue(client.character.eventSelectReadyCode, out DeadBody deadBody);
            Character deadCharacter = _server.instances.GetCharacterByInstanceId(deadBody.characterInstanceId);
            //Todo - server or map needs to maintain characters in memory for a period of time after disconnect
            NecClient deadClient = _server.clients.GetByCharacterInstanceId(deadBody.characterInstanceId);

            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //result, 0 sucess.  interupted, etc.
            res.WriteFloat(0); // time remaining
            router.Send(client, (ushort)AreaPacketId.recv_charabody_loot_complete2_r, res, ServerType.Area);

            if (deadClient != null)
            {
                res = BufferProvider.Provide();
                res.WriteByte((byte)deadCharacter.lootNotify.zoneType);
                res.WriteByte(deadCharacter.lootNotify.container);
                res.WriteInt16(deadCharacter.lootNotify.slot);

                res.WriteInt16(1 /*iteminstance.Quantity*/);  //Number here is "pieces"
                res.WriteCString($"{client.soul.name}");      // soul name
                res.WriteCString($"{client.character.name}"); // chara name
                router.Send(deadClient, (ushort)AreaPacketId.recv_charabody_notify_loot_item, res, ServerType.Area);
            }

            //if (successfull loot condition here)
            {
                ItemService itemService = new ItemService(client.character);
                ItemService deadCharacterItemService = new ItemService(deadCharacter);

                ItemInstance iteminstance = deadCharacterItemService.GetLootedItem(deadCharacter.lootNotify);
                //remove the icon from the deadClient's inventory if they are online.
                RecvItemRemove recvItemRemove = new RecvItemRemove(deadClient, iteminstance);
                if (deadClient != null)
                {
                    router.Send(recvItemRemove);
                }

                //Add RecvItemRemove to remove the icon from the charabody window on successfull loot as well.//ToDo - this didnt work
                RecvItemRemove recvItemRemove2 = new RecvItemRemove(client, iteminstance);
                router.Send(recvItemRemove2);

                //update the item statuses to unidentified
                iteminstance.statuses |= ItemStatuses.Unidentified;
                //put the item in the new owners inventory
                itemService.PutLootedItem(iteminstance);

                RecvItemInstanceUnidentified recvItemInstanceUnidentified = new RecvItemInstanceUnidentified(client, iteminstance);
                router.Send(client, recvItemInstanceUnidentified.ToPacket());
            }
        }
Beispiel #4
0
        public override void Handle(NecClient client, NecPacket packet)
        {
            NecClient targetClient = server.clients.GetByCharacterInstanceId((uint)client.character.eventSelectExecCode);

            short        fromSlot     = packet.data.ReadInt16();
            ulong        itemId       = client.character.tradeWindowSlot[fromSlot];
            ItemInstance itemInstance = client.character.itemLocationVerifier.GetItemByInstanceId(itemId);

            if (targetClient != null)
            {
                RecvItemRemove itemRemove = new RecvItemRemove(targetClient, itemInstance);
                router.Send(itemRemove);
            }

            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); // error check?
            router.Send(client, (ushort)AreaPacketId.recv_trade_remove_item_r, res, ServerType.Area);
        }
Beispiel #5
0
        public List <PacketResponse> GetMoveResponses(NecClient client, MoveResult moveResult)
        {
            List <PacketResponse> responses = new List <PacketResponse>();

            switch (moveResult.type)
            {
            case MoveType.Place:
                RecvItemUpdatePlace recvItemUpdatePlace = new RecvItemUpdatePlace(client, moveResult.destItem);
                responses.Add(recvItemUpdatePlace);
                break;

            case MoveType.Swap:
                RecvItemUpdatePlaceChange recvItemUpdatePlaceChange = new RecvItemUpdatePlaceChange(client, moveResult.originItem, moveResult.destItem);
                responses.Add(recvItemUpdatePlaceChange);
                break;

            case MoveType.PlaceQuantity:
                RecvItemUpdateNum recvItemUpdateNum = new RecvItemUpdateNum(client, moveResult.originItem);
                responses.Add(recvItemUpdateNum);
                RecvItemInstance recvItemInstance = new RecvItemInstance(client, moveResult.destItem);
                responses.Add(recvItemInstance);
                break;

            case MoveType.AddQuantity:
                RecvItemUpdateNum recvItemUpdateNum0 = new RecvItemUpdateNum(client, moveResult.originItem);
                responses.Add(recvItemUpdateNum0);
                RecvItemUpdateNum recvItemUpdateNum1 = new RecvItemUpdateNum(client, moveResult.destItem);
                responses.Add(recvItemUpdateNum1);
                break;

            case MoveType.AllQuantity:
                RecvItemRemove recvItemRemove = new RecvItemRemove(client, moveResult.originItem);
                responses.Add(recvItemRemove);
                RecvItemUpdateNum recvItemUpdateNum2 = new RecvItemUpdateNum(client, moveResult.destItem);
                responses.Add(recvItemUpdateNum2);
                break;

            case MoveType.None:
                break;
            }

            return(responses);
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte notifyProblemSysMsg   = 0;
            int  clientItemCount       = 0;
            int  targetClientItemcount = 0;

            NecClient   targetClient      = server.clients.GetByCharacterInstanceId((uint)client.character.eventSelectExecCode);
            ItemService itemService       = new ItemService(client.character);
            ItemService targetItemService = new ItemService(targetClient.character);

            RecvTradeNotifyFixed notifyFixed  = new RecvTradeNotifyFixed(0);
            RecvTradeFix         recvTradeFix = new RecvTradeFix();

            for (int i = 0; i < 20; i++)
            {
                if (client.character.tradeWindowSlot[i] > 0)
                {
                    clientItemCount++;
                }
                if (targetClient.character.tradeWindowSlot[i] > 0)
                {
                    targetClientItemcount++;
                }
            }

            _Logger.Debug($"Transferred items {clientItemCount}:{targetClientItemcount}");
            _Logger.Debug($"Free Space{client.character.itemLocationVerifier.GetTotalFreeSpace(ItemZoneType.AdventureBag)}:{targetClient.character.itemLocationVerifier.GetTotalFreeSpace(ItemZoneType.AdventureBag)}");

            //ToDo:  improve this logic when GetTotalFreeSpace can check all bags
            if (client.character.itemLocationVerifier.GetTotalFreeSpace(ItemZoneType.AdventureBag) < targetClientItemcount - clientItemCount)
            {
                notifyProblemSysMsg = 1;                                                                                                                               //doesnt work. GetTotalFreeSpace is not accurate. problem with itemService.PutLootedItem updating count.
            }
            if (targetClient.character.itemLocationVerifier.GetTotalFreeSpace(ItemZoneType.AdventureBag) < clientItemCount - targetClientItemcount)
            {
                notifyProblemSysMsg = 1;
            }
            //ToDo:  add other trade preventing scenarios here


            RecvTradeNotifyProblem recvTradeNotifyProblem = new RecvTradeNotifyProblem(0, notifyProblemSysMsg);

            router.Send(client, recvTradeNotifyProblem.ToPacket());
            if (targetClient != null)
            {
                router.Send(targetClient, recvTradeNotifyProblem.ToPacket());
            }


            if (notifyProblemSysMsg == 0)
            {
                //player 1 sends
                router.Send(client, notifyFixed.ToPacket());
                router.Send(client, recvTradeFix.ToPacket());

                //player 2 sends
                if (targetClient != null)
                {
                    router.Send(targetClient, notifyFixed.ToPacket());
                    router.Send(targetClient, recvTradeFix.ToPacket());
                }

                //Get stuff from targetClient
                for (int i = 0; i < 20; i++)
                {
                    ItemInstance itemInstance = targetClient.character.itemLocationVerifier.GetItemByInstanceId(targetClient.character.tradeWindowSlot[i]);
                    if (itemInstance != null)
                    {
                        RecvItemRemove recvItemRemove = new RecvItemRemove(targetClient, itemInstance);
                        if (targetClient != null)
                        {
                            router.Send(recvItemRemove);
                        }

                        targetClient.character.itemLocationVerifier.RemoveItem(itemInstance);

                        //put the item in the new owners inventory
                        itemInstance = itemService.PutLootedItem(itemInstance);

                        RecvItemInstance recvItemInstance = new RecvItemInstance(client, itemInstance);
                        router.Send(client, recvItemInstance.ToPacket());
                    }

                    //}
                    //give stuff to targetClient
                    //for (int i = 0; i < 20; i++)
                    //{
                    ItemInstance itemInstance2 = client.character.itemLocationVerifier.GetItemByInstanceId(client.character.tradeWindowSlot[i]);
                    if (itemInstance2 != null)
                    {
                        RecvItemRemove recvItemRemove2 = new RecvItemRemove(client, itemInstance2);
                        if (client != null)
                        {
                            router.Send(recvItemRemove2);
                        }

                        client.character.itemLocationVerifier.RemoveItem(itemInstance2);

                        //put the item in the new owners inventory
                        itemInstance2 = targetItemService.PutLootedItem(itemInstance2);

                        RecvItemInstance recvItemInstance2 = new RecvItemInstance(targetClient, itemInstance2);
                        if (targetClient != null)
                        {
                            router.Send(targetClient, recvItemInstance2.ToPacket());
                        }
                    }
                }

                client.character.tradeWindowSlot       = new ulong[20];
                targetClient.character.tradeWindowSlot = new ulong[20];

                Task.Delay(TimeSpan.FromSeconds(5)).ContinueWith
                    (t1 =>
                {
                    RecvEventEnd eventEnd = new RecvEventEnd(0);
                    if (targetClient != null)
                    {
                        router.Send(targetClient, eventEnd.ToPacket());
                    }
                    router.Send(client, eventEnd.ToPacket());
                }
                    );
            }
        }
Beispiel #7
0
        public void Move(NecServer server, NecClient client)
        {
            InventoryItem fromInvItem = client.Character.GetInventoryItem(fromStoreType, fromBagId, fromSlot);
            InventoryItem toInvItem   = client.Character.GetInventoryItem(toStoreType, toBagId, toSlot);

            if (toInvItem != null && (fromInvItem.StorageCount + toInvItem.StorageCount > 255))
            {
                RecvNormalSystemMessage unlikeItems =
                    new RecvNormalSystemMessage("The move would place too many items in destination slot!");
                server.Router.Send(unlikeItems, client);
                return;
            }

            if (fromInvItem.StorageCount == itemCount)
            {
                if (toInvItem != null)
                {
                    toInvItem.StorageCount =
                        (byte)(fromInvItem.StorageCount +
                               toInvItem.StorageCount);  // huh??? byte - byte is cast as int????
                    RecvItemUpdateNum itemNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    server.Router.Send(itemNum, client);
                    RecvItemRemove removeItem = new RecvItemRemove(fromInvItem.InstanceId);
                    server.Router.Send(removeItem, client);
                    client.Character.RemoveInventoryItem(fromInvItem);
                    client.Character.UpdateInventoryItem(toInvItem);
                }
                else
                {
                    fromInvItem.StorageType = toStoreType;
                    fromInvItem.StorageId   = toBagId;
                    fromInvItem.StorageSlot = toSlot;
                    RecvItemUpdatePlace itemPlace = new RecvItemUpdatePlace(fromInvItem.InstanceId,
                                                                            fromInvItem.StorageType, fromInvItem.StorageId, fromInvItem.StorageSlot);
                    server.Router.Send(itemPlace, client);
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
            }
            else
            {
                byte remainCount =
                    (byte)(fromInvItem.StorageCount - itemCount);  // huh??? byte - byte is cast as int????
                if (toInvItem != null)
                {
                    toInvItem.StorageCount =
                        (byte)(itemCount + toInvItem.StorageCount);  // huh??? byte - byte is cast as int????
                    fromInvItem.StorageCount = remainCount;
                    RecvItemUpdateNum toItemNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    server.Router.Send(toItemNum, client);
                    RecvItemUpdateNum fromItemNum =
                        new RecvItemUpdateNum(fromInvItem.InstanceId, fromInvItem.StorageCount);
                    server.Router.Send(fromItemNum, client);
                    client.Character.RemoveInventoryItem(fromInvItem);
                    client.Character.UpdateInventoryItem(toInvItem);
                }
                else
                {
                    RecvItemUpdateNum updateNum = new RecvItemUpdateNum(fromInvItem.InstanceId, remainCount);
                    server.Router.Send(updateNum, client);
                    InventoryItem newInvItem = client.Character.GetNextInventoryItem(server);
                    newInvItem.StorageCount = (byte)itemCount;
                    newInvItem.StorageType  = toStoreType;
                    newInvItem.StorageId    = toBagId;
                    newInvItem.StorageSlot  = toSlot;
                    newInvItem.StorageItem  = item;
                    RecvItemInstanceUnidentified itemUnidentified = new RecvItemInstanceUnidentified(newInvItem);
                    server.Router.Send(itemUnidentified, client);
                    fromInvItem.StorageCount = remainCount;
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
            }
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte[]  forgeItemStorageType = new byte[3];
            byte[]  forgeItemBag         = new byte[3];
            short[] forgeItemSlot        = new short[3];

            byte  storageType    = packet.data.ReadByte();
            byte  bag            = packet.data.ReadByte();
            short slot           = packet.data.ReadInt16();
            int   forgeItemCount = packet.data.ReadInt32();

            for (int i = 0; i < forgeItemCount; i++)
            {
                forgeItemStorageType[i] = packet.data.ReadByte();
                forgeItemBag[i]         = packet.data.ReadByte();
                forgeItemSlot[i]        = packet.data.ReadInt16();
            }

            byte  supportItemCount       = packet.data.ReadByte();
            byte  supportItemStorageType = packet.data.ReadByte();
            byte  supportItemBag         = packet.data.ReadByte();
            short supportItemSlot        = packet.data.ReadInt16();

            int result = 1;

            int luckyChance = Util.GetRandomNumber(0, client.character.luck); //the more luck you have, the better your chances

            if (luckyChance < 5)
            {
                result = 2;
            }
            if ((result == 2) & (forgeItemCount > 1) && Util.GetRandomNumber(0, client.character.luck) < 4)
            {
                result = 1;                                                                                             // use 2 forge stone, get a 2nd chance
            }
            if ((result == 2) & (forgeItemCount > 2) && Util.GetRandomNumber(0, client.character.luck) < 3)
            {
                result = 1;                                                                                             // use 3 forge stone, get a 3rd chance
            }
            //if ((result == 2) & (forgeItemCount > 2) && Util.GetRandomNumber(0, client.Character.Luck) < 5) result = 1; // use 3 forge stone, get a 4th chance


            RecvForgeNotifyExecuteResult recvForgeNotifyExecuteResult = new RecvForgeNotifyExecuteResult(client.character.instanceId, result);

            router.Send(client, recvForgeNotifyExecuteResult.ToPacket());

            ItemService     itemService     = new ItemService(client.character);
            ItemInstance    itemInstance    = client.character.itemLocationVerifier.GetItem(new ItemLocation((ItemZoneType)storageType, bag, slot));
            ForgeMultiplier forgeMultiplier = itemService.ForgeMultiplier(itemInstance.enhancementLevel + 1);

            if (itemInstance.enhancementLevel > 9)
            {
                result = 0;                                    // no forging beyond 10. sorry.
            }
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0);      // 0 is a pass, anything but 0 is a fail; seems like a check for if you can still upgrade the weapon
            res.WriteInt32(result); // anything but a 1 here is a fail condition, 1 here is a pass condition.
            router.Send(client, (ushort)AreaPacketId.recv_forge_execute_r, res, ServerType.Area);

            itemInstance.enhancementLevel += 1;
            itemInstance.physical          = (short)(itemInstance.physical * forgeMultiplier.factor);
            itemInstance.magical           = (short)(itemInstance.magical * forgeMultiplier.factor);
            itemInstance.maximumDurability = (short)(itemInstance.maximumDurability * forgeMultiplier.durability);
            itemInstance.hardness          = (byte)(itemInstance.hardness + forgeMultiplier.hardness);
            itemInstance.weight            = (short)(itemInstance.weight - forgeMultiplier.weight);

            if (result == 1)
            {
                RecvItemUpdateLevel recvItemUpdateLevel = new RecvItemUpdateLevel(itemInstance.instanceId, itemInstance.enhancementLevel);
                router.Send(client, recvItemUpdateLevel.ToPacket());
                RecvItemUpdatePhysics recvItemUpdatePhysics = new RecvItemUpdatePhysics(itemInstance.instanceId, itemInstance.physical);
                router.Send(client, recvItemUpdatePhysics.ToPacket());
                RecvItemUpdateMagic recvItemUpdateMagic = new RecvItemUpdateMagic(itemInstance.instanceId, itemInstance.magical);
                router.Send(client, recvItemUpdateMagic.ToPacket());
                RecvItemUpdateMaxDur recvItemUpdateMaxDur = new RecvItemUpdateMaxDur(itemInstance.instanceId, itemInstance.maximumDurability);
                router.Send(client, recvItemUpdateMaxDur.ToPacket());
                RecvItemUpdateHardness recvItemUpdateHardness = new RecvItemUpdateHardness(itemInstance.instanceId, itemInstance.hardness);
                router.Send(client, recvItemUpdateHardness.ToPacket());
                RecvItemUpdateWeight recvItemUpdateWeight = new RecvItemUpdateWeight(itemInstance.instanceId, itemInstance.weight);
                router.Send(client, recvItemUpdateWeight.ToPacket());

                itemService.UpdateEnhancementLevel(itemInstance);
            }
            else if (supportItemCount == 0)
            {
                itemService.Remove(itemInstance.location, itemInstance.quantity);
                RecvItemRemove recvItemRemove = new RecvItemRemove(client, itemInstance);
                router.Send(recvItemRemove);
            }
            else if (itemInstance.enhancementLevel > 4) //if forge fails but gaurd exists, do not lose item.
            {
                itemInstance.enhancementLevel = 4;

                ForgeMultiplier forgeDehancementMultiplier = itemService.LoginLoadMultiplier(itemInstance.enhancementLevel);
                server.settingRepository.itemLibrary.TryGetValue(itemInstance.baseId, out ItemLibrarySetting itemLibrarySetting); //ToDo,  load Nec_Item_Library into memory for queries like this.
                if (itemLibrarySetting != null)
                {
                    itemInstance.physical          = (short)itemLibrarySetting.physicalAttack;
                    itemInstance.magical           = (short)itemLibrarySetting.magicalAttack;
                    itemInstance.maximumDurability = itemLibrarySetting.durability;
                    itemInstance.hardness          = (byte)itemLibrarySetting.hardness;
                    itemInstance.weight            = (int)itemLibrarySetting.weight;
                }

                itemInstance.physical          = (short)(itemInstance.physical * forgeDehancementMultiplier.factor);
                itemInstance.magical           = (short)(itemInstance.magical * forgeDehancementMultiplier.factor);
                itemInstance.maximumDurability = (short)(itemInstance.maximumDurability * forgeDehancementMultiplier.durability);
                itemInstance.hardness          = (byte)(itemInstance.hardness + forgeDehancementMultiplier.hardness);
                itemInstance.weight            = (short)(itemInstance.weight - forgeDehancementMultiplier.weight);

                RecvItemUpdateLevel recvItemUpdateLevel = new RecvItemUpdateLevel(itemInstance.instanceId, itemInstance.enhancementLevel);
                router.Send(client, recvItemUpdateLevel.ToPacket());
                RecvItemUpdatePhysics recvItemUpdatePhysics = new RecvItemUpdatePhysics(itemInstance.instanceId, itemInstance.physical);
                router.Send(client, recvItemUpdatePhysics.ToPacket());
                RecvItemUpdateMagic recvItemUpdateMagic = new RecvItemUpdateMagic(itemInstance.instanceId, itemInstance.magical);
                router.Send(client, recvItemUpdateMagic.ToPacket());
                RecvItemUpdateMaxDur recvItemUpdateMaxDur = new RecvItemUpdateMaxDur(itemInstance.instanceId, itemInstance.maximumDurability);
                router.Send(client, recvItemUpdateMaxDur.ToPacket());
                RecvItemUpdateHardness recvItemUpdateHardness = new RecvItemUpdateHardness(itemInstance.instanceId, itemInstance.hardness);
                router.Send(client, recvItemUpdateHardness.ToPacket());
                RecvItemUpdateWeight recvItemUpdateWeight = new RecvItemUpdateWeight(itemInstance.instanceId, itemInstance.weight);
                router.Send(client, recvItemUpdateWeight.ToPacket());

                itemService.UpdateEnhancementLevel(itemInstance);
            }

            for (int i = 0; i < forgeItemCount; i++)
            {
                ItemInstance forgeItemInstance = client.character.itemLocationVerifier.GetItem(new ItemLocation((ItemZoneType)forgeItemStorageType[i], forgeItemBag[i], forgeItemSlot[i]));
                if (forgeItemInstance != null)
                {
                    RecvItemRemove recvItemRemove = new RecvItemRemove(client, forgeItemInstance);
                    router.Send(recvItemRemove);
                    itemService.Remove(forgeItemInstance.location, forgeItemInstance.quantity);
                }
            }

            for (int i = 0; i < supportItemCount; i++)
            {
                ItemInstance supportItemInstance = client.character.itemLocationVerifier.GetItem(new ItemLocation((ItemZoneType)supportItemStorageType, supportItemBag, supportItemSlot));
                if (supportItemInstance != null)
                {
                    RecvItemRemove recvItemRemove = new RecvItemRemove(client, supportItemInstance);
                    router.Send(recvItemRemove);
                    itemService.Remove(supportItemInstance.location, supportItemInstance.quantity);
                }
            }
        }
        public override void Handle(NecClient client, NecPacket packet)
        {
            byte
                toStoreType =
                packet.Data
                .ReadByte();         // [0 = adventure bag. 1 = character equipment], [then unknown byte], [then slot], [then unknown]
            byte  toBagId       = packet.Data.ReadByte();
            short fromSlot      = packet.Data.ReadInt16();
            byte  fromStoreType = packet.Data.ReadByte();
            byte  fromBagId     = packet.Data.ReadByte();
            short toSlot        = packet.Data.ReadInt16();

            Logger.Debug($"fromStoreType byte [{fromStoreType}]");
            Logger.Debug($"fromBagId byte [{fromBagId}]");
            Logger.Debug($"fromSlot byte [{fromSlot}]");
            Logger.Debug($"toStoreType byte [{toStoreType}]");
            Logger.Debug($"toBagId byte [{toBagId}]");
            Logger.Debug($"toSlot [{toSlot}]");

            int itemCount = packet.Data.ReadByte(); //last byte is stack count?

            Logger.Debug($"itemCount [{itemCount}]");
            IBuffer res = BufferProvider.Provide();

            res.WriteInt32(0); //error check. 0 to work

            /*
             *  ITEMUSE	GENERIC	Unable to use this item right now
             *  ITEMUSE	-201	Store location is incorrect
             *  ITEMUSE	-204	Item amount is incorrect
             *  ITEMUSE	-205	The target to use this item is incorrect
             *  ITEMUSE	-206	Unable to use due to delay time
             *  ITEMUSE	-207	No space available in inventory
             *  ITEMUSE	-208	Unable to use this item since it is cursed
             *  ITEMUSE	-209	Unable to use this item since it is broken
             *  ITEMUSE	-210	You do not meet the requirements to equip this item
             *  ITEMUSE	-211	Unable to use this item
             *  ITEMUSE	-212	You are not in the right status to use this item
             *  ITEMUSE	-230	Unable to use since it is on cool down.
             *  ITEMUSE	-2601	You've already received this scrap
             *  ITEMUSE	-2708	Cannot be used outside of town
             *  ITEMUSE	-3001	Unable to move items when you have a shop open
             *
             */

            Router.Send(client, (ushort)AreaPacketId.recv_item_move_r, res, ServerType.Area);

            InventoryItem fromInvItem = client.Character.GetInventoryItem(fromStoreType, fromBagId, fromSlot);
            InventoryItem toInvItem   = client.Character.GetInventoryItem(toStoreType, toBagId, toSlot);

            if (toInvItem != null && (fromInvItem.StorageItem != toInvItem.StorageItem))
            {
                RecvNormalSystemMessage unlikeItems = new RecvNormalSystemMessage("You can only stack like items!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (toInvItem != null && (toInvItem.StorageCount >= 255))
            {
                RecvNormalSystemMessage unlikeItems =
                    new RecvNormalSystemMessage("The move would place too many items in destination slot!");
                _server.Router.Send(unlikeItems, client);
                return;
            }

            if (fromInvItem.StorageCount > 1)
            {
                if (client.Character.currentEvent != null)
                {
                    Logger.Error(
                        $"Trying to start new event with another outstanding event active! Outstanding event type [{client.Character.currentEvent.EventType}]");
                    client.Character.currentEvent = null;
                }

                MoveItem moveItem = _server.Instances.CreateInstance <MoveItem>();
                moveItem.toStoreType          = toStoreType;
                moveItem.toBagId              = toBagId;
                moveItem.toSlot               = toSlot;
                moveItem.fromStoreType        = fromStoreType;
                moveItem.fromBagId            = moveItem.fromBagId;
                moveItem.fromSlot             = fromSlot;
                moveItem.itemCount            = (byte)itemCount;
                moveItem.item                 = fromInvItem.StorageItem;
                client.Character.currentEvent = moveItem;
                RecvEventStart eventStart = new RecvEventStart(0, 0);
                Router.Send(eventStart, client);
                RecvEventRequestInt getCount = new RecvEventRequestInt("Select number to move.", 1,
                                                                       fromInvItem.StorageCount, fromInvItem.StorageCount);
                Router.Send(getCount, client);
            }
            else
            {
                if (toInvItem == null)
                {
                    fromInvItem.StorageType = toStoreType;
                    fromInvItem.StorageId   = toBagId;
                    fromInvItem.StorageSlot = toSlot;
                    client.Character.UpdateInventoryItem(fromInvItem);
                    RecvItemUpdatePlace changePlace =
                        new RecvItemUpdatePlace(fromInvItem.InstanceId, toStoreType, toBagId, toSlot);
                    _server.Router.Send(changePlace, client);
                    client.Character.UpdateInventoryItem(fromInvItem);
                }
                else
                {
                    toInvItem.StorageCount += 1;
                    RecvItemUpdateNum updateNum = new RecvItemUpdateNum(toInvItem.InstanceId, toInvItem.StorageCount);
                    _server.Router.Send(updateNum, client);
                    RecvItemRemove removeitem = new RecvItemRemove(fromInvItem.InstanceId);
                    _server.Router.Send(removeitem, client);
                    client.Character.UpdateInventoryItem(toInvItem);
                    client.Character.RemoveInventoryItem(fromInvItem);
                }
            }

            //SendItemPlace(client);
            //SendItemPlaceChange(client);
        }