Exemplo n.º 1
0
        /// <summary>
        /// Handles Cache of the Hoard
        /// </summary>
        /// <returns></returns>
        private async Task <bool> HandleCacheOfTheHoard()
        {
            TreeRoot.StatusText = "Banded Coffer";

            if (
                GameObjectManager.GameObjects.Any(
                    i => Constants.TrapIds.Contains(i.NpcId) && i.Distance2D(Target.Location) < 2))
            {
                Blacklist.Add(Target.Unit, BlacklistFlags.All, TimeSpan.FromMinutes(3), "A trap is close to the Hoard Spawn location. Skipping.");
                Poi.Clear("A trap is close to the Hoard Spawn location. Skipping.");
                await Coroutine.Sleep(250);

                return(true);
            }

            if (Target.Location.Distance2D(Core.Me.Location) >= 2)
            {
                Logger.Info($"Banded Coffer is >= 3");
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, "Banded Coffer"), 0.5f, true);

                return(true);
            }
            await CommonTasks.StopMoving("Spawning Coffer");

            Logger.Info("Found a Cache of the Horde. Waiting for it to spawn... (Giving it a few seconds to spawn)");


            //target will change after the banded coffer is spawned
            var org = Target.Unit;

            //wait for the chest or for us to get into combat.
            await Coroutine.Wait(TimeSpan.FromSeconds(5),
                                 () =>
                                 Core.Me.InCombat || GameObjectManager.NumberOfAttackers > 0 || DeepDungeon.StopPlz ||
                                 GameObjectManager.GetObjectsOfType <EventObject>().Any(i => i.NpcId == EntityNames.BandedCoffer)
                                 );

            if (Core.Me.InCombat || GameObjectManager.NumberOfAttackers > 0)
            {
                Logger.Info("Entered Combat waiting on coffer to spawn.");
                return(true);
            }


            Blacklist.Add(org, BlacklistFlags.All | (BlacklistFlags)DeepDungeonManager.Level, TimeSpan.FromMinutes(3), "Spawned the Coffer or used all of our time...");
            Poi.Clear($"Hidden adden to blacklist");
            return(true);
        }
Exemplo n.º 2
0
 protected override void OnStart()
 {
     _min        = Convert.ToInt32(MinLevel);
     _max        = Convert.ToInt32(MaxLevel);
     _timeout    = Convert.ToInt32(timeout);
     currentstep = 0;
     Logging.Write("Doing fates and hunt in between.");
     Logging.Write("Stats: MinFate level={0} MaxFatelvl={1}", _min, _max);
     // MaxLevel = "34";
     // MinLevel = "25";
     CachedProvider = CombatTargeting.Instance.Provider;
     CombatTargeting.Instance.Provider = new MySuperAwesomeTargetingProvider();
     currentfate = null;
     Poi.Clear("Clearing POI");
     saveNow = DateTime.Now;
 }
Exemplo n.º 3
0
        public async Task <bool> Run()
        {
            if (!Constants.InDeepDungeon)
            {
                return(false);
            }


            if (Target == null)
            {
                return(false);
            }



            if (Navigator.InPosition(Core.Me.Location, Target.Location, 3f) && Target.Type == (PoiType)PoiTypes.ExplorePOI)
            {
                Poi.Clear("We have reached our destination");
                return(true);
            }
            var status = string.Format("Current Level {0}. Level Status: {1}% \"Done\": {2}", DeepDungeonManager.Level,
                                       PortalPercent, DDTargetingProvider.Instance.LevelComplete);

            TreeRoot.StatusText = status;

            if (ActionManager.IsSprintReady && Target.Location.Distance2D(Core.Me.Location) > 5 && MovementManager.IsMoving)
            {
                ActionManager.Sprint();
                return(true);
            }

            var res = await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, "Moving toward POTD Objective"), 1.5f);

            //if (Target.Unit != null)
            //{
            //    Logger.Verbose($"[PotdNavigator] Move Results: {res} Moving To: \"{Target.Unit.Name}\" LOS: {Target.Unit.InLineOfSight()}");
            //}
            //else
            //{
            //    Logger.Verbose($"[PotdNavigator] Move Results: {res} Moving To: \"{Target.Name}\" ");
            //}


            return(res);
        }
Exemplo n.º 4
0
        private async Task AcceptRaise()
        {
            Log($"We have Raise Aura.");
            Log($"Clicking Accept");
            await Coroutine.Sleep(500);

            ClientGameUiRevive.Revive();
            await Coroutine.Wait(-1, () => (CommonBehaviors.IsLoading));

            Log($"Waiting for loading to finish...");
            await Coroutine.Wait(-1, () => (Core.Me.IsAlive));

            if (OsirisSettings.Instance.ThankYouSir)
            {
                ChatManager.SendChat("/say Thanks for the raise.");
            }
            await Coroutine.Wait(15000, () => ClientGameUiRevive.ReviveState == ReviveState.None);

            Poi.Clear("We live!");
        }
Exemplo n.º 5
0
        public async Task <bool> Run()
        {
            if (Target.Type != PoiType.Collect)
            {
                return(false);
            }

            //let the navigation task handle moving toward the object if we are too far away.
            if (Target.Location.Distance2D(Core.Me.Location) > 3)
            {
                return(false);
            }

            if (Target.Unit == null || !Target.Unit.IsValid)
            {
                Poi.Clear("Target not found at location");
                return(true);
            }

            if (Target.Unit.NpcId == Constants.SelectedDungeon.LobbyExit)
            {
                Poi.Clear("This is lobby exit - clear to get lobby task to run");
                return(true);
            }
            //let the user know we are trying to run a treasure task
            TreeRoot.StatusText = "Treasure";
            if (Target.Unit.IsValid)
            {
                if (Target.Unit?.NpcId == EntityNames.Hidden)
                {
                    return(await HandleCacheOfTheHoard());
                }
            }
            else
            {
                return(true);
            }

            //treasure... or an "exit"...
            return(await TreasureOrExit());
        }
Exemplo n.º 6
0
        private async Task <bool> ExecutePoiLogic()
        {
            if (Poi.Current.Type != PoiType.Gather)
            {
                return(false);
            }

            var result = FindGatherSpot() || await GatherSequence();

            if (!result)
            {
                Poi.Clear(Localization.ExGather_ExecutePoiLogic);
            }

            if (Poi.Current.Type == PoiType.Gather && (!Poi.Current.Unit.IsValid || !Poi.Current.Unit.IsVisible))
            {
                Poi.Clear(Localization.ExGather_NodeIsGone);
            }

            return(result);
        }
Exemplo n.º 7
0
        public async Task <bool> Run()
        {
            if (MoveTimer.IsFinished && Poi.Current != null && Poi.Current.Type != PoiType.None)
            {
                var path = StraightPathHelper.RealStraightPath();

/*                 Logger.Info($"Dump path:");
 *              foreach(var x in path)
 *              {
 *                  Logger.Info(x.ToString());
 *              } */

                Logger.Warn("No activity was detected for {0} seconds. Adding target to the blacklist and trying again",
                            MoveTimer.WaitTime.TotalSeconds);
                if (Poi.Current.Unit != null)
                {
                    DDTargetingProvider.Instance.AddToBlackList(Poi.Current.Unit, TimeSpan.FromSeconds(60),
                                                                "Navigation Error");
                }
                //if (Poi.Current.Type != PoiType.None)
                Poi.Clear("No activity detected");


                MoveTimer.Reset();
                return(true);
            }

            if (MoveTimer.IsFinished)
            {
                Logger.Warn("No activity was detected for {0} seconds. Clearing Navigator?",
                            MoveTimer.WaitTime.TotalSeconds);
                await CommonTasks.StopMoving();

                Navigator.Clear();
                MoveTimer.Reset();
                return(true);
            }

            return(false);
        }
