Пример #1
0
        public bool AutoConsume(PlayerMobile m)
        {
            if (m == null || m.Deleted)
            {
                return(false);
            }

            if (TitleHue == null)
            {
                m.SendMessage(0x22, "This ancient scroll has lost whatever power it once had.");
                m.PrivateOverheadMessage(MessageType.Label, 1287, true, "*The scroll disintegrates in your hands*", m.NetState);

                LoggingCustom.Log("HueScrollsInvalid.txt", String.Format("{0} -> {1} ({2})", m, this, TitleHue));

                Delete();

                return(false);
            }

            if (!CanConsume(m, false))
            {
                return(false);
            }

            TitleProfile p = CustomTitles.EnsureProfile(m);

            if (p == null)
            {
                return(false);
            }

            GrantHue(m, p);
            return(true);
        }
Пример #2
0
            public DonationItemsGump(int set, Mobile player) : base(50, 200)
            {
                try
                {
                    m_Player = player;

                    switch (set)
                    {
                    case 1:
                        m_Set = DonationItemDeeds;
                        break;

                    case 2:
                        m_Set = DonationItemEthereal;
                        break;

                    case 3:
                        m_Set = DonationItemWears;
                        break;

                    default:
                        m_Set = new DonationItemEntry[0];
                        break;
                    }
                    LoadMe();
                }
                catch (Exception e)
                {
                    LoggingCustom.Log("ERROR_DonationVendor", "Mobile: " + player + "Error with donation vendor: " + e.Message + "\n" + e.StackTrace);
                }
            }
Пример #3
0
        private static void OnSocketConnect(SocketConnectEventArgs e)
        {
            try
            {
                IPAddress ip = ((IPEndPoint)e.Socket.RemoteEndPoint).Address;

                if (Firewall.IsBlocked(ip))
                {
                    Console.WriteLine("Client: {0}: Firewall blocked connection attempt.", ip);
                    e.AllowConnection = false;
                    return;
                }

                if (!IPLimiter.SocketBlock || IPLimiter.Verify(ip))
                {
                    return;
                }

                LoggingCustom.Log(
                    "LOG_IPLimits.log",
                    String.Format("{0}\tPast IP limit threshold\t{1}", ip, DateTime.Now.ToSimpleString("t d-m-y N")));

                Console.WriteLine("Client: {0}: Past IP limit threshold", ip);

                e.AllowConnection = false;
            }
            catch
            {
                e.AllowConnection = false;
            }
        }
Пример #4
0
        public static void Enqueue(PageEntry entry)
        {
            if (entry.Sender is PlayerMobile)
            {
                LoggingCustom.Log("LOG_Pages.txt",
                                  DateTime.Now + "\t" + entry.Sender + "\t" +
                                  (entry.Sender != null ? entry.Sender.Account.ToString() : "") + "\t" + entry.Message);
            }
            m_List.Add(entry);
            m_KeyedBySender[entry.Sender] = entry;

            //bool isStaffOnline = false;

            foreach (NetState ns in NetState.Instances)
            {
                Mobile m = ns.Mobile;

                if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && !IsHandling(m))
                {
                    m.SendMessage("A new page has been placed in the queue.");
                }

                //if ( m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify && m.LastMoveTime >= (DateTime.UtcNow - TimeSpan.FromMinutes( 10.0 )) )
                //isStaffOnline = true;
            }

            // if ( !isStaffOnline )
            //		entry.Sender.SendMessage( "We are sorry, but no staff members are currently available to assist you.  Your page will remain in the queue until one becomes available, or until you cancel it manually." );

            //if ( Email.SpeechLogPageAddresses != null && entry.SpeechLog != null )
            //	SendEmail( entry );
        }
Пример #5
0
 private static void ToLog(Mobile m, string speech, bool jailed, bool banned)
 {
     if (m != null && !m.Deleted && !String.IsNullOrWhiteSpace(speech) && CMOptions.LogEnabled)
     {
         LoggingCustom.Log(
             "DetectedAdvertisers.log",
             String.Format("[{0}]: {1}", ServerTime.ShortDateTimeNow, GetDetectedString(m, speech, jailed, banned)));
     }
 }
Пример #6
0
        private void OnCounteroffer()
        {
            if (_CounterOffer <= 0)
            {
                User.SendMessage("Counteroffer amount must be more than nothing!");
                Refresh(true);
                return;
            }

            if (_CounterOffer > MurderSystemController._HeadRansomCap)
            {
                _CounterOffer = MurderSystemController._HeadRansomCap;

                User.SendMessage(
                    "There is a cap of {0:#,0} for the counteroffer! Please enter a lower number.",
                    MurderSystemController._HeadRansomCap);
                Refresh(true);
                return;
            }

            Type cType = Head.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

            // We don't REALLY want to tell the killer that the victim has no gold
            // It should be handled by the offer gump where they are forced to accept/decline/counter.

            /*
             * int bal = Banker.GetBalance(_Victim, cType);
             *
             * if (bal < _CounterOffer)
             * {
             *      _CounterOffer = bal;
             *
             *      User.SendMessage("They cannot afford this amount!  Please make a new counteroffer.");
             *      Refresh(true);
             *      return;
             * }
             */

            new VictimReceiveOfferGump(_Victim, User, Head, _CounterOffer, _ReplyMessage).Send();
            User.SendMessage("Your counteroffer demand has been sent to {0}!", _Victim.RawName);

            LoggingCustom.Log(
                "MurdererNegotiate.txt",
                String.Format(
                    "[Killer -> Victim][COUNTER][{0}]:\t[{1} -> {2}]\t[{3}]\t[{4:#,0} {5}]\t\"{6}\"",
                    ServerTime.ShortDateTimeNow,
                    User,
                    _Victim,
                    Head,
                    _CounterOffer,
                    cType.Name,
                    _ReplyMessage));
        }
Пример #7
0
 public void LogIPAccess(IPAddress ipAddress, bool loggedOut)
 {
     LoggingCustom.Log(
         String.Format("Login/{0}.log", IOUtility.GetSafeFileName(Username)),
         "Time DD-MM-YYYY\tUsername\tAddress\tOnline",
         String.Format(
             "{0}\t{1}\t{2}\t{3}",
             DateTime.Now.ToSimpleString("t Z d-m-y"),
             Username,
             loggedOut ? String.Empty : ipAddress.ToString(),
             loggedOut ? "off" : "on"));
 }
Пример #8
0
        public override void OnDoubleClick(Mobile m)
        {
            if (!this.CheckDoubleClick(m, true, false, 2, true) || !(m is PlayerMobile))
            {
                return;
            }

            if (TitleHue == null)
            {
                m.SendMessage(0x22, "This ancient scroll has lost whatever power it once had.");
                m.PrivateOverheadMessage(MessageType.Label, 1287, true, "*The scroll disintegrates in your hands*", m.NetState);

                LoggingCustom.Log("HueScrollsInvalid.txt", String.Format("{0} -> {1} ({2})", m, this, TitleHue));

                Delete();

                return;
            }

            if (!CanConsume((PlayerMobile)m, true))
            {
                return;
            }

            var pm = (PlayerMobile)m;

            TitleProfile p = CustomTitles.EnsureProfile(pm);

            if (p == null)
            {
                return;
            }

            if (_Gump != null)
            {
                _Gump.Close(true);
                _Gump = null;
            }

            _Gump = SuperGump.Send(
                new ScrollConfirmGump(
                    pm,
                    null,
                    TitleHue,
                    b => GrantHue(pm, p),
                    b =>
            {
                pm.SendMessage(0x55, "You choose to not use the title hue scroll.");
                _Gump = null;
            }));
        }
