Пример #1
0
        private void WritePostRolls(PacketOut Out)
        {
            int maxCount = Math.Min(24, _postRoll.Count);

            for (int i = 0; i < maxCount; i++)
            {
                ContributionInfo curRoll = _postRoll[i].Value;

                Out.WriteStringBytes(curRoll.PlayerName);
                Out.Fill(0, 24 - curRoll.PlayerName.Length);
                Out.Fill(0, 2);
                Out.WriteUInt16R((ushort)curRoll.RandomBonus);
                Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
                Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
                Out.WriteByte(1);              // ???
                Out.WriteByte(curRoll.BagWon); // bag won
            }

            if (maxCount < 24)
            {
                for (int i = maxCount; i < 24; i++)
                {
                    Out.Fill(0, 34);  // i just send empty once here
                }
            }
        }
Пример #2
0
        /// <summary>
        /// <para>Adds contribution for a player. This is based on renown earned and comes from 4 sources at the moment:</para>
        /// <para>- Killing players.</para>
        /// <para>- Objective personal capture rewards.</para>
        /// <para>- Objective defense tick rewards.</para>
        /// <para>- Destroying siege weapons.</para>
        /// </summary>
        public void AddContribution(Player plr, uint contribution)
        {
            if (!plr.ValidInTier(_tier, true))
            {
                return;
            }

            ContributionInfo contrib;

            if (!PlayerContributions.TryGetValue(plr.CharacterId, out contrib))
            {
                contrib = new ContributionInfo(plr);
                PlayerContributions.Add(plr.CharacterId, contrib);
            }

            float contributionScaler;

            // Better rewards depending on group organization status.
            if (plr.WorldGroup == null)
            {
                contributionScaler    = 1f;
                contrib.ActiveTimeEnd = TCPManager.GetTimeStamp() + 90; // 1.5 minutes for solo
            }
            else
            {
                int memberCount = plr.WorldGroup.TotalMemberCount;
                contributionScaler    = 1f + memberCount * 0.05f;
                contrib.ActiveTimeEnd = TCPManager.GetTimeStamp() + 90 + (10 * memberCount); // 4.5 minutes for full warband
            }

            uint contribGain = (uint)(contribution * RENOWN_CONTRIBUTION_FACTOR * contributionScaler);

            contrib.BaseContribution += contribGain;
            TotalContribFromRenown   += contribGain;
        }
Пример #3
0
 public static void SetContributionInfoToProfileViewModel(ContributionInfo profile)
 {
     if (profile != null && profile.Contributions != null)
     {
         MyProfileViewModel.Instance.TotalOfData = profile.TotalContributions;
         MyProfileViewModel.Instance.List        = new System.Collections.ObjectModel.ObservableCollection <ContributionModel>();
         foreach (var contribution in profile.Contributions)
         {
             MvpHelper.SetIconAndLabelTextOfContribution(contribution);
             MyProfileViewModel.Instance.List.Add(contribution);
         }
     }
 }
Пример #4
0
        public static void SetContributionInfoToProfileViewModel(ContributionInfo profile)
        {
            if (profile != null && profile.Contributions != null)
            {
                MyProfileViewModel.Instance.TotalOfData = profile.TotalContributions;
                MyProfileViewModel.Instance.List        = new ObservableRangeCollection <ContributionModel>();

                var contributions = profile.Contributions.Select(c =>
                {
                    SetLabelTextOfContribution(c);
                    return(c);
                });

                MyProfileViewModel.Instance.List.AddRange(contributions);
            }
        }
Пример #5
0
        private void WritePersonalPreRolls(PacketOut Out)
        {
            int maxCount = Math.Min(24, 1);

            for (int i = 0; i < maxCount; i++)
            {
                ContributionInfo curRoll = _preRoll[i].Value;

                Out.WriteStringBytes(curRoll.PlayerName);
                Out.Fill(0, 24 - curRoll.PlayerName.Length);
                Out.Fill(0, 2);
                Out.WriteUInt16R((ushort)curRoll.RandomBonus);
                Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
                Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
            }

            if (maxCount < 24)
            {
                for (int i = maxCount; i < 24; i++)
                {
                    Out.Fill(0, 32);
                }
            }
        }
