Ejemplo n.º 1
0
    private void SeemStuckHandler()
    {
        if (DateTime.Now.Ticks / 10000000 - lastStuck.Ticks / 10000000 < 5 &&
            (currentState == discoverFlightMasterState || currentState == takeTaxiState))
        {
            stuckCount++;
            Logger.Log($"You're stuck ({stuckCount}/10)");

            if (stuckCount > 9)
            {
                if (currentState == discoverFlightMasterState)
                {
                    MovementManager.StopMove();
                    nearestFlightMaster.Disable("Unreachable");
                }
                if (currentState == takeTaxiState)
                {
                    MovementManager.StopMove();
                    from?.Disable("Unreachable");
                }
            }
        }
        else
        {
            stuckCount = 0;
        }

        lastStuck = DateTime.Now;
    }
    public static bool GoInteractwithFM(FlightMaster fm, bool openMapRequired = false)
    {
        if (GoToTask.ToPosition(fm.Position, 5f))
        {
            if (!Main.isLaunched ||
                !Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause ||
                ObjectManager.Me.Position.DistanceTo(fm.Position) > 10f)
            {
                return(false);
            }

            // We're in fight (possibly on mount)
            if (ObjectManager.Me.InCombatFlagOnly)
            {
                if (ObjectManager.Me.IsMounted)
                {
                    MountTask.DismountMount();
                }
                return(false);
            }

            // We have reached the FM
            if (ObjectManager.Me.IsMounted)
            {
                MountTask.DismountMount();
            }

            // Check if FM is here or dead
            WoWUnit nearbyFM = FindNearbyAliveFM(fm);
            if (nearbyFM == null)
            {
                fm.Disable("FlightMaster is absent or dead.");
                ResetFlags();
                return(false);
            }

            // Approach FM
            if (!GoToTask.ToPosition(nearbyFM.Position, 1f))
            {
                return(false);
            }

            Interact.InteractGameObject(ObjectManager.GetWoWUnitByEntry(fm.NPCId).First().GetBaseAddress);

            // Check if interaction successful
            if (!InteractWithFm(fm))
            {
                fm.Disable("Unable to interact with NPC");
                ResetFlags();
                return(false);
            }

            Usefuls.SelectGossipOption(GossipOptionsType.taxi);

            // Check if map open
            if (openMapRequired && !FmMapIsOpen(fm))
            {
                fm.Disable("Unable to open FM map");
                ResetFlags();
                return(false);
            }

            return(true);
        }
        // We haven't reach the FM yet
        return(false);
    }