Exemple #1
0
        /// <summary>Sends the given Character on the given Path.</summary>
        /// <param name="chr">The Character to fly around.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>Whether the client was sent on its way.</returns>
        internal static bool TryFly(Character chr, NPC vendor, PathNode[] destinations)
        {
            IRealmClient client = chr.Client;

            if (vendor == null && chr.Role.IsStaff)
            {
                PathNode pathNode = destinations.LastOrDefault();
                if (pathNode == null)
                {
                    return(false);
                }
                chr.TeleportTo(pathNode);
                return(true);
            }

            if (vendor == null || !vendor.CheckVendorInteraction(chr))
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.NotAvailable);
            }
            else if (PreFlightCheatChecks(client, destinations) &&
                     PreFlightValidPathCheck(client, destinations) &&
                     (client.ActiveCharacter.GodMode || PreFlightMoneyCheck(client)))
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.Ok);
                chr.UpdatePvPState(false, true);
                FlyUnit(chr, true);
                return(true);
            }

            return(false);
        }
Exemple #2
0
        /// <summary>
        /// Check that the character has enough money to cover the cost of the flight(s).
        /// Also deducts the cost of the flight from the character.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <returns>An array of destination TaxiNodes.</returns>
        private static bool PreFlightMoneyCheck(IRealmClient client)
        {
            Character activeCharacter = client.ActiveCharacter;
            uint      amount          = 0;

            foreach (TaxiPath taxiPath in activeCharacter.TaxiPaths)
            {
                if (taxiPath != null)
                {
                    amount += taxiPath.Price;
                }
                else
                {
                    activeCharacter.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }
            }

            if (activeCharacter.Money < amount)
            {
                activeCharacter.TaxiPaths.Clear();
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InsufficientFunds);
                return(false);
            }

            client.ActiveCharacter.SubtractMoney(amount);
            client.ActiveCharacter.Achievements.CheckPossibleAchievementUpdates(
                AchievementCriteriaType.GoldSpentForTravelling, amount, 0U, null);
            client.ActiveCharacter.Achievements.CheckPossibleAchievementUpdates(
                AchievementCriteriaType.FlightPathsTaken, 1U, 0U, null);
            return(true);
        }
Exemple #3
0
        /// <summary>
        /// Check that the character has enough money to cover the cost of the flight(s).
        /// Also deducts the cost of the flight from the character.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <returns>An array of destination TaxiNodes.</returns>
        private static bool PreFlightMoneyCheck(IRealmClient client)
        {
            Character curChar = client.ActiveCharacter;

            uint totalCost = 0;

            foreach (TaxiPath tempPath in curChar.TaxiPaths)
            {
                if (tempPath != null)
                {
                    totalCost += tempPath.Price;
                }
                else
                {
                    curChar.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }
            }

            // Do we have enough cash-money?
            if (curChar.Money < totalCost)
            {
                curChar.TaxiPaths.Clear();
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InsufficientFunds);
                return(false);
            }
            // Charge for the flight
            client.ActiveCharacter.SubtractMoney(totalCost);
            client.ActiveCharacter.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.GoldSpentForTravelling, totalCost);
            client.ActiveCharacter.Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.FlightPathsTaken, 1);
            return(true);
        }
Exemple #4
0
        /// <summary>
        /// Sends the given Character on the given Path.
        /// </summary>
        /// <param name="chr">The Character to fly around.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>Whether the client was sent on its way.</returns>
        internal static bool TryFly(Character chr, NPC vendor, PathNode[] destinations)
        {
            var client = chr.Client;

            if (vendor == null && chr.Role.IsStaff)
            {
                var dest = destinations.LastOrDefault();
                if (dest != null)
                {
                    chr.TeleportTo(dest);
                    return(true);
                }
                return(false);
            }

            if (vendor == null || !vendor.CheckVendorInteraction(chr))
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.NotAvailable);
            }
            else if (PreFlightCheatChecks(client, destinations) &&
                     PreFlightValidPathCheck(client, destinations) &&
                     (client.ActiveCharacter.GodMode || PreFlightMoneyCheck(client)))
            {
                // All good, send an "All Good" reply to the client.
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.Ok);

                // PvP flag is auto-cleared when starting a taxi-flight
                chr.UpdatePvPState(false, true);

                FlyUnit(chr, true);
                return(true);
            }
            return(false);
        }
Exemple #5
0
        /// <summary>Sends the given Character on the given Path.</summary>
        /// <param name="chr">The Character to fly around.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>Whether the client was sent on its way.</returns>
        internal static bool TryFly(Character chr, NPC vendor, PathNode[] destinations)
        {
            IRealmClient client = chr.Client;

            if (vendor == null && chr.Role.IsStaff)
            {
                PathNode pathNode = ((IEnumerable <PathNode>)destinations).LastOrDefault <PathNode>();
                if (pathNode == null)
                {
                    return(false);
                }
                chr.TeleportTo((IWorldLocation)pathNode);
                return(true);
            }

            if (vendor == null || !vendor.CheckVendorInteraction(chr))
            {
                TaxiHandler.SendActivateTaxiReply((IPacketReceiver)client, TaxiActivateResponse.NotAvailable);
            }
            else if (TaxiMgr.PreFlightCheatChecks(client, destinations) &&
                     TaxiMgr.PreFlightValidPathCheck(client, destinations) &&
                     (client.ActiveCharacter.GodMode || TaxiMgr.PreFlightMoneyCheck(client)))
            {
                TaxiHandler.SendActivateTaxiReply((IPacketReceiver)client, TaxiActivateResponse.Ok);
                chr.UpdatePvPState(false, true);
                TaxiMgr.FlyUnit((Unit)chr, true);
                return(true);
            }

            return(false);
        }
