Beispiel #1
0
        private void Init()
        {
            if (ItemGuid <= 0)
            {
                return;
            }
            Asda2ItemRecord itemRec;

            try
            {
                itemRec = Asda2ItemRecord.Find(ItemGuid);
            }
            catch (NotFoundException)
            {
                LogUtil.WarnException(string.Format("Mail message {0} failed to load cause item {1} not founded. Mail message deleted.", Guid, ItemGuid));
                ItemGuid = -1;
                this.SaveLater();
                return;
            }
            Item = Asda2Item.CreateItem(itemRec, (Character)null);
        }
Beispiel #2
0
        private void Init()
        {
            if (this.ItemGuid <= 0L)
            {
                return;
            }
            Asda2ItemRecord record;

            try
            {
                record = ActiveRecordBase <Asda2ItemRecord> .Find((object)this.ItemGuid);
            }
            catch (NotFoundException ex)
            {
                LogUtil.WarnException(
                    string.Format("Mail message {0} failed to load cause item {1} not founded. Mail message deleted.",
                                  (object)this.Guid, (object)this.ItemGuid), new object[0]);
                this.ItemGuid = -1L;
                this.SaveLater();
                return;
            }

            this.Item = Asda2Item.CreateItem(record, (Character)null);
        }
Beispiel #3
0
        public static void TryRemoveItems(Character activeCharacter, List <int> itemIds)
        {
            uint entityLowId = activeCharacter.Record.EntityLowId;

            if (!Asda2AuctionMgr.ItemsByOwner.ContainsKey(entityLowId))
            {
                activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded.");
            }
            else
            {
                bool?nullable1 = new bool?();
                List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>();
                foreach (int itemId in itemIds)
                {
                    if (!Asda2AuctionMgr.ItemsByOwner[entityLowId].ContainsKey(itemId))
                    {
                        asda2ItemRecordList.Clear();
                        activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded.");
                        return;
                    }

                    Asda2ItemRecord asda2ItemRecord = Asda2AuctionMgr.ItemsByOwner[entityLowId][itemId];
                    if (!nullable1.HasValue)
                    {
                        nullable1 = new bool?(asda2ItemRecord.Template.IsShopInventoryItem);
                    }
                    bool?nullable2         = nullable1;
                    bool shopInventoryItem = asda2ItemRecord.Template.IsShopInventoryItem;
                    if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0)
                    {
                        activeCharacter.YouAreFuckingCheater(
                            "Trying to remove shop\not shop item in one auction buy request.", 1);
                        activeCharacter.SendAuctionMsg(
                            "Removing from auction failed cause founded shop\not shop items in one request.");
                    }

                    asda2ItemRecordList.Add(asda2ItemRecord);
                }

                if (nullable1.Value)
                {
                    if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count)
                    {
                        activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                        return;
                    }
                }
                else if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }

                List <Asda2ItemTradeRef> asda2Items = new List <Asda2ItemTradeRef>();
                foreach (Asda2ItemRecord record in asda2ItemRecordList)
                {
                    Asda2AuctionMgr.UnRegisterItem(record);
                    int       amount          = record.Amount;
                    int       auctionId       = record.AuctionId;
                    Asda2Item asda2Item       = (Asda2Item)null;
                    Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null);
                    int       num             = (int)activeCharacter.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true,
                                                                                           ref asda2Item, new Asda2InventoryType?(), itemToCopyStats);
                    record.DeleteLater();
                    asda2Items.Add(new Asda2ItemTradeRef()
                    {
                        Amount = amount,
                        Item   = asda2Item,
                        Price  = auctionId
                    });
                    Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId)
                    .AddAttribute("source", 0.0, "removed_from_auction").AddItemAttributes(asda2Item, "").Write();
                }

                Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, asda2Items);
            }
        }
Beispiel #4
0
        public static void TryBuy(List <int> aucIds, Character chr)
        {
            if (aucIds.Count == 0)
            {
                return;
            }
            List <Asda2ItemRecord> asda2ItemRecordList = new List <Asda2ItemRecord>();
            uint amount1   = 0;
            bool?nullable1 = new bool?();

            foreach (int aucId in aucIds)
            {
                if (!Asda2AuctionMgr.AllAuctionItems.ContainsKey(aucId))
                {
                    chr.SendAuctionMsg("Can't found item you want to buy, may be some one already buy it.");
                    return;
                }

                Asda2ItemRecord allAuctionItem = Asda2AuctionMgr.AllAuctionItems[aucId];
                if (!nullable1.HasValue)
                {
                    nullable1 = new bool?(allAuctionItem.Template.IsShopInventoryItem);
                }
                bool?nullable2         = nullable1;
                bool shopInventoryItem = allAuctionItem.Template.IsShopInventoryItem;
                if ((nullable2.GetValueOrDefault() != shopInventoryItem ? 1 : (!nullable2.HasValue ? 1 : 0)) != 0)
                {
                    chr.YouAreFuckingCheater("Trying to buy shop\not shop item in one auction buy request.", 1);
                    chr.SendAuctionMsg("Buying from auction failed cause founded shop\not shop items in one request.");
                }

                asda2ItemRecordList.Add(allAuctionItem);
                amount1 += (uint)allAuctionItem.AuctionPrice;
            }

            if (chr.Money <= amount1)
            {
                chr.SendAuctionMsg("Failed to buy items. Not enoght money.");
            }
            else
            {
                if (nullable1.HasValue && nullable1.Value)
                {
                    if (chr.Asda2Inventory.FreeShopSlotsCount < asda2ItemRecordList.Count)
                    {
                        chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                        return;
                    }
                }
                else if (chr.Asda2Inventory.FreeRegularSlotsCount < asda2ItemRecordList.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }

                chr.SubtractMoney(amount1);
                List <Asda2ItemTradeRef> items = new List <Asda2ItemTradeRef>();
                foreach (Asda2ItemRecord record in asda2ItemRecordList)
                {
                    Asda2AuctionMgr.SendMoneyToSeller(record);
                    Asda2AuctionMgr.UnRegisterItem(record);
                    int       amount2         = record.Amount;
                    int       auctionId       = record.AuctionId;
                    Asda2Item asda2Item       = (Asda2Item)null;
                    Asda2Item itemToCopyStats = Asda2Item.CreateItem(record, (Character)null);
                    int       num             = (int)chr.Asda2Inventory.TryAdd(record.ItemId, record.Amount, true, ref asda2Item,
                                                                               new Asda2InventoryType?(), itemToCopyStats);
                    items.Add(new Asda2ItemTradeRef()
                    {
                        Amount = amount2,
                        Item   = asda2Item,
                        Price  = auctionId
                    });
                    record.DeleteLater();
                }

                Asda2AuctionHandler.SendItemsBuyedFromAukResponse(chr.Client, items);
                chr.SendMoneyUpdate();
            }
        }
