Пример #1
0
        public void RequestTake(RealmTime time, RequestTradePacket pkt)
        {
            if (tradeTarget != null)
            {
                SendError("You're already trading!");
                tradeTarget = null;
                return;
            }
            var target = Owner.GetUniqueNamedPlayer(pkt.Name);
            if (target == null)
            {
                SendError("Player not found!");
                return;
            }
            if (target.tradeTarget != null && target.tradeTarget != this)
            {
                SendError(target.Name + " is already trading!");
                return;
            }
                tradeTarget = target;
                trade = new bool[12];
                tradeAccepted = false;
                target.tradeTarget = this;
                target.trade = new bool[12];
                taking = true;
                tradeTarget.intake = true;
                var my = new TradeItem[Inventory.Length];
                for (var i = 0; i < Inventory.Length; i++)
                    my[i] = new TradeItem
                    {
                        Item = target.Inventory[i] == null ? -1 : target.Inventory[i].ObjectType,
                        SlotType = target.SlotTypes[i],
                        Included = false,
                        Tradeable = (target.Inventory[i] != null)

                    };
                var your = new TradeItem[target.Inventory.Length];
                for (var i = 0; i < target.Inventory.Length; i++)
                    your[i] = new TradeItem
                    {
                        Item = -1,
                        SlotType = target.SlotTypes[i],
                        Included = false,
                        Tradeable = false

                    };

                psr.SendPacket(new TradeStartPacket
                {
                    MyItems = my,
                    YourName = target.Name,
                    YourItems = your
                });
        }
Пример #2
0
 public void RequestForge(RealmTime time, RequestTradePacket pkt)
 {
     if (tradeTarget != null)
     {
         SendError("You're already trading!");
         tradeTarget = null;
         return;
     }
     trade = new bool[12];
     tradeAccepted = false;
     forging = true;
     ForgeList f = new ForgeList();
     foreach (var i in f.combos)
     {
         for (var x = 0; x < i.Key.Length; x++)
         {
             requestedItems.Add(i.Key[x]);
         }
         for (var x = 0; x < Inventory.Length; x++)
         {
             if (Inventory[x] != null)
             {
                 playerItems.Add(Inventory[x].ObjectId);
             }
         }
         for (var x = 0; x < playerItems.Count; x++)
         {
             for (var y = 0; y < requestedItems.Count; y++)
             {
                 if (requestedItems[y] == playerItems[x])
                 {
                     requestedItems.RemoveAt(y);
                     break;
                 }
             }
         }
         if (requestedItems.Count == 0)
         {
             var icdatas = new Dictionary<string, short>(db.data.XmlDatas.IdToType, StringComparer.OrdinalIgnoreCase);
             short objType;
             icdatas.TryGetValue(i.Value, out objType);
             forgableItems.Add(objType);
         }
     }
     if (forgableItems.Count < Inventory.Length)
     {
         for (var i = forgableItems.Count; i < Inventory.Length; i++)
         {
             forgableItems.Add(-1);
         }
     }
     var my = new TradeItem[Inventory.Length];
     for (var i = 0; i < Inventory.Length; i++)
     {
         my[i] = new TradeItem
         {
             Item = forgableItems[i],
             SlotType = SlotTypes[0],
             Included = false,
             Tradeable = forgableItems[i] != -1
         };
     }
     var your = new TradeItem[12];
     for (var i = 0; i < Inventory.Length; i++)
         your[i] = new TradeItem
         {
             Item = Inventory[i] == null ? -1 : Inventory[i].ObjectType,
             SlotType = SlotTypes[i],
             Included = false,
             Tradeable = false
         };
     psr.SendPacket(new TradeStartPacket
     {
         MyItems = my,
         YourName = "Items",
         YourItems = your
     });
 }
