Beispiel #1
0
        /// <summary>
        /// Returns all Nodes matching the arguments in the given trigger.
        /// </summary>
        /// <param name="trigger">[part of name|id]</param>
        /// <returns></returns>
        public static List <PathNode> GetNodes(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            string          s            = trigger.Text.NextWord();
            List <PathNode> pathNodeList = new List <PathNode>();
            uint            result;

            if (uint.TryParse(s, out result))
            {
                PathNode node = TaxiMgr.GetNode(result);
                if (node == null)
                {
                    trigger.Reply("Invalid Id: " + result);
                    return(pathNodeList);
                }

                pathNodeList.Add(node);
            }
            else if (s.Length > 0)
            {
                foreach (PathNode pathNode in TaxiMgr.PathNodesById)
                {
                    if (pathNode != null && pathNode.Name.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        pathNodeList.Add(pathNode);
                    }
                }
            }
            else
            {
                foreach (PathNode pathNode in TaxiMgr.PathNodesById)
                {
                    if (pathNode != null)
                    {
                        pathNodeList.Add(pathNode);
                    }
                }
            }

            if (pathNodeList.Count == 0)
            {
                if (s.Length > 0)
                {
                    trigger.Reply("Invalid Node-name: " + s);
                }
                else
                {
                    trigger.Reply("No Node.");
                }
            }

            return(pathNodeList);
        }
Beispiel #2
0
        /// <summary>
        /// Fly far away. (For taxi paths that include more than one stop.)
        /// </summary>
        public static void HandleTaxiActivateFar(IRealmClient client, RealmPacketIn packet)
        {
            EntityId id  = packet.ReadEntityId();
            uint     num = packet.ReadUInt32();

            PathNode[] destinations = new PathNode[num];
            for (int index = 0; (long)index < (long)num; ++index)
            {
                destinations[index] = TaxiMgr.PathNodesById.Get(packet.ReadUInt32());
            }
            NPC vendor = client.ActiveCharacter.Map.GetObject(id) as NPC;

            TaxiMgr.TryFly(client.ActiveCharacter, vendor, destinations);
        }
Beispiel #3
0
        /// <summary>Fly away</summary>
        public static void HandleTaxiActivate(IRealmClient client, RealmPacketIn packet)
        {
            EntityId id     = packet.ReadEntityId();
            uint     index1 = packet.ReadUInt32();
            uint     index2 = packet.ReadUInt32();
            NPC      vendor = client.ActiveCharacter.Map.GetObject(id) as NPC;

            PathNode[] destinations = new PathNode[2]
            {
                TaxiMgr.PathNodesById.Get(index1),
                TaxiMgr.PathNodesById.Get(index2)
            };
            TaxiMgr.TryFly(client.ActiveCharacter, vendor, destinations);
        }
Beispiel #4
0
        public static void HandleTaxiActivate(IRealmClient client, RealmPacketIn packet)
        {
            var vendorId = packet.ReadEntityId();
            var from     = packet.ReadUInt32();
            var to       = packet.ReadUInt32();

            var vendor = client.ActiveCharacter.Map.GetObject(vendorId) as NPC;

            var destinations = new PathNode[2];

            destinations[0] = TaxiMgr.PathNodesById.Get(from);
            destinations[1] = TaxiMgr.PathNodesById.Get(to);
            TaxiMgr.TryFly(client.ActiveCharacter, vendor, destinations);
        }
Beispiel #5
0
        /// <summary>
        /// Returns all Nodes matching the arguments in the given trigger.
        /// </summary>
        /// <param name="trigger">[part of name|id]</param>
        /// <returns></returns>
        public static List <PathNode> GetNodes(CmdTrigger <RealmServerCmdArgs> trigger)
        {
            var  name = trigger.Text.NextWord();
            var  list = new List <PathNode>();
            uint id;

            if (uint.TryParse(name, out id))
            {
                var node = TaxiMgr.GetNode(id);
                if (node == null)
                {
                    trigger.Reply("Invalid Id: " + id);
                    return(list);
                }
                list.Add(node);
            }
            else if (name.Length > 0)
            {
                foreach (var node in TaxiMgr.PathNodesById)
                {
                    if (node != null && node.Name.IndexOf(name, StringComparison.InvariantCultureIgnoreCase) >= 0)
                    {
                        list.Add(node);
                    }
                }
            }
            else
            {
                foreach (var node in TaxiMgr.PathNodesById)
                {
                    if (node != null)
                    {
                        list.Add(node);
                    }
                }
            }
            if (list.Count == 0)
            {
                if (name.Length > 0)
                {
                    trigger.Reply("Invalid Node-name: " + name);
                }
                else
                {
                    trigger.Reply("No Node.");
                }
            }
            return(list);
        }
Beispiel #6
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);
                    }
                }
            }
Beispiel #7
0
        public static void HandleTaxiActivateFar(IRealmClient client, RealmPacketIn packet)
        {
            var vendorId = packet.ReadEntityId();
            //var totalCost = packet.ReadUInt32(); // removed, 3.2.2
            var numNodes = packet.ReadUInt32();


            var destinations = new PathNode[numNodes];

            for (int i = 0; i < numNodes; ++i)
            {
                destinations[i] = TaxiMgr.PathNodesById.Get(packet.ReadUInt32());
            }

            var vendor = client.ActiveCharacter.Map.GetObject(vendorId) as NPC;

            TaxiMgr.TryFly(client.ActiveCharacter, vendor, destinations);
        }
