示例#1
0
        public static string CombatantFormatSwitch(CombatantData Data, string VarName, CultureInfo usCulture)
        {
            if (!Data.AllOut.ContainsKey("All"))
            {
                return("0%");
            }

            switch (VarName)
            {
            case "Block%":
                return(GetSpecialHitPerc(Data.Items["Incoming Damage"], "Block").ToString("0'%", usCulture));

            case "Dodge%":
                return(GetSpecialHitPerc(Data.Items["Incoming Damage"], "Dodge").ToString("0'%", usCulture));

            case "Resist%":
                return(GetResistance(Data.AllOut["All"]).ToString("0'%", usCulture));

            case "BaseDamage":
                return(GetBaseDamage(Data.AllOut["All"]).ToString("0", usCulture));

            default:
                return(VarName);
            }
        }
        // aDPSPortions
        string ADPSPortionsDataCallback(CombatantData data)
        {
            if (data.Parent.GetBoss() == null &&
                !PluginMain.Shared.EnabledCalculateRDPSADPSForALlZones)
            {
                return("");
            }

            var takenDPSGroup = data.GetATakenDPSGroup();

            string value = "";

            if (takenDPSGroup != null && takenDPSGroup != null)
            {
                foreach (KeyValuePair <string, double> kv in takenDPSGroup.OrderByDescending(x => Math.Abs(x.Value)))
                {
                    if (value.Length > 0)
                    {
                        value += " | ";
                    }
                    value += kv.Key + " : " + "-" + (kv.Value).ToString("#,0.00");
                }
            }

            return(value);
        }
示例#3
0
        public void Setup()
        {
            var player  = CombatantData.SummonPlayer();
            var monster = CombatantData.SummonSkele();

            battlefield = new Battlefield(player, monster);
        }
        public static Dictionary <string, double> GetRTakenDPSGroup(this CombatantData data)
        {
            var damage   = data.GetDamage();
            var duration = data.Parent.GetBossDuration().TotalSeconds;

            if (damage == null || duration < 0)
            {
                return(null);
            }

            var group = new Dictionary <string, double>();

            damage.BuffTakenDamages.ForEach(x =>
            {
                if (x.BuffTaken.Swing.Attacker != data.Name)
                {
                    if (group.ContainsKey(x.BuffTaken.Swing.AttackType))
                    {
                        group[x.BuffTaken.Swing.AttackType] += x.Value / duration;
                    }
                    else
                    {
                        group.Add(x.BuffTaken.Swing.AttackType, x.Value / duration);
                    }
                }
            });

            return(group);
        }
示例#5
0
        void oFormActMain_AfterCombatAction(bool isImport, CombatActionEventArgs actionInfo)
        {
            if (incDamageTypes.Contains(actionInfo.swingType) == false)
            {
                return;
            }
            if (actionInfo.damage <= 0)
            {
                return;
            }
            // Get the incoming damage combatant from the current encounter
            EncounterData activeEncounter = ActGlobals.oFormActMain.ActiveZone.Items[ActGlobals.oFormActMain.ActiveZone.Items.Count - 1];
            CombatantData combatant       = activeEncounter.GetCombatant(actionInfo.victim);

            SortedList <DateTime, long> damagePerSecond;

            if (combatant.Tags.ContainsKey(tagName))                    // See if the combatant already has a DamageTakenPerSecond container
            {
                damagePerSecond = (SortedList <DateTime, long>)combatant.Tags[tagName];
            }
            else
            {
                damagePerSecond = new SortedList <DateTime, long>();
                combatant.Tags.Add(tagName, damagePerSecond);
            }

            if (damagePerSecond.ContainsKey(actionInfo.time))                   // See if the container has an entry for the current second
            {
                damagePerSecond[actionInfo.time] += actionInfo.damage;          // Add damage to the current second
            }
            else
            {
                damagePerSecond.Add(actionInfo.time, actionInfo.damage);                        // Add this damage as the current second
            }
        }
示例#6
0
        /// <summary>
        /// Gets the sum of damage taken in the last XX seconds of an encounter and returns a DPS value
        /// </summary>
        /// <param name="Data">Combatant receiving damage</param>
        /// <param name="Seconds">The number of seconds to include from the end.  Or zero(0) to include all.</param>
        /// <returns>Encounter Damage Taken Per Second in the last Seconds for a Combatant</returns>
        private double DTakenPSIncremental(CombatantData Data, int Seconds)
        {
            double   rSecs       = (Seconds > Data.Parent.Duration.TotalSeconds) ? Data.Parent.Duration.TotalSeconds : Seconds; // If the encounter duration is less than (Seconds), use that duration instead
            DateTime cutoff      = Data.Parent.EndTime - TimeSpan.FromSeconds(rSecs);                                           // Find the earliest time we care about
            long     totalDamage = 0;

            if (Data.Tags.ContainsKey(tagName))                 // If live parsing created a DamageTakenPerSecond container
            {
                SortedList <DateTime, long> dps = (SortedList <DateTime, long>)Data.Tags[tagName];
                for (int i = dps.Count - 1; i >= 0; i--)                // From the end of the container, backwards
                {
                    if (dps.Keys[i] >= cutoff)                          // if the time entry is after our cutoff
                    {
                        totalDamage += dps.Values[i];                   // add its damage to our total
                    }
                    else
                    {
                        break;                          // the time entries should be sorted, so once we pass the cutoff, break
                    }
                }
            }

            double encDTakenPS = totalDamage / rSecs;

            return(encDTakenPS);
        }
