private long GetSpecialHitData(EncounterData Data, string specialName)
        {
            long total = 0;
            List<CombatantData> allys = Data.GetAllies();

            foreach (var ally in allys)
            {
                if (ally.Items.ContainsKey(OUT_DAMAGE) && ally.Items[OUT_DAMAGE].Items.ContainsKey(ALL))
                {
                    foreach (var swing in ally.Items[OUT_DAMAGE].Items[ALL].Items)
                    {
                        if (swing.Special.Contains(specialName))
                        {
                            total += swing.Damage;
                        }
                    }

                }
            }

            return total;
        }
        private void GenerateChatScript(EncounterData encounter, CultureInfo usCulture, Dictionary<string, Dictionary<string, string>> lines, SortedDictionary<string, string> displayOrder, SortedDictionary<string, string> displayOrderHealers, SortedDictionary<string, string> displayOrderTanks, bool isImport = false)
        {
            string scriptFolder = GetScriptFolder();
            if (Directory.Exists(scriptFolder))
            {
                const int NameLength = 7;
                StringBuilder line = new StringBuilder();
                StringBuilder lineSplit = new StringBuilder();
                bool exportColored = checkBox_ExportColored.Checked;
                string title = encounter.Title.Replace("\"", "&quot;");
                string combat_duration = encounter.Duration.TotalSeconds > 599 ? encounter.DurationS : encounter.DurationS.Substring(1, 4);
                string hitpoints = encounter.Damage.ToString("#,##0", usCulture);
                string hdrOutput = "";
                string hdrDamage = exportColored ? "<font face=LARGE_BOLD color=red>--- Damage</font><br>" : "--- Damage<br>";
                string hdrHeal = exportColored ? "<font face=LARGE_BOLD color=#25d425>--- Heal</font><br>" : "--- Heal<br>";
                string hdrTank = exportColored ? "<font face=LARGE_BOLD color=#09e4ea>--- Tank</font><br>" : "--- Tank<br>";
                string hdrMax = exportColored ? "<font face=LARGE_BOLD color=#be09cc>--- Max</font><br>" : "--- Max<br>";
                string lineReduced = "({0} more)<br>";
                List<String> lineDamage = new List<String>();
                List<String> lineHeal = new List<String>();
                List<String> lineTank = new List<String>();
                List<String> lineMax = new List<String>();

                // Gather data for damage, heal, tank and max
                long aegis_hp = GetSpecialHitData(encounter, SecretLanguage.Aegis);
                if (aegis_hp != 0)
                {
                    hitpoints += " [" + aegis_hp.ToString("#,##0", usCulture) + "]";
                }
                string heading = string.Format("total: {2} dmg, {0} dps in {1}", encounter.DPS.ToString("#,##0", usCulture), combat_duration, hitpoints);
                hdrOutput = string.Format("<a href=\"text://<div align=center><font face=HEADLINE color=red>{0}</font><br><font face=HUGE color=#FF6600>{1}</font></div><br><font face=LARGE>", title, heading);

                if (IsExportFieldSet("dps") || IsExportFieldSet("crit%") || IsExportFieldSet("pen%") || IsExportFieldSet("glance%") || IsExportFieldSet("block%") || IsExportFieldSet("evade%") || (IsExportFieldSet("aegismismatch%") && (aegis_hp != 0)))
                {
                    foreach (var name in displayOrder.Values)
                    {
                        Dictionary<string, string> entry = lines[name];
                        if ("0".Equals(entry["dmg"]))
                        {
                            continue;
                        }

                        string tempName = name;
                        if (checkBox_LimitNames.Checked)
                        {
                            if (name.Length > NameLength)
                            {
                                tempName = name.Substring(0, NameLength);
                            }
                        }

                        string combatant = string.Format("{0}", tempName);
                        combatant += AddChatScriptField(entry, "dps");
                        combatant += AddChatScriptField(entry, "pen%");
                        combatant += AddChatScriptField(entry, "crit%");
                        combatant += AddChatScriptField(entry, "glance%");
                        combatant += AddChatScriptField(entry, "block%");
                        combatant += AddChatScriptField(entry, "evade%");
                        if (aegis_hp != 0) combatant += AddChatScriptField(entry, "aegismismatch%");
                        lineDamage.Add(combatant + "<br>");
                    }
                }

                if (IsExportFieldSet("hps") || IsExportFieldSet("healcrit%"))
                {
                    foreach (var name in displayOrderHealers.Values)
                    {
                        Dictionary<string, string> entry = lines[name];
                        if ("0".Equals(entry["healing"]))
                        {
                            continue;
                        }

                        string tempName = name;
                        if (checkBox_LimitNames.Checked)
                        {
                            if (name.Length > NameLength)
                            {
                                tempName = name.Substring(0, NameLength);
                            }
                        }

                        string combatant = string.Format("{0}", tempName);
                        combatant += AddChatScriptField(entry, "hps");
                        combatant += AddChatScriptField(entry, "healcrit%");
                        lineHeal.Add(combatant + "<br>");
                    }
                }

                if (IsExportFieldSet("TakenDamage") || IsExportFieldSet("TakenCrit%") || IsExportFieldSet("TakenPen%") || IsExportFieldSet("TakenGlance%") || IsExportFieldSet("TakenBlock%") || IsExportFieldSet("TakenEvade%"))
                {
                    foreach (var name in displayOrderTanks.Values)
                    {
                        Dictionary<string, string> entry = lines[name];
                        if ("0".Equals(entry["takendamage"]))
                        {
                            continue;
                        }

                        string tempName = name;
                        if (checkBox_LimitNames.Checked)
                        {
                            if (name.Length > NameLength)
                            {
                                tempName = name.Substring(0, NameLength);
                            }
                        }

                        if (!isImport && entry.ContainsKey("death") && !"0".Equals(entry["death"]))
                        {
                            tempName += " †";
                        }

                        string combatant = string.Format("{0}", tempName);
                        combatant += AddChatScriptField(entry, "takendamage");
                        combatant += AddChatScriptField(entry, "takenpen%");
                        combatant += AddChatScriptField(entry, "takencrit%");
                        combatant += AddChatScriptField(entry, "takenglance%");
                        combatant += AddChatScriptField(entry, "takenblock%");
                        combatant += AddChatScriptField(entry, "takenevade%");
                        lineTank.Add(combatant + "<br>");
                    }
                }

                if (encounter.Damage > 0)
                {
                    string maxHit;
                    string maxHeal;
                    string maxDamage;

                    GetMaxText(encounter.GetAllies(), true, usCulture, out maxHit, out maxHeal, out maxDamage);
                    if (maxHit.Length > 0)
                    {
                        lineMax.Add(string.Format("Hit: {0}<br>", maxHit));
                    }

                    if (maxHeal.Length > 0)
                    {
                        lineMax.Add(string.Format("Heal: {0}<br>", maxHeal));
                    }

                    if (maxDamage.Length > 0)
                    {
                        lineMax.Add(string.Format("Incoming: {0}<br>", maxDamage));
                    }
                }

                string Expl = "";
                if (checkBox_ExportShowLegend.Checked)
                {
                    if (aegis_hp != 0) Expl = AddString(Expl, "[aegis]");
                    if (IsExportFieldSet("pen%") || IsExportFieldSet("takenpen%")) Expl = AddString(Expl, "p=pen");
                    if (IsExportFieldSet("crit%") || IsExportFieldSet("takencrit%") || IsExportFieldSet("healcrit%")) Expl = AddString(Expl, "c=crit");
                    if (IsExportFieldSet("glance%") || IsExportFieldSet("takenglance%")) Expl = AddString(Expl, "g=glance");
                    if (IsExportFieldSet("block%") || IsExportFieldSet("takenblock%")) Expl = AddString(Expl, "b=block");
                    if (IsExportFieldSet("evade%") || IsExportFieldSet("takenevade%")) Expl = AddString(Expl, "e=evade");
                    if (IsExportFieldSet("aegismismatch%") && (aegis_hp != 0)) Expl = AddString(Expl, "a=aegis mismatch");
                    Expl = "<br><font face=HUGE color=#828282>" + Expl + "</font>";
                }

                // Build page
                line.Append(hdrOutput);
                line.Append("<div>");
                if (lineDamage.Count > 0)
                {
                    line.Append(hdrDamage);
                    line.Append("{0}</div><br><div>");
                }
                if (lineHeal.Count > 0)
                {
                    line.Append(hdrHeal);
                    line.Append("{1}</div><br><div>");
                }
                if (lineTank.Count > 0)
                {
                    line.Append(hdrTank);
                    line.Append("{2}</div><br><div>");
                }
                AppendLineMax(lineMax, hdrMax, line);
                line.Append("</div>");
                line.Append("</font>");
                line.AppendFormat(Expl + "\">{0} - {1}</a>", title, heading);

                int DmgLen = GetTotalLength(lineDamage);
                int HealLen = GetTotalLength(lineHeal);
                int TankLen = GetTotalLength(lineTank);
                int MaxLen = GetTotalLength(lineMax);

                int limitDamage = DmgLen;
                int limitHeal = HealLen;
                int limitTank = TankLen;

                bool scriptToLong = line.Length + DmgLen + HealLen + TankLen > CHAT_LIMIT;

                if (scriptToLong)
                {
                    int countData = CHAT_LIMIT - line.Length;
                    float Ratio = (float)countData / (float)(DmgLen + HealLen + TankLen);

                    limitDamage = (int)Math.Round(DmgLen * Ratio);
                    limitHeal = (int)Math.Round(HealLen * Ratio);
                    limitTank = (int)Math.Round(TankLen * Ratio);
                }

                string outDamage = "";
                string outHeal = "";
                string outTank = "";

                for (var i = 0; i < lineDamage.Count; i++)
                {
                    if (outDamage.Length + lineDamage[i].Length <= limitDamage)
                    {
                        outDamage += lineDamage[i];
                    }
                    else
                    {
                        outDamage += string.Format(lineReduced, lineDamage.Count - i);
                        break;
                    }
                }

                for (var i = 0; i < lineHeal.Count; i++)
                {
                    if (outHeal.Length + lineHeal[i].Length <= limitHeal)
                    {
                        outHeal += lineHeal[i];
                    }
                    else
                    {
                        outHeal += string.Format(lineReduced, lineHeal.Count - i);
                        break;
                    }
                }

                for (var i = 0; i < lineTank.Count; i++)
                {
                    if (outTank.Length + lineTank[i].Length <= limitTank)
                    {
                        outTank += lineTank[i];
                    }
                    else
                    {
                        outTank += string.Format(lineReduced, lineTank.Count - i);
                        break;
                    }
                }

                string output = string.Format(line.ToString(), outDamage, outHeal, outTank);

                if (scriptToLong && checkBox_ExportSplit.Checked)
                {
                    // actchatsplit chat script
                    lineSplit.Append("<font color=red>[ ").Append(title).Append(" - ").Append(heading).Append(" ]</font>").AppendLine();

                    string linkStart = "<a href=\"text://<div align=center><font face=HEADLINE color=red>";
                    string linkCenter = "</font><br><font face=HUGE color=#FF6600>";
                    string linkEnd = "</font></div><br><font face=LARGE>";
                    string tagDivStart = "<div>";
                    string tagDivEnd = "</div><br>";
                    string tagFontEnd = "</font>";

                    string linkDamage = "\">Damage Report</a>";
                    string linkHeal = "\">Heal Report</a>";
                    string linkTank = "\">Tank Report</a>";

                    int scriptBaseLength = linkStart.Length + linkCenter.Length + linkEnd.Length + tagDivStart.Length + tagDivEnd.Length + tagFontEnd.Length + title.Length + heading.Length + Expl.Length + MaxLen + hdrMax.Length;
                    int scriptDamageLength = scriptBaseLength + hdrDamage.Length + linkDamage.Length;
                    int scriptHealLength = scriptBaseLength + hdrHeal.Length + linkHeal.Length;
                    int scriptTankLength = scriptBaseLength + hdrTank.Length + linkTank.Length;

                    // Damage Report
                    if (lineDamage.Count > 0)
                    {
                        lineSplit.Append(linkStart).Append(title).Append(linkCenter).Append(heading).Append(linkEnd);
                        lineSplit.Append(tagDivStart).Append(hdrDamage);
                        if (scriptDamageLength + DmgLen > CHAT_LIMIT)
                        {
                            AppendLinesReduced(lineDamage, lineSplit, CHAT_LIMIT - scriptDamageLength, lineReduced);
                        }
                        else
                        {
                            AppendLines(lineDamage, lineSplit);
                        }
                        lineSplit.Append(tagDivEnd);
                        AppendLineMax(lineMax, hdrMax, lineSplit);
                        lineSplit.Append(tagFontEnd).Append(Expl).Append(linkDamage).AppendLine();
                    }

                    // Heal Report
                    if (lineHeal.Count > 0)
                    {
                        lineSplit.Append(linkStart).Append(title).Append(linkCenter).Append(heading).Append(linkEnd);
                        lineSplit.Append(tagDivStart).Append(hdrHeal);
                        if (scriptHealLength + HealLen > CHAT_LIMIT)
                        {
                            AppendLinesReduced(lineHeal, lineSplit, CHAT_LIMIT - scriptHealLength, lineReduced);
                        }
                        else
                        {
                            AppendLines(lineHeal, lineSplit);
                        }
                        lineSplit.Append(tagDivEnd);
                        AppendLineMax(lineMax, hdrMax, lineSplit);
                        lineSplit.Append(tagFontEnd).Append(Expl).Append(linkHeal).AppendLine();
                    }

                    // Tank Report
                    if (lineTank.Count > 0)
                    {
                        lineSplit.Append(linkStart).Append(title).Append(linkCenter).Append(heading).Append(linkEnd);
                        lineSplit.Append(tagDivStart).Append(hdrTank);
                        if (scriptTankLength + TankLen > CHAT_LIMIT)
                        {
                            AppendLinesReduced(lineTank, lineSplit, CHAT_LIMIT - scriptTankLength, lineReduced);
                        }
                        else
                        {
                            AppendLines(lineTank, lineSplit);
                        }
                        lineSplit.Append(tagDivEnd);
                        AppendLineMax(lineMax, hdrMax, lineSplit);
                        lineSplit.Append(tagFontEnd).Append(Expl).Append(linkTank);
                    }
                }

                try
                {
                    using (TextWriter writer = new StreamWriter(Path.Combine(scriptFolder, "actchat"), false, Encoding.GetEncoding(1252)))
                    {
                        if (scriptToLong && checkBox_ExportSplit.Checked)
                        {
                            writer.WriteLine(lineSplit.ToString());
                        }
                        else
                        {
                            writer.WriteLine(output);
                        }
                    }
                    using (TextWriter writer = new StreamWriter(Path.Combine(scriptFolder, "acttell"), false, Encoding.GetEncoding(1252)))
                    {
                        writer.WriteLine(SecretLanguage.WhisperCmd + " %1 " + output);
                    }
                }
                catch (Exception)
                {
                    // Ignore errors writing the file.  Assume this is a security violation or such
                }
            }
        }
        private void GenerateHtmlScript(EncounterData encounter, CultureInfo usCulture, Dictionary<string, Dictionary<string, string>> lines, Dictionary<string, Dictionary<string, Dictionary<string, string>>> embedLines, SortedDictionary<string, string> displayOrder, SortedDictionary<string, SortedDictionary<string, string>> embedDisplayOrder)
        {
            string scriptFolder = GetScriptFolder();
            if (Directory.Exists(scriptFolder))
            {
                StringBuilder line = new StringBuilder(HTML_HEADER);
                for (int indx = 1; indx <= displayOrder.Count; ++indx)
                {
                    line.AppendLine("tr.embed" + indx.ToString() + " {background:#fff;}"
                                  + " tr.embed" + indx.ToString() + ":hover {background:#fef0f1;}");
                }

                string combat_duration = encounter.Duration.TotalSeconds > 599 ? encounter.DurationS : encounter.DurationS.Substring(1, 4);
                string hitpoints = encounter.Damage.ToString("#,##0", usCulture);
                long aegis_hp = GetSpecialHitData(encounter, SecretLanguage.Aegis);
                if (aegis_hp != 0)
                {
                    hitpoints += " [" + aegis_hp.ToString("#,##0", usCulture) + "]";
                }

                line.AppendFormat(HTML_TITLE, encounter.Title, encounter.DPS.ToString("#,##0", usCulture), combat_duration, hitpoints);

                // ---------- GROUP DAMAGE
                line.Append(HTML_TABLE_DAMAGE);
                int row = 0;
                int IsMultipleDeath = -1;
                foreach (var name in displayOrder.Values)
                {
                    string rowClass = (++row % 2 == 0) ? "odd" : "even";

                    Dictionary<string, string> entry = lines[name];
                    Dictionary<string, Dictionary<string, string>> embed;

                    if (embedLines.ContainsKey(name))
                    {
                        embed = embedLines[name];
                    }
                    else
                    {
                        embed = new Dictionary<string, Dictionary<string, string>>();
                    }

                    string nameStr = string.Format("{0}", name);

                    // a player were killed more than 1 in the report ? (-1:init / 0:no / 1: yes)
                    if (IsMultipleDeath == -1)
                    {
                        if (ALL.Equals(encounter.Title))
                        {
                            IsMultipleDeath = 1;
                        }
                        else
                        {
                            foreach (var death in entry["death"])
                            {
                                if ('0'.Equals(death) || '1'.Equals(death))
                                {
                                    continue;
                                }
                                else
                                {
                                    IsMultipleDeath = 1;
                                    break;
                                }
                            }
                            if (IsMultipleDeath == -1)
                            {
                                IsMultipleDeath = 0;
                            }
                        }
                    }
                    AppendHtmlLine(line, entry, rowClass, nameStr, false, row, IsMultipleDeath);

                    string embedRowClass = "embed" + row.ToString();
                    foreach (var embedName in embedDisplayOrder[name].Values)
                    {
                        Dictionary<string, string> embedEntry = embed[embedName];
                        string embedNameStr = embedEntry["name"];
                        AppendHtmlLine(line, embedEntry, embedRowClass, embedNameStr, true, row, 0);
                    }
                }

                // ---------- MY BUFFS
                line.Append(HTML_TABLE_BUFFS);
                if (encounter.Tags.ContainsKey(BUFFS))
                {
                    Dictionary<string, BuffData> buffs = encounter.Tags[BUFFS] as Dictionary<string, BuffData>;
                    if (buffs == null)
                    {
                        buffs = new Dictionary<string, BuffData>();
                    }

                    row = 0;
                    SortedSet<string> buffSort = new SortedSet<string>(buffs.Keys);
                    foreach (var name in buffSort)
                    {
                        var buff = buffs[name];
                        string rowClass = (++row % 2 == 0) ? "buffodd" : "buffeven";
                        double pct = buff.TotalTime * 100 / encounter.Duration.TotalMilliseconds;
                        line.AppendFormat("<tr class=\"{0}\"><td class=\"col1\"><strong>{1}</strong></td><td>{2}</td><td>{3}</td></tr>", rowClass, name, (buff.TotalTime / 1000).ToString("#,##0.0", usCulture), pct.ToString("0'%", usCulture));
                    }
                }

                // ---------- MAX HITS
                line.Append(HTML_TABLE_MAX);
                row = 0;
                foreach (var ally in encounter.GetAllies())
                {
                    var allyList = new List<CombatantData>();
                    allyList.Add(ally);

                    string maxHit;
                    string maxHeal;
                    string maxDamage;
                    GetMaxText(allyList, false, usCulture, out maxHit, out maxHeal, out maxDamage);

                    string rowClass = (++row % 2 == 0) ? "buffodd" : "buffeven";
                    line.AppendFormat("<tr class=\"{0}\"><td class=\"col1\"><strong>{1}</strong></td><td>{2}</td><td>{3}</td><td>{4}</td></tr>", rowClass, ally.Name, maxHit, maxHeal, maxDamage);
                }
                line.Append(HTML_CLOSE);

                try
                {
                    string newFile = Path.Combine(scriptFolder, "Z_act_new.html");
                    string oldFile = Path.Combine(scriptFolder, "Z_act.html");

                    using (TextWriter writer = new StreamWriter(newFile, false, Encoding.UTF8))
                    {
                        writer.WriteLine(line.ToString());
                    }

                    File.Delete(oldFile);
                    File.Move(newFile, oldFile);
                }
                catch (Exception)
                {
                    // Ignore errors writing the file.  Assume this is a security violation or such
                }

                try
                {
                    using (TextWriter writer = new StreamWriter(Path.Combine(scriptFolder, "act"), false))
                    {
                        string htmlScriptFolder = scriptFolder.Replace(Path.DirectorySeparatorChar, '/');
                        writer.WriteLine("/option WebBrowserStartURL \"file:///" + htmlScriptFolder + "/Z_act.html\"");
                        writer.WriteLine("/option web_browser 1");
                    }

                    string oldBuffFile = Path.Combine(scriptFolder, "Z_act_buffs.html");
                    if (File.Exists(oldBuffFile))
                    {
                        File.Delete(oldBuffFile);
                        File.Delete(Path.Combine(scriptFolder, "actbuffs"));
                    }
                }
                catch (Exception)
                {
                    // Ignore errors writing the file.  Assume this is a security violation or such
                }
            }
        }
        private void BuildScriptOutput(EncounterData encounter, CultureInfo usCulture, Dictionary<string, Dictionary<string, string>> lines, Dictionary<string, Dictionary<string, Dictionary<string, string>>> embedLines, SortedDictionary<string, string> displayOrder, SortedDictionary<string, SortedDictionary<string, string>> embedDisplayOrder, SortedDictionary<string, string> displayOrderHealers, SortedDictionary<string, string> displayOrderTanks)
        {
            HashSet<string> allies = new HashSet<string>();
            if (encounter.NumAllies > 0 && checkBox_ExportAllies.Checked)
            {
                foreach (var ally in encounter.GetAllies())
                {
                    allies.Add(ally.Name);
                }
            }
            bool round_dps = checkBox_ExportRoundDPS.Checked;
            foreach (var data in encounter.Items.Values)
            {
                try
                {
                    if (checkBox_Filter.Checked && checkBox_filterScript.Checked)
                    {
                        bool containsName = filterNames.Contains(data.Name);
                        if (checkBox_filterExclude.Checked)
                        {
                            if (containsName)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (!containsName)
                            {
                                continue;
                            }
                        }
                    }

                    if (allies.Count > 0 && !allies.Contains(data.Name))
                    {
                        continue;
                    }

                    Dictionary<string, string> row = new Dictionary<string, string>();
                    row["name"] = data.Name;
                    row["death"] = data.Deaths.ToString("#,##0", usCulture);
                    row["duration"] = data.Duration.TotalSeconds > 599 ? data.DurationS : data.DurationS.Substring(1, 4);

                    row["dmg"] = data.Damage.ToString("#,##0", usCulture);
                    row["healing"] = data.Healed.ToString("#,##0", usCulture);
                    row["dmg_script"] = ConvertValue(data.Damage, usCulture);
                    row["healing_script"] = ConvertValue(data.Healed, usCulture);

                    row["dps%"] = "--".Equals(data.DamagePercent) ? "n/a" : data.DamagePercent;
                    row["hps%"] = "--".Equals(data.HealedPercent) ? "n/a" : data.HealedPercent;

                    row["dps"] = "NaN".Equals(data.DPS) ? "0" : data.DPS.ToString(round_dps?GetIntCommas():GetFloatCommas(), usCulture);

                    row["crit%"] = "NaN".Equals(data.CritDamPerc) ? "0%" : data.CritDamPerc.ToString("0'%", usCulture);
                    row["healcrit%"] = "NaN".Equals(data.CritHealPerc) ? "0%" : data.CritHealPerc.ToString("0'%", usCulture);

                    row["pen%"] = CombatantFormatSwitch(data, "Penetration%", usCulture);
                    row["glance%"] = CombatantFormatSwitch(data, "Glance%", usCulture);
                    row["block%"] = CombatantFormatSwitch(data, "Blocked%", usCulture);

                    float miss = 100.0f - data.ToHit;
                    long aegis_dmg = GetSpecialHitData(data, SecretLanguage.Aegis);
                    long aegis_heal = GetSpecialHealData(data, SecretLanguage.Aegis);
                    double aegis_dps = (data.Duration.TotalSeconds > 0) ? aegis_dmg / data.Duration.TotalSeconds : 0.0;
                    double aegis_hps = 0.0;
                    row["evade%"] = miss.ToString("0'%", usCulture);
                    row["aegisdmg"] = aegis_dmg.ToString(GetIntCommas(), usCulture);
                    row["aegisdmg_script"] = (aegis_dmg != 0)? ConvertValue(aegis_dmg, usCulture) : "";
                    row["aegisdps"] = aegis_dps.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                    row["aegisheal"] = aegis_heal.ToString(GetIntCommas(), usCulture);
                    row["aegisheal_script"] = (aegis_heal != 0)? ConvertValue(aegis_heal, usCulture) : "";

                    row["aegismismatch%"] = CombatantFormatSwitch(data, "AegisMismatch%", usCulture);

                    if (data.Items.ContainsKey(OUT_HEAL))
                    {
                        row["healduration"] = data.Items[OUT_HEAL].Duration.TotalSeconds > 599 ? data.Items[OUT_HEAL].DurationS : data.Items[OUT_HEAL].DurationS.Substring(1, 4);
                        row["hps"] = "NaN".Equals(data.Items[OUT_HEAL].DPS) ? "0" : data.Items[OUT_HEAL].DPS.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                        aegis_hps = (data.Items[OUT_HEAL].Duration.TotalSeconds > 0) ? aegis_heal / data.Duration.TotalSeconds : 0.0;
                        row["aegishps"] = aegis_hps.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                    }
                    else
                    {
                        row["healduration"] = "0";
                        row["hps"] = "0";
                        row["aegishps"] = "0";
                    }

                    row["takendamage"] = ConvertValue(data.DamageTaken, usCulture);
                    long aegis_inc = GetSpecialIncData(data, SecretLanguage.Aegis);
                    row["aegisinc_script"] = (aegis_inc != 0) ? ConvertValue(aegis_inc, usCulture) : "";
                    row["takencrit%"] = CombatantFormatIncSwitch(data, "takencrit%", usCulture);
                    row["takenpen%"] = CombatantFormatIncSwitch(data, "takenpen%", usCulture);
                    row["takenglance%"] = CombatantFormatIncSwitch(data, "takenglance%", usCulture);
                    row["takenblock%"] = CombatantFormatIncSwitch(data, "takenblock%", usCulture);
                    row["takenevade%"] = CombatantFormatIncSwitch(data, "takenevade%", usCulture);
                    if (data.Items.ContainsKey(INC_DAMAGE))
                    {
                        double aegis_takendps = (data.Items[INC_DAMAGE].Duration.TotalSeconds > 0) ? aegis_inc / data.Items[INC_DAMAGE].Duration.TotalSeconds : 0.0;
                        row["takenduration"] = data.Items[INC_DAMAGE].Duration.TotalSeconds > 599 ? data.Items[INC_DAMAGE].DurationS : data.Items[INC_DAMAGE].DurationS.Substring(1, 4);
                        row["takendps"] = "NaN".Equals(data.Items[INC_DAMAGE].DPS) ? "0" : data.Items[INC_DAMAGE].DPS.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                        row["takenaegisdps"] = aegis_takendps.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                    }
                    else
                    {
                        row["takenduration"] = "0";
                        row["takendps"] = "0";
                        row["takenaegisdps"] = "0";
                    }

                    string name = row["name"];
                    lines.Add(name, row);
                    displayOrder.Add(GetScriptKey(data.Damage, data.Healed, name), name);
                    displayOrderHealers.Add(GetScriptKey(data.Healed, data.Damage, name), name);
                    displayOrderTanks.Add(GetScriptKey(data.DamageTaken, data.Damage, name), name);

                    var embed = new Dictionary<string, Dictionary<string, string>>();
                    foreach (var entry in data.Items[OUT_DAMAGE].Items)
                    {
                        var item = entry.Value;
                        if (ALL.Equals(entry.Key) || item.Damage < 1)
                        {
                            continue;
                        }

                        Dictionary<string, string> att = new Dictionary<string, string>();
                        att["name"] = entry.Key;
                        att["death"] = "0";
                        att["duration"] = "";
                        att["dmg"] = item.Damage.ToString("#,##0", usCulture);
                        att["dps%"] = (item.Damage * 100 / data.Damage).ToString("0'%", usCulture);
                        att["dps"] = "0";
                        att["pen%"] = GetSpecialHitPerc(item, SecretLanguage.Penetrated).ToString("0'%", usCulture);
                        att["crit%"] = item.CritPerc.ToString("0'%", usCulture);
                        att["glance%"] = GetSpecialHitPerc(item, SecretLanguage.Glancing).ToString("0'%", usCulture);
                        att["block%"] = GetSpecialHitPerc(item, SecretLanguage.Blocked).ToString("0'%", usCulture);
                        att["healing"] = "0";
                        att["hps%"] = "0%";
                        att["hps"] = "0";
                        att["healcrit%"] = "0%";

                        miss = 100.0f - data.ToHit;
                        aegis_dmg = GetSpecialHitData(item, SecretLanguage.Aegis);
                        aegis_dps = (item.Duration.TotalSeconds > 0) ? aegis_dmg / item.Duration.TotalSeconds : 0.0;
                        att["evade%"] = miss.ToString("0'%", usCulture);
                        att["aegisdmg"] = aegis_dmg.ToString(GetIntCommas(), usCulture);
                        att["aegisdps"] = aegis_dps.ToString(round_dps ? GetIntCommas() : GetFloatCommas(), usCulture);
                        att["aegisheal"] = "0";
                        att["aegishps"] = "0.0";
                        att["aegismismatch%"] = GetSpecialHitMissPerc(item, SecretLanguage.Aegis).ToString("0'%", usCulture);

                        att["takenduration"] = "0";
                        att["takendamage"] = "0";
                        att["takendps"] = "0";
                        att["takenaegisdps"] = "0";
                        att["aegisinc_script"] = "";
                        att["takencrit%"] = "0%";
                        att["takenpen%"] = "0%";
                        att["takenglance%"] = "0%";
                        att["takenblock%"] = "0%";
                        att["takenevade%"] = "0%";

                        att["dmgKey"] = GetScriptKey(item.Damage);
                        att["healKey"] = GetScriptKey(0);
                        embed[entry.Key] = att;
                    }

                    foreach (var entry in data.Items["Outgoing Heal (Out)"].Items)
                    {
                        var item = entry.Value;
                        if (ALL.Equals(entry.Key) || item.Damage < 1)
                        {
                            continue;
                        }

                        Dictionary<string, string> att;

                        if (embed.ContainsKey(entry.Key))
                        {
                            att = embed[entry.Key];
                        }
                        else
                        {
                            att = new Dictionary<string, string>();
                            att["name"] = entry.Key;
                            att["death"] = "0";
                            att["duration"] = "";
                            att["dmg"] = "0";
                            att["dps%"] = "0%";
                            att["dps"] = "0";
                            att["pen%"] = "0%";
                            att["crit%"] = "0%";
                            att["glance%"] = "0%";
                            att["block%"] = "0%";
                            att["evade%"] = "0";
                            att["aegisdmg"] = "0";
                            att["aegisdps"] = "0.0";
                            att["aegisheal"] = "0";
                            att["aegishps"] = "0.0";
                            att["aegismismatch%"] = "0%";

                            att["takenduration"] = "0";
                            att["takendamage"] = "0";
                            att["takendps"] = "0";
                            att["takenaegisdps"] = "0";
                            att["aegisinc_script"] = "";
                            att["takencrit%"] = "0%";
                            att["takenpen%"] = "0%";
                            att["takenglance%"] = "0%";
                            att["takenblock%"] = "0%";
                            att["takenevade%"] = "0%";
                            att["dmgKey"] = GetScriptKey(0);
                        }

                        aegis_heal = GetSpecialHitData(item, SecretLanguage.Aegis);
                        aegis_hps = (item.Duration.TotalSeconds > 0) ? aegis_heal / item.Duration.TotalSeconds : 0.0;
                        att["healing"] = item.Damage.ToString("#,##0", usCulture);
                        att["hps%"] = (item.Damage * 100 / data.Healed).ToString("0'%", usCulture);
                        att["hps"] = item.EncDPS.ToString(GetFloatCommas(), usCulture);
                        att["healcrit%"] = item.CritPerc.ToString("0'%", usCulture);
                        att["aegisheal"] = aegis_heal.ToString(GetIntCommas(), usCulture);
                        att["aegishps"] = aegis_hps.ToString(GetFloatCommas(), usCulture);

                        att["healKey"] = GetScriptKey(item.Damage);

                        embed[entry.Key] = att;
                    }

                    var embedOrder = new SortedDictionary<string, string>();
                    foreach (var item in embed.Values)
                    {
                        embedOrder[GetScriptKey(item["dmgKey"], item["healKey"], item["name"])] = item["name"];
                    }

                    embedDisplayOrder[name] = embedOrder;
                    embedLines[name] = embed;
                }
                catch (Exception)
                {
                    // Ignore errors writing this entry and continue
                }
            }
        }
