Пример #1
0
		public static void EventSink_PlayerDeath( PlayerDeathEventArgs e )
		{
			Mobile m = e.Mobile;

			//Check to make sure inmates don't give counts.
			if( m is PlayerMobile )
			{
				if( ((PlayerMobile)m).Inmate )
				{
					return;
				}
			}

            //Check to make sure we don't give counts during Server Wars.
            if (Server.Misc.AutoRestart.ServerWars == true)
                return;

			ArrayList killers = new ArrayList();
			ArrayList toGive = new ArrayList();

			//if ( DateTime.Now < ((PlayerMobile)m).NextMurderCountTime )
			//	return;

			bool bTimeRestricted = false; //false means they're out of time restriction

			foreach ( AggressorInfo ai in m.Aggressors )
			{
				bTimeRestricted = false;

				//Pix: 3/20/07 - fix a premature change that was made for townships
				//if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported && !ai.InitialAggressionNotCountable )
				if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported && !ai.InitialAggressionInNoCountZone)
				{
					try //just for safety's sake
					{
						if( m is PlayerMobile )
						{
							PlayerMobile pm = (PlayerMobile)m;
							if( pm.KillerTimes == null )
							{
								pm.KillerTimes = new ArrayList();
							}

							bool bFound = false;
							KillerTime kt = null;
							foreach( KillerTime k in pm.KillerTimes )
							{
								if( k.Killer == ai.Attacker )
								{
									bFound = true;
									kt = k;
								}
							}

							if( bFound )
							{
								if( kt != null )
								{
									if( DateTime.Now - kt.Time < TimeSpan.FromMinutes(2.0) )
									{
										bTimeRestricted = true;
									}
									kt.Time = DateTime.Now;
								}
							}
							else
							{
								kt = new KillerTime( ai.Attacker, DateTime.Now );
								pm.KillerTimes.Add(kt);
							}
						}
					}
					catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

					if( !bTimeRestricted )
					{
						killers.Add( ai.Attacker );
					}
					ai.Reported = true;
				}

				if ( ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
					toGive.Add( ai.Attacker );
			}

			foreach ( AggressorInfo ai in m.Aggressed )
			{
				if ( ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
					toGive.Add( ai.Defender );
			}

			foreach ( Mobile g in toGive )
			{
				int n = Notoriety.Compute( g, m );

				int theirKarma = m.Karma, ourKarma = g.Karma;
				bool innocent = ( n == Notoriety.Innocent );
				bool criminal = ( n == Notoriety.Criminal || n == Notoriety.Murderer );

				int fameAward = m.Fame / 200;
				int karmaAward = 0;

				if ( innocent )
					karmaAward = ( ourKarma > -2500 ? -850 : -110 - (m.Karma / 100) );
				else if ( criminal )
					karmaAward = 50;

				Titles.AwardFame( g, fameAward, false );
				Titles.AwardKarma( g, karmaAward, true );
			}

			if ( m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild )
				return;

			if ( killers.Count > 0 )
				new GumpTimer( m, killers ).Start();

			//((PlayerMobile)m).NextMurderCountTime = DateTime.Now + TimeSpan.FromMinutes(2.0);
		}
Пример #2
0
        public static void EventSink_PlayerDeath(PlayerDeathEventArgs e)
        {
            Mobile m = e.Mobile;

            //Check to make sure inmates don't give counts.
            if (m is PlayerMobile)
            {
                if (((PlayerMobile)m).Inmate)
                {
                    return;
                }
            }

            //Check to make sure we don't give counts during Server Wars.
            if (Server.Misc.AutoRestart.ServerWars == true)
            {
                return;
            }

            ArrayList killers = new ArrayList();
            ArrayList toGive  = new ArrayList();

            //if ( DateTime.Now < ((PlayerMobile)m).NextMurderCountTime )
            //	return;

            bool bTimeRestricted = false;             //false means they're out of time restriction

            foreach (AggressorInfo ai in m.Aggressors)
            {
                bTimeRestricted = false;

                //Pix: 3/20/07 - fix a premature change that was made for townships
                //if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported && !ai.InitialAggressionNotCountable )
                if (ai.Attacker.Player && ai.CanReportMurder && !ai.Reported && !ai.InitialAggressionInNoCountZone)
                {
                    try                     //just for safety's sake
                    {
                        if (m is PlayerMobile)
                        {
                            PlayerMobile pm = (PlayerMobile)m;
                            if (pm.KillerTimes == null)
                            {
                                pm.KillerTimes = new ArrayList();
                            }

                            bool       bFound = false;
                            KillerTime kt     = null;
                            foreach (KillerTime k in pm.KillerTimes)
                            {
                                if (k.Killer == ai.Attacker)
                                {
                                    bFound = true;
                                    kt     = k;
                                }
                            }

                            if (bFound)
                            {
                                if (kt != null)
                                {
                                    if (DateTime.Now - kt.Time < TimeSpan.FromMinutes(2.0))
                                    {
                                        bTimeRestricted = true;
                                    }
                                    kt.Time = DateTime.Now;
                                }
                            }
                            else
                            {
                                kt = new KillerTime(ai.Attacker, DateTime.Now);
                                pm.KillerTimes.Add(kt);
                            }
                        }
                    }
                    catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }

                    if (!bTimeRestricted)
                    {
                        killers.Add(ai.Attacker);
                    }
                    ai.Reported = true;
                }

                if (ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Attacker))
                {
                    toGive.Add(ai.Attacker);
                }
            }

            foreach (AggressorInfo ai in m.Aggressed)
            {
                if (ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds(30.0) && !toGive.Contains(ai.Defender))
                {
                    toGive.Add(ai.Defender);
                }
            }

            foreach (Mobile g in toGive)
            {
                int n = Notoriety.Compute(g, m);

                int  theirKarma = m.Karma, ourKarma = g.Karma;
                bool innocent = (n == Notoriety.Innocent);
                bool criminal = (n == Notoriety.Criminal || n == Notoriety.Murderer);

                int fameAward  = m.Fame / 200;
                int karmaAward = 0;

                if (innocent)
                {
                    karmaAward = (ourKarma > -2500 ? -850 : -110 - (m.Karma / 100));
                }
                else if (criminal)
                {
                    karmaAward = 50;
                }

                Titles.AwardFame(g, fameAward, false);
                Titles.AwardKarma(g, karmaAward, true);
            }

            if (m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild)
            {
                return;
            }

            if (killers.Count > 0)
            {
                new GumpTimer(m, killers).Start();
            }

            //((PlayerMobile)m).NextMurderCountTime = DateTime.Now + TimeSpan.FromMinutes(2.0);
        }