コード例 #1
0
ファイル: DamageTracker.cs プロジェクト: Gl0/TeraDamageMeter
        public void Update(SkillResult skillResult)
        {
            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.SourcePlayer);
                var statsChange = StatsChange(skillResult);
                playerStats.Dealt.Add(statsChange);
                TotalDealt.Add(statsChange);
            }

            if (skillResult.TargetPlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.TargetPlayer);
                var statsChange = StatsChange(skillResult);
                playerStats.Received.Add(statsChange);
                TotalReceived.Add(statsChange);
            }

            if (skillResult.SourcePlayer != null && (skillResult.Damage > 0) && (skillResult.Source.Id != skillResult.Target.Id))
            {
                LastAttack = skillResult.Time;

                if (FirstAttack == null)
                {
                    FirstAttack = skillResult.Time;
                }
            }
        }
コード例 #2
0
        private PlayerInfo GetOrCreate(SkillResult skillResult)
        {
            NpcEntity npctarget = skillResult.Target as NpcEntity;

            if (npctarget != null)
            {
                if (OnlyBosses)//not count bosses
                {
                    if (!npctarget.Info.Boss)
                    {
                        return(null);
                    }
                }
                if (IgnoreOneshots)//ignore damage that is more than 10x times than mob's hp
                {
                    if ((npctarget.Info.HP > 0) && (npctarget.Info.HP <= skillResult.Damage / 10))
                    {
                        return(null);
                    }
                }
            }
            var        player      = skillResult.SourcePlayer;
            PlayerInfo playerStats = StatsByUser.FirstOrDefault(pi => pi.Player.Equals(player));

            if (playerStats == null && (IsFromHealer(skillResult) ||                                 //either healer
                                        (!IsFromHealer(skillResult) && IsValidAttack(skillResult)))) //or damage from non-healer
            {
                playerStats = new PlayerInfo(player, this);
                StatsByUser.Add(playerStats);
            }
            return(playerStats);
        }
コード例 #3
0
        public void Update(EachSkillResultServerMessage message)
        {
            var skillResult = new SkillResult(message, _entityTracker, _playerTracker, _skillDatabase);

            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.SourcePlayer);
                var statsChange = StatsChange(skillResult);
                playerStats.Dealt.Add(statsChange);
                TotalDealt.Add(statsChange);
            }

            if (skillResult.TargetPlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.TargetPlayer);
                var statsChange = StatsChange(skillResult);
                playerStats.Received.Add(statsChange);
                TotalReceived.Add(statsChange);
            }

            if (skillResult.SourcePlayer != null && (skillResult.Damage > 0) && (skillResult.Source.Id != skillResult.Target.Id))
            {
                LastAttack = skillResult.Time;

                if (FirstAttack == null)
                {
                    FirstAttack = skillResult.Time;
                }
            }
        }
コード例 #4
0
        private void UpdateStats(SkillStats stats, SkillResult message)
        {
            if (message.Amount == 0)
            {
                return;
            }

            stats.Damage += message.Damage;
            stats.Heal   += message.Heal;
            stats.Hits++;
            if (message.IsCritical)
            {
                stats.Crits++;
            }
        }
コード例 #5
0
        public void Update(EachSkillResultServerMessage message)
        {
            var skillResult = new SkillResult(message, _entityTracker, _playerTracker, _skillDatabase);

            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.SourcePlayer);
                UpdateStats(playerStats.Dealt, skillResult);
            }

            if (skillResult.TargetPlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.TargetPlayer);
                UpdateStats(playerStats.Received, skillResult);
            }
        }
コード例 #6
0
ファイル: DamageTracker.cs プロジェクト: Gl0/TeraDamageMeter
        private SkillStats StatsChange(SkillResult message)
        {
            var result = new SkillStats();

            if (message.Amount == 0)
            {
                return(result);
            }

            /// Fix counting self-damage, such as Death from above & Command: Self-destruct
            if ((message.Source.RootOwner == message.Target.RootOwner) && (message.Damage > 0))
            {
                return(result);
            }

            NpcEntity npctarget = message.Target as NpcEntity;

            if (npctarget != null)
            {
                if (OnlyBosses)       /// not count bosses
                {
                    if (!npctarget.Info.Boss)
                    {
                        return(result);
                    }
                }
                if (IgnoreOneshots)    /// ignore damage that is more than 10x times than mob's hp
                {
                    if ((npctarget.Info.HP > 0) && (npctarget.Info.HP <= message.Damage / 10))
                    {
                        return(result);
                    }
                }
            }

            result.Damage = message.Damage;
            result.Heal   = message.Heal;
            result.Hits++;
            if (message.IsCritical)
            {
                result.Crits++;
            }

            return(result);
        }