Пример #9
0
        private void OnCounteroffer()
        {
            if (_CounterOffer <= 0)
            {
                User.SendMessage("Counteroffer amount must be more than nothing!");
                Refresh(true);
                return;
            }

            if (_CounterOffer > MurderSystemController._HeadRansomCap)
            {
                _CounterOffer = MurderSystemController._HeadRansomCap;

                User.SendMessage(
                    "There is a cap of {0:#,0} for the counteroffer! Please enter a lower number.",
                    MurderSystemController._HeadRansomCap);
                Refresh(true);
                return;
            }

            Type cType = Head.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

            int bal = Banker.GetBalance(User, cType);

            if (bal < _CounterOffer)
            {
                _CounterOffer = bal;

                User.SendMessage("You cannot afford this amount!  Please make a new counteroffer.");
                Refresh(true);
                return;
            }

            new KillerReceiveOfferGump(_Killer, User, Head, _CounterOffer, _ReplyMessage).Send();
            User.SendMessage("Your counteroffer request has been sent to {0}!", _Killer.RawName);

            LoggingCustom.Log(
                "MurdererNegotiate.txt",
                String.Format(
                    "[Victim -> Killer][COUNTER][{0}]:\t[{1} -> {2}]\t[{3}]\t[{4:#,0} {5}]\t\"{6}\"",
                    ServerTime.ShortDateTimeNow,
                    User,
                    _Killer,
                    Head,
                    _CounterOffer,
                    cType.Name,
                    _ReplyMessage));
        }
Пример #10
0
        private static void YoungPlayersList_OnCommand(CommandEventArgs e)
        {
            if (e.Mobile.Criminal)
            {
                e.Mobile.SendMessage("You can't use this command while you are a criminal!");
                return;
            }

            foreach (AggressorInfo aggressor in e.Mobile.Aggressors)
            {
                if (aggressor.Attacker is PlayerMobile)
                {
                    e.Mobile.SendMessage("You can't use that command while you are in combat!");
                    return;
                }
            }
            foreach (AggressorInfo aggressed in e.Mobile.Aggressed)
            {
                if (aggressed.Defender is PlayerMobile)
                {
                    e.Mobile.SendMessage("You can't use that command while you are in combat!");
                    return;
                }
            }
            //if (e.Mobile.Aggressors.Count > 0 || e.Mobile.Aggressed.Count > 0)

            if (e.Mobile is PlayerMobile && ((PlayerMobile)e.Mobile).Companion)
            {
                try
                {
                    if (!PlayerMobile.OnlineCompanions.Contains((PlayerMobile)e.Mobile))
                    {
                        PlayerMobile.OnlineCompanions.Add((PlayerMobile)e.Mobile);
                        UberScriptFunctions.Methods.LOCALMSG(null, e.Mobile, "You have signed on as a companion and will now receive young player notifications (log-out will sign you off).", 38);
                        LoggingCustom.Log(Path.Combine(new string[] { CompanionListGump.LogFileLocation, e.Mobile.RawName + ".txt" }), DateTime.Now + "\t" + "Signed on as Companion");
                    }
                }
                catch { }

                e.Mobile.SendGump(new CompanionListGump(e.Mobile));
            }
            else
            {
                e.Mobile.SendMessage("You must be a companion to have access to that command!");
            }
        }
