private static void RegroupTargetsByID(int id, AgentData agentData, List <CombatItem> combatItems) { IReadOnlyList <AgentItem> agents = agentData.GetNPCsByID(id); if (agents.Count > 1) { AgentItem firstItem = agents.First(); var agentValues = new HashSet <ulong>(agents.Select(x => x.Agent)); var newTargetAgent = new AgentItem(firstItem); newTargetAgent.OverrideAwareTimes(agents.Min(x => x.FirstAware), agents.Max(x => x.LastAware)); agentData.SwapMasters(new HashSet <AgentItem>(agents), firstItem); agentData.OverrideID(id, newTargetAgent); foreach (CombatItem c in combatItems) { if (agentValues.Contains(c.SrcAgent) && c.IsStateChange.SrcIsAgent()) { c.OverrideSrcAgent(newTargetAgent.Agent); } if (agentValues.Contains(c.DstAgent) && c.IsStateChange.DstIsAgent()) { c.OverrideDstAgent(newTargetAgent.Agent); } } } }
private static void RegroupTargetsByID(int id, AgentData agentData, List <CombatItem> combatItems, IReadOnlyDictionary <uint, AbstractExtensionHandler> extensions) { IReadOnlyList <AgentItem> agents = agentData.GetNPCsByID(id); if (agents.Count > 1) { AgentItem firstItem = agents.First(); var agentValues = new HashSet <ulong>(agents.Select(x => x.Agent)); var newTargetAgent = new AgentItem(firstItem); newTargetAgent.OverrideAwareTimes(agents.Min(x => x.FirstAware), agents.Max(x => x.LastAware)); agentData.SwapMasters(new HashSet <AgentItem>(agents), newTargetAgent); agentData.ReplaceAgentsFromID(newTargetAgent); foreach (CombatItem c in combatItems) { if (agentValues.Contains(c.SrcAgent) && c.SrcIsAgent(extensions)) { c.OverrideSrcAgent(newTargetAgent.Agent); } if (agentValues.Contains(c.DstAgent) && c.DstIsAgent(extensions)) { c.OverrideDstAgent(newTargetAgent.Agent); } } } }
public override void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList) { // find target AgentItem target = agentData.GetNPCsByID((int)ParseEnum.TargetIDS.Xera).FirstOrDefault(); if (target == null) { throw new InvalidOperationException("Error Encountered: Xera not found"); } // find split foreach (AgentItem NPC in agentData.GetAgentByType(AgentItem.AgentType.NPC)) { if (NPC.ID == 16286) { CombatItem move = combatData.FirstOrDefault(x => x.IsStateChange == ParseEnum.StateChange.Position && x.SrcAgent == NPC.Agent && x.Time >= NPC.FirstAware + 500); if (move != null) { _specialSplit = move.Time; } else { _specialSplit = NPC.FirstAware; } target.OverrideAwareTimes(target.FirstAware, NPC.LastAware); agentData.SwapMasters(NPC, target); var agents = new HashSet <ulong>() { NPC.Agent, target.Agent }; // update combat data foreach (CombatItem c in combatData) { if (agents.Contains(c.SrcAgent) && c.IsStateChange.SrcIsAgent()) { c.OverrideSrcAgent(target.Agent); } if (agents.Contains(c.DstAgent) && c.IsStateChange.DstIsAgent()) { c.OverrideDstAgent(target.Agent); } } break; } } ComputeFightTargets(agentData, combatData); }
private void SolveWvWPlayers(AgentData agentData, List <CombatItem> combatData, List <AbstractSingleActor> friendlies, IReadOnlyDictionary <uint, AbstractExtensionHandler> extensions) { IReadOnlyList <AgentItem> aList = agentData.GetAgentByType(AgentItem.AgentType.NonSquadPlayer); var set = new HashSet <string>(); var toRemove = new HashSet <AgentItem>(); var garbageList = new List <AbstractSingleActor>(); var teamChangeDict = combatData.Where(x => x.IsStateChange == ArcDPSEnums.StateChange.TeamChange).GroupBy(x => x.SrcAgent).ToDictionary(x => x.Key, x => x.ToList()); // IReadOnlyList <AgentItem> squadPlayers = agentData.GetAgentByType(AgentItem.AgentType.Player); ulong greenTeam = ulong.MaxValue; var greenTeams = new List <ulong>(); foreach (AgentItem a in squadPlayers) { if (teamChangeDict.TryGetValue(a.Agent, out List <CombatItem> teamChangeList)) { greenTeams.AddRange(teamChangeList.Where(x => x.SrcMatchesAgent(a)).Select(x => x.DstAgent)); } } if (greenTeams.Any()) { greenTeam = greenTeams.GroupBy(x => x).OrderByDescending(x => x.Count()).Select(x => x.Key).First(); } var playersToMerge = new Dictionary <PlayerNonSquad, AbstractSingleActor>(); var agentsToPlayersToMerge = new Dictionary <ulong, PlayerNonSquad>(); // foreach (AgentItem a in aList) { if (teamChangeDict.TryGetValue(a.Agent, out List <CombatItem> teamChangeList)) { a.OverrideIsNotInSquadFriendlyPlayer(teamChangeList.Where(x => x.SrcMatchesAgent(a)).Select(x => x.DstAgent).Any(x => x == greenTeam)); } List <AbstractSingleActor> actorListToFill = a.IsNotInSquadFriendlyPlayer ? friendlies : _detailed ? _targets : garbageList; var nonSquadPlayer = new PlayerNonSquad(a); if (!set.Contains(nonSquadPlayer.Character)) { actorListToFill.Add(nonSquadPlayer); set.Add(nonSquadPlayer.Character); } else { // we merge AbstractSingleActor mainPlayer = actorListToFill.FirstOrDefault(x => x.Character == nonSquadPlayer.Character); playersToMerge[nonSquadPlayer] = mainPlayer; agentsToPlayersToMerge[nonSquadPlayer.AgentItem.Agent] = nonSquadPlayer; } } if (playersToMerge.Any()) { foreach (CombatItem c in combatData) { if (agentsToPlayersToMerge.TryGetValue(c.SrcAgent, out PlayerNonSquad nonSquadPlayer) && c.SrcMatchesAgent(nonSquadPlayer.AgentItem, extensions)) { AbstractSingleActor mainPlayer = playersToMerge[nonSquadPlayer]; c.OverrideSrcAgent(mainPlayer.AgentItem.Agent); } if (agentsToPlayersToMerge.TryGetValue(c.DstAgent, out nonSquadPlayer) && c.DstMatchesAgent(nonSquadPlayer.AgentItem, extensions)) { AbstractSingleActor mainPlayer = playersToMerge[nonSquadPlayer]; c.OverrideDstAgent(mainPlayer.AgentItem.Agent); } } foreach (KeyValuePair <PlayerNonSquad, AbstractSingleActor> pair in playersToMerge) { PlayerNonSquad nonSquadPlayer = pair.Key; AbstractSingleActor mainPlayer = pair.Value; agentData.SwapMasters(nonSquadPlayer.AgentItem, mainPlayer.AgentItem); mainPlayer.AgentItem.OverrideAwareTimes(Math.Min(nonSquadPlayer.FirstAware, mainPlayer.FirstAware), Math.Max(nonSquadPlayer.LastAware, mainPlayer.LastAware)); toRemove.Add(nonSquadPlayer.AgentItem); } } agentData.RemoveAllFrom(toRemove); }
private void CompletePlayers(ParserController operation) { //Fix Disconnected players IReadOnlyList <AgentItem> playerAgentList = _agentData.GetAgentByType(AgentItem.AgentType.Player); foreach (AgentItem playerAgent in playerAgentList) { if (playerAgent.InstID == 0 || playerAgent.FirstAware == 0 || playerAgent.LastAware == long.MaxValue) { operation.UpdateProgressWithCancellationCheck("Skipping invalid player " + playerAgent.Name); continue; } bool skip = false; var player = new Player(playerAgent, _fightData.Logic.Mode == FightLogic.ParseMode.Instanced5 || _fightData.Logic.Mode == FightLogic.ParseMode.sPvP); foreach (Player p in _playerList) { if (p.Account == player.Account) // same player { if (p.Character == player.Character) // same character, can be fused { skip = true; ulong agent = p.AgentItem.Agent; operation.UpdateProgressWithCancellationCheck("Merging player " + p.Character); foreach (CombatItem c in _combatItems) { if (c.DstMatchesAgent(player.AgentItem, _enabledExtensions)) { c.OverrideDstAgent(agent); } if (c.SrcMatchesAgent(player.AgentItem, _enabledExtensions)) { c.OverrideSrcAgent(agent); } } _agentData.SwapMasters(player.AgentItem, p.AgentItem); p.AgentItem.OverrideAwareTimes(Math.Min(p.AgentItem.FirstAware, player.AgentItem.FirstAware), Math.Max(p.AgentItem.LastAware, player.AgentItem.LastAware)); break; } } } if (!skip) { _playerList.Add(player); } } if (_parserSettings.AnonymousPlayer) { for (int i = 0; i < _playerList.Count; i++) { _playerList[i].Anonymize(i + 1); } } _playerList = _playerList.OrderBy(a => a.Group).ToList(); if (_playerList.Exists(x => x.Group == 0)) { _playerList.ForEach(x => x.MakeSquadless()); } uint minToughness = _playerList.Min(x => x.Toughness); if (minToughness > 0) { operation.UpdateProgressWithCancellationCheck("Adjusting player toughness scores"); uint maxToughness = _playerList.Max(x => x.Toughness); foreach (Player p in _playerList) { p.AgentItem.OverrideToughness((ushort)Math.Round(10.0 * (p.AgentItem.Toughness - minToughness) / Math.Max(1.0, maxToughness - minToughness))); } } }
private void CompletePlayers() { //Fix Disconnected players List <AgentItem> playerAgentList = _agentData.GetAgentByType(AgentItem.AgentType.Player); bool refresh = false; foreach (AgentItem playerAgent in playerAgentList) { if (playerAgent.InstID == 0 || playerAgent.FirstAware == 0 || playerAgent.LastAware == long.MaxValue) { CombatItem tst = _combatItems.Find(x => x.SrcAgent == playerAgent.Agent); if (tst == null) { tst = _combatItems.Find(x => x.DstAgent == playerAgent.Agent); if (tst == null) { continue; } playerAgent.SetInstid(tst.DstInstid); refresh = true; } else { playerAgent.SetInstid(tst.SrcInstid); refresh = true; } playerAgent.OverrideAwareTimes(_logStartTime, _logEndTime); } bool skip = false; var player = new Player(playerAgent, _fightData.Logic.Mode == FightLogic.ParseMode.Fractal, false); foreach (Player p in _playerList) { if (p.Account == player.Account) // same player { if (p.Character == player.Character) // same character, can be fused { skip = true; ulong agent = p.Agent; foreach (CombatItem c in _combatItems) { if (player.Agent == c.DstAgent && c.IsStateChange.DstIsAgent()) { c.OverrideDstAgent(agent); } if (player.Agent == c.SrcAgent && c.IsStateChange.SrcIsAgent()) { c.OverrideSrcAgent(agent); } } _agentData.SwapMasters(player.AgentItem, p.AgentItem); p.AgentItem.OverrideAwareTimes(Math.Min(p.AgentItem.FirstAware, player.AgentItem.FirstAware), Math.Max(p.AgentItem.LastAware, player.AgentItem.LastAware)); break; } // different character in raid mode, discard it as it can't have any influence, otherwise add as a separate entity else if (_fightData.Logic.Mode == FightLogic.ParseMode.Raid) { skip = true; break; } } } if (!skip) { _playerList.Add(player); } } if (_parserSettings.AnonymousPlayer) { for (int i = 0; i < _playerList.Count; i++) { _playerList[i].Anonymize(i + 1); } } _playerList = _playerList.OrderBy(a => a.Group).ToList(); if (refresh) { _agentData.Refresh(); } }
internal override void EIEvtcParse(ulong gw2Build, FightData fightData, AgentData agentData, List <CombatItem> combatData, List <AbstractSingleActor> friendlies, IReadOnlyDictionary <uint, AbstractExtensionHandler> extensions) { // find target AgentItem firstXera = agentData.GetNPCsByID((int)ArcDPSEnums.TargetID.Xera).FirstOrDefault(); if (firstXera == null) { throw new MissingKeyActorsException("Xera not found"); } _xeraFirstPhaseEndTime = firstXera.LastAware; // var maxHPUpdates = combatData.Where(x => x.IsStateChange == ArcDPSEnums.StateChange.MaxHealthUpdate && x.DstAgent > 0).ToList(); // var bloodstoneFragments = maxHPUpdates.Where(x => x.DstAgent == 104580).Select(x => agentData.GetAgent(x.SrcAgent, x.Time)).Where(x => x.Type == AgentItem.AgentType.Gadget).ToList(); foreach (AgentItem gadget in bloodstoneFragments) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.BloodstoneFragment); } // var bloodstoneShards = maxHPUpdates.Where(x => x.DstAgent == 343620).Select(x => agentData.GetAgent(x.SrcAgent, x.Time)).Where(x => x.Type == AgentItem.AgentType.Gadget).ToList(); foreach (AgentItem gadget in bloodstoneShards) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.BloodstoneShard); } // var chargedBloodStones = maxHPUpdates.Where(x => x.DstAgent == 74700).Select(x => agentData.GetAgent(x.SrcAgent, x.Time)).Where(x => x.Type == AgentItem.AgentType.Gadget && x.LastAware > firstXera.LastAware).ToList(); foreach (AgentItem gadget in chargedBloodStones) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.ChargedBloodstone); } if (bloodstoneFragments.Any() || bloodstoneShards.Any() || chargedBloodStones.Any()) { agentData.Refresh(); } // find split AgentItem secondXera = agentData.GetNPCsByID(16286).FirstOrDefault(); if (secondXera != null) { CombatItem move = combatData.FirstOrDefault(x => x.IsStateChange == ArcDPSEnums.StateChange.Position && x.SrcMatchesAgent(secondXera) && x.Time >= secondXera.FirstAware + 500); if (move != null) { _xeraSecondPhaseStartTime = move.Time; } else { _xeraSecondPhaseStartTime = secondXera.FirstAware; } firstXera.OverrideAwareTimes(firstXera.FirstAware, secondXera.LastAware); agentData.SwapMasters(secondXera, firstXera); // update combat data foreach (CombatItem c in combatData) { if (c.SrcMatchesAgent(secondXera, extensions)) { c.OverrideSrcAgent(firstXera.Agent); } if (c.DstMatchesAgent(secondXera, extensions)) { c.OverrideDstAgent(firstXera.Agent); } } } ComputeFightTargets(agentData, combatData, extensions); if (_xeraSecondPhaseStartTime > 0) { AbstractSingleActor mainTarget = GetMainTarget(); if (mainTarget == null) { throw new MissingKeyActorsException("Xera not found"); } mainTarget.SetManualHealth(24085950); } }
internal override void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList) { // find target AgentItem firstXera = agentData.GetNPCsByID((int)ArcDPSEnums.TargetID.Xera).FirstOrDefault(); if (firstXera == null) { throw new MissingKeyActorsException("Xera not found"); } var maxHPUpdates = combatData.Where(x => x.IsStateChange == ArcDPSEnums.StateChange.MaxHealthUpdate && x.DstAgent > 0).ToList(); var bloodstoneFragments = maxHPUpdates.Where(x => x.DstAgent == 104580).Select(x => agentData.GetAgent(x.SrcAgent)).Where(x => x.Type == AgentItem.AgentType.Gadget).ToList(); foreach (AgentItem gadget in bloodstoneFragments) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.BloodstoneFragment); } var bloodstoneShards = maxHPUpdates.Where(x => x.DstAgent == 343620).Select(x => agentData.GetAgent(x.SrcAgent)).Where(x => x.Type == AgentItem.AgentType.Gadget).ToList(); foreach (AgentItem gadget in bloodstoneShards) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.BloodstoneShard); } var chargedBloodStones = maxHPUpdates.Where(x => x.DstAgent == 74700).Select(x => agentData.GetAgent(x.SrcAgent)).Where(x => x.Type == AgentItem.AgentType.Gadget && x.LastAware > firstXera.LastAware).ToList(); foreach (AgentItem gadget in chargedBloodStones) { gadget.OverrideType(AgentItem.AgentType.NPC); gadget.OverrideID(ArcDPSEnums.TrashID.ChargedBloodstone); // they are actually present from start to finish gadget.OverrideAwareTimes(firstXera.LastAware + 15000, gadget.LastAware); } if (bloodstoneFragments.Any() || bloodstoneShards.Any() || chargedBloodStones.Any()) { agentData.Refresh(); } // find split AgentItem secondXera = agentData.GetNPCsByID(16286).FirstOrDefault(); if (secondXera != null) { CombatItem move = combatData.FirstOrDefault(x => x.IsStateChange == ArcDPSEnums.StateChange.Position && x.SrcAgent == secondXera.Agent && x.Time >= secondXera.FirstAware + 500); if (move != null) { _xeraSecondPhaseStartTime = move.Time; } else { _xeraSecondPhaseStartTime = secondXera.FirstAware; } firstXera.OverrideAwareTimes(firstXera.FirstAware, secondXera.LastAware); agentData.SwapMasters(secondXera, firstXera); // update combat data foreach (CombatItem c in combatData) { if (c.SrcAgent == secondXera.Agent && c.IsStateChange.SrcIsAgent()) { c.OverrideSrcAgent(firstXera.Agent); } if (c.DstAgent == secondXera.Agent && c.IsStateChange.DstIsAgent()) { c.OverrideDstAgent(firstXera.Agent); } } } ComputeFightTargets(agentData, combatData); }
internal override void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList) { AgentItem dummyAgent = agentData.AddCustomAgent(fightData.FightStart, fightData.FightEnd, AgentItem.AgentType.NPC, _detailed ? "Dummy WvW Agent" : "Enemy Players", "", (int)ArcDPSEnums.TargetID.WorldVersusWorld, true); ComputeFightTargets(agentData, combatData); IReadOnlyList <AgentItem> aList = agentData.GetAgentByType(AgentItem.AgentType.EnemyPlayer); if (_detailed) { var set = new HashSet <string>(); foreach (AgentItem a in aList) { var npc = new NPC(a); if (!set.Contains(npc.Character)) { _targets.Add(npc); set.Add(npc.Character); } else { // we merge NPC mainNPC = _targets.FirstOrDefault(x => x.Character == npc.Character); foreach (CombatItem c in combatData) { if (c.IsStateChange.SrcIsAgent() && c.SrcAgent == npc.Agent) { c.OverrideSrcAgent(mainNPC.Agent); } if (c.IsStateChange.DstIsAgent() && c.DstAgent == npc.Agent) { c.OverrideDstAgent(mainNPC.Agent); } } agentData.SwapMasters(npc.AgentItem, mainNPC.AgentItem); mainNPC.AgentItem.OverrideAwareTimes(Math.Min(npc.FirstAware, mainNPC.FirstAware), Math.Max(npc.LastAware, mainNPC.LastAware)); } } } else { var enemyPlayerDicts = aList.GroupBy(x => x.Agent).ToDictionary(x => x.Key, x => x.ToList().First()); foreach (CombatItem c in combatData) { if (c.IsStateChange == ArcDPSEnums.StateChange.None && c.IsActivation == ArcDPSEnums.Activation.None && c.IsBuffRemove == ArcDPSEnums.BuffRemove.None && ((c.IsBuff != 0 && c.Value == 0) || (c.IsBuff == 0))) { if (enemyPlayerDicts.TryGetValue(c.SrcAgent, out AgentItem src)) { c.OverrideSrcAgent(dummyAgent.Agent); } if (enemyPlayerDicts.TryGetValue(c.DstAgent, out AgentItem dst)) { c.OverrideDstAgent(dummyAgent.Agent); } } } } }