Ejemplo n.º 1
0
        public static void SafeKeep(Player plr)
        {
            IBattlefront battlefront = plr.Region.Bttlfront;

            if (GameData.Constants.DoomsdaySwitch == 2)
            {
                ProximityProgressingBattlefront pBttlfront = battlefront as ProximityProgressingBattlefront;

                if (pBttlfront != null)
                {
                    foreach (Keep keep in pBttlfront._Keeps)
                    {
                        keep.SafeKeep();
                    }

                    plr.SendClientMessage("Keeps set to status safe");
                }
                else
                {
                    ProximityBattlefront bttlfront = battlefront as ProximityBattlefront;

                    foreach (Keep keep in bttlfront._Keeps)
                    {
                        keep.SafeKeep();
                    }

                    plr.SendClientMessage("Keeps set to status safe");
                }
            }
            else
            {
                ProgressingBattlefront pBttlfront = battlefront as ProgressingBattlefront;

                if (pBttlfront != null)
                {
                    foreach (Keep keep in pBttlfront._Keeps)
                    {
                        keep.SafeKeep();
                    }

                    plr.SendClientMessage("Keeps set to status safe");
                }
                else
                {
                    Battlefront bttlfront = battlefront as Battlefront;

                    foreach (Keep keep in bttlfront._Keeps)
                    {
                        keep.SafeKeep();
                    }

                    plr.SendClientMessage("Keeps set to status safe");
                }
            }
        }
Ejemplo n.º 2
0
        public static void Grace(Player plr)
        {
            IBattlefront battlefront = plr.Region.Bttlfront;

            if (GameData.Constants.DoomsdaySwitch == 2)
            {
                ProximityProgressingBattlefront pBttlfront = battlefront as ProximityProgressingBattlefront;

                if (pBttlfront != null)
                {
                    if (pBttlfront.GraceDisabled)
                    {
                        pBttlfront.StartGrace();
                    }
                    else
                    {
                        pBttlfront.EndGrace();
                    }

                    plr.SendClientMessage("Current Value of Grace: " + pBttlfront.GraceDisabled, ChatLogFilters.CHATLOGFILTERS_TELL_RECEIVE);
                }
                else
                {
                    ProximityBattlefront bttlfront = battlefront as ProximityBattlefront;

                    if (bttlfront.GraceDisabled)
                    {
                        bttlfront.StartGrace();
                    }
                    else
                    {
                        bttlfront.EndGrace();
                    }

                    plr.SendClientMessage("Current Value of Grace: " + bttlfront.GraceDisabled, ChatLogFilters.CHATLOGFILTERS_TELL_RECEIVE);
                }
            }
            else
            {
                ProgressingBattlefront pBttlfront = battlefront as ProgressingBattlefront;

                if (pBttlfront != null)
                {
                    if (pBttlfront.GraceDisabled)
                    {
                        pBttlfront.StartGrace();
                    }
                    else
                    {
                        pBttlfront.EndGrace();
                    }

                    plr.SendClientMessage("Current Value of Grace: " + pBttlfront.GraceDisabled);
                }
                else
                {
                    Battlefront bttlfront = battlefront as Battlefront;

                    if (bttlfront.GraceDisabled)
                    {
                        bttlfront.StartGrace();
                    }
                    else
                    {
                        bttlfront.EndGrace();
                    }

                    plr.SendClientMessage("Current Value of Grace: " + pBttlfront.GraceDisabled);
                }
            }
        }