Пример #6
0
        public void Scoreboard(ContributionInfo playerRoll, int preIndex, int postIndex)
        {
            Player targPlayer = Player.GetPlayer(playerRoll.PlayerCharId);

            if (targPlayer == null)
            {
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_PQLOOT_TRIGGER, 1723);

            Out.WriteStringBytes(_publicQuestInfo.Name);
            Out.Fill(0, 24 - _publicQuestInfo.Name.Length);
            Out.WriteByte(_bags[gold]);  // gold
            Out.WriteByte(_bags[purple]);
            Out.WriteByte(_bags[blue]);
            Out.WriteByte(_bags[green]);
            Out.WriteByte(_bags[white]); // white
            Out.Fill(0, 3);

            WritePreRolls(Out);

            Out.WriteStringBytes(playerRoll.PlayerName);
            Out.Fill(0, 24 - playerRoll.PlayerName.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteUInt16((ushort)(preIndex + 1)); // place

            WritePostRolls(Out);

            Out.WriteUInt16((ushort)(postIndex + 1)); // place
            Out.WriteStringBytes(playerRoll.PlayerName);
            Out.Fill(0, 24 - playerRoll.PlayerName.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteByte(1);                 // ???
            Out.WriteByte(playerRoll.BagWon); // bag won

            Out.Fill(0, 2);
            //Out.WriteUInt16(TIME_PQ_RESET);
            Out.WriteByte(0);
            Out.WriteByte(3);


            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.Fill(0, 27);
            //
            // no clue yet seams to be if you didnt won anything you get that item


            /*
             * Out.WritePacketString(@"|d4 c0 01 |...d............|
             |57 61 72 20 43 72 65 73 74 00 00 00 00 00 00 00 |War Crest.......|
             |00 00 00 00 00 00 00 00 00 00 00                |...........     |
             * ");
             */

            targPlayer.SendPacket(Out);
            // Info.SendCurrentStage(plr);
        }  //  d4 c0 01
Пример #7
0
        // Sevetar - commented out as it contains legacy RVR calls. Kept in as it might include useful logic
        //private void RollForPersonalBag(ContributionInfo player, float bagCountMod, Dictionary<uint, ContributionInfo> players, RegionMgr region)
        //{

        //    for (int i = 0; i < 5; ++i)
        //    {
        //        _availableBags[i] = 0;
        //    }
        //    for (int i = 0; i < 5; ++i)
        //    {
        //        _bags[i] = 0;
        //    }
        //    ProximityBattleFront bf = null;
        //    int aaoMult = 0;
        //    bool isBonusAppliedAndConsumed = true;
        //    Realms aaoRealm = Realms.REALMS_REALM_NEUTRAL;
        //    Player targPlayer = Player.GetPlayer(player.PlayerCharId);
        //    Character targCharacter = CharMgr.GetCharacter(player.PlayerCharId, true);
        //    if (region != null && region.Bttlfront != null && region.Bttlfront is ProximityBattleFront)
        //    {
        //        bf = region.Bttlfront as ProximityBattleFront;
        //        if (bf != null)
        //        {
        //            aaoMult = Math.Abs(bf._againstAllOddsMult);
        //            if (aaoMult != 0)
        //                aaoRealm = bf._againstAllOddsMult > 0 ? Realms.REALMS_REALM_DESTRUCTION : Realms.REALMS_REALM_ORDER;
        //        }

        //        if (targPlayer != null)
        //        {
        //            //T2 16-19, use bonus rolls
        //            if (region.GetTier() == 2)
        //            {
        //                if (targPlayer.Level < 16 || targPlayer.Level > 19)
        //                {
        //                    isBonusAppliedAndConsumed = false;
        //                }
        //            }
        //            //T3 20-29, use bonus rolls
        //            if (region.GetTier() == 3)
        //            {
        //                if (targPlayer.Level < 20 || targPlayer.Level > 29)
        //                {
        //                    isBonusAppliedAndConsumed = false;
        //                }
        //            }

        //            if (region.GetTier() == 4)
        //            {
        //                if (targPlayer.Level < 30)
        //                {
        //                    isBonusAppliedAndConsumed = false;
        //                }
        //            }
        //        }
        //    }
        //    //Which side is outnumbered?
        //    float aaoMultOutnumberedSide = aaoMult / 2.5f;
        //    //Which side is outnumbering the other side?
        //    float aaoMultOutnumberingSide = aaoMult / 2.5f;

        //    //Being outnumbered has a cap of 2, 10% bonus to your roll.
        //    if (aaoMultOutnumberedSide > 1f)
        //        aaoMultOutnumberedSide = 1f;

        //    //Being utnumbering has a cap of 40% penalty.
        //    if (aaoMultOutnumberingSide > 4f)
        //        aaoMultOutnumberingSide = 4f;

        //    //Divide by 10f to get sane multipliers for rolls
        //    aaoMultOutnumberedSide = aaoMultOutnumberedSide / 10f;
        //    aaoMultOutnumberingSide = aaoMultOutnumberingSide / 10f;

        //    const double goldChance = 0.01, purpChance = 0.05, blueChance = 0.1, greenChance = 0.15, whiteChance = 0.2;
        //    _preRoll = players.OrderByDescending(plrs => plrs.Value.BaseContribution).ToList();
        //    float acv = _preRoll.Sum(plrs => plrs.Value.BaseContribution) / _preRoll.Count;
        //    //handle roll value
        //    if (player.OptOutType == 1)
        //    {
        //        player.RandomBonus = 1;
        //        if (targPlayer != null)
        //        {
        //            targPlayer.SendLocalizeString(_publicQuestInfo.Name, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_PUBLIC_QUEST_OPT_OUT_APPLIED);
        //        }
        //    }
        //    else if (player.BaseContribution > acv * .10)
        //    {
        //        player.RandomBonus = (ushort)RandomMgr.Next(0, 1000);

        //        int temporaryBonus = (int)player.RandomBonus;
        //        if (aaoRealm != Realms.REALMS_REALM_NEUTRAL && aaoMult != 0)
        //        {
        //            if (targPlayer != null)
        //            {
        //                targPlayer.SendClientMessage("Your roll has been adjusted due to your army's size.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //            }
        //            if (player.PlayerRealm == aaoRealm)
        //            {
        //                temporaryBonus += (int)(player.RandomBonus * (aaoMultOutnumberedSide));
        //            }
        //            else
        //            {
        //                temporaryBonus -= (int)(player.RandomBonus * (aaoMultOutnumberingSide));
        //            }

        //        }
        //        player.RandomBonus = (uint)(Math.Max(2, temporaryBonus));
        //        if (targPlayer != null)
        //            targPlayer.SendClientMessage("You roll " + player.RandomBonus + ".", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //    }
        //    else
        //    {
        //        player.RandomBonus = 1;
        //    }

        //    float contribFactor = player.BaseContribution > acv ? player.BaseContribution / acv : 1f;
        //    float malus = 0;

        //    //get player bag pools

        //    if (targCharacter != null)
        //    {
        //        if (targCharacter.Bag_Pools == null)
        //            targCharacter.Bag_Pools = new List<Characters_bag_pools>();

        //        _bagPools = targCharacter.Bag_Pools.OrderByDescending(bgpools => bgpools.Bag_Type).ToList();
        //        if (_bagPools.Count == 0)
        //        {
        //            foreach (int pool in _bpools)
        //            {
        //                Characters_bag_pools _bagPool = new Characters_bag_pools((int)player.PlayerCharId, pool, 0);
        //                targCharacter.Bag_Pools.Add(_bagPool);
        //                CharMgr.Database.AddObject(_bagPool);
        //            }
        //            _bagPools = targCharacter.Bag_Pools.OrderByDescending(bgpools => bgpools.Bag_Type).ToList();
        //        }
        //    }

        //    //roll for each bag type
        //    foreach (Characters_bag_pools pool in _bagPools)
        //    {
        //        player.ContributionBonus = (uint)pool.BagPool_Value;
        //        if (player.RandomBonus > 1)
        //        {
        //            if (pool.Bag_Type == 4)
        //            {
        //                if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(12) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(12) / 1000d : goldChance * contribFactor)))
        //                {
        //                    _bags[gold] = 1;
        //                    if (isBonusAppliedAndConsumed)
        //                    {
        //                        if (targPlayer != null)
        //                        {
        //                            targPlayer.SendClientMessage("Your gold bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                        }
        //                        pool.BagPool_Value = 0;
        //                    }
        //                    if (targPlayer != null)
        //                    {
        //                        targPlayer.SendClientMessage("You have won a gold loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                    }

        //                    break;
        //                }
        //                else
        //                {
        //                    if (isBonusAppliedAndConsumed)
        //                        pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .01);
        //                }
        //            }
        //            else if (pool.Bag_Type == 3)
        //            {
        //                if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(13) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(13) / 1000d : purpChance * contribFactor)))
        //                {
        //                    _bags[purple] = 1;
        //                    if (isBonusAppliedAndConsumed)
        //                    {
        //                        if (targPlayer != null)
        //                        {
        //                            targPlayer.SendClientMessage("Your purple bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                        }
        //                        pool.BagPool_Value = 0;
        //                    }
        //                    if (targPlayer != null)
        //                        targPlayer.SendClientMessage("You have won a purple loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);

        //                    break;
        //                }
        //                else
        //                {
        //                    if (isBonusAppliedAndConsumed)
        //                        pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .02);
        //                }
        //            }
        //            else if (pool.Bag_Type == 2)
        //            {
        //                if ((player.RandomBonus + -malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(14) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(14) / 1000d : blueChance * contribFactor)))
        //                {
        //                    _bags[blue] = 1;
        //                    if (isBonusAppliedAndConsumed)
        //                    {
        //                        if (targPlayer != null)
        //                        {
        //                            targPlayer.SendClientMessage("Your blue loot bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                            pool.BagPool_Value = 0;
        //                        }
        //                    }
        //                    if (targPlayer != null)
        //                        targPlayer.SendClientMessage("You have won a blue loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                    break;
        //                }
        //                else
        //                {
        //                    if (isBonusAppliedAndConsumed)
        //                        pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .03);
        //                }
        //            }
        //            else if (pool.Bag_Type == 1)
        //            {
        //                if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(15) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(15) / 1000d : greenChance * contribFactor)))
        //                {
        //                    _bags[green] = 1;
        //                    if (isBonusAppliedAndConsumed)
        //                    {
        //                        if (targPlayer != null)
        //                            targPlayer.SendClientMessage("Your green loot bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                        pool.BagPool_Value = 0;
        //                    }
        //                    if (targPlayer != null)
        //                        targPlayer.SendClientMessage("You have won a green loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                    break;
        //                }
        //                else
        //                {
        //                    if (isBonusAppliedAndConsumed)
        //                        pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .04);
        //                }
        //            }
        //            else if (pool.Bag_Type == 0)
        //            {
        //                _bags[white] = 1;
        //                if (targPlayer != null)
        //                    targPlayer.SendClientMessage("You have won a white loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
        //                pool.BagPool_Value = 0;
        //            }
        //        }
        //    }
        //    foreach (Characters_bag_pools pool in _bagPools)
        //    {
        //        CharMgr.Database.SaveObject(pool);
        //    }

        //    for (int i = 0; i < 5; ++i)
        //    {
        //        _availableBags[i] = _bags[i];
        //    }


        //    byte bagWon = GetWonBagType(player.OptOutType == 2);
        //    if (bagWon == 0)
        //    {
        //        if (targPlayer != null)
        //            targPlayer.SendClientMessage("You have not contributed enough to this zone's capture, and thus have not rolled.");
        //        return;
        //    }
        //    //Log.Success("Winner", player.PlayerName + " Realm: " + player.PlayerRealm + " Bag Type: " + bagWon.ToString() + "Roll: " + player.RandomBonus + " Contrib: " + player.BaseContribution + " Avg Contrib: " + acv + " BonusConsumed: " + player.ContributionBonus);
        //    player.BagWon = bagWon;
        //    _lootBags.Add(player.PlayerCharId, new GoldBag(PublicQuest.GetBag(player.BagWon), player.PlayerCareerLine, player.PlayerName));
        //    PersonalScoreboard(player, bagWon);
        //}

        private void AssignLoot(Dictionary <uint, ContributionInfo> players)
        {
            _preRoll = players.OrderByDescending(plrs => plrs.Value.BaseContribution).ToList();

            ushort currentContribution = 750;

            // Handle contribution and random bonuses
            foreach (var kvpair in _preRoll)
            {
                ContributionInfo plrInfo = kvpair.Value;

                Player targPlayer = Player.GetPlayer(plrInfo.PlayerCharId);

                if (plrInfo.OptOutType == 1)
                {
                    plrInfo.RandomBonus = 1;
                    if (targPlayer != null)
                    {
                        targPlayer.SendLocalizeString(_publicQuestInfo.Name, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_PUBLIC_QUEST_OPT_OUT_APPLIED);
                    }
                }

                /*else if (_publicQuestInfo.PQType == 2 && (_publicQuestInfo.PQTier == 2 || _publicQuestInfo.PQTier == 3) && plrInfo.Player.Level > 30)
                 * {
                 *  plrInfo.RandomBonus = 1;
                 *  plrInfo.Player.SendClientMessage("You have been skipped for the loot roll because your rank is too high.", ChatLogFilters.CHATLOGFILTERS_SAY);
                 * }*/
                else if (plrInfo.BaseContribution > 0)
                {
                    plrInfo.RandomBonus = (ushort)RandomMgr.Next(0, 750);
                    if (currentContribution > 45)
                    {
                        plrInfo.ContributionBonus = currentContribution;
                        if (currentContribution > 100)
                        {
                            currentContribution -= 50;
                        }
                        else if (currentContribution > 50)
                        {
                            currentContribution -= 5;
                        }
                    }
                }
                else
                {
                    plrInfo.RandomBonus = 1;
                }
            }

            _postRoll = players.OrderByDescending(plrs => plrs.Value.PersistenceBonus + plrs.Value.RandomBonus + plrs.Value.ContributionBonus).ToList();

            for (int i = 0; i < 5; ++i)
            {
                _availableBags[i] = _bags[i];
            }

            foreach (KeyValuePair <uint, ContributionInfo> contribution in _postRoll)
            {
                byte bagWon = GetWonBagType(contribution.Value.OptOutType == 2);

                // No more bags to be won at this index or any after it.
                if (bagWon == 0)
                {
                    break;
                }
                Log.Success("Winner", contribution.Value.PlayerName + " Realm: " + contribution.Value.PlayerRealm + " Bag Type: " + bagWon.ToString());

                contribution.Value.BagWon = bagWon;
                _lootBags.Add(contribution.Key, new GoldBag(PublicQuest.GetBag(contribution.Value.BagWon), contribution.Value.PlayerCareerLine, contribution.Value.PlayerName));
            }
        }
Пример #8
0
        }  //  d4 c0 01

        public void PersonalScoreboard(ContributionInfo playerRoll, byte bagWon)
        {
            Player targPlayer = Player.GetPlayer(playerRoll.PlayerCharId);

            if (targPlayer == null)
            {
                return;
            }

            PacketOut Out = new PacketOut((byte)Opcodes.F_PQLOOT_TRIGGER, 1723);

            Out.WriteStringBytes(_publicQuestInfo.Name);
            Out.Fill(0, 24 - _publicQuestInfo.Name.Length);
            Out.WriteByte(_bags[gold]);  // gold
            Out.WriteByte(_bags[purple]);
            Out.WriteByte(_bags[blue]);
            Out.WriteByte(_bags[green]);
            Out.WriteByte(_bags[white]); // white
            Out.Fill(0, 3);
            ContributionInfo curRoll = playerRoll;

            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)curRoll.RandomBonus);
            Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
            for (int i = 1; i < 24; i++)
            {
                Out.Fill(0, 32);
            }

            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteUInt16(1); // place
            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)curRoll.RandomBonus);
            Out.WriteUInt16R((ushort)curRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)curRoll.PersistenceBonus);
            Out.WriteByte(1);              // ???
            Out.WriteByte(curRoll.BagWon); // bag won
            for (int i = 1; i < 24; i++)
            {
                Out.Fill(0, 34); // i just send empty once here
            }
            Out.WriteUInt16(1);  // place
            Out.WriteStringBytes(targPlayer.Name);
            Out.Fill(0, 24 - targPlayer.Name.Length);
            Out.Fill(0, 2);
            Out.WriteUInt16R((ushort)playerRoll.RandomBonus);
            Out.WriteUInt16R((ushort)playerRoll.ContributionBonus);
            Out.WriteUInt16R((ushort)playerRoll.PersistenceBonus);
            Out.WriteByte(1);                 // ???
            Out.WriteByte(playerRoll.BagWon); // bag won

            Out.Fill(0, 2);
            //Out.WriteUInt16(TIME_PQ_RESET);
            Out.WriteByte(0);
            Out.WriteByte(3);


            Out.WriteByte(0);
            Out.WriteByte(0);
            Out.WriteByte(1);
            Out.Fill(0, 27);
            //
            // no clue yet seams to be if you didnt won anything you get that item


            /*
             * Out.WritePacketString(@"|d4 c0 01 |...d............|
             |57 61 72 20 43 72 65 73 74 00 00 00 00 00 00 00 |War Crest.......|
             |00 00 00 00 00 00 00 00 00 00 00                |...........     |
             * ");
             */
            targPlayer.SendPacket(Out);
            // Info.SendCurrentStage(plr);
        }  //  d4 c0 01