示例#7
0
        public static TeamData ParseTeamData(IDictionary info, TeamData fill)
        {
            if (fill == null)
            {
                fill = new TeamData();
            }

            fill.Index       = TeamIndex.Parse(info["index"] as IDictionary);
            fill.Layout      = info["layout"].ToString();
            fill.LeaderIndex = int.Parse(info["leader"].ToString());
            fill.TeamId      = info.Contains("teamId") ? info["teamId"].ToString() : fill.TeamId;
            fill.Team        = new List <CombatantData>();

            ArrayList team = info["team"] as ArrayList;

            var enumerator = team.GetEnumerator();

            while (enumerator.MoveNext())
            {
                IDictionary   member         = enumerator.Current as IDictionary;
                CombatantData combatant_data = ParseCombatantData(member, null);
                fill.Team.Add(combatant_data);
            }

            return(fill);
        }
 string PHPSAsIntExportDataCallback(CombatantData data, string extraFormat)
 {
     if (double.TryParse(data.GetColumnByName("pHPS"), out double value) == false)
     {
         return("-");
     }
     return(value.ToString("#0"));
 }
示例#9
0
        public static string IsVehicle(CombatantData Combatant)
        {
            AttackType allAttacks = null;

            if (Combatant.AllOut.TryGetValue("All", out allAttacks))
            {
                return(IsVehicle(allAttacks));
            }
            return("N");
        }
示例#10
0
        public static int GetBaseDamageTaken(CombatantData Combatant)
        {
            AttackType allAttacks = null;

            if (Combatant.AllInc.TryGetValue("All", out allAttacks))
            {
                return(GetBaseDamage(allAttacks));
            }
            return(0);
        }
示例#11
0
        private string GetPerf(EncType enc, CombatantData combatant, double encdpshps)
        {
            string job = combatant.GetColumnByName("Job");

            if (job == string.Empty)
            {
                return(string.Empty);
            }

            string perfdpshps = enc == EncType.DPS ? "dps" : "hps";

            EncounterData encounter = combatant.Parent;
            string        zonename  = encounter.ZoneName;
            string        bossname  = encounter.GetStrongestEnemy("YOU");

            PerfKey key  = CreateKey(zonename, bossname);
            dynamic perf = null;

            if (cache.TryGetValue(key, out perf))
            {
                double[] perfarry = (double[])perf[perfdpshps][job];

                if (encdpshps < perfarry[6])
                {
                    return("10-");
                }
                if (encdpshps < perfarry[5])
                {
                    return("10+");
                }
                if (encdpshps < perfarry[4])
                {
                    return("25+");
                }
                if (encdpshps < perfarry[3])
                {
                    return("50+");
                }
                if (encdpshps < perfarry[2])
                {
                    return("75+");
                }
                if (encdpshps < perfarry[1])
                {
                    return("95+");
                }
                if (encdpshps < perfarry[0])
                {
                    return("99+");
                }
                return("100");
            }
            return(string.Empty);
        }
示例#12
0
        private static String GetCustomColumnData(CombatantData combatant, String column)
        {
            String data = combatant.GetColumnByName(column);

            if (data != null)
            {
                return(data);
            }

            return("");
        }
        string PHPSSqlDataCallback(CombatantData data)
        {
            if (data.Parent.GetBoss() == null &&
                !PluginMain.Shared.EnabledCalculateRDPSADPSForALlZones)
            {
                return("0.0");
            }

            var value = data.GetPHPS();

            return(value > 0 ? value.ToString() : "0.0");
        }
