Example #1
0
        /*
         *   // Group LOOT : Pass , accept, cancel
         *    Out.WritePacketString(@"|07 19 0A 00 00 00 00 03 2E 56 22 B9 00 |............V..|
         |00 00 00 00 00 00 00 00 24 00 00 00 00 00 01 00 |........$.......|
         |00 00 00 00 00 00 00 00 00 00 00 00 00 09 C4 00 |................|
         |01 00 00 00 00 00 00 00 00 00 00 00 00 09 57 61 |..............Wa|
         |72 20 43 72 65 73 74 00 00 00 00 00 00 71 50 72 |r Crest......qPr|
         |6F 6F 66 20 6F 66 20 79 6F 75 72 20 76 61 6C 6F |oof of your valo|
         |72 20 6F 6E 20 74 68 65 20 66 69 65 6C 64 20 6F |r on the field o|
         |66 20 62 61 74 74 6C 65 2E 20 54 68 65 73 65 20 |f battle. These |
         |6D 61 79 20 62 65 20 75 73 65 64 20 74 6F 20 74 |may be used to t|
         |72 61 64 65 20 66 6F 72 20 65 71 75 69 70 6D 65 |rade for equipme|
         |6E 74 20 66 72 6F 6D 20 76 61 72 69 6F 75 73 20 |nt from various |
         |51 75 61 72 74 65 72 6D 61 73 74 65 72 73 2E 01 |Quartermasters..|
         |00 00 00 03 06 00 08 00 00 00 00 00 00 00 00 00 |................|
         |00 00 00 00 00 00 00 00 00 00                   |..........      |");
         */



        public override void SetDeath(Unit Killer)
        {
            if (Killer.IsPlayer())
            {
                Player Plr = Killer.GetPlayer();

                PQuestObject pq = Plr.QtsInterface.GetPublicQuest();
                if (pq != null)
                {
                    pq.HandleEvent(Objective_Type.QUEST_KILL_MOB, Spawn.Entry, 1);
                }
            }

            Killer.QtsInterface.HandleEvent(Objective_Type.QUEST_KILL_MOB, Spawn.Entry, 1);
            base.SetDeath(Killer);

            if (Spawn.Entry == 28432 || Spawn.Entry == 34357 || Spawn.Entry == 5780)       // Lair Bosses 2 hour spawn time
            {
                EvtInterface.AddEvent(RezUnit, (7200000 + RandomMgr.Next(0, 3600000)), 1); // 2 hours seconds Rez
            }
            else
            {
                EvtInterface.AddEvent(RezUnit, 50000 + Level * 1000, 1); // 30 seconds Rez
            }
        }
Example #2
0
        public static Loot GenerateLoot(Unit Corps, Unit Looter)
        {
            if (!Looter.IsPlayer())
                return null;

            if (Corps.IsCreature())
            {
                Creature Crea = Corps.GetCreature();

                List<Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry);
                if (CreatureLoots.Count <= 0)
                    return null;

                List<LootInfo> Loots = new List<LootInfo>();
                foreach (Creature_loot Loot in CreatureLoots)
                {
                    float Pct = Loot.Pct * Program.Config.GlobalLootRate;
                    if (Pct <= 0)
                        Pct = 0.01f;

                    switch ((SystemData.ItemRarity)Loot.Info.Rarity)
                    {
                        case SystemData.ItemRarity.ITEMRARITY_COMMON:
                            Pct *= Program.Config.CommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_UNCOMMON:
                            Pct *= Program.Config.UncommonLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_RARE:
                            Pct *= Program.Config.RareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_VERY_RARE:
                            Pct *= Program.Config.VeryRareLootRate;
                            break;
                        case SystemData.ItemRarity.ITEMRARITY_ARTIFACT:
                            Pct *= Program.Config.ArtifactLootRate;
                            break;
                    };

                    if(Pct  > 100.0f || RandomMgr.Next(10000) < (Pct*100))
                      Loots.Add(new LootInfo(Loot.Info));
                }

                UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50);

                if (Loots.Count > 0 || Money > 0)
                {
                    Log.Success("LootMgr", "Generate Loot : " + Loots.Count);
                    Loot Lt = new Loot();
                    Lt.Money = Money;
                    Lt.Loots = Loots.ToArray();
                    return Lt;
                }

            }

            return null;
        }
