Exemplo n.º 1
0
        public void Flush(Mobile from, bool flushToLog)
        {
            //debug hang
            if (LoggingCustom.CommandDebug)
            {
                LoggingCustom.LogCommandDebug("Flush\t");
            }
            if (m_Responses.Count > 0)
            {
                for (int i = 0; i < m_Responses.Count; ++i)
                {
                    object obj = m_Responses[i];
                    //debug hang
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("Respone\t");
                    }
                    if (obj is MessageEntry)
                    {
                        from.SendMessage(((MessageEntry)obj).ToString());
                        //debug hang
                        if (LoggingCustom.CommandDebug)
                        {
                            LoggingCustom.LogCommandDebug(((MessageEntry)obj).ToString() + "\t");
                        }

                        if (flushToLog)
                        {
                            CommandLogging.WriteLine(from, ((MessageEntry)obj).ToString());
                        }
                    }
                    else if (obj is Gump)
                    {
                        from.SendGump((Gump)obj);
                    }
                }
            }
            else
            {
                //debug hang
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("Failure\t");
                }
                for (int i = 0; i < m_Failures.Count; ++i)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug(((MessageEntry)m_Failures[i]).ToString());
                    }
                    from.SendMessage(((MessageEntry)m_Failures[i]).ToString());
                }
            }
            if (LoggingCustom.CommandDebug)
            {
                LoggingCustom.LogCommandDebug("endflush\t");
            }
            m_Responses.Clear();
            m_Failures.Clear();
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
                }
            }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
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 );
        }
Exemplo n.º 6
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)));
     }
 }
Exemplo n.º 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"));
 }
Exemplo n.º 8
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));
        }
Exemplo n.º 9
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;
            }));
        }
Exemplo n.º 10
0
        public override void OnSingleClick(Mobile from)
        {
            base.OnSingleClick(from);

            if (from.Alive && m_Owner != null && BaseHouse.DecayEnabled && m_Owner.DecayPeriod != TimeSpan.Zero)
            {
                string message;

                switch (m_Owner.DecayLevel)
                {
                case DecayLevel.Ageless:
                    message = "ageless";
                    break;

                case DecayLevel.Fairly:
                    message = "fairly worn";
                    break;

                case DecayLevel.Greatly:
                    message = "greatly worn";
                    break;

                case DecayLevel.LikeNew:
                    message = "like new";
                    break;

                case DecayLevel.Slightly:
                    message = "slightly worn";
                    break;

                case DecayLevel.Somewhat:
                    message = "somewhat worn";
                    break;

                case DecayLevel.Collapsed:
                case DecayLevel.DemolitionPending:
                    message = "awaiting demolition";
                    break;

                default:
                    message = "in danger of collapsing";
                    break;
                }

                LabelTo(from, "This house is {0}.", message);
                LoggingCustom.LogHouseSign(
                    DateTime.Now + "\t" + from + "\t" + from.Account + "\t" + from.Address + "\t" + Serial + "\t" + message + "\t" +
                    Location);
            }
        }
Exemplo n.º 11
0
        public static void LogHarvesters()
        {
            try
            {
                var sb = new StringBuilder();

                string now        = DateTime.Now.ToString(CultureInfo.InvariantCulture);
                var    harvesters = new List <Mobile>();
                var    amounts    = new List <int>();
                // check for ore gathering
                GetSortedLists(PlayerOreHarvested, harvesters, amounts);
                int count = harvesters.Count;
                for (int i = 0; i < count; i++)
                {
                    sb.Append(now + "\t" + harvesters[i].Name + "\t" + harvesters[i].Account + "\t" + amounts[i] + "\tOre\n");
                }
                //============ same thing for logs
                GetSortedLists(PlayerLogsHarvested, harvesters, amounts);
                count = harvesters.Count;
                for (int i = 0; i < count; i++)
                {
                    sb.Append(now + "\t" + harvesters[i].Name + "\t" + harvesters[i].Account + "\t" + amounts[i] + "\tLogs\n");
                }
                //============ same thing for wool
                GetSortedLists(PlayerWoolHarvested, harvesters, amounts);
                count = harvesters.Count;
                for (int i = 0; i < count; i++)
                {
                    sb.Append(now + "\t" + harvesters[i].Name + "\t" + harvesters[i].Account + "\t" + amounts[i] + "\tWool\n");
                }
                //============ same thing for lockpickers
                GetSortedLists(PlayerLockpicking, harvesters, amounts);
                count = harvesters.Count;
                for (int i = 0; i < count; i++)
                {
                    sb.Append(now + "\t" + harvesters[i].Name + "\t" + harvesters[i].Account + "\t" + amounts[i] + "\tLockpicking\n");
                }
                LoggingCustom.LogHarvester(sb.ToString());
                LastReset = DateTime.UtcNow;
                PlayerLogsHarvested.Clear();
                PlayerOreHarvested.Clear();
            }
            catch (Exception except)
            {
                Console.WriteLine(except.Message);
                Console.WriteLine(except.StackTrace);
            }
        }