Пример #11
0
        private static void EventSink_Speech(SpeechEventArgs args)
        {
            Mobile m = args.Mobile;

            if (m == null)
            {
                return;
            }

            DateTime now = DateTime.Now;

            // check for logging (pseudoseer or counselor)
            if (m.AccessLevel == AccessLevel.Counselor)
            {
                LoggingCustom.LogCounselor(now + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (m.Account != null && PseudoSeerStone.Instance != null &&
                PseudoSeerStone.Instance.PseudoSeers.ContainsKey(m.Account))
            {
                LoggingCustom.LogPseudoseer(now + "\t" + m.Account + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (m is PlayerMobile && ((PlayerMobile)m).Companion)
            {
                LoggingCustom.Log(
                    Path.Combine(new[] { CompanionListGump.LogFileLocation, m.Name + ".txt" }),
                    now + "\t" + m.Name + ":\t" + args.Speech);
                LoggingCustom.LogCompanion(now + "\t" + m.Name + ":\t" + args.Speech);
            }

            if (!args.Blocked)             // might turn it to true if return override encountered
            {
                if (XmlScript.HasTrigger(m, TriggerName.onSay))
                {
                    args.Blocked = Trigger(m, m, TriggerName.onSay, null, args.Speech);
                }
                args.Handled = args.Blocked;
            }
            else if (XmlScript.HasTrigger(m, TriggerName.onSay))
            {
                Trigger(m, m, TriggerName.onSay, null, args.Speech);
            }
        }
Пример #12
0
        private void OnDecline()
        {
            User.SendMessage("You decide not to negotiate with {0}.", _Victim.RawName);
            _Victim.SendMessage("{0} has declined your offer.", User.RawName);

            Type cType = Head.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

            LoggingCustom.Log(
                "MurdererNegotiate.txt",
                String.Format(
                    "[Killer -> Victim][DECLINED][{0}]:\t[{1} -> {2}]\t[{3}]\t[{4:#,0} {5}]\t\"{6}\"",
                    ServerTime.ShortDateTimeNow,
                    User,
                    _Victim,
                    Head,
                    _Offer,
                    cType.Name,
                    _Message));
        }
Пример #13
0
        public static void StatLossDecay(Mobile mob)
        {
            var pm = mob as PlayerMobile;

            if (pm == null || pm.StatEnd == DateTime.MinValue)
            {
                return;                 // quick check for not previously in stat loss
            }

            if (pm.InStat)
            {
                ApplySkillLoss(pm);
            }
            else
            {
                pm.StatEnd = DateTime.MinValue;
                ClearSkillLoss(pm);
                LoggingCustom.Log("MurdererNegotiate.txt", DateTime.Now + "\t" + pm + "\t" + "Finished Statloss");
            }
        }
Пример #14
0
        protected override void OnTick()
        {
            if (PseudoSeerStone.Instance == null)
            {
                return;
            }

            List <Mobile> list = PseudoSeersControlGump.PseudoseerControlledMobiles();

            foreach (Mobile mob in list)
            {
                if (mob is BaseCreature)
                {
                    try
                    {
                        LoggingCustom.Log("LOG_PseudoseerMobs.txt", DateTime.UtcNow + "\t" + mob + "\t" + mob.Account + "\t" + mob.Region.Name + "\t" + mob.Location);
                    }
                    catch {}
                }
            }
        }
Пример #15
0
        public static void Initialize()
        {
            try
            {
                string filePath = Core.FindDataFile("gumpidx.mul");

                if (File.Exists(filePath))
                {
                    using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        BinaryReader bin = new BinaryReader(fs);
                        // http://wpdev.sourceforge.net/docs/formats/csharp/index.html
                        //To find data for a certain entry, you seek to (EntryID * 12), and read the data.
                        //Then, in the actual MUL file (not the index file), you seek to (lookup), and read (length) number of bytes.
                        //Some data relies on the extra field.
                        long test     = fs.Length - 1;
                        long position = 0;
                        while (position < test)
                        {
                            int lookup = bin.ReadInt32();
                            int length = bin.ReadInt32();
                            int extra  = bin.ReadInt32();
                            position += 12;
                            short width  = (short)((extra >> 16) & 0xFFFF);
                            short height = (short)(extra & 0xFFFF);
                            ParsedGumpData.Add(new GumpData(width, height));
                            //Console.WriteLine(width + " " + height);
                            //LoggingCustom.Log("ERROR_GumpIndexParser.txt", width + " " + height);
                        }

                        fs.Close();
                    }
                }
            }
            catch (Exception e)
            {
                LoggingCustom.Log("ERROR_GumpIndexParser.txt", DateTime.Now + "\t" + e.Message + "\n" + e.StackTrace);
            }
        }
Пример #16
0
        private void GrantHue(PlayerMobile pm, TitleProfile p)
        {
            if (TitleHue == null || pm == null || p == null)
            {
                return;
            }

            if (p.Contains(TitleHue))
            {
                pm.SendMessage(0x22, "You already own this title hue.");
                return;
            }

            p.Add(TitleHue);

            pm.PrivateOverheadMessage(
                MessageType.Label, 1287, true, "*The scroll crumbles in your hands as you absorb its power*", pm.NetState);

            LoggingCustom.Log("HueScrollsUsed.txt", String.Format("{0} -> {1} ({2})", pm, this, TitleHue));

            Delete();
        }
Пример #17
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                Mobile from = sender.Mobile;

                try
                {
                    switch (info.ButtonID)
                    {
                    case 1:
                        from.CloseGump(typeof(DonationVendorGump));
                        from.SendGump(new DonationItemsGump(1, m_Player));
                        break;

                    case 2:
                        from.CloseGump(typeof(DonationVendorGump));
                        from.SendGump(new DonationItemsGump(2, m_Player));
                        break;

                    case 3:
                        from.CloseGump(typeof(DonationVendorGump));
                        from.SendGump(new DonationItemsGump(3, m_Player));
                        break;

                    case 4:
                        from.CloseGump(typeof(DonationVendorGump));
                        from.SendGump(new DonationItemsGump(4, m_Player));
                        break;

                    default:
                        from.SendMessage("You Decide not to purchase at this time");
                        break;
                    }
                }
                catch (Exception e)
                {
                    LoggingCustom.Log("ERROR_DonationVendor", "Mobile: " + sender.Mobile + "Error with donation vendor: " + e.Message + "\n" + e.StackTrace);
                }
            }
Пример #18
0
        public static Rectangle2D GetRandomRectangle()
        {
            if (WeightedLocations.Count == 0)
            {
                LoggingCustom.Log(
                    "ERROR-RandomLocations.txt", "WeightedLocations.Count == 0: resorting to default rectangle (5, 5, 5, 5)");
                return(new Rectangle2D(5, 5, 5, 5));                // default rectangle just in case
            }

            int roll = Utility.Random(TotalWeighting);

            foreach (WeightedLocation loc in WeightedLocations)
            {
                roll -= loc.Weighting;

                if (roll < 0)
                {
                    return(loc.Rectangle);
                }
            }

            return(WeightedLocations[WeightedLocations.Count - 1].Rectangle);
        }
Пример #19
0
        public void SendCompanionTo(Mobile companion, Mobile youngPlayer)
        {
            if (youngPlayer.Map == Map.Internal)
            {
                return;
            }
            if (youngPlayer.Alive)
            {
                companion.Frozen = true;
            }
            else // dead young player
            {
                youngPlayer.LocalOverheadMessage(MessageType.Regular, 0x38, false, "Since you are a young player and died, a companion has volunteered to assist you!");
            }

            pets = GetNearbyPets(companion);

            companion.Hidden = true;
            companion.MoveToWorld(youngPlayer.Location, youngPlayer.Map);

            foreach (BaseCreature pet in pets)
            {
                if (pet.ControlOrder == OrderType.Guard || pet.ControlOrder == OrderType.Follow || pet.ControlOrder == OrderType.Come)
                {
                    pet.Hidden = true;
                    pet.Frozen = true;
                    pet.MoveToWorld(youngPlayer.Location, youngPlayer.Map);
                }
            }

            HideEffects(companion);
            if (youngPlayer is PlayerMobile)
            {
                ((PlayerMobile)youngPlayer).LastHelped = DateTime.UtcNow;
            }
            LoggingCustom.Log(Path.Combine(new string[] { LogFileLocation, companion.Name + ".txt" }), DateTime.Now + "\t" + companion.Name + "\thelping\t" + youngPlayer + "\t" + youngPlayer.Account + "\t" + youngPlayer.Location + "\t" + youngPlayer.Region);
        }
Пример #20
0
        public static void PlayerDonationCoin_OnCommand(CommandEventArgs e)
        {
            long DonationCoincount;

            if (e.Length > 0 && e.Arguments[0].ToLower() == "target")
            {
                e.Mobile.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(PlayerDonationCoinTarget));
            }
            else
            {
                DonationCoincount = DonationCoinOnPlayers(e.Mobile);
                e.Mobile.SendMessage("There is {0} DonationCoin owned by players.", DonationCoincount);
            }

            LoggingCustom.Log("LOG_PlayerDonationCoin.txt", "======================== " + DateTime.Now + " =====================");
            StringBuilder sb = new StringBuilder();

            foreach (PlayerResourceAmount playerResource in PlayerResourceAmount.ProcessedPlayers)
            {
                sb.Append(playerResource.Player + "\t" + playerResource.Owned + "\n");
            }
            LoggingCustom.Log("LOG_PlayerDonationCoin.txt", sb.ToString());
            PlayerResourceAmount.ProcessedPlayers = new List <PlayerResourceAmount>();
        }
Пример #21
0
            public override void OnResponse(NetState sender, RelayInfo info)
            {
                Mobile from = sender.Mobile;

                try
                {
                    if (info.ButtonID >= 300)
                    {
                        int         pr   = m_Set[info.ButtonID - 300].Price;
                        int         amnt = 0;
                        List <Item> dd   = new List <Item>();

                        for (int i = 0; i < from.BankBox.Items.Count; i++)
                        {
                            if (from.BankBox.Items[i] is DonationCoin)
                            {
                                amnt += from.BankBox.Items[i].Amount;
                                dd.Add(from.BankBox.Items[i]);
                            }
                        }

                        if (dd.Count == 0)
                        {
                            from.SendMessage("You don't have any Donation Coins!");
                        }
                        else if (dd.Count > 0)
                        {
                            if (pr > amnt)
                            {
                                from.SendMessage("You cannot afford that!");
                            }
                            else
                            {
                                for (int i = 0; i < dd.Count; i++)
                                {
                                    if (dd[i].Amount < pr)
                                    {
                                        pr -= dd[i].Amount;
                                        dd[i].Consume(dd[i].Amount);
                                    }
                                    else
                                    {
                                        dd[i].Consume(pr);
                                        pr = 0;
                                    }
                                }

                                Item d = Activator.CreateInstance(m_Set[info.ButtonID - 300].Type) as Item;

                                if (d is Spellbook)
                                {
                                    d.LootType = LootType.Newbied;
                                }
                                else if (!(d is BaseContainer))
                                {
                                    d.LootType = LootType.Blessed;
                                }
                                BankBox bank = from.BankBox;
                                from.SendMessage("The item has been placed in your bank and the Donation Coins was deducted from your bank account.");
                                bank.DropItem(d);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    from.SendMessage("Invalid Option Selected.");
                    LoggingCustom.Log("ERROR_DonationVendor", "Error with donation vendor: " + e.Message + "\n" + e.StackTrace);
                }
            }
Пример #22
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            if (info.ButtonID != 1 || m_House.Deleted)
            {
                return;
            }

            if (m_House.IsOwner(m_Mobile))
            {
                if (m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0)
                {
                    return;
                }

                if (!Guild.NewGuildSystem && m_House.FindGuildstone() != null)
                {
                    m_Mobile.SendLocalizedMessage(501389);                     // You cannot redeed a house with a guildstone inside.
                    return;
                }

                /*
                 * if ( m_House.PlayerVendors.Count > 0 )
                 * {
                 *      m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
                 *      return;
                 * }
                 */
                if (m_House.HasRentedVendors && m_House.VendorInventories.Count > 0)
                {
                    m_Mobile.SendLocalizedMessage(1062679);
                    // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
                    return;
                }

                if (m_House.HasRentedVendors)
                {
                    m_Mobile.SendLocalizedMessage(1062680);
                    // You cannot do that that while you still have contract vendors in your house.
                    return;
                }

                if (m_House.VendorInventories.Count > 0)
                {
                    m_Mobile.SendLocalizedMessage(1062681);
                    // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
                    return;
                }

                if (m_Mobile.AccessLevel >= AccessLevel.GameMaster)
                {
                    m_Mobile.SendMessage("You do not get a refund for your house as you are not a player");
                    m_House.RemoveKeys(m_Mobile);
                    m_House.Delete();
                }
                else
                {
                    Item toGive = m_House.GetDeed();

                    if (toGive == null && m_House.Price > 0)
                    {
                        toGive = new BankCheck(m_House.Price);
                    }

                    if (toGive != null)
                    {
                        BankBox box = m_Mobile.FindBank(m_House.Expansion) ?? m_Mobile.BankBox;

                        if (box != null)
                        {
                            box.AddItem(toGive);

                            if (toGive is BankCheck)
                            {
                                m_Mobile.LocalOverheadMessage(
                                    MessageType.Regular,
                                    0x38,
                                    false,
                                    "A check for " + ((BankCheck)toGive).Worth + " gold has been placed in your bank.");
                            }
                            else                             // it's a deed
                            {
                                m_Mobile.LocalOverheadMessage(MessageType.Regular, 0x38, false, "A deed has been placed in your bank.");
                            }
                        }
                        else if (m_Mobile.Backpack != null)
                        {
                            m_Mobile.Backpack.AddItem(toGive);
                            m_Mobile.SendMessage(
                                38,
                                "The house deed was placed IN YOUR BACKPACK because there was an error accessing your bank. Contact staff asap!");
                        }
                        else
                        {
                            LoggingCustom.Log("ERROR_HouseDemolish.txt", DateTime.Now + "\t" + m_Mobile + "\t" + m_House);
                        }
                        m_House.RemoveKeys(m_Mobile);
                        m_House.Delete();
                    }
                    else
                    {
                        m_Mobile.SendMessage("Unable to refund house.");
                    }
                }
            }
            else
            {
                m_Mobile.SendLocalizedMessage(501320);                 // Only the house owner may do this.
            }
        }
Пример #23
0
 public static void ConvertSkillScrollOperation(Item scroll, SkillName skillname)
 {
     try
     {
         var convertedScroll = new SkillScroll(1);
         convertedScroll.SkillName = skillname;
         if (scroll.Parent != null)
         {
             if (scroll.Parent is Container)
             {
                 var scrollParent = (Container)scroll.Parent;
                 scrollParent.AddItem(convertedScroll);
                 convertedScroll.X = scroll.X;
                 convertedScroll.Y = scroll.Y;
                 convertedScroll.Z = scroll.Z;
                 if (scroll.IsLockedDown)
                 {
                     BaseHouse house = BaseHouse.FindHouseAt(scroll.RootParentEntity as Item);
                     if (house == null)
                     {
                         LoggingCustom.Log("LOG_ScrollFail.txt",
                                           scroll + "\t" + skillname + "\t" + scroll.Location + "\tHOUSE WAS NULL!");
                     }
                     else
                     {
                         house.Release(house.Owner, scroll);
                         house.LockDown(house.Owner, convertedScroll);
                         LoggingCustom.Log("LOG_ScrollFail.txt",
                                           scroll + "\t" + skillname + "\t" + scroll.Location + "\tLOCKED DOWN IN CONTAINER");
                     }
                 }
                 if (scroll.RootParentEntity is PlayerVendor)
                 {
                     var pv = scroll.RootParentEntity as PlayerVendor;
                     if (pv.Owner != null)
                     {
                         pv.Owner.BankBox.AddItem(convertedScroll);
                         LoggingCustom.Log("LOG_ScrollVendor.txt",
                                           scroll + "\t" + skillname + "\t" + scroll.Location + "\t" + scroll.RootParentEntity);
                     }
                 }
                 scroll.Delete();
             }
             else
             {
                 LoggingCustom.Log("LOG_ScrollFail.txt", scroll + "\t" + skillname + "\t" + scroll.Location);
             }
             if (scroll.RootParentEntity != null)
             {
                 LoggingCustom.Log("LOG_ScrollConvert.txt",
                                   skillname + "\towner: " + scroll.RootParentEntity + "\t" + scroll.RootParentEntity.Location);
             }
         }
         else if (scroll.Map == Map.Felucca)
         {
             LoggingCustom.Log("LOG_ScrollConvert.txt", skillname + "\towner: null\t" + scroll.Location);
             convertedScroll.MoveToWorld(scroll.Location, scroll.Map);
             if (scroll.IsLockedDown)
             {
                 BaseHouse house = BaseHouse.FindHouseAt(scroll);
                 house.Release(house.Owner, scroll);
                 house.LockDown(house.Owner, convertedScroll);
                 LoggingCustom.Log("LOG_ScrollFail.txt",
                                   scroll + "\t" + skillname + "\t" + scroll.Location + "\tlockdown on house floor");
             }
             scroll.Delete();
         }
         else
         {
             LoggingCustom.Log("LOG_ScrollFail.txt", scroll + "\t" + skillname + "\t" + scroll.Location);
         }
     }
     catch (Exception e)
     {
         LoggingCustom.Log("LOG_ScrollFail.txt", e.Message + "\n" + e.StackTrace);
     }
 }
Пример #24
0
        public override bool OnDragDrop(Mobile from, Item dropped)
        {
            // trigger returns true if returnoverride
            if (XmlScript.HasTrigger(this, TriggerName.onDragDrop) &&
                UberScriptTriggers.Trigger(this, from, TriggerName.onDragDrop, dropped))
            {
                return(true);
            }

            bool bReturn = false;

            if (dropped is Head2)
            {
                var h = (Head2)dropped;

                if (h.Player == null || h.Player.Deleted)
                {
                    Say("This belonged to a nobody!");
                    h.Delete();
                    return(true);
                }

                if (h.Player != null)
                {
                    Mobile mob = h.Player;

                    from.CloseGump(typeof(HeadNegotiateGump));
                    mob.CloseGump(typeof(HeadOwnerListGump));

                    if (mob.Kills >= 5 && !h.Expired)
                    {
                        if (!h.Player.InStat)
                        {
                            LoggingCustom.Log("MurdererNegotiate.txt", DateTime.Now + "\t" + mob + "\t" + "STATTED by " + from.Name);

                            if (CentralGump.EnsureProfile(mob as PlayerMobile).BuyHead)
                            {
                                if (PendingStatloss == null)
                                {
                                    PendingStatloss = new List <HeadTurnInObj>();
                                }

                                if (PendingStatlossTimer == null || !PendingStatlossTimer.Running)
                                {
                                    PendingStatlossTimer = new InternalTimer();
                                    PendingStatlossTimer.Start();
                                }

                                if (!PendingStatloss.Exists(x => x.HeadOwner == mob as PlayerMobile))
                                {
                                    var headobject = new HeadTurnInObj(DateTime.UtcNow + TimeSpan.FromMinutes(5), from as PlayerMobile, mob as PlayerMobile);
                                    PendingStatloss.Add(headobject);

                                    Conquests.CheckProgress <ItemConquest>(from as PlayerMobile, h, "turnin");
                                    bReturn = true;
                                    h.Delete();
                                }
                                else
                                {
                                    from.SendMessage(61,
                                                     "This player is currently pending statloss.  Try to turn the head in again in 5 minutes.");
                                }
                            }
                            else
                            {
                                Conquests.CheckProgress <ItemConquest>(from as PlayerMobile, h, "turnin");
                                bReturn = true;
                                BeginSkillLoss(mob);
                                h.Delete();
                            }

                            if (mob.Kills <= 10)
                            {
                                Say("My thanks for slaying this vile person.");
                            }

                            if (mob.Kills > 10 && mob.Kills < 25)
                            {
                                Say("Thank you for ridding Brittania of this evil fiend.");
                            }

                            if (mob.Kills >= 25)
                            {
                                Say("Thank you for destroying " + mob.Name + ", Britannia is a much safer place with that scum gone.");
                            }
                        }
                        else                         //Owner of head is currently in statloss
                        {
                            Say("Begone.  This murderer has already met justice!");
                            Say("I'll take that head, you just run along now.");
                            bReturn = true;
                            h.Delete();
                        }
                    }
                    else if (h.Expired)                     //if head is decayed, set to true and change hue
                    {
                        Say("Why are you trying to give me this decayed piece of trash?");
                        h.Expire();
                    }
                    else
                    {
                        Say("You disgusting miscreant!  Why are you giving me an innocent person's head?");
                    }
                }
                else
                {
                    Say("I suspect treachery....");
                    Say("I'll take that head, you just run along now.");
                    bReturn = true;
                    h.Delete();
                }
            }

            return(bReturn);
        }
Пример #25
0
        private void OnAccept()
        {
            Type cType = Head.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);

            if (Head == null || Head.Deleted)
            {
                _Victim.SendMessage(
                    "Your head was turned over to the authorities by {0} during negotations.", User.RawName);
                User.SendMessage("You turned over {0}'s to the authorities during negotations and cannot accept this offer.", User.RawName);
                return;
            }

            if (Head.RootParentEntity != User)
            {
                _Victim.SendMessage(
                    "Your head does not appear to be possessed by {0} any longer.", User.RawName);
                User.SendMessage("You must retain the head in your pack or bank to engage in negotations for {0}'s head.", User.RawName);
                return;
            }

            if (!Banker.Withdraw(_Victim, cType, _Offer))
            {
                User.SendMessage("{0} could not afford this price.  Please make another offer later.", _Victim.RawName);

                _Victim.SendMessage(
                    "You could not afford to pay the counteroffer you made.  The amount of {0} in your bank has declined since you made the counteroffer.",
                    cType.Name);

                LoggingCustom.Log(
                    "MurdererNegotiate.txt",
                    String.Format(
                        "[Killer -> Victim][FAILED][{0}]:\t[{1} -> {2}]\t[{3}]\t[{4:#,0} {5}]\t\"{6}\"",
                        ServerTime.ShortDateTimeNow,
                        User,
                        _Victim,
                        Head,
                        _Offer,
                        cType.Name,
                        _Message));
                return;
            }

            _Victim.SendMessage(
                "{0:#,0} {1} has been withdrawn from your bank and paid to {2}.", _Offer, cType.Name, User.RawName);
            User.SendMessage("{0:#,0} {1} has been paid and added to your bank box by {2}.", _Offer, cType.Name, _Victim.RawName);

            Banker.Deposit(User, cType, _Offer);

            BankBox bank = _Victim.FindBank(Head.Expansion) ?? _Victim.BankBox;

            if (bank != null)
            {
                bank.DropItem(Head);
            }

            if (Head is Head2)
            {
                Head2.AllHeads.Remove((Head2)Head);
            }

            foreach (var g in GetInstances <HeadNegotiateGump>(_Victim, true).Where(g => g.Head == Head))
            {
                g.Close(true);
            }

            _Victim.SendMessage("Your severed head has been deposited into your bank box.");

            LoggingCustom.Log(
                "MurdererNegotiate.txt",
                String.Format(
                    "[Killer -> Victim][ACCEPTED][{0}]:\t[{1} -> {2}]\t[{3}]\t[{4:#,0} {5}]\t\"{6}\"",
                    ServerTime.ShortDateTimeNow,
                    User,
                    _Victim,
                    Head,
                    _Offer,
                    cType.Name,
                    _Message));
        }
Пример #26
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            if (from.Criminal)
            {
                from.SendMessage("You can't use this command while you are a criminal!");
                return;
            }

            foreach (AggressorInfo aggressor in from.Aggressors)
            {
                if (aggressor.Attacker is PlayerMobile)
                {
                    from.SendMessage("You can't use that command while you are in combat!");
                    return;
                }
            }
            foreach (AggressorInfo aggressed in from.Aggressed)
            {
                if (aggressed.Defender is PlayerMobile)
                {
                    from.SendMessage("You can't use that command while you are in combat!");
                    return;
                }
            }
            //if (from.Aggressors.Count > 0 || from.Aggressed.Count > 0)
            //{
            //    from.SendMessage("You can't use that command while you are in combat!");
            //    return;
            //}

            switch (info.ButtonID)
            {
            case 0:                     // Closed
            {
                return;
            }

            case 1:                     // Previous
            {
                if (m_Page > 0)
                {
                    from.SendGump(new CompanionListGump(from, m_Mobiles, m_Page - 1));
                }

                break;
            }

            case 2:                     // Next
            {
                if ((m_Page + 1) * EntryCount < m_Mobiles.Count)
                {
                    from.SendGump(new CompanionListGump(from, m_Mobiles, m_Page + 1));
                }

                break;
            }

            case 1000:     // sign out
            {
                if (from is PlayerMobile && ((PlayerMobile)from).Companion)
                {
                    PlayerMobile pm = (PlayerMobile)from;
                    if (PlayerMobile.OnlineCompanions.Contains(pm))
                    {
                        PlayerMobile.OnlineCompanions.Remove(pm);
                        UberScriptFunctions.Methods.LOCALMSG(null, from, "You have signed off as a companion. You will no longer receive young player alerts.", 38);
                        LoggingCustom.Log(Path.Combine(new string[] { CompanionListGump.LogFileLocation, from.RawName + ".txt" }), DateTime.Now + "\t" + "Signed off as Companion");
                        PlayerMobile.OnlineCompanions.Remove(pm);
                    }
                }
                break;
            }

            default:
            {
                int index = (m_Page * EntryCount) + (info.ButtonID - 3);

                if (index >= 0 && index < m_Mobiles.Count)
                {
                    Mobile m = m_Mobiles[index];

                    if (m.Deleted)
                    {
                        from.SendMessage("That player has deleted their character.");
                        from.SendGump(new CompanionListGump(from, m_Mobiles, m_Page));
                    }
                    else if (m.NetState == null)
                    {
                        from.SendMessage("That player is no longer online.");
                        from.SendGump(new CompanionListGump(from, m_Mobiles, m_Page));
                    }
                    else if (m == from || !m.Hidden || from.AccessLevel >= m.AccessLevel || (m is PlayerMobile && ((PlayerMobile)m).VisibilityList.Contains(from)))
                    {
                        if (m is PlayerMobile)
                        {
                            PlayerMobile pm = (PlayerMobile)m;
                            if (pm.Alive && DateTime.UtcNow < pm.LastHelped + TimeSpan.FromMinutes(PseudoSeerStone.CompanionMinutesBetweenHelp))
                            {
                                from.SendMessage("That player has been helped within the last minute, so you cannot jump to them at this time!");
                            }
                            else
                            {
                                if (CreaturePossession.IsInHouseOrBoat(pm.Location, pm.Map))
                                {
                                    from.SendMessage("That player is in a house or boat, so you cannot teleport to them.");
                                }
                                else
                                {
                                    SendCompanionTo(from, m);
                                }
                            }
                        }
                        else
                        {
                            SendCompanionTo(from, m);
                        }
                    }
                    else
                    {
                        from.SendMessage("You cannot see them.");
                        from.SendGump(new CompanionListGump(from, m_Mobiles, m_Page));
                    }
                }

                break;
            }
            }
        }
Пример #27
0
        public static void Reload()
        {
            WeightedLocations = new List <WeightedLocation>();
            TotalWeighting    = 0;

            List <string> errors = new List <string>();

            string line;

            // Read the file and display it line by line.
            try
            {
                StreamReader file       = new StreamReader(ConfigFileName);
                int          lineNumber = 0;

                while ((line = file.ReadLine()) != null)
                {
                    lineNumber++;

                    line = line.Trim();

                    if (String.IsNullOrWhiteSpace(line) || line.StartsWith("#"))
                    {
                        continue;
                    }

                    var args = line.Split();

                    try
                    {
                        if (args.Length < 2)
                        {
                            throw new Exception(
                                      "Line " + lineNumber + ": " + line +
                                      "\nUncommented line did not have format weighting<space>rectangleTopLeftX,rectangleTopLeftY,rectangleBottomRightX,rectangleBottomRightY");
                        }

                        // syntax is
                        // weighting<space>rectangleTopLeftX,rectangleTopLeftY,rectangleBottomRightX,rectangleBottomRightY
                        int weighting             = int.Parse(args[0]);
                        var coordinateVals        = args[1].Split(',');
                        int rectangleTopLeftX     = int.Parse(coordinateVals[0]);
                        int rectangleTopLeftY     = int.Parse(coordinateVals[1]);
                        int rectangleBottomRightX = int.Parse(coordinateVals[2]);
                        int rectangleBottomRightY = int.Parse(coordinateVals[3]);

                        WeightedLocations.Add(
                            new WeightedLocation(
                                new Point2D(rectangleTopLeftX, rectangleTopLeftY),
                                new Point2D(rectangleBottomRightX, rectangleBottomRightY),
                                weighting));
                        TotalWeighting += weighting;
                    }
                    catch (Exception e)
                    {
                        errors.Add(e.Message);
                    }
                }

                file.Close();
            }
            catch (Exception e)
            {
                errors.Add(e.ToString());
            }

            if (errors.Count > 0)
            {
                LoggingCustom.Log("ERROR-RandomLocations.txt", errors.ToArray());
            }
        }
Пример #28
0
        public virtual void GivePowerScrolls()
        {
            if (ChampSpawn == null && !AlwaysDropScrolls)
            {
                return;
            }

            var scores = new Dictionary <Mobile, double>(Scores);

            var toReceiveScroll = new List <Mobile>();


            // first find all eligible receivers
            var eligibleMobs      = new List <Mobile>();
            var eligibleMobScores = new List <double>();

            var eligibleFactionMobs      = new List <Mobile>();
            var eligibleFactionMobScores = new List <double>();


            double totalScores        = 0.0;
            double totalFactionScores = 0.0;

            var sb = new StringBuilder();

            sb.Append("========== " + DateTime.Now + " Champion " + GetType() + " Report ==============\r\n");
            sb.Append(
                "Score\tEligible\tName\tAccount\tAddress\tStr\tInt\tDex\tTaming\tProvocation\tMagery\tArchery\tMace\tFencing\tSwords\tLumberjack\tWrestling\tAnatomy\r\n");

            foreach (KeyValuePair <Mobile, double> pair in scores)
            {
                Mobile mob = pair.Key;

                if (mob == null)
                {
                    continue;
                }

                bool eligible = IsEligible(mob);

                sb.Append(
                    pair.Value + "\t" + eligible + "\t" + mob + "\t" + mob.Account + "\t" + mob.Address + "\t" + mob.Str +
                    "\t" +
                    mob.Int + "\t" + mob.Dex + "\t" + mob.Skills.AnimalTaming.Value + "\t" +
                    mob.Skills.Provocation.Value + "\t" +
                    mob.Skills.Magery.Value + "\t" + mob.Skills.Archery.Value + "\t" + mob.Skills.Macing.Value + "\t" +
                    mob.Skills.Fencing.Value + "\t" + mob.Skills.Swords.Value + "\t" + mob.Skills.Lumberjacking.Value +
                    "\t" +
                    mob.Skills.Wrestling.Value + "\t" + mob.Skills.Anatomy.Value + "\r\n");

                if (!eligible)
                {
                    continue;
                }

                eligibleMobs.Add(mob);
                eligibleMobScores.Add(pair.Value);

                if (mob is PlayerMobile && ((PlayerMobile)mob).FactionName != null)
                {
                    eligibleFactionMobs.Add(mob);
                    eligibleFactionMobScores.Add(pair.Value);
                    totalFactionScores += pair.Value;
                }

                totalScores += pair.Value;
            }

            if (0.1 > Utility.RandomDouble())
            {
                GiveRecipe(eligibleMobs, eligibleMobScores, totalScores);
            }

            if (0.1 > Utility.RandomDouble())
            {
                GiveRelic(eligibleMobs, eligibleMobScores, totalScores);
            }

            GiveSpecialItems(eligibleMobs, eligibleMobScores, totalScores);

            //determine faction PS winner


            for (int powerScrollIndex = 0;
                 powerScrollIndex < FactionPSToGive;
                 powerScrollIndex++)
            {
                double currentTestValue = 0.0;
                double roll             = Utility.RandomDouble() * totalFactionScores;

                for (int i = 0; i < eligibleFactionMobScores.Count; i++)
                {
                    currentTestValue += eligibleFactionMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    toReceiveScroll.Add(eligibleFactionMobs[i]);

                    totalScores -= eligibleFactionMobScores[i];

                    // remove them from eligible list now
                    eligibleFactionMobs.RemoveAt(i);
                    eligibleFactionMobScores.RemoveAt(i);
                    break;
                }
            }

            for (int powerScrollIndex = 0;
                 powerScrollIndex < PSToGive;
                 powerScrollIndex++)
            {
                double currentTestValue = 0.0;
                double roll             = Utility.RandomDouble() * totalScores;

                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    toReceiveScroll.Add(eligibleMobs[i]);

                    totalScores -= eligibleMobScores[i];

                    // remove them from eligible list now
                    eligibleMobs.RemoveAt(i);
                    eligibleMobScores.RemoveAt(i);
                    break;
                }
            }

            if (Portal == null && Invasion == null)
            {
                foreach (PlayerMobile mobile in scores.Keys.OfType <PlayerMobile>())
                {
                    PlayerMobile mobile1 = mobile;
                    Timer.DelayCall(
                        TimeSpan.FromMinutes(1),
                        () =>
                    {
                        var scrollgump = new PlayerScoresScrollGump(mobile1, onAccept: x =>
                        {
                            var scoreboard = new PlayerScoreResultsGump(mobile1, this, scores, toReceiveScroll).
                                             Send <PlayerScoreResultsGump>();
                        }).Send <PlayerScoresScrollGump>();
                    });
                }
            }

            foreach (Mobile luckyPlayer in toReceiveScroll)
            {
                PowerScroll ps = CreateRandomPowerScroll(Expansion);

                if (ps == null)
                {
                    continue;
                }

                GivePowerScrollTo(luckyPlayer, ps);
                sb.Append(luckyPlayer + " received powerScoll " + ps.Skill + " " + ps.Value + "\r\n");
            }

            LoggingCustom.Log("ChampionScores/" + IOUtility.GetSafeFileName(GetType().FullName) + ".log", sb.ToString());
        }
