コード例 #1
0
ファイル: DeepDungeon.cs プロジェクト: dxd391285004/DeepDive
        public override void Start()
        {
            Poi.Current = null;

            if (DutyManager.InInstance && !Constants.SelectedDungeon.DeepDungeonRawIds.Contains(WorldManager.ZoneId))
            {
                Constants.SelectedDungeon             = Constants.GetDeepDungeonByMapid(WorldManager.ZoneId);
                Settings.Instance.BetterSelectedLevel = Constants.SelectedDungeon.Floors.FirstOrDefault(i => i.MapId == WorldManager.ZoneId);
                Logger.Warn($"Started bot inside dungeon (Not currently selected): Using {Constants.SelectedDungeon.DisplayName}");
            }

            if (Constants.SelectedDungeon == null)
            {
                Logger.Error("No Selected Deep Dungeon: Something went really wrong");
                _root = new ActionAlwaysFail();
                return;
            }

            if (Settings.Instance.BetterSelectedLevel == null)
            {
                Settings.Instance.BetterSelectedLevel = Constants.SelectedDungeon.Floors[0];
                Logger.Error($"No floor selected, setting it to use [{Settings.Instance.BetterSelectedLevel.DisplayName}]");
            }

            Logger.Info(Constants.SelectedDungeon.ToString());
            //setup navigation manager
            Navigator.NavigationProvider = new DDNavigationProvider(new ServiceNavigationProvider());
            Navigator.PlayerMover        = new SlideMover();

            TreeHooks.Instance.ClearAll();

            DeepTracker.InitializeTracker(Core.Me.ClassLevel);

            _tasks = new TaskManagerProvider();


            _tasks.Add(new LoadingHandler());
            _tasks.Add(new DeathWindowHandler());
            _tasks.Add(new SideStepTask());
            //not sure if i want the trap handler to be above combat or not
            _tasks.Add(new TrapHandler());

            //pomanders for sure need to happen before combat so that we can correctly apply Lust for bosses
            _tasks.Add(new Pomanders());

            _tasks.Add(new CombatHandler());

            _tasks.Add(new LobbyHandler());
            _tasks.Add(new GetToCaptain());
            _tasks.Add(new POTDEntrance());


            _tasks.Add(new CairnOfReturn());
            _tasks.Add(new FloorExit());
            _tasks.Add(new Loot());


            _tasks.Add(new StuckDetection());
            _tasks.Add(new POTDNavigation());


            _tasks.Add(new BaseLogicHandler());

            Settings.Instance.Stop = false;
            if (!Core.Me.IsDow())
            {
                Logger.Error("Please change to a DOW class");
                _root = new ActionAlwaysFail();
                return;
            }


            //setup combat manager
            CombatTargeting.Instance.Provider = new DDCombatTargetingProvider();

            GameSettingsManager.FaceTargetOnAction = true;


            if (Constants.Lang == Language.Chn)
            {
                //回避 - sidestep
                //Zekken
                if (PluginManager.Plugins.Any(i => (i.Plugin.Name.Contains("Zekken") || i.Plugin.Name.Contains("技能躲避")) && i.Enabled))
                {
                    Logger.Error("禁用 AOE技能躲避插件 - Zekken");
                    _root = new ActionAlwaysFail();
                    return;
                }
            }

            if (PluginManager.Plugins.Any(i => i.Plugin.Name == "Zekken" && i.Enabled))
            {
                Logger.Error(
                    "Zekken is currently turned on, It will interfere with DeepDive & SideStep. Please Turn it off and restart the bot.");
                _root = new ActionAlwaysFail();
                return;
            }


            if (!ConditionParser.IsQuestCompleted(Constants.SelectedDungeon.UnlockQuest))
            {
                Logger.Error($"You must complete \"{DataManager.GetLocalizedQuestName(Constants.SelectedDungeon.UnlockQuest)}\" to run this base.");
                Logger.Error(
                    "Please switch to \"Order Bot\" and run the profile: \\BotBases\\DeepDive\\Profiles\\PotD_Unlock.xml");
                _root = new ActionAlwaysFail();
                return;
            }

            if (!ConditionParser.IsQuestCompleted(Settings.Instance.BetterSelectedLevel.QuestId))
            {
                Logger.Error($"You must complete \"{DataManager.GetLocalizedQuestName(Settings.Instance.BetterSelectedLevel.QuestId)}\" to run this floor.");
                Logger.Error("Complete the quest or change the floor selection");
                _root = new ActionAlwaysFail();
                return;
            }

            Logger.Error($"Quest {Settings.Instance.BetterSelectedLevel.QuestId} - \"{DataManager.GetLocalizedQuestName(Settings.Instance.BetterSelectedLevel.QuestId)}\" to run this base.");

            StopPlz = false;

            SetupSettings();

            _root =
                new ActionRunCoroutine(async x =>
            {
                if (StopPlz)
                {
                    return(false);
                }
                if (!_init)
                {
                    Logging.Write("DeepDive is waiting on Initialization to finish");
                    return(true);
                }

                if (await _tasks.Run())
                {
                    await Coroutine.Yield();
                }
                else
                {
                    Logger.Warn("No tasks ran");
                    await Coroutine.Sleep(1000);
                }

                return(true);
            });
        }