private void ResetDamageTracker(ResetPlayerStatsMessage message = null) { if (Server == null) { return; } var saveEncounter = message != null && message.ShouldSaveCurrent; if (saveEncounter && !DamageTracker.IsArchived && DamageTracker.StatsByUser.Count > 0 && DamageTracker.FirstAttack != null && DamageTracker.LastAttack != null) { DamageTracker.IsArchived = true; DamageTracker.Abnormals = _abnormalityStorage.Clone(); ArchivedDamageTrackers.Add(DamageTracker); return; } if (message != null && !message.ShouldSaveCurrent && DamageTracker.IsArchived) { ArchivedDamageTrackers.Remove(DamageTracker); } _abnormalityStorage.ClearEnded(); DamageTracker = new DamageTracker { OnlyBosses = OnlyBosses, IgnoreOneshots = IgnoreOneshots, Abnormals = _abnormalityStorage, MeterPlayer = _playerTracker?.Me() }; }
private void UpdateUi(int packetsWaiting = 0) { _lastTick = DateTime.UtcNow.Ticks; var handler = TickUpdated; var currentBoss = Encounter; var timedEncounter = TimedEncounter; var entities = Database.Database.Instance.AllEntity(); var filteredEntities = entities.Select(entityid => EntityTracker.GetOrNull(entityid)).OfType <NpcEntity>().Where(npc => npc.Info.Boss).ToList(); if (packetsWaiting > 1500 && filteredEntities.Count > 1) { Database.Database.Instance.DeleteAllWhenTimeBelow(Encounter); entities = Database.Database.Instance.AllEntity(); filteredEntities = entities.Select(entityid => EntityTracker.GetOrNull(entityid)).OfType <NpcEntity>().Where(npc => npc.Info.Boss).ToList(); } var entityInfo = Database.Database.Instance.GlobalInformationEntity(currentBoss, timedEncounter); Skills skills = null; if (SendFullDetails) { skills = Database.Database.Instance.GetSkills(entityInfo.BeginTime, entityInfo.EndTime); SendFullDetails = false; } var playersInfo = timedEncounter ? Database.Database.Instance.PlayerDamageInformation(entityInfo.BeginTime, entityInfo.EndTime) : Database.Database.Instance.PlayerDamageInformation(currentBoss); var heals = Database.Database.Instance.PlayerHealInformation(entityInfo.BeginTime, entityInfo.EndTime); var flash = FlashMessage; FlashMessage = null; var statsSummary = new StatsSummary(playersInfo, heals, entityInfo); var teradpsHistory = BossLink; var chatbox = Chat.Instance.Get(); var abnormals = _abnormalityStorage.Clone(currentBoss, entityInfo.BeginTime, entityInfo.EndTime); handler?.Invoke(statsSummary, skills, filteredEntities, timedEncounter, abnormals, teradpsHistory, chatbox, packetsWaiting, flash); }
private void UpdateUi() { _lastTick = DateTime.UtcNow.Ticks; var handler = TickUpdated; var currentBossFight = Encounter; var timedEncounter = TimedEncounter; var damage = DamageTracker.Instance.TotalDamage(currentBossFight, timedEncounter); var stats = DamageTracker.Instance.GetPlayerStats() .OrderByDescending(playerStats => playerStats.Dealt.Damage(currentBossFight, timedEncounter)) .ToList(); var firstHit = DamageTracker.Instance.FirstHit(currentBossFight); var lastHit = DamageTracker.Instance.LastHit(currentBossFight); var entities = DamageTracker.Instance.GetEntityStats(); var partyDps = DamageTracker.Instance.PartyDps(currentBossFight, timedEncounter); var teradpsHistory = BossLink.ToDictionary(x => x.Key, x => x.Value); var chatbox = Chat.Instance.Get(); var abnormals = _abnormalityStorage.Clone(currentBossFight?.NpcE); handler?.Invoke(firstHit, lastHit, damage, partyDps, entities, stats, currentBossFight, timedEncounter, abnormals, teradpsHistory, chatbox); }
private static ExtendedStats GenerateStats(NpcEntity entity, AbnormalityStorage abnormals) { if (!entity.Info.Boss) { return(null); } var timedEncounter = false; /* * modify timedEncounter depending on teradps.io need * */ var entityInfo = Database.Database.Instance.GlobalInformationEntity(entity, timedEncounter); var skills = Database.Database.Instance.GetSkills(entityInfo.BeginTime, entityInfo.EndTime); var playersInfo = timedEncounter ? Database.Database.Instance.PlayerDamageInformation(entityInfo.BeginTime, entityInfo.EndTime) : Database.Database.Instance.PlayerDamageInformation(entity); var heals = Database.Database.Instance.PlayerHealInformation(entityInfo.BeginTime, entityInfo.EndTime); playersInfo.RemoveAll(x => x.Amount == 0); var firstTick = entityInfo.BeginTime; var lastTick = entityInfo.EndTime; var interTick = lastTick - firstTick; var interval = interTick / TimeSpan.TicksPerSecond; if (interval == 0) { return(null); } var totaldamage = entityInfo.TotalDamage; var partyDps = TimeSpan.TicksPerSecond * totaldamage / interTick; var teradpsData = new EncounterBase(); var extendedStats = new ExtendedStats(); var _abnormals = abnormals.Clone(entity, firstTick, lastTick); extendedStats.Entity = entity; extendedStats.BaseStats = teradpsData; extendedStats.FirstTick = firstTick; extendedStats.LastTick = lastTick; teradpsData.areaId = entity.Info.HuntingZoneId + ""; teradpsData.bossId = entity.Info.TemplateId + ""; teradpsData.fightDuration = interval + ""; teradpsData.partyDps = partyDps + ""; extendedStats.Debuffs = _abnormals.Get(entity); foreach (var debuff in extendedStats.Debuffs) { var percentage = debuff.Value.Duration(firstTick, lastTick) * 100 / interTick; if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair <string, string>( debuff.Key.Id + "", percentage + "" )); } foreach (var user in playersInfo) { var teradpsUser = new Members(); var damage = user.Amount; teradpsUser.playerTotalDamage = damage + ""; if (damage <= 0) { continue; } var buffs = _abnormals.Get(user.Source); teradpsUser.playerClass = user.Source.Class.ToString(); teradpsUser.playerName = user.Source.Name; teradpsUser.playerServer = BasicTeraData.Instance.Servers.GetServerName(user.Source.ServerId); teradpsUser.playerAverageCritRate = Math.Round(user.CritRate, 1) + ""; teradpsUser.healCrit = user.Source.IsHealer ? heals.FirstOrDefault(x => x.Source == user.Source)?.CritRate + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond * damage / interTick + ""; teradpsUser.playerTotalDamagePercentage = user.Amount * 100 / entityInfo.TotalDamage + ""; extendedStats.PlayerReceived.Add(user.Source.Name, Tuple.Create(skills.HitsReceived(user.Source.User.Id, entity, timedEncounter), skills.DamageReceived(user.Source.User.Id, entity, timedEncounter))); var death = buffs.Death; teradpsUser.playerDeaths = death.Count(firstTick, lastTick) + ""; teradpsUser.playerDeathDuration = death.Duration(firstTick, lastTick) / TimeSpan.TicksPerSecond + ""; var aggro = buffs.Aggro(entity); teradpsUser.aggro = 100 * aggro.Duration(firstTick, lastTick) / interTick + ""; foreach (var buff in buffs.Times) { var percentage = buff.Value.Duration(firstTick, lastTick) * 100 / interTick; if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair <string, string>( buff.Key.Id + "", percentage + "" )); } var serverPlayerName = $"{teradpsUser.playerServer}_{teradpsUser.playerName}"; extendedStats.PlayerSkills.Add(serverPlayerName, skills.GetSkillsDealt(user.Source.User.Id, entity, timedEncounter)); extendedStats.PlayerBuffs.Add(serverPlayerName, buffs); var skillsId = SkillAggregate.GetAggregate(user, entityInfo.Entity, skills, timedEncounter, Database.Database.Type.Damage); extendedStats.PlayerSkillsAggregated[teradpsUser.playerServer + "/" + teradpsUser.playerName] = skillsId; foreach (var skill in skillsId) { var skillLog = new SkillLog(); var skilldamage = skill.Amount(); skillLog.skillAverageCrit = Math.Round(skill.AvgCrit()) + ""; skillLog.skillAverageWhite = Math.Round(skill.AvgWhite()) + ""; skillLog.skillCritRate = skill.CritRate() + ""; skillLog.skillDamagePercent = skill.DamagePercent() + ""; skillLog.skillHighestCrit = skill.BiggestCrit() + ""; skillLog.skillHits = skill.Hits() + ""; skillLog.skillId = skill.Skills.First().Key.Id + ""; skillLog.skillLowestCrit = skill.LowestCrit() + ""; skillLog.skillTotalDamage = skilldamage + ""; if (skilldamage == 0) { continue; } teradpsUser.skillLog.Add(skillLog); } teradpsData.members.Add(teradpsUser); } return(extendedStats); }
private static ExtendedStats GenerateStats(NpcEntity entity, AbnormalityStorage abnormals) { if (!entity.Info.Boss) { return(null); } var timedEncounter = false; /* * modify timedEncounter depending on teradps.io need * */ var entityInfo = Database.Database.Instance.GlobalInformationEntity(entity, timedEncounter); var skills = Database.Database.Instance.GetSkills(entityInfo.BeginTime, entityInfo.EndTime); var playersInfo = timedEncounter ? Database.Database.Instance.PlayerDamageInformation(entityInfo.BeginTime, entityInfo.EndTime) : Database.Database.Instance.PlayerDamageInformation(entity); var heals = Database.Database.Instance.PlayerHealInformation(entityInfo.BeginTime, entityInfo.EndTime); playersInfo.RemoveAll(x => x.Amount == 0); var firstTick = entityInfo.BeginTime; var lastTick = entityInfo.EndTime; var interTick = lastTick - firstTick; var interval = interTick / TimeSpan.TicksPerSecond; if (interval == 0) { return(null); } var totaldamage = entityInfo.TotalDamage; var partyDps = TimeSpan.TicksPerSecond * totaldamage / interTick; var teradpsData = new EncounterBase(); var extendedStats = new ExtendedStats(); var _abnormals = abnormals.Clone(entity, firstTick, lastTick); teradpsData.encounterUnixEpoch = new DateTimeOffset(new DateTime(lastTick, DateTimeKind.Utc)).ToUnixTimeSeconds(); extendedStats.Entity = entity; extendedStats.BaseStats = teradpsData; extendedStats.FirstTick = firstTick; extendedStats.LastTick = lastTick; teradpsData.areaId = entity.Info.HuntingZoneId + ""; teradpsData.bossId = entity.Info.TemplateId + ""; teradpsData.fightDuration = interval + ""; teradpsData.partyDps = partyDps + ""; extendedStats.Debuffs = _abnormals.Get(entity); foreach (var debuff in extendedStats.Debuffs.OrderByDescending(x => x.Value.Duration(firstTick, lastTick))) { var percentage = debuff.Value.Duration(firstTick, lastTick) * 100 / interTick; if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair <string, string>( debuff.Key.Id + "", percentage + "" )); var stacks = new List <List <int> > { new List <int> { 0, (int)percentage } }; var stackList = debuff.Value.Stacks(firstTick, lastTick).OrderBy(x => x); teradpsData.debuffDetail.Add(new List <object> { debuff.Key.Id, stacks }); if (stackList.Any() && stackList.Max() == 1) { continue; } foreach (var stack in stackList) { percentage = debuff.Value.Duration(firstTick, lastTick, stack) * 100 / interTick; if (percentage == 0) { continue; } stacks.Add(new List <int> { stack, (int)percentage }); } } foreach (var user in playersInfo.OrderByDescending(x => x.Amount)) { var teradpsUser = new Members(); var damage = user.Amount; teradpsUser.playerTotalDamage = damage + ""; if (damage <= 0) { continue; } var buffs = _abnormals.Get(user.Source); teradpsUser.guild = string.IsNullOrWhiteSpace(user.Source.GuildName) ? null : user.Source.GuildName; teradpsUser.playerClass = user.Source.Class.ToString(); teradpsUser.playerName = user.Source.Name; teradpsUser.playerId = user.Source.PlayerId; teradpsUser.playerServer = BasicTeraData.Instance.Servers.GetServerName(user.Source.ServerId); teradpsUser.playerAverageCritRate = Math.Round(user.CritRate, 1) + ""; teradpsUser.healCrit = user.Source.IsHealer ? heals.FirstOrDefault(x => x.Source == user.Source)?.CritRate + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond * damage / interTick + ""; teradpsUser.playerTotalDamagePercentage = user.Amount * 100 / entityInfo.TotalDamage + ""; extendedStats.PlayerReceived.Add(user.Source.Name, Tuple.Create(skills.HitsReceived(user.Source.User, entity, timedEncounter), skills.DamageReceived(user.Source.User, entity, timedEncounter))); extendedStats.PlayerCritDamageRate.Add(user.Source.Name, user.CritDamageRate); var death = buffs.Death; teradpsUser.playerDeaths = death.Count(firstTick, lastTick) + ""; teradpsUser.playerDeathDuration = death.Duration(firstTick, lastTick) / TimeSpan.TicksPerSecond + ""; var aggro = buffs.Aggro(entity); teradpsUser.aggro = 100 * aggro.Duration(firstTick, lastTick) / interTick + ""; foreach (var buff in buffs.Times.OrderByDescending(x => x.Value.Duration(firstTick, lastTick))) { var percentage = buff.Value.Duration(firstTick, lastTick) * 100 / interTick; if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair <string, string>( buff.Key.Id + "", percentage + "" )); var stacks = new List <List <int> > { new List <int> { 0, (int)percentage } }; var stackList = buff.Value.Stacks(firstTick, lastTick).OrderBy(x => x); teradpsUser.buffDetail.Add(new List <object> { buff.Key.Id, stacks }); if (stackList.Any() && stackList.Max() == 1) { continue; } foreach (var stack in buff.Value.Stacks(firstTick, lastTick).OrderBy(x => x)) { percentage = buff.Value.Duration(firstTick, lastTick, stack) * 100 / interTick; if (percentage == 0) { continue; } stacks.Add(new List <int> { stack, (int)percentage }); } } var serverPlayerName = $"{teradpsUser.playerServer}_{teradpsUser.playerName}"; extendedStats.PlayerSkills.Add(serverPlayerName, skills.GetSkillsDealt(user.Source.User, entity, timedEncounter)); extendedStats.PlayerBuffs.Add(serverPlayerName, buffs); var skillsId = SkillAggregate.GetAggregate(user, entityInfo.Entity, skills, timedEncounter, Database.Database.Type.Damage); extendedStats.PlayerSkillsAggregated[teradpsUser.playerServer + "/" + teradpsUser.playerName] = skillsId; foreach (var skill in skillsId.OrderByDescending(x => x.Amount())) { var skillLog = new SkillLog(); var skilldamage = skill.Amount(); skillLog.skillAverageCrit = Math.Round(skill.AvgCrit()) + ""; skillLog.skillAverageWhite = Math.Round(skill.AvgWhite()) + ""; skillLog.skillCritRate = skill.CritRate() + ""; skillLog.skillDamagePercent = skill.DamagePercent() + ""; skillLog.skillHighestCrit = skill.BiggestCrit() + ""; skillLog.skillHits = skill.Hits() + ""; var skillKey = skill.Skills.First().Key; skillLog.skillId = BasicTeraData.Instance.SkillDatabase.GetSkillByPetName(skillKey.NpcInfo?.Name, user.Source.RaceGenderClass)?.Id.ToString() ?? skillKey.Id.ToString(); skillLog.skillLowestCrit = skill.LowestCrit() + ""; skillLog.skillTotalDamage = skilldamage + ""; if (skilldamage == 0) { continue; } teradpsUser.skillLog.Add(skillLog); } if (NetworkController.Instance.MeterPlayers.Contains(user.Source)) { teradpsData.uploader = teradpsData.members.Count.ToString(); } teradpsData.members.Add(teradpsUser); } return(extendedStats); }
private void UpdateUi(int packetsWaiting = 0) { if (!NeedInit) { if (BasicTeraData.Instance.WindowData.EnableChat != MessageFactory.ChatEnabled) { MessageFactory.ChatEnabled = BasicTeraData.Instance.WindowData.EnableChat; if (BasicTeraData.Instance.WindowData.EnableChat) { AbnormalityTracker.AbnormalityAdded += NotifyProcessor.Instance.AbnormalityNotifierAdded; AbnormalityTracker.AbnormalityRemoved += NotifyProcessor.Instance.AbnormalityNotifierRemoved; } else { AbnormalityTracker.AbnormalityAdded -= NotifyProcessor.Instance.AbnormalityNotifierAdded; AbnormalityTracker.AbnormalityRemoved -= NotifyProcessor.Instance.AbnormalityNotifierRemoved; } PacketProcessing.Update(); } NotifyProcessor.Instance.AbnormalityNotifierMissing(); } _lastTick = DateTime.UtcNow.Ticks; var handler = TickUpdated; var currentBoss = Encounter; var timedEncounter = TimedEncounter; var entities = Database.Database.Instance.AllEntity(); var filteredEntities = entities.Select(entityid => EntityTracker.GetOrNull(entityid)).OfType <NpcEntity>().Where(npc => npc.Info.Boss).ToList(); if (packetsWaiting > 1500 && filteredEntities.Count > 1) { Database.Database.Instance.DeleteAllWhenTimeBelow(Encounter); entities = Database.Database.Instance.AllEntity(); filteredEntities = entities.Select(entityid => EntityTracker.GetOrNull(entityid)).OfType <NpcEntity>().Where(npc => npc.Info.Boss).ToList(); } var entityInfo = Database.Database.Instance.GlobalInformationEntity(currentBoss, timedEncounter); if (currentBoss != null) { long entityHP = 0; NotifyProcessor.Instance._lastBosses.TryGetValue(currentBoss.Id, out entityHP); var entityDamaged = currentBoss.Info.HP - entityHP; entityInfo.TimeLeft = entityDamaged == 0 ? 0 : entityInfo.Interval * entityHP / entityDamaged; } Skills skills = null; if (SendFullDetails) { skills = Database.Database.Instance.GetSkills(entityInfo.BeginTime, entityInfo.EndTime); SendFullDetails = false; } var playersInfo = timedEncounter ? Database.Database.Instance.PlayerDamageInformation(entityInfo.BeginTime, entityInfo.EndTime) : Database.Database.Instance.PlayerDamageInformation(currentBoss); if (BasicTeraData.Instance.WindowData.MeterUserOnTop) { playersInfo = playersInfo.OrderBy(x => MeterPlayers.Contains(x.Source) ? 0 : 1).ThenByDescending(x => x.Amount).ToList(); } var heals = Database.Database.Instance.PlayerHealInformation(entityInfo.BeginTime, entityInfo.EndTime); var flash = FlashMessage; FlashMessage = null; var statsSummary = new StatsSummary(playersInfo, heals, entityInfo); var teradpsHistory = BossLink; var chatbox = Chat.Instance.Get(); var abnormals = AbnormalityStorage.Clone(currentBoss, entityInfo.BeginTime, entityInfo.EndTime); handler?.Invoke(statsSummary, skills, filteredEntities, timedEncounter, abnormals, teradpsHistory, chatbox, packetsWaiting, flash); }
private static ExtendedStats GenerateStats(NpcEntity entity, AbnormalityStorage abnormals) { if (!entity.Info.Boss) return null; var timedEncounter = false; /* modify timedEncounter depending on teradps.io need */ var entityInfo = Database.Database.Instance.GlobalInformationEntity(entity, timedEncounter); var skills = Database.Database.Instance.GetSkills(entityInfo.BeginTime, entityInfo.EndTime); var playersInfo = timedEncounter ? Database.Database.Instance.PlayerDamageInformation(entityInfo.BeginTime, entityInfo.EndTime) : Database.Database.Instance.PlayerDamageInformation(entity); var heals = Database.Database.Instance.PlayerHealInformation(entityInfo.BeginTime, entityInfo.EndTime); playersInfo.RemoveAll(x => x.Amount == 0); var firstTick = entityInfo.BeginTime; var lastTick = entityInfo.EndTime; var interTick = lastTick - firstTick; var interval = interTick/TimeSpan.TicksPerSecond; if (interval == 0) { return null; } var totaldamage = entityInfo.TotalDamage; var partyDps = TimeSpan.TicksPerSecond*totaldamage/interTick; var teradpsData = new EncounterBase(); var extendedStats = new ExtendedStats(); var _abnormals = abnormals.Clone(entity, firstTick, lastTick); teradpsData.encounterUnixEpoch = new DateTimeOffset(new DateTime(lastTick,DateTimeKind.Utc)).ToUnixTimeSeconds(); extendedStats.Entity = entity; extendedStats.BaseStats = teradpsData; extendedStats.FirstTick = firstTick; extendedStats.LastTick = lastTick; teradpsData.areaId = entity.Info.HuntingZoneId + ""; teradpsData.bossId = entity.Info.TemplateId + ""; teradpsData.fightDuration = interval + ""; teradpsData.partyDps = partyDps + ""; extendedStats.Debuffs = _abnormals.Get(entity); foreach (var debuff in extendedStats.Debuffs.OrderByDescending(x => x.Value.Duration(firstTick, lastTick))) { var percentage = debuff.Value.Duration(firstTick, lastTick)*100/interTick; if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair<string, string>( debuff.Key.Id + "", percentage + "" )); } foreach (var user in playersInfo.OrderByDescending(x=>x.Amount)) { var teradpsUser = new Members(); var damage = user.Amount; teradpsUser.playerTotalDamage = damage + ""; if (damage <= 0) { continue; } var buffs = _abnormals.Get(user.Source); teradpsUser.playerClass = user.Source.Class.ToString(); teradpsUser.playerName = user.Source.Name; teradpsUser.playerServer = BasicTeraData.Instance.Servers.GetServerName(user.Source.ServerId); teradpsUser.playerAverageCritRate = Math.Round(user.CritRate, 1) + ""; teradpsUser.healCrit = user.Source.IsHealer ? heals.FirstOrDefault(x => x.Source == user.Source)?.CritRate + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond*damage/interTick + ""; teradpsUser.playerTotalDamagePercentage = user.Amount*100/entityInfo.TotalDamage + ""; extendedStats.PlayerReceived.Add(user.Source.Name, Tuple.Create(skills.HitsReceived(user.Source.User, entity, timedEncounter), skills.DamageReceived(user.Source.User, entity, timedEncounter))); var death = buffs.Death; teradpsUser.playerDeaths = death.Count(firstTick, lastTick) + ""; teradpsUser.playerDeathDuration = death.Duration(firstTick, lastTick)/TimeSpan.TicksPerSecond + ""; var aggro = buffs.Aggro(entity); teradpsUser.aggro = 100*aggro.Duration(firstTick, lastTick)/interTick + ""; foreach (var buff in buffs.Times.OrderByDescending(x=>x.Value.Duration(firstTick, lastTick))) { var percentage = buff.Value.Duration(firstTick, lastTick)*100/interTick; if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair<string, string>( buff.Key.Id + "", percentage + "" )); } var serverPlayerName = $"{teradpsUser.playerServer}_{teradpsUser.playerName}"; extendedStats.PlayerSkills.Add(serverPlayerName, skills.GetSkillsDealt(user.Source.User, entity, timedEncounter)); extendedStats.PlayerBuffs.Add(serverPlayerName, buffs); var skillsId = SkillAggregate.GetAggregate(user, entityInfo.Entity, skills, timedEncounter, Database.Database.Type.Damage); extendedStats.PlayerSkillsAggregated[teradpsUser.playerServer + "/" + teradpsUser.playerName] = skillsId; foreach (var skill in skillsId.OrderByDescending(x=>x.Amount())) { var skillLog = new SkillLog(); var skilldamage = skill.Amount(); skillLog.skillAverageCrit = Math.Round(skill.AvgCrit()) + ""; skillLog.skillAverageWhite = Math.Round(skill.AvgWhite()) + ""; skillLog.skillCritRate = skill.CritRate() + ""; skillLog.skillDamagePercent = skill.DamagePercent() + ""; skillLog.skillHighestCrit = skill.BiggestCrit() + ""; skillLog.skillHits = skill.Hits() + ""; var skillKey = skill.Skills.First().Key; skillLog.skillId= BasicTeraData.Instance.SkillDatabase.GetSkillByPetName(skillKey.NpcInfo?.Name, user.Source.RaceGenderClass)?.Id.ToString() ?? skillKey.Id.ToString(); skillLog.skillLowestCrit = skill.LowestCrit() + ""; skillLog.skillTotalDamage = skilldamage + ""; if (skilldamage == 0) { continue; } teradpsUser.skillLog.Add(skillLog); } teradpsData.members.Add(teradpsUser); } return extendedStats; }
private static ExtendedStats GenerateStats(SDespawnNpc despawnNpc, AbnormalityStorage abnormals) { if (!despawnNpc.Dead) { return(null); } var entity = DamageTracker.Instance.GetEntity(despawnNpc.Npc); if (!entity.IsBoss || !DamageTracker.Instance.EntitiesStats.ContainsKey(entity)) { return(null); } bool timedEncounter = false; //Nightmare desolarus if (entity.NpcE.Info.HuntingZoneId == 759 && entity.NpcE.Info.TemplateId == 1003) { timedEncounter = true; } var firstTick = DamageTracker.Instance.EntitiesStats[entity].FirstHit; var lastTick = DamageTracker.Instance.EntitiesStats[entity].LastHit; var interTick = lastTick - firstTick; var interval = interTick / TimeSpan.TicksPerSecond; if (interval == 0) { return(null); } var totaldamage = DamageTracker.Instance.TotalDamage(entity, timedEncounter); var partyDps = TimeSpan.TicksPerSecond * totaldamage / interTick; var teradpsData = new EncounterBase(); var extendedStats = new ExtendedStats(); var stats = DamageTracker.Instance.GetPlayerStats(); var _abnormals = abnormals.Clone(entity.NpcE, firstTick, lastTick); extendedStats.Entity = entity.NpcE; extendedStats.BaseStats = teradpsData; extendedStats.FirstTick = firstTick; extendedStats.LastTick = lastTick; teradpsData.areaId = entity.NpcE.Info.HuntingZoneId + ""; teradpsData.bossId = entity.NpcE.Info.TemplateId + ""; teradpsData.fightDuration = interval + ""; teradpsData.partyDps = partyDps + ""; extendedStats.Debuffs = _abnormals.Get(entity.NpcE); foreach (var debuff in extendedStats.Debuffs) { long percentage = (debuff.Value.Duration(firstTick, lastTick) * 100 / interTick); if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair <string, string>( debuff.Key.Id + "", percentage + "" )); } foreach (var user in stats) { var teradpsUser = new Members(); var damage = user.Dealt.Damage(entity, timedEncounter); teradpsUser.playerTotalDamage = damage + ""; if (damage <= 0) { continue; } var buffs = _abnormals.Get(user.Player); teradpsUser.playerClass = user.Class.ToString(); teradpsUser.playerName = user.Name; teradpsUser.playerServer = BasicTeraData.Instance.Servers.GetServerName(user.Player.ServerId); teradpsUser.playerAverageCritRate = user.Dealt.CritRate(entity, timedEncounter) + ""; teradpsUser.healCrit = user.IsHealer ? user.Dealt.CritRateHeal(entity, timedEncounter) + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond * damage / interTick + ""; teradpsUser.playerTotalDamagePercentage = user.Dealt.DamageFraction(entity, totaldamage, timedEncounter) + ""; var death = buffs.Death; teradpsUser.playerDeaths = death.Count(firstTick, lastTick) + ""; teradpsUser.playerDeathDuration = death.Duration(firstTick, lastTick) / TimeSpan.TicksPerSecond + ""; var aggro = buffs.Aggro(entity.NpcE); teradpsUser.aggro = 100 * aggro.Duration(firstTick, lastTick) / interTick + ""; foreach (var buff in buffs.Times) { long percentage = (buff.Value.Duration(firstTick, lastTick) * 100 / interTick); if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair <string, string>( buff.Key.Id + "", percentage + "" )); } var serverPlayerName = $"{teradpsUser.playerServer}_{teradpsUser.playerName}"; extendedStats.PlayerSkills.Add(serverPlayerName, timedEncounter ? user.Dealt.GetSkillsByTime(entity) : user.Dealt.GetSkills(entity)); extendedStats.PlayerBuffs.Add(serverPlayerName, buffs); var notimedskills = NoTimedSkills(extendedStats.PlayerSkills[serverPlayerName]); foreach (var skill in notimedskills) { var skillLog = new SkillLog(); var skilldamage = skill.Value.Damage; skillLog.skillAverageCrit = skill.Value.DmgAverageCrit + ""; skillLog.skillAverageWhite = skill.Value.DmgAverageHit + ""; skillLog.skillCritRate = skill.Value.CritRateDmg + ""; skillLog.skillDamagePercent = skill.Value.DamagePercentage(entity, timedEncounter) + ""; skillLog.skillHighestCrit = skill.Value.DmgBiggestCrit + ""; skillLog.skillHits = skill.Value.HitsDmg + ""; skillLog.skillId = BasicTeraData.Instance.SkillDatabase.GetSkillByPetName(skill.Key.NpcInfo?.Name, user.Player.RaceGenderClass)?.Id.ToString() ?? skill.Key.SkillId.ElementAt(0).ToString(); skillLog.skillLowestCrit = skill.Value.DmgLowestCrit + ""; skillLog.skillTotalDamage = skilldamage + ""; if (skilldamage == 0) { continue; } teradpsUser.skillLog.Add(skillLog); } teradpsData.members.Add(teradpsUser); } return(extendedStats); }