예제 #1
0
        public override async Task <bool> StartTask()
        {
            var bounty = ZetaDia.Storage.Quests.Bounties
                         .Where(c => c.Act == Act && c.Info.State != QuestState.Completed && !_blacklist.Contains(c.Quest))
                         .OrderByDescending(c => (int)c.Quest)
                         .FirstOrDefault();

            // Bounties completed in this Act.
            if (bounty == null)
            {
                return(true);
            }

            _bounty = BountyCoroutineFactory.GetBounty(bounty);
            if (_bounty == null)
            {
                Core.Logger.Error($"[RunBountySimple] Bounty is not supported ({QuestId}), ending tag.");
                _blacklist.Add(bounty.Quest);

                // Pick the next...
                return(await StartTask());
            }

            _bounty.Reset();
            return(false);
        }
예제 #2
0
        public override async Task <bool> MainTask()
        {
            if (!_bounty.IsDone && !await _bounty.GetCoroutine())
            {
                return(false);
            }

            _bounty = null;
            return(await StartTask());
        }
예제 #3
0
        public override void OnStart()
        {
            var bountyInfo = ZetaDia.ActInfo.Bounties.FirstOrDefault(b => (int)b.Quest == QuestId);

            _bounty = BountyCoroutineFactory.GetBounty(bountyInfo);
            if (_bounty == null)
            {
                Logger.Error("[RunBountyTag] Unsupported QuestId ({0}), ending tag.", QuestId);
                _isDone = true;
            }
        }
예제 #4
0
        public override async Task <bool> StartTask()
        {
            var bountyInfo = ZetaDia.Storage.Quests.Bounties.FirstOrDefault(b => (int)b.Quest == QuestId);

            if (bountyInfo == null)
            {
                Core.Logger.Error($"[RunBountyTag] Bounty is not available in this game.");
                return(true);
            }

            _bounty = BountyCoroutineFactory.GetBounty(bountyInfo);
            if (_bounty == null)
            {
                Core.Logger.Error($"[RunBountyTag] Bounty is not supported ({QuestId}), ending tag.");
                return(true);
            }

            _bounty.Reset();
            return(false);
        }
예제 #5
0
        private async Task <bool> GetCoroutine()
        {
            if (_isDone)
            {
                return(true);
            }

            if (PluginEvents.TimeSinceWorldChange < 1000)
            {
                Logger.Debug("[RunActBountiesTag] Sleeping 1 second due to world change");
                await Coroutine.Sleep(1000);
            }

            if (_bounties == null || _bounties.Count == 0)
            {
                if (BountyHelpers.AreAllActBountiesCompleted(Act))
                {
                    if (await _completeActBountiesCoroutine.GetCoroutine())
                    {
                        _isDone = true;
                        return(true);
                    }
                    return(true);
                }
                _isDone = true;
                return(true);
            }
            _currentBounty = _bounties.FirstOrDefault();
            if (_currentBounty != null)
            {
                if (_currentBounty.State != BountyCoroutine.States.Completed && _currentBounty.State != BountyCoroutine.States.Failed)
                {
                    return(await _currentBounty.GetCoroutine());
                }
                ScenesStorage.Reset();

                _bounties.Remove(_currentBounty);
                BountyStatistics.Report();
            }
            return(true);
        }
예제 #6
0
        public static BountyCoroutine GetBounty(BountyInfo bountyInfo)
        {
            if (bountyInfo == null)
            {
                return(null);
            }

            var bountyData = BountyDataFactory.GetBountyData((int)bountyInfo.Quest);

            if (bountyData == null)
            {
                Core.Logger.Log("Unsupported bounty: {0} - {1}", (int)bountyInfo.Quest, bountyInfo.Info.DisplayName);
                return(null);
            }
            //if (bountyData.QuestType != BountyQuestType.SpecialEvent)
            //{
            //    Core.Logger.Debug("Skipping bounty: {0} - {1}", (int)bountyInfo.Quest, bountyInfo.Info.DisplayName);
            //    return null;
            //}

            //if (QuestDataFactory.QuestDatas.ContainsKey((int)bountyInfo.Quest)) return null;

            BountyCoroutine bounty = null;

            //var bountyType = BountyHelpers.GetQuestType(bountyInfo);
            //if (bountyType != BountyQuestType.SpecialEvent)
            //{
            //    return null;
            //}

            //if (Bounties.TryGetValue((int)bountyInfo.Quest, out bounty))
            //{
            //    Core.Logger.Debug("[BountyFactory] Returning hardcoded bounty:" + bounty.QuestData.Name);
            //}

            // Try to get the kill bounty

            //// Try to get the kill bounty
            //if (bounty == null && bountyInfo.Info.DisplayName.Replace("Bounty: ", string.Empty).StartsWith("Kill ") && TryGetKillBounty((int)bountyInfo.Quest, out bounty))
            //{
            //    Core.Logger.Debug("[BountyFactory] Returning generated bounty:" + bounty.QuestData.Name);
            //}

            // Try to get the clear bounty
            //if (bounty == null && bountyInfo.Info.DisplayName.Replace("Bounty: ", string.Empty).StartsWith("Clear ") && TryGetClearBounty((int)bountyInfo.Quest, out bounty))
            //{
            //    Core.Logger.Debug("[BountyFactory] Returning generated bounty:" + bounty.QuestData.Name);
            //}

            //// Try to get the curse bounty
            //if (bounty == null && bountyInfo.Info.DisplayName.Replace("Bounty: ", string.Empty).StartsWith("The Cursed") && bountyInfo.Quest != SNOQuest.X1_Bounty_A5_PandExt_Event_CursedCrystals && TryGetCursedBounty((int)bountyInfo.Quest, out bounty))
            //{
            //    Core.Logger.Debug("[BountyFactory] Returning generated bounty:" + bounty.QuestData.Name);
            //}

            if (bounty == null)
            {
                bounty = new GenericBountyCoroutine((int)bountyInfo.Quest);
                //if (bounty.QuestData.Steps.First().Objectives.Any(o => o.ObjectiveType == QuestStepObjectiveType.EnterLevelArea))
                //    return null;
                //if (bounty.QuestData.QuestType != BountyQuestType.KillMonster && bounty.QuestData.QuestType != BountyQuestType.ClearZone)
                //    return null;
                Core.Logger.Debug("[BountyFactory] Returning generic bounty:" + bounty.QuestData.Name);
            }

            if (bounty != null)
            {
                bounty.Reset();
                //if (bounty.QuestData.IsDataComplete)
                //{
                //    return null;
                //}
            }
            return(bounty);
        }
예제 #7
0
        //public override void OnDone()
        //{
        //    if (_bounty != null)
        //    {
        //        _bounty.ResetState();
        //    }
        //}

        public override void ResetCachedDone(bool force = false)
        {
            _bounty = null;
            _isDone = false;
        }