public static ItemLocation FromSlot(Constants.SlotNumber slot) { ItemLocation loc = new ItemLocation(); loc.Type = Constants.ItemLocationType.Slot; loc.Slot = slot; return(loc); }
public Item(Client client, uint id, byte count, string name, ItemLocation location) { this.client = client; this.id = id; this.count = count; this.name = name; this.location = location; }
public static ItemLocation FromLocation(Location location, byte stack) { ItemLocation loc = new ItemLocation(); loc.Type = Constants.ItemLocationType.Ground; loc.GroundLocation = location; loc.StackOrder = stack; return(loc); }
public static ItemLocation FromContainer(byte container, byte position) { ItemLocation loc = new ItemLocation(); loc.Type = Constants.ItemLocationType.Container; loc.ContainerId = container; loc.ContainerSlot = position; loc.StackOrder = position; return(loc); }
/// <summary> /// Use the item on yourself /// </summary> /// <returns></returns> public bool UseOnSelf() { uint playerId = client.Player.Id; byte stack = 0; if (id == Constants.Items.Bottle.Vial.Id) { stack = count; } return(Packets.Outgoing.ItemUseBattlelistPacket.Send(client, ItemLocation.FromHotkey().ToLocation(), (ushort)id, stack, playerId)); }
/// <summary> /// Get the item in the specified slot. /// </summary> /// <param name="s"></param> /// <returns></returns> public Item GetItemInSlot(Constants.SlotNumber s) { uint address = Addresses.Player.SlotHead + 12 * ((uint)s - 1); uint id = client.Memory.ReadUInt32(address); if (id > 0) { byte count = client.Memory.ReadByte(address + Addresses.Player.DistanceSlotCount); return(new Item(client, id, count, "", ItemLocation.FromSlot(s))); } else { return(null); } }
public IEnumerable <Item> GetSlotItems() { uint address = Addresses.Player.SlotHead; for (int i = 0; i < Addresses.Player.MaxSlots; i++, address += 12) { uint id = client.Memory.ReadUInt32(address); if (id > 0) { yield return(new Item(client, id, client.Memory.ReadByte(address + +Addresses.Player.DistanceSlotCount), "", ItemLocation.FromSlot((Constants.SlotNumber)i))); } } }
public static ItemLocation FromItemLocation(ItemLocation location) { switch (location.Type) { case Pokemon.Constants.ItemLocationType.Container: return(ItemLocation.FromContainer(location.ContainerId, location.ContainerSlot)); case Pokemon.Constants.ItemLocationType.Ground: return(ItemLocation.FromLocation(location.GroundLocation, location.StackOrder)); case Pokemon.Constants.ItemLocationType.Slot: return(ItemLocation.FromSlot(location.Slot)); default: return(null); } }
/// <summary> /// Get the item at the specified location. /// </summary> /// <param name="location"></param> /// <returns></returns> public Item GetItem(ItemLocation location) { if (location.Type == Pokemon.Constants.ItemLocationType.Slot) { return(GetItemInSlot(location.Slot)); } else if (location.Type == Pokemon.Constants.ItemLocationType.Container) { long address = Addresses.Container.Start + Addresses.Container.StepContainer * (int)location.ContainerId + Addresses.Container.StepSlot * (int)location.Slot; return(new Item(client, client.Memory.ReadUInt32(address + Addresses.Container.DistanceItemId), client.Memory.ReadByte(address + Addresses.Container.DistanceItemCount), "", location)); } return(null); }
/// <summary> /// Return a list of all the items in the container. /// </summary> /// <returns></returns> public IEnumerable <Item> GetItems() { byte slot = 0; int amount = Amount; for (uint i = address; i <= address + Addresses.Container.StepSlot * amount - 1; i += Addresses.Container.StepSlot) { uint itemId = client.Memory.ReadUInt32(i + Addresses.Container.DistanceItemId); if (itemId > 0) { yield return(new Item( client, itemId, client.Memory.ReadByte(i + Addresses.Container.DistanceItemCount), "", ItemLocation.FromContainer(number, slot))); } slot++; } }
/// <summary> /// Use an item on a tile (eg. fishing) /// </summary> /// <param name="id"></param> /// <param name="onTile"></param> /// <returns></returns> public bool UseItemOnTile(uint id, Tile onTile) { return(Packets.Outgoing.ItemUseOnPacket.Send(client, ItemLocation.FromHotkey().ToLocation(), (ushort)id, 0, onTile.Location, (ushort)onTile.Ground.Id, 0)); }
/// <summary> /// Use an item on a creature of the given id /// </summary> /// <param name="id"></param> /// <param name="creatureId"></param> /// <returns></returns> public bool UseItemOnCreature(uint id, byte stack, int creatureId) { return(Packets.Outgoing.ItemUseBattlelistPacket.Send(client, ItemLocation.FromHotkey().ToLocation(), (ushort)id, stack, (uint)creatureId)); }
/// <summary> /// If you just want to use an item, like eat a food, or check gp etc /// </summary> /// <param name="id"></param> /// <returns></returns> public bool UseItem(uint id) { return(Packets.Outgoing.ItemUsePacket.Send(client, ItemLocation.FromHotkey().ToLocation(), (ushort)id, 0, 0x0F)); }