コード例 #1
0
        public static void RecordMetrics(Logger logger, int tier, RegionMgr region, IBattleFrontManager battleFrontManager)
        {
            try
            {
                var groupId = Guid.NewGuid().ToString();

                logger.Trace($"There are {battleFrontManager.GetBattleFrontStatusList().Count} battlefront statuses ({battleFrontManager.GetType().ToString()}).");
                foreach (var status in battleFrontManager.GetBattleFrontStatusList())
                {
                    lock (status)
                    {
                        if (status.RegionId == region.RegionId)
                        {
                            logger.Trace($"Recording metrics for BF Status : ({status.BattleFrontId}) {status.Description}");
                            if (!status.Locked)
                            {
                                var metrics = new RVRMetrics
                                {
                                    BattlefrontId            = status.BattleFrontId,
                                    BattlefrontName          = status.Description,
                                    DestructionVictoryPoints = (int)battleFrontManager.ActiveBattleFront.DestroVP,
                                    OrderVictoryPoints       = (int)battleFrontManager.ActiveBattleFront.OrderVP,
                                    Locked                   = status.LockStatus,
                                    OrderPlayersInLake       = PlayerUtil.GetTotalOrderPVPPlayerCountInZone(battleFrontManager.ActiveBattleFront.ZoneId),
                                    DestructionPlayersInLake = PlayerUtil.GetTotalDestPVPPlayerCountInZone(battleFrontManager.ActiveBattleFront.ZoneId),
                                    Tier      = tier,
                                    Timestamp = DateTime.UtcNow,
                                    GroupId   = groupId,
                                    TotalPlayerCountInRegion      = PlayerUtil.GetTotalPVPPlayerCountInRegion(status.RegionId),
                                    TotalDestPlayerCountInRegion  = PlayerUtil.GetTotalDestPVPPlayerCountInRegion(status.RegionId),
                                    TotalOrderPlayerCountInRegion = PlayerUtil.GetTotalOrderPVPPlayerCountInRegion(status.RegionId),
                                    TotalPlayerCount        = Player._Players.Count(x => !x.IsDisposed && x.IsInWorld() && x != null),
                                    TotalFlaggedPlayerCount = Player._Players.Count(x => !x.IsDisposed && x.IsInWorld() && x != null && x.CbtInterface.IsPvp)
                                };
                                WorldMgr.Database.AddObject(metrics);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                logger.Error($"Could not write rvr metrics..continuing. {e.Message} {e.StackTrace}");
            }
        }
コード例 #2
0
        public static void DetermineCaptains(IBattleFrontManager battleFrontManager, RegionMgr region)
        {
            var status = battleFrontManager.GetActiveCampaign().ActiveBattleFrontStatus;

            lock (status)
            {
                Logger.Trace($"Checking for new Realm Captains...");
                if (status.RegionId == region.RegionId)
                {
                    var zonePlayers = Player._Players.Where(x => !x.IsDisposed &&
                                                            x.IsInWorld() &&
                                                            x.CbtInterface.IsPvp &&
                                                            x.ScnInterface.Scenario == null &&
                                                            x.ZoneId == status.ZoneId).ToList();

                    if (zonePlayers.Count < REALM_CAPTAIN_MINIMUM_PLAYERS)
                    {
                        Logger.Trace($"Zone Players = {zonePlayers} - not enough for a Realm Captain to spawn");
                        return;
                    }

                    var realmCaptains = status.ContributionManagerInstance.GetHigestContributors(
                        REALM_CAPTAIN_MINIMUM_CONTRIBUTION, zonePlayers);


                    MarkPlayerAsRealmCaptain(status.DestructionRealmCaptain, Player._Players, UNMARK_PLAYER_REALM_CAPTAIN);
                    MarkPlayerAsRealmCaptain(status.OrderRealmCaptain, Player._Players, UNMARK_PLAYER_REALM_CAPTAIN);

                    status.RemoveAsRealmCaptain(status.DestructionRealmCaptain);
                    status.RemoveAsRealmCaptain(status.OrderRealmCaptain);

                    RemoveRealmCaptainBuffs(status.DestructionRealmCaptain);
                    RemoveRealmCaptainBuffs(status.OrderRealmCaptain);

                    // Destruction
                    if (realmCaptains[0] != null)
                    {
                        status.SetAsRealmCaptain(realmCaptains[0]);

                        MarkPlayerAsRealmCaptain(realmCaptains[0], zonePlayers, MARK_PLAYER_REALM_CAPTAIN);

                        if (StaticRandom.Instance.Next(100) < REALM_CAPTAIN_TELL_CHANCE)
                        {
                            foreach (var player in zonePlayers.Where(x => x.Realm == Realms.REALMS_REALM_ORDER))
                            {
                                player.SendMessage(
                                    $"A captain has emerged from the ranks of the enemy. Take the head of {realmCaptains[0].Name}!",
                                    ChatLogFilters.CHATLOGFILTERS_RVR);
                            }
                        }
                    }
                    // Order
                    if (realmCaptains[1] != null)
                    {
                        status.SetAsRealmCaptain(realmCaptains[1]);
                        MarkPlayerAsRealmCaptain(realmCaptains[1], zonePlayers, MARK_PLAYER_REALM_CAPTAIN);
                        if (StaticRandom.Instance.Next(100) < REALM_CAPTAIN_TELL_CHANCE)
                        {
                            foreach (var player in zonePlayers.Where(x => x.Realm == Realms.REALMS_REALM_DESTRUCTION))
                            {
                                player.SendMessage(
                                    $"A captain has emerged from the ranks of the enemy. Take the head of {realmCaptains[1].Name}!",
                                    ChatLogFilters.CHATLOGFILTERS_RVR);
                            }
                        }
                    }
                }
            }
        }