Пример #1
0
        internal static async Task <bool> HandleFate()
        {
            var currentFate = OracleFateManager.GetCurrentFateData();

            if (currentFate == null)
            {
                Logger.SendDebugLog("Current FATE could not be found, assuming it's finished.");
                OracleFateManager.ClearCurrentFate("FATE is "
                                                   + "no longer"
                                                   + " active.");
                return(false);
            }

            if (currentFate.Status == FateStatus.NOTACTIVE)
            {
                OracleFateManager.ClearCurrentFate("FATE is no longer active.");
                return(false);
            }

            if (Core.Player.Distance(currentFate.Location) > currentFate.Radius * 1.05f)
            {
                await OracleMovementManager.MoveToCurrentFate(false);

                if (OracleFateManager.CurrentFateId == 0)
                {
                    return(true);
                }
            }

            if (OracleCombatManager.IsPlayerBeingAttacked() && Poi.Current.Type != PoiType.Kill && Poi.Current.Type != PoiType.None)
            {
                OracleFateManager.ClearPoi("We're being attacked.", false);
                return(true);
            }

            if (OracleFateManager.IsLevelSyncNeeded(currentFate))
            {
                await OracleFateManager.SyncLevel(currentFate);

                return(true);
            }

            return(await RunFate());
        }
Пример #2
0
        internal static async Task <bool> HandleCombat()
        {
            var currentBc = Poi.Current.BattleCharacter;

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

            if (!currentBc.IsValid)
            {
                OracleFateManager.ClearPoi("Targeted unit is not valid.", false);
                return(true);
            }

            if (mostRecentBc == null || mostRecentBc != currentBc)
            {
                mostRecentBc    = currentBc;
                lastHpValue     = mostRecentBc.CurrentHealth;
                noDamageTimeout = Stopwatch.StartNew();
            }

            if (lastHpValue != mostRecentBc.CurrentHealth)
            {
                noDamageTimeout.Restart();
                lastHpValue = mostRecentBc.CurrentHealth;
            }

            if (ShouldBlacklistCombatPoi())
            {
                OracleFateManager.ClearPoi("Mob's HP has not changed in " + MainSettings.Instance.CombatNoDamageTimeout / 1000
                                           + " seconds, blacklisting and selecting a new mob.");
                Blacklist.Add(currentBc, BlacklistFlags.Combat, TimeSpan.FromMinutes(1), "No damage taken timeout triggered.");
                mostRecentBc    = null;
                noDamageTimeout = null;

                Core.Player.ClearTarget();
                return(true);
            }

            if (!currentBc.IsFate && !currentBc.IsDead && GameObjectManager.Attackers.All(mob => mob.ObjectId != currentBc.ObjectId) &&
                OracleFateManager.CurrentFateId != 0)
            {
                OracleFateManager.ClearPoi("Targeted unit is not in combat with us, nor part of the current FATE.", false);
                Blacklist.Add(currentBc, BlacklistFlags.Combat, TimeSpan.FromSeconds(30), "Not a FATE mob.");
                return(true);
            }

            // If target is not a FATE mob and is tapped by someone else.
            if (!currentBc.IsFate && currentBc.TappedByOther)
            {
                OracleFateManager.ClearPoi("Targeted unit is not a FATE mob and is tapped by someone else.");
                Blacklist.Add(currentBc, BlacklistFlags.Combat, TimeSpan.FromSeconds(30), "Tapped by another person.");
                Core.Player.ClearTarget();

                if (WaitSettings.Instance.FateWaitMode == FateWaitMode.GrindMobs)
                {
                    var target = await OracleCombatManager.GetGrindTarget();

                    if (target == null)
                    {
                        return(true);
                    }

                    Logger.SendLog("Selecting " + target.Name + " (" + target.ObjectId.ToString("X") + ") as the next target to kill.", true);
                    Poi.Current = new Poi(target, PoiType.Kill);
                }

                return(true);
            }

            // If target is a FATE mob, we need to handle several potential issues.
            if (currentBc.IsFate)
            {
                var fate = FateManager.GetFateById(Poi.Current.BattleCharacter.FateId);

                if (fate == null)
                {
                    return(true);
                }

                if (!OracleFateManager.IsLevelSyncNeeded(fate))
                {
                    return(true);
                }

                if (fate.Status != FateStatus.NOTACTIVE)
                {
                    if (fate.Within2D(Core.Player.Location))
                    {
                        await OracleFateManager.SyncLevel(fate);
                    }
                    else if (GameObjectManager.Attackers.Contains(Poi.Current.BattleCharacter))
                    {
                        await OracleMovementManager.MoveToCurrentFate(true);

                        await OracleFateManager.SyncLevel(fate);
                    }
                }
            }

            return(true);
        }