Ejemplo n.º 1
0
        public static ItemLocation FromSlot(Constants.SlotNumber slot)
        {
            ItemLocation loc = new ItemLocation();

            loc.Type = Constants.ItemLocationType.Slot;
            loc.Slot = slot;
            return(loc);
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        /// <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));
        }
Ejemplo n.º 6
0
        /// <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);
            }
        }
Ejemplo n.º 7
0
        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)));
                }
            }
        }
Ejemplo n.º 8
0
        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);
            }
        }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
        /// <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++;
            }
        }
Ejemplo n.º 11
0
 /// <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));
 }
Ejemplo n.º 12
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));
 }
Ejemplo n.º 13
0
 /// <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));
 }