Exemplo n.º 8
0
        internal async Task <bool> ResolveGatherItem()
        {
            if (!GatheringManager.WindowOpen)
            {
                return(false);
            }

            var previousGatherItem = GatherItem;

            GatherItemIsFallback = false;
            GatherItem           = null;
            CollectableItem      = null;

            var windowItems = GatheringManager.GatheringWindowItems.ToArray();

            // TODO: move method to common so we use it on fish too
            if (InventoryItemCount() >= 140)
            {
                if (Items.Count > 0)
                {
                    if (
                        SetGatherItem(
                            windowItems.OrderByDescending(i => i.SlotIndex).Where(i => i.IsFilled && !i.IsUnknown && i.ItemId < 20).ToArray()))
                    {
                        return(true);
                    }
                }

                GatherItem =
                    windowItems.Where(i => i.IsFilled && !i.IsUnknown)
                    .OrderByDescending(i => i.ItemId)
                    .FirstOrDefault(i => i.ItemId < 20);

                if (GatherItem != null)
                {
                    return(true);
                }

                Logger.Warn(Localization.Localization.ExGather_FullInventory);
                return(false);
            }

            if (DiscoverUnknowns)
            {
                var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex);

                GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

                if (GatherItem != null)
                {
                    return(true);
                }
            }

            if (Items.Count > 0)
            {
                if (SetGatherItem(windowItems))
                {
                    return(true);
                }
            }

            if (Slot > -1 && Slot < 8)
            {
                GatherItem = GatheringManager.GetGatheringItemByIndex((uint)Slot);
            }

            if (GatherItem == null && (!AlwaysGather || GatherStrategy == GatherStrategy.TouchAndGo))
            {
                Poi.Clear(Localization.Localization.ExGather_SkipNode);

                await CloseGatheringWindow();

                return(false);
            }

            if (GatherItem != null)
            {
                return(true);
            }

            GatherItemIsFallback = true;

            GatherItem =
                windowItems.Where(i => i.IsFilled && !i.IsUnknown)
                .OrderByDescending(i => i.ItemId)
                .FirstOrDefault(i => i.ItemId < 20)     // Try to gather cluster/crystal/shard
                ?? windowItems.FirstOrDefault(
                    i => i.IsFilled && !i.IsUnknown && !i.ItemData.Unique && !i.ItemData.Untradeable && i.ItemData.ItemCount() > 0)
                // Try to collect items you have that stack
                ?? windowItems.Where(i => i.Amount > 0 && !i.ItemData.Unique && !i.ItemData.Untradeable)
                .OrderByDescending(i => i.SlotIndex)
                .FirstOrDefault();     // Take last item that is not unique or untradeable

            // Seems we only have unknowns.
            if (GatherItem == null)
            {
                var items = new[] { 0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U }.Select(GatheringManager.GetGatheringItemByIndex).ToArray();

                GatherItem = items.FirstOrDefault(i => i.IsUnknownChance() && i.Amount > 0);

                if (GatherItem != null)
                {
                    return(true);
                }

                Logger.Warn(Localization.Localization.ExGather_NothingToGather);

                return(false);
            }

            if (previousGatherItem == null || previousGatherItem.ItemId != GatherItem.ItemId)
            {
                Logger.Info(Localization.Localization.ExGather_NothingToGather2 + GatherItem.ItemData + Localization.Localization.ExGather_NothingToGather3);
            }

            return(true);
        }
Exemplo n.º 9
0
 internal static void ClearPoi(string reason)
 {
     Logger.SendLog(reason);
     Poi.Clear(reason);
 }
Exemplo n.º 10
0
 private Composite SetRestPoi()
 {
     return(new HookExecutor(
                "RestPoi",
                "A hook location that executes downtime logic.",
                new Decorator(obj => Poi.Current.Type == PoiType.Wait, new PrioritySelector(new Decorator(
                                                                                                obj =>
     {
         if (FateData == null)
         {
             return true;
         }
         return !FateData.IsValid;
     },
                                                                                                new ActionRunCoroutine(obj => ResolveFate())),
                                                                                            new Decorator(
                                                                                                obj => FateData != null,
                                                                                                new Action(obj => Poi.Clear("Time for resting is over!"))),
                                                                                            new Decorator(
                                                                                                obj =>
     {
         if (!Core.Player.IsMounted)
         {
             return true;
         }
         return Poi.Current.Location.Distance(Core.Player.Location) <= 25f;
     },
                                                                                                new HookExecutor("SetCombatPoi")),
                                                                                            new Decorator(
                                                                                                obj => Poi.Current.Location.Distance(Core.Player.Location) > 15f,
                                                                                                CommonBehaviors.CreateMountBehavior()),
                                                                                            new Decorator(
                                                                                                obj => Poi.Current.Location != Vector3.Zero,
                                                                                                new Action(obj => Navigator.MoveToPointWithin(Poi.Current.Location, 15f, "Moving to rest location")))))));
 }
Exemplo n.º 11
0
 private Composite SetFatePoi()
 {
     return(new HookExecutor(
                "FatePoi",
                "A hook location that executes fate logic.",
                new Decorator(obj => Poi.Current.Type == PoiType.Fate, new PrioritySelector(new Decorator(
                                                                                                obj =>
     {
         if (FateData != null && !FateData.IsValid)
         {
             return true;
         }
         return FateData == null;
     },
                                                                                                new Action(obj => Poi.Clear("Fate is no longer valid"))),
                                                                                            new Decorator(obj => !Core.Player.IsMounted && !this.Withinfate, CommonBehaviors.CreateMountBehavior()),
                                                                                            new Decorator(
                                                                                                obj =>
     {
         if (!Core.Player.IsMounted)
         {
             return true;
         }
         return this.Withinfate;
     },
                                                                                                new HookExecutor("SetCombatPoi")),
                                                                                            CommonBehaviors.MoveAndStop(
                                                                                                obj => FateData.Location,
                                                                                                obj => FateData.Radius / 2f,
                                                                                                true,
                                                                                                "Moving to fate")))));
 }
Exemplo n.º 12
0
        //{
        //    get
        //    {
        //        var badGuys = (CombatTargeting.Instance.Provider as DDCombatTargetingProvider)?.GetObjectsByWeight();

        // var anyBadGuysAround = badGuys != null && badGuys.Any();

        // //if (Beta.Target != null && Beta.Target.IsValid &&
        // !Blacklist.Contains(Beta.Target.ObjectId, (BlacklistFlags)DeepDungeonManager.Level) &&
        // Beta.Target.Type != GameObjectType.GatheringPoint) // return null;

        // // Party member is dead if (PartyManager.AllMembers.Any(member => member.CurrentHealth ==
        // 0)) { // Select Beacon of Return as highest priority if it is known and can be used. if
        // (BeaconOfReturn != null && DeepDungeonManager.ReturnActive) return BeaconOfReturn;

        //            // If the Beacon of Return is not yet active and there are any mobs around: Kill the mobs.
        //            if (anyBadGuysAround)
        //                return new Poi(badGuys.First(), PoiType.Kill);
        //        }

        //        // Beacon of Passage
        //        if (LevelComplete && Portal != null)
        //            return Portal;

        //        // Bosses or Pomander of Rage / Pomander of Lust
        //        if ((DeepDungeonManager.BossFloor || Core.Me.HasAura(Auras.Lust)) && anyBadGuysAround)
        //            return new Poi(badGuys.First(), PoiType.Kill);

        //        // Chests
        //        if (LastEntities != null && LastEntities.Any())
        //            return LastEntities.First();

        //        // Kill something
        //        if (anyBadGuysAround)
        //            return new Poi(badGuys.First(), PoiType.Kill);

        //        return new Poi(
        //            SafeSpots.OrderByDescending(i => i.Distance2D(Core.Me.Location)).First(),
        //            PoiType.Hotspot
        //        );

        //    }
        //}

        internal void AddToBlackList(GameObject obj, string reason)
        {
            AddToBlackList(obj, TimeSpan.FromMinutes(1), reason);
            Poi.Clear(reason);
        }
Exemplo n.º 13
0
        /// <inheritdoc/>
        public override async Task <bool> Run()
        {
            // Always dodge above all else
            if (AvoidanceManager.IsRunningOutOfAvoid)
            {
                Logger.LogTrace(Translations.LOG_COMBAT_AVOIDING_AOE);

                return(HANDLED_EXECUTION);
            }

            // Non-combat preparations
            if (!Core.Player.InCombat)
            {
                if (await Rest())
                {
                    Logger.LogInformation(Translations.LOG_COMBAT_RESTING);
                    await CommonTasks.StopMoving();
                    await Heal();

                    return(HANDLED_EXECUTION);
                }

                if (await PreCombatBuff())
                {
                    return(HANDLED_EXECUTION);
                }
            }

            // Target management
            CombatTargeting.Instance.Pulse();  // TODO: Add reduced tick rate for pulse?
            BattleCharacter nextCombatTarget = CombatTargeting.Instance.FirstUnit;

            if (nextCombatTarget != null && (Poi.Current?.Unit == null || Poi.Current.Unit.Pointer != nextCombatTarget.Pointer))
            {
                Poi.Current = new Poi(nextCombatTarget, PoiType.Kill);
            }

            if (Poi.Current?.BattleCharacter == null || Poi.Current.Type != PoiType.Kill)
            {
                // No combat target to fight
                return(PASS_EXECUTION);
            }

            if (Poi.Current?.BattleCharacter == null || !Poi.Current.BattleCharacter.IsValid || !Poi.Current.BattleCharacter.IsAlive)
            {
                Logger.LogInformation(Translations.LOG_COMBAT_TARGET_DIED);
                Poi.Clear(Translations.LOG_COMBAT_TARGET_DIED);

                return(HANDLED_EXECUTION);
            }

            // Start combat
            StatusBar.Text = string.Format(Translations.STATUS_COMBAT_TARGET, Poi.Current.Name);

            if (Poi.Current.Unit.IsTargetable && Core.Player.PrimaryTargetPtr != Poi.Current.Unit.Pointer)
            {
                Poi.Current.Unit.Target();

                return(HANDLED_EXECUTION);
            }

            if (await PreCombatLogic())
            {
                return(HANDLED_EXECUTION);
            }

            if (!Core.Player.InCombat)
            {
                await Pull();

                return(HANDLED_EXECUTION);
            }
            else
            {
                if (await Heal())
                {
                    return(HANDLED_EXECUTION);
                }

                if (await CombatBuff())
                {
                    return(HANDLED_EXECUTION);
                }

                await Combat();

                return(HANDLED_EXECUTION);
            }
        }
Exemplo n.º 14
0
        //{
        //    get
        //    {
        //        var badGuys = (CombatTargeting.Instance.Provider as DDCombatTargetingProvider)?.GetObjectsByWeight();

        //        var anyBadGuysAround = badGuys != null && badGuys.Any();

        //        //if (Beta.Target != null && Beta.Target.IsValid && !Blacklist.Contains(Beta.Target.ObjectId, (BlacklistFlags)DeepDungeonManager.Level) && Beta.Target.Type != GameObjectType.GatheringPoint)
        //        //    return null;

        //        // Party member is dead
        //        if (PartyManager.AllMembers.Any(member => member.CurrentHealth == 0))
        //        {
        //            // Select Cairn of Return as highest priority if it is known and can be used.
        //            if (CairnOfReturn != null && DeepDungeonManager.ReturnActive)
        //                return CairnOfReturn;

        //            // If the Cairn of Return is not yet active and there are any mobs around: Kill the mobs.
        //            if (anyBadGuysAround)
        //                return new Poi(badGuys.First(), PoiType.Kill);
        //        }

        //        // Cairn of Passage
        //        if (LevelComplete && Portal != null)
        //            return Portal;

        //        // Bosses or Pomander of Rage / Pomander of Lust
        //        if ((DeepDungeonManager.BossFloor || Core.Me.HasAura(Auras.Lust)) && anyBadGuysAround)
        //            return new Poi(badGuys.First(), PoiType.Kill);

        //        // Chests
        //        if (LastEntities != null && LastEntities.Any())
        //            return LastEntities.First();

        //        // Kill something
        //        if (anyBadGuysAround)
        //            return new Poi(badGuys.First(), PoiType.Kill);

        //        return new Poi(
        //            SafeSpots.OrderByDescending(i => i.Distance2D(Core.Me.Location)).First(),
        //            PoiType.Hotspot
        //        );


        //    }
        //}

        internal void AddToBlackList(GameObject obj, string reason)
        {
            Blacklist.Add(obj, (BlacklistFlags)_floor, TimeSpan.FromMinutes(3), reason);
            Poi.Clear(reason);
        }
Exemplo n.º 15
0
        public async Task <bool> Run()
        {
            if (Target.Type != (PoiType)PoiTypes.UseCarnOfReturn)
            {
                return(false);
            }

            //let the navigation task handle moving toward the object if we are too far away.
            if (Target.Location.Distance2D(Core.Me.Location) > 3)
            {
                return(false);
            }

            var unit = GameObjectManager.GetObjectByNPCId(EntityNames.CairnofReturn);

            if (unit == null)
            {
                Logger.Warn("Carn of return could not be found at this location");
                location = Vector3.Zero;
                Poi.Clear("Carn of Return could not be found");
                return(true);
            }

            if (unit.Distance2D(Core.Me.Location) >= 3)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(unit.Location, "Carn of Return"), 2.5f, true);

                return(true);
            }

            //if we are a frog / lust we can't open a chest
            if (Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust))
            {
                Logger.Warn("Unable to open chest. Waiting for aura to end...");
                await CommonTasks.StopMoving("Waiting on aura to end");

                await Coroutine.Wait(TimeSpan.FromSeconds(30),
                                     () => !(Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust)) ||
                                     Core.Me.InCombat || DeepDungeon.StopPlz);

                //incase we entered combat
                return(true);
            }

            await Coroutine.Yield();

            if (Core.Me.HasAura(Auras.Lust))
            {
                await Tasks.Coroutines.Common.CancelAura(Auras.Lust);
            }
            Logger.Verbose("Attempting to interact with: {0}", unit.Name);
            unit.Target();
            unit.Interact();

            await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Wait(1000, () => Core.Me.IsCasting);
            }

            await Coroutine.Wait(10000, () => !Core.Me.IsCasting);

            await Coroutine.Sleep(500);

            Poi.Clear("Used Carn Of Return");
            return(true);
        }
