private void HandleNewConnection(Server server) { Text = $"Damage Meter connected to {server.Name}"; _server = server; _teraData = BasicTeraData.DataForRegion(server.Region); _entityRegistry = new EntityTracker(); _playerTracker = new PlayerTracker(_entityRegistry); _damageTracker = new DamageTracker(_entityRegistry, _playerTracker, _teraData.SkillDatabase); _messageFactory = new MessageFactory(_teraData.OpCodeNamer); }
void _teraSniffer_NewConnection(Server server) { InvokeAction(() => { var header = new LogHeader { Region = server.Region }; _logWriter = new PacketLogWriter(string.Format("{0}.TeraLog", DateTime.Now.ToString("yyyy-MM-dd HH-mm-ss", CultureInfo.InvariantCulture)), header); ConnectionList.Items.Clear(); ConnectionList.Items.Add(string.Format("New connection to {0}started...", server.Name)); _teraData = _basicTeraData.DataForRegion(server.Region); }); }
private void HandleNewConnection(Server server) { Server = server; _teraData = BasicTeraData.DataForRegion(server.Region); _entityTracker = new EntityTracker(_teraData.NpcDatabase); _playerTracker = new PlayerTracker(_entityTracker, BasicTeraData.Servers); _messageFactory = new MessageFactory(_teraData.OpCodeNamer); ResetDamageTracker(); DamageTracker = DamageTracker ?? new DamageTracker { OnlyBosses = OnlyBosses, IgnoreOneshots = IgnoreOneshots }; _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); _charmTracker = new CharmTracker(_abnormalityTracker); Logger.Info($"Connected to server {server.Name}."); }
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 void HandleMessageReceived(Message obj) { var message = _messageFactory.Create(obj); if (DamageTracker.IsArchived) { var npcOccupier = message as SNpcOccupierInfo; if (npcOccupier != null) { Entity ent = _entityTracker.GetOrPlaceholder(npcOccupier.NPC); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && npcOccupier.Target != EntityId.Empty) { CasualMessenger.Instance.ResetPlayerStats(true); //Stop viewing saved encounter on boss aggro } } return; } } _entityTracker?.Update(message); var skillResultMessage = message as EachSkillResultServerMessage; if (skillResultMessage != null) { if (skillResultMessage.IsValid(DamageTracker)) { var skillResult = new SkillResult(skillResultMessage, _entityTracker, _playerTracker, _teraData.SkillDatabase, null, _abnormalityTracker); CheckUpdate(skillResult); } return; } _playerTracker?.UpdateParty(message); _abnormalityTracker?.Update(message); var despawnNpc = message as SDespawnNpc; if (despawnNpc != null) { Entity ent = _entityTracker.GetOrPlaceholder(despawnNpc.Npc); if (ent is NpcEntity) { var npce = ent as NpcEntity; if (npce.Info.Boss && despawnNpc.Dead && !DamageTracker.IsArchived) { //no need to do something if we didn't count any skill against this boss if (DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Any(x => x.Target == npce)) { DamageTracker.PrimaryTarget = npce; //Name encounter with the last dead boss DamageTracker.IsPrimaryTargetDead = despawnNpc.Dead; //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData); } if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } } } return; } var spawnNpc = message as SpawnNpcServerMessage; if (spawnNpc != null) { if (spawnNpc.NpcArea == 950 && spawnNpc.NpcId == 9501) { var bosses = DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Select(x => x.Target).OfType <NpcEntity>().ToList(); var vergosPhase2Part1 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 1000); var vergosPhase2Part2 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 2000); //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase2Part1); } DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase2Part2); if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } if (spawnNpc.NpcArea == 950 && spawnNpc.NpcId == 9502) { var bosses = DamageTracker.StatsByUser.SelectMany(x => x.SkillLog).Select(x => x.Target).OfType <NpcEntity>().ToList(); var vergosPhase3 = bosses.FirstOrDefault(x => x.Info.HuntingZoneId == 950 && x.Info.TemplateId == 3000); //determine type ExportType exportType = ExportType.None; if (SettingsHelper.Instance.Settings.ExcelExport) { exportType = exportType | ExportType.Excel; } if (SettingsHelper.Instance.Settings.SiteExport) { exportType = exportType | ExportType.Upload; } if (exportType != ExportType.None) { DataExporter.ToTeraDpsApi(exportType, DamageTracker, _teraData, vergosPhase3); } if (AutosaveEncounters) { ResetDamageTracker(new ResetPlayerStatsMessage { ShouldSaveCurrent = true }); } } return; } var sLogin = message as LoginServerMessage; if (sLogin != null) { if (_needInit) { Server = BasicTeraData.Servers.GetServer(sLogin.ServerId, Server); _messageFactory.Region = Server.Region; Logger.Info($"Logged in to server {Server.Name}."); _teraData = BasicTeraData.DataForRegion(Server.Region); _entityTracker = new EntityTracker(_teraData.NpcDatabase, _userLogoTracker); _playerTracker = new PlayerTracker(_entityTracker, BasicTeraData.Servers); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); _entityTracker.Update(message); if (!DamageTracker.IsArchived) { DamageTracker.MeterPlayer = _playerTracker.Me(); } _needInit = false; } _abnormalityStorage.EndAll(message.Time.Ticks); _abnormalityTracker = new AbnormalityTracker(_entityTracker, _playerTracker, _teraData.HotDotDatabase, _abnormalityStorage, CheckUpdate); return; } 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 sGetUserList = message as S_GET_USER_LIST; if (sGetUserList != null) { _userLogoTracker.SetUserList(sGetUserList); return; } }