Ejemplo n.º 3
0
        public void LockZone(Realms realm, int zoneId, bool announce, bool reset, bool noRewards = false, bool draw = false)
        {
            Log.Debug("Battlefront.LockT4Zone", "Locking zone " + zoneId + " for " + realm);

            foreach (ProximityFlag flag in _Objectives.ToList())
            {
                if (flag.Ruin)
                {
                    _Objectives.Remove(flag);
                    flag.RemoveFromWorld();
                    continue;
                }

                if (flag.ZoneId == zoneId)
                {
                    flag.LockObjective(realm, announce);
                    flag._owningRealm = realm;
                    flag.BroadcastFlagInfo(false);
                }
            }

            if (realm == Realms.REALMS_REALM_ORDER)
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 4;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 2] = 0;
                HeldObjectives[0] = 0;
                HeldObjectives[1] = 4;
                HeldObjectives[2] = 0;
            }
            else
            {
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 0] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 1] = 0;
                _held[Zones.FindIndex(z => z.ZoneId == zoneId), 2] = 4;
                HeldObjectives[0] = 0;
                HeldObjectives[1] = 0;
                HeldObjectives[2] = 4;
            }

            foreach (Keep keep in _Keeps)
            {
                if (keep.Info.ZoneId == zoneId)
                {
                    Realms targetRealm = keep.GetContestedRealm();
                    Dictionary <uint, ContributionInfo> contributors = GetContributorsFromRealm(targetRealm);

                    if (contributors.Count > 0 && !noRewards)
                    {
                        if (DefenderPopTooSmall)
                        {
                            WinnerShare = 0.0f;
                        }

                        if (draw)
                        {
                            WinnerShare = 0.1f;
                            LoserShare  = 0.1f;
                        }

                        Log.Success("Logging keep rewards...", "");
                        Log.Success("Zone", ActiveZoneName);
                        Log.Success("Is defender pop too small to award rewards", DefenderPopTooSmall.ToString());
                        Log.Success("ProgressingBattlefront", $"Creating gold chest for {keep.Info.Name} for {contributors.Count} {(targetRealm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction")} contributors");
                        GoldChest.Create(Region, keep.Info.PQuest, ref contributors, targetRealm == realm ? WinnerShare : LoserShare);
                    }

                    keep.Realm = realm;
                    keep.LockKeep(realm, announce, reset);
                }
            }

            if (DefenderPopTooSmall)
            {
                Broadcast($"The forces of {(realm == Realms.REALMS_REALM_ORDER ? "Order " : "Destruction ")} conquered abandoned keep, no spoils of war were found!");
            }

            if (draw)
            {
                Broadcast("As forces of Order and Destruction were reluctant to trade final blows the war moved elsewhere!");
            }

            if (!announce)
            {
                return;
            }

            DisableSupplies();

            // Where 0 = Destromost zone, and 2 = Ordermost zone
            int campaignProgress = Zones.FindIndex(z => z.ZoneId == zoneId);

            string message;
            float  winnerRewardScale;

            if (realm == Realms.REALMS_REALM_DESTRUCTION)
            {
                campaignProgress = 2 - campaignProgress;
            }

            switch (campaignProgress)
            {
            case 0:
                // The realm has captured the zone closest to the enemy fort, leave the last zone locked and give them a reward
                UpdateStateOfTheRealm();
                PairingLocked = true;

#if DEBUG
                EvtInterface.AddEvent(EndGrace, 90 * 1000, 1);
#else
                EvtInterface.AddEvent(EndGrace, 10 * 60 * 1000, 1);
#endif


                Log.Info("Battlefront.LockT4Zone", "Locked all of region " + Region.RegionId);

                winnerRewardScale = 1.25f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[0].Name + " has been liberated by the forces of Order! The forces of Destruction have been cleansed from this region, but the fighting continues on elsewhere!";
                }
                else
                {
                    message = Zones[2].Name + " has been conquered by the forces of Destruction! The forces of Order flee like cowards, but the fighting continues on elsewhere!";
                }

                LockingRealm = realm;

                WorldMgr.EvaluateT4CampaignStatus(Region.RegionId);
                break;

            case 1:
                // The realm has captured the middle zone, unlock zone closest to enemy fort.
                if (Constants.DoomsdaySwitch > 0)
                {
                    //LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, true);
                    CheckUnlockZone(true, Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, true);
                }
                else
                {
                    //LiftZoneLock(Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, false);
                    CheckUnlockZone(true, Zones[realm == Realms.REALMS_REALM_ORDER ? 0 : 2].ZoneId, false);
                }

                winnerRewardScale = 1f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message        = Zones[1].Name + " has been reclaimed by the forces of Order! The forces of Destruction have retreated to " + Zones[0].Name + ", to build up for a renewed assault.";
                    DefendingRealm = Realms.REALMS_REALM_DESTRUCTION;
                }
                else
                {
                    message        = Zones[1].Name + " has been seized by the forces of Destruction! The forces of Order have fallen back to " + Zones[2].Name + " to make a last stand.";
                    DefendingRealm = Realms.REALMS_REALM_ORDER;
                }

                UpdateStateOfTheRealm();
                break;

            case 2:
                // The realm has recaptured the zone closest to their fort, unlock the middle zone
                if (Constants.DoomsdaySwitch > 0)
                {
                    CheckUnlockZone(true, Zones[1].ZoneId, true);
                }
                //LiftZoneLock(Zones[1].ZoneId, true);
                else
                {
                    CheckUnlockZone(true, Zones[1].ZoneId, false);
                }
                //LiftZoneLock(Zones[1].ZoneId, false);

                winnerRewardScale = 0.75f;

                if (realm == Realms.REALMS_REALM_ORDER)
                {
                    message = Zones[2].Name + " has been saved by the forces of Order! The forces of Destruction fall back to " + Zones[1].Name + "!";
                }
                else
                {
                    message = "The forces of Destruction tighten their grip on " + Zones[0].Name + ", and the forces of Order fall back to " + Zones[1].Name + "!";
                }

                DefendingRealm = Realms.REALMS_REALM_NEUTRAL;

                UpdateStateOfTheRealm();
                break;

            default:
                Log.Error("Battlefront.LockT4Zone", "The campaign progress was somehow at stage " + campaignProgress + ". This is not supposed to happen.");
                return;
            }

            VictoryPoints = 50;
            LastAnnouncedVictoryPoints = 50;

            WorldMgr.SendCampaignStatus(null);

            winnerRewardScale *= RelativeActivityFactor;

            try
            {
                Log.Info("Zone Lock", ZoneService.GetZone_Info((ushort)zoneId).Name);
                HandleLockReward(realm, winnerRewardScale, message, zoneId);
            }
            catch (Exception e)
            {
                Log.Error("HandleLockReward", "Exception thrown: " + e);
            }

            TotalContribFromRenown = (ulong)(Tier * 50);
            PlayerContributions.Clear();

            PlayerContributions = new Dictionary <uint, ContributionInfo>();

            int arr;
            if (Constants.DoomsdaySwitch == 2)
            {
                arr = (int)pairing;
            }
            else
            {
                arr = Tier;
            }

            if (BattlefrontList.ActiveFronts[arr - 1] == this)
            {
                BattlefrontList.ActiveFronts[arr - 1] = null;
            }

            // This should be 2 to make it work correct with 3 open zones, codeword c4rr0t
            if (Constants.DoomsdaySwitch != 2)
            {
                int i = 0;
                foreach (IBattlefront b in BattlefrontList.Battlefronts[Tier - 1])
                {
                    if (i > 0)
                    {
                        ProximityBattlefront front = b as ProximityBattlefront;
                        if (front != this && !front.PairingLocked)
                        {
                            front.EvtInterface.AddEvent(front.SupplyLineReset, 1, 1);
                        }
                    }
                    i++;
                }
            }

            /*else
             * {
             *  foreach (ProximityBattlefront b in BattlefrontList.RegionManagers[arr - 1])
             *      if (b != this && !b.PairingLocked && b.pairing == pairing)
             *          //b.EvtInterface.AddEvent(b.SupplyLineReset, 1, 1);
             * }*/
            DefenderPopTooSmall = false;
            _totalMaxOrder      = 0;
            _totalMaxDestro     = 0;

            PairingDrawTime = 0;
        }
