private void OnLogout(bool fake) { if (!fake) { PacketHandlers.Party.Clear(); SetTitleStr(""); Engine.MainWindow.UpdateTitle(); UOAssist.PostLogout(); m_ConnStart = DateTime.MinValue; } World.Player = null; World.Items.Clear(); World.Mobiles.Clear(); Macros.MacroManager.Stop(); ActionQueue.Stop(); Counter.Reset(); GoldPerHourTimer.Stop(); DamageTracker.Stop(); BandageTimer.Stop(); GateTimer.Stop(); BuffsTimer.Stop(); StealthSteps.Unhide(); Engine.MainWindow.OnLogout(); if (Engine.MainWindow.MapWindow != null) { Engine.MainWindow.MapWindow.Close(); } PacketHandlers.Party.Clear(); PacketHandlers.IgnoreGumps.Clear(); Config.Save(); //TranslateEnabled = false; }
private static void DamageTrackerReport(string[] param) { if (DamageTracker.Running) { DamageTracker.SendReport(); } }
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 }; }
void Attack() { if (lastAttackTime < 0 || Time.time - lastAttackTime > timeBetweenAttacks) { // TODO attack animation attackingCurrent.ApplyDamage(myDamage); lastAttackTime = Time.time; } attackingCurrent = null; }
public DamageTrackerFormatter(DamageTracker damageTracker, FormatHelpers formatHelpers) { var placeHolders = new List <KeyValuePair <string, object> >(); placeHolders.Add(new KeyValuePair <string, object>("Boss", damageTracker.Name ?? string.Empty)); placeHolders.Add(new KeyValuePair <string, object>("Time", formatHelpers.FormatTimeSpan(damageTracker.Duration))); Placeholders = placeHolders.ToDictionary(x => x.Key, y => y.Value); FormatProvider = formatHelpers.CultureInfo; }
void ConsiderTarget(Collider2D collision) { if (attackingCurrent == null) { if((whatIsDamagable.value & 1<<collision.gameObject.layer) == 1<<collision.gameObject.layer) { attackingCurrent = collision.gameObject.GetComponent<DamageTracker>(); if (attackingCurrent == null) { Debug.LogWarning("Attempted to target GameObject which does not have a DamageTracker"); } } } }
public override void OnResponse(int buttonId, int[] switches, GumpTextEntry[] textEntries = null) { if (buttonId == 1) { StringBuilder sb = new StringBuilder(); int x = 1; foreach (KeyValuePair<string, int> dmg in DamageTracker.GetTotalDamageList()) { sb.AppendLine($"{x}) {dmg.Key} [{dmg.Value:N2}]"); x++; } DamageTrackerListGump dmgList = new DamageTrackerListGump(sb.ToString()); dmgList.SendGump(); } base.OnResponse(buttonId, switches, textEntries); }
private void CheckUpdate(SkillResult skillResult) { if (PartyOnly &&//check if party only !(_playerTracker.MyParty(skillResult.SourcePlayer) || _playerTracker.MyParty(skillResult.TargetPlayer))) { return; } if (IsInactiveTimerReached() && skillResult.IsValid()) { CasualMessenger.Instance.ResetPlayerStats(AutosaveEncounters || DamageTracker.IsArchived); } if (!DamageTracker.IsArchived && skillResult.IsValid(DamageTracker?.FirstAttack)) //don't process while viewing a past encounter { DamageTracker.Update(skillResult); if (!skillResult.IsHeal && skillResult.Amount > 0) { _inactivityTimer.Restart(); } PlayerCount = DamageTracker.StatsByUser.Count; } }
private void CheckUpdate(SkillResult skillResult) { if (PartyOnly && !(_playerTracker.MyParty(skillResult.SourcePlayer) || _playerTracker.MyParty(skillResult.TargetPlayer))) { return; } if (SettingsHelper.Instance.Settings.InactivityResetDuration > 0 && _inactivityTimer.Elapsed > TimeSpan.FromSeconds(SettingsHelper.Instance.Settings.InactivityResetDuration) && skillResult.IsValid()) { CasualMessenger.Instance.ResetPlayerStats(AutosaveEncounters || DamageTracker.IsArchived); } if (!DamageTracker.IsArchived && skillResult.IsValid(DamageTracker?.FirstAttack)) //don't process while viewing a past encounter { DamageTracker.Update(skillResult); if (!skillResult.IsHeal && skillResult.Amount > 0) { _inactivityTimer.Restart(); } PlayerCount = DamageTracker.StatsByUser.Count; } }
private void LoadEncounter(DamageTracker obj) { DamageTracker = obj; }
public bool Load() { if (m_Name == null || m_Name.Trim() == "") { return(false); } string path = Config.GetUserDirectory("Profiles"); string file = Path.Combine(path, String.Format("{0}.xml", m_Name)); if (!File.Exists(file)) { return(false); } XmlDocument doc = new XmlDocument(); try { doc.Load(file); } catch { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file), "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } XmlElement root = doc["profile"]; if (root == null) { return(false); } Assembly exe = Assembly.GetCallingAssembly(); if (exe == null) { return(false); } foreach (XmlElement el in root.GetElementsByTagName("property")) { try { string name = el.GetAttribute("name"); string typeStr = el.GetAttribute("type"); string val = el.InnerText; if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange") { //m_Props[name] = null; if (m_Props.ContainsKey(name)) { m_Props.Remove(name); } } else { Type type = Type.GetType(typeStr); if (type == null) { type = exe.GetType(typeStr); } if (m_Props.ContainsKey(name) || name == "ForceSize") { if (type == null) { m_Props.Remove(name); } else { m_Props[name] = GetObjectFromString(val, type); } } } } catch (Exception e) { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()), "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Filter.Load(root["filters"]); Counter.LoadProfile(root["counters"]); Agent.LoadProfile(root["agents"]); DressList.Load(root["dresslists"]); TargetFilterManager.Load(root["targetfilters"]); SoundMusicManager.Load(root["soundfilters"]); FriendsManager.Load(root["friends"]); HotKey.Load(root["hotkeys"]); PasswordMemory.Load(root["passwords"]); OverheadMessages.Load(root["overheadmessages"]); ContainerLabels.Load(root["containerlabels"]); MacroVariables.Load(root["macrovariables"]); //imports previous absolutetargets and doubleclickvariables if present in profile if ((root.SelectSingleNode("absolutetargets") != null) || (root.SelectSingleNode("doubleclickvariables") != null)) { MacroVariables.Import(root); } ScriptVariables.Load(root["scriptvariables"]); GoldPerHourTimer.Stop(); DamageTracker.Stop(); if (m_Props.ContainsKey("ForceSize")) { try { int x, y; switch ((int)m_Props["ForceSize"]) { case 1: x = 960; y = 600; break; case 2: x = 1024; y = 768; break; case 3: x = 1152; y = 864; break; case 4: x = 1280; y = 720; break; case 5: x = 1280; y = 768; break; case 6: x = 1280; y = 800; break; case 7: x = 1280; y = 960; break; case 8: x = 1280; y = 1024; break; case 0: default: x = 800; y = 600; break; } SetProperty("ForceSizeX", x); SetProperty("ForceSizeY", y); if (x != 800 || y != 600) { SetProperty("ForceSizeEnabled", true); } m_Props.Remove("ForceSize"); } catch { } } //if ( !Language.Load( GetString( "Language" ) ) ) // MessageBox.Show( Engine.ActiveWindow, "Warning: Could not load language from profile, using current language instead.", "Language Error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return(true); }
public static void ToTeraDpsApi(ExportType exportType, DamageTracker damageTracker, TeraData teraData) { if (exportType == ExportType.None) { return; } //if we want to upload, primary target must be dead if (exportType.HasFlag(ExportType.Upload) && !damageTracker.IsPrimaryTargetDead) { return; } var exportToExcel = (exportType & (ExportType.Excel | ExportType.ExcelTemp)) != 0; //if we're not exporting to excel and credentials aren't fully entered, return //if (!exportToExcel // && (string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsToken) // || string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsUser))) // return; //ignore if not a boss var entity = damageTracker.PrimaryTarget; if (!(entity?.Info.Boss ?? false)) { return; } var abnormals = damageTracker.Abnormals; bool timedEncounter = false; //Nightmare desolarus if (entity.Info.HuntingZoneId == 759 && entity.Info.TemplateId == 1003) { timedEncounter = true; } var firstHit = damageTracker.StatsByUser.SelectMany(x => x.SkillLog).Where(x => x.Target == entity).Min(x => x.Time as DateTime?) ?? new DateTime(0); var lastHit = damageTracker.StatsByUser.SelectMany(x => x.SkillLog).Where(x => x.Target == entity).Max(x => x.Time as DateTime?) ?? new DateTime(0); var firstTick = firstHit.Ticks; var lastTick = lastHit.Ticks; var interval = lastTick - firstTick; var seconds = interval / TimeSpan.TicksPerSecond; if (seconds == 0) { return; } long totaldamage; if (timedEncounter) { totaldamage = damageTracker.StatsByUser.SelectMany(x => x.SkillLog) .Where(x => x.Time >= firstHit && x.Time <= lastHit) .Sum(x => (long)x.Damage); } else { totaldamage = damageTracker.StatsByUser.SelectMany(x => x.SkillLog) .Where(x => x.Target == entity) .Sum(x => (long)x.Damage); } var partyDps = TimeSpan.TicksPerSecond * totaldamage / interval; var teradpsData = new EncounterBase { encounterUnixEpoch = DateTimeTools.DateTimeToUnixTimestamp(damageTracker.LastAttack?.ToUniversalTime() ?? DateTime.UtcNow), areaId = entity.Info.HuntingZoneId + "", bossId = entity.Info.TemplateId + "", fightDuration = seconds + "", partyDps = partyDps + "" }; foreach (var debuff in abnormals.Get(entity).OrderByDescending(x => x.Value.Duration(firstTick, lastTick))) { long percentage = debuff.Value.Duration(firstTick, lastTick) * 100 / interval; if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair <string, string>( debuff.Key.Id + "", percentage + "" )); } foreach (var user in damageTracker.StatsByUser.OrderByDescending(x => x.Dealt.Damage)) { var filteredSkillog = timedEncounter ? user.SkillLog.Where(x => x.Time >= firstHit && x.Time <= lastHit).ToList() : user.SkillLog.Where(x => x.Target == entity).ToList(); long damage = filteredSkillog.Sum(x => x.Damage); if (damage <= 0) { continue; } var teradpsUser = new Members(); teradpsUser.playerTotalDamage = damage + ""; var buffs = abnormals.Get(user.Player); teradpsUser.playerClass = user.Class.ToString(); teradpsUser.playerName = user.Name; teradpsUser.playerServer = SettingsHelper.Instance.BasicTeraData.Servers.GetServerName(user.Player.ServerId); teradpsUser.playerAverageCritRate = Math.Round(100 * (double)filteredSkillog.Count(x => x.IsCritical && x.Damage > 0) / filteredSkillog.Count(x => x.Damage > 0)) + ""; teradpsUser.healCrit = user.Player.IsHealer ? Math.Round(100 * (double)filteredSkillog.Count(x => x.IsCritical && x.Heal > 0) / filteredSkillog.Count(x => x.Heal > 0)) + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond * damage / interval + ""; teradpsUser.playerTotalDamagePercentage = damage * 100 / totaldamage + ""; 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) / interval + ""; foreach (var buff in buffs.Times.OrderByDescending(x => x.Value.Duration(firstTick, lastTick))) { long percentage = (buff.Value.Duration(firstTick, lastTick) * 100 / interval); if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair <string, string>( buff.Key.Id + "", percentage + "" )); } var aggregated = new List <AggregatedSkillResult>(); var collection = new SynchronizedObservableCollection <SkillResult>(); foreach (var skill in filteredSkillog) { collection.Add(skill); if (aggregated.All(asr => !skill.IsSameSkillAs(asr))) { aggregated.Add(new AggregatedSkillResult(skill.SkillShortName, skill.IsHeal, AggregationType.Name, collection)); } } foreach (var skill in aggregated.OrderByDescending(x => x.Damage)) { var skillLog = new SkillLog(); var skilldamage = skill.Damage; if (skilldamage == 0) { continue; } skillLog.skillAverageCrit = skill.AverageCrit + ""; skillLog.skillAverageWhite = skill.AverageWhite + ""; skillLog.skillCritRate = Math.Round(skill.CritRate * 100) + ""; skillLog.skillDamagePercent = Math.Round(skill.DamagePercent * 100) + ""; skillLog.skillHighestCrit = skill.HighestCrit + ""; skillLog.skillHits = skill.Hits + ""; skillLog.skillId = teraData.SkillDatabase.GetSkillByPetName(skill.NpcInfo?.Name, user.Player.RaceGenderClass)?.Id.ToString() ?? skill.SkillId.ToString(); skillLog.skillLowestCrit = skill.LowestCrit + ""; skillLog.skillTotalDamage = skilldamage + ""; teradpsUser.skillLog.Add(skillLog); } teradpsData.members.Add(teradpsUser); } //export to excel if specified if (exportToExcel) { Task.Run(() => ExcelExport.ExcelSave(exportType, teradpsData, teraData)); } //return if we don't need to upload if (!exportType.HasFlag(ExportType.Upload)) { return; } /* * Validation, without that, the server cpu will be burning \o */ var areaId = int.Parse(teradpsData.areaId); if ( //areaId != 886 && //areaId != 467 && //areaId != 767 && //areaId != 768 && //areaId != 468 && areaId != 770 && areaId != 769 && areaId != 916 && areaId != 969 && areaId != 970 && areaId != 950 ) { return; } try { using (var client = new HttpClient()) { client.Timeout = TimeSpan.FromSeconds(40); var response = client.GetAsync("http://moongourd.com/shared/servertime"); var timediff = (response.Result.Headers.Date.Value.UtcDateTime.Ticks - DateTime.UtcNow.Ticks) / TimeSpan.TicksPerSecond; teradpsData.encounterUnixEpoch += timediff; } } catch (Exception) { Debug.WriteLine("Get server time error"); return; } var json = JsonConvert.SerializeObject(teradpsData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); Task.Run(() => Send(entity, json, 3)); }
public static void ToTeraDpsApi(SDespawnNpc despawnNpc, DamageTracker damageTracker, EntityTracker entityTracker, TeraData teraData) { if (!despawnNpc.Dead) { return; } var entity = entityTracker.GetOrPlaceholder(despawnNpc.Npc) as NpcEntity; if (!(entity?.Info.Boss ?? false)) { return; } if (!SettingsHelper.Instance.Settings.ExcelExport && (string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsToken) || string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsUser) || !SettingsHelper.Instance.Settings.SiteExport) ) { return; } var abnormals = damageTracker.Abnormals; bool timedEncounter = false; //Nightmare desolarus if (entity.Info.HuntingZoneId == 759 && entity.Info.TemplateId == 1003) { timedEncounter = true; } var firstHit = damageTracker.StatsByUser.SelectMany(x => x.SkillLog).Where(x => x.Target == entity).Min(x => x.Time as DateTime?) ?? new DateTime(0); var lastHit = damageTracker.StatsByUser.SelectMany(x => x.SkillLog).Where(x => x.Target == entity).Max(x => x.Time as DateTime?) ?? new DateTime(0); var firstTick = firstHit.Ticks; var lastTick = lastHit.Ticks; var interval = lastTick - firstTick; var seconds = interval / TimeSpan.TicksPerSecond; if (seconds == 0) { return; } long totaldamage; if (timedEncounter) { totaldamage = damageTracker.StatsByUser.SelectMany(x => x.SkillLog) .Where(x => x.Time >= firstHit && x.Time <= lastHit) .Sum(x => x.Damage); } else { totaldamage = damageTracker.StatsByUser.SelectMany(x => x.SkillLog) .Where(x => x.Target == entity) .Sum(x => x.Damage); } var partyDps = TimeSpan.TicksPerSecond * totaldamage / interval; var teradpsData = new EncounterBase { areaId = entity.Info.HuntingZoneId + "", bossId = entity.Info.TemplateId + "", fightDuration = seconds + "", partyDps = partyDps + "" }; foreach (var debuff in abnormals.Get(entity)) { long percentage = debuff.Value.Duration(firstTick, lastTick) * 100 / interval; if (percentage == 0) { continue; } teradpsData.debuffUptime.Add(new KeyValuePair <string, string>( debuff.Key.Id + "", percentage + "" )); } foreach (var user in damageTracker.StatsByUser) { var filteredSkillog = timedEncounter ? user.SkillLog.Where(x => x.Time >= firstHit && x.Time <= lastHit).ToList() : user.SkillLog.Where(x => x.Target == entity).ToList(); long damage = filteredSkillog.Sum(x => x.Damage); if (damage <= 0) { continue; } var teradpsUser = new Members(); teradpsUser.playerTotalDamage = damage + ""; var buffs = abnormals.Get(user.Player); teradpsUser.playerClass = user.Class.ToString(); teradpsUser.playerName = user.Name; teradpsUser.playerServer = SettingsHelper.Instance.BasicTeraData.Servers.GetServerName(user.Player.ServerId); teradpsUser.playerAverageCritRate = Math.Round(100 * (double)filteredSkillog.Count(x => x.IsCritical && x.Damage > 0) / filteredSkillog.Count(x => x.Damage > 0), 1) + ""; teradpsUser.healCrit = user.Player.IsHealer ? Math.Round(100 * (double)filteredSkillog.Count(x => x.IsCritical && x.Heal > 0) / filteredSkillog.Count(x => x.Heal > 0), 1) + "" : null; teradpsUser.playerDps = TimeSpan.TicksPerSecond * damage / interval + ""; teradpsUser.playerTotalDamagePercentage = damage * 100 / totaldamage + ""; 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) / interval + ""; foreach (var buff in buffs.Times) { long percentage = (buff.Value.Duration(firstTick, lastTick) * 100 / interval); if (percentage == 0) { continue; } teradpsUser.buffUptime.Add(new KeyValuePair <string, string>( buff.Key.Id + "", percentage + "" )); } var aggregated = new List <AggregatedSkillResult>(); var collection = new ThreadSafeObservableCollection <SkillResult>(); foreach (var skill in filteredSkillog) { collection.Add(skill); if (aggregated.All(asr => !skill.IsSameSkillAs(asr))) { aggregated.Add(new AggregatedSkillResult(skill.SkillShortName, skill.IsHeal, AggregationType.Name, collection)); } } foreach (var skill in aggregated) { var skillLog = new SkillLog(); var skilldamage = skill.Damage; if (skilldamage == 0) { continue; } skillLog.skillAverageCrit = skill.AverageCrit + ""; skillLog.skillAverageWhite = skill.AverageWhite + ""; skillLog.skillCritRate = Math.Round(skill.CritRate * 100, 1) + ""; skillLog.skillDamagePercent = Math.Round(skill.DamagePercent * 100, 1) + ""; skillLog.skillHighestCrit = skill.HighestCrit + ""; skillLog.skillHits = skill.Hits + ""; skillLog.skillId = teraData.SkillDatabase.GetSkillByPetName(skill.NpcInfo?.Name, user.Player.RaceGenderClass)?.Id.ToString() ?? skill.SkillId.ToString(); skillLog.skillLowestCrit = skill.LowestCrit + ""; skillLog.skillTotalDamage = skilldamage + ""; teradpsUser.skillLog.Add(skillLog); } teradpsData.members.Add(teradpsUser); } if (SettingsHelper.Instance.Settings.ExcelExport) { Task.Run(() => ExcelExport.ExcelSave(teradpsData, teraData)); } if (string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsToken) || string.IsNullOrEmpty(SettingsHelper.Instance.Settings.TeraDpsUser) || !SettingsHelper.Instance.Settings.SiteExport) { return; } /* * Validation, without that, the server cpu will be burning \o */ var areaId = int.Parse(teradpsData.areaId); if ( areaId != 886 && areaId != 467 && areaId != 767 && areaId != 768 && areaId != 470 && areaId != 468 ) { return; } if (int.Parse(teradpsData.partyDps) < 2000000 && areaId != 468) { return; } string json = JsonConvert.SerializeObject(teradpsData, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); Task.Run(() => Send(entity, json, 3)); }
void Start() { damageTracker = gameObject.GetComponent<DamageTracker>(); }