예제 #1
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);
        }
예제 #2
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
        /// <summary>
        /// Checks which nodes are currently activated by the player and sends the results to the client.
        /// </summary>
        public static void TalkToFM(this NPC taxiVendor, Character chr)
        {
            if (!taxiVendor.CheckVendorInteraction(chr))
            {
                return;
            }
            PathNode vendorTaxiNode = taxiVendor.VendorTaxiNode;

            if (vendorTaxiNode == null)
            {
                return;
            }
            TaxiNodeMask taxiNodes = chr.TaxiNodes;

            if (!taxiNodes.IsActive(vendorTaxiNode))
            {
                if (chr.GodMode)
                {
                    chr.ActivateAllTaxiNodes();
                }
                else
                {
                    taxiNodes.Activate(vendorTaxiNode);
                    TaxiHandler.SendTaxiPathActivated(chr.Client);
                    TaxiHandler.SendTaxiPathUpdate((IPacketReceiver)chr.Client, taxiVendor.EntityId, true);
                    return;
                }
            }

            chr.OnInteract((WorldObject)taxiVendor);
            TaxiHandler.ShowTaxiList(chr, (IEntity)taxiVendor, vendorTaxiNode);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #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)
        {
            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);
        }
예제 #6
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);
        }
예제 #7
0
        protected override void Apply(WorldObject target, ref DamageAction[] actions)
        {
            Character character = target as Character;

            character.TaxiNodes.Activate((uint)this.Effect.MiscValue);
            TaxiHandler.SendTaxiPathActivated(character.Client);
            TaxiHandler.SendTaxiPathUpdate((IPacketReceiver)character.Client, this.Cast.CasterUnit.EntityId, true);
        }
예제 #8
0
        protected override void Apply(WorldObject target)
        {
            var chr = target as Character;

            chr.TaxiNodes.Activate((uint)Effect.MiscValue);
            TaxiHandler.SendTaxiPathActivated(chr.Client);
            TaxiHandler.SendTaxiPathUpdate(chr.Client, Cast.CasterUnit.EntityId, true);
        }
예제 #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)
        {
            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);
        }
예제 #10
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                Character target = trigger.Args.Target as Character;

                if (target == null)
                {
                    trigger.Reply("No one selected.");
                }
                else
                {
                    string str = trigger.Text.NextModifiers();
                    if (str.Contains("a"))
                    {
                        target.ActivateAllTaxiNodes();
                    }
                    Map      map;
                    PathNode node;
                    if (str.Contains("r"))
                    {
                        map = World.GetNonInstancedMap(
                            trigger.Text.NextEnum(MapId.End));
                        if (map == null)
                        {
                            trigger.Reply("Invalid Map.");
                            return;
                        }

                        node = map.FirstTaxiNode;
                    }
                    else
                    {
                        map  = target.Map;
                        node = TaxiMgr.GetNearestTaxiNode(target.Position);
                    }

                    if (node != null)
                    {
                        TaxiHandler.ShowTaxiList(target, node);
                    }
                    else
                    {
                        trigger.Reply("There are no Taxis available on this Map ({0})", (object)map.Name);
                    }
                }
            }
예제 #11
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);
        }
예제 #12
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);
        }
예제 #13
0
        /// <summary>
        /// Checks which nodes are currently activated by the player and sends the results to the client.
        /// </summary>
        public static void TalkToFM(this NPC taxiVendor, Character chr)
        {
            if (!taxiVendor.CheckVendorInteraction(chr))
            {
                return;
            }

            // Get the taxi node associated with this Taxi Vendor
            var curNode = taxiVendor.VendorTaxiNode;

            if (curNode == null)
            {
                return;
            }

            // If this taxi node is as yet unknown to the player, activate it for them.
            var nodeMask = chr.TaxiNodes;

            if (!nodeMask.IsActive(curNode))
            {
                if (chr.GodMode)
                {
                    chr.ActivateAllTaxiNodes();
                }
                else
                {
                    nodeMask.Activate(curNode);
                    TaxiHandler.SendTaxiPathActivated(chr.Client);
                    TaxiHandler.SendTaxiPathUpdate(chr.Client, taxiVendor.EntityId, true);

                    // apparently the blizz-like activity is to not send the taxi list until the next
                    // vendor interaction. So we'll ditch this taco stand.
                    return;
                }
            }

            chr.OnInteract(taxiVendor);

            // The character has previously activated this TaxiNode, send the known nodes list to the client
            TaxiHandler.ShowTaxiList(chr, taxiVendor, curNode);
        }
예제 #14
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);
        }
예제 #15
0
 public void AddNode(PathNode node)
 {
     this.m_nodes[node.Id] = node;
     TaxiHandler.SendTaxiPathActivated(this.m_owner.Client);
 }