Ejemplo n.º 1
0
        /// <summary>
        ///     Mounts or Dismounts according to the provided MOUNTSTRATEGYDELEGATE.
        ///     <para>
        ///         Notes:
        ///         <list type="bullet">
        ///             <item>
        ///                 <description>
        ///                     <para>
        ///                         * A "Dismount" will unmount, or cancel a 'mounted' shapeshift form.
        ///                         Examples of the latter include: Druid Flight Form, Druid Travel Form, Shaman Ghost Wolf, Worgen
        ///                         Running Wild.
        ///                     </para>
        ///                 </description>
        ///             </item>
        ///             <item>
        ///                 <description>
        ///                     <para> * Requests to "Mount" will only be honored if the area allows it.</para>
        ///                 </description>
        ///             </item>
        ///         </list>
        ///     </para>
        /// </summary>
        /// <returns></returns>
        /// <remarks>17Apr2013-03:11UTC chinajade</remarks>
        public static async Task <bool> ExecuteMountStrategy(MountStrategyType mountStrategy, NavType navType = NavType.Fly)
        {
            if (mountStrategy == MountStrategyType.None)
            {
                return(false);
            }

#pragma warning disable 618
            // Dismount needed?
            if (mountStrategy == MountStrategyType.Dismount ||
                mountStrategy == MountStrategyType.CancelShapeshift ||
                mountStrategy == MountStrategyType.DismountOrCancelShapeshift ||
                mountStrategy == MountStrategyType.Land)
            {
                if (!Me.Mounted)
                {
                    return(false);
                }

                if (mountStrategy != MountStrategyType.Land)
                {
                    return(await CommonCoroutines.LandAndDismount("Requested by QB"));
                }

                if (!Me.IsFlying)
                {
                    return(false);
                }

                return(await CommonCoroutines.LandAndDismount("Land requested by QB", false));
            }
#pragma warning restore 618

            if (mountStrategy == MountStrategyType.Mount && Mount.UseMount && Mount.CanMount())
            {
                if (Me.Mounted)
                {
                    // Check if we should switch mounts
                    if (navType == NavType.Fly)
                    {
                        if (Mount.Current.IsFlyingMount || !Flightor.IsFlyableArea())
                        {
                            return(false);
                        }

                        await CommonCoroutines.LandAndDismount("Switching to flying mount");
                    }
                    else
                    {
                        // If ground nav then any mount is fine.
                        return(false);
                    }
                }

                if (navType == NavType.Fly)
                {
                    if (!Flightor.CanFly)
                    {
                        return(false);
                    }

                    return(await CommonCoroutines.SummonFlyingMount());
                }

                return(await CommonCoroutines.SummonGroundMount());
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Mounts or Dismounts according to the provided MOUNTSTRATEGYDELEGATE.
        ///     <para>
        ///         Notes:
        ///         <list type="bullet">
        ///             <item>
        ///                 <description>
        ///                     <para>
        ///                         * A "CancelShapeshift" will cancel _any_ shapeshift form whether or not
        ///                         that form represents a 'mounted' form or not.
        ///                     </para>
        ///                 </description>
        ///             </item>
        ///             <item>
        ///                 <description>
        ///                     <para>
        ///                         * A "Dismount" will unmount, or cancel a 'mounted' shapeshift form.
        ///                         Examples of the latter include: Druid Flight Form, Druid Travel Form, Shaman Ghost Wolf, Worgen
        ///                         Running Wild.
        ///                     </para>
        ///                 </description>
        ///             </item>
        ///             <item>
        ///                 <description>
        ///                     <para> * Requests to "Mount" will only be honored if the area allows it.</para>
        ///                 </description>
        ///             </item>
        ///         </list>
        ///     </para>
        /// </summary>
        /// <returns></returns>
        /// <remarks>17Apr2013-03:11UTC chinajade</remarks>
        public static async Task <bool> ExecuteMountStrategy(MountStrategyType mountStrategy, NavType navType = NavType.Fly)
        {
            if (mountStrategy == MountStrategyType.None)
            {
                return(false);
            }

            // Cancel Shapeshift needed?
            if (((mountStrategy == MountStrategyType.CancelShapeshift) ||
                 (mountStrategy == MountStrategyType.DismountOrCancelShapeshift)) &&
                Me.IsShapeshifted())
            {
                if (WoWMovement.ActiveMover.IsFlying)
                {
                    return(await LandAndDismount());
                }
                TreeRoot.StatusText = "Canceling shapeshift form.";
                Lua.DoString("CancelShapeshiftForm()");
                return(true);
            }

            // Dismount needed?
            if (((mountStrategy == MountStrategyType.Dismount) ||
                 (mountStrategy == MountStrategyType.DismountOrCancelShapeshift)) &&
                Me.IsMounted())
            {
                if (WoWMovement.ActiveMover.IsFlying)
                {
                    return(await LandAndDismount());
                }
                if (Me.IsShapeshifted())
                {
                    TreeRoot.StatusText = "Canceling 'mounted' shapeshift form.";
                    Lua.DoString("CancelShapeshiftForm()");
                    return(true);
                }
                if (Me.IsMounted())
                {
                    TreeRoot.StatusText = "Dismounting";

                    // Mount.Dismount() uses the Flightor landing system, which sometimes get stuck
                    // a yard or two above the landing zone...
                    // So, we opt to dismount via LUA since we've controlled the landing ourselves.
                    Lua.DoString("Dismount()");
                    return(true);
                }
            }

            if ((mountStrategy == MountStrategyType.Mount) && Mount.UseMount)
            {
                // Flying and Ground mounts...
                if (!WoWMovement.ActiveMover.IsSwimming)
                {
                    // If flying mount is wanted, and we're not on flying mount...
                    if (navType == NavType.Fly && !Flightor.MountHelper.Mounted && Flightor.MountHelper.CanMount)
                    {
                        Flightor.MountHelper.MountUp();
                        return(true);
                    }
                    // Try ground mount...
                    // NB: Force mounting by specifying a large distance to destination...
                    if (!Me.Mounted && Mount.CanMount())
                    {
                        if (Mount.MountUp(() => true, () => WoWMovement.ActiveMover.Location.Add(1000.0, 1000.0, 1000.0)))
                        {
                            return(true);
                        }
                    }
                }
                else
                {
                    // Swimming mounts...
                    return(false);
                }
            }
            return(false);
        }