Esempio n. 1
0
        public override void EquipDiggers()
        {
            if (_wrapper == null)
            {
                return;
            }
            var bp = GetCurrentDiggerBreakpoint();

            if (bp == null)
            {
                return;
            }

            if (bp.Time != _currentDiggerBreakpoint.Time)
            {
                _hasDiggerSwapped = false;
            }

            if (_hasDiggerSwapped)
            {
                return;
            }

            if (!DiggerManager.CanSwap())
            {
                return;
            }
            _hasDiggerSwapped        = true;
            _currentDiggerBreakpoint = bp;

            DiggerManager.EquipDiggers(bp.Diggers);
            _character.allDiggers.refreshMenu();
        }
Esempio n. 2
0
        protected bool PreRebirth()
        {
            if (Main.Settings.ManageYggdrasil && YggdrasilManager.AnyHarvestable())
            {
                if (Main.Settings.SwapYggdrasilLoadouts && Main.Settings.YggdrasilLoadout.Length > 0)
                {
                    if (!LoadoutManager.TryYggdrasilSwap() || !DiggerManager.TryYggSwap())
                    {
                        Main.Log("Delaying rebirth to wait for ygg loadout/diggers");
                        return(true);
                    }

                    YggdrasilManager.HarvestAll();
                    Main.Log("Delaying rebirth 1 loop to allow fruit effects");
                    return(true);
                }

                YggdrasilManager.HarvestAll();
                Main.Log("Delaying rebirth 1 loop to allow fruit effects");
                return(true);
            }

            DiggerManager.UpgradeCheapestDigger();

            CastBloodSpells(true);
            return(false);
        }
Esempio n. 3
0
        internal static void DoAllocations(this CustomAllocation allocation)
        {
            if (!Settings.GlobalEnabled)
            {
                return;
            }

            if (allocation.IsAllocationRunning)
            {
                return;
            }
            try
            {
                var originalInput = Main.Character.energyMagicPanel.energyMagicInput;

                allocation.IsAllocationRunning = true;

                if (Settings.ManageNGUDiff)
                {
                    allocation.SwapNGUDiff();
                }
                if (Settings.ManageGear)
                {
                    allocation.EquipGear();
                }
                if (Settings.ManageEnergy)
                {
                    allocation.AllocateEnergy();
                }
                if (Settings.ManageMagic)
                {
                    allocation.AllocateMagic();
                }
                if (Settings.ManageR3)
                {
                    allocation.AllocateR3();
                }

                if (Settings.ManageDiggers && Main.Character.buttons.diggers.interactable)
                {
                    allocation.EquipDiggers();
                    DiggerManager.RecapDiggers();
                }

                if (Settings.ManageWandoos && Main.Character.buttons.wandoos.interactable)
                {
                    allocation.SwapOS();
                }

                Main.Character.energyMagicPanel.energyRequested.text = originalInput.ToString();
                Main.Character.energyMagicPanel.validateInput();
            }
            finally
            {
                allocation.IsAllocationRunning = false;
            }
        }
Esempio n. 4
0
        public void DoRebirth()
        {
            if (_wrapper == null)
            {
                return;
            }

            if (_wrapper.Breakpoints.RebirthTime < 0)
            {
                return;
            }

            if (_character.rebirthTime.totalseconds < _wrapper.Breakpoints.RebirthTime)
            {
                return;
            }

            if (Main.Settings.SwapYggdrasilLoadouts && Main.Settings.YggdrasilLoadout.Length > 0)
            {
                if (!LoadoutManager.TryYggdrasilSwap() || !DiggerManager.TryYggSwap())
                {
                    Main.Log("Delaying rebirth to wait for ygg loadout/diggers");
                    return;
                }

                YggdrasilManager.HarvestAll();
                LoadoutManager.RestoreGear();
                LoadoutManager.ReleaseLock();
                DiggerManager.RestoreDiggers();
                DiggerManager.ReleaseLock();
            }

            _currentDiggerBreakpoint  = null;
            _currentEnergyBreakpoint  = null;
            _currentGearBreakpoint    = null;
            _currentWandoosBreakpoint = null;
            _currentMagicBreakpoint   = null;
            _currentR3Breakpoint      = null;

            Main.Log("Rebirth time hit, performing rebirth");
            var controller = Main.Character.rebirth;

            typeof(Rebirth).GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
            .Single(x => x.Name == "engage" && x.GetParameters().Length == 0).Invoke(controller, null);
        }