Exemplo n.º 16
0
        /// <summary>
        ///     Handles opening treasure coffers or opening an exit portal
        /// </summary>
        /// <returns></returns>
        internal async Task <bool> TreasureOrExit()
        {
            var tries = 0;
            var npcid = Target.Unit.NpcId;

            if (Target.Location.Distance2D(Core.Me.Location) >= 3)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, Target.Name), 2.5f, true);

                return(true);
            }

            pomanderCapped = false;
            //Unsubscribe first to prevent subscriptions from persisting
            //GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied;
            // GamelogManager.MessageRecevied += GamelogManagerOnMessageRecevied;

            while (!DeepDungeonCombined.StopPlz && Target.Unit != null && Target.Unit.IsValid && tries < 3)
            {
                try
                {
                    //if we are a transformed we can't open a chest
                    if (Constants.AuraTransformed)
                    {
                        Logger.Warn("Unable to open chest. Waiting for aura to end...");
                        await CommonTasks.StopMoving("Waiting on aura to end");

                        await Coroutine.Wait(TimeSpan.FromSeconds(30),
                                             () => !Constants.AuraTransformed || Core.Me.InCombat || DeepDungeonCombined.StopPlz);

                        return(true);
                    }


                    await Coroutine.Yield();

                    if (Core.Me.HasAura(Auras.Lust))
                    {
                        await Tasks.Common.CancelAura(Auras.Lust);
                    }

                    Logger.Verbose("Attempting to interact with: {0} ({1} / 3)", Target.Name, tries + 1);

                    if (!PartyManager.IsInParty || PartyManager.IsPartyLeader ||
                        PartyManager.IsInParty && Constants.IsExitObject(Target.Unit))
                    {
                        await CommonTasks.StopMoving("Interacting with chest");

                        if (!await ObjectInteraction(Target.Unit))
                        {
                            break;
                        }
                    }
                    else
                    {
                        await CommonTasks.StopMoving("Waiting for leader to use chest");
                    }

                    await Coroutine.Sleep(700);

                    if (!Target.Unit.IsValid)
                    {
                        break;
                    }

                    if (!Target.Unit.IsTargetable)
                    {
                        break;
                    }

                    if (SelectYesno.IsOpen)
                    {
                        break;
                    }
                }
                finally
                {
                    tries++;
                    DeepDungeonManager.PomanderChange();
                }
            }

            GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied;

            await Coroutine.Wait(500, () => SelectYesno.IsOpen);

            //if this is an exit
            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Sleep(1000);

                Logger.Verbose("Is window open : {0}", DeepDungeonResult.Instance.IsOpen);
                if (DeepDungeonResult.Instance.IsOpen)
                {
                    Logger.Verbose("Calling Close");
                    await Coroutine.Sleep(2000);

                    DeepDungeonResult.Instance.SendAction(1, 3, uint.MaxValue);
                    DeepTracker.EndRun(false);
                }
                await Coroutine.Wait(TimeSpan.MaxValue,
                                     () => DeepDungeonCombined.StopPlz || QuestLogManager.InCutscene || NowLoading.IsVisible);

                return(true);
            }

            if (Target.Unit != null && Target.Unit.IsValid)
            {
                Blacklist.Add(Target.Unit.ObjectId, TimeSpan.FromMinutes(5), $"Tried to Interact with the Target {tries} times");
            }

            Poi.Clear($"Tried to Interact with the Target {tries} times");

            return(false);
        }
Exemplo n.º 17
0
        /// <summary>
        ///     Handles opening treasure coffers or opening an exit portal
        /// </summary>
        /// <returns></returns>
        internal async Task <bool> TreasureOrExit()
        {
            var tries = 0;
            var npcid = Target.Unit.NpcId;

            if (Target.Location.Distance2D(Core.Me.Location) >= 3)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, Target.Name), 2.5f, true);

                return(true);
            }

            while (!DeepDungeon2.StopPlz && tries < 3 && Target.Unit.IsValid)
            {
                //if we are a frog / lust we can't open a chest
                if (Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) ||
                    Core.Me.HasAura(Auras.Lust))
                {
                    Logger.Warn("Unable to open chest. Waiting for aura to end...");
                    await CommonTasks.StopMoving("Waiting on aura to end");

                    await Coroutine.Wait(TimeSpan.FromSeconds(30),
                                         () => !(Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) ||
                                                 Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust)) ||
                                         Core.Me.InCombat || DeepDungeon2.StopPlz);

                    return(true);
                }

                await Coroutine.Yield();

                if (Core.Me.HasAura(Auras.Lust))
                {
                    await Tasks.Coroutines.Common.CancelAura(Auras.Lust);
                }
                Logger.Verbose("Attempting to interact with: {0} ({1} / 3)", Target.Name, tries + 1);
                if (!PartyManager.IsInParty || PartyManager.IsPartyLeader ||
                    PartyManager.IsInParty && Constants.IsExitObject(Target.Unit))
                {
                    await CommonTasks.StopMoving("Interacting with chest");

                    if (!await ScriptHelpers.ObjectInteraction(Target.Unit))
                    {
                        break;
                    }

                    //Target.Unit.Interact();
                }
                else
                {
                    await CommonTasks.StopMoving("Waiting for leader to use chest");
                }

                await Coroutine.Sleep(700);

                tries++;

                if (!Target.Unit.IsValid)
                {
                    break;
                }

                if (!Target.Unit.IsTargetable)
                {
                    break;
                }

                if (SelectYesno.IsOpen)
                {
                    break;
                }
            }

            await Coroutine.Wait(700, () => SelectYesno.IsOpen);

            //if this is an exit
            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Wait(TimeSpan.MaxValue,
                                     () => DeepDungeon2.StopPlz || QuestLogManager.InCutscene || NowLoading.IsVisible);

                return(true);
            }

            Blacklist.Add(Target.Unit.ObjectId, TimeSpan.FromMinutes(1),
                          $"Tried to Interact with the Target {tries+1} times");
            Poi.Clear($"Tried to Interact with the Target {tries+1} times");

            return(false);
        }
Exemplo n.º 18
0
 private static Composite CombatCoroutine()
 {
     return(new PrioritySelector(new Decorator(object0 => !InFight && !Core.Me.IsDead, new PrioritySelector(new HookExecutor("Rest", "", new ActionAlwaysFail()), new HookExecutor("PreCombatBuff", "", new ActionAlwaysFail()))),
                                 new Decorator(object0 => Core.Me.IsDead || Poi.Current == null || Poi.Current.BattleCharacter == null, new Action(delegate { Poi.Clear("Invalid Combat Poi"); })),
                                 new Decorator(object0 => !Poi.Current.Unit.IsValid || Poi.Current.BattleCharacter.IsDead || Poi.Current.Unit.IsFateGone,
                                               new Action(delegate
     {
         Poi.Clear("Targeted unit is dead, clearing Poi and carrying on!");
         return RunStatus.Failure;
     })),
                                 new Decorator(object0 => Poi.Current != null && Poi.Current.Unit != null && Poi.Current.Unit.IsValid && Poi.Current.Unit.Pointer != Core.Me.PrimaryTargetPtr && Poi.Current.Unit.Distance() < 30f,
                                               new Action(delegate { Poi.Current.Unit.Target(); })),
                                 new Decorator(object0 => Core.Me.PrimaryTargetPtr == IntPtr.Zero,
                                               new Action(delegate
     {
         Poi.Clear("Targeted unit is zero, clearing Poi and carrying on!");
         return RunStatus.Failure;
     })),
                                 new HookExecutor("PreCombatLogic"),
                                 new Decorator(object0 => Core.Me.PrimaryTargetPtr != IntPtr.Zero,
                                               new PrioritySelector(new Decorator(object0 => Core.Player.IsMounted &&
                                                                                  Core.Target.Location.Distance2D(Core.Player.Location) < Core.Me.CombatReach + RoutineManager.Current.PullRange,
                                                                                  new Action(delegate
     {
         ActionManager.Dismount();
         Navigator.Stop();
     })),
                                                                    new Decorator(object0 => !Core.Me.InCombat || !Core.Me.InCombat && !Poi.Current.BattleCharacter.InCombat,
                                                                                  new HookExecutor("Pull", "Run when pulling a mob to kill.", RoutineManager.Current.PullBehavior)),
                                                                    new Decorator(object0 => Core.Me.InCombat,
                                                                                  new PrioritySelector(new Decorator(object0 => PostCombatDelay > 0f && !Bool0,
                                                                                                                     new Action(delegate
     {
         Bool0 = true;
         return RunStatus.Failure;
     })),
                                                                                                       new Decorator(object0 => !Poi.Current.BattleCharacter.InCombat &&
                                                                                                                     Poi.Current.TimeSet + TimeSpan.FromSeconds(10.0) < DateTime.Now,
                                                                                                                     new Action(delegate
     {
         Poi
         .Clear("I'm in combat, but POI isn't and it has been atleast 10 seconds. Clearing POI and picking up a new target.");
     })),
                                                                                                       new Decorator(object0 => Poi.Current.BattleCharacter.IsDead,
                                                                                                                     new Action(delegate { Poi.Clear("I'm in combat, but POI is dead. Clearing POI and picking up a new target."); })),
                                                                                                       new HookExecutor("RoutineCombat", "Executes the current routine's Combat behavior", BrainBehavior.CombatLogic))))),
                                 new Action(object0 => RunStatus.Success)));
 }