Exemplo n.º 12
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));
        }
Exemplo n.º 13
0
 public static void TryPossessCreature(Mobile from, BaseCreature Subject)
 {
     if (from == null || Subject == null)
     {
         return;
     }
     if (HasPermissionsToPossess(from, Subject))
     {
         if (Subject.NetState != null)
         {
             from.SendMessage("Target creature is already under player control!");
             return;
         }
         if (from.AccessLevel < FullAccessStaffLevel)
         {
             if (IsInHouseOrBoat(Subject.Location, Map.Felucca))
             {
                 from.SendMessage("You cannot possess a creature in a house or boat.");
                 return;
             }
             if (Subject.Blessed == true)
             {
                 from.SendMessage("You cannot possess invulnerable mobs.");
                 return;
             }
         }
         if (Subject.Controlled && !IsAuthorizedStaff(from))
         {
             from.SendMessage("You cannot possess tamed or summoned creatures!");
             return;
         }
         //Subject.HasBeenPseudoseerControlled = true;
         if (Subject.Backpack == null)
         {
             // create a backpack for things like animals that have no backpack
             // ... this prevents client crash in case somebody has their pack auto-opening on login
             Subject.PackItem(new Gold(1));
         }
         LoggingCustom.LogPseudoseer(DateTime.Now + "\t" + from.Account + "\t" + from.Name + "\tpossessing\t" + Subject + "\tRegion: " + Subject.Region + "\tLocation: " + Subject.Location);
         ConnectClientToNPC(from.NetState, Subject);
     }
     else
     {
         from.SendMessage("You are not permitted to possess that creature type, only staff can grant this permission.");
     }
 }
Exemplo n.º 14
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!");
            }
        }
Exemplo n.º 15
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);
            }
        }
Exemplo n.º 16
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));
        }
Exemplo n.º 17
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");
            }
        }
Exemplo n.º 18
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 {}
                }
            }
        }
Exemplo n.º 19
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);
            }
        }
Exemplo n.º 20
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();
        }
Exemplo n.º 21
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);
                }
            }
Exemplo n.º 22
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);
        }
Exemplo n.º 23
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);
        }
Exemplo n.º 24
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>();
        }
Exemplo n.º 25
0
        public void IncogMode(PlayerMobile pm)
        {
            string originalName = pm.Name;

            pm.HueMod  = pm.Race.RandomSkinHue();
            pm.NameMod = pm.Female ? NameList.RandomName("female") : NameList.RandomName("male");

            LoggingCustom.LogDisguise(DateTime.Now + "\t" + originalName + "\t" + pm.NameMod);

            if (pm.Race != null)
            {
                pm.SetHairMods(pm.Race.RandomHair(pm.Female), pm.Race.RandomFacialHair(pm.Female));
                pm.HairHue       = pm.Race.RandomHairHue();
                pm.FacialHairHue = pm.Race.RandomHairHue();
            }

            pm.FixedParticles(0x373A, 10, 15, 5036, EffectLayer.Head);
            pm.PlaySound(0x3BD);

            BaseArmor.ValidateMobile(pm);
            BaseClothing.ValidateMobile(pm);

            //BuffInfo.AddBuff( Caster, new BuffInfo( BuffIcon.Incognito, 1075819, length, Caster ) );
        }
Exemplo n.º 26
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());
        }
Exemplo n.º 27
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.
            }
        }
Exemplo n.º 28
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);
        }
Exemplo n.º 29
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;
            }
            }
        }
Exemplo n.º 30
0
        public void RunCommand(Mobile from, object obj, BaseCommand command, string[] args)
        {
            try
            {
                if (command is GetCommand && obj is ArrayList && ((ArrayList)obj).Count > 20000)
                {
                    throw new Exception("Get command has too many potential target: " + ((ArrayList)obj).Count);
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("RunCommand\t" + command.Commands[0] + "\t");
                }
                CommandEventArgs e = new CommandEventArgs(from, command.Commands[0], GenerateArgString(args), args);

                if (!command.ValidateArgs(this, e))
                {
                    return;
                }

                bool flushToLog = false;

                if (obj is ArrayList)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("objArrayList\t");
                    }
                    ArrayList list = (ArrayList)obj;

                    if (list.Count > 20)
                    {
                        CommandLogging.Enabled = false;
                    }
                    else if (list.Count == 0)
                    {
                        command.LogFailure("Nothing was found to use this command on.");
                    }

                    command.ExecuteList(e, list);

                    if (list.Count > 20)
                    {
                        flushToLog             = true;
                        CommandLogging.Enabled = true;
                    }
                }
                else if (obj != null)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("obj\t");
                    }
                    if (command.ListOptimized)
                    {
                        ArrayList list = new ArrayList();
                        list.Add(obj);
                        command.ExecuteList(e, list);
                    }
                    else
                    {
                        command.Execute(e, obj);
                    }
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("flush\t");
                }
                command.Flush(from, flushToLog);
            }
            catch (Exception ex)
            {
                if (from != null)
                {
                    from.SendMessage(ex.Message);
                }
            }
        }