コード例 #1
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
        public static ItemLocation FromSlot(Constants.SlotNumber slot)
        {
            ItemLocation loc = new ItemLocation();

            loc.Type = Constants.ItemLocationType.Slot;
            loc.Slot = slot;
            return(loc);
        }
コード例 #2
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
 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;
 }
コード例 #3
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
        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);
        }
コード例 #4
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
        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);
        }
コード例 #5
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
        /// <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));
        }
コード例 #6
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
        /// <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);
            }
        }
コード例 #7
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
        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)));
                }
            }
        }
コード例 #8
0
ファイル: Item.cs プロジェクト: FaNtA91/pokemonapi
        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);
            }
        }
コード例 #9
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
 /// <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);
 }
コード例 #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++;
            }
        }
コード例 #11
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
 /// <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));
 }
コード例 #12
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
 /// <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));
 }
コード例 #13
0
ファイル: Inventory.cs プロジェクト: FaNtA91/pokemonapi
 /// <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));
 }