Exemplo n.º 19
0
        internal void Pulse()
        {
            if (CommonBehaviors.IsLoading)
            {
                return;
            }

            if (!Constants.InDeepDungeon)
            {
                return;
            }

            if (DirectorManager.ActiveDirector is InstanceContentDirector activeAsInstance)
            {
                if (activeAsInstance.TimeLeftInDungeon == TimeSpan.Zero)
                {
                    return;
                }
            }

            if (_floor != DeepDungeonManager.Level)
            {
                Logger.Info("Level has Changed. Clearing Targets");
                _floor = DeepDungeonManager.Level;
                Blacklist.Clear(i => i.Flags == (BlacklistFlags)DeepDungeonManager.Level);
            }

            //if (CairnOfReturn != null && !CairnOfReturn.IsValid)
            //    CairnOfReturn = null;

            //if (Portal != null && !Portal.IsValid)
            //    Portal = null;

            //using (new PerformanceLogger("Targeting Pulse"))
            // {
            // GameObjectManager.Update();
            LastEntities = new ReadOnlyCollection <GameObject>(GetObjectsByWeight());

            if (_lastPulse + TimeSpan.FromSeconds(5) >= DateTime.Now)
            {
                return;
            }
            Logger.Verbose($"Found {LastEntities.Count} Targets");

            if (_lastLoc == Core.Me.Location && !Core.Me.HasTarget)
            {
                Logger.Verbose($"Stuck but found {LastEntities.Count} Targets");

                if (_count > 3)
                {
                    Logger.Verbose($"[Stuck] COUNTER TRIGGERED... Do Something but found {LastEntities.Count} Targets");
                    _count     = 0;
                    _lastLoc   = Core.Me.Location;
                    _lastPulse = DateTime.Now;

                    GameObjectManager.Update();

                    DDNavigationProvider.trapList.RemoveWhere(r =>
                                                              r.Center.Distance2D(Core.Me.Location) < 15 || r.Center.Distance2D(Poi.Current.Location) < 15);

                    Logger.Debug("Going to starting room and clearing traps");
                    Navigator.PlayerMover.MoveTowards(Poi.Current.Location);
                    Thread.Sleep(500);
                    Navigator.Stop();
                    if (Poi.Current.Unit != null)
                    {
                        DDTargetingProvider.Instance.AddToBlackList(Poi.Current.Unit, TimeSpan.FromSeconds(20),
                                                                    "Navigation Error");
                    }
                    Poi.Clear("Stuck?");
                    Navigator.Clear();


                    //Poi.Current = new Poi(DDNavigationProvider.startingLoc, (PoiType) PoiTypes.ExplorePOI);
                    // Navigator.MoveTo(
                    //     POTDNavigation.SafeSpots.OrderByDescending(i => i.Distance2D(Core.Me.Location)).First(),
                    //      "SafeSpot)");
                    //DDNavigationProvider.trapList.Clear();
                }

                _count++;
            }

            _lastLoc   = Core.Me.Location;
            _lastPulse = DateTime.Now;
            // }
        }
Exemplo n.º 20
0
        /// <summary>
        ///     Handles opening treasure coffers or opening an exit portal
        /// </summary>
        /// <returns></returns>
        internal async Task <bool> TreasureOrExit()
        {
            int tries = 0;

/*            if (Target.Unit.IsValid && Target.Unit.NpcId == EntityNames.BossExit)
 *          {
 *
 *          }*/

            if (Target.Location.Distance2D(Core.Me.Location) >= 3)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, Target.Name), 2.5f, true);

                return(true);
            }

            while (!DeepDungeonHoH.StopPlz && tries < 3 && Target.Unit.IsValid)
            {
                //if we are a frog / lust we can't open a chest
                if (Constants.AuraTransformed)
                {
                    Logger.Warn("Unable to open chest. Waiting for aura to end...");
                    await CommonTasks.StopMoving("Waiting on aura to end");

                    await Coroutine.Wait(TimeSpan.FromSeconds(30),
                                         () => !Constants.AuraTransformed || Core.Me.InCombat || DeepDungeonHoH.StopPlz);

                    return(true);
                }

                await Coroutine.Yield();

                Logger.Verbose("Attempting to interact with: {0} ({1} / 3)", Target.Name, tries + 1);

                Target.Unit.Target();
                //if (!Settings.Instance.NotLeader || (Settings.Instance.NotLeader && Target.Unit != null && (Target.Unit.NpcId == EntityNames.FloorExit || Target.Unit.NpcId == EntityNames.LobbyExit || Target.Unit.NpcId == EntityNames.BossExit)))
                if (!PartyManager.IsInParty || PartyManager.IsPartyLeader ||
                    PartyManager.IsInParty && Constants.IsExitObject(Target.Unit))
                {
                    if (Constants.IsExitObject(Target.Unit))
                    {
                        Logger.Debug("At Exit");
                        await Coroutine.Sleep(500);
                    }


                    await CommonTasks.StopMoving("Leader Interacting");

                    Target.Unit.Interact();
                }
                else
                {
                    await CommonTasks.StopMoving("Waiting for leader to use chest");
                }

                await Coroutine.Sleep(500);

                tries++;

                if (!Target.Unit.IsValid)
                {
                    break;
                }

                if (!Target.Unit.IsTargetable)
                {
                    break;
                }

                if (SelectYesno.IsOpen)
                {
                    break;
                }
            }

            await Coroutine.Wait(1000, () => SelectYesno.IsOpen);

            //if this is an exit
            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Sleep(1000);

                Logger.Debug("Is window open : {0}", RaptureAtkUnitManager.GetWindowByName("DeepDungeonResult"));
                if (RaptureAtkUnitManager.GetWindowByName("DeepDungeonResult") != null)
                {
                    Logger.Debug("Calling Close");
                    await Coroutine.Sleep(2000);

                    RaptureAtkUnitManager.GetWindowByName("DeepDungeonResult").SendAction(1, 3, uint.MaxValue);
                }
                await Coroutine.Wait(TimeSpan.MaxValue,
                                     () => DeepDungeonHoH.StopPlz || QuestLogManager.InCutscene || NowLoading.IsVisible);

                return(true);
            }

            Blacklist.Add(Target.Unit.ObjectId, TimeSpan.FromMinutes(1),
                          $"Tried to Interact with the Target {tries} times");
            Poi.Clear($"Tried to Interact with the Target {tries} times");

            return(false);
        }