コード例 #7
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);

            _entityTracker?.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;

            if (skillResultMessage != null)
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                _damageTracker.Update(skillResult);
            }

            var cVersion = message as C_CHECK_VERSION;

            if (cVersion != null)
            {
                var opCodeNamer =
                    new OpCodeNamer(Path.Combine(_basicTeraData.ResourceDirectory,
                                                 $"opcodes/{cVersion.Versions[0]}.txt"));
                _messageFactory = new MessageFactory(opCodeNamer, _server.Region, cVersion.Versions[0]);
                return;
            }

            var sLoginMessage = message as LoginServerMessage;

            if (sLoginMessage != null)
            {
                if (_needInit)
                {
                    _server = _basicTeraData.Servers.GetServer(sLoginMessage.ServerId, _server);
                    _messageFactory.Region = _server.Region;
                    Text           = string.Format("Damage Meter connected to {0}", _server.Name);
                    _teraData      = _basicTeraData.DataForRegion(_server.Region);
                    _entityTracker = new EntityTracker(_teraData.NpcDatabase);
                    _playerTracker = new PlayerTracker(_entityTracker, _basicTeraData.Servers);
                    _damageTracker = new DamageTracker(_settings.OnlyBosses, _settings.IgnoreOneshots);
                    _entityTracker.Update(message);
                    _needInit = false;
                }
            }
        }
コード例 #8
0
        private SkillStats StatsChange(SkillResult message)
        {
            var result = new SkillStats();

            if (message.Amount == 0)
            {
                return(result);
            }

            result.Damage = message.Damage;
            result.Heal   = message.Heal;
            result.Hits++;
            if (message.IsCritical)
            {
                result.Crits++;
            }

            return(result);
        }
コード例 #9
0
        public void Update(SkillResult skillResult)
        {
            if (IsArchived)
            {
                return;            //prevent archived trackers from accidentally recording stats
            }
            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult);
                if (playerStats == null)
                {
                    return;                      //if this is null, that means we should ignore it
                }
                var statsChange = StatsChange(skillResult);
                if (statsChange == null)
                {
                    Logger.Warn($"Generated null SkillStats from {skillResult}");
                }

                playerStats.LogSkillUsage(skillResult);

                TotalDealt.Add(statsChange);
                playerStats.Dealt.Add(statsChange);
            }

            if (IsValidAttack(skillResult))
            {
                if (FirstAttack == null)
                {
                    FirstAttack = skillResult.Time;
                }

                LastAttack = skillResult.Time;
            }

            foreach (var playerStat in StatsByUser)
            {   //force update of calculated dps metrics
                playerStat.Dealt.UpdateStats();
            }
        }
コード例 #10
0
ファイル: DamageTracker.cs プロジェクト: DzenDyn/CasualMeter
 private PlayerInfo GetOrCreate(SkillResult skillResult)
 {
     var player = skillResult.SourcePlayer;
     PlayerInfo playerStats = StatsByUser.FirstOrDefault(pi => pi.Player.Equals(player));
     if (playerStats == null && (IsFromHealer(skillResult) ||//either healer
        (!IsFromHealer(skillResult) && IsValidAttack(skillResult))))//or damage from non-healer
     {
         playerStats = new PlayerInfo(player, this);
         StatsByUser.Add(playerStats);
     }
     return playerStats;
 }
コード例 #11
0
ファイル: PlayerInfo.cs プロジェクト: DzenDyn/CasualMeter
 public void LogSkillUsage(SkillResult result)
 {
     SkillLog.Add(result);
 }
コード例 #12
0
 public void LogSkillUsage(SkillResult result)
 {
     SkillLog.Add(result);
 }
コード例 #13
0
ファイル: ShellViewModel.cs プロジェクト: DzenDyn/CasualMeter
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);
            _entityTracker.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;
            if (SettingsHelper.Instance.Settings.InactivityResetDuration > 0
                && _inactivityTimer.Elapsed > TimeSpan.FromSeconds(SettingsHelper.Instance.Settings.InactivityResetDuration)
                && skillResultMessage.IsValid())
            {
                ResetDamageTracker();
            }
            if (!DamageTracker.IsArchived && skillResultMessage.IsValid(DamageTracker)) //don't process while viewing a past encounter
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                DamageTracker.Update(skillResult);
                if (!skillResult.IsHeal && skillResult.Amount > 0)
                    _inactivityTimer.Restart();
                PlayerCount = DamageTracker.StatsByUser.Count;
            }
        }
コード例 #14
0
ファイル: DamageTracker.cs プロジェクト: DzenDyn/CasualMeter
        private SkillStats StatsChange(SkillResult message)
        {
            var result = new SkillStats();
            if (message.Amount == 0)
                return result;

            result.Damage = message.Damage;
            result.Heal = message.Heal;

            if (IsFromHealer(message) || (!IsFromHealer(message) && !message.IsHeal))
            {
                result.Hits++;
                if (message.IsCritical)
                    result.Crits++;
            }

            return result;
        }