Beispiel #8
0
 /// <summary>
 /// Asked by the client upon landing at each stop in a multinode trip
 /// </summary>
 public static void HandleNextTaxiDestination(IRealmClient client, RealmPacketIn packet)
 {
     TaxiMgr.ContinueFlight(client.ActiveCharacter);
 }
Beispiel #9
0
        /// <summary>
        /// Is called after Character has been added to a map the first time and
        /// before it receives the first Update packet
        /// </summary>
        internal protected void InitializeCharacter()
        {
            World.AddCharacter(this);
            m_initialized = true;

            try
            {
                Regenerates = true;
                ((PlayerSpellCollection)m_spells).PlayerInitialize();

                OnLogin();

                if (m_record.JustCreated)
                {
                    if (!m_client.Account.Role.IsStaff)
                    {
                        CharacterHandler.SendCinematic(this);
                    }
                    if (m_zone != null)
                    {
                        m_zone.EnterZone(this, null);
                    }

                    m_spells.AddDefaultSpells();
                    m_reputations.Initialize();

                    if (Class == ClassId.Warrior && Spells.Contains(SpellId.ClassSkillBattleStance))
                    {
                        CallDelayed(1000, obj => SpellCast.Start(SpellId.ClassSkillBattleStance, false));
                    }
                    else if (Class == ClassId.DeathKnight && Spells.Contains(SpellId.ClassSkillBloodPresence))
                    {
                        CallDelayed(1000, obj => SpellCast.Start(SpellId.ClassSkillBloodPresence, false));
                    }

                    // set initial weapon skill max values
                    Skills.UpdateSkillsForLevel(Level);
                }
                else
                {
                    LoadDeathState();
                    LoadEquipmentState();
                }

                // load items
#if DEV
                // do this check in case that we did not load Items yet
                if (ItemMgr.Loaded)
#endif
                InitItems();

                // load ticket information
                var ticket = TicketMgr.Instance.GetTicket(EntityId.Low);
                if (ticket != null)
                {
                    Ticket = ticket;
                    Ticket.OnOwnerLogin(this);
                }

                // initialize sub systems
                GroupMgr.Instance.OnCharacterLogin(this);
                GuildMgr.Instance.OnCharacterLogin(this);
                RelationMgr.Instance.OnCharacterLogin(this);

                // set login date
                LastLogin = DateTime.Now;
                var isNew = m_record.JustCreated;

                // perform some stuff ingame
                AddMessage(() =>
                {
                    if (LastLogout == null)
                    {
                        RealmCommandHandler.ExecFirstLoginFileFor(this);
                    }

                    RealmCommandHandler.ExecAllCharsFileFor(this);

                    if (Account.Role.IsStaff)
                    {
                        RealmCommandHandler.ExecFileFor(this);
                    }

                    Stunned--;

                    if (m_record.NextTaxiVertexId != 0)
                    {
                        // we are on a Taxi
                        var vertex = TaxiMgr.GetVertex(m_record.NextTaxiVertexId);
                        if (vertex != null &&
                            vertex.MapId == m_Map.Id &&
                            vertex.ListEntry.Next != null &&
                            IsInRadius(vertex.Pos, vertex.ListEntry.Next.Value.DistFromPrevious))
                        {
                            TaxiPaths.Enqueue(vertex.Path);
                            TaxiMgr.FlyUnit(this, true, vertex.ListEntry);
                        }
                        else
                        {
                            m_record.NextTaxiVertexId = 0;
                        }
                    }
                    else
                    {
                        // cannot stand up instantly because else no one will see the char sitting in the first place
                        StandState = StandState.Stand;
                    }
                    GodMode = m_record.GodMode;

                    if (isNew)
                    {
                        // newly created Char logs in the first time
                        var evt = Created;
                        if (evt != null)
                        {
                            evt(this);
                        }
                    }

                    //if (Role.IsStaff)
                    if (GodMode)
                    {
                        //Notify("Your GodMode is " + (GodMode ? "ON" : "OFF") + "!");
                        Notify(RealmLangKey.GodModeIsActivated);
                    }

                    var login = LoggedIn;
                    if (login != null)
                    {
                        login(this, true);
                    }
                });

                if (isNew)
                {
                    SaveLater();
                    m_record.JustCreated = false;
                }
                else
                {
                    RealmServer.IOQueue.AddMessage(() =>
                    {
                        try
                        {
                            m_record.Update();
                        }
                        catch (Exception ex)
                        {
                            SaveLater();
                            LogUtil.ErrorException(ex, "Failed to Update CharacterRecord: " + m_record);
                        }
                    });
                }
            }
            catch (Exception e)
            {
                if (m_record.JustCreated)
                {
                    m_record.CanSave = false;
                    m_record.Delete();
                }
                World.RemoveCharacter(this);
                LogUtil.ErrorException(e, "Failed to initialize Character: " + this);
                m_client.Disconnect();
            }
        }