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 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 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); }