Example #3
0
        static public string GetCreatureText(uint Entry)
        {
            string Text = "";

            if (_CreatureTexts.ContainsKey(Entry))
            {
                int RandomNum = RandomMgr.Next(_CreatureTexts[Entry].Count);
                Text = _CreatureTexts[Entry][RandomNum].Text;
            }

            return(Text);
        }
Example #4
0
        public override bool Load()
        {
            Evt = _Owner.EvtInterface;
            if (_Owner.IsUnit())
            {
                Cbt = _Owner.GetUnit().CbtInterface;
                Mvt = _Owner.GetUnit().MvtInterface;
            }

            Evt.AddEvent(UpdateThink, BrainThinkTime + RandomMgr.Next(0, 2000), 0);
            Evt.AddEventNotify(EventName.ON_TARGET_DIE, OnTargetDie);

            return(base.Load());
        }
Example #5
0
        static public void Mount(Player Target)
        {
            if (Target.MvtInterface.IsMount())
            {
                return;
            }

            if (RandomMgr.Next(4) == 1)
            {
                Target.MvtInterface.CurrentMount.SetMount(3);
            }
            else
            {
                Target.MvtInterface.CurrentMount.SetMount(12);
            }
        }
Example #6
0
        public string GetRandomName()
        {
            if (RandomNames != null && RandomNames.Count > 0)
            {
                for (int TryCount = 0; TryCount < 10; ++TryCount)
                {
                    int ID = RandomMgr.Next(0, RandomNames.Count - 1);
                    if (GetCharacter(RandomNames[ID].Name) == null)
                    {
                        return(RandomNames[ID].Name);
                    }
                }
            }

            return("RandomName");
        }
 private void BombDroppedOff(Player plr, Part part)
 {
     if (plr == null)
     {
         Log.Error("BombDroppedOff", "NULL player");
         return;
     }
     if (_bomb == null)
     {
         Log.Error("BombDroppedOff", "NULL bomb");
         return;
     }
     GivePoints((_carrier.Realm == Realms.REALMS_REALM_ORDER ? 1 : 2), 75);
     _carrier.CanMount = true;
     RemoveBombBuff(_carrier);
     EvtInterface.AddEvent(DetonateStockpile, RandomMgr.Next(3000, 5000), 1);
     Broadcast(new[] { plr.GenderedName, (plr.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction"), _bomb.Name }, ChatLogFilters.CHATLOGFILTERS_C_WHITE, Localized_text.TEXT_BOMB_CAPTURE);
 }
        private void BombPickedUp(Player plr, Part part)
        {
            RemoveBombFromWorld();

            _carrier = plr;
            EvtInterface.RemoveEvent(CarrierBombTimer);
            EvtInterface.AddEvent(CarrierBombTimer, RandomMgr.Next(50000, 80000), 1);

            if (_carrier.Realm == Realms.REALMS_REALM_DESTRUCTION)
            {
                _centerGlow.VfxState = 2;
            }
            else
            {
                _centerGlow.VfxState = 1;
            }

            Broadcast(new[] { plr.GenderedName, (plr.Realm == Realms.REALMS_REALM_ORDER ? "Order" : "Destruction"), _bomb.Name }, ChatLogFilters.CHATLOGFILTERS_C_WHITE, Localized_text.TEXT_FLAG_CAPTURE);
        }
Example #9
0
        static public void Mount(Player Target)
        {
            if (Target.MvtInterface.IsMount())
            {
                return;
            }

            if (Target._Info.Race == (byte)GameData.Races.RACES_DWARF)
            {
                Target.MvtInterface.CurrentMount.SetMount(8);
            }
            else if (RandomMgr.Next(4) == 1)
            {
                Target.MvtInterface.CurrentMount.SetMount(180);
            }
            else
            {
                Target.MvtInterface.CurrentMount.SetMount(1);
            }
        }
Example #10
0
        public override void OnLoad()
        {
            InteractType = GenerateInteractType(Spawn.Title);

            SetFaction(Spawn.Faction != 0 ? Spawn.Faction : Spawn.Proto.Faction);

            ItmInterface.Load(WorldMgr.GetCreatureItems(Spawn.Entry));
            Level = (byte)RandomMgr.Next((int)Spawn.Proto.MinLevel, (int)Spawn.Proto.MaxLevel);
            StsInterface.SetBaseStat((byte)GameData.Stats.STATS_WOUNDS, GenerateWounds(Level, Rank));
            StsInterface.ApplyStats();
            Health = TotalHealth;

            X = Zone.CalculPin((uint)(Spawn.WorldX), true);
            Y = Zone.CalculPin((uint)(Spawn.WorldY), false);
            Z = (ushort)(Spawn.WorldZ * 2);


            // TODO : Bad Height Formula

            /*int HeightMap = HeightMapMgr.GetHeight(Zone.ZoneId, X, Y);
             * if (Z < HeightMap)
             * {
             *  Log.Error("Creature", "["+Spawn.Entry+"] Invalid Height : Min=" + HeightMap + ",Z=" + Z);
             *  return;
             * }*/

            Heading         = (ushort)Spawn.WorldO;
            WorldPosition.X = Spawn.WorldX;
            WorldPosition.Y = Spawn.WorldY;
            WorldPosition.Z = Spawn.WorldZ;

            SetOffset((ushort)(Spawn.WorldX >> 12), (ushort)(Spawn.WorldY >> 12));
            Region.UpdateRange(this);

            base.OnLoad();
        }
Example #11
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));
            }
        }
