Exemplo n.º 1
0
        public static void F_OBJECTIVE_UPDATE(BaseClient client, PacketIn packet)
        {
            GameClient cclient = (GameClient)client;

            uint pQuestID = packet.GetUint32();
            byte op       = packet.GetUint8();

            switch (op)
            {
            case 8:     // switch opt out state
                byte        optOutType = packet.GetUint8();
                PublicQuest pQuest     = cclient.Plr.QtsInterface.PublicQuest;

                if (pQuest == null || pQuest.Info.Entry != pQuestID)
                {
                    return;
                }

                pQuest.ProcessOptOut(cclient.Plr, optOutType);
                break;

            default:
                Log.Error("F_OBJECTIVE_UPDATE", $"Received unknown op {op} from client");
                break;
            }
        }
        protected void CreditQuestKill(Player killer)
        {
            if (killer.PriorityGroup != null)
            {
                List <Player> curMembers = killer.PriorityGroup.GetPlayersCloseTo(killer, 150);
            }

            if (!string.IsNullOrEmpty(Spawn.Proto.TokUnlock))
            {
                killer.TokInterface.AddToks(Spawn.Proto.TokUnlock);

                if (killer.WorldGroup != null)
                {
                    List <Player> members = killer.WorldGroup.GetPlayerListCopy();

                    foreach (var member in members)
                    {
                        if (member != killer)
                        {
                            member.TokInterface.AddToks(Spawn.Proto.TokUnlock);
                        }
                    }
                }
            }

            killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_GO, Spawn.Entry, 1);
            PublicQuest pq = killer.QtsInterface.PublicQuest;

            pq?.HandleEvent(killer, Objective_Type.QUEST_KILL_GO, Spawn.Entry, 1, 100);
        }
Exemplo n.º 3
0
        public PublicQuest CreatePQuest(PQuest_Info quest)
        {
            if (PublicQuests.ContainsKey(quest.Entry))
            {
                Log.Error("CreatePQuest", "Attempted to create public quest that was already contained: ZoneID:" + quest.ZoneId + " Entry: " + quest.Entry);
            }
            ZoneMgr     zone = GetZoneMgr(quest.ZoneId);
            PublicQuest obj  = new PublicQuest(quest);

            AddObject(obj, quest.ZoneId);
            PublicQuests.Add(quest.Entry, obj);
            return(obj);
        }
Exemplo n.º 4
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));
            }
        }
        private void HandleInteractionEvents(Player player)
        {
            if (!IsDead)
            {
                player.QtsInterface.HandleEvent(Objective_Type.QUEST_USE_GO, Spawn.Entry, 1);
            }

            // This will spawn a creature after interacting with the GO
            if (this.Spawn.Proto.CreatureId != 0 && IsAttackable == 0)
            {
                SpawnNPCFromGO();
            }

            // This will play sound after clicking on the GO
            long now = TCPManager.GetTimeStampMS();

            if (this.Spawn.SoundId != 0 && now > SoundCooldown)
            {
                this.PlaySound((ushort)this.Spawn.SoundId);
                SoundCooldown = TCPManager.GetTimeStampMS() + 60 * 1000;
            }

            HandleCustomInteraction();

            PublicQuest pq = player.QtsInterface.PublicQuest;

            pq?.HandleEvent(player, Objective_Type.QUEST_USE_GO, Spawn.Entry, 1, 50);

            if (Spawn.Proto.TokUnlock != null && Spawn.Proto.TokUnlock.Length > 1 && IsAttackable == 0)
            {
                player.TokInterface.AddToks(Spawn.Proto.TokUnlock);

                // This check if the GO we clicked is a Door - if it is we don't want to mess with its
                // VFXState because we can break it
                if (this.Spawn.DoorId == 0)
                {
                    this.EvtInterface.AddEvent(EventSendMeTo, 60000, 1);
                    if (this.Spawn.AllowVfxUpdate == 1)
                    {
                        this.VfxState = 1;
                    }
                    foreach (Player plr in PlayersInRange)
                    {
                        this.UpdateVfxState(VfxState);
                    }
                }
            }

            if (Spawn.TokUnlock != null && Spawn.TokUnlock.Length > 1 && IsAttackable == 0)
            {
                player.TokInterface.AddToks(Spawn.TokUnlock);

                // This check if the GO we clicked is a Door - if it is we don't want to mess with its
                // VFXState because we can break it
                if (this.Spawn.DoorId == 0)
                {
                    this.EvtInterface.AddEvent(EventSendMeTo, 60000, 1);

                    if (this.Spawn.AllowVfxUpdate == 1)
                    {
                        this.VfxState = 1;
                    }
                    foreach (Player plr in PlayersInRange)
                    {
                        this.UpdateVfxState(VfxState);
                    }
                }
            }
        }
        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);
        }