Exemple #1
0
        public override void SpecialParse(FightData fightData, AgentData agentData, List <CombatItem> combatData)
        {
            ComputeFightTargets(agentData, combatData);
            // Find target
            Target target = Targets.Find(x => x.ID == (ushort)ParseEnum.TargetIDS.Deimos);

            if (target == null)
            {
                throw new InvalidOperationException("Main target of the fight not found");
            }
            // enter combat
            CombatItem enterCombat = combatData.FirstOrDefault(x => x.SrcInstid == target.InstID && x.IsStateChange == ParseEnum.StateChange.EnterCombat && x.SrcInstid == target.InstID && x.LogTime <= target.LastAwareLogTime && x.LogTime >= target.FirstAwareLogTime);

            if (enterCombat != null)
            {
                fightData.OverrideStart(enterCombat.LogTime);
            }
            // Remove deimos despawn events as they are useless and mess with combat replay
            combatData.RemoveAll(x => x.IsStateChange == ParseEnum.StateChange.Despawn && x.SrcAgent == target.Agent);
            // invul correction
            CombatItem invulApp = combatData.FirstOrDefault(x => x.DstInstid == target.InstID && x.IsBuff != 0 && x.BuffDmg == 0 && x.Value > 0 && x.SkillID == 762);

            if (invulApp != null)
            {
                invulApp.OverrideValue((int)(target.LastAwareLogTime - invulApp.LogTime));
            }
            // Deimos gadgets
            CombatItem      targetable   = combatData.LastOrDefault(x => x.IsStateChange == ParseEnum.StateChange.Targetable && x.LogTime > combatData.First().LogTime&& x.DstAgent > 0);
            HashSet <ulong> gadgetAgents = new HashSet <ulong>();
            long            firstAware   = AttackTargetSpecialParse(targetable, agentData, combatData, gadgetAgents);

            // legacy method
            if (firstAware == 0)
            {
                CombatItem armDeimosDamageEvent = combatData.FirstOrDefault(x => x.LogTime >= target.LastAwareLogTime && (x.SkillID == 37980 || x.SkillID == 37982 || x.SkillID == 38046) && x.SrcAgent != 0 && x.SrcInstid != 0);
                if (armDeimosDamageEvent != null)
                {
                    List <AgentItem> deimosGadgets = agentData.GetAgentByType(AgentItem.AgentType.Gadget).Where(x => x.Name.Contains("Deimos") && x.LastAwareLogTime > armDeimosDamageEvent.LogTime).ToList();
                    if (deimosGadgets.Count > 0)
                    {
                        firstAware   = deimosGadgets.Max(x => x.FirstAwareLogTime);
                        gadgetAgents = new HashSet <ulong>(deimosGadgets.Select(x => x.Agent));
                    }
                }
            }
            if (gadgetAgents.Count > 0)
            {
                _specialSplitLogTime = (firstAware >= target.LastAwareLogTime ? firstAware : target.LastAwareLogTime);
                SetUniqueID(target.AgentItem, gadgetAgents, agentData, combatData);
            }
            target.AgentItem.LastAwareLogTime = combatData.Last().LogTime;
        }
        public override void EIEvtcParse(FightData fightData, AgentData agentData, List <CombatItem> combatData, List <Player> playerList)
        {
            ComputeFightTargets(agentData, combatData);
            // Find target
            NPC target = Targets.Find(x => x.ID == (int)ParseEnum.TargetIDS.Deimos);

            if (target == null)
            {
                throw new InvalidOperationException("Deimos not found");
            }
            // Remove deimos despawn events as they are useless and mess with combat replay
            combatData.RemoveAll(x => x.IsStateChange == ParseEnum.StateChange.Despawn && x.SrcAgent == target.Agent);
            // invul correction
            CombatItem invulApp = combatData.FirstOrDefault(x => x.DstAgent == target.Agent && x.IsBuff != 0 && x.BuffDmg == 0 && x.Value > 0 && x.SkillID == 762 && x.IsStateChange == ParseEnum.StateChange.None);

            if (invulApp != null)
            {
                invulApp.OverrideValue((int)(target.LastAware - invulApp.Time));
            }
            // Deimos gadgets
            CombatItem targetable   = combatData.LastOrDefault(x => x.IsStateChange == ParseEnum.StateChange.Targetable && x.DstAgent > 0);
            var        gadgetAgents = new HashSet <ulong>();
            long       firstAware   = AttackTargetSpecialParse(targetable, agentData, combatData, gadgetAgents);

            // legacy method
            if (firstAware == 0)
            {
                CombatItem armDeimosDamageEvent = combatData.FirstOrDefault(x => x.Time >= target.LastAware && (x.SkillID == 37980 || x.SkillID == 37982 || x.SkillID == 38046) && x.SrcAgent != 0 && x.SrcInstid != 0);
                if (armDeimosDamageEvent != null)
                {
                    var deimosGadgets = agentData.GetAgentByType(AgentItem.AgentType.Gadget).Where(x => x.Name.Contains("Deimos") && x.LastAware > armDeimosDamageEvent.Time).ToList();
                    if (deimosGadgets.Count > 0)
                    {
                        firstAware   = deimosGadgets.Max(x => x.FirstAware);
                        gadgetAgents = new HashSet <ulong>(deimosGadgets.Select(x => x.Agent));
                    }
                }
            }
            if (gadgetAgents.Count > 0)
            {
                _specialSplit = (firstAware >= target.LastAware ? firstAware : target.LastAware);
                MergeWithGadgets(target.AgentItem, gadgetAgents, agentData, combatData);
            }
            target.AgentItem.OverrideAwareTimes(target.FirstAware, fightData.FightEnd);
            target.OverrideName("Deimos");
        }
        public override void SpecialParse(FightData fightData, AgentData agentData, List <CombatItem> combatData)
        {
            // Find target
            Target target = Targets.Find(x => x.ID == (ushort)ParseEnum.TargetIDS.Deimos);

            if (target == null)
            {
                throw new InvalidOperationException("Main target of the fight not found");
            }
            if (!target.Character.Contains("Deimos"))
            {
                target.OverrideName("Deimos");
            }
            // enter combat
            CombatItem enterCombat = combatData.FirstOrDefault(x => x.SrcInstid == target.InstID && x.IsStateChange == ParseEnum.StateChange.EnterCombat);

            if (enterCombat != null)
            {
                fightData.FightStart = enterCombat.Time;
            }
            // Remove deimos despawn events as they are useless and mess with combat replay
            combatData.RemoveAll(x => x.IsStateChange == ParseEnum.StateChange.Despawn && x.SrcInstid == target.InstID && x.Time <= target.LastAware && x.Time >= target.FirstAware);
            // Deimos gadgets
            List <AgentItem> deimosGadgets = agentData.GetAgentByType(AgentItem.AgentType.Gadget).Where(x => x.Name.Contains("Deimos") && x.LastAware > target.LastAware).ToList();
            CombatItem       invulApp      = combatData.FirstOrDefault(x => x.DstInstid == target.InstID && x.IsBuff != 0 && x.BuffDmg == 0 && x.Value > 0 && x.SkillID == 762);
            CombatItem       targetable    = combatData.LastOrDefault(x => x.IsStateChange == ParseEnum.StateChange.Targetable && x.Time > combatData.First().Time&& x.DstAgent > 0);

            if (invulApp != null && targetable != null)
            {
                HashSet <ulong> gadgetAgents = new HashSet <ulong>();
                long            firstAware   = targetable.Time;
                AgentItem       targetAgent  = agentData.GetAgentByInstID(targetable.SrcInstid, targetable.Time);
                if (targetAgent != GeneralHelper.UnknownAgent)
                {
                    try
                    {
                        string[] names = targetAgent.Name.Split('-');
                        if (ushort.TryParse(names[2], out ushort masterInstid))
                        {
                            CombatItem structDeimosDamageEvent = combatData.FirstOrDefault(x => x.Time >= firstAware && x.IFF == ParseEnum.IFF.Foe && x.DstInstid == masterInstid && x.IsStateChange == ParseEnum.StateChange.Normal && x.IsBuffRemove == ParseEnum.BuffRemove.None &&
                                                                                           ((x.IsBuff == 1 && x.BuffDmg >= 0 && x.Value == 0) ||
                                                                                            (x.IsBuff == 0 && x.Value >= 0)));
                            if (structDeimosDamageEvent != null)
                            {
                                gadgetAgents.Add(structDeimosDamageEvent.DstAgent);
                            }
                            CombatItem armDeimosDamageEvent = combatData.FirstOrDefault(x => x.Time >= firstAware && (x.SkillID == 37980 || x.SkillID == 37982 || x.SkillID == 38046) && x.SrcAgent != 0 && x.SrcInstid != 0);
                            if (armDeimosDamageEvent != null)
                            {
                                gadgetAgents.Add(armDeimosDamageEvent.SrcAgent);
                            }
                        }
                        ;
                    }
                    catch
                    {
                        // nothing to do
                    }
                }
                invulApp.OverrideValue((int)(firstAware - invulApp.Time));
                _specialSplit = (firstAware >= target.LastAware ? firstAware : target.LastAware);
                target.AgentItem.LastAware = combatData.Last().Time;
                SetUniqueID(target, gadgetAgents, agentData, combatData);
            }
            // legacy method
            else if (deimosGadgets.Count > 0)
            {
                long firstAware = deimosGadgets.Max(x => x.FirstAware);
                _specialSplit = (firstAware >= target.LastAware ? firstAware : target.LastAware);
                target.AgentItem.LastAware = deimosGadgets.Max(x => x.LastAware);
                HashSet <ulong> gadgetAgents = new HashSet <ulong>(deimosGadgets.Select(x => x.Agent));
                SetUniqueID(target, gadgetAgents, agentData, combatData);
            }
        }