Beispiel #5
0
        public static void SendMailMessageRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.ReadInt32();
            short slotInq = packet.ReadInt16();
            Asda2InventoryType asda2InventoryType = (Asda2InventoryType)packet.ReadByte();
            ushort             num = packet.ReadUInt16();
            uint   sendedGold      = packet.ReadUInt32();
            string str             = packet.ReadAsdaString(20, Locale.Start);
            string subject         = packet.ReadAsdaString(32, Locale.Start);
            string message         = packet.ReadAsdaString(126, Locale.Start);

            if (!Asda2EncodingHelper.IsPrueEnglish(message))
            {
                client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("message");
                Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation,
                                                               (Asda2Item)null);
            }
            else if (!Asda2EncodingHelper.IsPrueEnglish(subject))
            {
                client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("subject");
                Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation,
                                                               (Asda2Item)null);
            }
            else
            {
                Asda2Item asda2Item = asda2InventoryType == Asda2InventoryType.Shop
          ? client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slotInq)
          : client.ActiveCharacter.Asda2Inventory.GetRegularItem(slotInq);
                if (client.ActiveCharacter.Money < 1001U || client.ActiveCharacter.Money - 1000U < sendedGold)
                {
                    Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.IncifitientGold,
                                                                   (Asda2Item)null);
                }
                else
                {
                    Character       chr    = World.GetCharacter(str, false);
                    CharacterRecord chrRec = chr == null?CharacterRecord.GetRecordByName(str) : chr.Record;

                    if (chrRec == null)
                    {
                        Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                       MailMessageSendedStatus.RecipentNotFounded, (Asda2Item)null);
                    }
                    else
                    {
                        Asda2Item sendItem = (Asda2Item)null;
                        if (asda2Item != null)
                        {
                            if (asda2Item.IsSoulbound)
                            {
                                Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                               MailMessageSendedStatus.YouCantSendThisItem, (Asda2Item)null);
                                return;
                            }

                            if (asda2Item.Amount < (int)num)
                            {
                                client.ActiveCharacter.YouAreFuckingCheater("Tying to mail wrong item amount", 50);
                                Asda2MailHandler.SendMailMessageSendedResponse(client,
                                                                               MailMessageSendedStatus.WrongInformation, (Asda2Item)null);
                                return;
                            }

                            asda2Item.ModAmount(-(num == (ushort)0 ? 1 : (int)num));
                            sendItem = Asda2Item.CreateItem(asda2Item.Template, (Character)null,
                                                            num == (ushort)0 ? 1 : (int)num);
                            sendItem.Record.SaveLater();
                        }

                        client.ActiveCharacter.SubtractMoney(sendedGold + 1000U);
                        Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                        .AddAttribute("source", 0.0, "send_mail").AddItemAttributes(sendItem, "sent")
                        .AddItemAttributes(asda2Item, "source").AddAttribute("gold", (double)sendedGold, "")
                        .AddAttribute("receiver", (double)chrRec.EntityLowId, str).Write();
                        ServerApp <WCell.RealmServer.RealmServer> .IOQueue.AddMessage((Action)(() =>
                        {
                            Asda2MailMessage record = new Asda2MailMessage(subject, message, sendItem, sendedGold,
                                                                           chrRec.EntityLowId, client.ActiveCharacter.Name);
                            record.CreateLater();
                            if (chr == null)
                            {
                                return;
                            }
                            chr.MailMessages.Add(record.Guid, record);
                            chr.SendMailMsg(string.Format("You recieve new message from {0}. Subject {1}.",
                                                          (object)client.ActiveCharacter.Name, (object)record.Subject));
                            Asda2MailHandler.SendYouHaveNewMailResponse(chr.Client, 1);
                        }));

                        Asda2MailHandler.SendMailMessageSendedResponse(client, MailMessageSendedStatus.Ok, asda2Item);
                    }
                }
            }
        }
Beispiel #6
0
        [PacketHandler(RealmServerOpCode.SendMailMessage)]//6620
        public static void SendMailMessageRequest(IRealmClient client, RealmPacketIn packet)
        {
            var sendedItemId = packet.ReadInt32();                    //default : 37823Len : 4
            var slot         = packet.ReadInt16();                    //default : 23Len : 2
            var inv          = (Asda2InventoryType)packet.ReadByte(); //default : 2Len : 1
            var amount       = packet.ReadUInt16();                   //default : 0Len : 2
            var sendedGold   = packet.ReadUInt32();                   //default : 555Len : 4
            var targetName   = packet.ReadAsdaString(20, Locale.En);  //default : Len : 18
            var subject      = packet.ReadAsdaString(32, Locale.En);  //default : Len : 32
            var message      = packet.ReadAsdaString(126, Locale.En); //default : Len : 126

            /*var prueEng = Asda2EncodingHelper.IsPrueEnglish(message);
             * if (!prueEng)
             * {
             *  client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("message");
             *  SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
             *  return;
             * }
             * prueEng = Asda2EncodingHelper.IsPrueEnglish(subject);
             * if (!prueEng)
             * {
             *  client.ActiveCharacter.SendOnlyEnglishCharactersAllowed("subject");
             *  SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
             *  return;
             * }*/
            var item = inv == Asda2InventoryType.Shop
                           ? client.ActiveCharacter.Asda2Inventory.GetShopShopItem(slot)
                           : client.ActiveCharacter.Asda2Inventory.GetRegularItem(slot);

            if (client.ActiveCharacter.Money < 1001 || client.ActiveCharacter.Money - 1000 < sendedGold)
            {
                SendMailMessageSendedResponse(client, MailMessageSendedStatus.IncifitientGold);
                return;
            }
            var chr    = World.GetCharacter(targetName, false);
            var chrRec = chr == null?CharacterRecord.GetRecordByName(targetName) : chr.Record;

            if (chrRec == null)
            {
                SendMailMessageSendedResponse(client, MailMessageSendedStatus.RecipentNotFounded);
                return;
            }
            Asda2Item sendItem = null;

            if (item != null)
            {
                if (item.IsSoulbound)
                {
                    //todo asda2 ItemMove log MailMessage
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.YouCantSendThisItem);
                    return;
                }
                if (item.Amount < amount)
                {
                    client.ActiveCharacter.YouAreFuckingCheater("Tying to mail wrong item amount", 50);
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.WrongInformation);
                    return;
                }
                if (RealmServer.IsPreparingShutdown || RealmServer.IsShuttingDown)
                {
                    SendMailMessageSendedResponse(client, MailMessageSendedStatus.YouCantSendThisItem);
                }
                if (client.ActiveCharacter.ChatBanned)
                {
                    client.ActiveCharacter.SendInfoMsg("you are banned");
                    return;
                }
                var par1   = item.Parametr1Type;
                var par11  = item.Parametr1Value;
                var par2   = item.Parametr2Type;
                var par22  = item.Parametr2Value;
                var par3   = item.Parametr3Type;
                var par33  = item.Parametr3Value;
                var par4   = item.Parametr4Type;
                var par44  = item.Parametr4Value;
                var par5   = item.Parametr5Type;
                var par55  = item.Parametr5Value;
                var Enchat = item.Enchant;
                var sowel1 = item.Soul1Id;
                var sowel2 = item.Soul2Id;
                var sowel3 = item.Soul3Id;
                var sowel4 = item.Soul4Id;
                var Dru    = item.Durability;
                item.ModAmount(-(amount == 0 ? 1 : amount));
                sendItem = Asda2Item.CreateItem(item.Template, null, amount == 0 ? 1 : amount);
                sendItem.Record.SaveLater();
                sendItem.Parametr1Type  = par1;
                sendItem.Parametr1Value = par11;
                sendItem.Parametr2Type  = par2;
                sendItem.Parametr2Value = par22;
                sendItem.Parametr3Type  = par3;
                sendItem.Parametr3Value = par33;
                sendItem.Parametr4Type  = par4;
                sendItem.Parametr4Value = par44;
                sendItem.Parametr5Type  = par5;
                sendItem.Parametr5Value = par55;
                sendItem.Enchant        = Enchat;
                sendItem.Soul1Id        = sowel1;
                sendItem.Soul2Id        = sowel2;
                sendItem.Soul3Id        = sowel3;
                sendItem.Soul4Id        = sowel4;
                sendItem.Durability     = Dru;
                sendItem.Record.SaveLater();
            }
            client.ActiveCharacter.SubtractMoney(sendedGold + 1000);
            var resLog = Log.Create(Log.Types.ItemOperations, LogSourceType.Character, client.ActiveCharacter.EntryId)
                         .AddAttribute("source", 0, "send_mail")
                         .AddItemAttributes(sendItem, "sent")
                         .AddItemAttributes(item, "source")
                         .AddAttribute("gold", sendedGold)
                         .AddAttribute("receiver", chrRec.EntityLowId, targetName)
                         .Write();

            RealmServer.IOQueue.AddMessage(() =>
            {
                var newMessage = new Asda2MailMessage(subject, message, sendItem, sendedGold, chrRec.EntityLowId, client.ActiveCharacter.Name);
                newMessage.CreateLater();
                if (chr != null)
                {
                    chr.MailMessages.Add(newMessage.Guid, newMessage);
                    chr.SendMailMsg(string.Format("You recieve new message from {0}. Subject {1}.", client.ActiveCharacter.Name, newMessage.Subject));
                    SendYouHaveNewMailResponse(chr.Client, 1);
                }
            });
            SendMailMessageSendedResponse(client, MailMessageSendedStatus.Ok, item);
            //client.ActiveCharacter.SubtractMoney(sendedGold + 1000);
        }