Пример #9
0
        /// <summary>
        /// Rewards players based on their contribution, converting it to XP, RP, Influence and Medallions.
        /// </summary>
        internal void HandleLockReward(Realms realm, float winnerRewardScale, string lockMessage, int zoneId, int tier)
        {
            /*
             * Some general notes on this.
             *
             * The ticker, if kicked consistently by a player during the course of one hour, will grant contribution which converts to 3000 RP over 60 minutes.
             * Rewards are based on a player's contribution performance relative to the best player on their realm.
             * The RP from a lock cannot exceed Tier * 5000, and by extension, the XP cannot exceed Tier * 15000,
             * the Influence cannot exceed Tier * 500 and there can be no more than 6 medallions issued.
             *
             * The rewards are scaled by the proximity of a zone to the enemy fortress.
             *
             * The rewards are also scaled by the relative Campaign scaler, which cripples rewards for players
             * refusing to fight in the most hotly contested zone.
             *
             * For the losing side, the reward is also scaled by the % of rewards, linked to the Victory Point pool.
             *
             * To receive the max losing reward, the top contributor on the losing realm must have contribution greater than 1/3 of the top attacker contribution.
             */

            string zoneName;

            if (zoneId == 0)
            {
                zoneName = _region.ZonesInfo[0].Name + " and " + _region.ZonesInfo[1].Name;
            }
            else
            {
                zoneName = ZoneService.GetZone_Info((ushort)zoneId).Name;
            }


            uint   xpCap  = (uint)(tier * 19000);
            uint   rpCap  = (uint)(tier * 10000);
            ushort infCap = (ushort)(tier * 2000);

            #region Init winner rewards
            Dictionary <uint, ContributionInfo> winnerContrib = GetContributorsFromRealm(realm);

            uint winMaxContrib = GetMaxContribution(winnerContrib);
            //Log.Info(zoneName, $"Winner contributor count : {winnerContrib.Count} Max contribution: {winMaxContrib}");

            uint   winRP             = (uint)(winMaxContrib * 1.5 * winnerRewardScale * BattleFrontConstants.LOCK_REWARD_SCALER);
            uint   winXP             = winRP * 4;
            ushort winInf            = (ushort)(winRP * 0.25f);
            ushort winMedallionCount = (ushort)Math.Min(20, winRP / (450 * tier));

            //Log.Info(zoneName, $"Lock XP: {winXP} RP: {winRP} Inf: {winInf} Medals: {winMedallionCount}");

            #endregion

            #region Init loser rewards

            Dictionary <uint, ContributionInfo> loserContrib = GetContributorsFromRealm(realm == Realms.REALMS_REALM_ORDER ? Realms.REALMS_REALM_DESTRUCTION : Realms.REALMS_REALM_ORDER);

            uint loserMaxContrib = GetMaxContribution(loserContrib);

            //Log.Info(zoneName, $"Loser contributor count : {loserContrib.Count} Max contribution: {loserMaxContrib}");

            uint   lossRP             = (uint)(winRP * LoserShare * Math.Min(1f, (loserMaxContrib * 3) / (float)winMaxContrib));
            uint   lossXP             = lossRP * 5;
            ushort lossInf            = (ushort)(lossRP * 0.35f);
            ushort lossMedallionCount = (ushort)Math.Min(15, winMedallionCount * LoserShare);

            //Log.Info(zoneName, $"Lock XP: {lossXP} RP: {lossRP} Inf: {lossInf} Medallions: {lossMedallionCount}");

            #endregion

            Item_Info medallionInfo = ItemService.GetItem_Info((uint)(208399 + tier));
            Item_Info T3Token       = ItemService.GetItem_Info(2165);
            Item_Info T4Token       = ItemService.GetItem_Info(2166);

            ushort tokenCount = 2;

            foreach (var kV in PlayerContributions)
            {
                Player plr = Player.GetPlayer(kV.Key);

                Character chara = plr != null ? plr.Info : CharMgr.GetCharacter(kV.Key, false);

                if (chara == null)
                {
                    continue;
                }

                if (plr != null)
                {
                    plr.SendLocalizeString(lockMessage, ChatLogFilters.CHATLOGFILTERS_RVR, Localized_text.CHAT_TAG_DEFAULT);
                    plr.SendLocalizeString(lockMessage, realm == Realms.REALMS_REALM_ORDER ? ChatLogFilters.CHATLOGFILTERS_C_ORDER_RVR_MESSAGE : ChatLogFilters.CHATLOGFILTERS_C_DESTRUCTION_RVR_MESSAGE, Localized_text.CHAT_TAG_DEFAULT);
                    // AAO multiplier needs to be multiplied with 20 to get the AAO that player sees.
                    // AAO mult is the global value for the server to grab the difference in size of the teams while AAOBonus is the players individual bonus
                    int aaoBuff = Convert.ToInt32(plr.AAOBonus);
                    if (aaoBuff < 0.1)
                    {
                        tokenCount = 1;
                    }
                    if (aaoBuff >= 2)
                    {
                        tokenCount = 3;
                    }
                    if (aaoBuff >= 3)
                    {
                        tokenCount = 4;
                    }
                    if (aaoBuff >= 4)
                    {
                        tokenCount = 5;
                    }
                }

                ContributionInfo contrib = kV.Value;

                if (chara.Realm == (int)realm)
                {
                    if (winRP == 0)
                    {
                        continue;
                    }

                    float contributionFactor = Math.Min(1f, contrib.BaseContribution / (winMaxContrib * 0.7f));

                    string contributionDesc;

                    if (contributionFactor > 0.75f)
                    {
                        contributionDesc = "valiant";
                    }
                    else if (contributionFactor > 0.5f)
                    {
                        contributionDesc = "stalwart";
                    }
                    else if (contributionFactor > 0.25f)
                    {
                        contributionDesc = "modest";
                    }
                    else
                    {
                        contributionDesc = "small";
                    }

                    plr?.SendClientMessage($"Your realm has captured {zoneName}, and you have been rewarded for your {contributionDesc} effort!", ChatLogFilters.CHATLOGFILTERS_RVR);

                    if (plr != null)
                    {
                        if (plr.Region == _region)
                        {
                            plr.AddXp(Math.Min(xpCap, (uint)(winXP * contributionFactor)), false, false);
                            if (plr.AAOBonus > 1)
                            {
                                plr.AddRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor + (tokenCount * 100))), false, RewardType.ZoneKeepCapture, zoneName);
                                if (plr.CurrentArea != null)
                                {
                                    ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId;
                                    plr.AddInfluence(influenceId, Math.Min(infCap, (ushort)(winInf * contributionFactor + (tokenCount * 100))));
                                }
                            }
                            else
                            {
                                plr.AddRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor)), false, RewardType.ZoneKeepCapture, zoneName);
                                if (plr.CurrentArea != null)
                                {
                                    ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId;
                                    plr.AddInfluence(influenceId, Math.Min(infCap, (ushort)(winInf * contributionFactor)));
                                }
                            }
                        }

                        else
                        {
                            plr.AddPendingXP(Math.Min(xpCap, (uint)(winXP * contributionFactor)));
                            plr.AddPendingRenown(Math.Min(rpCap, (uint)(winRP * contributionFactor)));
                        }
                    }

                    else if (chara.Value != null)
                    {
                        chara.Value.PendingXp     += Math.Min(xpCap, (uint)(winXP * contributionFactor));
                        chara.Value.PendingRenown += Math.Min(rpCap, (uint)(winRP * contributionFactor));
                        CharMgr.Database.SaveObject(chara.Value);
                    }

                    ushort resultantCount = (ushort)(winMedallionCount * contributionFactor);

                    /*
                     * if (plr != null && plr.AAOBonus > 1 && plr.Region == Region)
                     * {
                     *  resultantCount = Convert.ToUInt16(resultantCount * ((AgainstAllOddsMult * 20)/100));
                     * }
                     */
                    if (contributionFactor > 0 && plr != null)
                    {
                        if ((tier == 2 || tier == 3) && plr.ItmInterface.CreateItem(T3Token, tokenCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { T3Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }
                        if (tier == 4 && plr.ItmInterface.CreateItem(T4Token, tokenCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { T4Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }
                    }

                    if (resultantCount > 0)
                    {
                        if (plr != null && plr.Region == _region && plr.ItmInterface.CreateItem(medallionInfo, resultantCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { medallionInfo.Name, resultantCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }

                        else
                        {
                            Character_mail medallionMail = new Character_mail
                            {
                                Guid              = CharMgr.GenerateMailGuid(),
                                CharacterId       = chara.CharacterId,
                                CharacterIdSender = chara.CharacterId,
                                SenderName        = chara.Name,
                                ReceiverName      = chara.Name,
                                SendDate          = (uint)TCPManager.GetTimeStamp(),
                                Title             = "Medallion Reward",
                                Content           = "You've received a medallion reward for your realm's victory in a recent battle in which you were a participant.",
                                Money             = 0,
                                Opened            = false
                            };
                            medallionMail.Items.Add(new MailItem(medallionInfo.Entry, resultantCount));
                            if (tier == 2 || tier == 3)
                            {
                                medallionMail.Items.Add(new MailItem(T3Token.Entry, tokenCount));
                            }
                            if (tier == 4)
                            {
                                medallionMail.Items.Add(new MailItem(T4Token.Entry, tokenCount));
                            }
                            CharMgr.AddMail(medallionMail);
                        }
                    }
                }

                else
                {
                    if (lossRP == 0)
                    {
                        continue;
                    }

                    float scaleFactor = Math.Min(1f, contrib.BaseContribution / (loserMaxContrib * 0.7f));

                    string contributionDesc;

                    if (scaleFactor > 0.75f)
                    {
                        contributionDesc = "valiant";
                    }
                    else if (scaleFactor > 0.5f)
                    {
                        contributionDesc = "stalwart";
                    }
                    else if (scaleFactor > 0.25f)
                    {
                        contributionDesc = "modest";
                    }
                    else
                    {
                        contributionDesc = "small";
                    }

                    plr?.SendClientMessage($"Though your realm lost {zoneName}, you have been rewarded for your {contributionDesc} effort in defense.", ChatLogFilters.CHATLOGFILTERS_RVR);

                    if (plr != null)
                    {
                        if (plr.Region == _region)
                        {
                            plr.AddXp((uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor), false, false);
                            if (plr.AAOBonus > 1)
                            {
                                plr.AddRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor + (tokenCount * 100)), false, RewardType.ObjectiveDefense, zoneName);
                                if (plr.CurrentArea != null)
                                {
                                    ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId;
                                    plr.AddInfluence(influenceId, (ushort)Math.Min(infCap * 0.9f, lossInf * scaleFactor + (tokenCount * 100)));
                                }
                            }
                            else
                            {
                                plr.AddRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor), false, RewardType.ObjectiveDefense, zoneName);
                                if (plr.CurrentArea != null)
                                {
                                    ushort influenceId = realm == Realms.REALMS_REALM_ORDER ? (ushort)plr.CurrentArea.OrderInfluenceId : (ushort)plr.CurrentArea.DestroInfluenceId;
                                    plr.AddInfluence(influenceId, (ushort)Math.Min(infCap * 0.9f, lossInf * scaleFactor));
                                }
                            }
                        }

                        else
                        {
                            plr.AddPendingXP((uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor));
                            plr.AddPendingRenown((uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor));
                        }
                    }

                    else if (chara.Value != null)
                    {
                        chara.Value.PendingXp     += (uint)Math.Min(xpCap * 0.9f, lossXP * scaleFactor);
                        chara.Value.PendingRenown += (uint)Math.Min(rpCap * 0.9f, lossRP * scaleFactor);
                        CharMgr.Database.SaveObject(chara.Value);
                    }

                    ushort resultantCount = (ushort)(lossMedallionCount * scaleFactor);

                    /*
                     * if (plr != null && plr.AAOBonus > 1 && plr.Region == Region)
                     * {
                     *  resultantCount = Convert.ToUInt16(resultantCount * ((AgainstAllOddsMult * 20)/100));
                     * }
                     */
                    if (scaleFactor > 0 && plr != null)
                    {
                        if ((tier == 2 || tier == 3) && plr.ItmInterface.CreateItem(T3Token, tokenCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { T3Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }
                        if (tier == 4 && plr.ItmInterface.CreateItem(T4Token, tokenCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { T4Token.Name, tokenCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }
                    }
                    if (resultantCount > 0)
                    {
                        if (plr != null && plr.Region == _region && plr.ItmInterface.CreateItem(medallionInfo, resultantCount) == ItemResult.RESULT_OK)
                        {
                            plr.SendLocalizeString(new[] { medallionInfo.Name, resultantCount.ToString() }, ChatLogFilters.CHATLOGFILTERS_LOOT, Localized_text.TEXT_YOU_RECEIVE_ITEM_X);
                        }
                        else
                        {
                            Character_mail medallionMail = new Character_mail
                            {
                                Guid              = CharMgr.GenerateMailGuid(),
                                CharacterId       = chara.CharacterId,
                                CharacterIdSender = chara.CharacterId,
                                SenderName        = chara.Name,
                                ReceiverName      = chara.Name,
                                SendDate          = (uint)TCPManager.GetTimeStamp(),
                                Title             = "Medallion Reward",
                                Content           = "You've received a medallion reward for your participation in a recent battle.",
                                Money             = 0,
                                Opened            = false
                            };
                            medallionMail.Items.Add(new MailItem(medallionInfo.Entry, resultantCount));
                            if (tier == 2 || tier == 3)
                            {
                                medallionMail.Items.Add(new MailItem(T3Token.Entry, tokenCount));
                            }
                            if (tier == 4)
                            {
                                medallionMail.Items.Add(new MailItem(T4Token.Entry, tokenCount));
                            }
                            CharMgr.AddMail(medallionMail);
                        }
                    }
                }
            }

            PlayerContributions.Clear();
        }
        private void RollForPersonalBag(ContributionInfo player, float bagCountMod, Dictionary <uint, ContributionInfo> players, RegionMgr region)
        {
            for (int i = 0; i < 5; ++i)
            {
                _availableBags[i] = 0;
            }
            for (int i = 0; i < 5; ++i)
            {
                _bags[i] = 0;
            }
            ProximityBattlefront bf             = null;
            int       aaoMult                   = 0;
            bool      isBonusAppliedAndConsumed = true;
            Realms    aaoRealm                  = Realms.REALMS_REALM_NEUTRAL;
            Player    targPlayer                = Player.GetPlayer(player.PlayerCharId);
            Character targCharacter             = CharMgr.GetCharacter(player.PlayerCharId, true);

            if (region != null && region.Bttlfront != null && region.Bttlfront is ProximityBattlefront)
            {
                bf = region.Bttlfront as ProximityBattlefront;
                if (bf != null)
                {
                    aaoMult = Math.Abs(bf._againstAllOddsMult);
                    if (aaoMult != 0)
                    {
                        aaoRealm = bf._againstAllOddsMult > 0 ? Realms.REALMS_REALM_DESTRUCTION : Realms.REALMS_REALM_ORDER;
                    }
                }

                if (targPlayer != null)
                {
                    //T2 16-19, use bonus rolls
                    if (region.GetTier() == 2)
                    {
                        if (targPlayer.Level < 16 || targPlayer.Level > 19)
                        {
                            isBonusAppliedAndConsumed = false;
                        }
                    }
                    //T3 20-29, use bonus rolls
                    if (region.GetTier() == 3)
                    {
                        if (targPlayer.Level < 20 || targPlayer.Level > 29)
                        {
                            isBonusAppliedAndConsumed = false;
                        }
                    }

                    if (region.GetTier() == 4)
                    {
                        if (targPlayer.Level < 30)
                        {
                            isBonusAppliedAndConsumed = false;
                        }
                    }
                }
            }
            //Which side is outnumbered?
            float aaoMultOutnumberedSide = aaoMult / 2.5f;
            //Which side is outnumbering the other side?
            float aaoMultOutnumberingSide = aaoMult / 2.5f;

            //Being outnumbered has a cap of 2, 10% bonus to your roll.
            if (aaoMultOutnumberedSide > 1f)
            {
                aaoMultOutnumberedSide = 1f;
            }

            //Being utnumbering has a cap of 40% penalty.
            if (aaoMultOutnumberingSide > 4f)
            {
                aaoMultOutnumberingSide = 4f;
            }

            //Divide by 10f to get sane multipliers for rolls
            aaoMultOutnumberedSide  = aaoMultOutnumberedSide / 10f;
            aaoMultOutnumberingSide = aaoMultOutnumberingSide / 10f;

            const double goldChance = 0.01, purpChance = 0.05, blueChance = 0.1, greenChance = 0.15, whiteChance = 0.2;

            _preRoll = players.OrderByDescending(plrs => plrs.Value.BaseContribution).ToList();
            float acv = _preRoll.Sum(plrs => plrs.Value.BaseContribution) / _preRoll.Count;

            //handle roll value
            if (player.OptOutType == 1)
            {
                player.RandomBonus = 1;
                if (targPlayer != null)
                {
                    targPlayer.SendLocalizeString(_publicQuestInfo.Name, ChatLogFilters.CHATLOGFILTERS_SAY, Localized_text.TEXT_PUBLIC_QUEST_OPT_OUT_APPLIED);
                }
            }
            else if (player.BaseContribution > acv * .10)
            {
                player.RandomBonus = (ushort)RandomMgr.Next(0, 1000);

                int temporaryBonus = (int)player.RandomBonus;
                if (aaoRealm != Realms.REALMS_REALM_NEUTRAL && aaoMult != 0)
                {
                    if (targPlayer != null)
                    {
                        targPlayer.SendClientMessage("Your roll has been adjusted due to your army's size.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                    }
                    if (player.PlayerRealm == aaoRealm)
                    {
                        temporaryBonus += (int)(player.RandomBonus * (aaoMultOutnumberedSide));
                    }
                    else
                    {
                        temporaryBonus -= (int)(player.RandomBonus * (aaoMultOutnumberingSide));
                    }
                }
                player.RandomBonus = (uint)(Math.Max(2, temporaryBonus));
                if (targPlayer != null)
                {
                    targPlayer.SendClientMessage("You roll " + player.RandomBonus + ".", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                }
            }
            else
            {
                player.RandomBonus = 1;
            }

            float contribFactor = player.BaseContribution > acv ? player.BaseContribution / acv : 1f;
            float malus         = 0;

            //get player bag pools

            if (targCharacter != null)
            {
                if (targCharacter.Bag_Pools == null)
                {
                    targCharacter.Bag_Pools = new List <Characters_bag_pools>();
                }

                _bagPools = targCharacter.Bag_Pools.OrderByDescending(bgpools => bgpools.Bag_Type).ToList();
                if (_bagPools.Count == 0)
                {
                    foreach (int pool in _bpools)
                    {
                        Characters_bag_pools _bagPool = new Characters_bag_pools((int)player.PlayerCharId, pool, 0);
                        targCharacter.Bag_Pools.Add(_bagPool);
                        CharMgr.Database.AddObject(_bagPool);
                    }
                    _bagPools = targCharacter.Bag_Pools.OrderByDescending(bgpools => bgpools.Bag_Type).ToList();
                }
            }

            //roll for each bag type
            foreach (Characters_bag_pools pool in _bagPools)
            {
                player.ContributionBonus = (uint)pool.BagPool_Value;
                if (player.RandomBonus > 1)
                {
                    if (pool.Bag_Type == 4)
                    {
                        if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(12) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(12) / 1000d : goldChance *contribFactor)))
                        {
                            _bags[gold] = 1;
                            if (isBonusAppliedAndConsumed)
                            {
                                if (targPlayer != null)
                                {
                                    targPlayer.SendClientMessage("Your gold bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                                }
                                pool.BagPool_Value = 0;
                            }
                            if (targPlayer != null)
                            {
                                targPlayer.SendClientMessage("You have won a gold loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                            }

                            break;
                        }
                        else
                        {
                            if (isBonusAppliedAndConsumed)
                            {
                                pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .01);
                            }
                        }
                    }
                    else if (pool.Bag_Type == 3)
                    {
                        if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(13) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(13) / 1000d : purpChance *contribFactor)))
                        {
                            _bags[purple] = 1;
                            if (isBonusAppliedAndConsumed)
                            {
                                if (targPlayer != null)
                                {
                                    targPlayer.SendClientMessage("Your purple bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                                }
                                pool.BagPool_Value = 0;
                            }
                            if (targPlayer != null)
                            {
                                targPlayer.SendClientMessage("You have won a purple loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                            }

                            break;
                        }
                        else
                        {
                            if (isBonusAppliedAndConsumed)
                            {
                                pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .02);
                            }
                        }
                    }
                    else if (pool.Bag_Type == 2)
                    {
                        if ((player.RandomBonus + -malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(14) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(14) / 1000d : blueChance *contribFactor)))
                        {
                            _bags[blue] = 1;
                            if (isBonusAppliedAndConsumed)
                            {
                                if (targPlayer != null)
                                {
                                    targPlayer.SendClientMessage("Your blue loot bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                                    pool.BagPool_Value = 0;
                                }
                            }
                            if (targPlayer != null)
                            {
                                targPlayer.SendClientMessage("You have won a blue loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                            }
                            break;
                        }
                        else
                        {
                            if (isBonusAppliedAndConsumed)
                            {
                                pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .03);
                            }
                        }
                    }
                    else if (pool.Bag_Type == 1)
                    {
                        if ((player.RandomBonus - malus + (isBonusAppliedAndConsumed ? pool.BagPool_Value : 0)) >= 1000 - (1000 * (WorldMgr.WorldSettingsMgr.GetGenericSetting(15) > 0 ? WorldMgr.WorldSettingsMgr.GetGenericSetting(15) / 1000d : greenChance *contribFactor)))
                        {
                            _bags[green] = 1;
                            if (isBonusAppliedAndConsumed)
                            {
                                if (targPlayer != null)
                                {
                                    targPlayer.SendClientMessage("Your green loot bag bonus roll has been consumed.", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                                }
                                pool.BagPool_Value = 0;
                            }
                            if (targPlayer != null)
                            {
                                targPlayer.SendClientMessage("You have won a green loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                            }
                            break;
                        }
                        else
                        {
                            if (isBonusAppliedAndConsumed)
                            {
                                pool.BagPool_Value += (int)((player.RandomBonus - (0) + pool.BagPool_Value) * .04);
                            }
                        }
                    }
                    else if (pool.Bag_Type == 0)
                    {
                        _bags[white] = 1;
                        if (targPlayer != null)
                        {
                            targPlayer.SendClientMessage("You have won a white loot bag!", ChatLogFilters.CHATLOGFILTERS_CSR_TELL_RECEIVE);
                        }
                        pool.BagPool_Value = 0;
                    }
                }
            }
            foreach (Characters_bag_pools pool in _bagPools)
            {
                CharMgr.Database.SaveObject(pool);
            }

            for (int i = 0; i < 5; ++i)
            {
                _availableBags[i] = _bags[i];
            }


            byte bagWon = GetWonBagType(player.OptOutType == 2);

            if (bagWon == 0)
            {
                if (targPlayer != null)
                {
                    targPlayer.SendClientMessage("You have not contributed enough to this zone's capture, and thus have not rolled.");
                }
                return;
            }
            //Log.Success("Winner", player.PlayerName + " Realm: " + player.PlayerRealm + " Bag Type: " + bagWon.ToString() + "Roll: " + player.RandomBonus + " Contrib: " + player.BaseContribution + " Avg Contrib: " + acv + " BonusConsumed: " + player.ContributionBonus);
            player.BagWon = bagWon;
            _lootBags.Add(player.PlayerCharId, new GoldBag(PublicQuest.GetBag(player.BagWon), player.PlayerCareerLine, player.PlayerName));
            PersonalScoreboard(player, bagWon);
        }