void Awake() { if (_instance == null) { Debug.Log("Creating singleton"); // If this instance is the first in the scene, it becomes the singleton _instance = this; squad = new GameObject[7]; DontDestroyOnLoad(this); } else { // If another Singleton already exists, destroy this object if (this != _instance) { Debug.Log("Destroying invalid singleton"); Destroy(this.gameObject); } } }
public void Start() { try { _dir = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%/Desktop"), "NGUInjector"); if (!Directory.Exists(_dir)) { Directory.CreateDirectory(_dir); } var logDir = Path.Combine(_dir, "logs"); if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } OutputWriter = new StreamWriter(Path.Combine(logDir, "inject.log")) { AutoFlush = true }; LootWriter = new StreamWriter(Path.Combine(logDir, "loot.log")) { AutoFlush = true }; CombatWriter = new StreamWriter(Path.Combine(logDir, "combat.log")) { AutoFlush = true }; AllocationWriter = new StreamWriter(Path.Combine(logDir, "allocation.log")) { AutoFlush = true }; PitSpinWriter = new StreamWriter(Path.Combine(logDir, "pitspin.log"), true) { AutoFlush = true }; _profilesDir = Path.Combine(_dir, "profiles"); if (!Directory.Exists(_profilesDir)) { Directory.CreateDirectory(_profilesDir); } var oldPath = Path.Combine(_dir, "allocation.json"); var newPath = Path.Combine(_profilesDir, "default.json"); if (File.Exists(oldPath) && !File.Exists(newPath)) { File.Move(oldPath, newPath); } } catch (Exception e) { Log(e.Message); Log(e.StackTrace); Loader.Unload(); return; } try { Character = FindObjectOfType <Character>(); Log("Injected"); LogLoot("Starting Loot Writer"); LogCombat("Starting Combat Writer"); Controller = Character.inventoryController; PlayerController = FindObjectOfType <PlayerController>(); _invManager = new InventoryManager(); _yggManager = new YggdrasilManager(); _questManager = new QuestManager(); _combManager = new CombatManager(); LoadoutManager.ReleaseLock(); DiggerManager.ReleaseLock(); Settings = new SavedSettings(_dir); if (!Settings.LoadSettings()) { var temp = new SavedSettings(null) { PriorityBoosts = new int[] { }, YggdrasilLoadout = new int[] { }, SwapYggdrasilLoadouts = false, SwapTitanLoadouts = false, TitanLoadout = new int[] { }, ManageDiggers = true, ManageYggdrasil = false, ManageEnergy = true, ManageMagic = true, ManageInventory = true, ManageGear = true, AutoConvertBoosts = true, SnipeZone = 0, FastCombat = false, PrecastBuffs = true, AutoFight = false, AutoQuest = false, AutoQuestITOPOD = false, AllowMajorQuests = false, GoldDropLoadout = new int[] {}, AutoMoneyPit = false, AutoSpin = false, MoneyPitLoadout = new int[] {}, AutoRebirth = false, ManageWandoos = false, MoneyPitThreshold = 1e5, DoGoldSwap = false, BoostBlacklist = new int[] {}, CombatMode = 0, RecoverHealth = false, SnipeBossOnly = true, AllowZoneFallback = false, QuestFastCombat = true, AbandonMinors = false, MinorAbandonThreshold = 30, QuestCombatMode = 0, AutoBuyEM = false, AutoSpellSwap = false, CounterfeitThreshold = 400, SpaghettiThreshold = 30, BloodNumberThreshold = 1e10, CastBloodSpells = false, IronPillThreshold = 10000, BloodMacGuffinAThreshold = 6, BloodMacGuffinBThreshold = 6, CubePriority = 0, CombatEnabled = false, GlobalEnabled = false, QuickDiggers = new int[] {}, QuickLoadout = new int[] {}, UseButterMajor = false, ManualMinors = false, UseButterMinor = false, ActivateFruits = false, ManageR3 = true, WishPriorities = new int[] {}, BeastMode = true, ManageNGUDiff = true, AllocationFile = "default", TitanGoldTargets = new bool[ZoneHelpers.TitanZones.Length], ManageGoldLoadouts = false, ResnipeTime = 3600, TitanMoneyDone = new bool[ZoneHelpers.TitanZones.Length], TitanSwapTargets = new bool[ZoneHelpers.TitanZones.Length], GoldCBlockMode = false, DebugAllocation = false, AdventureTargetITOPOD = false, ITOPODRecoverHP = false, ITOPODCombatMode = 0, ITOPODBeastMode = true, ITOPODFastCombat = true, ITOPODPrecastBuffs = false, DisableOverlay = false, OptimizeITOPODFloor = false, YggSwapThreshold = 1, UpgradeDiggers = true, BlacklistedBosses = new int[0], SpecialBoostBlacklist = new int[0], MoreBlockParry = false, WishSortOrder = false, WishSortPriorities = false }; Settings.MassUpdate(temp); Log($"Created default settings"); } settingsForm = new SettingsForm(); if (string.IsNullOrEmpty(Settings.AllocationFile)) { Settings.SetSaveDisabled(true); Settings.AllocationFile = "default"; Settings.SetSaveDisabled(false); } if (Settings.TitanGoldTargets == null || Settings.TitanGoldTargets.Length == 0) { Settings.SetSaveDisabled(true); Settings.TitanGoldTargets = new bool[ZoneHelpers.TitanZones.Length]; Settings.SetSaveDisabled(false); } if (Settings.TitanMoneyDone == null || Settings.TitanMoneyDone.Length == 0) { Settings.SetSaveDisabled(true); Settings.TitanMoneyDone = new bool[ZoneHelpers.TitanZones.Length]; Settings.SetSaveDisabled(false); } if (Settings.TitanSwapTargets == null || Settings.TitanSwapTargets.Length == 0) { Settings.SetSaveDisabled(true); Settings.TitanSwapTargets = new bool[ZoneHelpers.TitanZones.Length]; Settings.SetSaveDisabled(false); } if (Settings.SpecialBoostBlacklist == null) { Settings.SetSaveDisabled(true); Settings.SpecialBoostBlacklist = new int[0]; Settings.SetSaveDisabled(false); } if (Settings.BlacklistedBosses == null) { Settings.SetSaveDisabled(true); Settings.BlacklistedBosses = new int[0]; Settings.SetSaveDisabled(false); } WishManager = new WishManager(); LoadAllocation(); LoadAllocationProfiles(); ZoneWatcher = new FileSystemWatcher { Path = _dir, Filter = "zoneOverride.json", NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true }; ZoneWatcher.Changed += (sender, args) => { Log(_dir); ZoneStatHelper.CreateOverrides(_dir); }; ConfigWatcher = new FileSystemWatcher { Path = _dir, Filter = "settings.json", NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true }; ConfigWatcher.Changed += (sender, args) => { if (IgnoreNextChange) { IgnoreNextChange = false; return; } Settings.LoadSettings(); settingsForm.UpdateFromSettings(Settings); LoadAllocation(); }; AllocationWatcher = new FileSystemWatcher { Path = _profilesDir, Filter = "*.json", NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName, EnableRaisingEvents = true }; AllocationWatcher.Changed += (sender, args) => { LoadAllocation(); }; AllocationWatcher.Created += (sender, args) => { LoadAllocationProfiles(); }; AllocationWatcher.Deleted += (sender, args) => { LoadAllocationProfiles(); }; AllocationWatcher.Renamed += (sender, args) => { LoadAllocationProfiles(); }; Settings.SaveSettings(); Settings.LoadSettings(); LogAllocation("Started Allocation Writer"); ZoneStatHelper.CreateOverrides(_dir); settingsForm.UpdateFromSettings(Settings); settingsForm.Show(); InvokeRepeating("AutomationRoutine", 0.0f, 10.0f); InvokeRepeating("SnipeZone", 0.0f, .1f); InvokeRepeating("MonitorLog", 0.0f, 1f); InvokeRepeating("QuickStuff", 0.0f, .5f); InvokeRepeating("ShowBoostProgress", 0.0f, 60.0f); InvokeRepeating("SetResnipe", 0f, 1f); reference = this; } catch (Exception e) { Log(e.ToString()); Log(e.StackTrace); Log(e.InnerException.ToString()); } }
public void Update() { _timeLeft -= Time.deltaTime; _combManager.UpdateFightTimer(Time.deltaTime); settingsForm.UpdateProgressBar((int)Math.Floor(_timeLeft / 10 * 100)); if (Input.GetKeyDown(KeyCode.F1)) { if (!settingsForm.Visible) { settingsForm.Show(); } settingsForm.BringToFront(); } if (Input.GetKeyDown(KeyCode.F2)) { Settings.GlobalEnabled = !Settings.GlobalEnabled; } if (Input.GetKeyDown(KeyCode.F3)) { QuickSave(); } if (Input.GetKeyDown(KeyCode.F7)) { QuickLoad(); } if (Input.GetKeyDown(KeyCode.F4)) { Settings.AutoQuestITOPOD = !Settings.AutoQuestITOPOD; } if (Input.GetKeyDown(KeyCode.F5)) { DumpEquipped(); } if (Input.GetKeyDown(KeyCode.F8)) { if (Settings.QuickLoadout.Length > 0) { if (_tempSwapped) { Log("Restoring Previous Loadout"); LoadoutManager.RestoreTempLoadout(); } else { Log("Equipping Quick Loadout"); LoadoutManager.SaveTempLoadout(); LoadoutManager.ChangeGear(Settings.QuickLoadout); } } if (Settings.QuickDiggers.Length > 0) { if (_tempSwapped) { Log("Equipping Previous Diggers"); DiggerManager.RestoreTempDiggers(); } else { Log("Equipping Quick Diggers"); DiggerManager.SaveTempDiggers(); DiggerManager.EquipDiggers(Settings.QuickDiggers); } } _tempSwapped = !_tempSwapped; } // F11 reserved for testing //if (Input.GetKeyDown(KeyCode.F11)) //{ // Character.realExp += 10000; //} }
public static LoadoutManager.Loadout GetLoadout(int idPlayer, int iChrSlot) { return(LoadoutManager.UnserializeLoadout((int[])PhotonNetwork.CurrentRoom.CustomProperties[GetLoadoutKey(idPlayer, iChrSlot)])); }
public override void Attached() { loadoutManager = GameObject.Find("PlayerManager").GetComponent <LoadoutManager>(); InstantiateWeapons(); shooting = GetComponent <Shooting>(); }
private void SnipeZone() { if (!Settings.GlobalEnabled) { return; } //If tm ever drops to 0, reset our gold loadout stuff if (Character.machine.realBaseGold == 0.0 && !Settings.DoGoldSwap) { Log("Time Machine Gold is 0. Lets reset gold snipe zone."); Settings.DoGoldSwap = true; Settings.TitanMoneyDone = new bool[ZoneHelpers.TitanZones.Length]; } //This logic should trigger only if Time Machine is ready if (Character.buttons.brokenTimeMachine.interactable) { if (Character.machine.realBaseGold == 0.0) { _combManager.ManualZone(0, false, false, false, true, false); return; } //Go to our gold loadout zone next to get a high gold drop if (Settings.ManageGoldLoadouts && Settings.DoGoldSwap && Settings.GoldDropLoadout.Length > 0) { if (LoadoutManager.TryGoldDropSwap()) { var bestZone = ZoneStatHelper.GetBestZone(); _furthestZone = ZoneHelpers.GetMaxReachableZone(false); _combManager.ManualZone(bestZone.Zone, true, bestZone.FightType == 1, false, bestZone.FightType == 2, false); return; } } } var questZone = _questManager.IsQuesting(); if (!Settings.CombatEnabled || Settings.AdventureTargetITOPOD || !ZoneHelpers.ZoneIsTitan(Settings.SnipeZone) || ZoneHelpers.ZoneIsTitan(Settings.SnipeZone) && !ZoneHelpers.TitanSpawningSoon(Array.IndexOf(ZoneHelpers.TitanZones, Settings.SnipeZone))) { if (questZone > 0) { if (Settings.QuestCombatMode == 0) { _combManager.ManualZone(questZone, false, false, false, Settings.QuestFastCombat, Settings.BeastMode); } else { _combManager.IdleZone(questZone, false, false); } return; } } if (!Settings.CombatEnabled) { return; } var tempZone = Settings.AdventureTargetITOPOD ? 1000 : Settings.SnipeZone; if (tempZone < 1000) { if (!CombatManager.IsZoneUnlocked(Settings.SnipeZone)) { tempZone = Settings.AllowZoneFallback ? ZoneHelpers.GetMaxReachableZone(false) : 1000; } else { if (ZoneHelpers.ZoneIsTitan(Settings.SnipeZone) && !ZoneHelpers.TitanSpawningSoon(Array.IndexOf(ZoneHelpers.TitanZones, Settings.SnipeZone))) { tempZone = 1000; } } } if (tempZone >= 1000) { if (Settings.ITOPODCombatMode == 0) { _combManager.ManualZone(tempZone, false, Settings.ITOPODRecoverHP, Settings.ITOPODPrecastBuffs, Settings.ITOPODFastCombat, Settings.ITOPODBeastMode); } else { _combManager.IdleZone(tempZone, false, Settings.ITOPODRecoverHP); } return; } if (Settings.CombatMode == 0) { _combManager.ManualZone(tempZone, Settings.SnipeBossOnly, Settings.RecoverHealth, Settings.PrecastBuffs, Settings.FastCombat, Settings.BeastMode); } else { _combManager.IdleZone(tempZone, Settings.SnipeBossOnly, Settings.RecoverHealth); } }
private void DrawHeader(Rect canvas) { WidgetRow widgetRow = new WidgetRow(canvas.x, canvas.y, UIDirection.RightThenDown); if (widgetRow.ButtonText(UIText.CreateCostume.TranslateSimple())) { AwesomeInventoryCostume costume = new AwesomeInventoryCostume(_loadout); _costume = costume; _loadout.Costumes.Add(costume); LoadoutManager.AddLoadout(costume); } if (widgetRow.ButtonText(UIText.CopyCostume.TranslateSimple())) { if (_costume != null) { AwesomeInventoryCostume costume = new AwesomeInventoryCostume(_costume); _costume = costume; _loadout.Costumes.Add(costume); LoadoutManager.AddLoadout(costume); } else { DrawNoCostumeWindow(); } } if (widgetRow.ButtonText(UIText.DeleteCostume.TranslateSimple())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (AwesomeInventoryCostume costume in _loadout.Costumes) { options.Add( new FloatMenuOption( costume.label , () => { if (LoadoutManager.TryRemoveLoadout(costume)) { _loadout.Costumes.Remove(costume); _costume = null; _pawn.outfits.CurrentOutfit = _loadout; } })); } if (!options.Any()) { options.Add(new FloatMenuOption(UIText.NoCostumeAvailable.TranslateSimple(), null)); } Find.WindowStack.Add(new FloatMenu(options)); } if (widgetRow.ButtonText(UIText.SelectCostume.TranslateSimple())) { List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (AwesomeInventoryCostume costume in _loadout.Costumes) { options.Add( new FloatMenuOption( costume.label , () => { _costume = costume; })); } if (!options.Any()) { options.Add(new FloatMenuOption(UIText.NoCostumeAvailable.TranslateSimple(), null)); } Find.WindowStack.Add(new FloatMenu(options)); } Rect nameRect = new Rect(widgetRow.FinalX, widgetRow.FinalY, canvas.width - widgetRow.FinalX, GenUI.ListSpacing); string name; if (_costume == null) { name = UIText.NoCostumeAvailable.TranslateSimple(); GUI.color = Color.grey; } else { name = _costume.label; } name = Widgets.TextField(nameRect, name); if (_costume != null) { _costume.label = name; } GUI.color = Color.white; }
/// <summary> /// Find an item that should be dropped from the pawn's inventory and how much to drop. /// </summary> /// <param name="pawn"></param> /// <param name="dropThing">The thing which should be dropped.</param> /// <param name="dropCount">The amount to drop.</param> /// <returns>bool, true indicates that the out variables are filled with something to do work on (drop).</returns> // NOTE (ProfoundDarkness): Ended up doing this by nibbling away at the pawn's inventory (or dictionary representation of ThingDefs/Count). // Probably not efficient but was easier to handle atm. static public bool GetExcessThing(this Pawn pawn, out Thing dropThing, out int dropCount) { //(ProfoundDarkness) Thanks to erdelf on the RimWorldMod discord for helping me figure out some dictionary stuff and C# concepts related to 'Primitives' (pass by Value). CompInventory inventory = pawn.TryGetComp <CompInventory>(); Loadout loadout = pawn.GetLoadout(); List <HoldRecord> records = LoadoutManager.GetHoldRecords(pawn); dropThing = null; dropCount = 0; if (inventory == null || inventory.container == null || loadout == null || loadout.Slots.NullOrEmpty()) { return(false); } Dictionary <ThingDef, int> listing = GetStorageByThingDef(pawn); // iterate over specifics and generics and Chip away at the dictionary. foreach (LoadoutSlot slot in loadout.Slots) { if (slot.thingDef != null && listing.ContainsKey(slot.thingDef)) { listing[slot.thingDef] -= slot.count; if (listing[slot.thingDef] <= 0) { listing.Remove(slot.thingDef); } } if (slot.genericDef != null) { List <ThingDef> killKeys = new List <ThingDef>(); int desiredCount = slot.count; // find dictionary entries which corespond to covered slot. foreach (ThingDef def in listing.Keys.Where(td => slot.genericDef.lambda(td))) { listing[def] -= desiredCount; if (listing[def] <= 0) { desiredCount = 0 - listing[def]; killKeys.Add(def); // the thing in inventory is exausted, forget about it. } else { break; // we have satisifed this loadout so no need to keep enumerating. } } // cleanup dictionary. foreach (ThingDef def in killKeys) { listing.Remove(def); } } } // if there is something left in the dictionary, that is what is to be dropped. // Complicated by the fact that we now consider ammo in guns as part of the inventory... if (listing.Any()) { if (records != null && !records.NullOrEmpty()) { // look at each remaining 'uneaten' thingdef in pawn's inventory. foreach (ThingDef def in listing.Keys) { HoldRecord rec = records.FirstOrDefault(r => r.thingDef == def); if (rec == null) { // the item we have extra of has no HoldRecord, drop it. dropThing = inventory.container.FirstOrDefault(t => t.def == def); if (dropThing != null) { dropCount = listing[def] > dropThing.stackCount ? dropThing.stackCount : listing[def]; return(true); } } else if (rec.count < listing[def]) { // the item we have extra of HAS a HoldRecord but the amount carried is above the limit of the HoldRecord, drop extra. dropThing = pawn.inventory.innerContainer.FirstOrDefault(t => t.def == def); if (dropThing != null) { dropCount = listing[def] - rec.count; dropCount = dropCount > dropThing.stackCount ? dropThing.stackCount : dropCount; return(true); } } } } else { foreach (ThingDef def in listing.Keys) { dropThing = inventory.container.FirstOrDefault(t => t.GetInnerIfMinified().def == def); if (dropThing != null) { dropCount = listing[def] > dropThing.stackCount ? dropThing.stackCount : listing[def]; return(true); } } } } // else return(false); }
// Runs every 10 seconds, our main loop void AutomationRoutine() { try { if (!Settings.GlobalEnabled) { _timeLeft = 10f; return; } ZoneHelpers.OptimizeITOPOD(); if (Settings.ManageInventory && !Controller.midDrag) { var converted = Character.inventory.GetConvertedInventory().ToArray(); var boostSlots = _invManager.GetBoostSlots(converted); _invManager.EnsureFiltered(converted); _invManager.ManageConvertibles(converted); _invManager.MergeEquipped(converted); _invManager.MergeInventory(converted); _invManager.MergeBoosts(converted); _invManager.MergeGuffs(converted); _invManager.BoostInventory(boostSlots); _invManager.BoostInfinityCube(); _invManager.ManageBoostConversion(boostSlots); } //if (Settings.ManageInventory && !Controller.midDrag) //{ // var watch = Stopwatch.StartNew(); // var converted = Character.inventory.GetConvertedInventory().ToArray(); // Log($"Creating CI: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // var boostSlots = _invManager.GetBoostSlots(converted); // Log($"Get Boost Slots: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.EnsureFiltered(converted); // Log($"Filtering: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.ManageConvertibles(converted); // Log($"Convertibles: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.MergeEquipped(converted); // Log($"Merge Equipped: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.MergeInventory(converted); // Log($"Merge Inventory: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.MergeBoosts(converted); // Log($"Merge Boosts: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.MergeGuffs(converted); // Log($"Merge Guffs: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.BoostInventory(boostSlots); // Log($"Boost Inventory: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.BoostInfinityCube(); // Log($"Boost Cube: {watch.ElapsedMilliseconds}"); // watch = Stopwatch.StartNew(); // _invManager.ManageBoostConversion(boostSlots); // Log($"Boost Conversion: {watch.ElapsedMilliseconds}"); // watch.Stop(); //} if (Settings.SwapTitanLoadouts || Settings.ManageGoldLoadouts && Settings.NeedsGoldSwap()) { LoadoutManager.TryTitanSwap(); DiggerManager.TryTitanSwap(); } if (Settings.ManageYggdrasil && Character.buttons.yggdrasil.interactable) { _yggManager.ManageYggHarvest(); _yggManager.CheckFruits(); } if (Settings.AutoBuyEM) { //We haven't unlocked custom purchases yet if (Character.highestBoss < 17) { return; } var ePurchase = Character.energyPurchases; var mPurchase = Character.magicPurchases; var r3Purchase = Character.res3Purchases; var energy = ePurchase.customAllCost() > 0; var r3 = Character.res3.res3On && r3Purchase.customAllCost() > 0; var magic = Character.highestBoss >= 37 && mPurchase.customAllCost() > 0; long total = 0; if (energy) { total += ePurchase.customAllCost(); } if (magic) { total += mPurchase.customAllCost(); } if (r3) { total += r3Purchase.customAllCost(); } if (total > 0) { var numPurchases = Math.Floor((double)(Character.realExp / total)); if (numPurchases > 0) { var t = string.Empty; if (energy) { t += "/exp"; } if (magic) { t += "/magic"; } if (r3) { t += "/res3"; } t = t.Substring(1); Log($"Buying {numPurchases} {t} purchases"); for (var i = 0; i < numPurchases; i++) { if (energy) { var ePurchaseMethod = ePurchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); ePurchaseMethod?.Invoke(ePurchase, null); } if (magic) { var mPurchaseMethod = mPurchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); mPurchaseMethod?.Invoke(mPurchase, null); } if (r3) { var r3PurchaseMethod = r3Purchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); r3PurchaseMethod?.Invoke(r3Purchase, null); } } } } } _profile.DoAllocations(); _profile.CastBloodSpells(); if (Settings.AutoQuest && Character.buttons.beast.interactable) { var converted = Character.inventory.GetConvertedInventory().ToArray(); if (!Character.inventoryController.midDrag) { _invManager.ManageQuestItems(converted); } _questManager.CheckQuestTurnin(); _questManager.ManageQuests(); } if (Settings.AutoRebirth) { _profile.DoRebirth(); } if (Settings.ManageMayo) { _cardManager.CheckManas(); } if (Settings.TrashCards) { _cardManager.TrashCards(); } if (Settings.AutoCastCards) { _cardManager.CastCards(); } } catch (Exception e) { Log(e.Message); Log(e.StackTrace); } _timeLeft = 10f; }
public void Start() { _dir = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%/Desktop"), "NGUInjector"); if (!Directory.Exists(_dir)) { Directory.CreateDirectory(_dir); } var logDir = Path.Combine(_dir, "logs"); if (!Directory.Exists(logDir)) { Directory.CreateDirectory(logDir); } OutputWriter = new StreamWriter(Path.Combine(logDir, "inject.log")) { AutoFlush = true }; LootWriter = new StreamWriter(Path.Combine(logDir, "loot.log")) { AutoFlush = true }; CombatWriter = new StreamWriter(Path.Combine(logDir, "combat.log")) { AutoFlush = true }; AllocationWriter = new StreamWriter(Path.Combine(logDir, "allocation.log")) { AutoFlush = true }; PitSpinWriter = new StreamWriter(Path.Combine(logDir, "pitspin.log"), true) { AutoFlush = true }; try { Character = FindObjectOfType <Character>(); Log("Injected"); LogLoot("Starting Loot Writer"); LogCombat("Starting Combat Writer"); LogAllocation("Started Allocation Writer"); Controller = Character.inventoryController; PlayerController = FindObjectOfType <PlayerController>(); _invManager = new InventoryManager(); _yggManager = new YggdrasilManager(); _questManager = new QuestManager(); _combManager = new CombatManager(); LoadoutManager.ReleaseLock(); DiggerManager.ReleaseLock(); Settings = new SavedSettings(_dir); if (!Settings.LoadSettings()) { var temp = new SavedSettings(null) { PriorityBoosts = new int[] { }, YggdrasilLoadout = new int[] { }, SwapYggdrasilLoadouts = true, HighestAKZone = 0, SwapTitanLoadouts = true, TitanLoadout = new int[] { }, ManageDiggers = true, ManageYggdrasil = true, ManageEnergy = true, ManageMagic = true, ManageInventory = true, ManageGear = true, AutoConvertBoosts = true, SnipeZone = 0, FastCombat = false, PrecastBuffs = true, AutoFight = false, AutoQuest = true, AutoQuestITOPOD = false, AllowMajorQuests = false, GoldDropLoadout = new int[] {}, AutoMoneyPit = false, AutoSpin = false, MoneyPitLoadout = new int[] {}, AutoRebirth = false, ManageWandoos = false, InitialGoldZone = -1, MoneyPitThreshold = 1e5, NextGoldSwap = false, BoostBlacklist = new int[] {}, GoldZone = 0, CombatMode = 0, RecoverHealth = false, SnipeBossOnly = true, AllowZoneFallback = false, QuestFastCombat = true, AbandonMinors = false, MinorAbandonThreshold = 30, QuestCombatMode = 0, AutoBuyEM = false, AutoSpellSwap = false, CounterfeitThreshold = 400, SpaghettiThreshold = 30, BloodNumberThreshold = 1e10, CubePriority = 0, CombatEnabled = false, GlobalEnabled = true, QuickDiggers = new int[] {}, QuickLoadout = new int[] {}, UseButterMajor = false, ManualMinors = false, UseButterMinor = false, ActivateFruits = true, ManageR3 = true, WishPriorities = new int[] {}, BeastMode = true }; Settings.MassUpdate(temp); Log($"Created default settings"); } settingsForm = new SettingsForm(); _profile = new CustomAllocation(_dir); _profile.ReloadAllocation(); ConfigWatcher = new FileSystemWatcher { Path = _dir, Filter = "settings.json", NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true }; ConfigWatcher.Changed += (sender, args) => { if (IgnoreNextChange) { IgnoreNextChange = false; return; } Settings.LoadSettings(); settingsForm.UpdateFromSettings(Settings); }; AllocationWatcher = new FileSystemWatcher { Path = _dir, Filter = "allocation.json", NotifyFilter = NotifyFilters.LastWrite, EnableRaisingEvents = true }; AllocationWatcher.Changed += (sender, args) => { LoadAllocation(); }; Settings.SaveSettings(); Settings.LoadSettings(); settingsForm.UpdateFromSettings(Settings); settingsForm.Show(); InvokeRepeating("AutomationRoutine", 0.0f, 10.0f); InvokeRepeating("SnipeZone", 0.0f, .1f); InvokeRepeating("MonitorLog", 0.0f, 1f); InvokeRepeating("QuickStuff", 0.0f, .5f); InvokeRepeating("ShowBoostProgress", 0.0f, 60.0f); } catch (Exception e) { Log(e.Message); Log(e.StackTrace); } }
private void SnipeZone() { if (!Settings.GlobalEnabled) { return; } //If tm ever drops to 0, reset our gold loadout stuff if (Character.machine.realBaseGold == 0.0 && !Settings.NextGoldSwap) { Log("Resetting Gold Loadout"); Settings.NextGoldSwap = true; settingsForm.UpdateGoldLoadout(Settings.NextGoldSwap); } //This logic should trigger only if Time Machine is ready if (Character.buttons.brokenTimeMachine.interactable) { //Hit our initial gold zone first to get TM started if (Character.machine.realBaseGold == 0.0 && CombatManager.IsZoneUnlocked(Settings.InitialGoldZone) && Settings.InitialGoldZone >= 0) { _combManager.ManualZone(Settings.InitialGoldZone, false, false, false, true); return; } //Go to our gold loadout zone next to get a high gold drop if (Settings.NextGoldSwap) { if (CombatManager.IsZoneUnlocked(Settings.GoldZone) && !ZoneHelpers.ZoneIsTitan(Settings.GoldZone) && Settings.GoldZone >= 0) { if (LoadoutManager.TryGoldDropSwap()) { _combManager.ManualZone(Settings.GoldZone, true, false, false, true); return; } } } } var questZone = _questManager.IsQuesting(); if (questZone > 0) { if (Settings.QuestCombatMode == 0) { _combManager.ManualZone(questZone, false, false, false, Settings.QuestFastCombat); } else { _combManager.IdleZone(questZone, false, false); } return; } if (!Settings.CombatEnabled) { return; } if (Settings.SnipeZone < 0) { return; } var tempZone = Settings.SnipeZone; if (Settings.SnipeZone < 1000) { if (!CombatManager.IsZoneUnlocked(Settings.SnipeZone)) { if (!Settings.AllowZoneFallback) { return; } for (var i = Character.adventureController.zoneDropdown.options.Count - 2; i >= 0; i--) { if (!ZoneHelpers.ZoneIsTitan(i)) { tempZone = i; break; } } } else { if (ZoneHelpers.ZoneIsTitan(Settings.SnipeZone) && !ZoneHelpers.TitansSpawningSoon().SpawningSoon) { tempZone = 1000; } } } if (Settings.CombatMode == 0) { _combManager.ManualZone(tempZone, Settings.SnipeBossOnly, Settings.RecoverHealth, Settings.PrecastBuffs, Settings.FastCombat); } else { _combManager.IdleZone(tempZone, Settings.SnipeBossOnly, Settings.RecoverHealth); } }
// Runs every 10 seconds, our main loop void AutomationRoutine() { try { if (!Settings.GlobalEnabled) { _timeLeft = 10f; return; } if (Settings.ManageInventory) { var converted = Character.inventory.GetConvertedInventory().ToArray(); var boostSlots = _invManager.GetBoostSlots(converted); _invManager.EnsureFiltered(converted); _invManager.ManageConvertibles(converted); _invManager.MergeEquipped(); _invManager.MergeInventory(converted); _invManager.MergeBoosts(converted); _invManager.MergeGuffs(converted); _invManager.BoostInventory(boostSlots); _invManager.BoostInfinityCube(); _invManager.ManageBoostConversion(boostSlots); } if (Settings.SwapTitanLoadouts) { LoadoutManager.TryTitanSwap(); DiggerManager.TryTitanSwap(); } if (Settings.ManageYggdrasil && Character.buttons.yggdrasil.interactable) { _yggManager.ManageYggHarvest(); _yggManager.CheckFruits(); } if (Settings.AutoBuyEM) { //We haven't unlocked custom purchases yet if (Character.highestBoss < 17) { return; } var r3 = Character.res3.res3On; var magic = Character.highestBoss >= 37; long total = 0; var ePurchase = Character.energyPurchases; var mPurchase = Character.magicPurchases; var r3Purchase = Character.res3Purchases; total += ePurchase.customAllCost(); if (magic) { total += mPurchase.customAllCost(); } if (r3) { total += r3Purchase.customAllCost(); } var numPurchases = Math.Floor((double)(Character.realExp / total)); if (numPurchases > 0) { var t = "exp"; if (magic) { t += "/magic"; } if (r3) { t += "/res3"; } Log($"Buying {numPurchases} {t} purchases"); for (var i = 0; i < numPurchases; i++) { var ePurchaseMethod = ePurchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); ePurchaseMethod?.Invoke(ePurchase, null); if (magic) { var mPurchaseMethod = mPurchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); mPurchaseMethod?.Invoke(mPurchase, null); } if (r3) { var r3PurchaseMethod = r3Purchase.GetType().GetMethod("buyCustomAll", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance); r3PurchaseMethod?.Invoke(r3Purchase, null); } } } } if (Settings.ManageGear) { _profile.EquipGear(); } if (Settings.ManageEnergy) { _profile.AllocateEnergy(); } if (Settings.ManageMagic) { _profile.AllocateMagic(); } if (Settings.ManageR3) { _profile.AllocateR3(); } if (Settings.ManageDiggers && Character.buttons.diggers.interactable) { _profile.EquipDiggers(); DiggerManager.RecapDiggers(); } if (Settings.ManageWandoos && Character.buttons.wandoos.interactable) { _profile.SwapOS(); } if (Settings.AutoQuest && Character.buttons.beast.interactable) { var converted = Character.inventory.GetConvertedInventory().ToArray(); _invManager.ManageQuestItems(converted); _questManager.CheckQuestTurnin(); _questManager.ManageQuests(); } if (Settings.AutoRebirth) { _profile.DoRebirth(); } Character.refreshMenus(); } catch (Exception e) { Log(e.Message); Log(e.StackTrace); } _timeLeft = 10f; }
public void LoadLoadout() { //Load whichever loadout slot is currently selected in the loadout dropdown InitWithLoadout(LoadoutManager.LoadSavedLoadoutForChr(ChrTypeSelectingFor(), dropdownSavedLoadouts.value)); }
public void DrawTagEditor(Rect r) { _ = r.PopRightPartPixels(Margin); var topRect = r.TopPartPixels(22f); if (Widgets.ButtonText(topRect.LeftPart(0.33f), "SelectTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", tag => curTag = tag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } topRect.AdjHorzBy(topRect.width * 0.33f); if (Widgets.ButtonText(topRect.LeftHalf(), "CreateNewTag")) { curTag = new Tag(string.Empty); LoadoutManager.AddTag(curTag); } if (Widgets.ButtonText(topRect.RightHalf(), "DeleteTag")) { var floatOpts = LoadoutManager.OptionPerTag(tag => $"{tag.name}", LoadoutManager.RemoveTag); if (floatOpts.Count == 0) { Messages.Message(new Message("NoTagsYetWarning", MessageTypeDefOf.RejectInput)); } else { Find.WindowStack.Add(new FloatMenu(floatOpts)); } } r.AdjVertBy(ModGUIUtility.DEFAULT_HEIGHT); if (curTag == null) { return; } Widgets.ListSeparator(ref r.m_YMin, r.width, "Modify".Translate() + " " + curTag.name); // [ Tag Name ] [ Edit Name ] var rect = r.PopTopPartPixels(ModGUIUtility.DEFAULT_HEIGHT); ModGUIUtility.InputField(rect, "ChangeTagName".Translate(), ref curTag.name); curTag.name ??= " "; var viewRect = new Rect(r.x, r.y, rect.width - 16f, (curTag.requiredItems.Count * ModGUIUtility.SPACED_HEIGHT * 2)); Widgets.BeginScrollView(r, ref curItemScroll, viewRect); var visibilityRect = r; visibilityRect.y += curItemScroll.y; var baseRect = viewRect; List <Item> toRemove = new List <Item>(); // List each item in the currently required items // [ Info ] [ Icon ] [ Name ] [ Edit Filter ] [ Edit Quantity ] [ Remove ] foreach (var item in curTag.requiredItems) { var def = item.Def; var itemRect = baseRect.PopTopPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (!itemRect.Overlaps(visibilityRect)) { continue; } // Info Rect infoRect = itemRect.PopLeftPartPixels(GenUI.SmallIconSize); if (Widgets.ButtonImageFitted(infoRect.ContractedBy(1f), TexButton.Info)) { Thing thing = Utility.MakeThingWithoutID(def, item.RandomStuff, item.RandomQuality); Find.WindowStack.Add(new Dialog_InfoCard(thing)); } // Icon var iconRect = itemRect.PopLeftPartPixels(ModGUIUtility.SPACED_HEIGHT * 2); if (item.Quantity > 1) { ModGUIUtility.FittedDefIconCount(iconRect, def, item.RandomStuff, item.Quantity); } else { Widgets.DefIcon(iconRect, def, item.RandomStuff); } TooltipHandler.TipRegion(iconRect, item.Def.DescriptionDetailed); // Remove var removeButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(removeButton.ContractedBy(1f), TexButton.DeleteX)) { toRemove.Add(item); } TooltipHandler.TipRegion(removeButton, "RemoveItemFromTag".Translate()); // Copy, Paste var copyPasteButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 3); ModGUIUtility.DraggableCopyPaste(copyPasteButton, ref item.filter, Filter.CopyFrom); TooltipHandler.TipRegion(copyPasteButton, "CopyPasteExplain".Translate()); // Edit var constrainButton = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 1.5f); if (Widgets.ButtonImageFitted(constrainButton.ContractedBy(1f), Textures.EditTex)) { Find.WindowStack.Add(new Dialog_ItemSpecifier(item.Filter)); } TooltipHandler.TipRegion(constrainButton, Strings.SpecifyElementsToolTip); var quantityFieldRect = itemRect.PopRightPartPixels(ModGUIUtility.SPACED_HEIGHT * 2f); item.quantityStr ??= item.Quantity.ToString(); ModGUIUtility.InputField(quantityFieldRect.ContractedBy(0, quantityFieldRect.height / 4.0f), "QuantityField" + item.Def.defName, ref item.quantityStr); if (item.quantityStr == "") { item.SetQuantity(0); } else { try { item.SetQuantity(int.Parse(item.quantityStr)); } catch (Exception e) { Log.ErrorOnce($"Invalid numeric string {item.quantityStr}: " + e.Message, item.quantityStr.GetHashCode()); } } TooltipHandler.TipRegion(quantityFieldRect, Strings.EditQuantity); // Name Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(itemRect, item.Label); Text.Anchor = TextAnchor.UpperLeft; } Widgets.EndScrollView(); foreach (var item in toRemove) { curTag.requiredItems.Remove(item); } }