示例#1
0
        public static void BeforeLogLineRead(bool isImport, Advanced_Combat_Tracker.LogLineEventArgs logInfo)
        {
            string l = logInfo.logLine;

            try
            {
                DateTime timestamp = ParseLogDateTime(l);

                char[]   dt       = { '\t' };
                string[] logParts = l.Split(dt);
                int      flag     = Convert.ToInt32(logParts[2], 16);
                if (flag > 7)
                {
                    return;
                }

                l = logParts[7];

                Match m;

                // open
                m = regex_open.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    encounter = target;
                    Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, encounter, encounter);
                    // DQX_ACT_Plugin.LogParserMessage("Open: "+target);
                    NameClass.Clear();
                    return;
                }

                // close
                m = regex_close.Match(l);
                if (m.Success)
                {
                    // Advanced_Combat_Tracker.ActGlobals.oFormActMain.ChangeZone("test");
                    Advanced_Combat_Tracker.ActGlobals.oFormActMain.EndCombat(true);
                    // DQX_ACT_Plugin.LogParserMessage("Close: ");
                    return;
                }

                // action
                if (!l.StartsWith(" →"))
                {
                    m = regex_action.Match(l);
                    if (m.Success)
                    {
                        actor  = m.Groups["actor"].Success ? DecodeString(m.Groups["actor"].Value) : "";
                        action = m.Groups["action"].Success ? DecodeString(m.Groups["action"].Value) : "";
                        if (!NameClass.ContainsKey(actor))
                        {
                            if (SkillClass.ContainsKey(action))
                            {
                                NameClass.Add(actor, SkillClass[action]);
                            }
                        }
                        return;
                    }
                    m = regex_action2.Match(l);
                    if (m.Success)
                    {
                        actor  = "不明";
                        action = m.Groups["action"].Success ? DecodeString(m.Groups["action"].Value) : "";
                        return;
                    }

                    // death
                    m = regex_dead2.Match(l);
                    if (m.Success)
                    {
                        string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            false,
                            "",
                            "不明",
                            "Death",
                            Advanced_Combat_Tracker.Dnum.Death,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                        return;
                    }
                    return;
                }

                if (!Advanced_Combat_Tracker.ActGlobals.oFormActMain.InCombat)
                {
                    return;
                }

                // crit
                m = regex_crit.Match(l);
                if (m.Success)
                {
                    isCritical = true;
                    return;
                }

                // damage
                m = regex_hit.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    // if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        MasterSwing ms = new MasterSwing(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            isCritical,
                            "",
                            new Advanced_Combat_Tracker.Dnum(int.Parse(m.Groups["damage"].Value, System.Globalization.NumberStyles.AllowThousands)),
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            action,
                            actor,
                            "",
                            target);

                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(ms);

                        var e = false;
                        foreach (var a in Allies)
                        {
                            if (a.Name == ms.Attacker)
                            {
                                e = true;
                                break;
                            }
                        }
                        if (ms.Attacker == encounter)
                        {
                            e = true;
                        }
                        if (!e)
                        {
                            CombatantData cd = ms.ParentEncounter.GetCombatant(ms.Attacker);
                            Allies.Add(cd);
                        }
                        ms.ParentEncounter.SetAllies(Allies);
                    }

                    isCritical = false;
                    return;
                }

                // miss
                m = regex_miss.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            isCritical,
                            "",
                            actor,
                            action,
                            Advanced_Combat_Tracker.Dnum.Miss,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                    }
                    isCritical = false;
                    return;
                }

                // heal
                m = regex_heal.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        MasterSwing ms = new MasterSwing(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            isCritical,
                            "",
                            new Advanced_Combat_Tracker.Dnum(int.Parse(m.Groups["damage"].Value, System.Globalization.NumberStyles.AllowThousands)),
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            action,
                            actor,
                            "",
                            target);

                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(ms);

                        var e = false;
                        foreach (var a in Allies)
                        {
                            if (a.Name == ms.Attacker)
                            {
                                e = true;
                                break;
                            }
                        }
                        if (ms.Attacker == encounter)
                        {
                            e = true;
                        }
                        if (!e)
                        {
                            CombatantData cd = ms.ParentEncounter.GetCombatant(ms.Attacker);
                            Allies.Add(cd);
                        }
                        ms.ParentEncounter.SetAllies(Allies);
                    }

                    isCritical = false;
                    return;
                }

                // death
                m = regex_dead.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            isCritical,
                            "",
                            actor,
                            "Death",
                            Advanced_Combat_Tracker.Dnum.Death,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                    }
                    isCritical = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                string exception = ex.ToString().Replace(Environment.NewLine, " ");
                if (ex.InnerException != null)
                {
                    exception += " " + ex.InnerException.ToString().Replace(Environment.NewLine, " ");
                }

                DQX_ACT_Plugin.LogParserMessage("Error [LogParse.BeforeLogLineRead] " + exception + " " + logInfo.logLine);
            }

            // For debugging
            // if (!string.IsNullOrWhiteSpace(l))
            //   DQX_ACT_Plugin.LogParserMessage("Unhandled Line: " + logInfo.logLine);
        }
