/// <summary> /// Main task executor for the Commence Duty logic. /// </summary> /// <returns>Returns <c>true</c> if any action was executed, otherwise <c>false</c>.</returns> internal new async Task <bool> ExecuteLogic() { // Do not execute this logic if the botbase is paused if (BotBase.Instance.IsPaused) { return(await Task.FromResult(false)); } if (DutyManager.InInstance) { if (ShouldVoteMvp()) { if (await VoteMvp().ExecuteCoroutine()) { return(await Task.FromResult(true)); } } if (ShouldLeaveDuty()) { LogHelper.Instance.Log("Leaving Duty..."); DutyManager.LeaveActiveDuty(); return(await Task.FromResult(true)); } if (BotBase.Instance.AutoPickUpTreasure && !WorldManager.InPvP) { if (GameObjectManager.GetObjectsOfType <Treasure>(true) .FirstOrDefault(i => i.IsTargetable && i.State == 0 && i.Distance2DSqr() < 8) is Treasure treasure) { LogHelper.Instance.Log(treasure); treasure.Interact(); Core.Me.ClearTarget(); return(await Task.FromResult(true)); } } } if (ShouldRegisterDuties()) { try { DutyManager.Queue(new InstanceContentResult { Id = BotBase.Instance.DutyToRegister.Id, IsInDutyFinder = true, ChnName = BotBase.Instance.DutyToRegister.Name, EngName = BotBase.Instance.DutyToRegister.Name }); LogHelper.Instance.Log($"Queued duty {BotBase.Instance.DutyToRegister.Name}"); } catch (ArgumentException e) { LogHelper.Instance.Log(e.Message); } catch (NullReferenceException e) { LogHelper.Instance.Log("Please select a duty to register!"); } //catch (NullReferenceException e) //{ // LogHelper.Instance.Log(); //} return(await Task.FromResult(true)); } // Play Duty notification sound if (ShouldPlayDutyReadySound()) { ShowLogNotification(); PlayNotificationSound(); return(await Task.FromResult(true)); } // Auto accept Duty Finder if (ShouldAcceptDutyFinder()) { LogHelper.Instance.Log(Localization.Localization.Msg_DutyConfirm); ContentsFinderConfirm.Commence(); WaitHelper.Instance.RemoveWait(@"CommenceDuty.DutyNotificationSound"); return(await Task.FromResult(true)); } return(await Task.FromResult(false)); }
private async Task JoinDutyTask(int DutyId, bool Undersized, bool Trial, bool Raid) { if (Undersized) { Logging.WriteDiagnostic("Joining Duty as Undersized party."); GameSettingsManager.JoinWithUndersizedParty = true; } else { Logging.WriteDiagnostic("Joining Duty as normal group."); GameSettingsManager.JoinWithUndersizedParty = false; } Logging.WriteDiagnostic("Queuing for " + DataManager.InstanceContentResults[(uint)DutyId].CurrentLocaleName); DutyManager.Queue(DataManager.InstanceContentResults[(uint)DutyId]); await Coroutine.Wait(5000, () => (DutyManager.QueueState == QueueState.CommenceAvailable || DutyManager.QueueState == QueueState.JoiningInstance)); Logging.WriteDiagnostic("Queued for Dungeon"); while (DutyManager.QueueState != QueueState.None || DutyManager.QueueState != QueueState.InDungeon || CommonBehaviors.IsLoading) { if (DutyManager.QueueState == QueueState.CommenceAvailable) { Logging.WriteDiagnostic("Waiting for queue pop."); await Coroutine.Wait(-1, () => (DutyManager.QueueState == QueueState.JoiningInstance || DutyManager.QueueState == QueueState.None)); } if (DutyManager.QueueState == QueueState.JoiningInstance) { Logging.WriteDiagnostic("Dungeon popped, commencing in 3."); await Coroutine.Sleep(3000); DutyManager.Commence(); await Coroutine.Wait(-1, () => (DutyManager.QueueState == QueueState.LoadingContent || DutyManager.QueueState == QueueState.CommenceAvailable)); } if (DutyManager.QueueState == QueueState.LoadingContent) { Logging.WriteDiagnostic("Waiting for everyone to accept"); await Coroutine.Wait(-1, () => (CommonBehaviors.IsLoading || DutyManager.QueueState == QueueState.CommenceAvailable)); await Coroutine.Sleep(1000); } if (CommonBehaviors.IsLoading) { break; } await Coroutine.Sleep(500); } if (DutyManager.QueueState == QueueState.None) { return; } await Coroutine.Sleep(500); if (CommonBehaviors.IsLoading) { await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading); } if (QuestLogManager.InCutscene) { TreeRoot.StatusText = "InCutscene"; if (ff14bot.RemoteAgents.AgentCutScene.Instance != null) { ff14bot.RemoteAgents.AgentCutScene.Instance.PromptSkip(); await Coroutine.Wait(250, () => SelectString.IsOpen); if (SelectString.IsOpen) { SelectString.ClickSlot(0); } } } Logging.WriteDiagnostic("Should be in duty"); var director = ((ff14bot.Directors.InstanceContentDirector)DirectorManager.ActiveDirector); if (director != null) { if (Trial) { if (director.TimeLeftInDungeon >= new TimeSpan(0, 60, 0)) { Logging.WriteDiagnostic("Barrier up"); await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(0, 59, 58)); } } if (Raid) { if (director.TimeLeftInDungeon >= new TimeSpan(2, 0, 0)) { Logging.WriteDiagnostic("Barrier up"); await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(1, 59, 58)); } } else { if (director.TimeLeftInDungeon >= new TimeSpan(1, 30, 0)) { Logging.WriteDiagnostic("Barrier up"); await Coroutine.Wait(-1, () => director.TimeLeftInDungeon < new TimeSpan(1, 29, 58)); } } } else { Logging.WriteDiagnostic("Director is null"); } Logging.WriteDiagnostic("Should be ready"); _isDone = true; }
private async Task JoinDutyTask(int DutyId, bool Trial) { Logging.WriteDiagnostic("Queuing for Dungeon"); GameSettingsManager.JoinWithUndersizedParty = true; DutyManager.Queue(DataManager.InstanceContentResults[(uint)DutyId]); await Coroutine.Wait(5000, () => (DutyManager.QueueState == QueueState.InQueue || DutyManager.QueueState == QueueState.JoiningInstance)); Logging.WriteDiagnostic("Queued for Dungeon"); await Coroutine.Wait(10000, () => (DutyManager.QueueState == QueueState.JoiningInstance)); await Coroutine.Wait(10000, () => (RaptureAtkUnitManager.GetWindowByName("ContentsFinderConfirm") != null)); Logging.WriteDiagnostic("Commencing"); DutyManager.Commence(); Logging.WriteDiagnostic("Waiting for Loading"); await Coroutine.Wait(10000, () => CommonBehaviors.IsLoading || QuestLogManager.InCutscene); if (CommonBehaviors.IsLoading) { await Coroutine.Wait(-1, () => !CommonBehaviors.IsLoading); } if (QuestLogManager.InCutscene) { TreeRoot.StatusText = "InCutscene"; if (ff14bot.RemoteAgents.AgentCutScene.Instance != null) { ff14bot.RemoteAgents.AgentCutScene.Instance.PromptSkip(); await Coroutine.Wait(250, () => SelectString.IsOpen); if (SelectString.IsOpen) { SelectString.ClickSlot(0); } } } Logging.WriteDiagnostic("Should be in duty"); var director = ((ff14bot.Directors.InstanceContentDirector)DirectorManager.ActiveDirector); if (director != null) { if (Trial) { if (director.TimeLeftInDungeon >= new TimeSpan(0, 60, 0)) { Logging.WriteDiagnostic("Barrier up"); await Coroutine.Wait(30000, () => director.TimeLeftInDungeon < new TimeSpan(0, 59, 58)); } } else { if (director.TimeLeftInDungeon >= new TimeSpan(1, 30, 0)) { Logging.WriteDiagnostic("Barrier up"); await Coroutine.Wait(30000, () => director.TimeLeftInDungeon < new TimeSpan(1, 29, 58)); } } } else { Logging.WriteDiagnostic("Director is null"); } Logging.WriteDiagnostic("Should be ready"); _isDone = true; }