Ejemplo n.º 4
0
        public void CheckUnlockZone(bool zoneLock = false, int zoneId = 0, bool reset = false)
        {
            int maxOpenZones     = 1;
            int currentOpenZones = 0;
            int totalRvRPlayers  = Player._Players.Where(p => p.CbtInterface.IsPvp == true && p.Level > 15 && p.ScnInterface.Scenario == null).Count();

            if (totalRvRPlayers < 201)
            {
                maxOpenZones = 1;
            }
            else if (totalRvRPlayers > 200 && totalRvRPlayers < 401)
            {
                maxOpenZones = 2;
            }
            else
            {
                maxOpenZones = 3;
            }

            /*foreach (IBattlefront t4front in BattlefrontList.ActiveFronts)
             * {
             *  if (t4front != null)
             *      currentOpenZones++;
             * }*/

            for (int i = 0; i < 4; i++)
            {
                foreach (IBattlefront b in BattlefrontList.Battlefronts[i])
                {
                    ProximityBattlefront front = b as ProximityBattlefront;
                    if (front != null && !front.PairingLocked && front.Tier > 1)
                    {
                        currentOpenZones++;
                    }
                }
            }
            if (zoneLock)
            {
                // Spaghetti...
                currentOpenZones = 0;
                for (int i = 0; i < 4; i++)
                {
                    foreach (IBattlefront b in BattlefrontList.Battlefronts[i])
                    {
                        ProximityProgressingBattlefront front = b as ProximityProgressingBattlefront;
                        if (front != null && !front.PairingLocked && front.Tier > 1 && front != this)
                        {
                            currentOpenZones++;
                        }
                    }
                }

                if (currentOpenZones == 0 || currentOpenZones < maxOpenZones)
                {
                    LiftZoneLock(zoneId, reset);
                }
                else
                {
                    Broadcast("Not enough warriors to support offensive in new region!");
                }
            }
            else
            {
                if (currentOpenZones < maxOpenZones)
                {
                    int dwarfPairingsOpen  = 0; // 1
                    int empirePairingsOpen = 0; // 2
                    int elfPairingsOpen    = 0; // 3

                    for (int i = 1; i < 4; i++)
                    {
                        foreach (ProximityBattlefront b in BattlefrontList.Battlefronts[i])
                        {
                            if ((int)b.pairing == 1 && !b.PairingLocked)
                            {
                                dwarfPairingsOpen++;
                            }
                            if ((int)b.pairing == 2 && !b.PairingLocked)
                            {
                                empirePairingsOpen++;
                            }
                            if ((int)b.pairing == 3 && !b.PairingLocked)
                            {
                                elfPairingsOpen++;
                            }
                        }
                    }

                    bool end        = false;
                    int  newPairing = (int)pairing;

                    while (newPairing == (int)pairing)
                    {
                        newPairing = random.Next(1, 4);
                        while (newPairing == 1 && dwarfPairingsOpen > 0)
                        {
                            newPairing = random.Next(1, 4);
                        }

                        while (newPairing == 2 && empirePairingsOpen > 0)
                        {
                            newPairing = random.Next(1, 4);
                        }

                        while (newPairing == 3 && elfPairingsOpen > 0)
                        {
                            newPairing = random.Next(1, 4);
                        }
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        if (i != (int)pairing - 1)
                        {
                            foreach (IBattlefront b in BattlefrontList.Battlefronts[i])
                            {
                                ProximityBattlefront front = b as ProximityBattlefront;
                                if (front != null && front.PairingLocked && front.Tier == 2 && front.pairing != pairing && (int)front.pairing == newPairing)
                                {
                                    front.LoadMidTierPairing(true);
                                    end = true;
                                    break;
                                }
                            }
                            if (end)
                            {
                                break;
                            }
                        }
                    }
                }
            }
        }
        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);
        }