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; } } }
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); }
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; } } }
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++; } }
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); } }
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); }
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; } } }
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); }
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(); } }
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; }
public void LogSkillUsage(SkillResult result) { SkillLog.Add(result); }
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; } }
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; }
public bool IsValidAttack(SkillResult skillResult) { return skillResult.SourcePlayer != null && (skillResult.Damage > 0) && (skillResult.Source.Id != skillResult.Target.Id); }
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(); } }
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(); } }
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); } }
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; }
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); } }
public bool IsFromHealer(SkillResult skillResult) { return(skillResult.SourcePlayer.IsHealer); }
public bool IsValidAttack(SkillResult skillResult) { return(skillResult.SourcePlayer != null && (skillResult.Damage > 0) && (skillResult.Source.Id != skillResult.Target.Id)); }
public bool IsFromHealer(SkillResult skillResult) { return skillResult.SourcePlayer.IsHealer; }