Exemplo n.º 1
0
        public void addItem(uint[] itemId)
        {
            if (!isSpaceForAdd(itemId[0], itemId.Length))
            {
                return;
            }

            //Update lists and db
            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));

            int startPos = list.Count;

            //New item that spilled over
            for (int i = 0; i < itemId.Length; i++)
            {
                Item          gItem     = Server.getItemGamedata(itemId[i]);
                InventoryItem addedItem = Database.addItem(owner, itemId[i], 1, (byte)1, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);
                list.Add(addedItem);
            }

            sendInventoryPackets(startPos);

            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));
            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 2
0
        public void Equip(ushort slot, InventoryItem item)
        {
            if (slot >= list.Length)
            {
                return;
            }

            if (writeToDB)
            {
                Database.equipItem(owner, slot, item.uniqueId);
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));

            if (list[slot] != null)
            {
                normalInventory.RefreshItem(list[slot], item);
            }
            else
            {
                normalInventory.RefreshItem(item);
            }

            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));
            SendEquipmentPackets(slot, item);
            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));

            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));

            list[slot] = item;
        }
Exemplo n.º 3
0
        public void removeItem(ulong itemDBId)
        {
            ushort        slot     = 0;
            InventoryItem toDelete = null;

            foreach (InventoryItem item in list)
            {
                if (item.uniqueId == itemDBId)
                {
                    toDelete = item;
                    break;
                }
                slot++;
            }

            if (toDelete == null)
            {
                return;
            }

            int oldListSize = list.Count;

            list.RemoveAt(slot);
            Database.removeItem(owner, itemDBId, inventoryCode);

            //Realign slots
            for (int i = slot; i < list.Count; i++)
            {
                list[i].slot = (ushort)i;
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));

            sendInventoryPackets(slot);
            sendInventoryRemovePackets(slot);
            if (slot != oldListSize - 1)
            {
                sendInventoryRemovePackets((ushort)(oldListSize - 1));
            }

            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));

            if (inventoryCode == NORMAL)
            {
                owner.getEquipment().SendFullEquipment(false);
            }

            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 4
0
        public void examinePlayer(Actor examinee)
        {
            Player toBeExamined;

            if (examinee is Player)
            {
                toBeExamined = (Player)examinee;
            }
            else
            {
                return;
            }

            queuePacket(InventoryBeginChangePacket.buildPacket(toBeExamined.actorId, actorId));
            toBeExamined.getEquipment().SendCheckEquipmentToPlayer(this);
            queuePacket(InventoryEndChangePacket.buildPacket(toBeExamined.actorId, actorId));
        }
Exemplo n.º 5
0
        public void removeItem(ushort slot)
        {
            if (slot >= list.Count)
            {
                return;
            }

            int oldListSize = list.Count;

            list.RemoveAt((int)slot);
            Database.removeItem(owner, slot, inventoryCode);

            //Realign slots
            for (int i = slot; i < list.Count; i++)
            {
                list[i].slot = (ushort)i;
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));

            sendInventoryPackets(slot);
            sendInventoryRemovePackets(slot);
            if (slot != oldListSize - 1)
            {
                sendInventoryRemovePackets((ushort)(oldListSize - 1));
            }

            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));

            if (inventoryCode == NORMAL)
            {
                owner.getEquipment().SendFullEquipment(false);
            }

            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 6
0
        public void Unequip(ushort slot)
        {
            if (slot >= list.Length)
            {
                return;
            }

            if (writeToDB)
            {
                Database.unequipItem(owner, slot);
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));

            normalInventory.RefreshItem(list[slot]);

            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));
            SendEquipmentPackets(slot, null);
            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));

            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));

            list[slot] = null;
        }