Beispiel #7
0
        public static void TryRemoveItems(Character activeCharacter, List <int> itemIds)
        {
            var chrId = activeCharacter.Record.EntityLowId;

            if (!ItemsByOwner.ContainsKey(chrId))
            {
                activeCharacter.SendAuctionMsg("Failed to remove items from auction. Items not founded.");
                return;
            }
            bool?isShopItems = null;
            var  items       = new List <Asda2ItemRecord>();

            foreach (var itemId in itemIds)
            {
                if (!ItemsByOwner[chrId].ContainsKey(itemId))
                {
                    items.Clear();
                    activeCharacter.SendAuctionMsg("Failed to remove items from auction. Item not founded.");
                    return;
                }
                var item = ItemsByOwner[chrId][itemId];
                if (isShopItems == null)
                {
                    isShopItems = item.Template.IsShopInventoryItem;
                }
                if (isShopItems != item.Template.IsShopInventoryItem)
                {
                    activeCharacter.YouAreFuckingCheater("Trying to remove shop\not shop item in one auction buy request.");
                    activeCharacter.SendAuctionMsg("Removing from auction failed cause founded shop\not shop items in one request.");
                }
                items.Add(item);
            }
            if ((bool)isShopItems)
            {
                if (activeCharacter.Asda2Inventory.FreeShopSlotsCount < items.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }
            }
            else
            {
                if (activeCharacter.Asda2Inventory.FreeRegularSlotsCount < items.Count)
                {
                    activeCharacter.SendAuctionMsg("Failed to delete items. Not enoght invntory space.");
                    return;
                }
            }
            var r = new List <Asda2ItemTradeRef>();

            foreach (var rec in items)
            {
                UnRegisterItem(rec);
                var       amount  = rec.Amount;
                var       aucId   = rec.AuctionId;
                Asda2Item item    = null;
                var       aucItem = Asda2Item.CreateItem(rec, (Character)null);
                activeCharacter.Asda2Inventory.TryAdd(rec.ItemId, rec.Amount, true, ref item, null, aucItem);
                rec.DeleteLater();
                r.Add(new Asda2ItemTradeRef {
                    Amount = amount, Item = item, Price = aucId
                });
                Log.Create(Log.Types.ItemOperations, LogSourceType.Character, activeCharacter.EntryId)
                .AddAttribute("source", 0, "removed_from_auction")
                .AddItemAttributes(item)
                .Write();
            }
            Asda2AuctionHandler.SendItemFromAukRemovedResponse(activeCharacter.Client, r);
        }
Beispiel #8
0
        public static void TryBuy(List <int> aucIds, Character chr)
        {
            if (aucIds.Count == 0)
            {
                return;
            }
            var  itemsToBuy  = new List <Asda2ItemRecord>();
            var  totalPrice  = 0u;
            bool?isShopItems = null;

            foreach (var aucId in aucIds)
            {
                if (!AllAuctionItems.ContainsKey(aucId))
                {
                    chr.SendAuctionMsg("Can't found item you want to buy, may be some one already buy it.");
                    return;
                }
                var item = AllAuctionItems[aucId];
                if (isShopItems == null)
                {
                    isShopItems = item.Template.IsShopInventoryItem;
                }
                if (isShopItems != item.Template.IsShopInventoryItem)
                {
                    chr.YouAreFuckingCheater("Trying to buy shop\not shop item in one auction buy request.");
                    chr.SendAuctionMsg("Buying from auction failed cause founded shop\not shop items in one request.");
                }
                itemsToBuy.Add(item);
                totalPrice += (uint)item.AuctionPrice;
            }
            if (chr.Money <= totalPrice)
            {
                chr.SendAuctionMsg("Failed to buy items. Not enoght money.");
                return;
            }
            if (isShopItems != null && isShopItems.Value)
            {
                if (chr.Asda2Inventory.FreeShopSlotsCount < itemsToBuy.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }
            }
            else
            {
                if (chr.Asda2Inventory.FreeRegularSlotsCount < itemsToBuy.Count)
                {
                    chr.SendAuctionMsg("Failed to buy items. Not enoght invntory space.");
                    return;
                }
            }
            chr.SubtractMoney(totalPrice);
            var r = new List <Asda2ItemTradeRef>();

            foreach (var itemRec in itemsToBuy)
            {
                SendMoneyToSeller(itemRec);
                UnRegisterItem(itemRec);
                var       amount    = itemRec.Amount;
                var       auctionId = itemRec.AuctionId;
                Asda2Item addedItem = null;
                var       item      = Asda2Item.CreateItem(itemRec, (Character)null);
                chr.Asda2Inventory.TryAdd(itemRec.ItemId, itemRec.Amount, true, ref addedItem, null, item);
                r.Add(new Asda2ItemTradeRef {
                    Amount = amount, Item = addedItem, Price = auctionId
                });
                itemRec.DeleteLater();
            }
            Asda2AuctionHandler.SendItemsBuyedFromAukResponse(chr.Client, r);
            chr.SendMoneyUpdate();
        }
