Exemplo n.º 1
0
        public void InventorySwap(RealmTime time, InvSwapPacket pkt)
        {
            Entity en1 = Owner.GetEntity(pkt.Obj1.ObjectId);
            Entity en2 = Owner.GetEntity(pkt.Obj2.ObjectId);
            IContainer con1 = en1 as IContainer;
            IContainer con2 = en2 as IContainer;

            //TODO: locker
            Item item1 = con1.Inventory[pkt.Obj1.SlotId];
            Item item2 = con2.Inventory[pkt.Obj2.SlotId];
            if (!AuditItem(con2, item1, pkt.Obj2.SlotId) ||
                !AuditItem(con1, item2, pkt.Obj1.SlotId))
                (en1 as Player).Client.SendPacket(new InvResultPacket() { Result = 1 });
            else
            {
                con1.Inventory[pkt.Obj1.SlotId] = item2;
                con2.Inventory[pkt.Obj2.SlotId] = item1;
                en1.UpdateCount++;
                en2.UpdateCount++;

                if (en1 is Player)
                {
                    (en1 as Player).CalcBoost();
                    (en1 as Player).Client.SendPacket(new InvResultPacket() { Result = 0 });
                }
                if (en2 is Player)
                {
                    (en2 as Player).CalcBoost();
                    (en2 as Player).Client.SendPacket(new InvResultPacket() { Result = 0 });
                }
            }
        }
        public void InventorySwap(RealmTime time, InvSwapPacket pkt)
        {
            var en1 = Owner.GetEntity(pkt.Obj1.ObjectId);
            var en2 = Owner.GetEntity(pkt.Obj2.ObjectId);
            var con1 = en1 as IContainer;
            var con2 = en2 as IContainer;

            //TODO: locker
            var item1 = con1.Inventory[pkt.Obj1.SlotId];
            var item2 = con2.Inventory[pkt.Obj2.SlotId];
            if (!AuditItem(con2, item1, pkt.Obj2.SlotId) ||
                !AuditItem(con1, item2, pkt.Obj1.SlotId))
                (en1 as Player).Client.SendPacket(new InvResultPacket {Result = 1});
            else
            {
                var publicbags = new List<short>
                {
                    0x0500,
                    0xffd,
                    0x0501
                };

                con1.Inventory[pkt.Obj1.SlotId] = item2;
                con2.Inventory[pkt.Obj2.SlotId] = item1;

                if (publicbags.Contains(en1.ObjectType) && (item2.Soulbound || item2.Undead || item2.SUndead))
                {
                    DropBag(item2);
                    con1.Inventory[pkt.Obj1.SlotId] = null;
                }
                if (publicbags.Contains(en2.ObjectType) && (item1.Soulbound || item1.Undead || item1.SUndead))
                {
                    DropBag(item1);
                    con2.Inventory[pkt.Obj2.SlotId] = null;
                }

                en1.UpdateCount++;
                en2.UpdateCount++;

                if (en1 is Player)
                {
                    if (en1.Owner.Name == "Vault")
                        (en1 as Player).Client.Save();
                    (en1 as Player).CalcBoost();
                    (en1 as Player).Client.SendPacket(new InvResultPacket {Result = 0});
                }
                if (en2 is Player)
                {
                    if (en2.Owner.Name == "Vault")
                        (en2 as Player).Client.Save();
                    (en2 as Player).CalcBoost();
                    (en2 as Player).Client.SendPacket(new InvResultPacket {Result = 0});
                }

                if (Owner is Vault)
                    if ((Owner as Vault).psr.Account.Name == psr.Account.Name)
                        return;

                if (!(en2 is Player))
                {
                    var con = en2 as Container;
                    const string dir = @"logs";
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    using (var writer = new StreamWriter(@"logs\DropLog.log", true))
                    {
                        writer.WriteLine(Name + " placed a " + item1.ObjectId +
                                         (con.BagOwner != null ? " (Soulbound)" : ""));
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void InventorySwap(RealmTime time, InvSwapPacket pkt)
        {
            Entity en1 = Owner.GetEntity(pkt.Obj1.ObjectId);
            Entity en2 = Owner.GetEntity(pkt.Obj2.ObjectId);
            IContainer con1 = en1 as IContainer;
            IContainer con2 = en2 as IContainer;

            //TODO: locker
            Item item1 = con1.Inventory[pkt.Obj1.SlotId];
            Item item2 = con2.Inventory[pkt.Obj2.SlotId];
            if (!AuditItem(con2, item1, pkt.Obj2.SlotId) ||
                !AuditItem(con1, item2, pkt.Obj1.SlotId))
                (en1 as Player).Client.SendPacket(new InvResultPacket() { Result = 1 });
            else
            {
                List<short> publicbags = new List<short>() {
                    0x0500,
                    0xffd
                };

                con1.Inventory[pkt.Obj1.SlotId] = item2;
                con2.Inventory[pkt.Obj2.SlotId] = item1;

                if (publicbags.Contains(en1.ObjectType) && (item2.Soulbound || item2.Undead || item2.SUndead))
                {
                    DropBag(item2);
                    con1.Inventory[pkt.Obj1.SlotId] = null;
                }
                if (publicbags.Contains(en2.ObjectType) && (item1.Soulbound || item1.Undead || item1.SUndead))
                {
                    DropBag(item1);
                    con2.Inventory[pkt.Obj2.SlotId] = null;
                }

                en1.UpdateCount++;
                en2.UpdateCount++;

                if (en1 is Player)
                {
                    if (en1.Owner.Name == "Vault")
                        (en1 as Player).Client.Save();
                    (en1 as Player).CalcBoost();
                    (en1 as Player).Client.SendPacket(new InvResultPacket() { Result = 0 });
                }
                if (en2 is Player)
                {
                    if (en2.Owner.Name == "Vault")
                        (en2 as Player).Client.Save();
                    (en2 as Player).CalcBoost();
                    (en2 as Player).Client.SendPacket(new InvResultPacket() { Result = 0 });
                }
            }
        }