Exemplo n.º 7
0
        public void SetEquipment(ushort[] slots, ushort[] itemSlots)
        {
            if (slots.Length != itemSlots.Length)
            {
                return;
            }

            for (int i = 0; i < slots.Length; i++)
            {
                InventoryItem item = normalInventory.getItemBySlot(itemSlots[i]);

                if (item == null)
                {
                    continue;
                }

                Database.equipItem(owner, slots[i], item.uniqueId);
                list[slots[i]] = normalInventory.getItemBySlot(itemSlots[i]);
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            SendFullEquipment(false);
            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 8
0
        public void addItem(uint itemId, int quantity, byte quality)
        {
            if (!isSpaceForAdd(itemId, quantity))
            {
                return;
            }

            Item             gItem          = Server.getItemGamedata(itemId);
            List <ushort>    slotsToUpdate  = new List <ushort>();
            List <SubPacket> addItemPackets = new List <SubPacket>();

            //Check if item id exists
            int quantityCount = quantity;

            for (int i = 0; i < list.Count; i++)
            {
                InventoryItem item = list[i];
                if (item.itemId == itemId && item.quantity < gItem.maxStack)
                {
                    slotsToUpdate.Add(item.slot);
                    int oldQuantity = item.quantity;
                    item.quantity  = Math.Min(item.quantity + quantityCount, gItem.maxStack);
                    quantityCount -= (gItem.maxStack - oldQuantity);
                    if (quantityCount <= 0)
                    {
                        break;
                    }
                }
            }

            //If it's unique, abort
            //if (quantityCount > 0 && storedItem.isUnique)
            //      return ITEMERROR_UNIQUE;

            //If Inventory is full
            //if (quantityCount > 0 && isInventoryFull())
            //       return ITEMERROR_FULL;

            //Update lists and db
            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));

            //These had their quantities changed
            foreach (ushort slot in slotsToUpdate)
            {
                Database.setQuantity(owner, slot, inventoryCode, list[slot].quantity);

                if (inventoryCode != CURRENCY && inventoryCode != KEYITEMS)
                {
                    sendInventoryPackets(list[slot]);
                }
            }

            //New item that spilled over
            while (quantityCount > 0)
            {
                InventoryItem addedItem = Database.addItem(owner, itemId, Math.Min(quantityCount, gItem.maxStack), quality, gItem.isExclusive ? (byte)0x3 : (byte)0x0, gItem.durability, inventoryCode);


                list.Add(addedItem);

                if (inventoryCode != CURRENCY && inventoryCode != KEYITEMS)
                {
                    sendInventoryPackets(addedItem);
                }

                quantityCount -= gItem.maxStack;
            }

            if (inventoryCode == CURRENCY || inventoryCode == KEYITEMS)
            {
                sendFullInventory();
            }

            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));
            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 9
0
        public void removeItem(uint itemId, int quantity)
        {
            if (!hasItem(itemId, quantity))
            {
                return;
            }

            List <ushort>        slotsToUpdate  = new List <ushort>();
            List <InventoryItem> itemsToRemove  = new List <InventoryItem>();
            List <ushort>        slotsToRemove  = new List <ushort>();
            List <SubPacket>     addItemPackets = new List <SubPacket>();

            //Remove as we go along
            int    quantityCount = quantity;
            ushort lowestSlot    = 0;

            for (int i = list.Count - 1; i >= 0; i--)
            {
                InventoryItem item = list[i];
                if (item.itemId == itemId)
                {
                    int oldQuantity = item.quantity;
                    //Stack nomnomed
                    if (item.quantity - quantityCount <= 0)
                    {
                        itemsToRemove.Add(item);
                        slotsToRemove.Add(item.slot);
                    }
                    else
                    {
                        slotsToUpdate.Add(item.slot);
                        item.quantity -= quantityCount; //Stack reduced
                    }

                    quantityCount -= oldQuantity;
                    lowestSlot     = item.slot;

                    if (quantityCount <= 0)
                    {
                        break;
                    }
                }
            }

            for (int i = 0; i < slotsToUpdate.Count; i++)
            {
                Database.setQuantity(owner, slotsToUpdate[i], inventoryCode, list[slotsToUpdate[i]].quantity);
            }

            int oldListSize = list.Count;

            for (int i = 0; i < itemsToRemove.Count; i++)
            {
                Database.removeItem(owner, itemsToRemove[i].uniqueId, inventoryCode);
                list.Remove(itemsToRemove[i]);
            }

            //Realign slots
            for (int i = lowestSlot; i < list.Count; i++)
            {
                list[i].slot = (ushort)i;
            }

            //Added tail end items that need to be cleared for slot realignment
            for (int i = oldListSize - 1; i >= oldListSize - itemsToRemove.Count; i--)
            {
                if (!slotsToRemove.Contains((ushort)i))
                {
                    slotsToRemove.Add((ushort)i);
                }
            }

            owner.queuePacket(InventoryBeginChangePacket.buildPacket(owner.actorId));
            owner.queuePacket(InventorySetBeginPacket.buildPacket(owner.actorId, inventoryCapacity, inventoryCode));

            sendInventoryPackets(lowestSlot);
            sendInventoryRemovePackets(slotsToRemove);

            owner.queuePacket(InventorySetEndPacket.buildPacket(owner.actorId));

            if (inventoryCode == NORMAL)
            {
                owner.getEquipment().SendFullEquipment(false);
            }

            owner.queuePacket(InventoryEndChangePacket.buildPacket(owner.actorId));
        }