Example #12
0
        static public Loot GenerateLoot(Unit Corps, Unit Looter)
        {
            if (!Looter.IsPlayer())
            {
                return(null);
            }

            Player Plr = Looter.GetPlayer();

            if (Corps.IsCreature())
            {
                Creature Crea = Corps.GetCreature();

                List <Creature_loot> CreatureLoots = WorldMgr.GetLoots(Crea.Entry);
                if (CreatureLoots.Count <= 0)
                {
                    return(null);
                }

                QuestsInterface Interface = Plr.QtsInterface;

                List <LootInfo> Loots = new List <LootInfo>();
                float           Pct;
                foreach (Creature_loot Loot in CreatureLoots)
                {
                    if (Loot.Info.MinRank > Corps.Level + 4 || Loot.Info.MinRenown > (Corps.Level + 4) * 2)
                    {
                        continue;
                    }

                    if (Loot.Info.Realm != 0 && Loot.Info.Realm != (byte)Plr.Realm)
                    {
                        continue;
                    }

                    Pct = Loot.Pct * Program.Config.GlobalLootRate;
                    if (Pct <= 0)
                    {
                        Pct = 0.01f;
                    }

                    switch ((SystemData.ItemRarity)Loot.Info.Rarity)
                    {
                    case SystemData.ItemRarity.ITEMRARITY_COMMON:
                        Pct *= Program.Config.CommonLootRate;
                        break;

                    case SystemData.ItemRarity.ITEMRARITY_UNCOMMON:
                        Pct *= Program.Config.UncommonLootRate;
                        break;

                    case SystemData.ItemRarity.ITEMRARITY_RARE:
                        Pct *= Program.Config.RareLootRate;
                        break;

                    case SystemData.ItemRarity.ITEMRARITY_VERY_RARE:
                        Pct *= Program.Config.VeryRareLootRate;
                        break;

                    case SystemData.ItemRarity.ITEMRARITY_ARTIFACT:
                        Pct *= Program.Config.ArtifactLootRate;
                        break;
                    }
                    ;

                    if (Interface != null && Pct != 100.0f)
                    {
                        foreach (KeyValuePair <ushort, Character_quest> Kp in Interface._Quests)
                        {
                            if (!Kp.Value.Done && !Kp.Value.IsDone())
                            {
                                foreach (Character_Objectives Obj in Kp.Value._Objectives)
                                {
                                    if (!Obj.IsDone() && Obj.Objective.Item != null)
                                    {
                                        if (Obj.Objective.Item.Entry == Loot.ItemId)
                                        {
                                            Pct = 100;
                                            break;
                                        }
                                    }
                                }
                            }

                            if (Pct >= 100)
                            {
                                break;
                            }
                        }
                    }

                    if (Pct >= 100f || RandomMgr.Next(10000) < (Pct * 100))
                    {
                        Loots.Add(new LootInfo(Loot.Info));
                    }
                }

                UInt32 Money = (UInt32)(Corps.Level * (UInt32)7) + (Corps.Rank * (UInt32)50);

                if (Loots.Count > 0 || Money > 0)
                {
                    Loot Lt = new Loot();
                    Lt.Money = Money;
                    Lt.Loots = Loots;
                    Corps.EvtInterface.Notify(EventName.ON_GENERATE_LOOT, Looter, Lt);
                    return(Lt);
                }
            }
            else if (Corps.IsGameObject())
            {
                // This will generate gameobject loot. Currently this only shows loot
                // if a player needs an item it holds for a quest. If an object has
                // been looted already or has no loot this will return null.
                // Todo: Currently object loot always is 100%. Make this support
                // non quest related loot.
                GameObject             GameObj         = Corps.GetGameObject();
                List <GameObject_loot> GameObjectLoots = WorldMgr.GetGameObjectLoots(GameObj.Spawn.Entry);
                if (GameObjectLoots.Count <= 0 || GameObj.Looted)
                {
                    return(null);
                }

                QuestsInterface Interface = Plr.QtsInterface;
                List <LootInfo> Loots     = new List <LootInfo>();
                foreach (GameObject_loot Loot in GameObjectLoots)
                {
                    if (Interface != null)
                    {
                        foreach (KeyValuePair <ushort, Character_quest> Kp in Interface._Quests)
                        {
                            if (!Kp.Value.Done && !Kp.Value.IsDone())
                            {
                                foreach (Character_Objectives Obj in Kp.Value._Objectives)
                                {
                                    if (!Obj.IsDone() && Obj.Objective.Item != null)
                                    {
                                        if (Obj.Objective.Item.Entry == Loot.ItemId)
                                        {
                                            Loots.Add(new LootInfo(Loot.Info));
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                Loot Lt = new Loot();
                Lt.Money = 0;
                Lt.Loots = Loots;
                return(Lt);
            }

            return(null);
        }
Example #13
0
        public override void SendMeTo(Player Plr)
        {
            // Log.Success("Creature", "SendMe " + Name);


            //Log.Info("Creature", "npc = " + Name + "  Oid = " + Oid + "  X= " + Spawn.WorldX + "  Y= " + Spawn.WorldY + "  Z= " + Spawn.WorldZ);



            PacketOut Out = new PacketOut((byte)Opcodes.F_CREATE_MONSTER);

            Out.WriteUInt16(Oid);
            Out.WriteUInt16(0);

            Out.WriteUInt16((UInt16)Heading);
            Out.WriteUInt16((UInt16)WorldPosition.Z);
            Out.WriteUInt32((UInt32)WorldPosition.X);
            Out.WriteUInt32((UInt32)WorldPosition.Y);
            Out.WriteUInt16(0); // Speed Z
            // 18


            if (Spawn.Proto.Model2 != 0)
            {
                if (RandomMgr.Next(0, 100) < 50)
                {
                    Out.WriteUInt16(Spawn.Proto.Model2);
                }
                else
                {
                    Out.WriteUInt16(Spawn.Proto.Model1);
                }
            }
            else
            {
                Out.WriteUInt16(Spawn.Proto.Model1);
            }

            Out.WriteByte((byte)RandomMgr.Next(Spawn.Proto.MinScale, Spawn.Proto.MaxScale));
            Out.WriteByte(Level);
            Out.WriteByte(Faction);

            Out.WriteByte(0);
            Out.WriteByte(Spawn.Val);
            Out.WriteUInt16(0);

            Out.WriteByte(Spawn.Emote);
            Out.WriteByte(0); // ?
            Out.WriteUInt16(Spawn.Proto._Unks[1]);
            Out.WriteByte(0);
            Out.WriteUInt16(Spawn.Proto._Unks[2]);
            Out.WriteUInt16(Spawn.Proto._Unks[3]);
            Out.WriteUInt16(Spawn.Proto._Unks[4]);
            Out.WriteUInt16(Spawn.Proto._Unks[5]);
            Out.WriteUInt16(Spawn.Proto._Unks[6]);
            Out.WriteUInt16(Spawn.Title);

            long TempPos = Out.Position;
            byte TempLen = (byte)(Spawn.bBytes.Length + States.Count);

            Out.WriteByte(TempLen);
            Out.Write(Spawn.bBytes, 0, Spawn.bBytes.Length);
            Out.Write(States.ToArray(), 0, States.Count);
            if (QtsInterface.CreatureHasStartQuest(Plr))
            {
                Out.WriteByte(5);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }
            else if (QtsInterface.CreatureHasQuestToAchieve(Plr))
            {
                Out.WriteByte(4);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }
            else if (QtsInterface.CreatureHasQuestToComplete(Plr))
            {
                Out.WriteByte(7);
                Out.Position = TempPos;
                Out.WriteByte((byte)(TempLen + 1));
            }

            Out.Position = Out.Length;

            Out.WriteByte(0);

            Out.WriteStringBytes(Name);



            Out.WriteByte(Spawn.D1);
            Out.WriteByte(Spawn.D2);

            Out.WriteUInt16(0); //00 00
            Out.WriteUInt16(0); // 00 00

            Out.WriteByte(Spawn.Unk1);

            Out.WriteByte(0);
            Out.WriteByte(48);
            Out.WriteByte(0x01);
            Out.WriteByte(0x0A);

            Out.WriteUInt16(0);
            Out.WriteByte(0);


            Out.WriteByte(Spawn.Icone);
            Out.WriteByte((byte)Spawn.Proto._Unks[0]);
            Out.WriteByte(0);


            Out.WriteUInt16(Oid);
            Out.WriteUInt32((UInt32)Spawn.Flag);
            Out.WriteUInt16((UInt16)Spawn.WorldZ);

            Out.WriteByte(100);

            Out.WriteUInt16(Spawn.ZoneId);

            Out.WriteUInt32(0);
            Out.WriteByte(Spawn.Head0);

            Out.WriteUInt16R((UInt16)Heading);


            Out.WriteUInt16(Oid);
            Out.WriteByte(0);
            Out.WriteByte(7);

            Plr.SendPacket(Out);



            Out = new PacketOut((byte)Opcodes.F_PLAY_SOUND);
            Out.WriteByte(0);
            Out.WriteUInt32((UInt32)Spawn.Sound1);
            Out.WriteUInt32((UInt32)Spawn.Flag);
            Out.WriteUInt16((UInt16)Spawn.WorldZ);
            Out.WriteUInt16(0);
            Plr.SendPacket(Out);


            Out = new PacketOut((byte)Opcodes.F_PLAY_SOUND);
            Out.WriteByte(0);
            Out.WriteUInt32((UInt32)Spawn.Sound2);
            Out.WriteUInt32((UInt32)Spawn.Flag);
            Out.WriteUInt16((UInt16)Spawn.WorldZ);
            Out.WriteUInt16(0);
            Plr.SendPacket(Out);



            base.SendMeTo(Plr);
        }
Example #14
0
        public override void OnLoad()
        {
            InteractType = GenerateInteractType(Spawn.Title != 0 ? Spawn.Title : Spawn.Proto.Title);

            SetFaction(Spawn.Faction != 0 ? Spawn.Faction : Spawn.Proto.Faction);

            ItmInterface.Load(WorldMgr.GetCreatureItems(Spawn.Entry));
            if (Spawn.Proto.MinLevel > Spawn.Proto.MaxLevel)
            {
                Spawn.Proto.MinLevel = Spawn.Proto.MaxLevel;
            }

            if (Spawn.Proto.MaxLevel <= Spawn.Proto.MinLevel)
            {
                Spawn.Proto.MaxLevel = Spawn.Proto.MinLevel;
            }

            if (Spawn.Proto.MaxLevel == 0)
            {
                Spawn.Proto.MaxLevel = 1;
            }
            if (Spawn.Proto.MinLevel == 0)
            {
                Spawn.Proto.MinLevel = 1;
            }

            Level = (byte)RandomMgr.Next((int)Spawn.Proto.MinLevel, (int)Spawn.Proto.MaxLevel + 1);
            StsInterface.SetBaseStat((byte)GameData.Stats.STATS_WOUNDS, GenerateWounds(Level, Rank));
            StsInterface.ApplyStats();
            Health = TotalHealth;

            X = Zone.CalculPin((uint)(Spawn.WorldX), true);
            Y = Zone.CalculPin((uint)(Spawn.WorldY), false);
            Z = (ushort)(Spawn.WorldZ);

            /*
             * if (Zone.ZoneId == 161)
             * {
             *  Z += 16384;
             *  X += 16384;
             *  Y += 16384;
             * }
             */
            // TODO : Bad Height Formula

            /*int HeightMap = HeightMapMgr.GetHeight(Zone.ZoneId, X, Y);
             * if (Z < HeightMap)
             * {
             *  Log.Error("Creature", "["+Spawn.Entry+"] Invalid Height : Min=" + HeightMap + ",Z=" + Z);
             *  return;
             * }*/

            Heading         = (ushort)Spawn.WorldO;
            WorldPosition.X = Spawn.WorldX;
            WorldPosition.Y = Spawn.WorldY;
            WorldPosition.Z = Spawn.WorldZ;

            SetOffset((ushort)(Spawn.WorldX >> 12), (ushort)(Spawn.WorldY >> 12));
            ScrInterface.AddScript(Spawn.Proto.ScriptName);
            base.OnLoad();

            if (Spawn.Title == 0 && Spawn.Icone == 0 && Spawn.Proto.Title == 0 && Spawn.Icone == 0 && Spawn.Emote == 0 && Spawn.Proto.FinishingQuests == null && Spawn.Proto.StartingQuests == null)
            {
                if (Faction <= 1 || Faction == 128 || Faction == 129)
                {
                    SFastRandom Random = new SFastRandom(X ^ Y ^ Z);

                    for (int i = 0; i < 3; ++i)
                    {
                        Waypoint Wp = new Waypoint();
                        Wp.X           = (ushort)(X + Random.randomInt(50) + Random.randomInt(100) + Random.randomInt(150));
                        Wp.Y           = (ushort)(Y + Random.randomInt(50) + Random.randomInt(100) + Random.randomInt(150));
                        Wp.Z           = (ushort)Z;
                        Wp.Speed       = 10;
                        Wp.WaitAtEndMS = (uint)(5000 + Random.randomIntAbs(10) * 1000);
                        AiInterface.AddWaypoint(Wp);
                    }
                }
            }

            IsActive = true;
        }
Example #15
0
        public GameData.AbilityResult CheckBlock()
        {
            // If wearing a shield
            int Block = 0;

            if (Target.ItmInterface.GetItemInSlot((UInt16)EquipSlot.MAIN_GAUCHE) != null && Target.ItmInterface.GetItemInSlot((UInt16)EquipSlot.MAIN_GAUCHE).Info.Type == 5)
            {
                Block = (int)(((double)((float)Target.ItmInterface.GetItemInSlot((UInt16)EquipSlot.MAIN_GAUCHE).Info.Armor / OffensiveStat) * 0.2) * 100);
            }
            if (Block > 50)
            {
                Block = 50;
            }
            Log.Info("Block rate", "" + Block);
            Log.Info("GameData Block", "" + GameData.BonusTypes.BONUSTYPES_EBONUS_BLOCK);

            if (RandomMgr.Next(100) < (Block + (Target.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_BLOCK) - Ab.Caster.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_BLOCK_STRIKETHROUGH))))
            {
                return(GameData.AbilityResult.ABILITYRESULT_BLOCK);
            }

            uint AttackType = 0;

            if (Ab.Info.Info.MaxRange <= 5)
            {
                AttackType = 0; // Melee
            }
            else
            {
                AttackType = 1; // Ranged
            }
            int SecondaryDefense = (int)((((double)DefensiveStat / OffensiveStat * 0.075) * 100));

            if (SecondaryDefense > 25)
            {
                SecondaryDefense = 25;
            }

            switch (AttackType)
            {
            case 0:                                                                                                                                                                                                                                        // Parray
            {
                if (RandomMgr.Next(100) < (SecondaryDefense + Target.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_PARRY) - Ab.Caster.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_PARRY_STRIKETHROUGH))) // Parry
                {
                    return(GameData.AbilityResult.ABILITYRESULT_PARRY);
                }
            }
            break;

            case 1:                                                                                                                                                                                                                                        // Evade
            {
                if (RandomMgr.Next(100) < (SecondaryDefense + Target.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_EVADE) - Ab.Caster.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_EVADE_STRIKETHROUGH))) // Dodge
                {
                    return(GameData.AbilityResult.ABILITYRESULT_EVADE);
                }
            }
            break;

            case 2:                                                                                                                                                                                                                                            // Disrupt
            {
                if (RandomMgr.Next(100) < (SecondaryDefense + Target.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_DISRUPT) - Ab.Caster.StsInterface.GetTotalStat((byte)GameData.BonusTypes.BONUSTYPES_EBONUS_DISRUPT_STRIKETHROUGH))) // Disrupt
                {
                    return(GameData.AbilityResult.ABILITYRESULT_DISRUPT);
                }
            }
            break;
            }

            Log.Info("Block", "<<<<<<<<<<<<<<<");
            return(GameData.AbilityResult.ABILITYRESULT_OK);
        }
