Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
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());
            }
        }