Exemplo n.º 10
0
        public void sendZoneInPackets(WorldManager world, ushort spawnType)
        {
            queuePacket(SetActorIsZoningPacket.buildPacket(actorId, actorId, false));
            queuePacket(_0x10Packet.buildPacket(actorId, 0xFF));
            queuePacket(SetMusicPacket.buildPacket(actorId, zone.bgmDay, 0x01));
            queuePacket(SetWeatherPacket.buildPacket(actorId, SetWeatherPacket.WEATHER_CLEAR, 1));

            queuePacket(SetMapPacket.buildPacket(actorId, zone.regionId, zone.actorId));

            queuePacket(getSpawnPackets(actorId, spawnType));
            getSpawnPackets(actorId, spawnType).debugPrintPacket();

            #region grouptest
            //Retainers
            List <ListEntry> retainerListEntries = new List <ListEntry>();
            retainerListEntries.Add(new ListEntry(actorId, 0xFFFFFFFF, 0x139E, false, true, customDisplayName));
            retainerListEntries.Add(new ListEntry(0x23, 0x0, 0xFFFFFFFF, false, false, "TEST1"));
            retainerListEntries.Add(new ListEntry(0x24, 0x0, 0xFFFFFFFF, false, false, "TEST2"));
            retainerListEntries.Add(new ListEntry(0x25, 0x0, 0xFFFFFFFF, false, false, "TEST3"));
            BasePacket retainerListPacket = BasePacket.createPacket(ListUtils.createRetainerList(actorId, 0xF4, 1, 0x800000000004e639, retainerListEntries), true, false);
            playerSession.queuePacket(retainerListPacket);

            //Party
            List <ListEntry> partyListEntries = new List <ListEntry>();
            partyListEntries.Add(new ListEntry(actorId, 0xFFFFFFFF, 0xFFFFFFFF, false, true, customDisplayName));
            partyListEntries.Add(new ListEntry(0x029B27D3, 0xFFFFFFFF, 0x195, false, true, "Valentine Bluefeather"));
            BasePacket partyListPacket = BasePacket.createPacket(ListUtils.createPartyList(actorId, 0xF4, 1, 0x8000000000696df2, partyListEntries), true, false);
            playerSession.queuePacket(partyListPacket);
            #endregion

            #region Inventory & Equipment
            queuePacket(InventoryBeginChangePacket.buildPacket(actorId));
            inventories[Inventory.NORMAL].sendFullInventory();
            inventories[Inventory.CURRENCY].sendFullInventory();
            inventories[Inventory.KEYITEMS].sendFullInventory();
            inventories[Inventory.BAZAAR].sendFullInventory();
            inventories[Inventory.MELDREQUEST].sendFullInventory();
            inventories[Inventory.LOOT].sendFullInventory();
            equipment.SendFullEquipment(false);
            playerSession.queuePacket(InventoryEndChangePacket.buildPacket(actorId), true, false);
            #endregion

            playerSession.queuePacket(getInitPackets(actorId));


            BasePacket areaMasterSpawn      = zone.getSpawnPackets(actorId);
            BasePacket debugSpawn           = world.GetDebugActor().getSpawnPackets(actorId);
            BasePacket worldMasterSpawn     = world.GetActor().getSpawnPackets(actorId);
            BasePacket weatherDirectorSpawn = new WeatherDirector(this, 8003).getSpawnPackets(actorId);
            BasePacket directorSpawn        = null;

            if (currentDirector != null)
            {
                directorSpawn = currentDirector.getSpawnPackets(actorId);
            }

            playerSession.queuePacket(areaMasterSpawn);
            playerSession.queuePacket(debugSpawn);
            if (directorSpawn != null)
            {
                //directorSpawn.debugPrintPacket();
                // currentDirector.getInitPackets(actorId).debugPrintPacket();
                queuePacket(directorSpawn);
                queuePacket(currentDirector.getInitPackets(actorId));
                //queuePacket(currentDirector.getSetEventStatusPackets(actorId));
            }
            playerSession.queuePacket(worldMasterSpawn);

            if (zone.isInn)
            {
                SetCutsceneBookPacket cutsceneBookPacket = new SetCutsceneBookPacket();
                for (int i = 0; i < 2048; i++)
                {
                    cutsceneBookPacket.cutsceneFlags[i] = true;
                }

                SubPacket packet = cutsceneBookPacket.buildPacket(actorId, "<Path Companion>", 11, 1, 1);

                packet.debugPrintSubPacket();
                queuePacket(packet);
            }

            playerSession.queuePacket(weatherDirectorSpawn);

/*
 #region hardcode
 *          BasePacket reply10 = new BasePacket("./packets/login/login10.bin"); //Item Storage, Inn Door created
 *          BasePacket reply11 = new BasePacket("./packets/login/login11.bin"); //NPC Create ??? Final init
 *          reply10.replaceActorID(actorId);
 *          reply11.replaceActorID(actorId);
 *          //playerSession.queuePacket(reply10);
 *         // playerSession.queuePacket(reply11);
 #endregion
 */
        }