示例#14
0
        public static CombatantData ParseCombatantData(IDictionary info, CombatantData fill)
        {
            if (fill == null)
            {
                fill = new CombatantData();
            }

            fill.IsPlayer       = info.Contains("isUser") && info["isUser"] != null && bool.Parse(info["isUser"].ToString());
            fill.IsPlayerMirror = info.Contains("isUserMirror") && info["isUserMirror"] != null && bool.Parse(info["isUserMirror"].ToString());
            fill.PlayerId       = info.Contains("uid") && info["uid"] != null?long.Parse(info["uid"].ToString()) : 0;

            fill.IsEnemy = info.Contains("isEnemy") && info["isEnemy"] != null && bool.Parse(info["isEnemy"].ToString());
            fill.EnemyId = info.Contains("enemyId") && info["enemyId"] != null?int.Parse(info["enemyId"].ToString()) : 0;

            fill.IsPlayerTroop       = info.Contains("isPlayerTroop") && info["isPlayerTroop"] != null && bool.Parse(info["isPlayerTroop"].ToString());
            fill.IsPlayerTroopMirror = info.Contains("isPlayerTroopMirror") && info["isPlayerTroopMirror"] != null && bool.Parse(info["isPlayerTroopMirror"].ToString());
            fill.IsEnemyTroop        = info.Contains("isEnemyTroop") && info["isEnemyTroop"] != null && bool.Parse(info["isEnemyTroop"].ToString());
            fill.TroopId             = info.Contains("troopId") && info["troopId"] != null?int.Parse(info["troopId"].ToString()) : 0;

            fill.Threaten = info.Contains("threaten") && bool.Parse(info["threaten"].ToString());
            fill.Level    = info.Contains("level") && info["level"] != null?int.Parse(info["level"].ToString()) : 0;

            fill.Name        = info.Contains("name") ? info["name"].ToString() : string.Empty;
            fill.Model       = info["model"].ToString();
            fill.Portrait    = info["portrait"].ToString();
            fill.Position    = info["pos"].ToString();
            fill.TplId       = int.Parse(info["tplId"].ToString());
            fill.CharacterId = int.Parse(info["characterId"].ToString());
            fill.Index       = CombatantIndex.Parse(info["index"] as IDictionary);

            ArrayList equipments = info.Contains("equipments") ? info["equipments"] as ArrayList : null;

            if (equipments != null)
            {
                fill.Equipments.Clear();

                var enumerator = equipments.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    IDictionary equip     = enumerator.Current as IDictionary;
                    string      name      = equip["name"].ToString();
                    string      assetName = equip["assetName"].ToString();
                    fill.Equipments[name] = assetName;
                }
            }

            if (string.IsNullOrEmpty(fill.Name))
            {
                fill.Name = (string)GlobalUtils.CallStaticHotfixEx("Hotfix_LT.Data.CharacterTemplateManager", "Instance", "GetHeroName", fill.CharacterId);
            }

            return(fill);
        }
        public static double GetPHPS(this CombatantData data)
        {
            var healing  = data.GetHealing();
            var duration = data.Parent.Duration.TotalSeconds;//data.Parent.GetBossDuration().TotalSeconds;

            if (healing == null || duration < 0)
            {
                return(-1);
            }

            return(healing.Value / duration);
        }
        public static double GetPDPS(this CombatantData data)
        {
            var damage   = data.GetDamage();
            var duration = data.Parent.GetBossDuration().TotalSeconds;

            if (damage == null || duration < 0)
            {
                return(-1);
            }

            return(damage.Value / duration);
        }
示例#17
0
        /// <summary>
        /// Gets the sum of damage taken in the last XX seconds of an encounter and returns a DPS value
        /// </summary>
        /// <param name="Data">Combatant receiving damage</param>
        /// <param name="Seconds">The number of seconds to include from the end.  Or zero(0) to include all.</param>
        /// <returns>Encounter Damage Taken Per Second in the last Seconds for a Combatant</returns>
        private double DTakenPSOnDemand(CombatantData Data, int Seconds)
        {
            AttackType at;

            if (Data.Items[CombatantData.DamageTypeDataIncomingDamage].Items.TryGetValue(ActGlobals.ActLocalization.LocalizationStrings["attackTypeTerm-all"].DisplayedText, out at))
            {
                if (Data.Tags.ContainsKey("DTakenCount|Duration"))                                                // Check if ever cached
                {
                    if ((string)Data.Tags["DTakenCount|Duration"] == $"{at.Items.Count}|{Data.Parent.DurationS}") // Check if the cached value matches current totals
                    {
                        if (Data.Tags.ContainsKey($"DamageTakenPSInLast|{Seconds}"))                              // Check if there is a cached version for last XX seconds
                        {
                            return((double)Data.Tags[$"DamageTakenPSInLast|{Seconds}"]);
                        }
                    }
                }

                Stopwatch sw = new Stopwatch();
                sw.Start();

                double   rSecs       = (Seconds > Data.Parent.Duration.TotalSeconds) ? Data.Parent.Duration.TotalSeconds : Seconds;           // If the encounter duration is less than (Seconds), use that duration instead
                TimeSpan tsSecs      = TimeSpan.FromSeconds(rSecs);
                long     totalDamage = 0;
                foreach (MasterSwing ms in at.Items)
                {
                    if (ms.Time >= Data.Parent.EndTime - tsSecs || Seconds == 0)                        // if the MasterSwing's time falls in the timeframe of the end-(Seconds)
                    {
                        totalDamage += ms.Damage;
                    }
                }
                double encDTakenPS = totalDamage / rSecs;

                ActGlobals.oFormActMain.WriteDebugLog($"DamageTakenPSInLast {Data.Name} {sw.ElapsedMilliseconds}");

                // Create our cache entries
                if (Data.Tags.ContainsKey("DTakenCount|Duration"))
                {
                    Data.Tags["DTakenCount|Duration"]           = $"{at.Items.Count}|{Data.Parent.DurationS}";
                    Data.Tags[$"DamageTakenPSInLast|{Seconds}"] = encDTakenPS;
                }
                else
                {
                    Data.Tags.Add("DTakenCount|Duration", $"{at.Items.Count}|{Data.Parent.DurationS}");
                    Data.Tags.Add($"DamageTakenPSInLast|{Seconds}", encDTakenPS);
                }
                return(encDTakenPS);
            }
            else
            {
                return(0);
            }
        }
