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 BuildAssistant v1.0.1
RoR2BuildAssistant.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using RoR2; using RoR2.UI; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RoR2BuildAssistant")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RoR2BuildAssistant")] [assembly: AssemblyTitle("RoR2BuildAssistant")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RoR2BuildAssistant { internal sealed class BarEntry { public ItemCard Card; public int Target; public int Owned; public int Remaining => Math.Max(0, Target - Owned); } internal sealed class BuildCoach { private static readonly HashSet<string> BuildTiers = new HashSet<string> { "Tier1", "Tier2", "Tier3" }; private static readonly HashSet<string> PlanTiers = new HashSet<string> { "Tier1", "Tier2", "Tier3", "Boss", "Lunar", "Cursed", "VoidTier1", "VoidTier2", "VoidTier3" }; private static readonly Dictionary<string, KeyValuePair<int, string>> Utility = new Dictionary<string, KeyValuePair<int, string>>(StringComparer.OrdinalIgnoreCase) { { "SCRAPWHITE", Note(2, "sucata: use em uma impressora para copiar um item que falta na build") }, { "SCRAPGREEN", Note(2, "sucata: use em uma impressora para copiar um item que falta na build") }, { "SCRAPRED", Note(2, "sucata: use em uma impressora para copiar um item que falta na build") }, { "SCRAPYELLOW", Note(2, "sucata: use em uma impressora para copiar um item que falta na build") }, { "REGENERATINGSCRAP", Note(3, "sucata que volta a cada fase: rende um item incomum por fase em impressoras") }, { "TREASURECACHE", Note(2, "não ajuda em combate, mas abre uma provisão com um item na fase") }, { "TREASURECACHEVOID", Note(2, "não ajuda em combate, mas abre uma provisão com um item na fase") }, { "FREECHEST", Note(3, "entrega itens grátis a cada fase: acelera a build") }, { "LOWERPRICEDCHESTS", Note(3, "um item a mais no primeiro baú de cada fase") }, { "ITEMDROPCHANCEONKILL", Note(3, "monstros grandes soltam itens: acelera a build") }, { "EXTRASHRINEITEM", Note(1, "só ajuda se você usa Templos do Acaso") }, { "DUPLICATOR", Note(3, "cada item coletado dá uma cópia temporária") }, { "BONUSGOLDPACKONKILL", Note(2, "ouro extra ao abater: compra mais baús") }, { "GOLDONHURT", Note(1, "ouro ao apanhar: ajuda pouco") }, { "GOLDONHIT", Note(1, "ouro ao acertar, mas perde ouro ao apanhar: arriscado") }, { "MONEYLOAN", Note(1, "ouro agora em troca de dívida: arriscado") }, { "ONLEVELUPFREEUNLOCK", Note(0, "todo o ouro vira experiência e tudo fica mais caro: muda a run inteira") }, { "FOCUSEDCONVERGENCE", Note(1, "acelera o Teleportador, mas a zona encolhe") }, { "MONSTERSONSHRINEUSE", Note(-1, "chama inimigos ao usar um templo: mais perigo") }, { "TRANSFERDEBUFFONHIT", Note(-2, "reduz suas estatísticas em combate até passar para um inimigo") }, { "TONICAFFLICTION", Note(-3, "só reduz suas estatísticas") }, { "PAGESHREDDED", Note(0, "não faz nada") }, { "LUNARTRINKET", Note(0, "parece não fazer nada") }, { "RECYCLER", Note(4, "troca o item que não serve por outro da mesma raridade: ótimo para ajustar a build") }, { "SCANNER", Note(2, "mostra baús e templos: ajuda a achar itens") }, { "MULTISHOPCARD", Note(2, "devolve ouro e deixa os outros terminais abertos") }, { "HEALANDREVIVE", Note(4, "revive você ou um aliado uma vez") }, { "LUNARPORTALONUSE", Note(1, "só serve para ir ao Bazar") } }; private readonly string editsFile; private readonly Dictionary<string, int> edits = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); private string survivorKey = ""; private readonly string selectionFile; private readonly Dictionary<string, string> selections = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, int> inventory = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, ItemCard> cards = new Dictionary<string, ItemCard>(StringComparer.OrdinalIgnoreCase); private BuildEngine engine; private SurvivorProfile profile = SurvivorProfiles.Default; private string planSignature = ""; private int hexCount; private static readonly KeyValuePair<string, int>[] LevelSteps = new KeyValuePair<string, int>[3] { new KeyValuePair<string, int>("Tier1", 10), new KeyValuePair<string, int>("Tier2", 4), new KeyValuePair<string, int>("Tier3", 1) }; private readonly Dictionary<string, int> tierLevels = new Dictionary<string, int>(); private IDictionary<string, string> lastTiers; private static readonly KeyValuePair<string, int>[] SurviveItems = new KeyValuePair<string, int>[7] { new KeyValuePair<string, int>("DELAYEDDAMAGE", 1), new KeyValuePair<string, int>("EXTRALIFE", 1), new KeyValuePair<string, int>("VENGEFULSPIRIT", 1), new KeyValuePair<string, int>("TELEPORTONLOWHEALTH", 1), new KeyValuePair<string, int>("HEALINGPOTION", 2), new KeyValuePair<string, int>("PERSONALSHIELD", 3), new KeyValuePair<string, int>("BEAR", 3) }; private bool surviveMode; private readonly Dictionary<string, List<GeneratedBuild>> planCache = new Dictionary<string, List<GeneratedBuild>>(); private Task<List<GeneratedBuild>> pendingPlan; private string pendingKey; private string pendingName; private string pendingSignature; private SurvivorProfile pendingProfile; private string[] statsLines = new string[0]; private string statsKey = ""; private int updates; private const string CustomKey = "minha"; private readonly Dictionary<string, Dictionary<string, int>> custom = new Dictionary<string, Dictionary<string, int>>(StringComparer.OrdinalIgnoreCase); private const double BuildPriority = 1000.0; private static readonly HashSet<string> DefenseItems = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "SEED", "HEALONCRIT", "GHOSTBLADES", "SANGUINECHALICE", "BEAR", "BEARVOID", "PERSONALSHIELD", "DELAYEDDAMAGE", "EXTRALIFE", "TELEPORTONLOWHEALTH", "HEALINGPOTION", "FLATHEALTH", "COOKEDSTEAK", "KNURL", "INFUSION", "TOOTH", "MEDKIT", "MUSHROOM", "BARRIERONKILL", "SPRINTARMOR", "REPULSIONARMORPLATE", "OUTOFCOMBATARMOR", "HEALWHILESAFE", "INCREASEHEALING", "PEARL", "VENGEFULSPIRIT", "PHASING", "SHIELDBOOSTER", "BARRIERONCOOLDOWN", "BARRIERONOVERHEAL", "PARENTEGG", "POWERCUBE" }; private static readonly HashSet<string> MovementItems = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "HOOF", "SPRINTBONUS", "FEATHER", "SPEEDBOOSTPICKUP", "JUMPDAMAGESTRIKE", "MOVESPEEDONKILL", "SPRINTOUTOFCOMBAT", "JUMPBOOST", "POWERPYRAMID" }; public bool FastKill; public bool GlassRun; public string PlanVariant = ""; public string SurvivorName { get; private set; } public string Focus => profile.Focus; public bool HasSurvivor => !string.IsNullOrEmpty(SurvivorName); public List<GeneratedBuild> Builds { get; private set; } public GeneratedBuild Selected { get; private set; } public int HexCount => hexCount; public int Revision { get; private set; } public int BuildLevel => (tierLevels.Count == 0) ? 1 : tierLevels.Values.Max(); public bool SurviveMode { get { return surviveMode; } set { if (surviveMode != value) { surviveMode = value; planSignature = ""; Revision++; } } } public bool NeedsUpdate => planSignature.Length == 0; public bool HasEdits { get { if (Selected == null) { return false; } string prefix = survivorKey + "|" + Selected.Archetype.Key + "|"; return edits.Keys.Any((string key) => key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)); } } public bool IsCustom => Selected != null && Selected.Archetype.Key == "minha"; private string CustomFile => Path.Combine(Path.GetDirectoryName(editsFile), "builds_proprias.txt"); public string PhaseText { get { string text = (FastKill ? " FARM" : "") + (GlassRun ? " VIDRO" : ""); if (Selected == null) { return text.Trim(); } return (Selected.Targets.Keys.Any((string token) => IsCore(token) && LeftFor(token) > 0) ? "DANO PRIMEIRO" : "ESCALANDO") + text; } } private static KeyValuePair<int, string> Note(int score, string reason) { return new KeyValuePair<int, string>(score, reason); } public BuildCoach(string folder) { Builds = new List<GeneratedBuild>(); selectionFile = Path.Combine(folder, "builds_escolhidas.txt"); editsFile = Path.Combine(folder, "ajustes_das_builds.txt"); LoadCustom(); try { if (File.Exists(editsFile)) { string[] array = File.ReadAllLines(editsFile); foreach (string text in array) { string[] array2 = text.Split('='); if (array2.Length == 2 && int.TryParse(array2[1], out var result)) { edits[array2[0]] = result; } } } } catch { } try { if (!File.Exists(selectionFile)) { return; } string[] array3 = File.ReadAllLines(selectionFile); foreach (string text2 in array3) { string[] array4 = text2.Split('='); if (array4.Length == 2) { selections[array4[0]] = array4[1]; } } } catch { } } public static string ProfileKey(string bodyToken) { if (string.IsNullOrEmpty(bodyToken)) { return string.Empty; } return bodyToken.EndsWith("_BODY_NAME", StringComparison.OrdinalIgnoreCase) ? bodyToken.Substring(0, bodyToken.Length - "_BODY_NAME".Length) : bodyToken; } public void Update(string bodyToken, string bodyName, BaseStats stats, CombatProfile combat, double danger, double difficulty, IEnumerable<ItemCard> catalog) { string text = ProfileKey(bodyToken); updates++; inventory.Clear(); cards.Clear(); hexCount = 0; Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); Dictionary<string, string> tiers = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); foreach (ItemCard item in catalog) { if (!string.IsNullOrEmpty(item.Token)) { cards[item.Token] = item; if (!string.IsNullOrEmpty(item.Description)) { dictionary[item.Token] = item.Description; } if (item.Tier == "Hex") { hexCount += item.PermanentCount; } if (item.Count > 0) { inventory[item.Token] = item.Count; } if (item.Category == "Item" && item.IsEligible && !item.Hidden && PlanTiers.Contains(item.Tier)) { tiers[item.Token] = item.Tier; } } } Objective objective = new Objective { Survival = Math.Min(1.4, 0.55 + 0.05 * Math.Max(0.0, difficulty) + danger * 4.0), Mobility = 0.25 }; engine = new BuildEngine(combat, stats, objective, dictionary, FallbackValue); string text2 = text + "|" + tiers.Count + PlanVariant; if (text2 != planSignature) { planSignature = text2; pendingKey = text; pendingName = bodyName; pendingProfile = SurvivorProfiles.Find(bodyToken); pendingSignature = text2; if (planCache.TryGetValue(text2, out var value)) { pendingPlan = null; FinishPlan(value); return; } BuildEngine planner = engine; IList<BuildArchetype> signatureBuilds = SurvivorBuilds.For(text); pendingPlan = Task.Run(() => planner.GenerateBuilds(tiers, signatureBuilds)); } else if (pendingPlan == null) { survivorKey = text; SurvivorName = bodyName; lastTiers = tiers; FollowProgress(); } } private void FollowProgress() { if (Selected == null || lastTiers == null) { return; } if (inventory.Count == 0) { if (tierLevels.Count > 0 && planCache.TryGetValue(planSignature, out var value)) { FinishPlan(value); } return; } KeyValuePair<string, int>[] levelSteps = LevelSteps; for (int i = 0; i < levelSteps.Length; i++) { KeyValuePair<string, int> step = levelSteps[i]; string value3; List<KeyValuePair<string, int>> list = Selected.Targets.Where((KeyValuePair<string, int> goal) => lastTiers.TryGetValue(goal.Key, out value3) && value3 == step.Key).ToList(); if (list.Count != 0 && !list.Any((KeyValuePair<string, int> goal) => OwnedOf(goal.Key) < goal.Value)) { tierLevels.TryGetValue(step.Key, out var value2); value2 = Math.Max(value2, 1) + 1; tierLevels[step.Key] = value2; Objective objective = Selected.Archetype.Objective; BuildEngine buildEngine = ((objective == null) ? engine : engine.WithObjective(objective)); List<string> pool = Selected.Archetype.Tokens.Concat(Selected.Targets.Keys).ToList(); int num = Selected.Targets.Values.Sum(); buildEngine.Extend(Selected.Targets, pool, lastTiers, step.Key, step.Value, value2); if (Selected.Targets.Values.Sum() == num) { buildEngine.Extend(Selected.Targets, lastTiers.Keys, lastTiers, step.Key, step.Value, value2); } Revision++; } } } private void AddSurviveItems() { if (!surviveMode) { return; } foreach (GeneratedBuild build in Builds) { KeyValuePair<string, int>[] surviveItems = SurviveItems; for (int i = 0; i < surviveItems.Length; i++) { KeyValuePair<string, int> keyValuePair = surviveItems[i]; if (cards.TryGetValue(keyValuePair.Key, out var value) && value.IsEligible && !value.Hidden) { build.Targets.TryGetValue(keyValuePair.Key, out var value2); if (value2 < keyValuePair.Value) { build.Targets[keyValuePair.Key] = keyValuePair.Value; } } } } } public double ScrapValue(ItemCard card) { string token = card.Token ?? string.Empty; if (LeftFor(token) > 0 || card.Tier == "Boss") { return -1.0; } int num = OwnedOf(token) - TargetOf(token); if (num <= 0) { return -1.0; } return (TargetOf(token) > 0) ? 50.0 : (100.0 - Math.Max(0.0, Math.Min(99.0, (engine == null) ? 0.0 : engine.Gain(inventory, token).Score))); } public void Poll() { if (pendingPlan != null && pendingPlan.IsCompleted) { Task<List<GeneratedBuild>> task = pendingPlan; pendingPlan = null; if (task.IsFaulted) { Debug.LogWarning((object)("[RoR2 Build Assistant] Cálculo das builds falhou: " + task.Exception.GetBaseException().Message)); return; } planCache[pendingSignature] = task.Result; FinishPlan(task.Result); } } private void FinishPlan(List<GeneratedBuild> plan) { survivorKey = pendingKey; SurvivorName = pendingName; profile = pendingProfile; Builds = plan.Select((GeneratedBuild build) => new GeneratedBuild { Archetype = build.Archetype, Targets = new Dictionary<string, int>(build.Targets, StringComparer.OrdinalIgnoreCase), Order = build.Order, Rating = build.Rating, DamagePercent = build.DamagePercent, SurvivalPercent = build.SurvivalPercent }).ToList(); tierLevels.Clear(); AddSurviveItems(); ApplyEdits(); AddCustomBuild(); Selected = (selections.TryGetValue(survivorKey, out var chosen) ? Builds.FirstOrDefault((GeneratedBuild build) => build.Archetype.Key == chosen) : null); if (Selected == null) { Selected = Builds.FirstOrDefault(); } Revision++; try { Debug.Log((object)("[RoR2 Build Assistant] Builds de " + survivorKey + ": " + Builds.Count + " (" + pendingSignature + " itens disponíveis), escolhida: " + ((Selected == null) ? "nenhuma" : Selected.Name))); } catch (Exception) { } } public string[] StatsLines(bool showNow) { string text = Revision + "|" + updates + "|" + showNow; if (text == statsKey) { return statsLines; } statsKey = text; if (engine == null || Selected == null) { statsLines = new string[0]; return statsLines; } Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); CombatResult combatResult = engine.Evaluate(dictionary); CombatResult combatResult2 = engine.Evaluate(inventory); CombatResult combatResult3 = engine.Evaluate(Selected.Targets); string text2 = (showNow ? "<pos=50%>base<pos=68%>agora<pos=85%>build" : "<pos=62%>base<pos=82%>build"); Func<string, string, string, string, string> func = (string label, string a, string b, string c) => label + (showNow ? ("<pos=50%>" + a + "<pos=68%>" + b + "<pos=85%>" + c) : ("<pos=62%>" + a + "<pos=82%>" + c)); List<string> list = new List<string> { "<style=cStack>" + text2 + "</style>", func("Velocidade de ataque", Mult(combatResult.AttackSpeed), Mult(combatResult2.AttackSpeed), "<style=cIsDamage>" + Mult(combatResult3.AttackSpeed) + "</style>"), func("Chance de crítico", Pct(combatResult.Crit), Pct(combatResult2.Crit), "<style=cIsDamage>" + Pct(combatResult3.Crit) + "</style>"), func("Vida", Whole(combatResult.Health), Whole(combatResult2.Health), "<style=cIsHealing>" + Whole(combatResult3.Health) + "</style>"), func("Bloqueio", Pct(combatResult.Block), Pct(combatResult2.Block), "<style=cIsHealing>" + Pct(combatResult3.Block) + "</style>"), func("Velocidade (m/s)", One(combatResult.Speed), One(combatResult2.Speed), "<style=cIsUtility>" + One(combatResult3.Speed) + "</style>"), func("Dano total", "x1.0", Mult(combatResult2.Dps / Math.Max(combatResult.Dps, 0.01)), "<style=cIsDamage>" + Mult(combatResult3.Dps / Math.Max(combatResult.Dps, 0.01)) + "</style>"), func("Aguenta (vida efetiva)", "x1.0", Mult(combatResult2.Effective / Math.Max(combatResult.Effective, 1.0)), "<style=cIsHealing>" + Mult(combatResult3.Effective / Math.Max(combatResult.Effective, 1.0)) + "</style>") }; statsLines = list.ToArray(); return statsLines; } private static string Mult(double value) { return "x" + ((value >= 100.0) ? Math.Round(value).ToString() : value.ToString("0.0", CultureInfo.InvariantCulture)); } private static string Pct(double value) { return Math.Round(value * 100.0) + "%"; } private static string Whole(double value) { return Math.Round(value).ToString(); } private static string One(double value) { return value.ToString("0.0", CultureInfo.InvariantCulture); } private void ApplyEdits() { foreach (GeneratedBuild build in Builds) { string prefix = survivorKey + "|" + build.Archetype.Key + "|"; foreach (KeyValuePair<string, int> item in edits.Where((KeyValuePair<string, int> entry) => entry.Key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList()) { string key = item.Key.Substring(prefix.Length); if (item.Value <= 0) { build.Targets.Remove(key); } else { build.Targets[key] = item.Value; } } } } public void Adjust(string token, int delta) { if (Selected == null || string.IsNullOrEmpty(survivorKey)) { return; } Selected.Targets.TryGetValue(token, out var value); int num = Math.Max(0, Math.Min(99, value + delta)); if (num == value) { return; } if (IsCustom) { if (num == 0) { Selected.Targets.Remove(token); } else { Selected.Targets[token] = num; } custom[survivorKey] = new Dictionary<string, int>(Selected.Targets, StringComparer.OrdinalIgnoreCase); Revision++; SaveCustom(); return; } edits[survivorKey + "|" + Selected.Archetype.Key + "|" + token] = num; if (num == 0) { Selected.Targets.Remove(token); } else { Selected.Targets[token] = num; } Revision++; SaveEdits(); } public void ResetEdits() { if (Selected == null) { return; } string prefix = survivorKey + "|" + Selected.Archetype.Key + "|"; foreach (string item in edits.Keys.Where((string candidate) => candidate.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList()) { edits.Remove(item); } planSignature = ""; Revision++; SaveEdits(); } private void SaveEdits() { try { Directory.CreateDirectory(Path.GetDirectoryName(editsFile)); File.WriteAllLines(editsFile, edits.Select((KeyValuePair<string, int> pair) => pair.Key + "=" + pair.Value).ToArray()); } catch { } } public void CycleBuild(int direction) { if (Builds.Count != 0) { int num = Math.Max(0, Builds.IndexOf(Selected)); Select(Builds[(num + direction + Builds.Count) % Builds.Count]); } } public void Select(GeneratedBuild build) { Selected = build; tierLevels.Clear(); selections[survivorKey] = build.Archetype.Key; Revision++; SaveSelections(); } private void SaveSelections() { try { Directory.CreateDirectory(Path.GetDirectoryName(selectionFile)); File.WriteAllLines(selectionFile, selections.Select((KeyValuePair<string, string> pair) => pair.Key + "=" + pair.Value).ToArray()); } catch { } } private double FallbackValue(string token) { if (!cards.TryGetValue(token, out var value)) { return 0.0; } BuildTag[] array = ItemCatalogTags.For(token, value.Category == "Equipamento"); if (array.Length == 0) { return 0.0; } int value2; return (double)array.Max((BuildTag tag) => profile.Weights.TryGetValue(tag, out value2) ? value2 : 0) * 0.8; } public List<BarEntry> Bar() { return EntriesFor(Selected); } public List<BarEntry> EntriesFor(GeneratedBuild build, bool stable = false) { if (build == null) { return new List<BarEntry>(); } IEnumerable<BarEntry> source = from target in build.Targets where cards.ContainsKey(target.Key) select new BarEntry { Card = cards[target.Key], Target = target.Value, Owned = OwnedOf(target.Key) }; if (stable) { return (from entry in source orderby TierOrder(entry.Card.Tier), entry.Card.Name select entry).ToList(); } return (from entry in source orderby entry.Remaining == 0, TierOrder(entry.Card.Tier), entry.Remaining descending select entry).ToList(); } public int LeftFor(string token) { return Math.Max(0, TargetOf(token) - OwnedOf(token)); } public int TargetOf(string token) { int value; return (Selected != null && Selected.Targets.TryGetValue(token, out value)) ? value : 0; } public List<ItemCard> Catalog(string tier) { return (from card in cards.Values where card.Category == "Item" && card.IsEligible && !card.Hidden && card.Tier == tier orderby OptionValue(card) descending, card.Name select card).ToList(); } private void LoadCustom() { try { if (!File.Exists(CustomFile)) { return; } string[] array = File.ReadAllLines(CustomFile); foreach (string text in array) { string[] array2 = text.Split('='); if (array2.Length != 2) { continue; } Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); string[] array3 = array2[1].Split(','); foreach (string text2 in array3) { string[] array4 = text2.Split(':'); if (array4.Length == 2 && int.TryParse(array4[1], out var result) && result > 0) { dictionary[array4[0]] = result; } } custom[array2[0]] = dictionary; } } catch { } } private void SaveCustom() { try { Directory.CreateDirectory(Path.GetDirectoryName(CustomFile)); File.WriteAllLines(CustomFile, custom.Select((KeyValuePair<string, Dictionary<string, int>> pair) => pair.Key + "=" + string.Join(",", pair.Value.Select((KeyValuePair<string, int> item) => item.Key + ":" + item.Value).ToArray())).ToArray()); } catch { } } private void AddCustomBuild() { if (custom.TryGetValue(survivorKey, out var value)) { Builds.Add(new GeneratedBuild { Archetype = new BuildArchetype { Key = "minha", Name = "Minha build", Why = "Montada por você: use Editar build para escolher os itens e as quantidades.", Tokens = new string[0] }, Targets = new Dictionary<string, int>(value, StringComparer.OrdinalIgnoreCase) }); } } public void NewCustomBuild() { if (Selected != null && !string.IsNullOrEmpty(survivorKey)) { custom[survivorKey] = new Dictionary<string, int>(Selected.Targets, StringComparer.OrdinalIgnoreCase); selections[survivorKey] = "minha"; planSignature = ""; Revision++; SaveCustom(); SaveSelections(); } } public void DeleteCustomBuild() { if (IsCustom) { custom.Remove(survivorKey); selections.Remove(survivorKey); planSignature = ""; Revision++; SaveCustom(); SaveSelections(); } } private static int TierOrder(string tier) { return (!(tier == "Tier3")) ? ((tier == "Tier2") ? 1 : 2) : 0; } private int OwnedOf(string token) { inventory.TryGetValue(token, out var value); inventory.TryGetValue(token + "CONSUMED", out var value2); return value + value2; } public int MatchPercent(GeneratedBuild build) { List<KeyValuePair<string, int>> source = inventory.Where((KeyValuePair<string, int> pair) => BuildEngine.IsModeled(pair.Key) && cards.ContainsKey(pair.Key) && cards[pair.Key].Tier != "Hex").ToList(); int num = source.Sum((KeyValuePair<string, int> pair) => pair.Value); if (num == 0) { return 0; } int value; int num2 = source.Sum((KeyValuePair<string, int> pair) => build.Targets.TryGetValue(pair.Key, out value) ? Math.Min(pair.Value, value) : 0); return num2 * 100 / num; } public string DescribeBuild(GeneratedBuild build) { IEnumerable<string> source = from target in build.Targets where cards.ContainsKey(target.Key) orderby TierOrder(cards[target.Key].Tier) select target.Value + "x " + cards[target.Key].Name; string text = build.Why + "\n\n<style=cIsDamage>Itens:</style> " + string.Join(", ", source.ToArray()); List<string> source2 = build.Order.Where((string token) => cards.ContainsKey(token)).ToList(); List<string> list = (from token in source2 where cards[token].Tier == "Tier1" || cards[token].Tier == "Tier2" || cards[token].Tier == "VoidTier1" || cards[token].Tier == "VoidTier2" select cards[token].Name).ToList(); List<string> list2 = (from token in source2 where cards[token].Tier != "Tier1" && cards[token].Tier != "Tier2" && cards[token].Tier != "VoidTier1" && cards[token].Tier != "VoidTier2" select cards[token].Name).ToList(); if (list.Count >= 3) { int count = (int)Math.Ceiling((double)list.Count / 2.0); text = text + "\n\n<style=cIsHealing>Prioridade:</style>\n1. Comece por: " + string.Join(", ", list.Take(count).ToArray()) + "\n2. Depois: " + string.Join(", ", list.Skip(count).ToArray()); if (list2.Count > 0) { text = text + "\n3. Se aparecer, pegue: " + string.Join(", ", list2.ToArray()); } } if (build.Archetype.Key != "minha") { text = text + "\n\n<style=cIsUtility>Ao completar (estimativa):</style> " + Signed(build.DamagePercent) + " dano, " + Signed(build.SurvivalPercent) + " sobrevivência."; } return text; } private static string Signed(double value) { return ((value >= 0.0) ? "+" : "") + Math.Round(value) + "%"; } public string TooltipForBarEntry(BarEntry entry) { List<string> list = new List<string>(); list.Add(string.IsNullOrEmpty(entry.Card.NativeDescription) ? "Descrição indisponível." : entry.Card.NativeDescription); list.Add(string.Empty); list.Add((entry.Remaining > 0) ? ("<style=cIsHealing>Faltam " + entry.Remaining + " de " + entry.Target + "</style> na build " + Selected.Name + ".") : ("<style=cIsHealing>Meta cumprida (" + entry.Target + ").</style> Cópias extras ainda somam, mas outros itens rendem mais.")); AppendWhy(list, entry.Card); return string.Join("\n", list.ToArray()); } private void AppendWhy(List<string> lines, ItemCard card) { if (engine != null) { string text = BuildEngine.NoteFor(card.Token); if (text != null) { lines.Add("<style=cIsUtility>Por quê:</style> " + text + "."); } if (BuildEngine.IsModeled(card.Token)) { lines.Add("<style=cIsDamage>Próxima cópia:</style> " + engine.Gain(inventory, card.Token).Describe() + "."); } } } public string TooltipForOption(ItemCard card) { List<string> list = new List<string>(); list.Add(string.IsNullOrEmpty(card.NativeDescription) ? "Descrição indisponível." : card.NativeDescription); list.Add(string.Empty); list.Add(OptionReason(card)); return string.Join("\n", list.ToArray()); } public string OptionReason(ItemCard card) { string token = card.Token ?? string.Empty; if (card.Tier == "Hex") { return "<style=cDeath>Maldição:</style> só tem penalidade" + ((engine != null && BuildEngine.IsModeled(token)) ? (" (" + engine.Gain(inventory, token).Describe() + ")") : "") + ". " + HexAdvice(); } if (Utility.TryGetValue(token, out var value)) { return "<style=cIsUtility>" + Cap(value.Value) + ".</style>"; } if (token.StartsWith("AFFIX", StringComparison.OrdinalIgnoreCase)) { return "<style=cIsUtility>Dá o poder de uma elite enquanto estiver equipado.</style>"; } List<string> list = new List<string>(); if (Selected != null && Selected.Targets.TryGetValue(token, out var value2)) { int num = Math.Max(0, value2 - OwnedOf(token)); list.Add("<style=cIsHealing>" + ((num > 0) ? ("Da sua build: faltam " + num + " de " + value2) : ("Meta da build já cumprida (" + value2 + ")")) + ".</style>"); } else { GeneratedBuild generatedBuild = Builds.FirstOrDefault((GeneratedBuild build) => build.Targets.ContainsKey(token)); if (generatedBuild != null) { list.Add("<style=cStack>Fora da sua build, mas serve para " + generatedBuild.Name + ".</style>"); } else if (Selected != null) { list.Add("<style=cStack>Fora da sua build.</style>"); } } if (engine != null) { string text = BuildEngine.NoteFor(token); if (BuildEngine.IsModeled(token)) { list.Add("<style=cIsDamage>Agora:</style> " + engine.Gain(inventory, token).Describe() + ((text != null) ? (" — " + text) : "") + "."); } else if (ItemCatalogTags.For(token, card.Category == "Equipamento").Length != 0) { list.Add("<style=cSub>Efeito sem cálculo exato; avaliado pelo tipo do item.</style>"); } else { list.Add("<style=cSub>Sem dados deste item; leia a descrição.</style>"); } } return string.Join("\n", list.ToArray()); } private static string Cap(string text) { return string.IsNullOrEmpty(text) ? text : (char.ToUpperInvariant(text[0]) + text.Substring(1)); } public double OptionValue(ItemCard card) { string text = card.Token ?? string.Empty; if (engine == null) { return 0.0; } if (Selected != null && Selected.Targets.TryGetValue(text, out var value) && OwnedOf(text) < value) { return 1000.0 + PickPriority(card, text) + Math.Max(0.0, PickPlanner().Gain(inventory, text).Score); } if (Utility.TryGetValue(text, out var value2)) { return value2.Key; } if (text.StartsWith("AFFIX", StringComparison.OrdinalIgnoreCase)) { return 4.0; } if (card.Category == "Equipamento" && card.Count > 0) { return -3.0; } double score = engine.Gain(inventory, text).Score; if (card.Tier.IndexOf("Lunar", StringComparison.OrdinalIgnoreCase) >= 0) { return Math.Min(score - 2.0, 0.4); } return Math.Min(score, 999.0); } private bool IsCore(string token) { return ((Selected == null) ? null : Selected.Archetype.Core)?.Contains<string>(token, StringComparer.OrdinalIgnoreCase) ?? (!DefenseItems.Contains(token) && !MovementItems.Contains(token)); } private double PickPriority(ItemCard card, string token) { Objective objective = Selected.Archetype.Objective; double num = ((objective == null) ? 1.0 : Math.Max(objective.Damage, 0.1)); double num2 = (objective?.Survival ?? 0.7) / num / 2.0 * (double)((!GlassRun) ? 1 : 2) * (surviveMode ? 1.5 : 1.0); double num3 = (objective?.Mobility ?? 0.8) / num / 4.0; int num4 = 0; int num5 = 0; int num6 = 0; foreach (KeyValuePair<string, int> item in inventory) { if (DefenseItems.Contains(item.Key)) { num5 += item.Value; } else if (MovementItems.Contains(item.Key)) { num6 += item.Value; } else { num4 += item.Value; } } if (DefenseItems.Contains(token)) { return ((double)num5 < Math.Floor((double)num4 * num2)) ? 850 : 300; } if (MovementItems.Contains(token)) { return ((double)num6 < Math.Floor((double)num4 * num3)) ? 840 : 400; } if (card.Tier == "Tier3" || card.Tier == "Boss") { return 900.0; } return IsCore(token) ? 800 : 500; } private BuildEngine PickPlanner() { Objective objective = ((Selected == null) ? null : Selected.Archetype.Objective); if (objective == null) { return engine; } return engine.WithObjective(new Objective { Damage = objective.Damage * (FastKill ? 1.3 : 1.0) * (GlassRun ? 0.7 : 1.0), Survival = objective.Survival * (GlassRun ? 1.5 : 1.0), Mobility = objective.Mobility }); } public string SynergyLine() { if (engine == null) { return null; } List<string> pool = (from card in cards.Values where card.Category == "Item" && card.IsEligible && !card.Hidden && BuildTiers.Contains(card.Tier) select card.Token).ToList(); if (!engine.BestSynergy(inventory, pool, out var owned, out var other, out var extra) || extra < 1.0) { return null; } return "<style=cIsUtility>Combo:</style> com " + NameOf(owned) + " você ganha muito mais com " + NameOf(other) + "."; } public string SwapLine() { if (engine == null) { return null; } foreach (string tier in BuildTiers) { List<string> list = (from card in cards.Values where card.Tier == tier && card.Count > 0 && !card.Hidden select card.Token).ToList(); List<string> sameTierPool = (from card in cards.Values where card.Tier == tier && card.IsEligible && !card.Hidden select card.Token).ToList(); if (list.Count > 0 && engine.BestSwap(inventory, list, sameTierPool, out var sell, out var buy, out var net) && net >= 3.0) { return "<style=cIsUtility>Troca que compensa:</style> use " + NameOf(sell) + " em uma impressora de " + NameOf(buy) + "."; } } return null; } private string NameOf(string token) { ItemCard value; return cards.TryGetValue(token, out value) ? value.Name : token; } public string HexAdvice() { string text = ((hexCount <= 0) ? "nada ainda" : ((hexCount == 1) ? "1 escolha comum" : ((hexCount <= 3) ? "2 escolhas: comum e incomum" : ((hexCount == 4) ? "2 escolhas, com todas as opções incomuns" : ((hexCount > 6) ? "3 escolhas: Santificado ou Lendário na última" : "3 escolhas, com item Santificado quase certo"))))); string text2 = ((hexCount < 5) ? ("Faltam " + (5 - hexCount) + " para liberar item Santificado.") : ((hexCount >= 7) ? "Purifique já: a Mão da Vida drena 7 por vez e pode ser usada de novo." : ("Faltam " + (7 - hexCount) + " para liberar a opção Lendária."))); return "Com " + hexCount + " na Mão da Vida do Templo Santificado: " + text + ". " + text2 + " A Mão da Morte dá mais 3 por jogador, mas fecha o templo."; } } internal sealed class CombatProfile { public double HitsPerSecond = 2.0; public double HitPercent = 2.0; public double ProcCoefficient = 1.0; public double AttackSpeedShare = 0.7; public double CooldownShare = 0.3; public double SecondaryShare = 0.15; public double NearShare = 0.3; public double BossShare = 0.25; public double FirstHitShare = 0.15; public double BigHitShare = 0.1; public double Targets = 1.5; public double KillsPerSecond = 0.4; public double SprintShare = 0.4; public double StillShare = 0.1; public double SpeedDamageShare; public double DebuffShare = 0.15; public double CritValue = 1.0; public bool CritBecomesDamage; public CombatProfile With(double debuffs = -1.0, double critValue = -1.0, bool critBecomesDamage = false) { if (debuffs >= 0.0) { DebuffShare = debuffs; } if (critValue >= 0.0) { CritValue = critValue; } CritBecomesDamage = critBecomesDamage; return this; } public CombatProfile Clone() { return (CombatProfile)MemberwiseClone(); } } internal sealed class BaseStats { public double Damage = 12.0; public double Health = 110.0; public double Regen = 1.0; public double Armor; public double Speed = 7.0; public double Crit = 0.01; } internal sealed class Objective { public double Damage = 1.0; public double Survival = 0.7; public double Mobility = 0.25; } internal sealed class CombatState { public double AttackSpeed; public double DamageMult = 1.0; public double Crit; public double CritMult = 2.0; public double Near; public double First; public double Boss; public double CooldownMult = 1.0; public double SecondaryCharges; public double Luck; public double FlatHealth; public double HealthMult = 1.0; public double ShieldPercent; public double Armor; public double SprintArmor; public double BlockStacks; public double Speed; public double SprintSpeed; public double LifePerHit; public double LifePerCrit; public double RegenFlat; public double StillHealPercent; public double HealOnKillFlat; public double HealOnKillPercent; public double BarrierOnKill; public double MedkitPercent; public double HealingMult = 1.0; public double CritAttackSpeedCap; public double BandDamage; public double KillDamage; public double InstantKillChance; public double LifeSteal; public double DpsMult = 1.0; public double EffectiveMult = 1.0; public double EliteExecute; public double Debuffs; public double PulseBase; public double HealDamage; public double BarrierFromHealing; public int TeslaCopies; public bool DeathMark; public readonly List<ProcEffect> Procs = new List<ProcEffect>(); } internal struct ProcEffect { public double Chance; public double Damage; public bool Total; public double Targets; } internal sealed class ItemEffect { public string Token; public string Note; public double[] Defaults; public Action<CombatState, int, double[]> Apply; } internal struct CombatResult { public double Dps; public double Effective; public double Speed; public double Score; public double AttackSpeed; public double Crit; public double Health; public double Block; } internal struct ItemGain { public string Token; public double Score; public double Dps; public double Effective; public double Speed; public string Describe() { List<string> list = new List<string>(); if (Math.Abs(Dps) >= 0.5) { list.Add(Signed(Dps) + " dano"); } if (Math.Abs(Effective) >= 0.5) { list.Add(Signed(Effective) + " sobrevivência"); } if (Math.Abs(Speed) >= 0.5) { list.Add(Signed(Speed) + " velocidade"); } return (list.Count == 0) ? "quase sem efeito agora" : string.Join(", ", list); } private static string Signed(double value) { return ((value >= 0.0) ? "+" : "") + Math.Round(value).ToString(CultureInfo.InvariantCulture) + "%"; } } internal sealed class PlanStep { public string Token; public int Copies; public ItemGain Gain; } internal sealed class BuildArchetype { public string Key; public string Name; public string Why; public Objective Objective; public string[] Tokens; public bool NeedsVoid; public string[] Must; public string[] Core; } internal sealed class GeneratedBuild { public BuildArchetype Archetype; public Dictionary<string, int> Targets; public List<string> Order = new List<string>(); public double Rating; public double DamagePercent; public double SurvivalPercent; public string Name => Archetype.Name; public string Why => Archetype.Why; } internal sealed class BuildEngine { private const int CommonQuota = 34; private const int UncommonQuota = 13; private const int LegendaryQuota = 4; private const int BossQuota = 3; private const int LunarQuota = 2; private const int CursedQuota = 2; private static readonly Dictionary<string, int> ItemCaps = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "DEATHMARK", 1 }, { "ARMORREDUCTIONONHIT", 1 }, { "WARDONLEVEL", 1 }, { "SLOWONHIT", 1 }, { "FEATHER", 3 }, { "INCREASEDAMAGEONMULTIKILL", 5 }, { "DELAYEDDAMAGE", 2 }, { "VENGEFULSPIRIT", 1 }, { "JUMPDAMAGESTRIKE", 2 }, { "EXECUTELOWHEALTHELITE", 2 }, { "PHASING", 2 }, { "TELEPORTONLOWHEALTH", 2 }, { "THORNS", 2 } }; private static readonly string[] SpeedItems = new string[9] { "HOOF", "SPRINTBONUS", "ATTACKSPEEDANDMOVESPEED", "POWERPYRAMID", "FEATHER", "SPRINTOUTOFCOMBAT", "JUMPBOOST", "MOVESPEEDONKILL", "UTILITYSKILLMAGAZINE" }; private static readonly string[] HealthItems = new string[14] { "BEAR", "FLATHEALTH", "COOKEDSTEAK", "INFUSION", "PERSONALSHIELD", "SPRINTARMOR", "KNURL", "BARRIERONKILL", "TOOTH", "MEDKIT", "SEED", "MUSHROOM", "HEALWHILESAFE", "INCREASEHEALING" }; private static readonly string[] CritItems = new string[4] { "CRITGLASSES", "ATTACKSPEEDONCRIT", "HEALONCRIT", "CRITDAMAGE" }; private static readonly string[] ProcItems = new string[11] { "SYRINGE", "MISSILE", "CHAINLIGHTNING", "BLEEDONHIT", "STICKYBOMB", "BOUNCENEARBY", "FIREBALLSONHIT", "LIGHTNINGSTRIKEONHIT", "CLOVER", "ATTACKSPEEDANDMOVESPEED", "POWERORB" }; private static readonly string[] ExplosionItems = new string[10] { "BEHEMOTH", "IGNITEONKILL", "EXPLODEONDEATH", "STICKYBOMB", "DAGGER", "CHAINLIGHTNING", "FIREBALLSONHIT", "ICERING", "FIRERING", "BOUNCENEARBY" }; private static readonly string[] BossItems = new string[10] { "CROWBAR", "BOSSDAMAGEBONUS", "FIRERING", "ICERING", "LIGHTNINGSTRIKEONHIT", "BLEEDONHIT", "FRAGILEDAMAGEBONUS", "SECONDARYSKILLMAGAZINE", "ALIENHEAD", "CRITDAMAGE" }; private static readonly string[] AttackSpeedItems = new string[8] { "SYRINGE", "ATTACKSPEEDANDMOVESPEED", "POWERORB", "ATTACKSPEEDONCRIT", "CRITGLASSES", "BEHEMOTH", "BOUNCENEARBY", "FIREBALLSONHIT" }; private static readonly string[] SustainItems = new string[9] { "HEALONCRIT", "SEED", "TOOTH", "INFUSION", "MEDKIT", "INCREASEHEALING", "COOKEDSTEAK", "CRITGLASSES", "ATTACKSPEEDONCRIT" }; private static readonly string[] ShieldItems = new string[8] { "PERSONALSHIELD", "BARRIERONKILL", "BEAR", "SPRINTARMOR", "KNURL", "FLATHEALTH", "MISSILEVOID", "MEDKIT" }; private static readonly string[] LuckItems = new string[10] { "CLOVER", "BLEEDONHIT", "STICKYBOMB", "MISSILE", "CHAINLIGHTNING", "FIREBALLSONHIT", "LIGHTNINGSTRIKEONHIT", "BOUNCENEARBY", "CRITGLASSES", "HEALONCRIT" }; private static readonly string[] CloseItems = new string[10] { "NEARBYDAMAGEBONUS", "BEHEMOTH", "KNURL", "COOKEDSTEAK", "SEED", "BEAR", "FLATHEALTH", "BARRIERONKILL", "IGNITEONKILL", "SYRINGE" }; private static readonly string[] GlassItems = new string[9] { "CRITDAMAGE", "CRITGLASSES", "CROWBAR", "FRAGILEDAMAGEBONUS", "LUNARDAGGER", "ATTACKSPEEDONCRIT", "BOSSDAMAGEBONUS", "SPRINTBONUS", "HOOF" }; private static readonly string[] VoidItems = new string[7] { "CRITGLASSESVOID", "BEARVOID", "MISSILEVOID", "CHAINLIGHTNINGVOID", "BLEEDONHITVOID", "MUSHROOMVOID", "EXPLODEONDEATHVOID" }; private static readonly string[] CooldownItems = new string[6] { "ALIENHEAD", "BANDOLIER", "SECONDARYSKILLMAGAZINE", "UTILITYSKILLMAGAZINE", "FIRERING", "ICERING" }; internal static readonly BuildArchetype[] Archetypes = new BuildArchetype[16] { Archetype("cadencia", "Cadência e efeitos", "Muitos golpes por segundo, e cada um ativa efeitos.", 1.2, 0.4, 0.1, ProcItems, new string[1] { "BEAR" }), Archetype("critico", "Crítico", "Chegue a 100% de crítico e transforme isso em dano e cura.", 1.2, 0.5, 0.1, CritItems, new string[1] { "SYRINGE" }), Archetype("speed", "Speed", "Sempre em movimento: difícil de acertar e chega em tudo primeiro.", 0.5, 0.2, 1.6, SpeedItems, new string[4] { "SYRINGE", "CRITGLASSES", "MISSILE", "CHAINLIGHTNING" }), Archetype("speedvida", "Speed + Vida", "Corre muito e aguenta os erros.", 0.3, 1.1, 1.0, SpeedItems, HealthItems), Archetype("speedcritvida", "Speed + Crítico + Vida", "Equilíbrio entre fugir, matar e sobreviver.", 0.9, 0.8, 0.7, SpeedItems, CritItems, HealthItems), Archetype("explosao", "Explosão", "Dano em área e abates em cadeia para limpar grupos.", 1.3, 0.4, 0.1, ExplosionItems, new string[2] { "SYRINGE", "CRITGLASSES" }), Archetype("tanque", "Tanque", "Vida, bloqueio e cura para nunca sair da luta.", 0.3, 1.6, 0.1, HealthItems, new string[1] { "SYRINGE" }), Archetype("chefes", "Caça-chefes", "Dano concentrado em um alvo, para o Teleportador e os chefes.", 1.4, 0.3, 0.1, BossItems, new string[2] { "CRITGLASSES", "SYRINGE" }), Archetype("recarga", "Recarga", "Habilidades sempre prontas.", 1.1, 0.5, 0.2, CooldownItems, new string[2] { "SYRINGE", "CRITGLASSES" }), Archetype("metralhadora", "Metralhadora", "Cadência de ataque no máximo: cada clique vale mais e os efeitos disparam sem parar.", 1.5, 0.3, 0.2, AttackSpeedItems, new string[3] { "CRITGLASSES", "BLEEDONHIT", "STICKYBOMB" }), Archetype("vampiro", "Vampiro", "Cura em cada acerto, crítico e abate: o dano que você causa é a sua vida.", 0.9, 1.0, 0.2, SustainItems, new string[5] { "SYRINGE", "CRITGLASSES", "HEALONCRIT", "SEED", "TOOTH" }), Archetype("escudo", "Escudo e barreira", "Escudo grande, bloqueio e barreira por abate: o dano some antes de chegar na vida.", 0.5, 1.4, 0.3, ShieldItems, new string[2] { "SYRINGE", "MISSILE" }), Archetype("sortudo", "Sortudo", "Trevo de Quatro Folhas faz todo efeito rolar duas vezes: muitos efeitos baratos viram dano pesado.", 1.2, 0.5, 0.2, LuckItems, new string[2] { "SYRINGE", "BEAR" }), Archetype("perto", "Corpo a corpo", "Dano extra de perto, explosões a cada golpe e vida para aguentar a briga.", 1.3, 0.9, 0.3, CloseItems, new string[2] { "SYRINGE", "BEAR" }), Archetype("vidro", "Canhão de vidro", "Dano máximo e vida mínima: crítico gigante e golpe de abertura. Arriscado e muito forte.", 1.8, 0.1, 0.6, GlassItems, new string[2] { "SYRINGE", "HOOF" }), VoidArchetype() }; private static readonly Dictionary<string, ItemEffect> Effects = BuildEffects(); internal static readonly Dictionary<string, string> Corrupts = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "CRITGLASSESVOID", "CRITGLASSES" }, { "BEARVOID", "BEAR" }, { "MISSILEVOID", "MISSILE" }, { "CHAINLIGHTNINGVOID", "CHAINLIGHTNING" }, { "BLEEDONHITVOID", "BLEEDONHIT" }, { "MUSHROOMVOID", "MUSHROOM" }, { "EXPLODEONDEATHVOID", "EXPLODEONDEATH" }, { "SLOWONHITVOID", "SLOWONHIT" }, { "EQUIPMENTMAGAZINEVOID", "EQUIPMENTMAGAZINE" }, { "ELEMENTALRINGVOID", "FIRERING" }, { "CLOVERVOID", "CLOVER" }, { "TREASURECACHEVOID", "TREASURECACHE" }, { "EXTRALIFEVOID", "EXTRALIFE" } }; private readonly CombatProfile profile; private readonly BaseStats stats; private readonly Objective objective; private readonly Dictionary<string, double[]> numbers; private readonly Func<string, double> fallback; private const int MaxBuilds = 10; private static readonly string[] CoreKit = new string[11] { "HOOF", "SPRINTBONUS", "ATTACKSPEEDANDMOVESPEED", "FEATHER", "SPRINTOUTOFCOMBAT", "PERSONALSHIELD", "BEAR", "REPULSIONARMORPLATE", "TELEPORTONLOWHEALTH", "EXECUTELOWHEALTHELITE", "EXTRALIFE" }; private static readonly Dictionary<string, double[]> ParsedText = new Dictionary<string, double[]>(); internal static IEnumerable<ItemEffect> AllEffects => Effects.Values; private static int MaxCopies(string token, string tier) { if (ItemCaps.TryGetValue(token, out var value)) { return value; } if (!(tier == "Tier1")) { if (tier == "Tier2") { return 6; } return 2; } return 14; } private static int AnchorCopies(string token, string tier) { if (string.Equals(token, "SEED", StringComparison.OrdinalIgnoreCase)) { return 5; } if (ItemCaps.TryGetValue(token, out var value)) { return value; } if (!(tier == "Tier1")) { if (tier == "Tier2") { return 3; } return 1; } return 5; } private static string QuotaTier(string tier) { return tier switch { "VoidTier1" => "Tier1", "VoidTier2" => "Tier2", "VoidTier3" => "Tier3", _ => tier, }; } private static BuildArchetype VoidArchetype() { BuildArchetype buildArchetype = Archetype("vazio", "Vazio", "Versões do Vazio dos itens: efeitos mais fortes, mas trocam os itens comuns. Só com a DLC ativa.", 1.0, 0.8, 0.2, VoidItems, new string[4] { "SYRINGE", "CRITGLASSES", "BEAR", "MISSILE" }); buildArchetype.NeedsVoid = true; return buildArchetype; } private static BuildArchetype Archetype(string key, string name, string why, double damage, double survival, double mobility, params string[][] families) { return new BuildArchetype { Key = key, Name = name, Why = why, Objective = new Objective { Damage = damage, Survival = survival, Mobility = mobility }, Tokens = families.SelectMany((string[] family) => family).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToArray() }; } public BuildEngine(CombatProfile profile, BaseStats stats, Objective objective, IDictionary<string, string> descriptions = null, Func<string, double> fallback = null) { this.profile = profile; this.stats = stats; this.objective = objective; this.fallback = fallback; numbers = new Dictionary<string, double[]>(StringComparer.OrdinalIgnoreCase); foreach (ItemEffect value2 in Effects.Values) { string value; double[] array = ((descriptions != null && descriptions.TryGetValue(value2.Token, out value)) ? ParseStackNumbers(value) : null); numbers[value2.Token] = ((array != null && array.Length >= value2.Defaults.Length) ? array : value2.Defaults); } } public BuildEngine WithObjective(Objective other) { return new BuildEngine(this, other); } private BuildEngine(BuildEngine source, Objective other) { profile = source.profile; stats = source.stats; objective = other; numbers = source.numbers; fallback = source.fallback; } public static bool IsModeled(string token) { return Effects.ContainsKey(token); } public static string NoteFor(string token) { ItemEffect value; return Effects.TryGetValue(token, out value) ? value.Note : null; } public CombatResult Evaluate(IDictionary<string, int> inventory) { CombatState combatState = new CombatState(); foreach (KeyValuePair<string, int> item in inventory) { if (item.Value > 0 && Effects.TryGetValue(item.Key, out var value)) { double[] array = numbers[item.Key]; double[] array2 = new double[array.Length / 2]; for (int i = 0; i < array2.Length; i++) { array2[i] = array[i * 2] + array[i * 2 + 1] * (double)(item.Value - 1); } value.Apply(combatState, item.Value, array2); } } return Compute(combatState); } private double Roll(double chance, double luck) { chance = Math.Max(0.0, Math.Min(1.0, chance)); return 1.0 - Math.Pow(1.0 - chance, 1.0 + luck); } private CombatResult Compute(CombatState s) { CombatProfile combatProfile = profile; double chance = Math.Min(1.0, stats.Crit + s.Crit); chance = Roll(chance, s.Luck); if (combatProfile.CritBecomesDamage) { s.CritMult += stats.Crit + s.Crit; chance = 0.85; } double num = 1.0 + chance * (s.CritMult - 1.0) * combatProfile.CritValue; double num2 = s.AttackSpeed + s.CritAttackSpeedCap * Math.Min(1.0, chance * combatProfile.HitsPerSecond / 1.5); double num3 = Math.Max(0.0, 1.0 - combatProfile.AttackSpeedShare - combatProfile.CooldownShare); double num4 = combatProfile.AttackSpeedShare * (1.0 + num2) + combatProfile.CooldownShare / s.CooldownMult + num3; num4 += combatProfile.SecondaryShare * 0.35 * s.SecondaryCharges; double num5 = combatProfile.HitsPerSecond * num4; double num6 = stats.Damage * s.DamageMult; double num7 = num6 * combatProfile.HitPercent * (1.0 + combatProfile.NearShare * s.Near) * (1.0 + combatProfile.FirstHitShare * s.First) * (1.0 + combatProfile.BossShare * s.Boss) * num * (1.0 + combatProfile.SpeedDamageShare * (s.Speed + combatProfile.SprintShare * s.SprintSpeed)); double num8 = num5 * num7 * Math.Max(1.0, combatProfile.Targets * 0.6); foreach (ProcEffect proc in s.Procs) { double num9 = Roll(proc.Chance, s.Luck); double num10 = (proc.Total ? num7 : (num6 * num)); double num11 = Math.Max(1.0, Math.Min(proc.Targets, combatProfile.Targets)); num8 += num5 * combatProfile.ProcCoefficient * num9 * proc.Damage * num10 * num11; } num8 += combatProfile.KillsPerSecond * s.KillDamage * num6 * combatProfile.Targets; num8 += ((combatProfile.BigHitShare > 0.0) ? (s.BandDamage * num7 * combatProfile.Targets / 10.0 * Math.Min(1.0, combatProfile.BigHitShare * 5.0)) : 0.0); num8 += s.PulseBase * num6; if (s.TeslaCopies > 0) { num8 += num6 * 2.0 * Math.Min(1 + 2 * s.TeslaCopies, combatProfile.Targets * 2.0); } num8 *= 1.0 + (1.0 - combatProfile.BossShare) * Math.Min(0.9, s.InstantKillChance * num5); num8 *= 1.0 + (1.0 - combatProfile.BossShare) * 0.35 * s.EliteExecute; if (s.DeathMark) { num8 *= 1.0 + 0.5 * Math.Min(1.0, combatProfile.DebuffShare + s.Debuffs); } num8 *= s.DpsMult; double num12 = (stats.Health + s.FlatHealth) * s.HealthMult; double num13 = stats.Armor + s.Armor + combatProfile.SprintShare * s.SprintArmor; double num14 = ((num13 >= 0.0) ? (1.0 + num13 / 100.0) : (1.0 / (1.0 - num13 / 100.0))); double num15 = 1.0 - 1.0 / (1.0 + s.BlockStacks); double num16 = num14 / (1.0 - num15); double num17 = stats.Regen + s.RegenFlat + (s.LifePerHit * num5 * combatProfile.ProcCoefficient + s.LifePerCrit * chance * num5 * combatProfile.ProcCoefficient) + combatProfile.KillsPerSecond * (s.HealOnKillFlat + s.HealOnKillPercent * num12) + combatProfile.StillShare * s.StillHealPercent * num12 + s.MedkitPercent * num12 / 10.0 + s.LifeSteal * num8; num17 *= s.HealingMult; num8 += s.HealDamage * num17; double num18 = s.Speed + combatProfile.SprintShare * s.SprintSpeed; double num19 = 1.0 + 0.5 * Math.Min(Math.Max(0.0, num18), 1.5); double num20 = (num12 * (1.0 + s.ShieldPercent) + combatProfile.KillsPerSecond * 8.0 * s.BarrierOnKill + num17 * (4.0 + s.BarrierFromHealing)) * num16 * s.EffectiveMult * num19; double num21 = stats.Speed * (1.0 + Math.Min(num18, 1.5) + Math.Max(0.0, num18 - 1.5) * 0.1); return new CombatResult { Dps = num8, Effective = num20, AttackSpeed = 1.0 + num2, Crit = chance, Health = num12, Block = num15, Speed = num21, Score = objective.Damage * Math.Log(Math.Max(num8, 0.01)) + objective.Survival * Math.Log(Math.Max(num20, 1.0)) + objective.Mobility * Math.Log(Math.Max(num21, 0.1)) }; } public static Dictionary<string, int> WithItem(IDictionary<string, int> inventory, string token, int copies) { Dictionary<string, int> dictionary = new Dictionary<string, int>(inventory, StringComparer.OrdinalIgnoreCase); dictionary.TryGetValue(token, out var value); dictionary[token] = value + copies; if (Corrupts.TryGetValue(token, out var value2) && dictionary.TryGetValue(value2, out value) && value > 0) { dictionary[token] += value; dictionary[value2] = 0; } return dictionary; } public ItemGain Gain(IDictionary<string, int> inventory, string token, int copies = 1) { CombatResult combatResult = Evaluate(inventory); CombatResult combatResult2 = Evaluate(WithItem(inventory, token, copies)); ItemGain result = new ItemGain { Token = token, Score = (combatResult2.Score - combatResult.Score) * 100.0, Dps = Percent(combatResult.Dps, combatResult2.Dps), Effective = Percent(combatResult.Effective, combatResult2.Effective), Speed = Percent(combatResult.Speed, combatResult2.Speed) }; if (!Effects.ContainsKey(token) && fallback != null) { result.Score = fallback(token); } return result; } private static double Percent(double before, double after) { return (before <= 0.0) ? 0.0 : ((after / before - 1.0) * 100.0); } public List<ItemGain> Rank(IDictionary<string, int> inventory, IEnumerable<string> pool) { return (from token in pool select Gain(inventory, token) into gain orderby gain.Score descending select gain).ToList(); } public List<PlanStep> Plan(IDictionary<string, int> inventory, IList<string> pool, int picks) { Dictionary<string, int> current = new Dictionary<string, int>(inventory, StringComparer.OrdinalIgnoreCase); List<PlanStep> list = new List<PlanStep>(); for (int i = 0; i < picks; i++) { ItemGain itemGain = (from token in pool select Gain(current, token) into gain orderby gain.Score descending select gain).FirstOrDefault(); if (itemGain.Token == null || itemGain.Score <= 0.05) { break; } if (list.Count > 0 && list[list.Count - 1].Token == itemGain.Token) { PlanStep planStep = list[list.Count - 1]; planStep.Copies++; planStep.Gain = Combine(planStep.Gain, itemGain); } else { list.Add(new PlanStep { Token = itemGain.Token, Copies = 1, Gain = itemGain }); } current = WithItem(current, itemGain.Token, 1); } return list; } private static ItemGain Combine(ItemGain a, ItemGain b) { return new ItemGain { Token = a.Token, Score = a.Score + b.Score, Dps = Stack(a.Dps, b.Dps), Effective = Stack(a.Effective, b.Effective), Speed = Stack(a.Speed, b.Speed) }; } private static double Stack(double a, double b) { return ((1.0 + a / 100.0) * (1.0 + b / 100.0) - 1.0) * 100.0; } public List<GeneratedBuild> GenerateBuilds(IDictionary<string, string> availableTiers, IList<BuildArchetype> signature = null) { Dictionary<string, int> inventory = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); CombatResult combatResult = Evaluate(inventory); List<GeneratedBuild> list = new List<GeneratedBuild>(); signature = signature ?? new BuildArchetype[0]; foreach (BuildArchetype item in signature.Concat(Archetypes)) { List<string> order = new List<string>(); if (!item.NeedsVoid || item.Tokens.Any((string token) => Corrupts.ContainsKey(token) && availableTiers.ContainsKey(token))) { Dictionary<string, int> dictionary = WithObjective(item.Objective).PlanTargets(item.Tokens, availableTiers, order, item.Must); if (dictionary.Count >= 3) { CombatResult combatResult2 = Evaluate(dictionary); list.Add(new GeneratedBuild { Archetype = item, Targets = dictionary, Order = order, DamagePercent = Percent(combatResult.Dps, combatResult2.Dps), SurvivalPercent = Percent(combatResult.Effective, combatResult2.Effective), Rating = combatResult2.Score - combatResult.Score }); } } } double num = ((list.Count == 0) ? 1.0 : list.Max((GeneratedBuild generatedBuild) => generatedBuild.Rating)); double num2 = ((list.Count == 0) ? 0.0 : list.Min((GeneratedBuild generatedBuild) => generatedBuild.Rating)); foreach (GeneratedBuild item2 in list) { item2.Rating = ((num - num2 < 0.0001) ? 100.0 : (50.0 + 50.0 * (item2.Rating - num2) / (num - num2))); } List<GeneratedBuild> list2 = (from generatedBuild in list orderby generatedBuild.Archetype.Must != null descending, signature.Contains(generatedBuild.Archetype) descending, generatedBuild.Rating descending select generatedBuild).ToList(); List<GeneratedBuild> list3 = new List<GeneratedBuild>(); foreach (GeneratedBuild build in list2) { if (!list3.Any((GeneratedBuild kept) => Overlap(kept.Targets, build.Targets) > 0.8)) { list3.Add(build); } } return list3.Take(10).ToList(); } internal static BuildArchetype Signature(string key, string name, string why, double damage, double survival, double mobility, params string[] tokens) { return Archetype(key, name, why, damage, survival, mobility, tokens, CoreKit); } private static double Overlap(IDictionary<string, int> a, IDictionary<string, int> b) { int value; int num = a.Sum((KeyValuePair<string, int> pair) => b.TryGetValue(pair.Key, out value) ? Math.Min(pair.Value, value) : 0); int num2 = Math.Min(a.Values.Sum(), b.Values.Sum()); return (num2 == 0) ? 1.0 : ((double)num / (double)num2); } private Dictionary<string, int> PlanTargets(IList<string> tokens, IDictionary<string, string> availableTiers, List<string> order = null, string[] must = null) { Dictionary<string, int> quota = new Dictionary<string, int> { { "Tier1", 34 }, { "Tier2", 13 }, { "Tier3", 4 }, { "Boss", 3 }, { "Lunar", 2 }, { "Cursed", 2 } }; List<string> source = tokens.Where(availableTiers.ContainsKey).Where(Effects.ContainsKey).ToList(); Dictionary<string, int> current = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); foreach (string item in (must != null) ? source.Where(((IEnumerable<string>)must).Contains<string>) : source.Take(2)) { string text = QuotaTier(availableTiers[item]); if (quota.TryGetValue(text, out var value)) { int num = Math.Min(value, AnchorCopies(item, text)); if (num > 0) { current = WithItem(current, item, num); quota[text] -= num; order?.Add(item); } } } while (true) { IEnumerable<string> source2 = source.Where(delegate(string token) { string text2 = QuotaTier(availableTiers[token]); current.TryGetValue(token, out var value2); int value3; return quota.TryGetValue(text2, out value3) && value3 > 0 && value2 < MaxCopies(token, text2); }); ItemGain itemGain = (from token in source2 select Gain(current, token) into gain orderby gain.Score descending select gain).FirstOrDefault(); if (itemGain.Token == null || itemGain.Score <= 0.02) { break; } current = WithItem(current, itemGain.Token, 1); quota[QuotaTier(availableTiers[itemGain.Token])]--; if (order != null && !order.Contains(itemGain.Token)) { order.Add(itemGain.Token); } } return (from pair in current where pair.Value > 0 orderby pair.Value descending select pair).ToDictionary<KeyValuePair<string, int>, string, int>((KeyValuePair<string, int> pair) => pair.Key, (KeyValuePair<string, int> pair) => pair.Value, StringComparer.OrdinalIgnoreCase); } public void Extend(IDictionary<string, int> targets, IEnumerable<string> pool, IDictionary<string, string> tiers, string tier, int picks, int level) { Dictionary<string, int> current = new Dictionary<string, int>(targets, StringComparer.OrdinalIgnoreCase); List<string> source = pool.Where((string token) => Effects.ContainsKey(token) && tiers.ContainsKey(token) && tiers[token] == tier).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList(); for (int num = 0; num < picks; num++) { ItemGain itemGain = (from token in source.Where(delegate(string token) { current.TryGetValue(token, out var value2); return value2 < MaxCopies(token, tier) * level; }) select Gain(current, token) into gain orderby gain.Score descending select gain).FirstOrDefault(); if (itemGain.Token == null || itemGain.Score <= 0.02) { break; } current = WithItem(current, itemGain.Token, 1); targets.TryGetValue(itemGain.Token, out var value); targets[itemGain.Token] = value + 1; } } public bool BestSynergy(IDictionary<string, int> inventory, IList<string> pool, out string owned, out string other, out double extra) { owned = null; other = null; extra = 0.0; foreach (KeyValuePair<string, int> item in inventory.Where((KeyValuePair<string, int> pair) => pair.Value > 0 && Effects.ContainsKey(pair.Key))) { Dictionary<string, int> dictionary = new Dictionary<string, int>(inventory, StringComparer.OrdinalIgnoreCase); dictionary[item.Key] = 0; foreach (string item2 in pool) { if (!(item2 == item.Key) && Effects.ContainsKey(item2)) { double num = Gain(inventory, item2).Score - Gain(dictionary, item2).Score; if (num > extra) { extra = num; owned = item.Key; other = item2; } } } } return owned != null; } public bool BestSwap(IDictionary<string, int> inventory, IList<string> sameTierOwned, IList<string> sameTierPool, out string sell, out string buy, out double net) { sell = null; buy = null; net = 0.0; foreach (string token in sameTierOwned) { if (!Effects.ContainsKey(token)) { continue; } Dictionary<string, int> dictionary = new Dictionary<string, int>(inventory, StringComparer.OrdinalIgnoreCase); dictionary[token] = Math.Max(0, dictionary[token] - 1); ItemGain itemGain = Rank(dictionary, sameTierPool.Where((string candidate) => candidate != token)).FirstOrDefault(); if (itemGain.Token != null) { double num = itemGain.Score - Gain(dictionary, token).Score; if (num > net) { net = num; sell = token; buy = itemGain.Token; } } } return sell != null; } internal static double[] ParseStackNumbers(string description) { if (string.IsNullOrEmpty(description)) { return null; } if (ParsedText.TryGetValue(description, out var value)) { return value; } value = ReadStackNumbers(description); ParsedText[description] = value; return value; } private static double[] ReadStackNumbers(string description) { string input = Regex.Replace(description, "<[^>]*>", string.Empty); List<double> list = new List<double>(); foreach (Match item2 in Regex.Matches(input, "(\\d[\\d.,]*)\\s*%?[^\\d()]{0,30}\\(\\s*([+-])\\s*(\\d[\\d.,]*)")) { double item = ParseNumber(item2.Groups[1].Value); double num = ParseNumber(item2.Groups[3].Value); list.Add(item); list.Add((item2.Groups[2].Value == "-") ? (0.0 - num) : num); } return (list.Count == 0) ? null : list.ToArray(); } private static double ParseNumber(string text) { text = text.TrimEnd('.', ','); text = Regex.Replace(text, "\\.(?=\\d{3}(\\D|$))", string.Empty).Replace(',', '.'); double result; return double.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out result) ? result : 0.0; } private static ItemEffect E(string token, string note, double[] defaults, Action<CombatState, int, double[]> apply) { return new ItemEffect { Token = token, Note = note, Defaults = defaults, Apply = apply }; } private static double[] P(params double[] pairs) { return pairs; } private static void Proc(CombatState s, double chance, double damage, bool total, double targets = 1.0) { s.Procs.Add(new ProcEffect { Chance = chance, Damage = damage, Total = total, Targets = targets }); } private static Dictionary<string, ItemEffect> BuildEffects() { ItemEffect[] source = new ItemEffect[112] { E("SYRINGE", "cadência de todos os ataques", P(15.0, 15.0), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += v[0] / 100.0; }), E("ATTACKSPEEDANDMOVESPEED", "ataca e anda mais rápido", P(7.5, 7.5, 7.0, 7.0), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += v[0] / 100.0; s.Speed += v[1] / 100.0; }), E("POWERORB", "velocidade de ataque fixa", P(), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += 0.15 * (double)n; }), E("CRITGLASSES", "crítico dobra o dano e ativa efeitos de crítico", P(10.0, 10.0), delegate(CombatState s, int n, double[] v) { s.Crit += v[0] / 100.0; }), E("ATTACKSPEEDONCRIT", "cada crítico acelera os ataques até o limite", P(36.0, 24.0), delegate(CombatState s, int n, double[] v) { s.CritAttackSpeedCap += v[0] / 100.0; }), E("HEALONCRIT", "crítico vira cura", P(8.0, 4.0), delegate(CombatState s, int n, double[] v) { s.Crit += 0.05; s.LifePerCrit += v[0]; }), E("CRITDAMAGE", "cada crítico causa muito mais dano", P(100.0, 100.0), delegate(CombatState s, int n, double[] v) { s.CritMult += v[0] / 100.0; }), E("BOSSDAMAGEBONUS", "só conta contra chefes", P(20.0, 20.0), delegate(CombatState s, int n, double[] v) { s.Boss += v[0] / 100.0; }), E("CROWBAR", "golpe de abertura em inimigos quase cheios", P(75.0, 75.0), delegate(CombatState s, int n, double[] v) { s.First += v[0] / 100.0; }), E("NEARBYDAMAGEBONUS", "só conta a menos de 13 m", P(20.0, 20.0), delegate(CombatState s, int n, double[] v) { s.Near += v[0] / 100.0; }), E("FRAGILEDAMAGEBONUS", "dano fixo, mas quebra se a vida cair demais", P(20.0, 20.0), delegate(CombatState s, int n, double[] v) { s.DamageMult *= 1.0 + v[0] / 100.0; }), E("LUNARDAGGER", "dobra o dano e divide a vida", P(100.0, 100.0, 50.0, 50.0), delegate(CombatState s, int n, double[] v) { s.DamageMult *= Math.Pow(2.0, n); s.HealthMult *= Math.Pow(0.5, n); }), E("BLEEDONHIT", "dano contínuo por acerto, forte em chefes", P(10.0, 10.0), delegate(CombatState s, int n, double[] v) { Proc(s, v[0] / 100.0, 2.4, total: false); s.Debuffs += 0.2; }), E("STICKYBOMB", "chance de bomba a cada acerto", P(5.0, 5.0), delegate(CombatState s, int n, double[] v) { Proc(s, v[0] / 100.0, 1.8, total: true); }), E("MISSILE", "cada cópia aumenta o dano do míssil", P(300.0, 300.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.1, v[0] / 100.0, total: true); }), E("MOREMISSILE", "mais mísseis nos efeitos que já lançam mísseis", P(), delegate { }), E("CHAINLIGHTNING", "cada cópia alcança mais alvos", P(3.0, 2.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.25, 0.8, total: true, v[0]); }), E("BOUNCENEARBY", "ganchos em vários inimigos", P(20.0, 20.0, 10.0, 5.0), delegate(CombatState s, int n, double[] v) { Proc(s, v[0] / 100.0, 1.0, total: true, v[1]); }), E("FIREBALLSONHIT", "bolas de magma por acerto", P(300.0, 300.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.1, 3.0 * v[0] / 100.0 * 0.5, total: true, 2.0); }), E("LIGHTNINGSTRIKEONHIT", "relâmpago forte por acerto", P(500.0, 500.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.1, v[0] / 100.0, total: true); }), E("BEHEMOTH", "todo acerto vira uma pequena explosão", P(4.0, 1.5), delegate(CombatState s, int n, double[] v) { Proc(s, 1.0, 0.6 * (0.6 + 0.4 * (double)n), total: true, 3.0); }), E("PRIMARYSKILLSHURIKEN", "lança shurikens com a habilidade primária", P(400.0, 100.0, 3.0, 1.0), delegate(CombatState s, int n, double[] v) { s.KillDamage += v[0] / 100.0 * v[1] / 10.0 / 0.4; }), E("FIRERING", "golpes acima de 400% ativam a faixa", P(300.0, 300.0), delegate(CombatState s, int n, double[] v) { s.BandDamage += v[0] / 100.0; }), E("ICERING", "golpes acima de 400% ativam a faixa", P(3.0, 3.0, 250.0, 250.0), delegate(CombatState s, int n, double[] v) { s.BandDamage += v[1] / 100.0; }), E("IGNITEONKILL", "abates incendeiam o grupo", P(12.0, 4.0, 150.0, 75.0), delegate(CombatState s, int n, double[] v) { s.KillDamage += 1.5 + v[1] / 100.0; s.Debuffs += 0.1; }), E("EXPLODEONDEATH", "abates viram explosões", P(12.0, 2.4, 350.0, 280.0), delegate(CombatState s, int n, double[] v) { s.KillDamage += v[1] / 100.0; }), E("DAGGER", "adagas automáticas ao abater", P(150.0, 150.0), delegate(CombatState s, int n, double[] v) { s.KillDamage += 3.0 * v[0] / 100.0; }), E("CLOVER", "toda chance rola de novo a seu favor", P(1.0, 1.0), delegate(CombatState s, int n, double[] v) { s.Luck += v[0]; }), E("ALIENHEAD", "reduz a recarga de todas as habilidades", P(25.0, 25.0), delegate(CombatState s, int n, double[] v) { s.CooldownMult *= Math.Pow(0.75, n); }), E("BANDOLIER", "abates podem zerar as recargas", P(18.0, 10.0), delegate(CombatState s, int n, double[] v) { s.CooldownMult *= 1.0 / (1.0 + 0.5 * v[0] / 100.0); }), E("SECONDARYSKILLMAGAZINE", "mais cargas da secundária", P(1.0, 1.0), delegate(CombatState s, int n, double[] v) { s.SecondaryCharges += v[0]; }), E("UTILITYSKILLMAGAZINE", "mais cargas da utilitária e recarga menor", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.08 * (double)n; s.CooldownMult *= Math.Pow(0.9, n); }), E("BEAR", "bloqueia golpes inteiros", P(15.0, 15.0), delegate(CombatState s, int n, double[] v) { s.BlockStacks += v[0] / 100.0; }), E("PERSONALSHIELD", "escudo que recarrega fora de perigo", P(8.0, 8.0), delegate(CombatState s, int n, double[] v) { s.ShieldPercent += v[0] / 100.0; }), E("FLATHEALTH", "vida fixa, vale mais no começo", P(25.0, 25.0), delegate(CombatState s, int n, double[] v) { s.FlatHealth += v[0]; }), E("COOKEDSTEAK", "vida máxima alta", P(50.0, 50.0, 5.0, 5.0), delegate(CombatState s, int n, double[] v) { s.FlatHealth += v[0]; s.HealthMult *= 1.0 + v[1] / 100.0; }), E("INFUSION", "vida permanente a cada abate", P(1.0, 1.0, 100.0, 100.0), delegate(CombatState s, int n, double[] v) { s.FlatHealth += v[1] * 0.6; }), E("SPRINTARMOR", "armadura enquanto corre", P(30.0, 30.0), delegate(CombatState s, int n, double[] v) { s.SprintArmor += v[0]; }), E("POWERCUBE", "armadura fixa", P(), delegate(CombatState s, int n, double[] v) { s.Armor += 50 * n; }), E("BARRIERONKILL", "abates dão barreira", P(15.0, 15.0), delegate(CombatState s, int n, double[] v) { s.BarrierOnKill += v[0]; }), E("KNURL", "vida e regeneração altas", P(40.0, 40.0, 1.6, 1.6), delegate(CombatState s, int n, double[] v) { s.FlatHealth += v[0]; s.RegenFlat += v[1]; }), E("SEED", "cura a cada acerto", P(1.0, 1.0), delegate(CombatState s, int n, double[] v) { s.LifePerHit += v[0]; }), E("TOOTH", "abates soltam cura", P(2.0, 2.0), delegate(CombatState s, int n, double[] v) { s.HealOnKillFlat += 8.0; s.HealOnKillPercent += v[0] / 100.0; }), E("MEDKIT", "cura logo depois de apanhar", P(5.0, 5.0), delegate(CombatState s, int n, double[] v) { s.MedkitPercent += v[0] / 100.0; s.RegenFlat += 5.0; }), E("HEALWHILESAFE", "só regenera fora de combate", P(3.0, 3.0), delegate(CombatState s, int n, double[] v) { s.RegenFlat += v[0] * 0.3; }), E("MUSHROOM", "cura em área quando fica parado", P(4.5, 2.25), delegate(CombatState s, int n, double[] v) { s.StillHealPercent += v[0] / 100.0; }), E("INCREASEHEALING", "multiplica toda cura", P(100.0, 100.0), delegate(CombatState s, int n, double[] v) { s.HealingMult *= 1.0 + v[0] / 100.0; }), E("HOOF", "velocidade sempre ativa", P(14.0, 14.0), delegate(CombatState s, int n, double[] v) { s.Speed += v[0] / 100.0; }), E("SPRINTBONUS", "só conta correndo", P(25.0, 25.0), delegate(CombatState s, int n, double[] v) { s.SprintSpeed += v[0] / 100.0; }), E("POWERPYRAMID", "velocidade fixa", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.15 * (double)n; }), E("FEATHER", "saltos extras para escapar e alcançar: as primeiras valem muito", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.15 * Math.Sqrt(n); }), E("JUMPBOOST", "saltos mais altos e rápidos", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.05 * (double)n; }), E("SPRINTOUTOFCOMBAT", "corre muito, mas só fora de combate", P(), delegate(CombatState s, int n, double[] v) { s.SprintSpeed += 0.1 * (double)n; }), E("MOVESPEEDONKILL", "abates dão velocidade", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.1 * (double)n; }), E("SPEEDBOOSTPICKUP", "orbes dão +12% de velocidade, acumulando 3 (+3 por cópia) vezes", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.12 * (double)Math.Min(3 * n, 1 + n); }), E("INCREASEDAMAGEONMULTIKILL", "cada abate dá +3,5% (+1%) de dano, até 10 (+5) vezes", P(), delegate(CombatState s, int n, double[] v) { s.DpsMult *= 1.0 + 0.5 * (0.035 + 0.01 * (double)(n - 1)) * (double)Math.Min(10 + 5 * (n - 1), 12); }), E("JUMPDAMAGESTRIKE", "andar carrega até +160% de velocidade; pular solta uma explosão", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.8; s.PulseBase += 0.8 + 0.56 * (double)(n - 1); }), E("ATTACKSPEEDPERNEARBYALLYORENEMY", "+10% (+3,5) de ataque por aliado ou inimigo perto, até 3 (+1)", P(), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += (0.1 + 0.035 * (double)(n - 1)) * (double)Math.Min(2 + n, 3); }), E("CRITATLOWERELEVATION", "acertar de cima dá crítico e dano de crítico, até 10 vezes", P(), delegate(CombatState s, int n, double[] v) { s.Crit += 0.05 * (double)n; s.CritMult += 0.05 * (double)n; }), E("HEALINGPOTION", "com menos de 25% de vida, cura 75% e é gasto", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.0 + 0.4 * (double)n / (double)(n + 1); }), E("SHIELDBOOSTER", "escudo de 4% e +30 de armadura enquanto tiver escudo", P(), delegate(CombatState s, int n, double[] v) { s.ShieldPercent += 0.04; s.Armor += 15 * n; }), E("BARRIERONCOOLDOWN", "barreira quando uma habilidade recarrega", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.0 + 0.04 * (double)n; }), E("ENERGIZEDONEQUIPMENTUSE", "+70% de ataque ao usar equipamento", P(), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += 0.7 * Math.Min(0.8, 0.3 + 0.1 * (double)n); }), E("BOOSTALLSTATS", "+4% em todos os atributos por efeito ativo, até 4 (+4)", P(), delegate(CombatState s, int n, double[] v) { double num = 0.04 * (double)Math.Min(2 + 2 * n, 4 * n); s.DamageMult *= 1.0 + num; s.HealthMult *= 1.0 + num; s.AttackSpeed += num; s.Speed += num; s.Armor += 100.0 * num; }), E("STUNANDPIERCE", "15% de bumerangue elétrico que atravessa e atordoa", P(), delegate(CombatState s, int n, double[] v) { Proc(s, 0.15, 1.2 + 1.2 * (double)n, total: false, 2.0); }), E("METEORATTACKONHIGHDAMAGE", "chance de meteoro; golpes fortes aumentam chance e dano", P(), delegate(CombatState s, int n, double[] v) { Proc(s, 0.03 + 0.03 * (double)n, 20.0, total: false, 3.0); }), E("BARRAGEONBOSS", "mísseis que tiram % da vida do chefe", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += 2 * n; }), E("GHOSTBLADES", "roubo de vida de 1% (+1%) e lâminas fantasmas", P(), delegate(CombatState s, int n, double[] v) { s.LifeSteal += 0.01 * (double)n; s.PulseBase += n; }), E("SANGUINECHALICE", "10% de sangramento, e sangrar inimigos cura você", P(), delegate(CombatState s, int n, double[] v) { Proc(s, 0.1, 2.4, total: false); s.RegenFlat += 3 * n; s.Debuffs += 0.1; }), E("VENGEFULSPIRIT", "espírito que absorve 50% de todo dano recebido", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.6; }), E("SPRINTDAMAGE", "correr carrega velocidade e crânios que causam dano", P(), delegate(CombatState s, int n, double[] v) { s.Speed += 0.2; s.PulseBase += 1.5 * (double)n; }), E("EXECUTELOWHEALTHELITE", "mata elites com pouca vida na hora", P(), delegate(CombatState s, int n, double[] v) { s.EliteExecute += 1.0 - 1.0 / (1.0 + 0.13 * (double)n); }), E("WARCRYONMULTIKILL", "abates em sequência dão fúria: ataca e anda mais rápido", P(), delegate(CombatState s, int n, double[] v) { double num = Math.Min(0.8, 0.25 + 0.1 * (double)n); s.AttackSpeed += 1.0 * num; s.Speed += 0.5 * num; }), E("DEATHMARK", "inimigos com vários efeitos negativos recebem +50% de dano", P(), delegate(CombatState s, int n, double[] v) { s.DeathMark = true; }), E("SLOWONHIT", "deixa inimigos lentos, o que ajuda a fugir e soma para a Marca Fatal", P(), delegate(CombatState s, int n, double[] v) { s.Debuffs += 0.2; s.EffectiveMult *= 1.0 + 0.12 * (double)n / (double)(n + 1); }), E("STUNCHANCEONHIT", "chance de atordoar quem você acerta", P(), delegate(CombatState s, int n, double[] v) { s.Debuffs += 0.05; s.EffectiveMult *= 1.0 + 0.1 * (double)n / (double)(n + 3); }), E("REPULSIONARMORPLATE", "reduz o dano de cada golpe, ótimo contra muitos golpes fracos", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.0 + 0.3 * (double)n / (double)(n + 3); }), E("OUTOFCOMBATARMOR", "armadura alta enquanto ninguém acerta você", P(), delegate(CombatState s, int n, double[] v) { s.Armor += (double)(100 * n) * 0.25; }), E("DELAYEDDAMAGE", "o próximo golpe é dividido e só o último pedaço pode matar; recarrega em 15 s", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.25 + 0.02 * (double)(n - 1); }), E("TELEPORTONLOWHEALTH", "teleporta para longe quando a vida cai demais", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.3 + 0.08 * (double)(n - 1); }), E("PHASING", "fica invisível e rápido quando a vida cai", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.0 + 0.12 * (double)n / (double)(n + 1); }), E("EXTRALIFE", "uma vida extra: salva a partida de um erro", P(), delegate(CombatState s, int n, double[] v) { s.EffectiveMult *= 1.0 + 0.35 * (double)n; }), E("WARDONLEVEL", "estandarte que acelera ataques e movimento perto dele", P(), delegate(CombatState s, int n, double[] v) { s.AttackSpeed += 0.09; s.Speed += 0.09; }), E("FIREWORK", "fogos ao abrir baús, dano pequeno", P(), delegate(CombatState s, int n, double[] v) { s.KillDamage += 0.2 * (double)n; }), E("THORNS", "devolve dano a quem bate em você", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += 0.4 + 0.4 * (double)n; }), E("ICICLE", "cada abate faz crescer um círculo de gelo ao redor", P(), delegate(CombatState s, int n, double[] v) { s.KillDamage += 3 * n; }), E("LASERTURBINE", "disco que atravessa tudo depois de abates", P(), delegate(CombatState s, int n, double[] v) { s.KillDamage += 2 * n; s.PulseBase += n; }), E("SHOCKNEARBY", "raios automáticos nos inimigos ao redor", P(), delegate(CombatState s, int n, double[] v) { s.TeslaCopies = n; }), E("ARMORREDUCTIONONHIT", "tira muita armadura do alvo: todo dano sobe, principalmente em chefes", P(), delegate(CombatState s, int n, double[] v) { s.DpsMult *= 1.45; s.Debuffs += 0.2; }), E("PERMANENTDEBUFFONHIT", "cada acerto tira armadura para sempre", P(), delegate(CombatState s, int n, double[] v) { s.DpsMult *= 1.0 + Math.Min(0.8, 0.2 * (double)n); s.Debuffs += 0.2; }), E("HEADHUNTER", "ganha o poder dos elites que abate", P(), delegate(CombatState s, int n, double[] v) { s.DpsMult *= 1.0 + 0.06 * (double)n; s.Debuffs += 0.1; }), E("BARRIERONOVERHEAL", "cura que sobra vira barreira", P(), delegate(CombatState s, int n, double[] v) { s.BarrierFromHealing += 3 * n; }), E("NOVAONHEAL", "toda cura vira dano nos inimigos: forte com muita cura", P(), delegate(CombatState s, int n, double[] v) { s.HealDamage += 2.5 * (double)n; }), E("STRENGTHENBURN", "fogo mais forte", P(), delegate(CombatState s, int n, double[] v) { s.KillDamage += 2 * n; s.Debuffs += 0.2; }), E("BLEEDONHITANDEXPLODE", "crítico causa sangramento e o alvo explode ao morrer", P(), delegate(CombatState s, int n, double[] v) { s.KillDamage += 4 * n; s.Debuffs += 0.2; }), E("BEETLEGLAND", "besouros aliados lutam com você", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += 1.5 * (double)n; s.EffectiveMult *= 1.0 + 0.05 * (double)n; }), E("SPRINTWISP", "espíritos atacam enquanto você corre", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += 1.5 * (double)n; }), E("SIPHONONLOWHEALTH", "drena os inimigos perto e cura", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += n; s.RegenFlat += 4 * n; s.Debuffs += 0.1; }), E("NOVAONLOWHEALTH", "explosão enorme quando a vida cai", P(), delegate(CombatState s, int n, double[] v) { s.PulseBase += 1.2 * (double)n; s.EffectiveMult *= 1.0 + 0.05 * (double)n; }), E("PARENTEGG", "cura ao tomar dano", P(), delegate(CombatState s, int n, double[] v) { s.RegenFlat += 6 * n; }), E("PEARL", "mais vida máxima", P(), delegate(CombatState s, int n, double[] v) { s.HealthMult *= 1.0 + 0.1 * (double)n; }), E("SHINYPEARL", "melhora todos os atributos", P(), delegate(CombatState s, int n, double[] v) { s.HealthMult *= 1.0 + 0.1 * (double)n; s.DamageMult *= 1.0 + 0.1 * (double)n; s.AttackSpeed += 0.1 * (double)n; s.Speed += 0.1 * (double)n; s.Crit += 0.1 * (double)n; s.Armor += 10 * n; }), E("CRITGLASSESVOID", "chance de abate instantâneo, mas troca os Óculos", P(0.5, 0.5), delegate(CombatState s, int n, double[] v) { s.InstantKillChance += v[0] / 100.0; }), E("BEARVOID", "bloqueia um golpe a cada recarga, mas troca os Tempos Difíceis", P(15.0, -10.0), delegate(CombatState s, int n, double[] v) { s.BlockStacks += 0.2 + 0.08 * (double)n; }), E("MISSILEVOID", "míssil em todo acerto enquanto tiver escudo, mas troca o Míssil", P(40.0, 50.0), delegate(CombatState s, int n, double[] v) { s.ShieldPercent += 0.1; Proc(s, 1.0, v[0] / 100.0, total: true); }), E("CHAINLIGHTNINGVOID", "raios repetidos, mas troca o Ukulele", P(3.0, 3.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.25, 0.6 * v[0], total: true); }), E("BLEEDONHITVOID", "colapso forte, mas troca a Adaga Triangular", P(10.0, 10.0), delegate(CombatState s, int n, double[] v) { Proc(s, v[0] / 100.0, 4.0, total: false); }), E("MUSHROOMVOID", "cura correndo, mas troca o Fungo", P(2.0, 2.0), delegate(CombatState s, int n, double[] v) { s.RegenFlat += 0.4 * v[0]; }), E("EXPLODEONDEATHVOID", "detona inimigos cheios, mas troca o Fogo Fátuo", P(12.0, 2.4, 260.0, 156.0), delegate(CombatState s, int n, double[] v) { Proc(s, 0.15, v[1] / 100.0, total: false, 3.0); }), E("HEXCURSE", "divide sua vida máxima", P(30.0, 30.0), delegate(CombatState s, int n, double[] v) { s.HealthMult /= 1.0 + v[0] / 100.0; }), E("LOWERHEALING", "divide toda a cura", P(40.0, 40.0), delegate(CombatState s, int n, double[] v) { s.HealingMult /= 1.0 + v[0] / 100.0; }), E("SLIPPERYGROUND", "chão escorregadio", P(40.0, 30.0), delegate(CombatState s, int n, double[] v) { s.Speed -= 0.1 * (double)n; }) }; return source.ToDictionary<ItemEffect, string>((ItemEffect effect) => effect.Token, StringComparer.OrdinalIgnoreCase); } } internal static class SurvivorCombat { private static readonly Dictionary<string, CombatProfile> All = new Dictionary<string, CombatProfile>(StringComparer.OrdinalIgnoreCase) { { "COMMANDO", C(6.0, 1.0, 1.0, 0.8, 0.2, 0.2, 0.3, 0.25, 0.1, 0.05, 1.2, 0.4, 0.3, 0.1) }, { "HUNTRESS", C(2.5, 1.6, 0.8, 0.6, 0.4, 0.3, 0.1, 0.25, 0.15, 0.1, 1.6, 0.4, 0.8, 0.0) }, { "BANDIT2", C(1.5, 3.0, 0.7, 0.45, 0.55, 0.3, 0.4, 0.25, 0.3, 0.4, 1.3, 0.4, 0.5, 0.0).With(0.4) }, { "TOOLBOT", C(12.0, 0.7, 0.6, 0.85, 0.15, 0.1, 0.3, 0.25, 0.05, 0.05, 1.3, 0.5, 0.2, 0.1) }, { "ENGI", C(5.0, 1.0, 1.0, 0.6, 0.4, 0.2, 0.2, 0.25, 0.1, 0.05, 1.2, 0.4, 0.2, 0.6) }, { "MAGE", C(1.2, 3.5, 1.0, 0.4, 0.6, 0.4, 0.2, 0.25, 0.25, 0.5, 2.0, 0.4, 0.1, 0.2).With(0.4) }, { "MERC", C(4.0, 1.5, 1.0, 0.55, 0.45, 0.2, 0.9, 0.25, 0.15, 0.2, 2.0, 0.5, 0.4, 0.0).With(0.35) }, { "TREEBOT", C(2.5, 2.0, 0.6, 0.45, 0.55, 0.3, 0.3, 0.25, 0.15, 0.2, 1.8, 0.4, 0.2, 0.2).With(0.5) }, { "LOADER", C(1.2, 5.0, 1.0, 0.25, 0.75, 0.2, 0.95, 0.3, 0.3, 0.7, 1.8, 0.4, 0.3, 0.0, 0.6) }, { "CROCO", C(3.0, 1.5, 1.0, 0.45, 0.55, 0.2, 0.5, 0.25, 0.1, 0.15, 2.5, 0.5, 0.6, 0.0).With(0.6, 0.6) }, { "CAPTAIN", C(4.0, 1.0, 0.75, 0.6, 0.4, 0.25, 0.4, 0.25, 0.15, 0.1, 1.5, 0.4, 0.2, 0.2) }, { "HERETIC", C(2.5, 2.0, 0.8, 0.45, 0.55, 0.3, 0.3, 0.25, 0.15, 0.3, 2.0, 0.5, 0.2, 0.0) }, { "RAILGUNNER", C(1.0, 8.0, 1.2, 0.3, 0.7, 0.5, 0.05, 0.35, 0.4, 0.8, 1.5, 0.3, 0.1, 0.3).With(-1.0, -1.0, critBecomesDamage: true) }, { "VOIDSURVIVOR", C(5.0, 1.2, 0.8, 0.65, 0.35, 0.35, 0.3, 0.25, 0.1, 0.1, 1.4, 0.4, 0.3, 0.1) }, { "SEEKER", C(2.5, 2.5, 1.0, 0.45, 0.55, 0.3, 0.4, 0.25, 0.15, 0.3, 2.0, 0.4, 0.2, 0.1) }, { "FALSESON", C(1.5, 4.0, 1.0, 0.5, 0.5, 0.3, 0.8, 0.3, 0.2, 0.5, 2.0, 0.4, 0.1, 0.1) }, { "CHEF", C(3.0, 2.0, 1.0, 0.35, 0.65, 0.3, 0.5, 0.25, 0.15, 0.25, 2.5, 0.5, 0.2, 0.0) }, { "DRIFTER", C(2.5, 2.2, 1.0, 0.55, 0.45, 0.2, 0.85, 0.25, 0.15, 0.2, 1.8, 0.4, 0.2, 0.1) }, { "DRONETECH", C(3.0, 1.0, 0.8, 0.35, 0.65, 0.2, 0.2, 0.25, 0.1, 0.1, 1.5, 0.4, 0.3, 0.2) }, { "ENFORCER", C(1.8, 3.0, 1.0, 0.65, 0.35, 0.2, 0.6, 0.3, 0.2, 0.3, 1.6, 0.4, 0.1, 0.3) }, { "ACOLYTE", C(3.0, 1.8, 1.0, 0.65, 0.35, 0.2, 0.85, 0.25, 0.15, 0.15, 1.8, 0.5, 0.3, 0.0) } }; private static CombatProfile C(double hits, double percent, double coef, double attack, double cooldown, double secondary, double near, double boss, double first, double big, double targets, double kills, double sprint, double still, double speedDamage = 0.0) { return new CombatProfile { HitsPerSecond = hits, HitPercent = percent, ProcCoefficient = coef, AttackSpeedShare = attack, CooldownShare = cooldown, SecondaryShare = secondary, NearShare = near, BossShare = boss, FirstHitShare = first, BigHitShare = big, Targets = targets, KillsPerSecond = kills, SprintShare = sprint, StillShare = still, SpeedDamageShare = speedDamage }; } public static CombatProfile For(string profileToken) { CombatProfile value; return (!string.IsNullOrEmpty(profileToken) && All.TryGetValue(profileToken, out value)) ? value.Clone() : new CombatProfile(); } } internal sealed class CombatTelemetry { private const float CombatWindow = 3f; private const float NearDistance = 13f; private const int MinimumHits = 60; private const int FullTrustHits = 500; private readonly string folder; private readonly HashSet<GameObject> recentVictims = new HashSet<GameObject>(); private CharacterBody body; private string key = ""; private float lastHit = -100f; private float lastVictimReset; private float lastHealth; private double hits; private double damagePercent; private double nearHits; private double bossHits; private double firstHits; private double bigHits; private double kills; private double combatSeconds; private double sprintSeconds; private double stillSeconds; private double victimSamples; private double victimSum; private double healthLost; public bool Trusted => hits >= 60.0; public double HitsPerSecond => (combatSeconds > 1.0) ? (hits / combatSeconds) : 0.0; public double NearShare => (hits > 0.0) ? (nearHits / hits) : 0.0; public double Targets => (victimSamples > 0.0) ? (victimSum / victimSamples) : 1.0; public double DangerPerSecond => (combatSeconds > 1.0) ? (healthLost / combatSeconds) : 0.0; private string FilePath => Path.Combine(folder, "medicao_" + key + ".txt"); public CombatTelemetry(string folder) { this.folder = folder; GlobalEventManager.onClientDamageNotified += OnDamage; } public void Track(CharacterBody current, string loadoutKey) { if ((Object)(object)current != (Object)(object)body) { body = current; lastHealth = (((Object)(object)current == (Object)null || (Object)(object)current.healthComponent == (Object)null) ? 0f : current.healthComponent.combinedHealthFraction); } if (loadoutKey != key) { Save(); key = loadoutKey; Load(); } if ((Object)(object)body == (Object)null || (Object)(object)body.healthComponent == (Object)null) { return; } float combinedHealthFraction = body.healthComponent.combinedHealthFraction; if (Time.time - lastHit < 3f) { combatSeconds += Time.deltaTime; if (body.isSprinting) { sprintSeconds += Time.deltaTime; } if ((Object)(object)body.characterMotor != (Object)null && ((Vector3)(ref body.characterMotor.velocity)).sqrMagnitude < 1f) { stillSeconds += Time.deltaTime; } if (combinedHealthFraction < lastHealth) { healthLost += lastHealth - combinedHealthFraction; } } lastHealth = combinedHealthFraction; if (Time.time - lastVictimReset > 2f) { if (recentVictims.Count > 0) { victimSum += recentVictims.Count; victimSamples += 1.0; recentVictims.Clear(); } lastVictimReset = Time.time; } } private void OnDamage(DamageDealtMessage message) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Invalid comparison between Unknown and I4 //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null || message == null || (Object)(object)message.attacker != (Object)(object)((Component)body).gameObject || (Object)(object)message.victim == (Object)null || ((int)message.damageColorIndex != 0 && (int)message.damageColorIndex != 5 && (int)message.damageColorIndex != 10 && (int)message.damageColorIndex != 11 && (int)message.damageColorIndex != 12)) { return; } lastHit = Time.time; hits += 1.0; recentVictims.Add(message.victim); float num = ((body.damage > 0f) ? (message.damage / body.damage) : 1f); if (message.crit) { num *= 0.5f; } damagePercent += num; if (num >= 4f) { bigHits += 1.0; } Vector3 val = message.position - body.corePosition; if (((Vector3)(ref val)).sqrMagnitude < 169f) { nearHits += 1.0; } CharacterBody component = message.victim.GetComponent<CharacterBody>(); if ((Object)(object)component == (Object)null) { return; } if (component.isBoss) { bossHits += 1.0; } HealthComponent healthComponent = component.healthComponent; if (!((Object)(object)healthComponent == (Object)null)) { if (!healthComponent.alive) { kills += 1.0; } else if (healthComponent.combinedHealthFraction + message.damage / Mathf.Max(1f, healthComponent.fullCombinedHealth) >= 0.9f) { firstHits += 1.0; } } } public CombatProfile Apply(CombatProfile estimate) { if (!Trusted || combatSeconds < 5.0) { return estimate; } double trust = Math.Min(1.0, hits / 500.0); CombatProfile combatProfile = estimate.Clone(); combatProfile.HitsPerSecond = Mix(estimate.HitsPerSecond, HitsPerSecond, trust); combatProfile.HitPercent = Mix(estimate.HitPercent, damagePercent / hits, trust); combatProfile.NearShare = Mix(estimate.NearShare, NearShare, trust); combatProfile.BossShare = Mix(estimate.BossShare, bossHits / hits, trust); combatProfile.FirstHitShare = Mix(estimate.FirstHitShare, firstHits / hits, trust); combatProfile.BigHitShare = Mix(estimate.BigHitShare, bigHits / hits, trust); combatProfile.Targets = Mix(estimate.Targets, Targets, trust); combatProfile.KillsPerSecond = Mix(estimate.KillsPerSecond, kills / combatSeconds, trust); combatProfile.SprintShare = Mix(estimate.SprintShare, sprintSeconds / combatSeconds, trust); combatProfile.StillShare = Mix(estimate.StillShare, stillSeconds / combatSeconds, trust); return combatProfile; } private static double Mix(double a, double b, double trust) { return a + (b - a) * trust; } public void Save() { if (string.IsNullOrEmpty(key) || hits <= 0.0) { return; } try { Directory.CreateDirectory(folder); double[] array = new double[13] { hits, damagePercent, nearHits, bossHits, firstHits, bigHits, kills, combatSeconds, sprintSeconds, stillSeconds, victimSamples, victimSum, healthLost }; File.WriteAllText(FilePath, string.Join(" ", Array.ConvertAll(array, Format))); } catch (Exception ex) { Debug.LogWarning((object)("[RoR2 Build Assistant] Medição não salva: " + ex.Message)); } } private static string Format(double value) { return value.ToString("R", CultureInfo.InvariantCulture); } private void Load() { hits = (damagePercent = (nearHits = (bossHits = (firstHits = (bigHits = (kills = (combatSeconds = (sprintSeconds = (stillSeconds = (victimSamples = (victimSum = (healthLost = 0.0)))))))))))); try { if (string.IsNullOrEmpty(key) || !File.Exists(FilePath)) { return; } string[] array = File.ReadAllText(FilePath).Split(' '); if (array.Length == 13) { double[] array2 = Array.ConvertAll(array, (string part) => double.Parse(part, CultureInfo.InvariantCulture)); hits = array2[0]; damagePercent = array2[1]; nearHits = array2[2]; bossHits = array2[3]; firstHits = array2[4]; bigHits = array2[5]; kills = array2[6]; combatSeconds = array2[7]; sprintSeconds = array2[8]; stillSeconds = array2[9]; victimSamples = array2[10]; victimSum = array2[11]; healthLost = array2[12]; } } catch (Exception ex) { Debug.LogWarning((object)("[RoR2 Build Assistant] Medição não lida: " + ex.Message)); } } } internal sealed class ItemCard { public string Key; public string Token; public object CatalogIndex; public object ExpansionDef; public bool Hidden; public string Name; public string Description; public string NativeDescription; public string Tier; public string Category; public string Acquisition; public string Unlock; public string Expansion; public bool IsEli