private static async Task <bool> OpenRiftTask()
        {
            // Move to and use Greater Rift Portal
            if (ZetaDia.Me.IsParticipatingInTieredLootRun && ZetaDia.IsInTown && ZetaDia.CurrentLevelAreaId == (int)SNOLevelArea.x1_Westm_Hub &&
                ConditionParser.IsActiveQuestAndStep((int)SNOQuest.X1_LR_DungeonFinder, 13))
            {
                // [202EBD3C] GizmoType: Portal Name: X1_OpenWorld_Tiered_Rifts_Portal-5041 ActorSNO: 396751 Distance: 11.58544 Position: <606.84, 750.39, 2.53> Barracade: False Radius: 8.316568
                var moveToPortal = new MoveToActorTag
                {
                    QuestId       = (int)SNOQuest.X1_LR_DungeonFinder,
                    StepId        = 13,
                    ActorId       = GreaterRiftPortalSNO,
                    X             = 606,
                    Y             = 750,
                    Z             = 2,
                    IsPortal      = true,
                    InteractRange = 9,
                    Timeout       = 10
                };
                Logr.Log("Queueing MoveToActor for interacting with Greater Rift Portal");
                BotBehaviorQueue.Queue(moveToPortal,
                                       ret => ZetaDia.Me.IsParticipatingInTieredLootRun && ZetaDia.IsInTown && ZetaDia.CurrentLevelAreaId == (int)SNOLevelArea.x1_Westm_Hub &&
                                       !ConditionParser.IsActiveQuestAndStep(337492, 10));
                return(true);
            }

            if (!SimpleFollow.Leader.RequestOpenRift)
            {
                return(false);
            }

            if (HighestLevelTieredRiftKey > SimpleFollow.Leader.HighestTeamRiftKey)
            {
                return(false);
            }

            // In regular rift quests
            if (ConditionParser.IsActiveQuestAndStep(337492, 1) ||
                ConditionParser.IsActiveQuestAndStep(337492, 3) ||
                ConditionParser.IsActiveQuestAndStep(337492, 13) ||
                ConditionParser.IsActiveQuestAndStep(337492, 16))
            {
                return(false);
            }

            // In Rift Trial
            if (ZetaDia.ActInfo.ActiveQuests.Any(q => q.QuestSNO == (int)SNOQuest.p1_TieredRift_Challenge))
            {
                return(false);
            }

            // Our rift key is the lowest of the team, lets open a rift!

            var keyPriorityList = SimpleFollow.Leader.RiftKeyPriority;

            if (keyPriorityList.Count != 3)
            {
                throw new ArgumentOutOfRangeException("RiftKeyPriority", "Expected 3 Rift keys, API is broken?");
            }

            if (ZetaDia.Actors.GetActorsOfType <DiaObject>(true).Any(i => i.IsValid && i.ActorSNO == RiftPortalSNO))
            {
                Logr.Log("Rift Portal already open!");
                return(false);
            }

            if (!ZetaDia.IsInTown)
            {
                return(await CommonCoroutines.UseTownPortal("Going to town to open rift"));
            }

            bool needsGreaterKeys = !ZetaDia.Me.Inventory.Backpack.Any(i => IsRiftKey(i) && IsGreaterRiftKey(i)) &&
                                    ZetaDia.Me.Inventory.StashItems.Any(i => IsRiftKey(i) && IsGreaterRiftKey(i));
            bool needsTrialKeys = !ZetaDia.Me.Inventory.Backpack.Any(i => IsRiftKey(i) && IsTrialRiftKey(i)) &&
                                  ZetaDia.Me.Inventory.StashItems.Any(i => IsRiftKey(i) && IsTrialRiftKey(i));
            bool needsNormalKeys = !ZetaDia.Me.Inventory.Backpack.Any(i => IsRiftKey(i) && IsNormalKey(i)) &&
                                   ZetaDia.Me.Inventory.StashItems.Any(i => IsRiftKey(i) && IsNormalKey(i));

            if (needsGreaterKeys)
            {
                Logr.Log("Moving to stash to get Greater Rift Keys");
                BotBehaviorQueue.Queue(new GetItemFromStashTag {
                    GreaterRiftKey = true, StackCount = 1
                });
                return(true);
            }

            if (needsTrialKeys)
            {
                Logr.Log("Moving to stash to get Trial Rift Keys");
                BotBehaviorQueue.Queue(new GetItemFromStashTag {
                    ActorId = 408416, StackCount = 1
                });
                return(true);
            }

            if (needsNormalKeys)
            {
                Logr.Log("Moving to stash to get Rift Keys");
                BotBehaviorQueue.Queue(new GetItemFromStashTag {
                    ActorId = (int)SNOActor.LootRunKey, StackCount = 1
                });
                return(true);
            }

            int questStepId = 1;
            var quest       = ZetaDia.ActInfo.ActiveQuests.FirstOrDefault(q => q.QuestSNO == (int)SNOQuest.X1_LR_DungeonFinder);

            if (quest != null)
            {
                questStepId = quest.QuestStep;
            }

            if (ZetaDia.IsInTown && !ConditionParser.ActorExistsAt(RiftPortalSNO, 606, 750, 2, 50) && !ConditionParser.ActorExistsAt(GreaterRiftPortalSNO, 606, 750, 2, 50))
            {
                BotBehaviorQueue.Reset();
                Logr.Log("Queueing QTOpenRiftWrapper");
                BotBehaviorQueue.Queue(new QTOpenRiftWrapperTag());
                BotBehaviorQueue.Queue(new WaitTimerTag {
                    QuestId = 337492, StepId = questStepId, WaitTime = 2000
                });
                FollowTag.LastInteractTime = DateTime.Now.AddSeconds(15);
            }

            if (ZetaDia.IsInTown && ConditionParser.ActorExistsAt(RiftPortalSNO, 606, 750, 2, 50) && ConditionParser.IsActiveQuestAndStep(337492, questStepId))
            {
                Logr.Log("Queueing MoveToActor for Rift Portal");
                BotBehaviorQueue.Reset();
                BotBehaviorQueue.Queue(new MoveToActorTag {
                    QuestId = 337492, StepId = questStepId, ActorId = RiftPortalSNO, Timeout = 10
                });
                BotBehaviorQueue.Queue(new WaitTimerTag {
                    QuestId = 337492, StepId = questStepId, WaitTime = 2000
                });
                FollowTag.LastInteractTime = DateTime.Now.AddSeconds(15);
            }
            if (ZetaDia.IsInTown && ConditionParser.ActorExistsAt(GreaterRiftPortalSNO, 606, 750, 2, 50) && ConditionParser.IsActiveQuestAndStep(337492, questStepId))
            {
                Logr.Log("Queueing MoveToActor for Greater Rift Portal");
                BotBehaviorQueue.Reset();
                BotBehaviorQueue.Queue(new MoveToActorTag {
                    QuestId = 337492, StepId = questStepId, ActorId = GreaterRiftPortalSNO, Timeout = 10
                });
                BotBehaviorQueue.Queue(new WaitTimerTag {
                    QuestId = 337492, StepId = questStepId, WaitTime = 2000
                });
                FollowTag.LastInteractTime = DateTime.Now.AddSeconds(15);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// TODO: Get rid of case switching and stepping. Makes it harder to reorder functions
        /// </summary>
        public void Execute()
        {
            while (running && BotMain.IsRunning)
            {
                BotMain.CurrentBot.Pulse();
                switch (step)
                {
                case 0:
                    if (ZetaDia.IsInGame && !ZetaDia.IsLoadingWorld && ZetaDia.Me.IsValid)
                    {
                        Buff();
                        step++;
                    }
                    break;

                case 1:
                    if (MoveWithPower(1993, 2603))
                    {
                        step++;
                    }
                    break;

                case 2:
                    if (MoveWithPower(2044, 2529))     //(2026, 2557) //2044, 2529 lets you see the cellar. Sometimes. It's not detecting an open cellar properly
                    {
                        step++;
                    }
                    break;

                case 3:
                    step++;
                    break;

                case 4:
                    if (MoveWithPower(2046, 2527))
                    {
                        step++;
                    }
                    break;

                case 5:
                    if (MoveWithPower(2078, 2492))
                    {
                        step++;
                    }
                    break;

                case 6:

                    //ZetaDia.Me.UsePower(SNOPower.DemonHunter_Vault, new Vector3(2066, 2477, ZetaDia.Me.Position.Z), ZetaDia.Me.WorldDynamicId, 2, -1);
                    if (MoveWithPower(2066, 2477))
                    {
                        step++;
                    }
                    break;

                case 7:
                    if (ZetaDia.Me.ActorClass == ActorClass.DemonHunter)
                    {
                        ZetaDia.Me.UsePower(SNOPower.DemonHunter_Preparation, ZetaDia.Me.Position);     //reset discipline so I can vault to cellar or exit game
                    }
                    if (!ConditionParser.ActorExistsAt(176007, 2059, 2478, 27, 15))
                    {
                        ExitUnsuccessfulGame();
                        step = 13;
                    }
                    step++;
                    break;

                case 8:
                    if (Zeta.ZetaDia.CurrentWorldId == 71150)
                    {
                        Interact("g_Portal_Square_Blue");
                    }
                    step++;
                    break;

                case 9:
                    if (Zeta.ZetaDia.CurrentWorldId == 71150)
                    {
                        step = 7;
                    }
                    else
                    {
                        step++;
                    }
                    break;

                case 10:
                    //blank for now
                    step++;
                    break;

                case 11:
                    if (MoveWithPower(125, 160))
                    {
                        step++;
                    }
                    break;

                case 12:
                    if (MoveTo(120, 137))
                    {
                        step++;
                    }
                    break;

                case 13:
                    //check for repair and sell


                    //manually quit
                    //Helper.RemoveAllBehavior();
                    //ZetaDia.Me.UseTownPortal();
                    //ZetaDia.Service.Games.LeaveGame();
                    break;
                }
                //if (ZetaDia.Me.IsDead) step = 13;
                if (step == 13)
                {
                    break;
                }
            }
        }