Пример #29
0
        public override void GivePowerScrolls()
        {
            if (ChampSpawn == null && !AlwaysDropScrolls)
            {
                return;
            }

            var scores = new Dictionary <Mobile, double>(Scores);

            var toReceiveScroll = new List <Mobile>();

            // first find all eligible receivers
            var eligibleMobs      = new List <Mobile>();
            var eligibleMobScores = new List <double>();

            List <KeyValuePair <Mobile, double> > orderedscores = scores.ToList();

            orderedscores.Sort((firstPair, nextPair) => firstPair.Value.CompareTo(nextPair.Value));
            orderedscores.Reverse();

            double totalScores = 0.0;
            var    sb          = new StringBuilder();

            sb.Append("========== " + DateTime.Now + " Champion " + GetType() + " Report ==============\r\n");
            sb.Append(
                "Score\tEligible\tName\tAccount\tAddress\tStr\tInt\tDex\tTaming\tProvocation\tMagery\tArchery\tMace\tFencing\tSwords\tLumberjack\tWrestling\tAnatomy\r\n");

            foreach (KeyValuePair <Mobile, double> pair in scores)
            {
                Mobile mob = pair.Key;

                if (mob == null)
                {
                    continue;
                }

                bool eligible = IsEligible(mob);

                sb.Append(
                    pair.Value + "\t" + eligible + "\t" + mob + "\t" + mob.Account + "\t" + mob.Address + "\t" + mob.Str +
                    "\t" +
                    mob.Int + "\t" + mob.Dex + "\t" + mob.Skills.AnimalTaming.Value + "\t" +
                    mob.Skills.Provocation.Value + "\t" +
                    mob.Skills.Magery.Value + "\t" + mob.Skills.Archery.Value + "\t" + mob.Skills.Macing.Value + "\t" +
                    mob.Skills.Fencing.Value + "\t" + mob.Skills.Swords.Value + "\t" + mob.Skills.Lumberjacking.Value +
                    "\t" +
                    mob.Skills.Wrestling.Value + "\t" + mob.Skills.Anatomy.Value + "\r\n");

                if (!eligible)
                {
                    continue;
                }

                eligibleMobs.Add(mob);
                eligibleMobScores.Add(pair.Value);

                totalScores += pair.Value;
            }

            for (int powerScrollIndex = 0;
                 powerScrollIndex < ChampionGlobals.CSOptions.PowerScrollsToGive;
                 powerScrollIndex++)
            {
                double currentTestValue = 0.0;
                double roll             = Utility.RandomDouble() * totalScores;

                for (int i = 0; i < eligibleMobScores.Count; i++)
                {
                    currentTestValue += eligibleMobScores[i];

                    if (roll > currentTestValue)
                    {
                        continue;
                    }

                    toReceiveScroll.Add(eligibleMobs[i]);

                    totalScores -= eligibleMobScores[i];

                    // remove them from eligible list now
                    eligibleMobs.RemoveAt(i);
                    eligibleMobScores.RemoveAt(i);
                    break;
                }
            }


            foreach (PlayerMobile mobile in scores.Keys.OfType <PlayerMobile>())
            {
                PlayerMobile mobile1 = mobile;
                Timer.DelayCall(
                    TimeSpan.FromMinutes(1),
                    () =>
                {
                    var scrollgump = new PlayerScoresScrollGump(mobile1, onAccept: x =>
                    {
                        var scoreboard = new PlayerScoreResultsGump(mobile1, this, scores, toReceiveScroll).
                                         Send <PlayerScoreResultsGump>();
                    }).Send <PlayerScoresScrollGump>();
                });
            }

            foreach (Mobile luckyPlayer in toReceiveScroll)
            {
                PowerScroll ps = CreateRandomPowerScroll(Expansion);

                if (ps == null)
                {
                    continue;
                }

                GivePowerScrollTo(luckyPlayer, ps);
                sb.Append(luckyPlayer + " received powerScoll " + ps.Skill + " " + ps.Value + "\r\n");
            }

            foreach (PlayerMobile pm in orderedscores.Select(kvp => kvp.Key as PlayerMobile))
            {
                TitleHue titlehue;

                CustomTitles.TryGetHue(1196, out titlehue);

                TitleProfile p = CustomTitles.EnsureProfile(pm);

                if (pm != null && titlehue != null && p != null && !p.Contains(titlehue))
                {
                    p.Add(titlehue);
                    pm.SendMessage(titlehue.Hue, "You have been granted the title hue: " + titlehue.Hue);
                    sb.Append(pm + " received titlehue " + titlehue.Hue + "\r\n");
                    break;
                }
            }

            LoggingCustom.Log("ChampionScores/" + IOUtility.GetSafeFileName(GetType().FullName) + ".log", sb.ToString());
        }