コード例 #15
0
ファイル: DamageTracker.cs プロジェクト: hawkwork/CasualMeter
 public bool IsValidAttack(SkillResult skillResult)
 {
     return skillResult.SourcePlayer != null && (skillResult.Damage > 0) &&
            (skillResult.Source.Id != skillResult.Target.Id);
 }
コード例 #16
0
ファイル: DamageTracker.cs プロジェクト: DzenDyn/CasualMeter
        public void Update(SkillResult skillResult)
        {
            if (IsArchived) return;//prevent archived trackers from accidentally recording stats

            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult);
                if (playerStats == null) return; //if this is null, that means we should ignore it
                var statsChange = StatsChange(skillResult);
                if (statsChange == null) Logger.Warn($"Generated null SkillStats from {skillResult}");

                playerStats.LogSkillUsage(skillResult);

                TotalDealt.Add(statsChange);
                playerStats.Dealt.Add(statsChange);
            }

            if (IsValidAttack(skillResult))
            {
                if (FirstAttack == null)
                    FirstAttack = skillResult.Time;

                LastAttack = skillResult.Time;
            }

            foreach (var playerStat in StatsByUser)
            {   //force update of calculated dps metrics
                playerStat.Dealt.UpdateStats();
            }
        }
コード例 #17
0
ファイル: DamageTracker.cs プロジェクト: hawkwork/CasualMeter
        public void Update(SkillResult skillResult)
        {
            if (IsArchived) return;//prevent archived trackers from accidentally recording stats

            if (skillResult.SourcePlayer != null)
            {
                var playerStats = GetOrCreate(skillResult.SourcePlayer);
                var statsChange = StatsChange(skillResult);
                playerStats.Dealt.Add(statsChange);
                playerStats.LogSkillUsage(skillResult);
                TotalDealt.Add(statsChange);
            }

            //don't care about damage received since it's useless
            //if (skillResult.TargetPlayer != null)
            //{
            //    var playerStats = GetOrCreate(skillResult.TargetPlayer);
            //    var statsChange = StatsChange(skillResult);
            //    playerStats.Received.Add(statsChange);
            //    TotalReceived.Add(statsChange);
            //}

            if (IsValidAttack(skillResult))
            {
                if (FirstAttack == null)
                    FirstAttack = skillResult.Time;

                LastAttack = skillResult.Time;
            }

            foreach (var playerStat in StatsByUser)
            {   //force update of calculated dps metrics
                playerStat.UpdateStats();
            }
        }
コード例 #18
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);
            _entityTracker.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;
            if (!DamageTracker.IsArchived && //don't process while viewing a past encounter
                skillResultMessage != null && !skillResultMessage.IsUseless &&//stuff like warrior DFA
                (DamageTracker.FirstAttack != null || (!skillResultMessage.IsHeal && skillResultMessage.Amount > 0)) &&//only record first hit is it's a damage hit (heals occurring outside of fights)
                !(skillResultMessage.Target.Equals(skillResultMessage.Source) && !skillResultMessage.IsHeal))//disregard damage dealt to self (gunner self destruct)
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                DamageTracker.Update(skillResult);
            }
        }
コード例 #19
0
ファイル: DamageTracker.cs プロジェクト: hawkwork/CasualMeter
        private SkillStats StatsChange(SkillResult message)
        {
            var result = new SkillStats();
            if (message.Amount == 0)
                return result;

            result.Damage = message.Damage;
            result.Heal = message.Heal;

            result.Hits++;
            if (message.IsCritical)
                result.Crits++;

            return result;
        }
コード例 #20
0
        private void HandleMessageReceived(Message obj)
        {
            var message = _messageFactory.Create(obj);
            _entityTracker.Update(message);

            var skillResultMessage = message as EachSkillResultServerMessage;
            if (skillResultMessage != null)
            {
                var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase);
                _damageTracker.Update(skillResult);
            }
        }
コード例 #21
0
 public bool IsFromHealer(SkillResult skillResult)
 {
     return(skillResult.SourcePlayer.IsHealer);
 }
コード例 #22
0
 public bool IsValidAttack(SkillResult skillResult)
 {
     return(skillResult.SourcePlayer != null && (skillResult.Damage > 0) &&
            (skillResult.Source.Id != skillResult.Target.Id));
 }
コード例 #23
0
ファイル: DamageTracker.cs プロジェクト: DzenDyn/CasualMeter
 public bool IsFromHealer(SkillResult skillResult)
 {
     return skillResult.SourcePlayer.IsHealer;
 }