Пример #3
0
        public void RequestTrade(RealmTime time, RequestTradePacket pkt)
        {
            if (!NameChosen)
            {
                SendInfo("Unique name is required to trade with others!");
                return;
            }
            if (tradeTarget != null)
            {
                SendError("You're already trading!");
                tradeTarget = null;
                return;
            }
            var target = Owner.GetUniqueNamedPlayer(pkt.Name);
            if (target == null)
            {
                SendError("Player not found!");
                return;
            }
            if (target.tradeTarget != null && target.tradeTarget != this)
            {
                SendError(target.Name + " is already trading!");
                return;
            }

            if (potentialTrader.ContainsKey(target))
            {
                tradeTarget = target;
                trade = new bool[12];
                tradeAccepted = false;
                target.tradeTarget = this;
                target.trade = new bool[12];
                target.tradeAccepted = false;
                potentialTrader.Clear();
                target.potentialTrader.Clear();

                var my = new TradeItem[Inventory.Length];
                for (var i = 0; i < Inventory.Length; i++)
                    my[i] = new TradeItem
                    {
                        Item = Inventory[i] == null ? -1 : Inventory[i].ObjectType,
                        SlotType = SlotTypes[i],
                        Included = false,
                        Tradeable =
                            (Inventory[i] != null && i >= 4) && (!Inventory[i].Soulbound && !Inventory[i].Undead && !Inventory[i].SUndead)
                    };
                var your = new TradeItem[target.Inventory.Length];
                for (var i = 0; i < target.Inventory.Length; i++)
                    your[i] = new TradeItem
                    {
                        Item = target.Inventory[i] == null ? -1 : target.Inventory[i].ObjectType,
                        SlotType = target.SlotTypes[i],
                        Included = false,
                        Tradeable =
                            (target.Inventory[i] != null && i >= 4) && (!target.Inventory[i].Soulbound && !target.Inventory[i].Undead &&
                                                                        !target.Inventory[i].SUndead)
                    };

                psr.SendPacket(new TradeStartPacket
                {
                    MyItems = my,
                    YourName = target.Name,
                    YourItems = your
                });
                target.psr.SendPacket(new TradeStartPacket
                {
                    MyItems = your,
                    YourName = Name,
                    YourItems = my
                });
            }
            else
            {
                target.potentialTrader[this] = 1000*20;
                target.psr.SendPacket(new TradeRequestedPacket
                {
                    Name = Name
                });
                SendInfo("Sent trade request to " + target.Name);
            }
        }
Пример #4
0
        public void RequestTrade(RealmTime time, RequestTradePacket pkt)
        {
            if (!NameChosen)
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars = -1,
                    Name = "",
                    Text = "Unique name is required to trade with other!"
                });
                return;
            }
            if (tradeTarget != null)
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars = -1,
                    Name = "*Error*",
                    Text = "You're already trading!"
                });
                return;
            }
            Player target = Owner.GetUniqueNamedPlayer(pkt.Name);
            if (target == null)
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars = -1,
                    Name = "*Error*",
                    Text = "Player not found!"
                });
                return;
            }
            if (target.tradeTarget != null && target.tradeTarget != this)
            {
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars = -1,
                    Name = "*Error*",
                    Text = target.Name + " is already trading!"
                });
                return;
            }

            if (this.potentialTrader.ContainsKey(target))
            {
                this.tradeTarget = target;
                this.trade = new bool[12];
                this.tradeAccepted = false;
                target.tradeTarget = this;
                target.trade = new bool[12];
                target.tradeAccepted = false;
                this.potentialTrader.Clear();
                target.potentialTrader.Clear();

                TradeItem[] my = new TradeItem[this.Inventory.Length];
                for (int i = 0; i < this.Inventory.Length; i++)
                    my[i] = new TradeItem()
                    {
                        Item = this.Inventory[i] == null ? -1 : this.Inventory[i].ObjectType,
                        SlotType = this.SlotTypes[i],
                        Included = false,
                        Tradeable = (this.Inventory[i] == null || i < 4) ? false : !this.Inventory[i].Soulbound
                    };
                TradeItem[] your = new TradeItem[target.Inventory.Length];
                for (int i = 0; i < target.Inventory.Length; i++)
                    your[i] = new TradeItem()
                    {
                        Item = target.Inventory[i] == null ? -1 : target.Inventory[i].ObjectType,
                        SlotType = target.SlotTypes[i],
                        Included = false,
                        Tradeable = (target.Inventory[i] == null || i < 4) ? false : !target.Inventory[i].Soulbound
                    };

                this.psr.SendPacket(new TradeStartPacket()
                {
                    MyItems = my,
                    YourName = target.Name,
                    YourItems = your
                });
                target.psr.SendPacket(new TradeStartPacket()
                {
                    MyItems = your,
                    YourName = this.Name,
                    YourItems = my
                });
            }
            else
            {
                target.potentialTrader[this] = 1000 * 20;
                target.psr.SendPacket(new TradeRequestedPacket()
                {
                    Name = Name
                });
                psr.SendPacket(new TextPacket()
                {
                    BubbleTime = 0,
                    Stars = -1,
                    Name = "",
                    Text = "You have sent a trade request to " + target.Name + "!"
                });
                return;
            }
        }