Example #16
0
        public override void OnLoad()
        {
            InteractType = GenerateInteractType(Spawn.Title != 0 ? Spawn.Title : Spawn.Proto.Title);

            SetFaction(Spawn.Faction != 0 ? Spawn.Faction : Spawn.Proto.Faction);

            ItmInterface.Load(WorldMgr.GetCreatureItems(Spawn.Entry));
            if (Spawn.Proto.MinLevel > Spawn.Proto.MaxLevel)
            {
                Spawn.Proto.MinLevel = Spawn.Proto.MaxLevel;
            }

            if (Spawn.Proto.MaxLevel <= Spawn.Proto.MinLevel)
            {
                Spawn.Proto.MaxLevel = Spawn.Proto.MinLevel;
            }

            if (Spawn.Proto.MaxLevel == 0)
            {
                Spawn.Proto.MaxLevel = 1;
            }
            if (Spawn.Proto.MinLevel == 0)
            {
                Spawn.Proto.MinLevel = 1;
            }


            if (Spawn.Level != 0)
            {
                if (Spawn.Level > 2)
                {
                    Level = (byte)RandomMgr.Next((int)Spawn.Level - 1, Spawn.Level + 1);
                }
                else
                {
                    Level = (byte)RandomMgr.Next((int)Spawn.Level, Spawn.Level + 1);
                }
            }
            else
            {
                Level = (byte)RandomMgr.Next((int)Spawn.Proto.MinLevel, (int)Spawn.Proto.MaxLevel + 1);
            }
            StsInterface.SetBaseStat((byte)GameData.Stats.STATS_WOUNDS, GenerateWounds(Level, Rank));
            StsInterface.ApplyStats();
            Health = TotalHealth;

            X = Zone.CalculPin((uint)(Spawn.WorldX), true);
            Y = Zone.CalculPin((uint)(Spawn.WorldY), false);
            Z = (ushort)(Spawn.WorldZ);

            /*
             * if (Zone.ZoneId == 161)
             * {
             *  Z += 16384;
             *  X += 16384;
             *  Y += 16384;
             * }
             * //*/
            // TODO : Bad Height Formula

            /*
             * //int HeightMap = HeightMapMgr.GetHeight(Zone.ZoneId, X, Y);
             * int HeightMap = ClientFileMgr.GetHeight(Zone.ZoneId, X, Y);
             *
             * if (Z < HeightMap)
             * {
             *  Log.Error("Creature", "["+Spawn.Entry+"] Invalid Height : Min=" + HeightMap + ",Z=" + Z);
             *  return;
             * }*/

            Heading         = (ushort)Spawn.WorldO;
            WorldPosition.X = Spawn.WorldX;
            WorldPosition.Y = Spawn.WorldY;
            WorldPosition.Z = Spawn.WorldZ;

            SetOffset((ushort)(Spawn.WorldX >> 12), (ushort)(Spawn.WorldY >> 12));
            ScrInterface.AddScript(Spawn.Proto.ScriptName);
            base.OnLoad();

            /*AiInterface.Waypoints = WorldMgr.GetNpcWaypoints(Spawn.Guid);
             *
             * if (Spawn.Title == 0 && Spawn.Icone == 0 && Spawn.Proto.Title == 0 && Spawn.Icone == 0 && Spawn.Emote == 0 && Spawn.Proto.FinishingQuests == null && Spawn.Proto.StartingQuests == null)
             * {
             *  if (Faction <= 1 || Faction == 128 || Faction == 129)
             *  {
             *      if (AiInterface.Waypoints.Count <= 4)
             *      {
             *          int i = 0;
             *          if (AiInterface.Waypoints.Count != 0)
             *              i = AiInterface.Waypoints.Count - 1;
             *          for (; i < 3; ++i)
             *          {
             *              AiInterface.AddWaypoint(new Waypoint());
             *          }
             *      }
             *      foreach (Waypoint Wp in AiInterface.Waypoints)
             *      {
             *          AiInterface.RandomizeWaypoint(Wp);
             *      }
             *  }
             * }*/
            IsActive = true;

            if (InteractType == GameData.InteractType.INTERACTTYPE_TRAINER)
            {
                States.Add(1);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_BANKER)
            {
                States.Add(11);                                                 // 11
            }
            if (InteractType == GameData.InteractType.INTERACTTYPE_GUILD_VAULT) // added
            {
                States.Add(0);                                                  // dont know what states are yet ?
            }
            if (InteractType == GameData.InteractType.INTERACTTYPE_AUCTIONEER)
            {
                States.Add(12);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_GUILD_REGISTRAR)
            {
                States.Add(14);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_FLIGHT_MASTER)
            {
                States.Add(15);
            }

            if (InteractType == GameData.InteractType.INTERACTTYPE_DYEMERCHANT)
            {
                States.Add(26);
            }
        }
        private void Explosion(Point3D location, Player target = null)
        {
            var killPlayers = new List <Player>();

            if (target == null)
            {
                killPlayers = Region.WorldQuery <Player>(location, 10);
            }

            if (target != null && killPlayers.Contains(target))
            {
                killPlayers.Add(target);
            }

            AbilityDamageInfo damageThisPass = new AbilityDamageInfo
            {
                Entry           = 14050,
                DisplayEntry    = 0,
                DamageType      = DamageTypes.RawDamage,
                MinDamage       = (ushort)(30000),
                MaxDamage       = (ushort)(30000),
                CastPlayerSubID = 0
            };


            PacketOut Out = new PacketOut((byte)Opcodes.F_PLAY_EFFECT, 30);

            Out.WriteUInt16(264);
            Out.WriteUInt16(0);
            Out.WriteUInt32((uint)location.X);
            Out.WriteUInt32((uint)location.Y);
            Out.WriteUInt32((uint)location.Z);
            Out.WriteUInt16(100);
            Out.WriteUInt16(100);
            Out.WriteUInt16(100);
            Out.WriteUInt16(0);


            Region.DispatchPacket(Out, location, 400);


            foreach (var player in killPlayers)
            {
                CombatManager.InflictDamage(damageThisPass, 20, player, player);
            }

            foreach (var player in Region.WorldQuery <Player>(location, 50))
            {
                if (!player.IsDead)
                {
                    int val = RandomMgr.Next(2000, 8000);
                    player.ApplyKnockback(location, 700, 50, 0, 2, 1);
                    CombatManager.InflictDamage(new AbilityDamageInfo
                    {
                        Entry           = 14050,
                        DisplayEntry    = 0,
                        DamageType      = DamageTypes.RawDamage,
                        MinDamage       = (ushort)(val),
                        MaxDamage       = (ushort)(val),
                        CastPlayerSubID = 0
                    }, player.Level, player, player);
                }
            }

            if (_carrier != null)
            {
                _carrier.CanMount = true;
                RemoveBombBuff(_carrier);
            }

            CreateBomb();
        }
        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);
        }