Exemplo n.º 21
0
        public async Task <bool> Run()
        {
            if (!DutyManager.InInstance || DeepDungeonManager.Director.TimeLeftInDungeon == TimeSpan.Zero)
            {
                return(false);
            }
            //dont try and do combat outside of the dungeon plz
            if (!Constants.InDeepDungeon)
            {
                return(false);
            }

            if (AvoidanceManager.IsRunningOutOfAvoid)
            {
                return(true);
            }

            if (!Core.Me.InRealCombat())
            {
                if (await Rest())
                {
                    await CommonTasks.StopMoving("Resting");

                    await Tasks.Common.UsePots();

                    return(true);
                }

                if (await PreCombatBuff())
                {
                    return(true);
                }


                // For floors with auto heal penalty or item penalty we will engage normally until we hit
                // the magic sub-40% threshold. Statistically it is smarter to just try and finish the floor
                // instead of waiting around while healing just to encounter additional mobs spawning in.
                if (Core.Me.CurrentHealthPercent <= 40 &&
                    (Core.Me.HasAura(Auras.ItemPenalty) || Core.Me.HasAura(Auras.NoAutoHeal)) &&
                    !DeepDungeonManager.BossFloor)
                {
                    await CommonTasks.StopMoving("Resting");
                    await Heal();

                    return(true);
                }

                if (Core.Me.CurrentHealthPercent <= 90 &&
                    !(Core.Me.HasAura(Auras.ItemPenalty) || Core.Me.HasAura(Auras.NoAutoHeal)) &&
                    !DeepDungeonManager.BossFloor)
                {
                    await CommonTasks.StopMoving("Resting");
                    await Heal();

                    return(true);
                }
            }

            if (Poi.Current == null || Poi.Current.Type != PoiType.Kill || Poi.Current.BattleCharacter == null)
            {
                return(false);
            }
            if (Poi.Current.BattleCharacter == null || !Poi.Current.BattleCharacter.IsValid || Poi.Current.BattleCharacter.IsDead)
            {
                Poi.Clear("Target is dead");
                return(true);
            }

            var target = Poi.Current;

            TreeRoot.StatusText = $"Combat: {target.BattleCharacter.Name}";

            //target if we are in range
            //Logger.Info("======= OUT OF RANGE");
            if (target.BattleCharacter.Pointer != Core.Me.PrimaryTargetPtr && target.BattleCharacter.IsTargetable && target.Location.Distance2D(Core.Me.Location) <= Constants.ModifiedCombatReach)
            {
                Logger.Warn("Combat target has changed");
                target.BattleCharacter.Target();
                return(true);
            }

            //Logger.Info("======= PRE COMBAT");
            if (await PreCombatBuff())
            {
                return(true);
            }

            //Logger.Info("======= OUT OF RANGE2");
            //we are outside of targeting range, walk to the mob
            if ((Core.Me.PrimaryTargetPtr == IntPtr.Zero || target.Location.Distance2D(Core.Me.Location) > Constants.ModifiedCombatReach) && !AvoidanceManager.IsRunningOutOfAvoid)
            {
                //Logger.Info("======= MoveAndStop======");
                var dist = Core.Player.CombatReach + RoutineManager.Current.PullRange + (target.Unit != null ? target.Unit.CombatReach : 0);
                if (dist > 30)
                {
                    dist = 29;
                }

                await CommonTasks.MoveAndStop(new MoveToParameters(target.Location, target.Name), Constants.ModifiedCombatReach, true);

                return(true);
            }

            if (await UseWitching())
            {
                return(true);
            }

            //used if we are transformed
            if (await UsePomanderSpell())
            {
                return(true);
            }

            if (await PreCombatLogic())
            {
                return(true);
            }

            //Logger.Info("======= PULL");
            //pull not in combat
            if (!Core.Me.HasAura(Auras.Lust) && !Core.Me.HasAura(Auras.Rage) && !Core.Me.InRealCombat())
            {
                //if(target.Location.Distance2D(Core.Me.Location) > RoutineManager.Current.PullRange)
                //{
                //    Logger.Info("======= Should be pulling....out");
                //    TreeRoot.StatusText = $"Moving to kill target";
                //    await CommonTasks.MoveAndStop(new MoveToParameters(target.Location, target.Name),  Constants.ModifiedCombatReach, true);
                //    return true;
                //}
                await Pull();

                return(true);
            }

            //6334 - Final Sting
            if (
                GameObjectManager.Attackers.Any(
                    i =>
                    i.IsCasting &&
                    i.CastingSpellId == 6334 &&
                    i.TargetCharacter == Core.Me) &&
                Core.Me.CurrentHealthPercent < 90)
            {
                if (await Tasks.Common.UsePots(true))
                {
                    return(true);
                }
            }

            if (Core.Me.InRealCombat())
            {
                if (await Tasks.Common.UseSustain())
                {
                    return(true);
                }

                if (Settings.Instance.UseAntidote)
                {
                    if (Core.Me.HasAnyAura(Auras.Poisons) && await Tasks.Common.UseItemById(Items.Antidote))
                    {
                        return(true);
                    }
                }

                if (await Heal())
                {
                    return(true);
                }

                if (await CombatBuff())
                {
                    return(true);
                }

                if (await Combat())
                {
                    return(true);
                }
            }

            //Logger.Warn($"don't let anything else execute if we are running the kill poi");
            //don't let anything else execute if we are running the kill poi
            return(true); //we expected to do combat
        }
Exemplo n.º 22
0
        public async Task <bool> Run()
        {
            //dont try and do combat outside of the dungeon plz
            if (!Constants.InDeepDungeon)
            {
                return(false);
            }

            if (AvoidanceManager.IsRunningOutOfAvoid)
            {
                return(true);
            }


            if (!Core.Me.InRealCombat())
            {
                if (!Core.Me.HasAura(Auras.NoAutoHeal) && await Rest())
                {
                    await CommonTasks.StopMoving("Resting");

                    await Tasks.Coroutines.Common.UsePots();

                    return(true);
                }

                if (await PreCombatBuff())
                {
                    return(true);
                }

                // For floors with auto heal penalty or item penalty we will engage normally until we hit
                // the magic sub-40% threshold. Statistically it is smarter to just try and finish the floor
                // instead of waiting around while healing just to encounter additional mobs spawning in.
                if (Core.Me.CurrentHealthPercent <= 20 &&
                    (Core.Me.HasAura(Auras.ItemPenalty) || Core.Me.HasAura(Auras.NoAutoHeal)) &&
                    !DeepDungeonManager.BossFloor)
                {
                    await CommonTasks.StopMoving("Resting");
                    await Heal();

                    return(true);
                }

                if (Core.Me.CurrentHealthPercent <= 85 &&
                    !(Core.Me.HasAura(Auras.ItemPenalty) || Core.Me.HasAura(Auras.NoAutoHeal)) &&
                    !DeepDungeonManager.BossFloor)
                {
                    await CommonTasks.StopMoving("Resting");
                    await Heal();

                    return(true);
                }
            }

            if (Poi.Current == null || Poi.Current.Type != PoiType.Kill || Poi.Current.BattleCharacter == null)
            {
                return(false);
            }

            if (Poi.Current.BattleCharacter == null || !Poi.Current.BattleCharacter.IsValid ||
                Poi.Current.BattleCharacter.IsDead)
            {
                Poi.Clear("Target is dead");
                return(true);
            }

            Poi target = Poi.Current;

            TreeRoot.StatusText = $"Combat: {target.BattleCharacter.Name}";

            //target if we are in range
            //Logger.Info("======= OUT OF RANGE");
            if (target.BattleCharacter.Pointer != Core.Me.PrimaryTargetPtr && target.BattleCharacter.IsTargetable &&
                target.Location.Distance2D(Core.Me.Location) <= _pullRange)
            {
                Logger.Warn("Combat target has changed");
                target.BattleCharacter.Target();
                return(true);
            }

            //Logger.Info("======= PRE COMBAT");
            if (await PreCombatBuff())
            {
                return(true);
            }

            //Logger.Info("======= OUT OF RANGE2");
            //we are outside of targeting range, walk to the mob
            if ((Core.Me.PrimaryTargetPtr == IntPtr.Zero || target.Location.Distance2D(Core.Me.Location) > _pullRange) && !AvoidanceManager.IsRunningOutOfAvoid)
            {
                float dist = Core.Player.CombatReach + RoutineManager.Current.PullRange +
                             (target.Unit != null ? target.Unit.CombatReach : 0);
                if (dist > _pullRange)
                {
                    dist = _pullRange;
                }

                await CommonTasks.MoveAndStop(new MoveToParameters(target.Location, target.Name), dist, true);

                return(true);
            }

            if (await UseWitching())
            {
                return(true);
            }

            //used if we are transformed
            if (await UsePomanderSpell())
            {
                return(true);
            }

            if (await PreCombatLogic())
            {
                return(true);
            }

            //Logger.Info("======= PULL");
            //pull not in combat
            if (!Core.Me.HasAura(Auras.Lust) && !Core.Me.HasAura(Auras.Rage) && !Core.Me.InRealCombat())
            {
                //if(target.Location.Distance2D(Core.Me.Location) > RoutineManager.Current.PullRange)
                //{
                //    TreeRoot.StatusText = $"Moving to kill target";
                //    await CommonTasks.MoveAndStop(new MoveToParameters(target.Location, target.Name), Core.Player.CombatReach + RoutineManager.Current.PullRange + (target.Unit != null ? target.Unit.CombatReach : 0), true);
                //    return true;
                //}
                await Pull();

                return(true);
            }

            //6334 - Final Sting
            if (
                GameObjectManager.Attackers.Any(
                    i =>
                    i.IsCasting &&
                    i.CastingSpellId == 6334 &&
                    i.TargetCharacter == Core.Me) &&
                Core.Me.CurrentHealthPercent < 90)
            {
                if (await Tasks.Coroutines.Common.UsePots(true))
                {
                    return(true);
                }
            }


            if (GameObjectManager.Attackers.Any(
                    i =>
                    i.IsCasting &&
                    i.CastingSpellId == 6351 &&
                    i.NpcId == 7268))
            {
                BattleCharacter npc =
                    GameObjectManager.Attackers
                    .FirstOrDefault(i => i.IsCasting && i.NpcId == 7268 && i.CastingSpellId == 6351);
                while (npc != null && npc.IsCasting)
                {
                    MovementManager.SetFacing(npc.Heading);
                    await Coroutine.Sleep(100);
                }
            }

            if (GameObjectManager.Attackers.Any(
                    i =>
                    i.IsCasting &&
                    i.CastingSpellId == 11290 &&
                    i.NpcId == 7478))
            {
                BattleCharacter npc =
                    GameObjectManager.Attackers
                    .FirstOrDefault(i => i.IsCasting && i.NpcId == 7478 && i.CastingSpellId == 11290);


                while (npc != null && npc.IsCasting)
                {
                    Clio.Utilities.Vector3 vector3 = new Clio.Utilities.Vector3(-299.9771f, -0.01531982f, -320.4548f);
                    float dist = Core.Player.Location.Distance(vector3);
                    Navigator.PlayerMover.MoveTowards(vector3);
                    while (vector3.Distance2D(Core.Me.Location) >= 4.4)
                    {
                        Navigator.PlayerMover.MoveTowards(vector3);
                        await Coroutine.Sleep(100);
                    }
                    Navigator.PlayerMover.MoveStop();
                    await Coroutine.Sleep(10000);
                }
            }
            //DeepDungeonManager.BossFloor
            if (DeepDungeonManager.BossFloor && GameObjectManager.Attackers.Any(i => i.IsCasting))
            {
                BattleCharacter npc = GameObjectManager.Attackers.FirstOrDefault(i => i.IsCasting);
                string          log = $"Boss {npc.NpcId} Cast {npc.CastingSpellId}";
                Logger.Debug(log);
            }

            if (!Core.Me.InRealCombat())
            {
                return(true);
            }

            //we expected to do combat
            if (await Tasks.Coroutines.Common.UseSustain())
            {
                return(true);
            }

            if (Settings.Instance.UseAntidote)
            {
                if (Core.Me.HasAnyAura(Auras.Poisons) && await Tasks.Coroutines.Common.UseItemById(Items.Antidote))
                {
                    return(true);
                }
            }

            if (await Heal())
            {
                return(true);
            }

            if (await CombatBuff())
            {
                return(true);
            }

            if (await Combat())
            {
                return(true);
            }

            //Logger.Warn($"don't let anything else execute if we are running the kill poi");
            //don't let anything else execute if we are running the kill poi
            return(true); //we expected to do combat
        }
Exemplo n.º 23
0
 internal void AddToBlackList(GameObject obj, TimeSpan time, string reason)
 {
     Blacklist.Add(obj, (BlacklistFlags)_floor, time, reason);
     Poi.Clear(reason);
 }
Exemplo n.º 24
0
        /// <summary>
        /// Handles opening treasure coffers or opening an exit portal
        /// </summary>
        /// <returns></returns>
        internal async Task <bool> TreasureOrExit()
        {
            var tries = 0;
            var npcid = Target.Unit.NpcId;

            if (Target.Location.Distance2D(Core.Me.Location) >= 3)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, Target.Name), 2.5f, true);

                return(true);
            }

            pomanderCapped = false;
            //Unsubscribe first to prevent subscriptions from persisting
            GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied;
            GamelogManager.MessageRecevied += GamelogManagerOnMessageRecevied;

            while (!DeepDungeon.StopPlz && (Target.Unit != null && Target.Unit.IsValid) && tries < 3 && !pomanderCapped)
            {
                try
                {
                    //if we are a frog / lust we can't open a chest
                    if (Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust))
                    {
                        Logger.Warn("Unable to open chest. Waiting for aura to end...");
                        await CommonTasks.StopMoving("Waiting on aura to end");

                        await Coroutine.Wait(TimeSpan.FromSeconds(30),
                                             () => !(Core.Me.HasAura(Auras.Toad) || Core.Me.HasAura(Auras.Frog) || Core.Me.HasAura(Auras.Toad2) || Core.Me.HasAura(Auras.Lust)) ||
                                             Core.Me.InCombat || DeepDungeon.StopPlz);

                        return(true);
                    }


                    await Coroutine.Yield();

                    if (Core.Me.HasAura(Auras.Lust))
                    {
                        await Deep.Tasks.Coroutines.Common.CancelAura(Auras.Lust);
                    }
                    Logger.Verbose("Attempting to interact with: {0} ({1} / 3)", Target.Name, tries + 1);

                    await CommonTasks.StopMoving("Stop and open chest");

                    Target.Unit.Target();
                    Target.Unit.Interact();
                    await Coroutine.Sleep(800);


                    if (!Target.Unit.IsTargetable)
                    {
                        break;
                    }
                    if (SelectYesno.IsOpen)
                    {
                        break;
                    }
                }
                finally
                {
                    tries++;
                }
            }
            GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied;

            await Coroutine.Wait(500, () => SelectYesno.IsOpen);

            //if this is an exit
            if (SelectYesno.IsOpen)
            {
                SelectYesno.ClickYes();
                await Coroutine.Wait(TimeSpan.MaxValue, () => DeepDungeon.StopPlz || QuestLogManager.InCutscene || NowLoading.IsVisible);

                return(true);
            }

            if (Target.Unit != null && Target.Unit.IsValid)
            {
                Blacklist.Add(Target.Unit.ObjectId, TimeSpan.FromMinutes(5), $"Tried to Interact with the Target {tries} times");
            }

            Poi.Clear($"Tried to Interact with the Target {tries} times");

            return(false);
        }
