Example #1
0
        internal void Pulse()
        {
            if (CommonBehaviors.IsLoading)
            {
                return;
            }

            if (!DutyManager.InInstance)
            {
                return;
            }

            if (DeepDungeonManager.Director.TimeLeftInDungeon == TimeSpan.Zero)
            {
                return;
            }

            if (!Constants.InDeepDungeon)
            {
                return;
            }

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

            using (new PerformanceLogger("Targeting Pulse", true))
            {
                LastEntities = new ReadOnlyCollection <GameObject>(GetObjectsByWeight());
            }

            if (_lastPulse + TimeSpan.FromSeconds(5) < DateTime.Now)
            {
                Logger.Verbose($"Found {LastEntities.Count} Targets");
                if (!LastEntities.Any())
                {
                    if (!GameObjectManager.GameObjects.Any(r => r.NpcId == EntityNames.OfPassage && !FloorExit.blackList.Contains(r.ObjectId)))
                    {
                        FloorExit.blackList.Clear();
                    }
                }
                _lastPulse = DateTime.Now;
            }
        }
Example #2
0
        internal static async Task <bool> UsePomander(Pomander number, uint auraId = 0)
        {
            if (Core.Me.HasAura(Auras.ItemPenalty) && number != Pomander.Serenity)
            {
                return(false);
            }

            //cannot use pomander while under the auras of rage / lust
            if (Core.Me.HasAnyAura(Auras.Lust, Auras.Rage))
            {
                return(false);
            }

            var data = DeepDungeonManager.GetInventoryItem(number);

            if (data.Count == 0)
            {
                return(false);
            }

            if (data.HasAura)
            {
                return(false);
            }

            if (Core.Me.HasAura(auraId) && Core.Me.GetAuraById(auraId).TimespanLeft > TimeSpan.FromMinutes(1))
            {
                return(false);
            }

            var lockoutTimer = PomanderLockoutTimers[number];

            if (!lockoutTimer.IsFinished)
            {
                return(false);
            }

            await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

            var cnt = data.Count;
            await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

            var wt = new WaitTimer(TimeSpan.FromSeconds(30));

            wt.Reset();
            while (cnt == data.Count && !wt.IsFinished)
            {
                Logger.Verbose($"Using Pomander: {number}");
                DeepDungeonManager.UsePomander(number);
                await Coroutine.Sleep(150);

                await Coroutine.Wait(5000, () => !DeepDungeonManager.IsCasting);

                DeepDungeonManager.PomanderChange();
                data = DeepDungeonManager.GetInventoryItem(number);
            }

            //Wait a little so we don't trigger the anti-stuck
            await Coroutine.Sleep(1000);

            //TODO this is probabbly stored somewhere in the client...
            switch (number)
            {
            case Pomander.Rage:
                PomanderState = ItemState.Rage;
                break;

            case Pomander.Lust:
                PomanderState = ItemState.Lust;
                break;

            case Pomander.Resolution:
                PomanderState = ItemState.Resolution;
                break;
            }

            lockoutTimer.Reset();

            return(true);
        }
Example #3
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);
        }