public static MoveItemInfo RecvMoveItem(Packet p) { p.Skip(2); byte frombag = p.ReadByte(); byte fromslot = p.ReadByte(); int itemid = p.ReadInt(); byte tobag = p.ReadByte(); byte toslot = p.ReadByte(); int itemunder = p.ReadInt(); MoveItemInfo mii = new MoveItemInfo { FromBag = frombag, FromSlot = fromslot, ItemID = itemid, ToBag = tobag, ToSlot = toslot, ItemIDUnder = itemunder }; return mii; }
public static byte[] SendMoveItem(MoveItemInfo m, byte error) { Packet p = new Packet(200); p.WriteByte(error); p.WriteByte(m.FromBag); p.WriteByte(m.FromSlot); p.WriteByte(m.ToBag); p.WriteByte(m.ToSlot); return p.GetWrittenBuffer(PacketIds.SendMoveItem); }
public ClientMoveItemEventArgs(MoveItemInfo mii) { this.moveinfo = mii; }
private void HandleUnEquipItem(Client c, MoveItemInfo m, BaseItem item) { try { MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray()); if (m.ToBag != 255 && m.ToSlot != 255) { if (!c.MyCharacter.Bags[m.ToBag - 1].IsSlotValid(item, m.ToSlot)) { throw new InvalidItemSlotException("NO PUT ON EDGE PUJJ"); } if (!c.MyCharacter.Bags[m.ToBag - 1].CheckSlot(item, m.ToSlot)) { switch (item.Slot) { case (byte)Slot.Weapon: // Hand c.MyCharacter.Hand = null; break; case (byte)Slot.Hat: // Hat c.MyCharacter.Head = null; break; case (byte)Slot.Armor: // Armor c.MyCharacter.Body = null; break; case (byte)Slot.Shoes: // Shoes c.MyCharacter.Feet = null; break; case (byte)Slot.Ring: c.MyCharacter.Ring = null; break; case (byte)Slot.Necklace: c.MyCharacter.Necklace = null; break; case (byte)Slot.Cape: c.MyCharacter.Cape = null; break; case (byte)Slot.Mirror: c.MyCharacter.Mirror = null; break; default: break; } item.Bag = m.ToBag; item.Slot = m.ToSlot; c.MyCharacter.Bags[m.ToBag - 1].AddItem(item); itemDataManager.UpdateItem(item); byte[] SendMoveItem = PacketManager.SendMoveItem(m, 0); c.Send(SendMoveItem); byte[] SendNewStats = PacketManager.SendStats(c.MyCharacter); c.Send(SendNewStats); byte[] SendNewVisuals = PacketManager.SendSpawnPlayers(c.MyCharacter); SendToClients(SendNewVisuals, clients); } else { byte[] SendError = PacketManager.SendMoveItem(m, 2); c.Send(SendError); } } } catch { byte[] SendError = PacketManager.SendMoveItem(m, 2); c.Send(SendError); } }
private bool HandleItemMove(Client c, MoveItemInfo m, BaseItem item) { BaseItem test; try { if (m.ItemIDUnder != 0) test = c.MyCharacter.Bags[m.ToBag - 1].Items.First(x => x.ItemID == m.ItemIDUnder); if (m.ToSlot != 255) { if (c.MyCharacter.Bags[m.ToBag - 1].MoveItem(c.MyCharacter, item, m.ToSlot, out test)) { if (test == null) { item.Slot = (byte)(m.ToSlot); item.Bag = (byte)(m.ToBag); itemDataManager.UpdateItem(item); } else { int tempslot, tempbag; tempslot = item.Slot; tempbag = item.Bag; item.Slot = test.Slot; item.Bag = test.Bag; test.Slot = (byte)tempslot; test.Bag = (byte)tempbag; //if (m.FromBag != m.ToBag && m.FromBag > 0) //{ // c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item); // c.MyCharacter.Bags[m.ToBag - 1].RemoveItem(test); // c.MyCharacter.Bags[m.ToBag - 1].AddItem(item); // c.MyCharacter.Bags[m.FromBag - 1].AddItem(test); //} itemDataManager.UpdateItem(item); itemDataManager.UpdateItem(test); } if (m.FromBag != m.ToBag && m.FromBag > 0) { c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item); c.MyCharacter.Bags[m.ToBag - 1].AddItem(item); if (test != null) { c.MyCharacter.Bags[m.ToBag - 1].RemoveItem(test); c.MyCharacter.Bags[m.FromBag - 1].AddItem(test); } } return true; } } return false; } catch { return false; } }
private void HandleEquipItem(Client c, MoveItemInfo m, BaseItem item) { try { BaseItem conflict = null; MapEngine mapEngine = GetMapEngine(c.MyCharacter.MapId); Client[] clients = GetClientsForChars(mapEngine.GetCharactersInRange(c.MyCharacter.Position, 150).ToArray()); switch (m.ToSlot) { case (byte)Slot.Weapon: // Hand conflict = c.MyCharacter.Hand; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Hand = (Hand)item; break; case (byte)Slot.Hat: // Hat conflict = c.MyCharacter.Head; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Head = (Head)item; break; case (byte)Slot.Armor: // Armor conflict = c.MyCharacter.Body; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Body = (Body)item; break; case (byte)Slot.Shoes: // Shoes conflict = c.MyCharacter.Feet; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Feet = (Feet)item; break; case (byte)Slot.Ring: conflict = c.MyCharacter.Ring; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Ring = (Ring)item; break; case (byte)Slot.Necklace: conflict = c.MyCharacter.Necklace; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Necklace = (Necklace)item; break; case (byte)Slot.Cape: conflict = c.MyCharacter.Cape; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Cape = (Cape)item; break; case (byte)Slot.Mirror: conflict = c.MyCharacter.Mirror; if (conflict != null) { conflict.Slot = item.Slot; conflict.Bag = item.Bag; } c.MyCharacter.Mirror = (Mirror)item; break; default: break; } if (conflict != null) { c.MyCharacter.Bags[m.FromBag - 1].AddItem(conflict); itemDataManager.UpdateItem(conflict); } c.MyCharacter.Bags[m.FromBag - 1].RemoveItem(item); itemDataManager.UpdateItem(item); byte[] SendEquipItem = PacketManager.SendMoveItem(m, 0); c.Send(SendEquipItem); byte[] SendNewStats = PacketManager.SendStats(c.MyCharacter); c.Send(SendNewStats); if (c.MyCharacter.ImperialSet != ImperialSet.None) { SendCommandHelp(string.Format("Wearing set: {0}", c.MyCharacter.ImperialSet.ToString()), c); } byte[] SendNewVisuals = PacketManager.SendSpawnPlayers(c.MyCharacter); SendToClients(SendNewVisuals, clients); } catch (RequiredClassException) { byte[] SendEquipError = PacketManager.SendMoveItem(m, 3); c.Send(SendEquipError); } }