Exemplo n.º 25
0
        protected override Composite CreateBehavior()
        {
            return(new PrioritySelector(
                       new Decorator(ret => ShouldStop(),
                                     new Action(r => OnDoneWhile())),
                       new Decorator(ret => DateTime.Now > saveNow + TimeSpan.FromSeconds(_timeout) && currentstep == 0,
                                     new Action(r => OnTimeout())),
                       // This one will run always kind of a pulse one
                       new Sequence(
                           new Action(r => CountDeath()),
                           new Action(r => IsFateStillActive()),
                           new Action(r => UpdateFateData()),
                           new ActionAlwaysFail() //always fail that the rest of the tree is traveresd
                           ),
                       //Start fighting Fate Mobs but only when we are in close range to the fate position.TBD enhance this filter

                       #region sync//level Sync

                       new Decorator(r => currentfate != null && FateManager.WithinFate && currentfate.MaxLevel < Core.Player.ClassLevel && !Core.Me.IsLevelSynced,
                                     new ActionRunCoroutine(async r =>
            {
                Logging.Write("Applying Level Sync.");

                ToDoList.LevelSync();

                await Coroutine.Sleep(500);

                return false;
            })
                                     ),

                       #endregion sync//level Sync

                       #region Movment

                       new Decorator(
                           ret => currentstep == 1 && Vector3.Distance(Core.Player.Location, Position) > (currentfate.Radius - 10),
                           UseFlight ? new ActionRunCoroutine(obj => FlyTo(Position, true, true)) : CommonBehaviors.MoveAndStop(ret => Position, Distance, stopInRange: true, destinationName: "Moving to Fates.")

                           ),

                       #region Handin

                       new Decorator(r => currentfate != null && FateManager.WithinFate && currentfate.Icon == FateIconType.KillHandIn && currentfate.TimeLeft.Minutes <= 8,
                                     new Sequence(
                                         new Action(r =>
            {
                Poi.Clear("Handing in items.");
                Logging.Write("Hand-in Fate");
                var npc = GameObjectManager
                          .GetObjectsOfType <BattleCharacter>()
                          .Where(
                    b => b.IsFate && !b.CanAttack && b.FateId == currentfate.Id);
                var q = from s in npc
                        group s by s into g
                        orderby g.Count() descending
                        select g.Key;
                if (q.LastOrDefault() == null)
                {
                    Logging.Write("Could not find handin NPC. Something is wrong.");
                    return;
                }
                tempProvider = CombatTargeting.Instance.Provider;
                CombatTargeting.Instance.Provider = new NullTargetingProvider();
                MoveTo(q.LastOrDefault().Location);
                GameObjectManager.GetObjectByNPCId(q.LastOrDefault().NpcId).Interact();
                Talk.Next();
                InventoryManager.GetBagByInventoryBagId(InventoryBagId.KeyItems).FilledSlots.LastOrDefault().Handover();
                Request.HandOver();
                CombatTargeting.Instance.Provider = tempProvider;
            }),
                                         new ActionAlwaysFail() //always fail that the rest of the tree is traveresd
                                         )),

                       new Decorator(ret => Talk.DialogOpen,
                                     new Action(r =>
            {
                Talk.Next();
            })),
                       new Decorator(ret => Request.IsOpen,
                                     new Action(r =>
            {
                GameObjectManager.GetObjectByNPCId(npc.NpcId).Interact();
                InventoryManager.GetBagByInventoryBagId(InventoryBagId.KeyItems).FilledSlots.LastOrDefault().Handover();
                Request.HandOver();
            })),

                       //Find fates

                       #endregion Handin

                       #endregion Movment

                       #region escort

                       new Decorator(r => currentfate != null && fateid != 0 && Poi.Current.Type != PoiType.Kill,
                                     new ActionRunCoroutine(async r => MoveToFocusedFate())

                                     ),

                       #endregion escort

                       new Decorator(ret => currentfate == null && currentstep == 0,
                                     new Sequence(
                                         new Action(r =>
            {
                getFates();
                if (currentfate != null)
                {
                    GoFate();
                }
                else
                {
                    GoHunting();
                }
            }
                                                    )
                                         )),
                       new ActionAlwaysSucceed()
                       ));
        }
Exemplo n.º 26
0
        public async Task <bool> Run()
        {
            if (Target.Type != PoiType.Wait)
            {
                return(false);
            }

            //let the navigator handle movement if we are far away
            if (Target.Location.Distance2D(Core.Me.Location) > 3)
            {
                return(false);
            }

            // move closer plz
            if (Target.Location.Distance2D(Core.Me.Location) >= 2)
            {
                await CommonTasks.MoveAndStop(new MoveToParameters(Target.Location, "Floor Exit"), 0.5f, true);

                return(true);
            }

            await CommonTasks.StopMoving();

            _moveTimer.Reset();
            var _level = DeepDungeonManager.Level;

            if (!GameObjectManager.GameObjects.Any(r => r.NpcId == EntityNames.OfPassage))
            {
                blackList.Clear();
            }

            ExitObjectId = GameObjectManager.GameObjects.Where(r => r.NpcId == EntityNames.OfPassage).OrderBy(r => r.Distance()).FirstOrDefault().ObjectId;
            Logger.Info($"Exit object id is {ExitObjectId}");
            await Coroutine.Wait(-1,
                                 () => Core.Me.InCombat || _level != DeepDungeonManager.Level || CommonBehaviors.IsLoading ||
                                 QuestLogManager.InCutscene || GameObjectManager.GetObjectByObjectId(ExitObjectId) == null || _moveTimer.IsFinished || !GameObjectManager.GetObjectByObjectId(ExitObjectId).IsVisible);

            if (_moveTimer.IsFinished || GameObjectManager.GetObjectByObjectId(ExitObjectId) == null || !GameObjectManager.GetObjectByObjectId(ExitObjectId).IsVisible)
            {
                if (Poi.Current.Unit != null)
                {
                    if (!Poi.Current.Unit.IsValid)
                    {
                        Logger.Warn("Waited 2 minutes at exit: Blacklisting current exit for 10min not valid");
                        DDTargetingProvider.Instance.AddToBlackList(Poi.Current.Unit, TimeSpan.FromMinutes(10),
                                                                    "Waited at exit(not valid) for 5 minutes");
                    }
                    else
                    {
                        Logger.Warn("Waited 2 minutes at exit: Blacklisting current exit for 5 min");
                        DDTargetingProvider.Instance.AddToBlackList(Poi.Current.Unit, TimeSpan.FromMinutes(5),
                                                                    "Waited at exit for 5 minutes");
                    }
                }
                else
                {
                    Logger.Warn("Waited 2 minutes at exit but poi is null");
                }

                if (PartyManager.IsInParty && PartyManager.AllMembers.All(i => i.BattleCharacter.Location.Distance2D(GameObjectManager.GetObjectByObjectId(ExitObjectId).Location) < 10))
                {
                    blackList.Add(ExitObjectId);
                }
            }

            Poi.Clear("Floor has changed or we have entered combat");
            location = Vector3.Zero;
            Navigator.Clear();
            return(true);
        }