Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CombatLog v1.3.0
CombatLog.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace BubCombatLog; internal class Step { public string Label; public string Detail; public float Before; public float After; public Step(string label, string detail, float before, float after) { Label = label; Detail = detail; Before = before; After = after; } } internal class Half { public bool IsAttack; public ZDOID Attacker; public ZDOID Victim; public float Key; public string AttackerName = "?"; public string VictimName = "?"; public List<Step> Steps = new List<Step>(); public float HpBefore; public float HpAfter; public float HpMax; public bool Blocked; public bool Parry; public bool Timed; public bool GuardBroken; public bool Dodged; public bool Killed; public bool Staggered; public string BlockKind = ""; public float Held; public float Stamina; public float StaggerBefore; public float StaggerAfter; public float StaggerMax; public float Instant; public float Dot; public string DamageText = ""; public void Write(ZPackage p) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) p.Write(IsAttack); p.Write(Attacker); p.Write(Victim); p.Write(Key); p.Write(AttackerName); p.Write(VictimName); p.Write(Steps.Count); foreach (Step step in Steps) { p.Write(step.Label); p.Write(step.Detail ?? ""); p.Write(step.Before); p.Write(step.After); } p.Write(HpBefore); p.Write(HpAfter); p.Write(HpMax); int num = (Blocked ? 1 : 0) | (Parry ? 2 : 0) | (Timed ? 4 : 0) | (GuardBroken ? 8 : 0) | (Dodged ? 16 : 0) | (Killed ? 32 : 0) | (Staggered ? 64 : 0); p.Write(num); p.Write(BlockKind); p.Write(Held); p.Write(Stamina); p.Write(StaggerBefore); p.Write(StaggerAfter); p.Write(StaggerMax); p.Write(Instant); p.Write(Dot); p.Write(DamageText); } public static Half Read(ZPackage p) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Half half = new Half(); half.IsAttack = p.ReadBool(); half.Attacker = p.ReadZDOID(); half.Victim = p.ReadZDOID(); half.Key = p.ReadSingle(); half.AttackerName = p.ReadString(); half.VictimName = p.ReadString(); int num = p.ReadInt(); for (int i = 0; i < num; i++) { half.Steps.Add(new Step(p.ReadString(), p.ReadString(), p.ReadSingle(), p.ReadSingle())); } half.HpBefore = p.ReadSingle(); half.HpAfter = p.ReadSingle(); half.HpMax = p.ReadSingle(); int num2 = p.ReadInt(); half.Blocked = (num2 & 1) != 0; half.Parry = (num2 & 2) != 0; half.Timed = (num2 & 4) != 0; half.GuardBroken = (num2 & 8) != 0; half.Dodged = (num2 & 0x10) != 0; half.Killed = (num2 & 0x20) != 0; half.Staggered = (num2 & 0x40) != 0; half.BlockKind = p.ReadString(); half.Held = p.ReadSingle(); half.Stamina = p.ReadSingle(); half.StaggerBefore = p.ReadSingle(); half.StaggerAfter = p.ReadSingle(); half.StaggerMax = p.ReadSingle(); half.Instant = p.ReadSingle(); half.Dot = p.ReadSingle(); half.DamageText = p.ReadString(); return half; } } internal static class Combat { private class Ctx { public Ctx Prev; public Character Victim; public HitData Hit; public Half Half; public float StaminaBefore; public float BlockBefore; public float AfterArmor = -1f; } public static FieldInfo StaggerDamage; public static FieldInfo BlockTimer; public static FieldInfo AttackCharacter; public static FieldInfo AttackWeapon; public static FieldInfo SemanCharacter; public static Func<Humanoid, ItemData> GetCurrentBlocker; public static Func<Character, float> GetStaggerTreshold; private static readonly ConditionalWeakTable<HitData, Half> AttackByHit = new ConditionalWeakTable<HitData, Half>(); private static readonly ConditionalWeakTable<object, Half> AttackBySource = new ConditionalWeakTable<object, Half>(); private static object currentSource; private static readonly List<string> SiteLabels = new List<string>(); private static Ctx current; private static bool dying; private static Dictionary<SkillType, float> skillsBefore; public static void Patch(Harmony h) { StaggerDamage = AccessTools.Field(typeof(Character), "m_staggerDamage"); BlockTimer = AccessTools.Field(typeof(Humanoid), "m_blockTimer"); AttackCharacter = AccessTools.Field(typeof(Attack), "m_character"); AttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon"); SemanCharacter = AccessTools.Field(typeof(SEMan), "m_character"); GetCurrentBlocker = AccessTools.MethodDelegate<Func<Humanoid, ItemData>>(AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null), (object)null, true); GetStaggerTreshold = AccessTools.MethodDelegate<Func<Character, float>>(AccessTools.Method(typeof(Character), "GetStaggerTreshold", (Type[])null, (Type[])null), (object)null, true); h.Patch((MethodBase)AccessTools.Method(typeof(Attack), "ModifyDamage", (Type[])null, (Type[])null), Hm("ModifyDamagePrefix"), Hm("ModifyDamagePostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(SEMan), "ModifyAttack", (Type[])null, (Type[])null), Hm("ModifyAttackPrefix"), Hm("ModifyAttackPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Projectile), "Setup", (Type[])null, (Type[])null), (HarmonyMethod)null, Hm("SourceSetup"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Aoe), "Setup", (Type[])null, (Type[])null), (HarmonyMethod)null, Hm("SourceSetup"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Projectile), "OnHit", (Type[])null, (Type[])null), Hm("SourceHitPrefix"), (HarmonyMethod)null, (HarmonyMethod)null, Hm("SourceHitFinalizer"), (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Aoe), "OnHit", (Type[])null, (Type[])null), Hm("SourceHitPrefix"), (HarmonyMethod)null, (HarmonyMethod)null, Hm("SourceHitFinalizer"), (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Character), "Damage", (Type[])null, (Type[])null), Hm("DeliverPrefix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); HarmonyMethod val = Hm("DefenseTranspiler"); MethodInfo methodInfo = AccessTools.Method(typeof(Character), "RPC_Damage", (Type[])null, (Type[])null); HarmonyMethod obj = Hm("DefensePrefix"); HarmonyMethod obj2 = Hm("DefensePostfix"); HarmonyMethod val2 = Hm("DefenseFinalizer"); h.Patch((MethodBase)methodInfo, obj, obj2, val, val2, (HarmonyMethod)null); RpcMark.Patch(h); h.Patch((MethodBase)AccessTools.Method(typeof(Character), "ApplyDamage", (Type[])null, (Type[])null), Hm("ApplyDamagePrefix"), Hm("ApplyDamagePostfix"), val, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Humanoid), "BlockAttack", (Type[])null, (Type[])null), Hm("BlockPrefix"), Hm("BlockPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Character), "Stagger", (Type[])null, (Type[])null), (HarmonyMethod)null, Hm("StaggerPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Character), "AddStaggerDamage", (Type[])null, (Type[])null), Hm("AddStaggerPrefix"), Hm("AddStaggerPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Player), "OnDeath", (Type[])null, (Type[])null), Hm("DeathPrefix"), Hm("DeathPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Skills), "OnDeath", (Type[])null, (Type[])null), Hm("SkillsPrefix"), Hm("SkillsPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); h.Patch((MethodBase)AccessTools.Method(typeof(Skills), "Clear", (Type[])null, (Type[])null), Hm("SkillsClearPrefix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static HarmonyMethod Hm(string name) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return new HarmonyMethod(typeof(Combat).GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic)); } public static string Name(Character c) { if ((Object)(object)c == (Object)null) { return Lang.K("env"); } if (c is Player) { return c.GetHoverName(); } int num = c.GetLevel() - 1; if (num <= 0) { return c.m_name; } return c.m_name + " " + new string('★', num); } public static float Total(HitData hit) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) DamageTypes damage = hit.m_damage; return damage.m_damage + damage.m_blunt + damage.m_slash + damage.m_pierce + damage.m_fire + damage.m_frost + damage.m_lightning + damage.m_poison + damage.m_spirit; } public static string Source(Character attacker, HitData hit) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected I4, but got Unknown if ((Object)(object)attacker != (Object)null) { return Name(attacker); } HitType hitType = hit.m_hitType; return (hitType - 3) switch { 0 => Lang.K("cause_fall"), 1 => Lang.K("cause_drowning"), 2 => Lang.K("cause_burning"), 3 => Lang.K("cause_freezing"), 4 => Lang.K("cause_poisoned"), 5 => Lang.K("cause_water"), 6 => Lang.K("cause_smoke"), 7 => Lang.K("cause_edge"), 8 => Lang.K("cause_impact"), 9 => Lang.K("cause_cart"), 10 => Lang.K("cause_tree"), 11 => Lang.K("cause_self"), 12 => Lang.K("cause_structural"), 13 => Lang.K("cause_turret"), 14 => Lang.K("cause_boat"), 15 => Lang.K("cause_stalagtite"), 16 => Lang.K("cause_catapult"), 17 => Lang.K("cause_cinder"), 18 => Lang.K("cause_ashocean"), 19 => Lang.K("cause_lava"), 20 => Lang.K("cause_incinerator"), 21 => Lang.K("cause_drawbridge"), _ => Lang.K("env"), }; } public static float Bar(Character c) { return (float)StaggerDamage.GetValue(c); } public static ZDOID Id(Character c) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)c != (Object)null)) { return ZDOID.None; } return c.GetZDOID(); } public static string N(float v) { return Mathf.RoundToInt(v).ToString(); } public static string DamageText(DamageTypes d) { List<string> list = new List<string>(); Part(list, d.m_damage, "damage"); Part(list, d.m_blunt, "blunt"); Part(list, d.m_slash, "slash"); Part(list, d.m_pierce, "pierce"); Part(list, d.m_fire, "fire"); Part(list, d.m_frost, "frost"); Part(list, d.m_lightning, "lightning"); Part(list, d.m_poison, "poison"); Part(list, d.m_spirit, "spirit"); if (list.Count <= 0) { return ""; } return "%D" + string.Join(";", list.ToArray()); } private static void Part(List<string> parts, float v, string type) { if (v >= 0.5f) { parts.Add(type + "=" + N(v)); } } private static bool IsLocal(Character c) { if ((Object)(object)c != (Object)null) { return (Object)(object)c == (Object)(object)Player.m_localPlayer; } return false; } private static void ModifyDamagePrefix(Attack __instance, HitData __0, float __1) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) Character val = (Character)AttackCharacter.GetValue(__instance); ItemData val2 = (ItemData)AttackWeapon.GetValue(__instance); Half half = new Half(); half.IsAttack = true; half.AttackerName = Name(val); float num = Total(__0); string text = ((val2 != null) ? val2.m_shared.m_name : Lang.K("st_weapon")); string label = ((val2 != null && val2.m_quality > 1) ? Lang.K("st_base_q", text, val2.m_quality.ToString()) : Lang.K("st_base", text)); half.Steps.Add(new Step(label, DamageText(__0.m_damage), num, num)); num = Mult(half, Lang.K("st_mult_attack"), __instance.m_damageMultiplier, num); num = Mult(half, Lang.K((val is Player) ? "st_skill" : "st_random"), __1, num); if ((Object)(object)val != (Object)null) { int num2 = val.GetLevel() - 1; num = Mult(half, Lang.K("st_stars", Mathf.Max(0, num2).ToString()), 1f + (float)Mathf.Max(0, num2) * 0.5f, num); if (__instance.m_damageMultiplierPerMissingHP > 0f) { num = Mult(half, Lang.K("st_missing_hp"), 1f + (val.GetMaxHealth() - val.GetHealth()) * __instance.m_damageMultiplierPerMissingHP, num); } if (__instance.m_damageMultiplierByTotalHealthMissing > 0f) { num = Mult(half, Lang.K("st_missing_hp_pct"), 1f + (1f - val.GetHealthPercentage()) * __instance.m_damageMultiplierByTotalHealthMissing, num); } } AttackByHit.Remove(__0); AttackByHit.Add(__0, half); } private static float Mult(Half t, string label, float factor, float before) { if (Mathf.Abs(factor - 1f) < 0.001f) { return before; } float num = before * factor; t.Steps.Add(new Step(label, Lang.K("x", Lang.Num(factor)), before, num)); return num; } private static void ModifyDamagePostfix(HitData __0) { if (AttackByHit.TryGetValue(__0, out var value)) { Reconcile(value, Total(__0), Lang.K("st_adj_game")); } } private static void Reconcile(Half t, float actual, string label) { float num = ((t.Steps.Count > 0) ? t.Steps[t.Steps.Count - 1].After : actual); if (!(Mathf.Abs(actual - num) < 0.05f)) { string detail = ((num > 0.01f) ? Lang.K("x", Lang.Num(actual / num)) : ""); t.Steps.Add(new Step(label, detail, num, actual)); } } private static void ModifyAttackPrefix(ref HitData __1) { if (__1 != null && AttackByHit.TryGetValue(__1, out var value)) { Reconcile(value, Total(__1), Lang.K("st_adj_combo")); } } private static void ModifyAttackPostfix(SEMan __instance, ref HitData __1) { if (__1 == null || !AttackByHit.TryGetValue(__1, out var value)) { return; } float after = value.Steps[value.Steps.Count - 1].After; float num = Total(__1); if (Mathf.Abs(num - after) < 0.05f) { return; } List<string> list = new List<string>(); foreach (StatusEffect statusEffect in __instance.GetStatusEffects()) { if ((Object)(object)statusEffect != (Object)null && !string.IsNullOrEmpty(statusEffect.m_name)) { list.Add(statusEffect.m_name); } } string text = Lang.Num(num / Mathf.Max(0.01f, after)); string detail = ((list.Count > 0) ? Lang.K("x_list", text, string.Join(", ", list.ToArray())) : Lang.K("x", text)); value.Steps.Add(new Step(Lang.K("st_fx_attacker"), detail, after, num)); } private static void SourceSetup(object __instance, HitData __3) { if (__3 != null && AttackByHit.TryGetValue(__3, out var value)) { AttackBySource.Remove(__instance); AttackBySource.Add(__instance, value); } } private static string SourceName(object source) { Component val = (Component)((source is Component) ? source : null); if (!((Object)(object)val != (Object)null)) { return "?"; } return ((Object)val.gameObject).name.Replace("(Clone)", "").Trim(); } private static void SourceHitPrefix(object __instance, out object __state) { __state = currentSource; currentSource = __instance; } private static Exception SourceHitFinalizer(Exception __exception, object __state) { currentSource = __state; return __exception; } private static void DeliverPrefix(Character __instance, HitData __0) { //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) if (__0 == null) { return; } Character attacker = __0.GetAttacker(); if (IsLocal(attacker) || IsLocal(__instance) || __instance is Player) { if (!AttackByHit.TryGetValue(__0, out var value) && (currentSource == null || !AttackBySource.TryGetValue(currentSource, out value))) { value = new Half(); value.AttackerName = Source(attacker, __0); string label = ((currentSource is Aoe) ? Lang.K("st_src_aoe", SourceName(currentSource)) : ((currentSource is Projectile) ? Lang.K("st_src_projectile", SourceName(currentSource)) : (((Object)(object)attacker == (Object)null) ? Lang.K("st_src_cause", Source(null, __0)) : Lang.K("st_src_untracked")))); float num = Total(__0); string text = DamageText(__0.m_damage); value.Steps.Add(new Step(label, (currentSource != null && text.Length > 0) ? Lang.K("st_own_damage", text) : text, num, num)); } Half half = new Half(); half.IsAttack = true; half.Steps.AddRange(value.Steps); half.AttackerName = Source(attacker, __0); half.VictimName = Name(__instance); half.Attacker = __0.m_attacker; half.Victim = Id(__instance); half.Key = Total(__0); Reconcile(half, half.Key, Lang.K((currentSource is Projectile) ? "st_adj_projectile" : ((currentSource is Aoe) ? "st_adj_aoe" : "st_adj_game"))); if (IsLocal(attacker) || IsLocal(__instance)) { Log.Merge(half); } if (__instance is Player && !IsLocal(__instance)) { Net.Send(__instance, half); } } } private static void DefensePrefix(Character __instance, HitData __1, out Ctx __state) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) __state = null; if (__1 != null && !((Object)(object)Player.m_localPlayer == (Object)null)) { Character attacker = __1.GetAttacker(); if ((IsLocal(__instance) || attacker is Player) && !__instance.IsDead() && !__instance.IsTeleporting() && !__instance.InCutscene()) { Ctx ctx = new Ctx(); ctx.Prev = current; ctx.Victim = __instance; ctx.Hit = __1; Half half = new Half(); half.Attacker = __1.m_attacker; half.Victim = Id(__instance); half.Key = Total(__1); half.AttackerName = Source(attacker, __1); half.VictimName = Name(__instance); half.DamageText = DamageText(__1.m_damage); half.HpBefore = __instance.GetHealth(); half.HpMax = __instance.GetMaxHealth(); half.StaggerBefore = Bar(__instance); half.StaggerMax = GetStaggerTreshold(__instance); ctx.Half = half; ctx.StaminaBefore = (IsLocal(__instance) ? Player.m_localPlayer.GetStamina() : 0f); current = ctx; __state = ctx; } } } private static Exception DefenseFinalizer(Exception __exception, Ctx __state) { if (__state != null) { current = __state.Prev; } return __exception; } private static void DefensePostfix(Character __instance, Ctx __state) { if (__state != null) { Half half = __state.Half; half.HpAfter = __instance.GetHealth(); half.StaggerAfter = Bar(__instance); half.Killed = __instance.IsDead() || half.HpAfter <= 0f; if (IsLocal(__instance)) { half.Stamina = __state.StaminaBefore - Player.m_localPlayer.GetStamina(); } if (half.Steps.Count == 0 && half.HpAfter >= half.HpBefore) { half.Dodged = true; } Character attacker = __state.Hit.GetAttacker(); if (IsLocal(attacker) || IsLocal(__instance)) { Log.Merge(half); } if (attacker is Player && !IsLocal(attacker)) { Net.Send(attacker, half); } } } private static Ctx Active(HitData hit) { Ctx ctx = current; if (ctx == null || ctx.Hit != hit) { return null; } return ctx; } private static IEnumerable<CodeInstruction> DefenseTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo methodInfo = AccessTools.Method(typeof(HitData), "ApplyModifier", new Type[1] { typeof(float) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HitData), "ApplyArmor", (Type[])null, (Type[])null); MethodInfo methodInfo3 = AccessTools.Method(typeof(HitData), "ApplyResistance", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.Method(typeof(SEMan), "OnDamaged", (Type[])null, (Type[])null); for (int i = 0; i < list.Count; i++) { CodeInstruction val = list[i]; if (CodeInstructionExtensions.Calls(val, methodInfo) || CodeInstructionExtensions.Calls(val, methodInfo2)) { bool flag = CodeInstructionExtensions.Calls(val, methodInfo2); int count = SiteLabels.Count; SiteLabels.Add(flag ? ArmorLabel(list, i) : ModifierLabel(list, i)); val.opcode = OpCodes.Call; val.operand = AccessTools.Method(typeof(Combat), flag ? "WArmor" : "WModifier", (Type[])null, (Type[])null); CodeInstruction val2 = new CodeInstruction(OpCodes.Ldc_I4, (object)count); val2.labels.AddRange(val.labels); val.labels.Clear(); list.Insert(i, val2); i++; } else if (CodeInstructionExtensions.Calls(val, methodInfo3)) { val.opcode = OpCodes.Call; val.operand = AccessTools.Method(typeof(Combat), "WResistance", (Type[])null, (Type[])null); } else if (CodeInstructionExtensions.Calls(val, methodInfo4)) { val.opcode = OpCodes.Call; val.operand = AccessTools.Method(typeof(Combat), "WOnDamaged", (Type[])null, (Type[])null); } } return list; } private static bool Back(List<CodeInstruction> code, int i, int range, Func<CodeInstruction, bool> test) { int num = i - 1; while (num >= 0 && num >= i - range) { if (test(code[num])) { return true; } num--; } return false; } private static bool LoadsField(CodeInstruction ci, string name) { FieldInfo fieldInfo = ci.operand as FieldInfo; if (fieldInfo != null) { return fieldInfo.Name == name; } return false; } private static bool CallsNamed(CodeInstruction ci, string name) { MethodInfo methodInfo = ci.operand as MethodInfo; if (methodInfo != null) { return methodInfo.Name == name; } return false; } private static string ModifierLabel(List<CodeInstruction> code, int i) { if (Back(code, i, 2, (CodeInstruction c) => LoadsField(c, "m_enemyDamageRate"))) { return "st_mod_enemy"; } if (Back(code, i, 2, (CodeInstruction c) => LoadsField(c, "m_playerDamageRate"))) { return "st_mod_player"; } if (Back(code, i, 2, (CodeInstruction c) => LoadsField(c, "m_localDamgeTakenRate"))) { return "st_mod_taken"; } if (Back(code, i, 2, (CodeInstruction c) => LoadsField(c, "m_backstabBonus"))) { return "st_mod_backstab"; } if (Back(code, i, 3, (CodeInstruction c) => CallsNamed(c, "GetDifficultyDamageScalePlayer"))) { return "st_mod_scale_player"; } if (Back(code, i, 6, (CodeInstruction c) => CallsNamed(c, "GetDifficultyDamageScaleEnemy"))) { return "st_mod_scale_enemy"; } if (Back(code, i, 2, (CodeInstruction c) => c.opcode == OpCodes.Ldc_R4 && c.operand is float && (float)c.operand == 2f)) { return "st_mod_staggered"; } return "st_mod"; } private static string ArmorLabel(List<CodeInstruction> code, int i) { if (Back(code, i, 3, (CodeInstruction c) => CallsNamed(c, "GetBodyArmor"))) { return "st_armor"; } if (Back(code, i, 4, (CodeInstruction c) => LoadsField(c, "m_worldLevelEnemyBaseAC"))) { return "st_armor_world"; } return "st_armor"; } private static void WModifier(HitData hit, float factor, int site) { float before = Total(hit); hit.ApplyModifier(factor); Ctx ctx = Active(hit); if (ctx != null && Mathf.Abs(factor - 1f) > 0.001f) { ctx.Half.Steps.Add(new Step(Lang.K(SiteLabels[site]), Lang.K("x", Lang.Num(factor)), before, Total(hit))); } } private static void WArmor(HitData hit, float armor, int site) { float num = Total(hit); hit.ApplyArmor(armor); Ctx ctx = Active(hit); if (ctx != null) { if (armor > 0f || num - Total(hit) > 0.05f) { ctx.Half.Steps.Add(new Step(Lang.K(SiteLabels[site], N(armor)), "", num, Total(hit))); } ctx.AfterArmor = Total(hit); } } private static void WResistance(HitData hit, DamageModifiers mods, out DamageModifier significant) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) float num = Total(hit); DamageTypes damage = hit.m_damage; hit.ApplyResistance(mods, ref significant); Ctx ctx = Active(hit); if (ctx != null) { List<string> list = new List<string>(); Res(list, damage.m_blunt, mods.m_blunt, "blunt"); Res(list, damage.m_slash, mods.m_slash, "slash"); Res(list, damage.m_pierce, mods.m_pierce, "pierce"); Res(list, damage.m_fire, mods.m_fire, "fire"); Res(list, damage.m_frost, mods.m_frost, "frost"); Res(list, damage.m_lightning, mods.m_lightning, "lightning"); Res(list, damage.m_poison, mods.m_poison, "poison"); Res(list, damage.m_spirit, mods.m_spirit, "spirit"); string label = Lang.K((hit.m_weakSpot >= 0) ? "st_resist_weak" : "st_resist"); if (list.Count > 0 || Mathf.Abs(num - Total(hit)) > 0.05f) { ctx.Half.Steps.Add(new Step(label, (list.Count > 0) ? ("%R" + string.Join(";", list.ToArray())) : "", num, Total(hit))); } } } private static void Res(List<string> parts, float amount, DamageModifier mod, string type) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!(amount < 0.5f) && (int)mod != 0) { parts.Add(type + "=" + mod); } } private static void WOnDamaged(SEMan seman, HitData hit, Character attacker) { float num = Total(hit); seman.OnDamaged(hit, attacker); Ctx ctx = Active(hit); if (ctx != null && Mathf.Abs(num - Total(hit)) > 0.05f) { ctx.Half.Steps.Add(new Step(Lang.K("st_fx_target"), "", num, Total(hit))); } } private static void BlockPrefix(Humanoid __instance, HitData __0) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 Ctx ctx = Active(__0); if (ctx != null && !((Object)(object)ctx.Victim != (Object)(object)__instance)) { ItemData val = GetCurrentBlocker(__instance); if (val != null) { float timedBlockBonus = val.m_shared.m_timedBlockBonus; float num = (float)BlockTimer.GetValue(__instance); Half half = ctx.Half; half.Timed = num >= 0f && num < 0.25f; half.Parry = half.Timed && timedBlockBonus > 1f; half.BlockKind = Lang.K(((int)val.m_shared.m_itemType != 5) ? "kind_weapon" : ((timedBlockBonus <= 1f) ? "kind_tower" : ((timedBlockBonus >= 2f) ? "kind_buckler" : "kind_round"))); ctx.BlockBefore = Total(__0); } } } private static void BlockPostfix(Humanoid __instance, HitData __0, bool __result) { Ctx ctx = Active(__0); if (ctx != null && !((Object)(object)ctx.Victim != (Object)(object)__instance) && __result && ctx.Half.BlockKind.Length != 0) { Half half = ctx.Half; half.Blocked = true; half.Held = ctx.BlockBefore - Total(__0); string label = Lang.K(half.Parry ? "st_parry" : (half.Timed ? "st_block_timed" : "st_block"), half.BlockKind); half.Steps.Add(new Step(label, half.GuardBroken ? Lang.K("guard_broken") : "", ctx.BlockBefore, Total(__0))); } } private static void ApplyDamagePrefix(Character __instance, HitData __0, out float[] __state) { __state = new float[2] { __instance.GetHealth(), Total(__0) }; Ctx ctx = Active(__0); if (ctx != null) { float num = Total(__0); if (ctx.AfterArmor >= 0f && ctx.AfterArmor - num > 0.05f) { ctx.Half.Dot = ctx.AfterArmor - num; ctx.Half.Steps.Add(new Step(Lang.K("st_dot_split"), "", ctx.AfterArmor, num)); } } } private static void ApplyDamagePostfix(Character __instance, HitData __0, float[] __state) { float num = __state[0] - __instance.GetHealth(); Stats.ReportDamage(__instance, __0, num, __state[1], __state[0], __0 != RpcMark.Current); Ctx ctx = Active(__0); if (ctx != null) { ctx.Half.Instant = num; float num2 = ((ctx.Half.Steps.Count > 0) ? ctx.Half.Steps[ctx.Half.Steps.Count - 1].After : ctx.Half.Key); if (Mathf.Abs(num2 - num) > 0.5f && num >= 0f) { ctx.Half.Steps.Add(new Step(Lang.K("st_hp_cap"), "", num2, num)); } } else if (num > 0f && (IsLocal(__instance) || IsLocal(__0.GetAttacker()))) { Log.DotTick(__instance, __0, num); } } private static void StaggerPostfix(Character __instance) { Ctx ctx = current; if (ctx != null && (Object)(object)ctx.Victim == (Object)(object)__instance) { ctx.Half.Staggered = true; if (ctx.Half.BlockKind.Length > 0) { ctx.Half.GuardBroken = true; } } else if (Log.Near(__instance)) { Log.Event(Log.Color(Lang.R(Name(__instance)) + " " + Lang.S("staggered"), "ffcc40")); } } private static void AddStaggerPrefix(Character __instance, out float __state) { __state = Bar(__instance); } private static void AddStaggerPostfix(Character __instance, float __state, float __0) { Ctx ctx = current; if ((ctx == null || !((Object)(object)ctx.Victim == (Object)(object)__instance)) && !(__instance is Player) && Log.Near(__instance) && !(__0 <= 0f)) { Log.Event(Log.Color(Lang.S("stagger_add", Lang.R(Name(__instance)), N(__0)), "d0a0ff") + " (stagger " + N(__state) + "→" + N(Bar(__instance)) + "/" + N(GetStaggerTreshold(__instance)) + ")"); } } private static void DeathPrefix(Player __instance) { if (IsLocal((Character)(object)__instance)) { dying = true; Log.SkillLoss = null; Log.SkillsReset = false; } } private static void DeathPostfix(Player __instance) { if (IsLocal((Character)(object)__instance) && dying) { dying = false; Log.Death(); } } private static float Level(Skill s) { return s.m_level + s.GetLevelPercentage(); } private static void SkillsPrefix(Skills __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!dying) { return; } skillsBefore = new Dictionary<SkillType, float>(); foreach (Skill skill in __instance.GetSkillList()) { skillsBefore[skill.m_info.m_skill] = Level(skill); } } private static void SkillsPostfix(Skills __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (!dying || skillsBefore == null) { return; } List<Log.SkillDelta> list = new List<Log.SkillDelta>(); foreach (Skill skill in __instance.GetSkillList()) { if (skillsBefore.TryGetValue(skill.m_info.m_skill, out var value)) { float num = Level(skill); if (!(value - num < 0.01f)) { Log.SkillDelta skillDelta = new Log.SkillDelta(); skillDelta.Skill = skill.m_info.m_skill; skillDelta.Before = value; skillDelta.After = num; list.Add(skillDelta); } } } list.Sort((Log.SkillDelta x, Log.SkillDelta y) => (y.Before - y.After).CompareTo(x.Before - x.After)); Log.SkillLoss = list; skillsBefore = null; } private static void SkillsClearPrefix() { if (dying) { Log.SkillsReset = true; } } } internal static class RpcMark { public static HitData Current; public static void Patch(Harmony h) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0055: Expected O, but got Unknown h.Patch((MethodBase)AccessTools.Method(typeof(Character), "RPC_Damage", (Type[])null, (Type[])null), new HarmonyMethod(typeof(RpcMark).GetMethod("Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(RpcMark).GetMethod("Finalizer", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null); } private static void Prefix(HitData __1, out HitData __state) { __state = Current; Current = __1; } private static Exception Finalizer(Exception __exception, HitData __state) { Current = __state; return __exception; } } internal static class Fights { public class Entry { public DateTime When; public FightSnapshot Snap; } public static readonly List<Entry> History = new List<Entry>(); public static readonly List<Entry> Saved = new List<Entry>(); public static int MaxHistory = 30; private static string SavePath => Path.Combine(Path.Combine(Paths.BepInExRootPath, "CombatLog"), "saved_fights.txt"); public static void OnEnded(FightSnapshot s) { History.RemoveAll((Entry e) => e.Snap.Id == s.Id && (DateTime.Now - e.When).TotalHours < 1.0); Entry entry = new Entry(); entry.When = DateTime.Now; entry.Snap = s; History.Insert(0, entry); while (History.Count > MaxHistory) { History.RemoveAt(History.Count - 1); } } public static FightSnapshot Session() { FightSnapshot fightSnapshot = new FightSnapshot(); fightSnapshot.Ended = true; Dictionary<string, FightSnapshot.Row> dictionary = new Dictionary<string, FightSnapshot.Row>(); Dictionary<string, Dictionary<string, float>> dictionary2 = new Dictionary<string, Dictionary<string, float>>(); Dictionary<string, Dictionary<int, float>> dictionary3 = new Dictionary<string, Dictionary<int, float>>(); foreach (Entry item in History) { fightSnapshot.Duration += item.Snap.Duration; foreach (FightSnapshot.Row row in item.Snap.Rows) { if (!dictionary.TryGetValue(row.Name, out var value)) { value = new FightSnapshot.Row(); value.Name = row.Name; dictionary[row.Name] = value; dictionary2[row.Name] = new Dictionary<string, float>(); dictionary3[row.Name] = new Dictionary<int, float>(); } value.Done += row.Done; value.Overkill += row.Overkill; value.Taken += row.Taken; value.Healing += row.Healing; value.Kills += row.Kills; value.Hits += row.Hits; foreach (KeyValuePair<string, float> pet in row.Pets) { Add(dictionary2[row.Name], pet.Key, pet.Value); } foreach (KeyValuePair<int, float> skill in row.Skills) { Add(dictionary3[row.Name], skill.Key, skill.Value); } } } foreach (FightSnapshot.Row value2 in dictionary.Values) { foreach (KeyValuePair<string, float> item2 in dictionary2[value2.Name]) { value2.Pets.Add(item2); } foreach (KeyValuePair<int, float> item3 in dictionary3[value2.Name]) { value2.Skills.Add(item3); } fightSnapshot.Rows.Add(value2); } fightSnapshot.Rows.Sort((FightSnapshot.Row a, FightSnapshot.Row b) => b.Done.CompareTo(a.Done)); fightSnapshot.Duration = Mathf.Max(1f, fightSnapshot.Duration); return fightSnapshot; } private static void Add<K>(Dictionary<K, float> d, K key, float v) { d.TryGetValue(key, out var value); d[key] = value + v; } public static string Title(FightSnapshot s) { Dictionary<string, int> dictionary = new Dictionary<string, int>(); List<string> list = new List<string>(); foreach (FightSnapshot.Foe fo in s.Foes) { string text = Lang.R(fo.Name); if (!dictionary.ContainsKey(text)) { dictionary[text] = 0; list.Add(text); } dictionary[text]++; } List<string> list2 = new List<string>(); foreach (string item in list) { list2.Add((dictionary[item] > 1) ? (item + " ×" + dictionary[item]) : item); } if (list2.Count > 4) { int num = list2.Count - 3; list2 = list2.GetRange(0, 3); list2.Add("+" + num); } return string.Join(", ", list2.ToArray()); } public static void Load() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown Saved.Clear(); try { if (!File.Exists(SavePath)) { return; } string[] array = File.ReadAllLines(SavePath); foreach (string text in array) { int num = text.IndexOf('|'); if (num > 0 && long.TryParse(text.Substring(0, num), out var result)) { try { Entry entry = new Entry(); entry.When = new DateTime(result); entry.Snap = FightSnapshot.Read(new ZPackage(Convert.FromBase64String(text.Substring(num + 1)))); Saved.Add(entry); } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] skipping a broken saved fight: " + ex.Message)); } } } } catch (Exception ex2) { Debug.LogWarning((object)("[Combat Log] could not read saved fights: " + ex2.Message)); } } public static bool IsSaved(FightSnapshot s, DateTime when) { foreach (Entry item in Saved) { if (item.Snap.Id == s.Id && Math.Abs((item.When - when).TotalSeconds) < 1.0) { return true; } } return false; } public static void Save(FightSnapshot s, DateTime when) { if (!IsSaved(s, when)) { Entry entry = new Entry(); entry.When = when; entry.Snap = s; Saved.Insert(0, entry); Write(); } } public static void Delete(Entry e) { Saved.Remove(e); Write(); } private static void Write() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown try { Directory.CreateDirectory(Path.GetDirectoryName(SavePath)); List<string> list = new List<string>(); foreach (Entry item in Saved) { ZPackage val = new ZPackage(); item.Snap.Write(val); list.Add(item.When.Ticks + "|" + Convert.ToBase64String(val.GetArray())); } File.WriteAllLines(SavePath, list.ToArray()); } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] could not save fights: " + ex.Message)); } } } internal static class Lang { public const char Sep = '\u001f'; private static readonly Dictionary<string, string[]> T; public static bool Portuguese => ((Localization.instance != null) ? Localization.instance.GetSelectedLanguage() : null)?.StartsWith("Portuguese") ?? false; private static void A(string key, string en, string pt) { T[key] = new string[2] { en, pt }; } static Lang() { T = new Dictionary<string, string[]>(); A("you", "you", "você"); A("env", "environment", "ambiente"); A("cause_fall", "fall", "queda"); A("cause_drowning", "drowning", "afogamento"); A("cause_burning", "burning", "queimadura"); A("cause_freezing", "freezing", "congelamento"); A("cause_poisoned", "poison", "veneno"); A("cause_water", "water", "água"); A("cause_smoke", "smoke", "fumaça"); A("cause_edge", "edge of the world", "borda do mundo"); A("cause_impact", "impact", "impacto"); A("cause_cart", "cart", "carroça"); A("cause_tree", "falling tree", "árvore caindo"); A("cause_self", "yourself", "você mesmo"); A("cause_structural", "falling structure", "estrutura caindo"); A("cause_turret", "turret", "torreta"); A("cause_boat", "boat", "barco"); A("cause_stalagtite", "stalactite", "estalactite"); A("cause_catapult", "catapult", "catapulta"); A("cause_cinder", "cinder fire", "fogo de brasa"); A("cause_ashocean", "Ashlands ocean", "mar das Ashlands"); A("cause_lava", "lava", "lava"); A("cause_incinerator", "incinerator", "incinerador"); A("cause_drawbridge", "drawbridge", "ponte levadiça"); A("dt_damage", "{0} pure", "{0} puro"); A("dt_blunt", "{0} blunt", "{0} contundente"); A("dt_slash", "{0} slash", "{0} corte"); A("dt_pierce", "{0} pierce", "{0} perfurante"); A("dt_fire", "{0} fire", "{0} fogo"); A("dt_frost", "{0} frost", "{0} gelo"); A("dt_lightning", "{0} lightning", "{0} raio"); A("dt_poison", "{0} poison", "{0} veneno"); A("dt_spirit", "{0} spirit", "{0} espírito"); A("ty_blunt", "blunt", "contundente"); A("ty_slash", "slash", "corte"); A("ty_pierce", "pierce", "perfurante"); A("ty_fire", "fire", "fogo"); A("ty_frost", "frost", "gelo"); A("ty_lightning", "lightning", "raio"); A("ty_poison", "poison", "veneno"); A("ty_spirit", "spirit", "espírito"); A("ty_dot", "damage over time", "dano contínuo"); A("rm_Resistant", "resistant", "resistente"); A("rm_VeryResistant", "very resistant", "muito resistente"); A("rm_SlightlyResistant", "slightly resistant", "pouco resistente"); A("rm_Weak", "weak", "fraco"); A("rm_VeryWeak", "very weak", "muito fraco"); A("rm_SlightlyWeak", "slightly weak", "pouco fraco"); A("rm_Immune", "immune", "imune"); A("rm_Ignore", "ignores", "ignora"); A("st_base", "Base damage: {0}", "Dano base: {0}"); A("st_base_q", "Base damage: {0} (level {1})", "Dano base: {0} (nível {1})"); A("st_weapon", "weapon", "arma"); A("st_mult_attack", "Attack multiplier", "Multiplicador do ataque"); A("st_skill", "Skill (with random roll)", "Skill (com variação aleatória)"); A("st_random", "Random roll", "Variação aleatória"); A("st_stars", "Attacker stars ({0}★)", "Estrelas do atacante ({0}★)"); A("st_missing_hp", "Missing-health bonus", "Bônus por vida faltando"); A("st_missing_hp_pct", "Missing-health % bonus", "Bônus por % de vida faltando"); A("st_adj_game", "Game/mod adjustment", "Ajuste do jogo/mods"); A("st_adj_combo", "Hit bonus (combo finisher)", "Bônus do golpe (fim de combo)"); A("st_adj_projectile", "Projectile adjustment", "Ajuste do projétil"); A("st_adj_aoe", "Area adjustment", "Ajuste da área"); A("st_fx_attacker", "Effects on attacker", "Efeitos no atacante"); A("st_src_aoe", "Area effect: {0}", "Efeito de área: {0}"); A("st_src_projectile", "Projectile: {0}", "Projétil: {0}"); A("st_src_cause", "Cause: {0}", "Causa: {0}"); A("st_src_untracked", "Hit without breakdown (untracked source)", "Golpe sem detalhamento (origem não rastreada)"); A("st_own_damage", "{0} (effect's own damage)", "{0} (dano próprio do efeito)"); A("x", "×{0}", "×{0}"); A("x_list", "×{0} ({1})", "×{0} ({1})"); A("st_mod_enemy", "World: enemy damage", "Mundo: dano dos inimigos"); A("st_mod_player", "World: player damage", "Mundo: dano dos jogadores"); A("st_mod_taken", "Damage taken (difficulty)", "Dano recebido (dificuldade)"); A("st_mod_backstab", "Sneak attack (backstab)", "Ataque furtivo (backstab)"); A("st_mod_scale_player", "Player-count scaling (vs player)", "Escala por nº de jogadores (contra jogador)"); A("st_mod_scale_enemy", "Player-count scaling (vs enemy)", "Escala por nº de jogadores (contra inimigo)"); A("st_mod_staggered", "Target staggered", "Alvo em stagger"); A("st_mod", "Modifier", "Modificador"); A("st_armor", "Armor {0}", "Armadura {0}"); A("st_armor_world", "Base armor (world level) {0}", "Armadura base (nível do mundo) {0}"); A("st_resist", "Resistances", "Resistências"); A("st_resist_weak", "Resistances (weak spot)", "Resistências (ponto fraco)"); A("st_fx_target", "Effects on target", "Efeitos no alvo"); A("st_block", "Block {0}", "Bloqueio {0}"); A("st_block_timed", "Block {0} (timed)", "Bloqueio {0} no tempo"); A("st_parry", "Parry {0}", "Parry {0}"); A("st_dot_split", "Turns into damage over time (fire/poison/spirit)", "Vira dano contínuo (fogo/veneno/espírito)"); A("st_hp_cap", "Health cap/other", "Limite de vida/outros"); A("kind_tower", "tower", "tower"); A("kind_buckler", "buckler", "buckler"); A("kind_round", "round", "redondo"); A("kind_weapon", "with weapon", "com arma"); A("dmg", "{0} damage", "{0} de dano"); A("dot_extra", "{0} over time", "{0} contínuo"); A("blocked", "blocked {0} ({1})", "bloqueou {0} ({1})"); A("blocked_timed", "blocked {0} ({1}, timed)", "bloqueou {0} ({1}, no tempo)"); A("parried", "parry {0} ({1})", "parry {0} ({1})"); A("guard_broken", "GUARD BROKEN", "GUARDA QUEBRADA"); A("staggered", "STAGGERED", "CAMBALEOU"); A("killed", "DIED", "MORREU"); A("ignored", "IGNORED (dodge/invulnerable)", "IGNORADO (esquiva/invulnerável)"); A("health", "health", "vida"); A("hit", "hit {0}", "golpe {0}"); A("no_defense", " (defense calculated on another PC without the mod)", " (defesa calculada em outro PC sem o mod)"); A("no_attack", " (attack calculated on another PC without the mod)", " (ataque calculado em outro PC sem o mod)"); A("attack", "ATTACK", "ATAQUE"); A("defense", "DEFENSE", "DEFESA"); A("attack_missing", "unavailable (calculated on another PC without the mod) — hit arrived with {0}", "indisponível (calculado em outro PC sem o mod) — golpe chegou com {0}"); A("defense_missing", "unavailable (calculated on another PC without the mod)", "indisponível (calculado em outro PC sem o mod)"); A("received", "Hit received", "Golpe recebido"); A("now", "{0} now", "{0} na hora"); A("stagger_add", "{0} +{1} stagger", "{0} +{1} stagger"); A("dot_line", "{0} in {1} s (health {2}→{3})", "{0} em {1} s (vida {2}→{3})"); A("dot_from", " — from {0}", " — de {0}"); A("you_died", "YOU DIED", "VOCÊ MORREU"); A("recap_total", "{0} damage in the last {1} s", "{0} de dano nos últimos {1} s"); A("hits_one", "{0} hit", "{0} golpe"); A("hits_many", "{0} hits", "{0} golpes"); A("last_hit", "Killing blow", "Último golpe"); A("skills_lost", "SKILLS LOST", "SKILLS PERDIDAS"); A("skills_none", "No skill loss (protection after a recent death)", "Sem perda de skill (proteção de morte recente)"); A("skills_reset", "All skills were reset (world rule)", "Todas as skills foram zeradas (regra do mundo)"); A("skills_total", "Total lost: {0} levels", "Total perdido: {0} níveis"); A("recap_close", "F8 closes", "F8 fecha"); A("recap_file", "===== DEATH RECAP =====", "===== RESUMO DE MORTE ====="); A("w_title", "Combat Log", "Combat Log"); A("w_free_mouse", "Tab frees the mouse", "Tab libera o mouse"); A("w_detailed", "Detailed", "Detalhado"); A("w_list", "List", "Lista"); A("w_text", "Text", "Texto"); A("w_normal", "Normal", "Normal"); A("w_copy", "Copy", "Copiar"); A("w_copied_log", "log copied", "log copiado"); A("w_copied_hit", "hit copied", "golpe copiado"); A("w_empty", "No hits yet.", "Nenhum golpe ainda."); A("w_tab_log", "Log", "Log"); A("w_tab_fight", "Fight", "Luta"); A("f_active", "Fight in progress", "Luta em andamento"); A("f_last", "Last fight", "Última luta"); A("f_none", "No fight yet. Fights show up when you or your pets fight enemies (the server needs Combat Log too).", "Nenhuma luta ainda. As lutas aparecem quando você ou seus pets enfrentam inimigos (o servidor também precisa do Combat Log)."); A("f_foes", "Enemies", "Inimigos"); A("f_alive_count", "{0}/{1} alive", "{0}/{1} vivos"); A("f_dead", "dead", "morto"); A("f_alive", "alive", "vivo"); A("f_dead_count", "{0} dead", "{0} mortos"); A("f_taken", "taken {0}", "recebido {0}"); A("f_heal", "healed {0}", "cura {0}"); A("f_kills", "kills {0}", "abates {0}"); A("f_overkill", "overkill {0}", "overkill {0}"); A("f_dps", "{0}/s", "{0}/s"); A("f_view_current", "Current", "Atual"); A("f_view_session", "Session", "Sessão"); A("f_view_history", "History", "Histórico"); A("f_view_saved", "Saved", "Salvas"); A("f_back", "← Back", "← Voltar"); A("f_save", "Save fight", "Salvar luta"); A("f_saved_ok", "fight saved", "luta salva"); A("f_is_saved", "Saved ✓", "Salva ✓"); A("f_delete", "Delete", "Apagar"); A("f_session_title", "Session: {0} fights", "Sessão: {0} lutas"); A("f_history_empty", "No finished fight this session yet.", "Nenhuma luta encerrada nesta sessão ainda."); A("f_saved_empty", "No saved fights. Open a finished fight and press \"Save fight\".", "Nenhuma luta salva. Abra uma luta encerrada e clique em \"Salvar luta\"."); A("f_players", "{0} players", "{0} jogadores"); A("f_by_skill", "By skill", "Por skill"); A("f_by_pet", "By pet", "Por pet"); A("f_skill_none", "no skill", "sem skill"); A("f_hits", "{0} hits, {1} per hit", "{0} golpes, {1} por golpe"); A("f_click_hint", "click a player for the breakdown", "clique num jogador para ver o detalhamento"); } public static string S(string key) { if (!T.TryGetValue(key, out var value)) { return key; } if (!Portuguese) { return value[0]; } return value[1]; } public static string S(string key, params object[] args) { try { return string.Format(S(key), args); } catch { return S(key); } } public static string K(string key, params string[] args) { if (args == null || args.Length == 0) { return "@" + key; } return "@" + key + '\u001f' + string.Join('\u001f'.ToString(), args); } public static string Num(float v) { return "#" + v.ToString("0.####", CultureInfo.InvariantCulture); } public static string R(string spec) { if (string.IsNullOrEmpty(spec)) { return ""; } switch (spec[0]) { case '@': { string[] array = spec.Substring(1).Split('\u001f'); object[] array2 = new object[array.Length - 1]; for (int i = 1; i < array.Length; i++) { array2[i - 1] = R(array[i]); } return S(array[0], array2); } case '#': { if (!float.TryParse(spec.Substring(1), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return spec; } return F(result); } case '%': if (spec.Length > 1 && spec[1] == 'D') { return List(spec.Substring(2), damage: true); } if (spec.Length > 1 && spec[1] == 'R') { return List(spec.Substring(2), damage: false); } return spec; default: if (Localization.instance == null) { return spec; } return Localization.instance.Localize(spec); } } private static string List(string body, bool damage) { List<string> list = new List<string>(); string[] array = body.Split(';'); foreach (string text in array) { int num = text.IndexOf('='); if (num > 0) { string text2 = text.Substring(0, num); string text3 = text.Substring(num + 1); if (damage) { list.Add(S("dt_" + text2, text3)); } else { list.Add(S("ty_" + text2) + " " + S("rm_" + text3)); } } } return string.Join(", ", list.ToArray()); } public static string F(float v) { string text = v.ToString("0.00", CultureInfo.InvariantCulture); if (!Portuguese) { return text; } return text.Replace('.', ','); } public static string F1(float v) { string text = v.ToString("0.0", CultureInfo.InvariantCulture); if (!Portuguese) { return text; } return text.Replace('.', ','); } } internal static class Net { private const string Rpc = "bub_CombatLog_Half2"; public static void Register() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("bub_CombatLog_Half2", (Action<long, ZPackage>)OnHalf); } } public static void Send(Character to, Half half) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if (ZRoutedRpc.instance != null && !((Object)(object)to == (Object)null)) { ZNetView component = ((Component)to).GetComponent<ZNetView>(); ZDO val = (((Object)(object)component != (Object)null) ? component.GetZDO() : null); if (val != null) { ZPackage val2 = new ZPackage(); half.Write(val2); ZRoutedRpc.instance.InvokeRoutedRPC(val.GetOwner(), "bub_CombatLog_Half2", new object[1] { val2 }); } } } private static void OnHalf(long sender, ZPackage p) { try { Log.Merge(Half.Read(p)); } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] invalid packet from another player: " + ex.Message)); } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("bub.combatlog", "Combat Log", "1.3.0")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "bub.combatlog"; public const string Version = "1.3.0"; internal static Plugin Instance; internal ConfigEntry<KeyboardShortcut> toggleKey; internal ConfigEntry<bool> writeFile; internal ConfigEntry<float> nearbyRange; internal ConfigEntry<float> recapSeconds; internal Widget widget; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown Instance = this; toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle key", new KeyboardShortcut((KeyCode)289, (KeyCode[])(object)new KeyCode[0]), "Shows/hides the widget (and closes the death recap)."); writeFile = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Write file", true, "Write every hit, detailed, to BepInEx/CombatLog/<date>.log."); nearbyRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Nearby range", 40f, "Staggers of creatures within this distance are logged."); recapSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Death recap", "Seconds", 10f, new ConfigDescription("How far back the death recap looks.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 60f), new object[0])); widget = new Widget(((BaseUnityPlugin)this).Config); Fights.MaxHistory = ((BaseUnityPlugin)this).Config.Bind<int>("Fights", "History size", 30, new ConfigDescription("Finished fights kept for this session.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 200), new object[0])).Value; Fights.Load(); Harmony val = new Harmony("bub.combatlog"); Combat.Patch(val); Stats.Init(((BaseUnityPlugin)this).Config, val); val.Patch((MethodBase)AccessTools.Method(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin).GetMethod("RegisterRpc", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void RegisterRpc() { Net.Register(); Stats.Register(); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = toggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (Log.RecapVisible) { Log.HideRecap(); } else { widget.ToggleVisible(); } } Log.Tick(); Stats.Tick(); } private void OnDestroy() { Log.Close(); } private void OnGUI() { widget.Draw(); } } internal class Entry { public Half Attack; public Half Defense; public float Created; public DateTime Time; public bool Final; public string Compact; public string Detailed; public Half Any => Defense ?? Attack; public bool Incoming { get { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { return Any.Victim == ((Character)localPlayer).GetZDOID(); } return false; } } } internal static class Log { public class Item { public string Compact; public string Detail; public bool Expanded; } private class Dot { public string Victim; public string Type; public string Source; public float Amount; public float HpStart; public float HpEnd; public float Started; public bool Incoming; } private class DotRecord { public float Time; public string Source; public float Amount; } public class SkillDelta { public SkillType Skill; public float Before; public float After; } private static readonly List<Entry> pending = new List<Entry>(); private static readonly List<Entry> finished = new List<Entry>(); public static readonly List<Item> Items = new List<Item>(); public static int Added; private static readonly Dictionary<string, Dot> dots = new Dictionary<string, Dot>(); private static readonly List<DotRecord> dotHistory = new List<DotRecord>(); public static List<SkillDelta> SkillLoss; public static bool SkillsReset; private static string recap; private static float recapShownAt = -1f; private static StreamWriter file; public static bool RecapVisible { get { if (recap != null) { return Time.time - recapShownAt < 45f; } return false; } } public static void HideRecap() { recap = null; } public static string RecapText() { return recap; } public static string Color(string text, string hex) { return "<color=#" + hex + ">" + text + "</color>"; } public static bool Near(Character c) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)c != (Object)null) { return Vector3.Distance(((Component)localPlayer).transform.position, ((Component)c).transform.position) <= Plugin.Instance.nearbyRange.Value; } return false; } private static string Stamp(DateTime t) { return t.ToString("HH:mm:ss"); } public static void Merge(Half h) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) Entry entry = null; float num = float.MaxValue; foreach (Entry item in pending) { Half half = (h.IsAttack ? item.Defense : item.Attack); Half half2 = (h.IsAttack ? item.Attack : item.Defense); if (half2 == null && half != null && !(half.Attacker != h.Attacker) && !(half.Victim != h.Victim)) { float num2 = Mathf.Abs(half.Key - h.Key); if (num2 < num) { num = num2; entry = item; } } } if (entry == null) { entry = new Entry(); entry.Created = Time.time; entry.Time = DateTime.Now; pending.Add(entry); } if (h.IsAttack) { entry.Attack = h; } else { entry.Defense = h; } if (entry.Attack != null && entry.Defense != null) { Finish(entry); } } public static void Tick() { for (int num = pending.Count - 1; num >= 0; num--) { if (Time.time - pending[num].Created > 1.5f) { Finish(pending[num]); } } List<string> list = null; foreach (KeyValuePair<string, Dot> dot in dots) { if (Time.time - dot.Value.Started > 3f) { if (list == null) { list = new List<string>(); } list.Add(dot.Key); } } if (list == null) { return; } foreach (string item in list) { FlushDot(item); } } private static void Finish(Entry e) { pending.Remove(e); e.Final = true; e.Compact = CompactLine(e); e.Detailed = DetailedBlock(e); finished.Add(e); if (finished.Count > 300) { finished.RemoveAt(0); } AddItem(e.Compact, e.Detailed); WriteFile(e.Detailed); } public static void Event(string text) { string text2 = Stamp(DateTime.Now) + " " + text; AddItem(text2, null); WriteFile(text2); } private static void AddItem(string compact, string detail) { Item item = new Item(); item.Compact = compact; item.Detail = detail; Items.Add(item); Added++; if (Items.Count > 300) { Items.RemoveAt(0); } } private static string R(string spec) { return Lang.R(spec); } private static bool IsMe(ZDOID id) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { return id == ((Character)localPlayer).GetZDOID(); } return false; } private static string Who(Half h, bool attacker) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) if (IsMe(attacker ? h.Attacker : h.Victim)) { return Lang.S("you"); } return R(attacker ? h.AttackerName : h.VictimName); } private static string Header(Entry e) { Half any = e.Any; return Color(Who(any, attacker: true) + " → " + Who(any, attacker: false), e.Incoming ? "ff9a7a" : "9ad0ff"); } private static string CompactLine(Entry e) { Half attack = e.Attack; Half defense = e.Defense; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Stamp(e.Time)).Append(" ").Append(Header(e)) .Append(": "); if (defense == null) { stringBuilder.Append(Lang.S("hit", Combat.N(attack.Key))).Append(Color(Lang.S("no_defense"), "999999")); return stringBuilder.ToString(); } if (defense.Dodged) { return stringBuilder.Append(Color(Lang.S("ignored"), "8fe08f")).ToString(); } float v = defense.HpBefore - defense.HpAfter; stringBuilder.Append(Color(Lang.S("dmg", Combat.N(v)), "ff7070")); if (defense.Dot > 0.5f) { stringBuilder.Append(" + ").Append(Lang.S("dot_extra", Combat.N(defense.Dot))); } if (defense.Blocked) { stringBuilder.Append(" | ").Append(Color(Lang.S(defense.Parry ? "parried" : (defense.Timed ? "blocked_timed" : "blocked"), Combat.N(defense.Held), R(defense.BlockKind)), "8fe08f")); } if (defense.GuardBroken) { stringBuilder.Append(" | ").Append(Color(Lang.S("guard_broken"), "ff5050")); } else if (defense.Staggered) { stringBuilder.Append(" | ").Append(Color(Lang.S("staggered"), "ffcc40")); } stringBuilder.Append(" | ").Append(Lang.S("health")).Append(" ") .Append(Combat.N(defense.HpBefore)) .Append("→") .Append(Combat.N(defense.HpAfter)); if (Mathf.Abs(defense.Stamina) >= 0.5f) { stringBuilder.Append(" | stamina ").Append((defense.Stamina > 0f) ? "−" : "+").Append(Combat.N(Mathf.Abs(defense.Stamina))); } stringBuilder.Append(" | stagger ").Append(Combat.N(defense.StaggerBefore)).Append("→") .Append(Combat.N(defense.StaggerAfter)) .Append("/") .Append(Combat.N(defense.StaggerMax)); if (defense.Killed) { stringBuilder.Append(" | ").Append(Color(Lang.S("killed"), "ff5050")); } if (attack == null) { stringBuilder.Append(Color(Lang.S("no_attack"), "999999")); } return stringBuilder.ToString(); } private static string DetailedBlock(Entry e) { Half attack = e.Attack; Half defense = e.Defense; Half any = e.Any; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Stamp(e.Time)).Append(" ").Append(Header(e)); if (defense != null && !defense.Dodged) { stringBuilder.Append(" — ").Append(Color(Lang.S("dmg", Combat.N(defense.HpBefore - defense.HpAfter)), "ff7070")).Append(" (") .Append(Lang.S("health")) .Append(" ") .Append(Combat.N(defense.HpBefore)) .Append(" → ") .Append(Combat.N(defense.HpAfter)) .Append(")"); } if (defense != null && defense.Dodged) { stringBuilder.Append(" — ").Append(Color(Lang.S("ignored"), "8fe08f")); } stringBuilder.Append("\n ").Append(Color(Lang.S("attack"), "e0c070")); if (attack == null) { stringBuilder.Append("\n ").Append(Color(Lang.S("attack_missing", Combat.N(any.Key)), "999999")); } else { foreach (Step step in attack.Steps) { stringBuilder.Append("\n ").Append(StepLine(step)); } } stringBuilder.Append("\n ").Append(Color(Lang.S("defense"), "e0c070")); if (defense == null) { stringBuilder.Append("\n ").Append(Color(Lang.S("defense_missing"), "999999")); } else { if (defense.DamageText.Length > 0) { stringBuilder.Append("\n ").Append(Lang.S("received")).Append(" ") .Append(R(defense.DamageText)) .Append(" = ") .Append(Combat.N(defense.Key)); } foreach (Step step2 in defense.Steps) { stringBuilder.Append("\n ").Append(StepLine(step2)); } if (!defense.Dodged) { stringBuilder.Append("\n = ").Append(Lang.S("now", Combat.N(defense.Instant))); if (defense.Dot > 0.5f) { stringBuilder.Append(" · ").Append(Lang.S("dot_extra", Combat.N(defense.Dot))); } if (defense.Blocked && Mathf.Abs(defense.Stamina) >= 0.5f) { stringBuilder.Append(" · stamina −").Append(Combat.N(defense.Stamina)); } stringBuilder.Append(" · stagger ").Append(Combat.N(defense.StaggerBefore)).Append("→") .Append(Combat.N(defense.StaggerAfter)) .Append("/") .Append(Combat.N(defense.StaggerMax)); if (defense.GuardBroken) { stringBuilder.Append(" · ").Append(Color(Lang.S("guard_broken"), "ff5050")); } else if (defense.Staggered) { stringBuilder.Append(" · ").Append(Color(Lang.S("staggered"), "ffcc40")); } if (defense.Killed) { stringBuilder.Append(" · ").Append(Color(Lang.S("killed"), "ff5050")); } } } return stringBuilder.ToString(); } private static string StepLine(Step s) { string text = R(s.Label); string text2 = (string.IsNullOrEmpty(s.Detail) ? "" : (" " + Color(R(s.Detail), "b8b8b8"))); if (Mathf.Abs(s.Before - s.After) < 0.05f) { return text + text2 + " " + Combat.N(s.After); } string text3 = ((s.After < s.Before) ? Color(" (−" + Combat.N(s.Before - s.After) + ")", "8fe08f") : Color(" (+" + Combat.N(s.After - s.Before) + ")", "ff9a7a")); return text + text2 + " " + Combat.N(s.Before) + " → " + Combat.N(s.After) + text3; } public static void DotTick(Character victim, HitData hit, float lost) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) string text = Lang.S((hit.m_damage.m_poison > 0f) ? "ty_poison" : ((hit.m_damage.m_fire > 0f) ? "ty_fire" : ((hit.m_damage.m_spirit > 0f) ? "ty_spirit" : ((hit.m_damage.m_frost > 0f) ? "ty_frost" : "ty_dot")))); Character attacker = hit.GetAttacker(); string key = ((object)victim.GetZDOID()/*cast due to .constrained prefix*/).ToString() + "|" + text; if (!dots.TryGetValue(key, out var value)) { value = new Dot(); value.Victim = (((Object)(object)victim == (Object)(object)Player.m_localPlayer) ? Lang.S("you") : R(Combat.Name(victim))); value.Type = text; value.Source = (((Object)(object)attacker != (Object)null) ? R(Combat.Name(attacker)) : text); value.HpStart = victim.GetHealth() + lost; value.Started = Time.time; value.Incoming = (Object)(object)victim == (Object)(object)Player.m_localPlayer; dots[key] = value; } value.Amount += lost; value.HpEnd = victim.GetHealth(); if (value.Incoming) { DotRecord dotRecord = new DotRecord(); dotRecord.Time = Time.time; dotRecord.Source = value.Source + " (" + text + ")"; dotRecord.Amount = lost; dotHistory.Add(dotRecord); if (dotHistory.Count > 400) { dotHistory.RemoveAt(0); } } } private static void FlushDot(string key) { Dot dot = dots[key]; dots.Remove(key); Event(Color(dot.Victim + ": " + dot.Type, dot.Incoming ? "ff9a7a" : "9ad0ff") + " " + Lang.S("dot_line", Combat.N(dot.Amount), Combat.N(Mathf.Max(1f, Time.time - dot.Started)), Combat.N(dot.HpStart), Combat.N(dot.HpEnd)) + ((dot.Source != dot.Type) ? Lang.S("dot_from", dot.Source) : "")); } public static void Death() { for (int num = pending.Count - 1; num >= 0; num--) { Finish(pending[num]); } float value = Plugin.Instance.recapSeconds.Value; DateTime dateTime = DateTime.Now.AddSeconds(0f - value); Dictionary<string, float[]> dictionary = new Dictionary<string, float[]>(); Entry entry = null; float num2 = 0f; foreach (Entry item in finished) { if (item.Incoming && !(item.Time < dateTime) && item.Defense != null) { float num3 = Mathf.Max(0f, item.Defense.HpBefore - item.Defense.HpAfter); Add(dictionary, R(item.Any.AttackerName), num3, 1f); num2 += num3; entry = item; } } foreach (DotRecord item2 in dotHistory) { if (!(Time.time - item2.Time > value)) { Add(dictionary, item2.Source, item2.Amount, 0f); num2 += item2.Amount; } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Color(Lang.S("you_died"), "ff5050")).Append(" — ").Append(Lang.S("recap_total", Combat.N(num2), Combat.N(value))); List<KeyValuePair<string, float[]>> list = new List<KeyValuePair<string, float[]>>(dictionary); list.Sort((KeyValuePair<string, float[]> x, KeyValuePair<string, float[]> y) => y.Value[0].CompareTo(x.Value[0])); foreach (KeyValuePair<string, float[]> item3 in list) { float v = ((num2 > 0f) ? (item3.Value[0] / num2 * 100f) : 0f); stringBuilder.Append("\n ").Append(item3.Key).Append(": ") .Append(Combat.N(item3.Value[0])) .Append(" (") .Append(Combat.N(v)) .Append("%)"); if (item3.Value[1] > 0f) { stringBuilder.Append(", ").Append(Lang.S((item3.Value[1] > 1f) ? "hits_many" : "hits_one", Combat.N(item3.Value[1]))); } } AppendSkills(stringBuilder); if (entry != null) { stringBuilder.Append("\n\n").Append(Color(Lang.S("last_hit"), "e0c070")).Append("\n") .Append(entry.Detailed); } stringBuilder.Append("\n\n").Append(Color(Lang.S("recap_close"), "999999")); recap = stringBuilder.ToString(); recapShownAt = Time.time; string text = Lang.S("recap_file"); WriteFile(text + "\n" + recap + "\n" + new string('=', text.Length)); } private static void AppendSkills(StringBuilder sb) { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) sb.Append("\n\n").Append(Color(Lang.S("skills_lost"), "e0c070")); if (SkillsReset) { sb.Append("\n ").Append(Color(Lang.S("skills_reset"), "ff5050")); return; } if (SkillLoss == null || SkillLoss.Count == 0) { sb.Append("\n ").Append(Color(Lang.S("skills_none"), "8fe08f")); return; } float num = 0f; foreach (SkillDelta item in SkillLoss) { float num2 = item.Before - item.After; num += num2; float v = ((item.Before > 0f) ? (num2 / item.Before * 100f) : 0f); sb.Append("\n ").Append(SkillName(item.Skill)).Append(" ") .Append(Lang.F1(item.Before)) .Append(" → ") .Append(Lang.F1(item.After)) .Append(Color(" (−" + Lang.F1(num2) + " · −" + Lang.F1(v) + "%)", "ff9a7a")); } sb.Append("\n ").Append(Lang.S("skills_total", Lang.F1(num))); } internal static string SkillName(SkillType type) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) string text = "$skill_" + ((object)type).ToString().ToLower(); string text2 = ((Localization.instance != null) ? Localization.instance.Localize(text) : text); if (!text2.StartsWith("$") && !text2.StartsWith("[")) { return text2; } return ((object)type).ToString(); } private static void Add(Dictionary<string, float[]> d, string key, float dmg, float hits) { if (!d.TryGetValue(key, out var value)) { value = (d[key] = new float[2]); } value[0] += dmg; value[1] += hits; } private static void WriteFile(string text) { if (!Plugin.Instance.writeFile.Value) { return; } try { if (file == null) { string text2 = Path.Combine(Paths.BepInExRootPath, "CombatLog"); Directory.CreateDirectory(text2); file = new StreamWriter(Path.Combine(text2, DateTime.Now.ToString("yyyy-MM-dd") + ".log"), append: true, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false)); file.AutoFlush = true; } file.WriteLine(StripTags(text)); } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] could not write the log file: " + ex.Message)); Plugin.Instance.writeFile.Value = false; } } public static void Close() { if (file != null) { file.Close(); } } public static string Plain(string s) { return StripTags(s); } private static string StripTags(string s) { StringBuilder stringBuilder = new StringBuilder(s.Length); bool flag = false; foreach (char c in s) { switch (c) { case '<': flag = true; continue; case '>': flag = false; continue; } if (!flag) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } } internal enum Side : byte { Environment, Player, Pet, Enemy } internal class CombatEvent { public Side AttackerSide; public Side VictimSide; public string AttackerName = ""; public string VictimName = ""; public string AttackerOwner = ""; public string VictimOwner = ""; public ZDOID AttackerId; public ZDOID VictimId; public float Amount; public float Overkill; public bool Killed; public bool Dot; public bool Heal; public int Skill; public Vector3 Position; public void Write(ZPackage p) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) p.Write((byte)AttackerSide); p.Write((byte)VictimSide); p.Write(AttackerName); p.Write(VictimName); p.Write(AttackerOwner); p.Write(VictimOwner); p.Write(AttackerId); p.Write(VictimId); p.Write(Amount); p.Write(Overkill); p.Write((Killed ? 1 : 0) | (Dot ? 2 : 0) | (Heal ? 4 : 0)); p.Write(Skill); p.Write(Position); } public static CombatEvent Read(ZPackage p) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) CombatEvent combatEvent = new CombatEvent(); combatEvent.AttackerSide = (Side)p.ReadByte(); combatEvent.VictimSide = (Side)p.ReadByte(); combatEvent.AttackerName = p.ReadString(); combatEvent.VictimName = p.ReadString(); combatEvent.AttackerOwner = p.ReadString(); combatEvent.VictimOwner = p.ReadString(); combatEvent.AttackerId = p.ReadZDOID(); combatEvent.VictimId = p.ReadZDOID(); combatEvent.Amount = p.ReadSingle(); combatEvent.Overkill = p.ReadSingle(); int num = p.ReadInt(); combatEvent.Killed = (num & 1) != 0; combatEvent.Dot = (num & 2) != 0; combatEvent.Heal = (num & 4) != 0; combatEvent.Skill = p.ReadInt(); combatEvent.Position = p.ReadVector3(); return combatEvent; } } internal class FightSnapshot { public class Row { public string Name; public float Done; public float Overkill; public float Taken; public float Healing; public int Kills; public int Hits; public List<KeyValuePair<string, float>> Pets = new List<KeyValuePair<string, float>>(); public List<KeyValuePair<int, float>> Skills = new List<KeyValuePair<int, float>>(); } public class Foe { public string Name; public bool Dead; public float Taken; } public int Id; public bool Ended; public float Duration; public List<Row> Rows = new List<Row>(); public List<Foe> Foes = new List<Foe>(); public void Write(ZPackage p) { p.Write(1); p.Write(Id); p.Write(Ended); p.Write(Duration); p.Write(Rows.Count); foreach (Row row in Rows) { p.Write(row.Name); p.Write(row.Done); p.Write(row.Overkill); p.Write(row.Taken); p.Write(row.Healing); p.Write(row.Kills); p.Write(row.Hits); p.Write(row.Pets.Count); foreach (KeyValuePair<string, float> pet in row.Pets) { p.Write(pet.Key); p.Write(pet.Value); } p.Write(row.Skills.Count); foreach (KeyValuePair<int, float> skill in row.Skills) { p.Write(skill.Key); p.Write(skill.Value); } } p.Write(Foes.Count); foreach (Foe fo in Foes) { p.Write(fo.Name); p.Write(fo.Dead); p.Write(fo.Taken); } } public static FightSnapshot Read(ZPackage p) { FightSnapshot fightSnapshot = new FightSnapshot(); p.ReadInt(); fightSnapshot.Id = p.ReadInt(); fightSnapshot.Ended = p.ReadBool(); fightSnapshot.Duration = p.ReadSingle(); int num = p.ReadInt(); for (int i = 0; i < num; i++) { Row row = new Row(); row.Name = p.ReadString(); row.Done = p.ReadSingle(); row.Overkill = p.ReadSingle(); row.Taken = p.ReadSingle(); row.Healing = p.ReadSingle(); row.Kills = p.ReadInt(); row.Hits = p.ReadInt(); int num2 = p.ReadInt(); for (int j = 0; j < num2; j++) { row.Pets.Add(new KeyValuePair<string, float>(p.ReadString(), p.ReadSingle())); } int num3 = p.ReadInt(); for (int k = 0; k < num3; k++) { row.Skills.Add(new KeyValuePair<int, float>(p.ReadInt(), p.ReadSingle())); } fightSnapshot.Rows.Add(row); } int num4 = p.ReadInt(); for (int l = 0; l < num4; l++) { Foe foe = new Foe(); foe.Name = p.ReadString(); foe.Dead = p.ReadBool(); foe.Taken = p.ReadSingle(); fightSnapshot.Foes.Add(foe); } return fightSnapshot; } } internal static class Stats { private class PStats { public string Name; public float Done; public float Overkill; public float Taken; public float Healing; public int Kills; public int Hits; public Dictionary<string, float> Pets = new Dictionary<string, float>(); public Dictionary<int, float> Skills = new Dictionary<int, float>(); } private class FoeInfo { public string Name; public bool Dead; public float LastSeen; public float Taken; public Vector3 Position; } private class Fight { public int Id; public float Start; public float LastEvent; public bool Ended; public bool Dirty; public Dictionary<string, PStats> Players = new Dictionary<string, PStats>(); public Dictionary<ZDOID, FoeInfo> Foes = new Dictionary<ZDOID, FoeInfo>(); public Vector3 Position; } private const string EventRpc = "bub_CombatLog_Event"; private const string FightRpc = "bub_CombatLog_Fight"; private const string OwnerKey = "bub_nt_ownername"; private static ConfigEntry<float> idleTimeout; private static ConfigEntry<float> graceSeconds; private static ConfigEntry<float> joinRadius; private static Func<ZRoutedRpc, long> GetServerPeerID; public static FightSnapshot Current; public static FightSnapshot Last; public static int Received; private static readonly List<Fight> fights = new List<Fight>(); private static int nextId = 1; private static float lastBroadcast; private static bool IsServer { get { if ((Object)(object)ZNet.instance != (Object)null) { return ZNet.instance.IsServer(); } return false; } } public static void Init(ConfigFile config, Harmony h) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0116: Expected O, but got Unknown idleTimeout = config.Bind<float>("Fights (server)", "Idle seconds", 12f, new ConfigDescription("An engaged enemy that neither deals nor takes damage for this long leaves the fight.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 120f), new object[0])); graceSeconds = config.Bind<float>("Fights (server)", "End grace seconds", 4f, new ConfigDescription("Quiet time after the last enemy is gone before the fight closes.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), new object[0])); joinRadius = config.Bind<float>("Fights (server)", "Join radius", 60f, new ConfigDescription("A new hit within this distance of an ongoing fight joins it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 300f), new object[0])); GetServerPeerID = AccessTools.MethodDelegate<Func<ZRoutedRpc, long>>(AccessTools.Method(typeof(ZRoutedRpc), "GetServerPeerID", (Type[])null, (Type[])null), (object)null, true); h.Patch((MethodBase)AccessTools.Method(typeof(Character), "Heal", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stats), "HealPrefix", (Type[])null), new HarmonyMethod(typeof(Stats), "HealPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void Register() { if (ZRoutedRpc.instance != null) { ZRoutedRpc.instance.Register<ZPackage>("bub_CombatLog_Event", (Action<long, ZPackage>)OnEvent); ZRoutedRpc.instance.Register<ZPackage>("bub_CombatLog_Fight", (Action<long, ZPackage>)OnFight); fights.Clear(); Current = null; Last = null; } } private static Side SideOf(Character c, out string owner) { owner = ""; if ((Object)(object)c == (Object)null) { return Side.Environment; } if (c is Player) { return Side.Player; } if (c.IsTamed()) { ZNetView component = ((Component)c).GetComponent<ZNetView>(); ZDO val = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO() : null); if (val != null) { owner = val.GetString("bub_nt_ownername", ""); if (owner.Length == 0) { owner = val.GetString(ZDOVars.s_follow, ""); } } return Side.Pet; } return Side.Enemy; } public static void ReportDamage(Character victim, HitData hit, float lost, float attempted, float hpBefore, bool dot) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Expected I4, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) if (ZRoutedRpc.instance != null && !((Object)(object)victim == (Object)null) && !(lost <= 0f)) { Character attacker = hit.GetAttacker(); CombatEvent combatEvent = new CombatEvent(); combatEvent.AttackerSide = SideOf(attacker, out combatEvent.AttackerOwner); combatEvent.VictimSide = SideOf(victim, out combatEvent.VictimOwner); bool flag = combatEvent.AttackerSide == Side.Player || combatEvent.AttackerSide == Side.Pet; bool flag2 = combatEvent.VictimSide == Side.Player || combatEvent.VictimSide == Side.Pet; if ((flag && combatEvent.VictimSide == Side.Enemy) || (flag2 && (combatEvent.AttackerSide == Side.Enemy || combatEvent.AttackerSide == Side.Environment))) { combatEvent.AttackerName = Combat.Source(attacker, hit); combatEvent.VictimName = Combat.Name(victim); combatEvent.AttackerId = Combat.Id(attacker); combatEvent.VictimId = Combat.Id(victim); combatEvent.Amount = lost; combatEvent.Killed = victim.IsDead() || victim.GetHealth() <= 0f; combatEvent.Overkill = (combatEvent.Killed ? Mathf.Max(0f, attempted - hpBefore) : 0f); combatEvent.Dot = dot; combatEvent.Skill = (int)hit.m_skill; combatEvent.Position = ((Component)victim).transform.position; Send(combatEvent); } } } private static void HealPrefix(Character __instance, out float __state) { __state = __instance.GetHealth(); } private static void HealPostfix(Character __instance, float __state) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || Current == null || Current.Ended) { return; } float num = __instance.GetHealth() - __state; if (num < 0.5f) { return; } bool flag = false; foreach (FightSnapshot.Row row in Current.Rows) { if (row.Name == val.GetPlayerName()) { flag = true; break; } } if (flag) { CombatEvent combatEvent = new CombatEvent(); combatEvent.Heal = true; combatEvent.VictimSide = Side.Player; combatEvent.VictimName = val.GetPlayerName(); combatEvent.VictimId = ((Character)val).GetZDOID(); combatEvent.Amount = num; combatEvent.Position = ((Component)val).transform.position; Send(combatEvent); } } private static void Send(CombatEvent e) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); e.Write(val); ZRoutedRpc.instance.InvokeRoutedRPC(GetServerPeerID(ZRoutedRpc.instance), "bub_CombatLog_Event", new object[1] { val }); } private static void OnFight(long sender, ZPackage pkg) { try { FightSnapshot fightSnapshot = FightSnapshot.Read(pkg); Player localPlayer = Player.m_localPlayer; bool flag = false; if ((Object)(object)localPlayer != (Object)null) { foreach (FightSnapshot.Row row in fightSnapshot.Rows) { if (row.Name == localPlayer.GetPlayerName()) { flag = true; break; } } } if (flag || Current == null || Current.Ended || Current.Id == fightSnapshot.Id) { Current = fightSnapshot; if (fightSnapshot.Ended && flag) { Last = fightSnapshot; Fights.OnEnded(fightSnapshot); } Received++; } } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] invalid fight data: " + ex.Message)); } } private static void OnEvent(long sender, ZPackage pkg) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!IsServer) { return; } CombatEvent combatEvent; try { combatEvent = CombatEvent.Read(pkg); } catch (Exception ex) { Debug.LogWarning((object)("[Combat Log] invalid combat event: " + ex.Message)); return; } float time = Time.time; string player = PlayerOf(combatEvent, attacker: true) ?? PlayerOf(combatEvent, attacker: false); ZDOID val = ((combatEvent.AttackerSide == Side.Enemy) ? combatEvent.AttackerId : ((combatEvent.VictimSide == Side.Enemy) ? combatEvent.VictimId : ZDOID.None)); Fight fight = FindFight(player, val, combatEvent.Position); if (fight == null) { if (combatEvent.Heal || val == ZDOID.None) { return; } fight = new Fight(); fight.Id = nextId++; fight.Start = time; fights.Add(fight); } fight.LastEvent = time; fight.Position = combatEvent.Position; fight.Dirty = true; if (val != ZDOID.None) { if (!fight.Foes.TryGetValue(val, out var value)) { value = new FoeInfo(); value.Name = ((combatEvent.AttackerSide == Side.Enemy) ? combatEvent.AttackerName : combatEvent.VictimName); fight.Foes[val] = value; } value.LastSeen = time; value.Position = combatEvent.Position; if (combatEvent.VictimSide == Side.Enemy) { value.Taken += combatEvent.Amount; if (combatEvent.Killed) { value.Dead = true; } } } if (combatEvent.Heal) { Row(fight, combatEvent.VictimName).Healing += combatEvent.Amount; } else if (combatEvent.VictimSide == Side.Enemy) { string text = ((combatEvent.AttackerSide == Side.Player) ? combatEvent.AttackerName : combatEvent.AttackerOwner); if (text.Length == 0) { text = combatEvent.AttackerName; } PStats pStats = Row(fight, text); pStats.Done += combatEvent.Amount; pStats.Overkill += combatEvent.Overkill; if (!combatEvent.Dot && combatEvent.AttackerSide == Side.Player) { pStats.Hits++; } if (combatEvent.Killed) { pStats.Kills++; } if (combatEvent.AttackerSide == Side.Pet) { pStats.Pets.TryGetValue(combatEvent.AttackerName, out var value2); pStats.Pets[combatEvent.AttackerName] = value2 + combatEvent.Amount; } else { pStats.Skills.TryGetValue(combatEvent.Skill, out var value3); pStats.Skills[combatEvent.Skill] = value3 + combatEvent.Amount; } } else if (combatEvent.VictimSide == Side.Player) { Row(fight, combatEvent.VictimName).Taken += combatEvent.Amount; } } private static string PlayerOf(CombatEvent e, bool attacker) { switch (attacker ? e.AttackerSide : e.VictimSide) { case Side.Player: if (!attacker) { return e.VictimName; } return e.AttackerName; case Side.Pet: { string text = (attacker ? e.AttackerOwner : e.VictimOwner); if (text.Length <= 0) { return null; } return text; } default: return null; } } private static PStats Row(Fight f, string name) { if (!f.Players.TryGetValue(name, out var value)) { value = new PStats(); value.Name = name; f.Players[name] = value; } return value; } private static Fight FindFight(string player, ZDOID foe, Vector3 pos) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) foreach (Fight fight in fights) { if (!fight.Ended) { if (foe != ZDOID.None && fight.Foes.ContainsKey(foe)) { return fight; } if (player != null && fight.Players.ContainsKey(player)) { return fight; } } } foreach (Fight fight2 in fights) { if (fight2.Ended) { continue; } if (Vector3.Distance(fight2.Position, pos) <= joinRadius.Value) { return fight2; } foreach (FoeInfo value in fight2.Foes.Values) { if (!value.Dead && Vector3.Distance(value.Position, pos) <= joinRadius.Value) { return fight2; } } } return null; } public static void Tick() { if (!IsServer || ZRoutedRpc.instance == null) { return; } float time = Time.time; if (time - lastBroadcast < 1f) { return; } lastBroadcast = time; for (int num = fights.Count - 1; num >= 0; num--) { Fight fight = fights[num]; if (!fight.Ended) { bool flag = false; foreach (FoeInfo value in fight.Foes.Values) { if (!value.Dead && time - value.LastSeen < idleTimeout.Value) { flag = true; break; } } if (!flag && time - fight.LastEvent >= graceSeconds.Value) { fight.Ended = true; fight.Dirty = true; } } if (fight.Dirty) { fight.Dirty = false; Broadcast(fight, time); } if (fight.Ended) { fights.RemoveAt(num); } } } private static void Broadcast(Fight f, float now) { //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown FightSnapshot fightSnapshot = new FightSnapshot(); fightSnapshot.Id = f.Id; fightSnapshot.Ended = f.Ended; fightSnapshot.Duration = Mathf.Max(1f, f.LastEvent - f.Start); foreach (PStats value in f.Players.Values) { FightSnapshot.Row row = new FightSnapshot.Row(); row.Name = value.Name; row.Done = value.Done; row.Overkill = value.Overkill; row.Taken = value.Taken; row.Healing = value.Healing; row.Kills = value.Kills; row.Hits = value.Hits; foreach (KeyValuePair<string, float> pet in value.Pets) { row.Pets.Add(pet); } foreach (KeyValuePair<int, float> skill in value.Skills) { row.Skills.Add(skill); } fightSnapshot.Rows.Add(row); } fightSnapshot.Rows.Sort((FightSnapshot.Row a, FightSnapshot.Row b) => b.Done.CompareTo(a.Done)); foreach (FoeInfo value2 in f.Foes.Values) { FightSnapshot.Foe foe = new FightSnapshot.Foe(); foe.Name = value2.Name; foe.Dead = value2.Dead; foe.Taken = value2.Taken; fightSnapshot.Foes.Add(foe); } ZPackage val = new ZPackage(); fightSnapshot.Write(val); ZRoutedRpc.instance.InvokeRoutedRPC(0L, "bub_CombatLog_Fight", new object[1] { val }); } } internal class Widget { private enum View { Current, Session, History, Saved, Detail } private class StringBuilderLite { private readonly StringBuilder sb = new StringBuilder(); public void Line(string s) { if (sb.Length > 0) { sb.AppendLine(); } sb.Append(s); } public override string ToString() { return sb.ToString(); } } private const float Margin = 12f; private const float BarHeight = 22f; private const float Grip = 16f; private const int MaxShown = 120; private readonly ConfigEntry<bool> visible; private readonly ConfigEntry<bool> minimized; private readonly ConfigEntry<bool> detailAll; private readonly ConfigEntry<bool> fightTab; private readonly ConfigEntry<int> width; private readonly ConfigEntry<int> height; private readonly ConfigEntry<int> fontSize; private readonly ConfigEntry<float> offsetX; private readonly ConfigEntry<float> offsetY; private readonly ConfigEntry<float> opacity; private float curW; private float curH; private Vector2 scroll; private Vector2 fightScroll; private bool stick = true; private int seenAdded = -1; private float contentHeight; private bool resizing; private bool moving; private float curX; private float curY; private Vector2 moveMouse; private Vector2 moveOffset; private bool textMode; private string plain; private int plainAdded = -1; private bool plainDetail; private string toast; private float toastUntil; private Vector2 resizeMouse; private Vector2 resizeSize; private GUIStyle text; private GUIStyle entry; private GUIStyle title; private GUIStyle button; private GUIStyle area; private Texture2D bg; private Texture2D bar; private Texture2D hover; private int styledFont = -1; private View view; private Fights.Entry viewing; private readonly HashSet<string> expanded = new HashSet<string>(); public Widget(ConfigFile config) { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown visible = config.Bind<bool>("Widget", "Visible", true, "Widget shown (F8 toggles)."); minimized = config.Bind<bool>("Widget", "Minimized", false, "Only the title bar with the last line."); detailAll = config.Bind<bool>("Widget", "Detailed", false, "Show every hit detailed (otherwise click a hit to expand it)."); fightTab = config.Bind<bool>("Widget", "Fight tab", false, "Show the fight scoreboard instead of the hit log."); width = config.Bind<int>("Widget", "Width", 560, "Width in pixels (drag the top-left corner to resize)."); height = config.Bind<int>("Widget", "Height", 260, "Height in pixels."); fontSize = config.Bind<int>("Widget", "Font size", 13, new ConfigDescription("Text size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(9, 24), new object[0])); opacity = config.Bind<float>("Widget", "Background opacity", 0.6f, new ConfigDescription("0 = transparent, 1 = solid.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); offsetX = config.Bind<float>("Widget", "Offset from right", 12f, "Distance from the right edge of the screen (drag the title bar to move)."); offsetY = config.Bind<float>("Widget", "Offset from bottom", 12f, "Distance from the bottom edge of the screen."); curX = offsetX.Value; curY = offsetY.Value; curW = width.Value; curH = height.Value; } public void ToggleVisible() { visible.Value = !visible.Value; } private void Init() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //I