Exemple #1
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID == 0)             // Cancel
            {
                return;
            }
            if (m_Mobile.Deleted || m_Moongate.Deleted || m_Mobile.Map == null)
            {
                return;
            }

            var switches = info.Switches;

            if (switches.Length == 0)
            {
                return;
            }

            var switchID  = switches[0];
            var listIndex = switchID / 100;
            var listEntry = switchID % 100;

            if (listIndex < 0 || listIndex >= m_Lists.Length)
            {
                return;
            }

            var list = m_Lists[listIndex];

            if (listEntry < 0 || listEntry >= list.Entries.Length)
            {
                return;
            }

            var entry = list.Entries[listEntry];

            if (m_Mobile.Map == list.Map && m_Mobile.InRange(entry.Location, 1))
            {
                m_Mobile.SendLocalizedMessage(1019003);                 // You are already there.
                return;
            }
            if (m_Mobile.IsStaff())
            {
                //Staff can always use a gate!
            }
            else if (!m_Mobile.InRange(m_Moongate.GetWorldLocation(), 1) || m_Mobile.Map != m_Moongate.Map)
            {
                m_Mobile.SendLocalizedMessage(1019002);                 // You are too far away to use the gate.
                return;
            }
            else if (m_Mobile.Player && SpellHelper.RestrictRedTravel && m_Mobile.Murderer && list.Map != Map.Felucca && !Siege.SiegeShard)
            {
                m_Mobile.SendLocalizedMessage(1019004);                 // You are not allowed to travel there.
                return;
            }
            else if (Sigil.ExistsOn(m_Mobile) && list.Map != Faction.Facet)
            {
                m_Mobile.SendLocalizedMessage(1019004);                 // You are not allowed to travel there.
                return;
            }
            else if (m_Mobile.Criminal)
            {
                m_Mobile.SendLocalizedMessage(1005561, "", 0x22);                 // Thou'rt a criminal and cannot escape so easily.
                return;
            }
            else if (SpellHelper.CheckCombat(m_Mobile))
            {
                m_Mobile.SendLocalizedMessage(1005564, "", 0x22);                 // Wouldst thou flee during the heat of battle??
                return;
            }
            else if (m_Mobile.Spell != null)
            {
                m_Mobile.SendLocalizedMessage(1049616);                 // You are too busy to do that at the moment.
                return;
            }

            BaseCreature.TeleportPets(m_Mobile, entry.Location, list.Map);

            m_Mobile.Combatant = null;
            m_Mobile.Warmode   = false;
            m_Mobile.Hidden    = true;

            m_Mobile.MoveToWorld(entry.Location, list.Map);

            Effects.PlaySound(entry.Location, list.Map, 0x1FE);

            CityTradeSystem.OnPublicMoongateUsed(m_Mobile);
        }