Esempio n. 5
0
        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
            };

            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,
                        BalanceCube           = true,
                        CombatEnabled         = false,
                        GlobalEnabled         = true,
                        QuickDiggers          = new int[] {},
                        QuickLoadout          = new int[] {},
                        UseButterMajor        = false,
                        ManualMinors          = false,
                        UseButterMinor        = false,
                        ActivateFruits        = 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);
            }
            catch (Exception e)
            {
                Log(e.Message);
                Log(e.StackTrace);
            }
        }
Esempio n. 6
0
        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;
                    }
                    //Magic isn't unlocked yet
                    if (Character.highestBoss < 37)
                    {
                        var ePurchase    = Character.energyPurchases;
                        var total        = ePurchase.customAllCost();
                        var numPurchases = Math.Floor((double)(Character.realExp / total));
                        if (numPurchases > 0)
                        {
                            var ePurchaseMethod = ePurchase.GetType().GetMethod("buyCustomAll",
                                                                                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            if (ePurchaseMethod != null)
                            {
                                Log($"Buying {numPurchases} exp purchases");
                                for (var i = 0; i < numPurchases; i++)
                                {
                                    ePurchaseMethod.Invoke(ePurchase, null);
                                }
                            }
                        }
                    }
                    else
                    {
                        var ePurchase    = Character.energyPurchases;
                        var mPurchase    = Character.magicPurchases;
                        var total        = ePurchase.customAllCost() + mPurchase.customAllCost();
                        var numPurchases = Math.Floor((double)(Character.realExp / total));
                        if (numPurchases > 0)
                        {
                            var ePurchaseMethod = ePurchase.GetType().GetMethod("buyCustomAll",
                                                                                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            var mPurchaseMethod = mPurchase.GetType().GetMethod("buyCustomAll",
                                                                                BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                            if (ePurchaseMethod != null && mPurchaseMethod != null)
                            {
                                Log($"Buying {numPurchases} e/m purchases");
                                for (var i = 0; i < numPurchases; i++)
                                {
                                    ePurchaseMethod.Invoke(ePurchase, null);
                                    mPurchaseMethod.Invoke(mPurchase, 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();
                }
            }
            catch (Exception e)
            {
                Log(e.Message);
                Log(e.StackTrace);
            }
            _timeLeft = 10f;
        }
Esempio n. 7
0
        void QuickStuff()
        {
            //Turn on autoattack if we're in ITOPOD and its not on
            if (Settings.AutoQuestITOPOD && Character.adventureController.zone >= 1000 && !Character.adventure.autoattacking && !Settings.CombatEnabled)
            {
                Character.adventureController.idleAttackMove.setToggle();
            }

            if (Settings.AutoFight)
            {
                var needsAllocation = false;
                var bc = Character.bossController;
                if (!bc.isFighting && !bc.nukeBoss)
                {
                    if (Character.bossID == 0)
                    {
                        needsAllocation = true;
                    }

                    if (bc.character.attack / 5.0 > bc.character.bossDefense && bc.character.defense / 5.0 > bc.character.bossAttack)
                    {
                        bc.startNuke();
                    }
                    else
                    {
                        if (bc.character.attack > (bc.character.bossDefense * 1.4) && bc.character.defense > bc.character.bossAttack * 1.4)
                        {
                            bc.beginFight();
                            bc.stopButton.gameObject.SetActive(true);
                        }
                    }
                }

                if (needsAllocation)
                {
                    if (Settings.ManageGear)
                    {
                        _profile.EquipGear();
                    }
                    if (Settings.ManageEnergy)
                    {
                        _profile.AllocateEnergy();
                    }
                    if (Settings.ManageMagic)
                    {
                        _profile.AllocateMagic();
                    }
                    if (Settings.ManageDiggers && Character.buttons.diggers.interactable)
                    {
                        _profile.EquipDiggers();
                        DiggerManager.RecapDiggers();
                    }

                    if (Settings.ManageR3 && Character.buttons.hacks.interactable)
                    {
                        _profile.AllocateR3();
                    }

                    if (Settings.ManageWandoos && Character.buttons.wandoos.interactable)
                    {
                        _profile.SwapOS();
                    }
                }
            }

            if (Settings.AutoMoneyPit)
            {
                MoneyPitManager.CheckMoneyPit();
            }

            if (Settings.AutoSpin)
            {
                MoneyPitManager.DoDailySpin();
            }

            if (Settings.AutoQuestITOPOD)
            {
                MoveToITOPOD();
            }

            if (Settings.AutoSpellSwap)
            {
                var spaghetti   = (Character.bloodMagicController.lootBonus() - 1) * 100;
                var counterfeit = ((Character.bloodMagicController.goldBonus() - 1)) * 100;
                var number      = Character.bloodMagic.rebirthPower;
                Character.bloodMagic.rebirthAutoSpell = Settings.BloodNumberThreshold >= number;
                Character.bloodMagic.goldAutoSpell    = Settings.CounterfeitThreshold >= counterfeit;
                Character.bloodMagic.lootAutoSpell    = Settings.SpaghettiThreshold >= spaghetti;
                Character.bloodSpells.updateGoldToggleState();
                Character.bloodSpells.updateLootToggleState();
                Character.bloodSpells.updateRebirthToggleState();
            }
        }
Esempio n. 8
0
        public void Update()
        {
            _timeLeft -= 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;
                settingsForm.UpdateActive(Settings.GlobalEnabled);
            }

            if (Input.GetKeyDown(KeyCode.F3))
            {
                QuickSave();
            }

            if (Input.GetKeyDown(KeyCode.F7))
            {
                QuickLoad();
            }

            if (Input.GetKeyDown(KeyCode.F4))
            {
                Settings.AutoQuestITOPOD = !Settings.AutoQuestITOPOD;
                settingsForm.UpdateITOPOD(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;
            }

            //if (Input.GetKeyDown(KeyCode.F11))
            //{
            //
            //}
        }
Esempio n. 9
0
        // 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();
                }

                if (Settings.ManageCooking)
                {
                    _cookingManager.manageFood();
                }
            }
            catch (Exception e)
            {
                Log(e.Message);
                Log(e.StackTrace);
            }
            _timeLeft = 10f;
        }
Esempio n. 10
0
        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
                };
                CardsWriter = new StreamWriter(Path.Combine(logDir, "cards.log"))
                {
                    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");
                LogCard("Starting Card Writer");
                Controller          = Character.inventoryController;
                PlayerController    = FindObjectOfType <PlayerController>();
                ArbitraryController = FindObjectOfType <ArbitraryController>();
                _invManager         = new InventoryManager();
                _yggManager         = new YggdrasilManager();
                _questManager       = new QuestManager();
                _combManager        = new CombatManager();
                _cardManager        = new CardManager();
                _cookingManager     = new CookingManager();
                _consumablesManager = new ConsumablesManager();
                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,
                        ManageMayo               = false,
                        TrashCards               = false,
                        TrashAdventureCards      = false,
                        AutoCastCards            = false,
                        CardsTrashQuality        = 0,
                        TrashCardCost            = 0,
                        DontCastCardType         = new string[0],
                        TrashChunkers            = false,
                        HackAdvance              = 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());
            }
        }