Example #5
0
 void oFormActMain_OnCombatStart(bool isImport, CombatToggleEventArgs actionInfo)
 {
     if (ChromaReady == true && chk_enableEmnity.Checked && state != 3)
     {
         inCombat = true;
         ActiveEnconter = actionInfo.encounter;
         if (dpstickstart == true)
         {
             dpsloop.Stop();
             dpstickstart = false;
             dpsloop.Enabled = false;
         }
         if (state == 6)
         {
             skyWatcher.Enabled = false;
             updateState("transition", btn_emnityCol.BackColor, btn_defaultCol.BackColor, true);
             state = 6;
         }
         else if (state == 4)
         {
             updateState("transition", btn_emnityCol.BackColor, btn_defaultCol.BackColor, true);
             state = 4;
         }
         else
         {
             updateState("transition", btn_emnityCol.BackColor, btn_defaultCol.BackColor, true);
             state = 2;
         }
     }
 }
Example #6
0
        void oFormActMain_OnCombatEnd(bool isImport, CombatToggleEventArgs actionInfo)
        {
            inCombat = false;
            ActiveEnconter = null;
            if (dpstickstart == true)
            {
                dpsloop.Stop();
                dpstickstart = false;
                dpsloop.Enabled = false;
            }

            if (ChromaReady == true && chk_enableEmnity.Checked)
            {
                if (state == 6)
                {
                    setWeather(calculateWeather(currentZone));
                    skyWatcher.Enabled = true;
                    state = 6;
                }
                else if (state == 4)
                {
                    updateState("breath", btn_raidEffectsA.BackColor, btn_raidEffectsB.BackColor);
                    skyWatcher.Enabled = false;
                    state = 4;
                }
                else
                {
                    updateState("transition", btn_defaultCol.BackColor, btn_defaultCol.BackColor, true);
                    skyWatcher.Enabled = false;
                    state = 1;
                }
            }
        }
        // Needed to import this code to allow a setup from a blank state instead of the default state.
        // Blank state setup is the only way to enable the plugin when switching from some other plugin
        // that changed the default state.
        private string EncounterFormatSwitch(EncounterData Data, List<CombatantData> SelectiveAllies, string VarName, string Extra)
        {
            long damage = 0;
            long healed = 0;
            int swings = 0;
            int hits = 0;
            int crits = 0;
            int heals = 0;
            int critheals = 0;
            int cures = 0;
            int misses = 0;
            int hitfail = 0;
            float tohit = 0;
            double dps = 0;
            double hps = 0;
            long healstaken = 0;
            long damagetaken = 0;
            long powerdrain = 0;
            long powerheal = 0;
            int kills = 0;
            int deaths = 0;

            switch (VarName)
            {
                case "maxheal":
                    return Data.GetMaxHeal(true, false);
                case "MAXHEAL":
                    return Data.GetMaxHeal(false, false);
                case "maxhealward":
                    return Data.GetMaxHeal(true, true);
                case "MAXHEALWARD":
                    return Data.GetMaxHeal(false, true);
                case "maxhit":
                    return Data.GetMaxHit(true);
                case "MAXHIT":
                    return Data.GetMaxHit(false);
                case "duration":
                    return Data.DurationS;
                case "DURATION":
                    return Data.Duration.TotalSeconds.ToString("0");
                case "damage":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    return damage.ToString();
                case "damage-m":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    return (damage / 1000000.0).ToString("0.00");
                case "DAMAGE-k":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    return (damage / 1000.0).ToString("0");
                case "DAMAGE-m":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    return (damage / 1000000.0).ToString("0");
                case "healed":
                    foreach (CombatantData cd in SelectiveAllies)
                        healed += cd.Healed;
                    return healed.ToString();
                case "swings":
                    foreach (CombatantData cd in SelectiveAllies)
                        swings += cd.Swings;
                    return swings.ToString();
                case "hits":
                    foreach (CombatantData cd in SelectiveAllies)
                        hits += cd.Hits;
                    return hits.ToString();
                case "crithits":
                    foreach (CombatantData cd in SelectiveAllies)
                        crits += cd.CritHits;
                    return crits.ToString();
                case "crithit%":
                    foreach (CombatantData cd in SelectiveAllies)
                        crits += cd.CritHits;
                    foreach (CombatantData cd in SelectiveAllies)
                        hits += cd.Hits;
                    float critdamperc = (float)crits / (float)hits;
                    return critdamperc.ToString("0'%");
                case "heals":
                    foreach (CombatantData cd in SelectiveAllies)
                        heals += cd.Heals;
                    return heals.ToString();
                case "critheals":
                    foreach (CombatantData cd in SelectiveAllies)
                        critheals += cd.CritHits;
                    return critheals.ToString();
                case "critheal%":
                    foreach (CombatantData cd in SelectiveAllies)
                        critheals += cd.CritHeals;
                    foreach (CombatantData cd in SelectiveAllies)
                        heals += cd.Heals;
                    float crithealperc = (float)critheals / (float)heals;
                    return crithealperc.ToString("0'%");
                case "cures":
                    foreach (CombatantData cd in SelectiveAllies)
                        cures += cd.CureDispels;
                    return cures.ToString();
                case "misses":
                    foreach (CombatantData cd in SelectiveAllies)
                        misses += cd.Misses;
                    return misses.ToString();
                case "hitfailed":
                    foreach (CombatantData cd in SelectiveAllies)
                        hitfail += cd.Blocked;
                    return hitfail.ToString();
                case "TOHIT":
                    foreach (CombatantData cd in SelectiveAllies)
                        tohit += cd.ToHit;
                    tohit /= SelectiveAllies.Count;
                    return tohit.ToString("0");
                case "DPS":
                case "ENCDPS":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    dps = damage / Data.Duration.TotalSeconds;
                    return dps.ToString("0");
                case "DPS-k":
                case "ENCDPS-k":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    dps = damage / Data.Duration.TotalSeconds;
                    return (dps / 1000.0).ToString("0");
                case "ENCHPS":
                    foreach (CombatantData cd in SelectiveAllies)
                        healed += cd.Healed;
                    hps = healed / Data.Duration.TotalSeconds;
                    return hps.ToString("0");
                case "ENCHPS-k":
                    foreach (CombatantData cd in SelectiveAllies)
                        healed += cd.Healed;
                    hps = healed / Data.Duration.TotalSeconds;
                    return (hps / 1000.0).ToString("0");
                case "tohit":
                    foreach (CombatantData cd in SelectiveAllies)
                        tohit += cd.ToHit;
                    tohit /= SelectiveAllies.Count;
                    return tohit.ToString("F");
                case "dps":
                case "encdps":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    dps = damage / Data.Duration.TotalSeconds;
                    return dps.ToString("F");
                case "dps-k":
                case "encdps-k":
                    foreach (CombatantData cd in SelectiveAllies)
                        damage += cd.Damage;
                    dps = damage / Data.Duration.TotalSeconds;
                    return (dps / 1000.0).ToString("F");
                case "enchps":
                    foreach (CombatantData cd in SelectiveAllies)
                        healed += cd.Healed;
                    hps = healed / Data.Duration.TotalSeconds;
                    return hps.ToString("F");
                case "enchps-k":
                    foreach (CombatantData cd in SelectiveAllies)
                        healed += cd.Healed;
                    hps = healed / Data.Duration.TotalSeconds;
                    return (hps / 1000.0).ToString("F");
                case "healstaken":
                    foreach (CombatantData cd in SelectiveAllies)
                        healstaken += cd.HealsTaken;
                    return healstaken.ToString();
                case "damagetaken":
                    foreach (CombatantData cd in SelectiveAllies)
                        damagetaken += cd.DamageTaken;
                    return damagetaken.ToString();
                case "powerdrain":
                    foreach (CombatantData cd in SelectiveAllies)
                        powerdrain += cd.PowerDamage;
                    return powerdrain.ToString();
                case "powerheal":
                    foreach (CombatantData cd in SelectiveAllies)
                        powerheal += cd.PowerReplenish;
                    return powerheal.ToString();
                case "kills":
                    foreach (CombatantData cd in SelectiveAllies)
                        kills += cd.Kills;
                    return kills.ToString();
                case "deaths":
                    foreach (CombatantData cd in SelectiveAllies)
                        deaths += cd.Deaths;
                    return deaths.ToString();
                case "title":
                    return Data.Title;

                default:
                    return VarName;
            }
        }
Example #8
0
 public static long GetBaseDamageTaken(EncounterData enc)
 {
     List<CombatantData> allies = enc.GetAllies();
     long TotalBaseDamage = 0;
     foreach (CombatantData ally in allies)
     {
         if (ally.GetCombatantType() > 0) TotalBaseDamage += GetBaseDamageTaken(ally);
     }
     return TotalBaseDamage;
 }