Beispiel #9
0
        public void GuildWaveResultAndItems(Character chr)
        {
            if (chr.IsDead)
            {
                chr.Resurrect();
            }

            Asda2TitleChecker.OnGuildWaveEnd(chr, LastWinnedWave);

            Asda2GuildWaveItemRecord waveItem = null;

            foreach (Asda2GuildWaveItemRecord record in Asda2ItemMgr.GuildWaveRewardRecords)
            {
                if (record.Wave == LastWinnedWave + 1 && record.Lvl == (int)Math.Ceiling(chr.Level / 10.0F) * 10 && record.Difficulty == _difficulty)
                {
                    waveItem = record;
                    break;
                }
            }

            if (waveItem != null)
            {
                List <KeyValuePair <int, int> > pairs = new List <KeyValuePair <int, int> >();
                pairs.Add(new KeyValuePair <int, int>(1, waveItem.Chance1));
                pairs.Add(new KeyValuePair <int, int>(2, waveItem.Chance2));
                pairs.Add(new KeyValuePair <int, int>(3, waveItem.Chance3));
                pairs.Add(new KeyValuePair <int, int>(4, waveItem.Chance4));
                pairs.Add(new KeyValuePair <int, int>(5, waveItem.Chance5));
                pairs.Add(new KeyValuePair <int, int>(6, waveItem.Chance6));
                pairs.Add(new KeyValuePair <int, int>(7, waveItem.Chance7));
                pairs.Add(new KeyValuePair <int, int>(8, waveItem.Chance8));
                pairs.Sort((a, b) => a.Value.CompareTo(b.Value));

                int templateId1 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);
                int templateId2 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);
                int templateId3 = getTemplateIdFromIndex(CharacterFormulas.GetWaveRewardItems(pairs), waveItem);

                Asda2Item item1 = Asda2Item.CreateItem(templateId1, chr, 1);

                Asda2Item wavecoin = null;

                int amount = getAverageLevel() / CharacterFormulas.WaveCoinsDivider;

                if (amount > 0)
                {
                    wavecoin = Asda2Item.CreateItem(33712, chr, amount);
                    chr.Asda2Inventory.TryAdd(33712, amount, true, ref wavecoin);
                }

                chr.Asda2Inventory.TryAdd(templateId1, 1, true, ref item1);

                if (_difficulty > 0)
                {
                    Asda2Item item2 = Asda2Item.CreateItem(templateId2, chr, 1);
                    chr.Asda2Inventory.TryAdd(templateId2, 1, true, ref item2);

                    if (_difficulty == 2)
                    {
                        Asda2Item item3 = Asda2Item.CreateItem(templateId3, chr, 1);
                        chr.Asda2Inventory.TryAdd(templateId3, 1, true, ref item3);
                    }
                }

                Asda2GuildWaveHandler.GuildWaveResult(this, chr, wavecoin == null ? 0 : wavecoin.Amount, templateId1, templateId2, templateId3);
            }
        }