예제 #1
0
            public static bool AddItem(Character chr, Asda2ItemTemplate templ, int amount, Character triggerer)
            {
                int num = amount;
                Asda2PlayerInventory asda2Inventory      = chr.Asda2Inventory;
                Asda2Item            asda2Item           = (Asda2Item)null;
                Asda2InventoryError  asda2InventoryError = asda2Inventory.TryAdd((int)templ.ItemId, amount, false,
                                                                                 ref asda2Item, new Asda2InventoryType?(), (Asda2Item)null);

                if (asda2InventoryError != Asda2InventoryError.Ok || amount < num)
                {
                    if (asda2InventoryError != Asda2InventoryError.Ok)
                    {
                        Asda2InventoryHandler.SendItemReplacedResponse(chr.Client, Asda2InventoryError.NotInfoAboutItem,
                                                                       (short)0, (byte)0, 0, (short)0, 0, (byte)0, 0, (short)0, false);
                    }
                    return(false);
                }

                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, chr.EntryId)
                .AddAttribute("source", 0.0, "created_by_gm").AddItemAttributes(asda2Item, "")
                .AddAttribute("map", (double)chr.MapId, chr.MapId.ToString())
                .AddAttribute("x", (double)chr.Asda2Position.X, "")
                .AddAttribute("y", (double)chr.Asda2Position.Y, "")
                .AddAttribute("gm", (double)triggerer.EntryId, triggerer.Name).Write();
                Asda2InventoryHandler.SendBuyItemResponse(Asda2BuyItemStatus.Ok, chr, new Asda2Item[5]
                {
                    asda2Item,
                    null,
                    null,
                    null,
                    null
                });
                return(true);
            }
예제 #2
0
        public static void SendInventoryInfoResponse(IRealmClient client)
        {
            Asda2PlayerInventory     asda2Inventory    = client.ActiveCharacter.Asda2Inventory;
            List <List <Asda2Item> > asda2ItemListList = new List <List <Asda2Item> >();
            int count1 = 0;

            Asda2Item[] array1 = asda2Inventory.RegularItems
                                 .Where(it => it != null).ToArray();
            while (count1 < array1.Length)
            {
                asda2ItemListList.Add(new List <Asda2Item>(array1.Skip(count1)
                                                           .Take(9)));
                count1 += 9;
            }

            foreach (List <Asda2Item> asda2ItemList in asda2ItemListList)
            {
                using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.RegularInventoryInfo))
                {
                    for (int index = 0; index < asda2ItemList.Count; ++index)
                    {
                        Asda2Item asda2Item = asda2ItemList[index];
                        if (asda2Item != null)
                        {
                            Asda2InventoryHandler.WriteItemInfoToPacket(packet, asda2Item, false);
                        }
                    }

                    client.Send(packet, false);
                }
            }

            asda2ItemListList.Clear();
            int count2 = 0;

            Asda2Item[] array2 = asda2Inventory.ShopItems
                                 .Where(it => it != null).ToArray();
            while (count2 < array2.Length)
            {
                asda2ItemListList.Add(new List <Asda2Item>(array2.Skip(count2)
                                                           .Take(9)));
                count2 += 9;
            }

            foreach (List <Asda2Item> asda2ItemList in asda2ItemListList)
            {
                using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ShopInventoryInfo))
                {
                    for (int index = 0; index < asda2ItemList.Count; ++index)
                    {
                        Asda2Item asda2Item = asda2ItemList[index];
                        if (asda2Item != null)
                        {
                            Asda2InventoryHandler.WriteItemInfoToPacket(packet, asda2Item, false);
                        }
                    }

                    client.Send(packet, false);
                }
            }
        }
예제 #3
0
        public static void RegisterItemToAukRequest(IRealmClient client, RealmPacketIn packet)
        {
            Character            activeCharacter = client.ActiveCharacter;
            Asda2PlayerInventory asda2Inventory  = activeCharacter.Asda2Inventory;

            packet.Position += 15;
            int num1 = 0;
            List <Asda2ItemTradeRef> items = new List <Asda2ItemTradeRef>();

            for (int index = 0; index < 5 && packet.RemainingLength >= 50; ++index)
            {
                packet.Position += 4;
                byte  num2 = packet.ReadByte();
                short num3 = packet.ReadInt16();
                packet.Position += 12;
                int num4 = packet.ReadInt32();
                packet.Position += 34;
                int num5 = packet.ReadInt32();
                packet.Position += 41;
                if (num5 < 0 || num5 > 100000000)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong price while registering auk items : " + (object)num3, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                if (num3 < (short)0 || num3 > (short)70)
                {
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong cell while registering auk items : " + (object)num3, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                Asda2Item asda2Item;
                switch (num2)
                {
                case 1:
                    asda2Item = asda2Inventory.ShopItems[(int)num3];
                    break;

                case 2:
                    asda2Item = asda2Inventory.RegularItems[(int)num3];
                    break;

                default:
                    client.ActiveCharacter.YouAreFuckingCheater(
                        "Tried to use wrong inventory while registering auk items : " + (object)num2, 1);
                    Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                  (List <Asda2ItemTradeRef>)null);
                    return;
                }

                items.Add(new Asda2ItemTradeRef()
                {
                    Item   = asda2Item,
                    Amount = num4,
                    Price  = num5
                });
                num1 += num5;
            }

            if ((double)client.ActiveCharacter.Money <=
                (double)num1 * (double)CharacterFormulas.AuctionPushComission)
            {
                client.ActiveCharacter.SendAuctionMsg("Not enought money to register items.");
                Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client, (List <Asda2ItemTradeRef>)null);
            }
            else
            {
                Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client, items);
                foreach (Asda2ItemTradeRef itemRef in items)
                {
                    if (itemRef.Item == null)
                    {
                        activeCharacter.SendAuctionMsg("Failed to register item cause not founded.");
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    if (itemRef.Amount < 0 || itemRef.Amount > itemRef.Item.Amount)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater(
                            "Tried to use wrong item amount while registering auk items : " + (object)itemRef.Amount,
                            1);
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    if (itemRef.Item.IsSoulbound)
                    {
                        client.ActiveCharacter.YouAreFuckingCheater(
                            "Tried to use soulbounded item while registering auk items : " + (object)itemRef.Amount,
                            1);
                        Asda2AuctionHandler.SendRegisterItemToAukCancelWindowResponse(client,
                                                                                      (List <Asda2ItemTradeRef>)null);
                        return;
                    }

                    asda2Inventory.AuctionItem(itemRef);
                }

                AchievementProgressRecord progressRecord =
                    client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(10U);
                switch (++progressRecord.Counter)
                {
                case 100:
                    client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Merchant48);
                    break;

                case 200:
                    client.ActiveCharacter.GetTitle(Asda2TitleId.Merchant48);
                    break;
                }

                progressRecord.SaveAndFlush();
                activeCharacter.SendAuctionMsg("You have success with registering auction items.");
                activeCharacter.SendMoneyUpdate();
            }
        }