Пример #30
0
        private static void CMInvoke()
        {
            CommandUtility.Register(
                "AddCustomTitle",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                if (e.Arguments.Length < 2)
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity]");
                    return;
                }

                string maleValue   = e.Arguments[0];
                string femaleValue = e.Arguments[1];

                var rarity = TitleRarity.Common;

                if (e.Arguments.Length > 2 && !Enum.TryParse(e.Arguments[2], true, out rarity))
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity]");
                    return;
                }

                var display = TitleDisplay.BeforeName;

                if (e.Arguments.Length > 3 && !Enum.TryParse(e.Arguments[3], true, out display))
                {
                    e.Mobile.SendMessage(0x22, "Format: <maleTitle> <femaleTitle> [rarity] [display]");
                    return;
                }

                string result;

                Title title = CreateTitle(maleValue, femaleValue, rarity, display, out result);

                e.Mobile.SendMessage(title == null ? 0x22 : 0x33, result);
            });

            CommandUtility.Register(
                "AddCustomTitleHue",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                if (e.Arguments.Length == 0)
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                int value;

                if (!Int32.TryParse(e.Arguments[0], out value))
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                var rarity = TitleRarity.Common;

                if (e.Arguments.Length > 1 && !Enum.TryParse(e.Arguments[1], true, out rarity))
                {
                    e.Mobile.SendMessage(0x22, "Format: <hue> [rarity]");
                    return;
                }

                string result;

                TitleHue hue = CreateHue(value, rarity, out result);

                e.Mobile.SendMessage(hue == null ? 0x22 : 0x33, result);
            });

            CommandUtility.Register(
                "WipeCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                new ConfirmDialogGump((PlayerMobile)e.Mobile)
                {
                    Title = "Confirm Action: Wipe",
                    Html  =
                        "This action will wipe all titles, title hues and title profiles.\nThis action can not be reversed!\n\nClick OK to confirm.",
                    AcceptHandler = b =>
                    {
                        Profiles.Values.ForEach(p => VitaNexCore.TryCatch(p.Clear));
                        Profiles.Clear();
                        e.Mobile.SendMessage("All title profiles have been cleared.");

                        HueRegistry.Values.ForEach(h => VitaNexCore.TryCatch(h.Clear));
                        HueRegistry.Clear();
                        e.Mobile.SendMessage("All title hues have been cleared.");

                        TitleRegistry.Values.ForEach(t => VitaNexCore.TryCatch(t.Clear));
                        TitleRegistry.Clear();
                        e.Mobile.SendMessage("All titles have been cleared.");
                    }
                }.Send();
            });

            CommandUtility.Register(
                "GrantCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                GrantTitlesTarget(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "RevokeCustomTitles",
                AccessLevel.Administrator,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                RevokeTitlesTarget(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "pg",
                AccessLevel.Player,
                e =>
            {
                if (e.Mobile is PlayerMobile && e.Mobile.Map != Map.ZombieLand)
                {
                    var player = e.Mobile as PlayerMobile;
                    if (player.RawName == "Savo-" || player.RawName == "Savo" || player.RawName == "Tsavo" ||
                        player.RawName == "a evil savo" || player.RawName == "a pirate savo" || player.RawName == "Tsavo-")
                    {
                        player.Frozen = true;
                        if (!player.Mounted)
                        {
                            player.Animate(239, 7, 1, true, false, 0);
                        }
                        player.PublicOverheadMessage(MessageType.Spell, player.SpeechHue, true, "Kal Ort Por", false);
                        Timer.DelayCall(TimeSpan.FromSeconds(0.75 + (0.25 * 3)), () =>
                        {
                            player.Frozen = false;
                            player.Hidden = true;
                            BaseCreature.TeleportPets(player, new Point3D(2977, 2893, -4), Map.Felucca, false);
                            player.MoveToWorld(new Point3D(2977, 2893, -4), Map.Felucca);
                        });
                    }
                }
            });

            CommandUtility.Register(
                "he",
                AccessLevel.Player,
                e =>
            {
                if (e.Mobile is PlayerMobile && e.Mobile.Map != Map.ZombieLand)
                {
                    var player = e.Mobile as PlayerMobile;
                    if (player.RawName == "Savo-" || player.RawName == "Savo" || player.RawName == "Tsavo" ||
                        player.RawName == "a evil savo" || player.RawName == "a pirate savo" || player.RawName == "Tsavo-")
                    {
                        player.Frozen = true;
                        if (!player.Mounted)
                        {
                            player.Animate(239, 7, 1, true, false, 0);
                        }
                        player.PublicOverheadMessage(MessageType.Spell, player.SpeechHue, true, "Kal Ort Por", false);
                        Timer.DelayCall(TimeSpan.FromSeconds(0.75 + (0.25 * 3)), () =>
                        {
                            player.Frozen = false;
                            player.Hidden = true;
                            BaseCreature.TeleportPets(player, new Point3D(2318, 3755, 0), Map.Felucca, false);
                            player.MoveToWorld(new Point3D(2318, 3755, 0), Map.Felucca);
                        });
                    }
                }
            });

            CommandUtility.Register(
                "CustomTitles",
                AccessLevel.Player,
                e =>
            {
                if (!CMOptions.ModuleEnabled)
                {
                    e.Mobile.SendMessage(0x22, "The Custom Titles module is currently disabled.");
                    return;
                }

                SendTitlesGump(e.Mobile as PlayerMobile);
            });

            CommandUtility.Register(
                "ConvertMetaDragons",
                AccessLevel.Developer,
                e =>
            {
                foreach (Mobile mob in World.Mobiles.Values.Where(x => x is EvolutionDragon).ToArray())
                {
                    var dragon = mob as EvolutionDragon;
                    if (dragon != null)
                    {
                        var newmeta           = new MetaDragon();
                        newmeta.Location      = dragon.Location;
                        newmeta.Map           = dragon.Map;
                        newmeta.Loyalty       = 100;
                        newmeta.ControlMaster = dragon.ControlMaster;
                        newmeta.Controlled    = true;
                        newmeta.ControlTarget = null;
                        newmeta.ControlOrder  = OrderType.Come;
                        newmeta.IsBonded      = true;
                        newmeta.Hue           = dragon.Hue;
                        newmeta.RawStr        = dragon.RawStr;
                        newmeta.RawDex        = dragon.RawDex;
                        newmeta.RawInt        = dragon.RawInt;
                        newmeta.Name          = dragon.Name;

                        newmeta.Stage           = dragon.Stage;
                        newmeta.MaxStage        = 7;
                        newmeta.EvolutionPoints = dragon.EvolutionPoints;

                        newmeta.Metaskills = new Dictionary <MetaSkillType, BaseMetaSkill>();

                        dragon.Delete();
                    }
                }
            });

            CommandUtility.Register(
                "GetAllItems",
                AccessLevel.Developer,
                e =>
            {
                var itemsdict = new Dictionary <int, int>();
                foreach (Item item in World.Items.Values.Where(x => x.Movable || x.IsLockedDown).ToArray())
                {
                    if (itemsdict.ContainsKey(item.ItemID))
                    {
                        itemsdict[item.ItemID]++;
                    }
                    else
                    {
                        itemsdict.Add(item.ItemID, 1);
                    }
                }

                foreach (KeyValuePair <int, int> kvp in itemsdict.OrderBy(i => i.Value))
                {
                    var sb = new StringBuilder();

                    sb.Append("ItemID: " + kvp.Key + "---------------Count: " + kvp.Value + "\n");
                    LoggingCustom.Log("ItemsLog/" + IOUtility.GetSafeFileName("Itemslog") + ".log", sb.ToString());
                }
            });

            CommandUtility.RegisterAlias("CustomTitles", "Titles");

            CommandUtility.Register("FlameSpiral", AccessLevel.GameMaster, e => BeginTarget(e.Mobile));
            CommandUtility.Register("FlashEffect", AccessLevel.GameMaster, e => DoFlash(e.Mobile));
            CommandUtility.Register("UpgradeAccounts", AccessLevel.Developer, e => UpgradeAccounts());
            CommandUtility.Register("LockedDownFix", AccessLevel.Developer, e => LockedDownFix());
        }