Exemple #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            m_From.CloseGump(typeof(ShardTravelGump));
            int     id = info.ButtonID;
            Point3D p;
            Map     map;

            if (id < 100)
            {
                if (id == 2)
                {
                    m_From.SendGump(new ShardTravelGump(m_From, m_Page - 1, X, Y, m_TravelMap));
                }
                if (id == 3)
                {
                    m_From.SendGump(new ShardTravelGump(m_From, m_Page + 1, X, Y, m_TravelMap));
                }
                if (id == 4)
                {
                    m_From.SendGump(new ShardTravelGump(m_From, m_Page, X, Y, m_TravelMap));
                    m_From.SendGump(new MapTravelHelp(X, Y));
                }
            }
            else if (id < 10000)
            {
                m_From.SendGump(new ShardTravelGump(m_From, m_Page, X, Y, m_TravelMap, id));
            }
            else if (id < 20000)
            {
                // Here begins the teleport

                string message = "";

                try
                {
                    id -= 10000;
                    bool             NonGM = m_From.AccessLevel < AccessLevel.GameMaster;
                    ShardTravelEntry entry = m_TravelMap.GetEntry(id);
                    if (entry == null)
                    {
                        return;
                    }

                    p   = entry.Destination;
                    map = entry.Map;

                    if (NonGM && Factions.Sigil.ExistsOn(m_From))
                    {
                        m_From.SendLocalizedMessage(1061632); // You can't do that while carrying the sigil.
                    }
                    else if (NonGM && map == Map.Felucca && m_From is PlayerMobile && ((PlayerMobile)m_From).Young)
                    {
                        m_From.SendLocalizedMessage(1049543);
                        // You decide against traveling to Felucca while you are still young.
                    }
                    else if (NonGM && m_From.Kills >= 5 && map != Map.Felucca)
                    {
                        m_From.SendLocalizedMessage(1019004); // You are not allowed to travel there.
                    }
                    else if (NonGM && m_From.Criminal)
                    {
                        m_From.SendLocalizedMessage(1005561, "", 0x22);
                        // Thou'rt a criminal and cannot escape so easily.
                    }
                    else if (NonGM && SpellHelper.CheckCombat(m_From))
                    {
                        m_From.SendLocalizedMessage(1005564, "", 0x22); // Wouldst thou flee during the heat of battle??
                    }
                    else if (NonGM && Misc.WeightOverloading.IsOverloaded(m_From))
                    {
                        m_From.SendLocalizedMessage(502359, "", 0x22); // Thou art too encumbered to move.
                    }
                    else if (!map.CanSpawnMobile(p.X, p.Y, p.Z))
                    {
                        m_From.SendLocalizedMessage(501942); // That location is blocked.
                    }
                    else if (m_From.Holding != null)
                    {
                        m_From.SendLocalizedMessage(1071955); // You cannot teleport while dragging an object.
                    }
                    else if (entry.Unlocked || !NonGM)
                    {
                        if (NonGM && CHARGE)                         // Do not charge GMs - they might complain...
                        {
                            Container pack = m_From.Backpack;
                            if (pack == null || (pack.ConsumeTotal(payTypes, payAmounts) > 0))
                            {
                                if (pack == null)
                                {
                                    message = "Your pack is null???";
                                }
                                else
                                {
                                    message = string.Format("Using the map to teleport costs {0}.", PAYTHIS);
                                }
                                m_From.SendGump(new ShardTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
                                return;
                            }
                            // Payment was successful if we reach here ...
                        }
                        m_From.MoveToWorld(p, map);
                        message = string.Format("{0} have been moved to X:{1}, Y:{2}, Z:{3}, Map: {4}",
                                                CHARGE ? "You paid " + PAYTHIS + " and" : "You", p.X, p.Y, p.Z, map);
                    }
                }
                catch
                {
                    message = string.Format("Teleport failed.");
                }

                m_From.SendGump(new ShardTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
            }
            else if (id >= 30000 && id < 40000)
            {
                id -= 30000;

                ShardTravelEntry entry = m_TravelMap.GetEntry(id);
                if (entry == null)
                {
                    return;
                }

                p   = entry.Destination;
                map = entry.Map;

                string message = "";
                if (map != m_From.Map)
                {
                    message = "You must be on the same map to Explore there.";
                }
                else
                {
                    if (m_From.InRange(p, 7))
                    {
                        entry.Unlocked   = true;
                        entry.Discovered = true; // We do this in case a GM unlocked the location before it was discovered.
                        message          = string.Format("You have unlocked a new location: {0}.", entry.Name);
                    }
                    else
                    {
                        int distance = (int)m_From.GetDistanceToSqrt(p);
                        message = string.Format("That location is still approximately {0} paces to the {1}.",
                                                distance, MapTravelHelp.GetDirection(m_From, p));
                    }
                }
                m_From.SendGump(new ShardTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            m_From.CloseGump(typeof(TrammelTravelGump));
            int     id = info.ButtonID;
            Point3D p;
            Map     map;

            if (id < 100)
            {
                if (id == 2)
                {
                    m_From.SendGump(new TrammelTravelGump(m_From, m_Page - 1, X, Y, m_TravelMap));
                }
                if (id == 3)
                {
                    m_From.SendGump(new TrammelTravelGump(m_From, m_Page + 1, X, Y, m_TravelMap));
                }
                if (id == 4)
                {
                    m_From.SendGump(new TrammelTravelGump(m_From, m_Page, X, Y, m_TravelMap));
                    m_From.SendGump(new MapTravelHelp(X, Y));
                }
            }
            else if (id < 10000)
            {
                m_From.SendGump(new TrammelTravelGump(m_From, m_Page, X, Y, m_TravelMap, id));
            }
            else if (id < 20000)
            {
                // Here begins the teleport

                string message = "";

                try
                {
                    id -= 10000;
                    bool           NonGM = m_From.AccessLevel < AccessLevel.GameMaster;
                    MapTravelEntry entry = m_TravelMap.GetEntry(id);
                    if (entry == null)
                    {
                        return;
                    }

                    p   = entry.Destination;
                    map = entry.Map;

                    if (MapTravelHelp.CanTravel(m_From, map, p) && (entry.Unlocked || !NonGM) && m_TravelMap.Parent == m_From.Backpack)
                    {
                        if (NonGM && CHARGE) // Do not charge GMs - they might complain...
                        {
                            Container pack = m_From.Backpack;
                            if (pack == null || (pack.ConsumeTotal(payTypes, payAmounts) > 0))
                            {
                                if (pack == null)
                                {
                                    message = "Your pack is null???";
                                }
                                else
                                {
                                    message = string.Format("Using the map to teleport costs {0}.", PAYTHIS);
                                }
                                m_From.SendGump(new TrammelTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
                                return;
                            }
                            // Payment was successful if we reach here ...
                        }
                        m_From.MoveToWorld(p, map);
                        message = string.Format("{0} have been moved to X:{1}, Y:{2}, Z:{3}, Map: {4}",
                                                CHARGE ? "You paid " + PAYTHIS + " and" : "You", p.X, p.Y, p.Z, map);
                    }
                }
                catch
                {
                    message = string.Format("Teleport failed.");
                }

                m_From.SendGump(new TrammelTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
            }
            else if (id >= 30000 && id < 40000)
            {
                id -= 30000;

                MapTravelEntry entry = m_TravelMap.GetEntry(id);
                if (entry == null)
                {
                    return;
                }

                p   = entry.Destination;
                map = entry.Map;

                string message = "";
                if (map != m_From.Map)
                {
                    message = "You must be on the same map to Explore there.";
                }
                else
                {
                    if (m_From.InRange(p, 7))
                    {
                        entry.Unlocked   = true;
                        entry.Discovered = true; // We do this in case a GM unlocked the location before it was discovered.
                        message          = string.Format("You have unlocked a new location: {0}.", entry.Name);
                    }
                    else
                    {
                        int distance = (int)m_From.GetDistanceToSqrt(p);
                        message = string.Format("That location is still approximately {0} paces to the {1}.",
                                                distance, MapTravelHelp.GetDirection(m_From, p));
                    }
                }
                m_From.SendGump(new TrammelTravelGump(m_From, m_Page, X, Y, m_TravelMap, m_Detail, message));
            }
        }