Exemple #6
0
        /// <summary>Check various character states that disallow flights.</summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if flight allowed.</returns>
        private static bool PreFlightCheatChecks(IRealmClient client, PathNode[] destinations)
        {
            Character activeCharacter = client.ActiveCharacter;
            PathNode  destination     = destinations[0];

            if (destinations.Length < 2)
            {
                return(false);
            }
            if (activeCharacter.IsMounted)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerAlreadyMounted);
                return(false);
            }

            if (activeCharacter.ShapeshiftForm != ShapeshiftForm.Normal &&
                activeCharacter.ShapeshiftForm != ShapeshiftForm.BattleStance &&
                (activeCharacter.ShapeshiftForm != ShapeshiftForm.BerserkerStance &&
                 activeCharacter.ShapeshiftForm != ShapeshiftForm.DefensiveStance) &&
                activeCharacter.ShapeshiftForm != ShapeshiftForm.Shadow)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerShapeShifted);
                return(false);
            }

            if (activeCharacter.IsLoggingOut)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerShapeShifted);
                return(false);
            }

            if (!activeCharacter.CanMove)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerMoving);
                return(false);
            }

            if (activeCharacter.IsUsingSpell)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerBusy);
                return(false);
            }

            if (destination.MapId != activeCharacter.Map.Id)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.NoPathNearby);
                return(false);
            }

            if (activeCharacter.TradeWindow == null)
            {
                return(true);
            }
            TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerBusy);
            return(false);
        }
Exemple #7
0
        /// <summary>
        /// Check that a valid path exists between the destinations.
        /// Also sets the characters TaxiPaths queue with the sequence of valid
        /// paths to the final destination.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if a valid path exists.</returns>
        private static bool PreFlightValidPathCheck(IRealmClient client, PathNode[] destinations)
        {
            var curChar = client.ActiveCharacter;

            curChar.TaxiPaths.Clear();

            for (uint i = 0; i < (destinations.Length - 1); ++i)
            {
                TaxiPath path = destinations[i].GetPathTo(destinations[i + 1]);
                if (path == null)
                {
                    curChar.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }
                curChar.TaxiPaths.Enqueue(path);
            }
            return(true);
        }
Exemple #8
0
        /// <summary>
        /// Check that a valid path exists between the destinations.
        /// Also sets the characters TaxiPaths queue with the sequence of valid
        /// paths to the final destination.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if a valid path exists.</returns>
        private static bool PreFlightValidPathCheck(IRealmClient client, PathNode[] destinations)
        {
            Character activeCharacter = client.ActiveCharacter;

            activeCharacter.TaxiPaths.Clear();
            for (uint index = 0; (long)index < (long)(destinations.Length - 1); ++index)
            {
                TaxiPath pathTo = destinations[index].GetPathTo(destinations[index + 1U]);
                if (pathTo == null)
                {
                    activeCharacter.TaxiPaths.Clear();
                    TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.InvalidChoice);
                    return(false);
                }

                activeCharacter.TaxiPaths.Enqueue(pathTo);
            }

            return(true);
        }
Exemple #9
0
        /// <summary>
        /// Check various character states that disallow flights.
        /// </summary>
        /// <param name="client">The IRealmClient requesting the flight.</param>
        /// <param name="destinations">An array of destination TaxiNodes.</param>
        /// <returns>True if flight allowed.</returns>
        private static bool PreFlightCheatChecks(IRealmClient client, PathNode[] destinations)
        {
            var curChar    = client.ActiveCharacter;
            var sourceNode = destinations[0];             //[startNode, destination, destination, ...]

            if (destinations.Length < 2)
            {
                return(false);
            }

            // Cheat Checks
            // Cheat check -- can't fly while mounted
            if (curChar.IsMounted)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerAlreadyMounted);
                return(false);
            }

            // Cheat check -- can't fly shape-shifted
            if (!(curChar.ShapeshiftForm == ShapeshiftForm.Normal ||
                  curChar.ShapeshiftForm == ShapeshiftForm.BattleStance ||
                  curChar.ShapeshiftForm == ShapeshiftForm.BerserkerStance ||
                  curChar.ShapeshiftForm == ShapeshiftForm.DefensiveStance ||
                  curChar.ShapeshiftForm == ShapeshiftForm.Shadow))
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerShapeShifted);
                return(false);
            }

            // Cheat check -- can't fly while logging out
            if (curChar.IsLoggingOut)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerShapeShifted);
                return(false);
            }


            // Cheat check -- can't fly immobilized
            if (!curChar.CanMove)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerMoving);
                return(false);
            }


            // Cheat check -- can't fly while casting
            if (curChar.IsUsingSpell)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerBusy);
                return(false);
            }

            // Cheat check -- can't fly from a node across the continent
            if (sourceNode.MapId != curChar.Map.Id)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.NoPathNearby);
                return(false);
            }

            // Cheat check -- can't fly while trading
            if (curChar.TradeWindow != null)
            {
                TaxiHandler.SendActivateTaxiReply(client, TaxiActivateResponse.PlayerBusy);
                return(false);
            }
            return(true);
        }