示例#18
0
        private int GetCurseCureCount(CombatantData Combatant)
        {
            AttackType curseCures = null;

            if (Combatant.AllOut.TryGetValue("Cure Curse", out curseCures))
            {
                return(curseCures.Swings);
            }
            else
            {
                return(0);
            }
        }
        public static double GetADPS(this CombatantData data)
        {
            var damage   = data.GetDamage();
            var duration = data.Parent.GetBossDuration().TotalSeconds;

            if (damage == null || duration < 0)
            {
                return(-1);
            }

            var takenDPS = data.GetATakenDPSGroup().Values.Sum();

            return((damage.Value / duration) - takenDPS);
        }
示例#20
0
        public static VariableClump GetIdEntity(string id, out bool found)
        {
            VariableClump vc = new VariableClump();

            found = false;
            try
            {
                object plug = null;
                plug = GetInstance();
                if (plug == null)
                {
                    return(vc);
                }
                PropertyInfo  pi = GetDataRepository(plug);
                CombatantData cd = GetCombatants(plug, pi);
                lock (cd.Lock)
                {
                    foreach (dynamic cmx in cd.Combatants)
                    {
                        if (String.Compare(ConvertToHex(cmx.ID), id, true) == 0)
                        {
                            int inParty = 0;
                            try
                            {
                                if ((int)cmx.PartyType == 1)
                                {
                                    inParty = 1;
                                }
                                else
                                {
                                    inParty = 0;
                                }
                            }
                            catch (Exception)
                            {
                                inParty = 0;
                            }
                            PopulateClumpFromCombatant(vc, cmx, inParty, 0);
                            found = true;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/idexception", "Exception in FFXIV ID entity retrieve: {0}", ex.Message));
            }
            return(vc);
        }
示例#21
0
        private string GetHpsPerf(CombatantData combatant)
        {
            double absorbHPS = combatant.EncHPS;

            if (absorbHPS > 0)
            {
                int overhealpct = Int32.Parse(combatant.GetColumnByName("OverHealPct").Replace("%", string.Empty));

                double absorbHeald = combatant.Healed - Math.Round(Decimal.ToDouble(combatant.Healed * (overhealpct / 100)));
                absorbHPS = Math.Round(absorbHeald / combatant.Parent.Duration.TotalSeconds);
            }

            return(GetPerf(EncType.HPS, combatant, absorbHPS));
        }
示例#22
0
        public static int GetResistance(CombatantData Combatant)
        {
            float BaseDamageTaken = GetBaseDamageTaken(Combatant);
            float resist          = 0;

            if (BaseDamageTaken > 0)
            {
                resist = ((float)Combatant.DamageTaken / BaseDamageTaken);
                return((int)((1 - resist) * 100));
            }
            else
            {
                return(0);
            }
        }
示例#23
0
 private string AbsorbHeal(CombatantData data, string format)
 {
     try
     {
         return(data.Items[CombatantData.DamageTypeDataOutgoingHealing].Items.ToList()
                .Where(x => x.Key == "All")
                .Sum(x => x.Value.Items.Where(y => y.DamageType == "Absorb")
                     .Sum(y => Convert.ToInt64(y.Damage))).ToString());
     }
     catch (Exception ex)
     {
         LOG.Logger.Log(LogLevel.Error, ex.Message);
         return("0");
     }
 }
示例#24
0
        public static VariableClump GetNamedEntity(string name)
        {
            VariableClump vc = new VariableClump();

            try
            {
                object plug = null;
                plug = GetInstance();
                if (plug == null)
                {
                    return(vc);
                }
                PropertyInfo  pi = GetDataRepository(plug);
                CombatantData cd = GetCombatants(plug, pi);
                lock (cd.Lock)
                {
                    foreach (dynamic cmx in cd.Combatants)
                    {
                        if (cmx.Name == name)
                        {
                            int inParty = 0;
                            try
                            {
                                if ((int)cmx.PartyType == 1)
                                {
                                    inParty = 1;
                                }
                                else
                                {
                                    inParty = 0;
                                }
                            }
                            catch (Exception)
                            {
                                inParty = 0;
                            }
                            PopulateClumpFromCombatant(vc, cmx, inParty, 0);
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(Plugin.DebugLevelEnum.Error, I18n.Translate("internal/ffxiv/namedexception", "Exception in FFXIV named entity retrieve: {0}", ex.Message));
            }
            return(vc);
        }
示例#25
0
        public static int GetTankPercent(CombatantData Combatant)
        {
            if (Combatant.GetCombatantType() == 0)
            {
                return(0);
            }
            float TotalDamage     = (float)GetBaseDamageTaken(Combatant.Parent);
            float BaseDamageTaken = (float)GetBaseDamageTaken(Combatant);

            if (BaseDamageTaken > 0)
            {
                float i = (float)(BaseDamageTaken / TotalDamage);
                return((int)(i * 100));
            }
            return(0);
        }
示例#26
0
 private static CombatantData GetCombatants(object plug, PropertyInfo reprop)
 {
     if (reprop == null)
     {
         // use _Memory
         FieldInfo fi   = plug.GetType().GetField("_Memory", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         dynamic   mmry = fi.GetValue(plug);
         if (mmry == null)
         {
             return(null);
         }
         fi = mmry.GetType().GetField("_config", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         dynamic cnfg = fi.GetValue(mmry);
         if (cnfg == null)
         {
             return(null);
         }
         fi = cnfg.GetType().GetField("ScanCombatants", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         dynamic cmbt = fi.GetValue(cnfg);
         if (cmbt == null)
         {
             return(null);
         }
         fi       = cmbt.GetType().GetField("_CurrentPlayerID", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         PlayerId = fi.GetValue(cmbt);
         CombatantData cd = new CombatantData();
         fi            = cmbt.GetType().GetField("_Combatants", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         cd.Combatants = fi.GetValue(cmbt);
         fi            = cmbt.GetType().GetField("_CombatantsLock", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Instance);
         cd.Lock       = fi.GetValue(cmbt);
         return(cd);
     }
     else
     {
         // use DataRepository
         MethodInfo mi = reprop.GetGetMethod();
         object     o  = mi.Invoke(plug, null);
         mi       = o.GetType().GetMethod("GetCurrentPlayerID", BindingFlags.Instance | BindingFlags.Public);
         PlayerId = (uint)mi.Invoke(o, null);
         mi       = o.GetType().GetMethod("GetCombatantList", BindingFlags.Instance | BindingFlags.Public);
         CombatantData cd = new CombatantData();
         cd.Combatants = mi.Invoke(o, null);
         cd.Lock       = cd;
         return(cd);
     }
 }
示例#27
0
        private void Capture(object sender, RoutedEventArgs e)
        {
            BitmapSource bitmap;

            System.Windows.Point point = CombatantData.PointToScreen(new System.Windows.Point(0.0d, 0.0d));
            Rect target = new Rect(point.X + 2.0, point.Y + 1.0, CombatantData.ActualWidth - 3.0, CombatantData.ActualHeight + 17.0);

            using (Bitmap screen = new Bitmap((int)target.Width, (int)target.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb))
            {
                using (Graphics bmp = Graphics.FromImage(screen))
                {
                    bmp.CopyFromScreen((int)target.X, (int)target.Y, 0, 0, screen.Size);
                    bitmap = Imaging.CreateBitmapSourceFromHBitmap(screen.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
                }
            }
            Clipboard.SetImage(bitmap);
        }
        public static int GetHPerf(this CombatantData data)
        {
            var boss = data.Parent.GetBoss();
            var job  = data.GetJob();

            if (boss == null || job == null)
            {
                return(-1);
            }

            var pHPS        = data.GetPHPS();
            var hPercentile = boss.HPercentiles.Where(x => x.Job == job.Name).FirstOrDefault();

            if (pHPS == -1 || hPercentile == null)
            {
                return(-1);
            }

            return(CalculatePerf(pHPS, hPercentile));
        }
示例#29
0
        void sendEncounterCombatantData(CombatantData cd, Int32 actorId)
        {
            // build send data
            List <Byte> sendData = new List <Byte>();

            sendData.Add(DATA_TYPE_COMBATANT);                             // declare data type
            prepareInt32(ref sendData, cd.EncStartTime.GetHashCode());     // encounter id
            prepareInt32(ref sendData, actorId);                           // actor id (ffxiv)
            prepareString(ref sendData, cd.Name);                          // combatant name
            prepareString(ref sendData, cd.GetColumnByName("Job"));        // combatant job (ffxiv)
            prepareInt32(ref sendData, (Int32)cd.Damage);                  // damage done
            prepareInt32(ref sendData, (Int32)cd.DamageTaken);             // damage taken
            prepareInt32(ref sendData, (Int32)cd.Healed);                  // damage healed
            prepareInt32(ref sendData, cd.Deaths);                         // number of deaths
            prepareInt32(ref sendData, cd.Hits);                           // number of attacks
            prepareInt32(ref sendData, cd.Heals);                          // number of heals performed
            prepareInt32(ref sendData, cd.Kills);                          // number of kills
            // send
            sendUdp(ref sendData);
        }
示例#30
0
        public static string CombatantFormatSwitch(CombatantData Data, string VarName, CultureInfo usCulture)
        {
            if (!Data.AllOut.ContainsKey("All"))
            {
                return "0%";
            }

            switch (VarName)
            {
                case "Block%":
                    return GetSpecialHitPerc(Data.Items["Incoming Damage"], "Block").ToString("0'%", usCulture);
                case "Dodge%":
                    return GetSpecialHitPerc(Data.Items["Incoming Damage"], "Dodge").ToString("0'%", usCulture);
                case "Resist%":
                    return GetResistance(Data.AllOut["All"]).ToString("0'%", usCulture);
                case "BaseDamage":
                    return GetBaseDamage(Data.AllOut["All"]).ToString("0", usCulture);
                default:
                    return VarName;
            }
        }
        private static Healing GetHealing(this CombatantData data)
        {
            var job = data.GetJob();

            if (job == null || !data.IsAlly() || data.Name == null)
            {
                return(null);
            }

            var key       = data.Name.ToString();
            var lastSwing = data.AllOut.ContainsKey(AttackType.All) ? data.AllOut[AttackType.All].Items.LastOrDefault() : null;
            var healing   = healingCache.ContainsKey(key) && healingCache[key].LastSwing == lastSwing ? healingCache[key] : null;

            if (healing == null && lastSwing != null &&
                data.Items[DamageTypeData.OutgoingHealing].Items.Count() > 0)
            {
                // Attacks
                var healingItems = data.Items[DamageTypeData.OutgoingHealing].Items[AttackType.All].Items.ToList();
                var attacks      = healingItems.Where(x => x.Damage.Number > 0).ToList();

                var totalHealing = attacks.Select(x => x.Damage.Number - long.Parse((string)x.Tags.GetValue(SwingTag.Overheal, "0"))).Sum();

                healing = new Healing()
                {
                    Value     = totalHealing,
                    LastSwing = lastSwing
                };

                if (healingCache.ContainsKey(key))
                {
                    healingCache[key] = healing;
                }
                else
                {
                    healingCache.Add(key, healing);
                }
            }

            return(healing);
        }
示例#32
0
 public static int GetTankPercent(CombatantData Combatant)
 {
     if (Combatant.GetCombatantType() == 0) return 0;
     float TotalDamage = (float)GetBaseDamageTaken(Combatant.Parent);
     float BaseDamageTaken = (float)GetBaseDamageTaken(Combatant);
     if (BaseDamageTaken > 0)
     {   
         float i = (float)(BaseDamageTaken / TotalDamage );
         return (int)(i * 100);
     }
     return 0;
 }
示例#33
0
 public static int GetResistance(CombatantData Combatant)
 {
     float BaseDamageTaken = GetBaseDamageTaken(Combatant);
     float resist = 0;
     if (BaseDamageTaken > 0)
     {
         resist = ((float)Combatant.DamageTaken / BaseDamageTaken);
         return (int)((1 - resist) * 100);
     }
     else return 0;
 }
示例#34
0
 public static string IsVehicle(CombatantData Combatant)
 {
     AttackType allAttacks = null;
     if (Combatant.AllOut.TryGetValue("All", out allAttacks))
     {
         return IsVehicle(allAttacks);
     }
     return "N";
 }
        private long GetSpecialIncData(CombatantData Data, string specialName)
        {
            long total = 0;

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

            return total;
        }
        private long GetSpecialHealData(CombatantData Data, string specialName)
        {
            long total = 0;

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

            return total;
        }
 private int CDCompareFlankDamPrec(CombatantData Left, CombatantData Right)
 {
     return GetDTFlankPrecValue(Left.Items["Outgoing Damage"]).CompareTo(GetDTFlankPrecValue(Right.Items["Outgoing Damage"]));
 }
        private string CombatantFormatIncSwitch(CombatantData Data, string VarName, CultureInfo usCulture)
        {
            if ((!Data.Items.ContainsKey(INC_DAMAGE)) || (!Data.Items[INC_DAMAGE].Items.ContainsKey(ALL)))
            {
                return "0%";
            }

            switch (VarName)
            {
                case "takencrit%":
                    return Data.Items[INC_DAMAGE].Items[ALL].CritPerc.ToString("0'%", usCulture);
                case "takenpen%":
                    return GetSpecialHitPerc(Data.Items[INC_DAMAGE].Items[ALL],SecretLanguage.Penetrated).ToString("0'%", usCulture);
                case "takenglance%":
                    return GetSpecialHitPerc(Data.Items[INC_DAMAGE].Items[ALL],SecretLanguage.Glancing).ToString("0'%", usCulture);
                case "takenblock%":
                    return GetSpecialHitPerc(Data.Items[INC_DAMAGE].Items[ALL],SecretLanguage.Blocked).ToString("0'%", usCulture);
                case "takenevade%":
                    double missperc = 0.0;
                    if (Data.Items[INC_DAMAGE].Items[ALL].Hits > 0)
                    {
                        missperc = 100.0 * Data.Items[INC_DAMAGE].Items[ALL].Misses / Data.Items[INC_DAMAGE].Items[ALL].Hits;
                    }
                    return missperc.ToString("0'%", usCulture);
                default:
                    return VarName;
             }
        }
        private float GetFilteredCritChance(CombatantData Data)
        {
            List<AttackType> allAttackTypes = new List<AttackType>();
            List<AttackType> filteredAttackTypes = new List<AttackType>();

            foreach (KeyValuePair<string, AttackType> item in Data.Items["Outgoing Damage"].Items)
                allAttackTypes.Add(item.Value);
            foreach (KeyValuePair<string, AttackType> item in Data.Items["Healed (Out)"].Items)
                allAttackTypes.Add(item.Value);

            foreach (AttackType item in allAttackTypes)
            {
                if (item.Type == ActGlobals.ActLocalization.LocalizationStrings["attackTypeTerm-all"].DisplayedText)
                    continue;
                if (item.CritPerc == 0.0f)
                    continue;

                string damageType = string.Empty;
                bool cont = false;
                for (int i = 0; i < item.Items.Count; i++)
                {
                    string itemDamageType = item.Items[i].DamageType;
                    if (String.IsNullOrEmpty(damageType))
                    {
                        damageType = itemDamageType;
                    }
                    else
                    {
                        if (itemDamageType == "melee")
                            continue;
                        if (itemDamageType == "non-melee")
                            continue;
                        if (itemDamageType != damageType)
                        {
                            cont = true;
                            break;
                        }
                    }
                }
                if (cont)
                    continue;
                filteredAttackTypes.Add(item);
            }

            if (filteredAttackTypes.Count == 0)
                return float.NaN;
            else
            {
                float hits = 0;
                float critHits = 0;
                for (int i = 0; i < filteredAttackTypes.Count; i++)
                {
                    AttackType item = filteredAttackTypes[i];
                    hits += item.Hits;
                    critHits += item.CritHits;
                }
                float perc = critHits / hits;
                float ratio = hits / (float)Data.AllOut[ActGlobals.ActLocalization.LocalizationStrings["attackTypeTerm-all"].DisplayedText].Hits;
                //ActGlobals.oFormActMain.WriteDebugLog(String.Format("FCrit: {0} -> {1} / {2} = {3:0%} [{4:0%} data used]", Data.Name, critHits, hits, perc, ratio));
                if (perc == 1)
                {
                    if (ratio > 0.25f)
                        return 100;
                    else
                        return float.NaN;
                }
                if (ratio > 0.25f)
                    return (int)(perc * 100f);
                else
                    return float.NaN;
            }
        }
 private string GetSqlDataDmgEffectPrec(CombatantData Data)
 {
     return GetSqlDataEffectiveness(Data.Items["Outgoing Damage"]);
 }
 private string GetSqlDataFlankDamPrec(CombatantData Data)
 {
     return GetSqlDataFlankPrec(Data.Items["Outgoing Damage"]);
 }
 private int CDCompareDmgTakenEffectPrec(CombatantData Left, CombatantData Right)
 {
     return GetDTEffectivenessValue(Left.Items["Incoming Damage"]).CompareTo(GetDTEffectivenessValue(Right.Items["Incoming Damage"]));
 }
示例#43
0
 public static int GetBaseDamageTaken(CombatantData Combatant)
 {
     AttackType allAttacks = null;
     if (Combatant.AllInc.TryGetValue("All", out allAttacks))
     {
         return GetBaseDamage(allAttacks);
     }
     return 0;
 }
        private string CombatantFormatSwitch(CombatantData Data, string VarName, CultureInfo usCulture)
        {
            if ((!Data.Items.ContainsKey(OUT_DAMAGE)) || (!Data.Items[OUT_DAMAGE].Items.ContainsKey(ALL)))
            {
                return "0%";
            }

            switch (VarName)
            {
                case "Glance%":
                    return GetSpecialHitPerc(Data.Items[OUT_DAMAGE].Items[ALL], SecretLanguage.Glancing).ToString("0'%", usCulture);
                case "Penetration%":
                    return GetSpecialHitPerc(Data.Items[OUT_DAMAGE].Items[ALL], SecretLanguage.Penetrated).ToString("0'%", usCulture);
                case "Blocked%":
                    return GetSpecialHitPerc(Data.Items[OUT_DAMAGE].Items[ALL], SecretLanguage.Blocked).ToString("0'%", usCulture);
                case "AegisMismatch%":
                    return GetSpecialHitMissPerc(Data.Items[OUT_DAMAGE].Items[ALL], SecretLanguage.Aegis).ToString("0'%", usCulture);
                default:
                    return VarName;
            }
        }
 private string GetSqlDataDmgTakenEffectPrec(CombatantData Data)
 {
     return GetSqlDataEffectiveness(Data.Items["Incoming Damage"]);
 }
        private string CombatantFormatSwitch(CombatantData Data, string VarName, string Extra)
        {
            int len = 0;
            switch (VarName)
            {
                case "name":
                    return Data.Name;
                case "NAME":
                    len = Int32.Parse(Extra);
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME3":
                    len = 3;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME4":
                    len = 4;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME5":
                    len = 5;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME6":
                    len = 6;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME7":
                    len = 7;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME8":
                    len = 8;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME9":
                    len = 9;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME10":
                    len = 10;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME11":
                    len = 11;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME12":
                    len = 12;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME13":
                    len = 13;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME14":
                    len = 14;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "NAME15":
                    len = 15;
                    return Data.Name.Length - len > 0 ? Data.Name.Remove(len, Data.Name.Length - len).Trim() : Data.Name;
                case "DURATION":
                    return Data.Duration.TotalSeconds.ToString("0");
                case "duration":
                    return Data.DurationS;
                case "maxhit":
                    return Data.GetMaxHit(true);
                case "MAXHIT":
                    return Data.GetMaxHit(false);
                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 "damage":
                    return Data.Damage.ToString();
                case "damage-k":
                    return (Data.Damage / 1000.0).ToString("0.00");
                case "damage-m":
                    return (Data.Damage / 1000000.0).ToString("0.00");
                case "DAMAGE-k":
                    return (Data.Damage / 1000.0).ToString("0");
                case "DAMAGE-m":
                    return (Data.Damage / 1000000.0).ToString("0");
                case "healed":
                    return Data.Healed.ToString();
                case "swings":
                    return Data.Swings.ToString();
                case "hits":
                    return Data.Hits.ToString();
                case "crithits":
                    return Data.CritHits.ToString();
                case "critheals":
                    return Data.CritHeals.ToString();
                case "crithit%":
                    return Data.CritDamPerc.ToString("0'%");
                case "fcrithit%":
                    return GetFilteredCritChance(Data).ToString("0'%");
                case "critheal%":
                    return Data.CritHealPerc.ToString("0'%");
                case "heals":
                    return Data.Heals.ToString();
                case "cures":
                    return Data.CureDispels.ToString();
                case "misses":
                    return Data.Misses.ToString();
                case "hitfailed":
                    return Data.Blocked.ToString();
                case "TOHIT":
                    return Data.ToHit.ToString("0");
                case "DPS":
                    return Data.DPS.ToString("0");
                case "DPS-k":
                    return (Data.DPS / 1000.0).ToString("0");
                case "ENCDPS":
                    return Data.EncDPS.ToString("0");
                case "ENCDPS-k":
                    return (Data.EncDPS / 1000.0).ToString("0");
                case "ENCHPS":
                    return Data.EncHPS.ToString("0");
                case "ENCHPS-k":
                    return (Data.EncHPS / 1000.0).ToString("0");
                case "tohit":
                    return Data.ToHit.ToString("F");
                case "dps":
                    return Data.DPS.ToString("F");
                case "dps-k":
                    return (Data.DPS / 1000.0).ToString("F");
                case "encdps":
                    return Data.EncDPS.ToString("F");
                case "encdps-k":
                    return (Data.EncDPS / 1000.0).ToString("F");
                case "enchps":
                    return Data.EncHPS.ToString("F");
                case "enchps-k":
                    return (Data.EncHPS / 1000.0).ToString("F");
                case "healstaken":
                    return Data.HealsTaken.ToString();
                case "damagetaken":
                    return Data.DamageTaken.ToString();
                case "powerdrain":
                    return Data.PowerDamage.ToString();
                case "powerheal":
                    return Data.PowerReplenish.ToString();
                case "kills":
                    return Data.Kills.ToString();
                case "deaths":
                    return Data.Deaths.ToString();
                case "damage%":
                    return Data.DamagePercent;
                case "healed%":
                    return Data.HealedPercent;
                case "threatstr":
                    return Data.GetThreatStr("Threat (Out)");
                case "threatdelta":
                    return Data.GetThreatDelta("Threat (Out)").ToString();
                case "n":
                    return "\n";
                case "t":
                    return "\t";

                default:
                    return VarName;
            }
        }