示例#2
0
        public static void BeforeLogLineRead(bool isImport, Advanced_Combat_Tracker.LogLineEventArgs logInfo)
        {
            string logLine = logInfo.logLine;

            if (_ACT == null)
            {
                throw new ApplicationException("ACT Wrapper not initialized.");
            }

            try
            {
                // parse datetime
                DateTime timestamp   = ParseLogDateTime(logLine);
                int      chatLogType = 0;
                if (logLine.IndexOf('|') > 5)
                {
                    logLine = logLine.Substring(logLine.IndexOf('|') + 1);
                    if (logLine.IndexOf('|') > 0)
                    {
                        chatLogType = Convert.ToInt32(logLine.Substring(0, logLine.IndexOf('|')), 16);
                        logLine     = logLine.Substring(logLine.IndexOf('|') + 1);
                    }
                }
                else if (logLine.IndexOf(' ') > 5)
                {
                    logLine = logLine.Substring(logLine.IndexOf(' '));
                }

                // reformat logline
                logInfo.logLine = "[" + timestamp.ToString("HH:mm:ss.fff") + "] " + logLine;
                // timestamp = DateTime.ParseExact(logLine.Substring(1, logLine.IndexOf(']') - 1), "HH:mm:ss.fff", System.Globalization.CultureInfo.InvariantCulture);

                // Exclude certain chat codes
                if (chatLogType == 0x0c) // 0x0c = NPC talking, not parsed.
                {
                    return;
                }

                Match m;

                m = regex_yourdamage.Match(logLine);
                if (m.Success)
                {
                    string actor   = "You";
                    string target  = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    string damage  = (m.Groups["damage"].Value ?? "").Replace(",", "");
                    string hpdrain = (m.Groups["HPDrain"].Value ?? "").Replace(",", "");

                    if (_ACT.SetEncounter(timestamp, actor, target))
                    {
                        _ACT.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            m.Groups["critical"].Value == "critically hit",
                            "",
                            actor,
                            DecodeString(m.Groups["skill"].Value),
                            new Advanced_Combat_Tracker.Dnum(int.Parse(damage)),
                            timestamp,
                            _ACT.GlobalTimeSorter,
                            target,
                            "");

                        if (m.Groups["HPDrain"].Success)
                        {
                            _ACT.AddCombatAction(
                                (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                                false,
                                "Drain",
                                actor,
                                DecodeString(m.Groups["skill"].Value),
                                new Advanced_Combat_Tracker.Dnum(int.Parse(hpdrain)),
                                timestamp,
                                _ACT.GlobalTimeSorter,
                                actor,
                                "");
                        }
                    }

                    return;
                }

                m = regex_incomingdamage1.Match(logLine);
                if (!m.Success)
                {
                    m = regex_incomingdamage2.Match(logLine);
                }
                if (!m.Success)
                {
                    m = regex_incomingdamage3.Match(logLine);
                }
                if (m.Success)
                {
                    string target  = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    string actor   = m.Groups["actor"].Success ? DecodeString(m.Groups["actor"].Value) : "";
                    string skill   = m.Groups["skill"].Success ? DecodeString(m.Groups["skill"].Value) : "";
                    string damage  = (m.Groups["damage"].Value ?? "").Replace(",", "");
                    string hpdrain = (m.Groups["HPDrain"].Value ?? "").Replace(",", "");

                    // if skillname is blank, the skillname and actor may be transposed
                    if (string.IsNullOrWhiteSpace(skill))
                    {
                        if (!string.IsNullOrWhiteSpace(actor))
                        {
                            // "Received 1373 damage from Rising Blaze's ."
                            skill = actor;
                        }
                    }

                    if (string.IsNullOrWhiteSpace(target))
                    {
                        target = "You";
                    }

                    if (string.IsNullOrWhiteSpace(actor))
                    {
                        actor = "You";
                    }

                    // todo: in the future, if damage is missing, still parse the buff portion
                    if (!m.Groups["damage"].Success)
                    {
                        return;
                    }
                    if (_ACT.SetEncounter(timestamp, actor, target))
                    {
                        _ACT.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            m.Groups["critical"].Value == "Critical",
                            "",
                            actor,
                            skill,
                            new Advanced_Combat_Tracker.Dnum(int.Parse(damage)),
                            timestamp,
                            _ACT.GlobalTimeSorter,
                            target,
                            "");

                        if (m.Groups["HPDrain"].Success)
                        {
                            _ACT.AddCombatAction(
                                (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                                false,
                                "Drain",
                                actor,
                                skill,
                                new Advanced_Combat_Tracker.Dnum(int.Parse(hpdrain)),
                                timestamp,
                                _ACT.GlobalTimeSorter,
                                actor,
                                "");
                        }
                    }

                    return;
                }

                m = regex_heal.Match(logLine);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    if (string.IsNullOrWhiteSpace(target))
                    {
                        target = "You";
                    }
                    string actor = "Unknown";

                    // do not process if there is no HP amount.
                    if (!m.Groups["HPAmount"].Success)
                    {
                        return;
                    }

                    string hpamount = (m.Groups["HPAmount"].Value ?? "").Replace(",", "");

                    if (_ACT.SetEncounter(timestamp, actor, target))
                    {
                        _ACT.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            false,
                            "",
                            actor,
                            DecodeString(m.Groups["skill"].Value),
                            new Advanced_Combat_Tracker.Dnum(int.Parse(hpamount)),
                            timestamp,
                            _ACT.GlobalTimeSorter,
                            target,
                            "");
                    }
                    return;
                }


                m = regex_debuff2.Match(logLine);
                if (m.Success)
                {
                    // todo: add debuff support
                    return;
                }

                m = regex_debuff.Match(logLine);
                if (m.Success)
                {
                    // todo: add debuff support
                    return;
                }

                m = regex_buff.Match(logLine);
                if (m.Success)
                {
                    // todo: add buff support
                    return;
                }

                m = regex_evade.Match(logLine);
                if (m.Success)
                {
                    // todo: add evade support
                    return;
                }

                m = regex_defeat.Match(logLine);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    string actor  = m.Groups["actor"].Success ? DecodeString(m.Groups["actor"].Value) : "";
                    if (string.IsNullOrWhiteSpace(actor))
                    {
                        actor = "Unknown";
                    }

                    if (_ACT.SetEncounter(timestamp, actor, target))
                    {
                        _ACT.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            false,
                            "",
                            actor,
                            DecodeString(m.Groups["skill"].Value),
                            Advanced_Combat_Tracker.Dnum.Death,
                            timestamp,
                            _ACT.GlobalTimeSorter,
                            target,
                            "");
                    }

                    return;
                }
            }
            catch (Exception ex)
            {
                string exception = ex.ToString().Replace(Environment.NewLine, " ");
                if (ex.InnerException != null)
                {
                    exception += " " + ex.InnerException.ToString().Replace(Environment.NewLine, " ");
                }

                BNS_ACT_Plugin.LogParserMessage("Error [LogParse.BeforeLogLineRead] " + exception + " " + logInfo.logLine);
            }

            // For debugging
            if (!string.IsNullOrWhiteSpace(logLine))
            {
                BNS_ACT_Plugin.LogParserMessage("Unhandled Line: " + logInfo.logLine);
            }
        }