Exemple #1
2
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			switch ( version )
			{
				case 0:
				{
					m_Boat = reader.ReadItem() as BaseBoat;
					m_Side = (PlankSide) reader.ReadInt();
					m_Locked = reader.ReadBool();
					m_KeyValue = reader.ReadUInt();

					if ( m_Boat == null )
						Delete();

					break;
				}
			}

			if ( IsOpen )
			{
				m_CloseTimer = new CloseTimer( this );
				m_CloseTimer.Start();
			}
		}
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
			i_Timer=new DBSTimer(this);
			i_Timer.Start();
		}
Exemple #3
1
        public VendorInventory( BaseHouse house, GenericReader reader )
        {
            m_House = house;

            int version = reader.ReadEncodedInt();

            m_Owner = reader.ReadMobile();
            m_VendorName = reader.ReadString();
            m_ShopName = reader.ReadString();

            m_Items = reader.ReadStrongItemList();
            m_Gold = reader.ReadInt();

            m_ExpireTime = reader.ReadDeltaTime();

            if ( m_Items.Count == 0 && m_Gold == 0 )
            {
                Timer.DelayCall( TimeSpan.Zero, new TimerCallback( Delete ) );
            }
            else
            {
                TimeSpan delay = m_ExpireTime - DateTime.UtcNow;
                m_ExpireTimer = new ExpireTimer( this, delay > TimeSpan.Zero ? delay : TimeSpan.Zero );
                m_ExpireTimer.Start();
            }
        }
Exemple #4
0
		public virtual void StartTimer()
		{
			if ( m_Timer != null )
				m_Timer.Stop();
						
			m_Timer = Timer.DelayCall( TimeSpan.FromMinutes( 5 ), new TimerCallback( Kill ) );
		}
Exemple #5
0
		public MLQuestInstance( MLQuest quest, IQuestGiver quester, PlayerMobile player )
		{
			m_Quest = quest;

			m_Quester = quester;
			m_QuesterType = ( quester == null ) ? null : quester.GetType();
			m_Player = player;

			m_Accepted = DateTime.UtcNow;
			m_Flags = MLQuestInstanceFlags.None;

			m_ObjectiveInstances = new BaseObjectiveInstance[quest.Objectives.Count];

			BaseObjectiveInstance obj;
			bool timed = false;

			for ( int i = 0; i < quest.Objectives.Count; ++i )
			{
				m_ObjectiveInstances[i] = obj = quest.Objectives[i].CreateInstance( this );

				if ( obj.IsTimed )
					timed = true;
			}

			Register();

			if ( timed )
				m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 5 ), TimeSpan.FromSeconds( 5 ), Slice );
		}
Exemple #6
0
        public ChiefParoxysmus()
            : base(AIType.AI_Melee, FightMode.Closest, 10, 1, 0.2, 0.4)
        {
            Name = "Chief Paroxysmus";
            Body = 0x100;

            SetStr( 1200, 1400 );
            SetDex( 75, 85 );
            SetInt( 75, 85 );

            SetHits( 50000 );

            SetDamage( 28, 36 );

            SetDamageType( ResistanceType.Physical, 80 );
            SetDamageType( ResistanceType.Poison, 20 );

            SetResistance( ResistanceType.Physical, 75, 85 );
            SetResistance( ResistanceType.Fire, 40, 50 );
            SetResistance( ResistanceType.Cold, 50, 60 );
            SetResistance( ResistanceType.Poison, 55, 65 );
            SetResistance( ResistanceType.Energy, 50, 60 );

            SetSkill( SkillName.MagicResist, 120.0 );
            SetSkill( SkillName.Tactics, 120.0 );
            SetSkill( SkillName.Wrestling, 120.0 );
            SetSkill( SkillName.Anatomy, 120.0 );
            SetSkill( SkillName.Poisoning, 120.0 );

            Fame = 32000;
            Karma = -32000;

            m_Timer = new TeleportTimer( this );
            m_Timer.Start();
        }
		public void Activate( bool newvalue )
		{
			if ( m_Active ) //Currently Active
			{
				if ( !newvalue ) //We are disabling it!
				{
					QuitGame();
					if ( m_Timer != null )
					{
						m_Timer.Stop();
						m_Timer = null;
					}
				}
			}
			else if ( newvalue ) //Currently Deactive, we are enabling it!
			{
				QuitGame();
				if ( m_Timer != null )
				{
					m_Timer.Stop();
					m_Timer = null;
				}

				m_Timer = new AutoCTFTimer( this );
				m_Timer.Start();
			}

			m_Active = newvalue;
		}
Exemple #8
0
		public virtual void StopTimer()
		{
			if ( m_Timer != null )
				m_Timer.Stop();

			m_Timer = null;
		}
Exemple #9
0
        public Aquarium( int itemID )
            : base(itemID)
        {
            if ( itemID == 0x3060 )
                AddComponent( new AddonContainerComponent( 0x3061 ), -1, 0, 0 );

            if ( itemID == 0x3062 )
                AddComponent( new AddonContainerComponent( 0x3063 ), 0, -1, 0 );

            MaxItems = 30;
            Weight = 10.0;

            m_Food = new AquariumState();
            m_Water = new AquariumState();

            m_Food.State = (int) FoodState.Full;
            m_Water.State = (int) WaterState.Strong;

            m_Food.Maintain = Utility.RandomMinMax( 1, 2 ); ;
            m_Food.Improve = m_Food.Maintain + Utility.RandomMinMax( 1, 2 );

            m_Water.Maintain = Utility.RandomMinMax( 1, 3 ); ;

            m_Events = new List<int>();

            m_Timer = Timer.DelayCall( TimeSpan.FromHours( 24 ), TimeSpan.FromHours( 24 ), new TimerCallback( Evaluate ) );
        }
Exemple #10
0
        public virtual void BeginConceal()
        {
            if ( m_Concealing != null )
                m_Concealing.Stop();

            m_Concealing = Timer.DelayCall( ConcealPeriod, new TimerCallback( Conceal ) );
        }
Exemple #11
0
 public TrackArrow( Mobile from, Mobile target, int range )
     : base(from, target)
 {
     m_From = from;
     m_Timer = new TrackTimer( from, target, range, this );
     m_Timer.Start();
 }
Exemple #12
0
		private void OnTimerTick()
		{
			Sandbox.SafeInvoke(
				() =>
				{
					if (_Timer == null)
					{
						return;
					}

					DateTime now = DateTime.UtcNow;

					if (now.Month != 4 || now.Day != 1)
					{
						_Timer.Stop();
						_Timer = null;
						return;
					}

					foreach (NetState state in NetState.Instances.ToArray())
					{
						if (state == null || !state.Running || state.Mobile == null || state.Mobile.Deleted || state.Mobile.Hidden)
						{
							continue;
						}

						Mobile m = state.Mobile;
						m.Say("I used to {0}, then I took an arrow to the knee!", _Vars[Utility.Random(_Vars.Length)]);
					}

					_Timer.Interval = TimeSpan.FromMinutes(Utility.RandomMinMax(5, 20));
				},
				this);
		}
        public void EndSpin( SpinCallback callback, Mobile from, int hue )
        {
            if ( m_Timer != null )
            {
                m_Timer.Stop();
            }

            m_Timer = null;

            foreach ( AddonComponent c in AddonComponents )
            {
                switch ( c.ItemID )
                {
                    case 0x1016:
                    case 0x101A:
                    case 0x101D:
                    case 0x10A5:
                        --c.ItemID;
                        break;
                }
            }

            if ( callback != null )
            {
                callback( this, from, hue );
            }
        }
Exemple #14
0
        public void Ensure()
        {
            m_Blocks = new List<Item>();

            foreach ( Rectangle3D r3d in Area )
            {
                Rectangle2D r2d = new Rectangle2D( r3d.Start, r3d.End );

                foreach ( Item item in Map.GetItemsInBounds( r2d ) )
                {
                    if ( item is Static )
                        m_Blocks.Add( item );
                }
            }

            if ( m_Blocks.Count == 0 )
            {
                m_Blocks = null;
                return;
            }

            foreach ( Item item in m_Blocks )
            {
                item.Hue = 0x807;
                item.Visible = false;
            }

            m_FadingTimer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 0.33 ), new TimerCallback( OnTick ) );
        }
        public PlayerVendor( Mobile owner, BaseHouse house )
        {
            Owner = owner;
            House = house;

            if ( BaseHouse.NewVendorSystem )
            {
                m_BankAccount = 0;
                m_HoldGold = 4;
            }
            else
            {
                m_BankAccount = 1000;
                m_HoldGold = 0;
            }

            ShopName = "Shop Not Yet Named";

            m_SellItems = new Hashtable();

            CantWalk = true;

            InitStats( 75, 75, 75 );
            InitBody();
            InitOutfit();

            TimeSpan delay = PayTimer.GetInterval();

            m_PayTimer = new PayTimer( this, delay );
            m_PayTimer.Start();

            m_NextPayTime = DateTime.Now + delay;
        }
Exemple #16
0
        public TreeStump( int itemID )
            : base()
        {
            AddComponent( new AddonComponent( itemID ), 0, 0, 0 );

            m_Timer = Timer.DelayCall( TimeSpan.FromDays( 1 ), TimeSpan.FromDays( 1 ), new TimerCallback( GiveLogs ) );
        }
Exemple #17
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
                case 1:
                    {
                        m_Caster = (BaseCreature)reader.ReadMobile();

                        goto case 0;
                    }
                case 0:
                    {
                        m_End = reader.ReadDeltaTime();

                        m_Timer = new InternalTimer(this, TimeSpan.Zero, true, true);
                        m_Timer.Start();

                        break;
                    }
            }
        }
Exemple #18
0
		public override void OnTalk( PlayerMobile player, bool contextMenu )
		{
			QuestSystem qs = player.Quest;

			if ( qs is TheGraveDiggerQuest )
			{
				QuestObjective obj = qs.FindObjective( typeof( VincentsLittleGirlObjective ) );

				if ( obj != null && !obj.Completed )
				{
					obj.Complete();
					this.Say( "Sweetie that strange person over there is stairing at me." );
					if ( this.BoyFriend != null )
					{
						m_RespondTime = DateTime.Now + TimeSpan.FromSeconds( 1.0 );
						m_Timer = new InternalTimer( this.BoyFriend, player, m_RespondTime );
						m_Timer.Start();
						m_Player = player;
					}
				}
				else
				{
					this.Say( "Yes? can i help you?" );
				}
			}
		}
        public void FinishHealing()
        {
            for ( int i = 0; i < 7 && i < Components.Count; i++ )
                Components[ i ].Hue = 0x6;

            m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 2 ), new TimerCallback( OpenOrgan ) );
        }
Exemple #20
0
		public virtual void StartTimer()
		{
			if ( m_Timer != null )
				return;

			m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 0.5 ), TimeSpan.FromSeconds( 0.5 ), new TimerCallback( Slice ) );
		}
        public ResurrectMenu( Mobile owner, Mobile healer, ResurrectMessage msg )
            : base("", m_Options)
        {
            m_Location = owner.Location;
            m_Healer = healer;

            m_Timer = Timer.DelayCall( TimeSpan.FromSeconds( 5.0 ), m_Unfreeze, owner );

            owner.Frozen = true;

            switch ( msg )
            {
                case ResurrectMessage.Healer:
                    Question = "It is possible for you to be resurrected here by this healer. Do you wish to try?";
                    break;
                case ResurrectMessage.VirtueShrine:
                    m_Heal = true;
                    Question = "It is possible for you to be resurrected at this Shrine to the Virtues. Do you wish to try?";
                    break;
                case ResurrectMessage.ChaosShrine:
                    m_Heal = true;
                    Question = "It is possible for you to be resurrected at the Chaos Shrine. Do you wish to try?";
                    break;
                case ResurrectMessage.Generic:
                default:
                    Question = "It is possible for you to be resurrected now. Do you wish to try?";
                    break;
            }
        }
			public LogoutGump( CampfireEntry entry, Bedroll bedroll ) : base( 100, 0 )
			{
				m_Entry = entry;
				m_Bedroll = bedroll;

				m_CloseTimer = Timer.DelayCall( TimeSpan.FromSeconds( 10.0 ), new TimerCallback( Close ) );

				AddBackground( 0, 0, 400, 350, 0xA28 );

				AddHtmlLocalized( 100, 20, 200, 35, 1011015, false, false ); // <center>Logging out via camping</center>

				/* Using a bedroll in the safety of a camp will log you out of the game safely.
				 * If this is what you wish to do choose CONTINUE and you will be logged out.
				 * Otherwise, select the CANCEL button to avoid logging out at this time.
				 * The camp will remain secure for 10 seconds at which time this window will close
				 * and you not be logged out.
				 */
				AddHtmlLocalized( 50, 55, 300, 140, 1011016, true, true );

				AddButton( 45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 80, 300, 110, 35, 1011011, false, false ); // CONTINUE

				AddButton( 200, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
				AddHtmlLocalized( 235, 300, 110, 35, 1011012, false, false ); // CANCEL
			}
Exemple #23
0
		public IceSnow2()
		{
			m_Decays = true;
			m_DecayTime = DateTime.Now + TimeSpan.FromMinutes( 2.0 );
			m_Timer = new InternalTimer( this, m_DecayTime );
			m_Timer.Start();
		}
        public PageEntry( Mobile sender, string message, PageType type )
        {
            m_Sender = sender;
            m_Sent = DateTime.Now;
            m_Message = Utility.FixHtml( message );
            m_Type = type;
            m_PageLocation = sender.Location;
            m_PageMap = sender.Map;

            PlayerMobile pm = sender as PlayerMobile;
            if ( pm != null && pm.SpeechLog != null && Array.IndexOf( SpeechLogAttachment, type ) >= 0 )
                m_SpeechLog = new List<SpeechLogEntry>( pm.SpeechLog );

            m_Timer = new InternalTimer( this );
            m_Timer.Start();

            StaffHistory history = Reports.Reports.StaffHistory;

            if ( history != null )
            {
                m_PageInfo = new PageInfo( this );

                history.AddPage( m_PageInfo );
            }
        }
		private void FinishWorking_Callback( object state )
		{
			if ( m_Timer != null )
			{
				m_Timer.Stop();
				m_Timer = null;
			}

			Mobile from = state as Mobile;

			if ( from != null && !from.Deleted && !this.Deleted && IsFull )
			{
				SackFlour flour = new SackFlour();

				flour.ItemID = ( Utility.RandomBool() ? 4153 : 4165 );

				if ( from.PlaceInBackpack( flour ) )
				{
					m_Flour = 0;
				}
				else
				{
					flour.Delete();
					from.SendLocalizedMessage( 500998 ); // There is not enough room in your backpack!  You stop grinding.
				}
			}

			UpdateStage();
		}
        public Penthesilea(bool decays) : base()
        {
			Name = "Penthesilea";
		    Body = 401;
            VirtualArmor = 50;
			CantWalk = true;
			Female = true;

            HairItemID= 0x203C;
			HairHue = 1153;
			
            AddItem( new Server.Items.FancyDress( 0x481) );
			AddItem( new Server.Items.Sandals( 0x481) );;
			
			Blessed = true;

            if (decays)
            {
                m_Decays = true;
                m_DecayTime = DateTime.Now + TimeSpan.FromSeconds(30);

                m_Timer = new InternalTimer(this, m_DecayTime);
                m_Timer.Start();
            }
        }
		public override void OnAfterDelete()
		{
			if ( m_DecayTimer != null )
				m_DecayTimer.Stop();

			m_DecayTimer = null;
		}
		public TreasureMapChest( Mobile owner, int level, bool temporary ) : base( 0xE40 )
		{
			Name = "a treasure chest";
			m_Owner = owner;
			m_Level = level;
			m_DeleteTime = DateTime.Now + TimeSpan.FromHours( 3.0 );

			m_Temporary = temporary;
			m_Guardians = new List<Mobile>();

			m_Timer = new DeleteTimer( this, m_DeleteTime );
			m_Timer.Start();

			Fill( this, level );

			if ( level == 0 || level == 1 )
				ItemValue = ItemValue.Common;
			else if ( level == 2 || level == 3 )
				ItemValue = ItemValue.Uncommon;
			else if ( level == 4 || level == 5 )
				ItemValue = ItemValue.Rare;
			else if ( level == 6 || level == 7 )
				ItemValue = ItemValue.Epic;
			else
				ItemValue = ItemValue.Legendary;
		}
Exemple #29
0
        public MagicalFishFinder() : base(5366)
        {
            Hue = 2500;

            Expires = DateTime.UtcNow + TimeSpan.FromHours(DecayPeriod);
            m_Timer = Timer.DelayCall(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(10), CheckDecay);
        }
Exemple #30
0
        public DuelWall( bool northsouth, Mobile from, Mobile to )
            : base(0x80)
        {
            m_From = from;
            m_To = to;
            Movable = false;

            if( northsouth )
            {
                m_Item1 = new InternalItem( this, 1, 0 );
                m_Item2 = new InternalItem( this, -1, 0 );
                m_XOffset1 = 1;
                m_XOffset2 = -1;
                m_YOffset1 = 0;
                m_YOffset2 = 0;
            }
            else
            {
                m_Item1 = new InternalItem( this, 0, 1 );
                m_Item2 = new InternalItem( this, 0, -1 );
                m_XOffset1 = 0;
                m_XOffset2 = 0;
                m_YOffset1 = 1;
                m_YOffset2 = -1;
            }

            m_Timer = new InternalTimer( this, TimeSpan.FromSeconds( 10.0 ), m_From, m_To );
            m_Timer.Start();

            m_End = DateTime.Now + TimeSpan.FromSeconds( 3.0 );

            Effects.PlaySound( new Point3D( X, Y, Z ), Map, 0x1F6 );
        }
Exemple #31
0
        private void ConnectStream()
        {
            try
            {
                c_Connecting   = true;
                c_ConnectTimer = Server.Timer.DelayCall(TimeSpan.FromSeconds(30), new Server.TimerCallback(TimerFail));
                c_LastPong     = DateTime.Now;

                c_Reader = new StreamReader(c_Tcp.GetStream(), System.Text.Encoding.Default);
                c_Writer = new StreamWriter(c_Tcp.GetStream(), System.Text.Encoding.Default);

                BroadcastSystem(General.Local(107));

                SendMessage(String.Format("USER {0} 1 * :Hello!", Data.IrcNick));
                SendMessage(String.Format("NICK {0}", Data.IrcNick));

                c_Thread = new Thread(new ThreadStart(ReadStream));
                c_Thread.Start();

                Server.Timer.DelayCall(TimeSpan.FromSeconds(15.0), new Server.TimerCallback(Names));

                foreach (Data data in Data.Datas.Values)
                {
                    if (data.Mobile.HasGump(typeof(IrcGump)))
                    {
                        GumpPlus.RefreshGump(data.Mobile, typeof(IrcGump));
                    }
                }
            }
            catch (Exception e)
            {
                Errors.Report(General.Local(266), e);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
            }
        }
Exemple #32
0
            /*private static void ProcessAddQueue()
             * {
             *      while ( m_AddQueue.Count != 0 )
             *      {
             *              Timer t = (Timer)m_AddQueue.Dequeue();
             *              t.m_Next = DateTime.Now + t.m_Delay;
             *              t.m_Index = 0;
             *              m_Timers[(int)t.Priority].Add( t );
             *      }//while !empty
             * }
             *
             * private static void ProcessRemoveQueue()
             * {
             *      while ( m_RemoveQueue.Count != 0 )
             *      {
             *              Timer t = (Timer)m_RemoveQueue.Dequeue();
             *              m_Timers[(int)t.Priority].Remove( t );
             *      }//while !empty
             * }
             *
             * private static void ProcessPriorityQueue()
             * {
             *      while ( m_PriQueue.Count != 0 )
             *      {
             *              PriChangeEntry e = (PriChangeEntry)m_PriQueue.Dequeue();
             *
             *              Timer t = e.m_Timer;
             *              TimerPriority oldPri = e.m_OldPri;
             *
             *              m_Timers[(int)oldPri].Remove( t );
             *              m_Timers[(int)t.Priority].Add( t );
             *
             *              e.Free();
             *      }//while !empty
             * }*/

            public void TimerMain()
            {
                DateTime now;
                int      i, j;

                while (!Core.Closing)
                {
                    now = DateTime.UtcNow;

                    /*ProcessAddQueue();
                     * ProcessRemoveQueue();
                     * ProcessPriorityQueue();*/
                    lock (m_ChangeQueue.SyncRoot)
                        ProcessChangeQueue(now);

                    bool queued = false;

                    for (i = 0; i < m_Timers.Length; i++)
                    {
                        if (now < m_NextPriorities[i])
                        {
                            break;
                        }

                        m_NextPriorities[i] = now + m_PriorityDelays[i];

                        for (j = 0; j < m_Timers[i].Count; j++)
                        {
                            Timer t = (Timer)m_Timers[i][j];

                            if (!t.m_Queued && now > t.m_Next)
                            {
                                t.m_Queued = true;

                                lock (m_Queue)
                                    m_Queue.Enqueue(t);

                                queued = true;

                                if (t.m_Count != 0 && (++t.m_Index >= t.m_Count))
                                {
                                    t.Stop();
                                }
                                else
                                {
                                    t.m_Next = now + t.m_Interval;
                                }
                            }
                        }                //for timers.Count
                    }                    //for Timer.Timers.Length

                    /* notify the core of new timers in the queue */
                    if (queued)
                    {
                        Core.WakeUp();
                    }

                    /* find the earliest timer class which needs another check */
                    DateTime earliest = DateTime.MaxValue;

                    for (i = 0; i < m_Timers.Length; i++)
                    {
                        if (m_Timers[i].Count > 0 &&
                            m_NextPriorities[i] < earliest)
                        {
                            earliest = m_NextPriorities[i];
                        }
                    }

                    /* sleep until there is a signal or until the next
                     * timer must be activated */
                    now = DateTime.UtcNow;

                    TimeSpan sleep = earliest <= now
                                                ? TimeSpan.FromMilliseconds(10)
                                                : (earliest == DateTime.MaxValue
                                                   ? TimeSpan.FromSeconds(1)
                                                   : earliest - now);

                    m_Signal.WaitOne(sleep, false);
                    //Thread.Sleep(sleep);
                    //Thread.Sleep(10);
                }        //while (true)
            }            //TimerMain
Exemple #33
0
 public static void RemoveTimer(Timer t)
 {
     Change(t, -1, false);
 }
Exemple #34
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);

            for (int i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "-debug"))
                {
                    m_Debug = true;
                }
                else if (Insensitive.Equals(args[i], "-service"))
                {
                    m_Service = true;
                }
                else if (Insensitive.Equals(args[i], "-profile"))
                {
                    Profiling = true;
                }
                else if (Insensitive.Equals(args[i], "-nocache"))
                {
                    m_Cache = false;
                }
                else if (Insensitive.Equals(args[i], "-haltonwarning"))
                {
                    m_HaltOnWarning = true;
                }
                else if (Insensitive.Equals(args[i], "-vb"))
                {
                    m_VBdotNET = true;
                }
            }

            try
            {
                if (m_Service)
                {
                    if (!Directory.Exists("Logs"))
                    {
                        Directory.CreateDirectory("Logs");
                    }

                    Console.SetOut(m_MultiConOut = new MultiTextWriter(new FileLogger("Logs/Console.log")));
                }
                else
                {
                    Console.SetOut(m_MultiConOut = new MultiTextWriter(Console.Out));
                }
            }
            catch
            {
            }

            m_Thread   = Thread.CurrentThread;
            m_Process  = Process.GetCurrentProcess();
            m_Assembly = Assembly.GetEntryAssembly();

            if (m_Thread != null)
            {
                m_Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";

            Version ver = m_Assembly.GetName().Version;

            // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
            Console.WriteLine("RunUO - [www.runuo.com] Version {0}.{1}, Build {2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision);
            Console.WriteLine("Core: Running on .NET Framework Version {0}.{1}.{2}", Environment.Version.Major, Environment.Version.Minor, Environment.Version.Build);

            string s = Arguments;

            if (s.Length > 0)
            {
                Console.WriteLine("Core: Running with arguments: {0}", s);
            }

            m_ProcessorCount = Environment.ProcessorCount;

            if (m_ProcessorCount > 1)
            {
                m_MultiProcessor = true;
            }

            if (m_MultiProcessor || Is64Bit)
            {
                Console.WriteLine("Core: Optimizing for {0} {2}processor{1}", m_ProcessorCount, m_ProcessorCount == 1 ? "" : "s", Is64Bit ? "64-bit " : "");
            }

            int platform = (int)Environment.OSVersion.Platform;

            if (platform == 4 || platform == 128)                // MS 4, MONO 128
            {
                m_Unix = true;
                Console.WriteLine("Core: Unix environment detected");
            }
            else
            {
                m_ConsoleEventHandler = new ConsoleEventHandler(OnConsoleEvent);
                SetConsoleCtrlHandler(m_ConsoleEventHandler, true);
            }

            while (!ScriptCompiler.Compile(m_Debug, m_Cache))
            {
                Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found.");

                if (m_Service)
                {
                    return;
                }

                Console.WriteLine(" - Press return to exit, or R to try again.");

                if (Console.ReadKey(true).Key != ConsoleKey.R)
                {
                    return;
                }
            }

            ScriptCompiler.Invoke("Configure");

            Region.Load();
            World.Load();

            ScriptCompiler.Invoke("Initialize");

            SocketPool.Create();

            MessagePump ms = m_MessagePump = new MessagePump();

            timerThread.Start();

            for (int i = 0; i < Map.AllMaps.Count; ++i)
            {
                Map.AllMaps[i].Tiles.Force();
            }

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                DateTime now, last = DateTime.Now;

                const int   sampleInterval = 100;
                const float ticksPerSecond = (float)(TimeSpan.TicksPerSecond * sampleInterval);

                int sample = 0;

                while (m_Signal.WaitOne())
                {
                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    m_MessagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }

                    if ((++sample % sampleInterval) == 0)
                    {
                        now = DateTime.Now;
                        m_CyclesPerSecond[m_CycleIndex++ % m_CyclesPerSecond.Length] =
                            ticksPerSecond / (now.Ticks - last.Ticks);
                        last = now;
                    }
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }
        }
Exemple #35
0
        public static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            AppDomain.CurrentDomain.ProcessExit        += CurrentDomain_ProcessExit;

            foreach (string a in args)
            {
                if (Insensitive.Equals(a, "-debug"))
                {
                    Debug = true;
                }
                else if (Insensitive.Equals(a, "-service"))
                {
                    Service = true;
                }
                else if (Insensitive.Equals(a, "-profile"))
                {
                    Profiling = true;
                }
                else if (Insensitive.Equals(a, "-nocache"))
                {
                    _Cache = false;
                }
                else if (Insensitive.Equals(a, "-haltonwarning"))
                {
                    HaltOnWarning = true;
                }
                else if (Insensitive.Equals(a, "-vb"))
                {
                    VBdotNet = true;
                }
                else if (Insensitive.Equals(a, "-usehrt"))
                {
                    _UseHRT = true;
                }
            }

            try
            {
                if (Service)
                {
                    if (!Directory.Exists("Logs"))
                    {
                        Directory.CreateDirectory("Logs");
                    }

                    Console.SetOut(MultiConsoleOut = new MultiTextWriter(new FileLogger("Logs/Console.log")));
                }
                else
                {
                    Console.SetOut(MultiConsoleOut = new MultiTextWriter(Console.Out));
                }
            }
            catch
            { }

            Thread   = Thread.CurrentThread;
            Process  = Process.GetCurrentProcess();
            Assembly = Assembly.GetEntryAssembly();

            if (Thread != null)
            {
                Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();

            _TimerThread = new Thread(ttObj.TimerMain)
            {
                Name = "Timer Thread"
            };

            Version ver = Assembly.GetName().Version;

            String publishNumber = "";

            if (File.Exists("Publish.txt"))
            {
                publishNumber = File.ReadAllText("Publish.txt");
            }

            // Added to help future code support on forums, as a 'check' people can ask for to it see if they recompiled core or not
            Utility.PushColor(ConsoleColor.DarkGreen);
            Console.WriteLine(new String('-', Console.BufferWidth));
            Utility.PopColor();
            Utility.PushColor(ConsoleColor.Cyan);
            Console.WriteLine(
                "ServUO - [http://www.servuo.com] Version {0}.{1}, Build {2}.{3}",
                ver.Major,
                ver.Minor,
                ver.Build,
                ver.Revision);
            Console.WriteLine("Publish {0}", publishNumber);
            Utility.PopColor();

            string s = Arguments;

            if (s.Length > 0)
            {
                Utility.PushColor(ConsoleColor.Yellow);
                Console.WriteLine("Core: Running with arguments: {0}", s);
                Utility.PopColor();
            }

            ProcessorCount = Environment.ProcessorCount;

            if (ProcessorCount > 1)
            {
                MultiProcessor = true;
            }

            if (MultiProcessor || Is64Bit)
            {
                Utility.PushColor(ConsoleColor.Green);
                Console.WriteLine(
                    "Core: Optimizing for {0} {2}processor{1}",
                    ProcessorCount,
                    ProcessorCount == 1 ? "" : "s",
                    Is64Bit ? "64-bit " : "");
                Utility.PopColor();
            }

            int platform = (int)Environment.OSVersion.Platform;

            if (platform == 4 || platform == 128)
            {
                // MS 4, MONO 128
                Unix = true;
                Utility.PushColor(ConsoleColor.Yellow);
                Console.WriteLine("Core: Unix environment detected");
                Utility.PopColor();
            }
            else
            {
                m_ConsoleEventHandler = OnConsoleEvent;
                UnsafeNativeMethods.SetConsoleCtrlHandler(m_ConsoleEventHandler, true);
            }

            if (GCSettings.IsServerGC)
            {
                Utility.PushColor(ConsoleColor.DarkYellow);
                Console.WriteLine("Core: Server garbage collection mode enabled");
                Utility.PopColor();
            }

            if (_UseHRT)
            {
                Utility.PushColor(ConsoleColor.DarkYellow);
                Console.WriteLine(
                    "Core: Requested high resolution timing ({0})",
                    UsingHighResolutionTiming ? "Supported" : "Unsupported");
                Utility.PopColor();
            }

            Utility.PushColor(ConsoleColor.DarkYellow);
            Console.WriteLine("RandomImpl: {0} ({1})", RandomImpl.Type.Name, RandomImpl.IsHardwareRNG ? "Hardware" : "Software");
            Utility.PopColor();

            Utility.PushColor(ConsoleColor.DarkYellow);
            Console.WriteLine("Core: Loading config...");
            Config.Load();
            Utility.PopColor();

            while (!ScriptCompiler.Compile(Debug, _Cache))
            {
                Utility.PushColor(ConsoleColor.Red);
                Console.WriteLine("Scripts: One or more scripts failed to compile or no script files were found.");
                Utility.PopColor();

                if (Service)
                {
                    return;
                }

                Console.WriteLine(" - Press return to exit, or R to try again.");

                if (Console.ReadKey(true).Key != ConsoleKey.R)
                {
                    return;
                }
            }

            ScriptCompiler.Invoke("Configure");

            Region.Load();
            World.Load();

            ScriptCompiler.Invoke("Initialize");

            MessagePump messagePump = MessagePump = new MessagePump();

            _TimerThread.Start();

            foreach (Map m in Map.AllMaps)
            {
                m.Tiles.Force();
            }

            NetState.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                long now, last = TickCount;

                const int   sampleInterval = 100;
                const float ticksPerSecond = 1000.0f * sampleInterval;

                long sample = 0;

                while (!Closing)
                {
                    _Signal.WaitOne();

                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    messagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }

                    if (sample++ % sampleInterval != 0)
                    {
                        continue;
                    }

                    now = TickCount;
                    _CyclesPerSecond[_CycleIndex++ % _CyclesPerSecond.Length] = ticksPerSecond / (now - last);
                    last = now;
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }
        }
Exemple #36
0
 public static void AddTimer(Timer t)
 {
     Change(t, (int)t.Priority, true);
 }
Exemple #37
0
 public static void PriorityChange(Timer t, int newPrio)
 {
     Change(t, newPrio, false);
 }
        static void Main(string[] args)
        {
            _rand = new Random(Environment.TickCount);

            SslConfig sslConfig;
            TcpConfig tcpConfig = new TcpConfig(true, 5000, 20000);

            Console.WriteLine("Setting up secure server");
            sslConfig  = new SslConfig(true, "cert.pfx", "", SslProtocols.Tls12);
            _webServer = new SimpleWebServer(10000, tcpConfig, 16 * 1024, 3000, sslConfig);
            _webServer.Start(Constants.GAME_PORT);
            Console.WriteLine("Server started");

            _webServer.onConnect    += WebServerOnConnect;
            _webServer.onData       += WebServerOnData;
            _webServer.onDisconnect += WebServerOnDisconnect;

            Timer stateUpdateTimer = new Timer(1f / Constants.SERVER_TICKRATE * 1000);

            stateUpdateTimer.Elapsed  += StateUpdateTimerOnElapsed;
            stateUpdateTimer.AutoReset = true;
            stateUpdateTimer.Enabled   = true;

            while (!Console.KeyAvailable)
            {
                _webServer.ProcessMessageQueue();

                // GUARD, DONT DO STATE STUFF IF WE ARE WAITING
                if (_waitingOnStateTimer)
                {
                    continue;
                }
                switch (_currentState)
                {
                case GameState.Waiting:
                {
                    if (_connectedIds.Count >= 2)
                    {
                        _currentState = GameState.Begin;
                        SendStateUpdate(_currentState);
                    }

                    break;
                }

                case GameState.Begin:
                {
                    // Set timer to go to builder state
                    Timer beginTimer = new Timer(SECONDS_WAITING_IN_BEGIN * 1000);
                    beginTimer.AutoReset = false;
                    beginTimer.Start();
                    _waitingOnStateTimer = true;

                    beginTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                        _waitingOnStateTimer = false;

                        _movedObjects = new List <ushort>();
                        _currentState = GameState.Builder;
                        SendStateUpdate(_currentState);
                    };
                    break;
                }

                case GameState.Builder:
                {
                    // Set timer to go to builder state
                    Timer buildTimer = new Timer(SECONDS_WAITING_IN_BUILD * 1000);
                    buildTimer.AutoReset = false;
                    buildTimer.Start();
                    _waitingOnStateTimer = true;

                    buildTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                        _waitingOnStateTimer = false;

                        // Reset everyones guesses
                        foreach (PlayerData playerData in _playerDatas.Values)
                        {
                            playerData.guesses.Clear();
                        }
                        _currentState = GameState.Search;
                        SendStateUpdate(_currentState);
                    };
                    break;
                }

                case GameState.Search:
                {
                    // Set timer to go to scoring state
                    Timer searchTimer = new Timer(SECONDS_WAITING_IN_SEARCH * 1000);
                    searchTimer.AutoReset = false;
                    searchTimer.Start();
                    _waitingOnStateTimer = true;

                    searchTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                        _waitingOnStateTimer = false;

                        _currentState = GameState.Scoring;
                        SendStateUpdate(_currentState);
                    };
                    break;
                }

                case GameState.Scoring:
                {
                    _bitBuffer.Clear();

                    foreach (var playerData in _playerDatas.Values)
                    {
                        // GUARD, DON'T SCORE THE BUILDER THIS WAY
                        if (playerData.id == _builderId)
                        {
                            continue;
                        }

                        // Free points for objects builder couldnt move
                        // A point for a correct guess, minus point for a wrong guess
                        int correct = _movedObjects.Distinct().Intersect(playerData.guesses).Count();
                        int points  = (correct * 2) - playerData.guesses.Count + (NUMBER_OF_MOVEABLE_OBJECTS - _movedObjects.Count);
                    }
                }
                }
            }

            Console.WriteLine("Closing server");
            _webServer.Stop();
        }
Exemple #39
0
        public static void Main(string[] args)
        {
            m_Assembly = Assembly.GetEntryAssembly();

            /* print a banner */
            Version ver = m_Assembly.GetName().Version;

            Console.WriteLine("SunUO Version {0}.{1}.{2} http://www.sunuo.org/",
                              ver.Major, ver.Minor, ver.Revision);
            Console.WriteLine("  on {0}, runtime {1}",
                              Environment.OSVersion, Environment.Version);

            if ((int)Environment.OSVersion.Platform == 128)
            {
                Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)");
            }

            Console.WriteLine();

            /* prepare SunUO */
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            AppDomain.CurrentDomain.ProcessExit        += new EventHandler(CurrentDomain_ProcessExit);

            bool debug = false;

            for (int i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "-debug"))
                {
                    debug = true;
                }
                else if (Insensitive.Equals(args[i], "-service"))
                {
                    m_Service = true;
                }
                else if (Insensitive.Equals(args[i], "-profile"))
                {
                    Profiling = true;
                }
                else if (args[i] == "--logfile")
                {
                    string       logfile = args[++i];
                    StreamWriter writer  = new StreamWriter(new FileStream(logfile, FileMode.Append, FileAccess.Write));
                    writer.AutoFlush = true;
                    Console.SetOut(writer);
                    Console.SetError(writer);
                }
            }

            config = new Config(Path.Combine(BaseDirectoryInfo.CreateSubdirectory("etc").FullName, "sunuo.xml"));

            try
            {
                m_MultiConOut = new MultiTextWriter(Console.Out);
                Console.SetOut(m_MultiConOut);

                if (m_Service)
                {
                    string filename = Path.Combine(LogDirectoryInfo.FullName, "console.log");
                    m_MultiConOut.Add(new FileLogger(filename));
                }
            }
            catch
            {
            }

            m_Thread  = Thread.CurrentThread;
            m_Process = Process.GetCurrentProcess();

            if (m_Thread != null)
            {
                m_Thread.Name = "Core Thread";
            }

            if (BaseDirectory.Length > 0)
            {
                Directory.SetCurrentDirectory(BaseDirectory);
            }

            Timer.TimerThread ttObj = new Timer.TimerThread();
            timerThread      = new Thread(new ThreadStart(ttObj.TimerMain));
            timerThread.Name = "Timer Thread";

            if (!ScriptCompiler.Compile(debug))
            {
                return;
            }

            Console.Write("Verifying scripts:");
            m_ItemCount   = 0;
            m_MobileCount = 0;
            foreach (Library l in ScriptCompiler.Libraries)
            {
                int itemCount = 0, mobileCount = 0;
                Console.Write(" {0}[", l.Name);
                l.Verify(ref itemCount, ref mobileCount);
                Console.Write("{0} items, {1} mobiles]", itemCount, mobileCount);
                m_ItemCount   += itemCount;
                m_MobileCount += mobileCount;
            }
            Console.WriteLine(" - done ({0} items, {1} mobiles)", m_ItemCount, m_MobileCount);

            try {
                ScriptCompiler.Configure();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Configure exception: {0}", e.InnerException);
                return;
            }

            if (!config.Exists)
            {
                config.Save();
            }

            World.Load();

            try {
                ScriptCompiler.Initialize();
            } catch (TargetInvocationException e) {
                Console.WriteLine("Initialize exception: {0}", e.InnerException);
                return;
            }

            Region.Load();

            m_MessagePump = new MessagePump(new Listener(Listener.Port));

            timerThread.Start();

            NetState.Initialize();
            Encryption.Initialize();

            EventSink.InvokeServerStarted();

            try
            {
                while (!m_Closing)
                {
                    Thread.Sleep(1);

                    Mobile.ProcessDeltaQueue();
                    Item.ProcessDeltaQueue();

                    Timer.Slice();
                    m_MessagePump.Slice();

                    NetState.FlushAll();
                    NetState.ProcessDisposedQueue();

                    if (Slice != null)
                    {
                        Slice();
                    }
                }
            }
            catch (Exception e)
            {
                CurrentDomain_UnhandledException(null, new UnhandledExceptionEventArgs(e, true));
            }

            if (timerThread.IsAlive)
            {
                timerThread.Abort();
            }
        }
        static void Main(string[] args)
        {
            _rand = new Random(Environment.TickCount);

            SslConfig sslConfig;
            TcpConfig tcpConfig = new TcpConfig(true, 5000, 20000);
            Console.WriteLine("Setting up secure server");
            sslConfig = new SslConfig(true, "cert.pfx", "", SslProtocols.Tls12);
            _webServer = new SimpleWebServer(10000, tcpConfig, 16*1024, 3000, sslConfig);
            _webServer.Start(Constants.GAME_PORT);
            Console.WriteLine("Server started");

            _webServer.onConnect += WebServerOnConnect;
            _webServer.onData += WebServerOnData;
            _webServer.onDisconnect += WebServerOnDisconnect;

            Timer stateUpdateTimer = new Timer(1f / Constants.SERVER_TICKRATE * 1000);
            stateUpdateTimer.Elapsed += StateUpdateTimerOnElapsed;
            stateUpdateTimer.AutoReset = true;
            stateUpdateTimer.Enabled = true;

            while (!Console.KeyAvailable) {
                _webServer.ProcessMessageQueue();

                // GUARD, DONT DO STATE STUFF IF WE ARE WAITING
                if (_waitingOnStateTimer) continue;
                switch(_currentState) {
                    case GameState.Waiting:
                    {
                        if (_handshakenClientCount >= 2) {
                            _currentState = GameState.Begin;
                            SendStateUpdate(_currentState);
                        }

                        break;
                    }
                    case GameState.Begin:
                    {
                        // Set timer to go to builder state
                        beginTimer = new Timer(SECONDS_WAITING_IN_BEGIN * 1000);
                        beginTimer.AutoReset = false;
                        beginTimer.Start();
                        _waitingOnStateTimer = true;

                        beginTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                            _waitingOnStateTimer = false;

                            _movedObjects = new Dictionary<ushort, Tuple<ushort, ushort>>();
                            _currentState = GameState.Builder;
                            SendStateUpdate(_currentState);
                        };
                        break;
                    }
                    case GameState.Builder:
                    {
                        // Set timer to go to builder state
                        buildTimer = new Timer(SECONDS_WAITING_IN_BUILD * 1000);
                        buildTimer.AutoReset = false;
                        buildTimer.Start();
                        _waitingOnStateTimer = true;

                        buildTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                            _waitingOnStateTimer = false;

                            // Reset everyones guesses
                            foreach (PlayerData playerData in _playerDatas.Values) {
                                playerData.guesses.Clear();
                            }
                            _currentState = GameState.Search;
                            SendStateUpdate(_currentState);
                        };
                        break;
                    }
                    case GameState.Search:
                    {
                        // Set timer to go to scoring state
                        searchTimer = new Timer(SECONDS_WAITING_IN_SEARCH * 1000);
                        searchTimer.AutoReset = false;
                        searchTimer.Start();
                        _waitingOnStateTimer = true;

                        searchTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                            _waitingOnStateTimer = false;

                            _currentState = GameState.Scoring;
                            SendStateUpdate(_currentState);
                        };
                        break;
                    }
                    case GameState.Scoring:
                    {
                        // Set timer to wait for points to come in from clients
                        scoringTimer = new Timer(SECONDS_WAITING_IN_SCORING * 1000);
                        scoringTimer.AutoReset = false;
                        scoringTimer.Start();
                        _waitingOnStateTimer = true;

                        scoringTimer.Elapsed += delegate(Object source, ElapsedEventArgs e) {
                            _waitingOnStateTimer = false;

                            // Tell everyone everyones scores
                            _bitBuffer.Clear();
                            _bitBuffer.AddByte(7);
                            _bitBuffer.AddUShort((ushort)_playerDatas.Count);

                            foreach (PlayerData data in _playerDatas.Values) {
                                _bitBuffer.AddUShort(data.id);
                                _bitBuffer.AddShort(data.points);

                                Console.WriteLine($"Points: {data.id} {data.points}");
                            }

                            _bitBuffer.ToArray(_buffer);
                            _webServer.SendAll(_connectedIds, new ArraySegment<byte>(_buffer, 0, 3 + 4 * _playerDatas.Count));

                            if (_handshakenClientCount >= 2) {
                                _currentState = GameState.Begin;
                            }
                            else {
                                _currentState = GameState.Waiting;
                            }
                            SendStateUpdate(_currentState);
                        };

                        break;
                    }
                }
            }

            Console.WriteLine("Closing server");
            _webServer.Stop();
        }
Exemple #41
0
 private TimerChangeEntry(Timer t, int newIndex, bool isAdd)
 {
     m_Timer    = t;
     m_NewIndex = newIndex;
     m_IsAdd    = isAdd;
 }
Exemple #42
0
        public static void Sacrifice(Mobile from, object targeted)
        {
            if (!from.CheckAlive())
            {
                return;
            }

            if (!(from is PlayerMobile pm))
            {
                return;
            }

            if (!(targeted is Mobile targ))
            {
                return;
            }

            if (!ValidateCreature(targ))
            {
                from.SendLocalizedMessage(1052014); // You cannot sacrifice your fame for that creature.
            }
            else if (targ.Hits * 100 / Math.Max(targ.HitsMax, 1) < 90)
            {
                from.SendLocalizedMessage(1052013); // You cannot sacrifice for this monster because it is too damaged.
            }
            else if (from.Hidden)
            {
                from.SendLocalizedMessage(1052015); // You cannot do that while hidden.
            }
            else if (VirtueHelper.IsHighestPath(from, VirtueName.Sacrifice))
            {
                from.SendLocalizedMessage(1052068); // You have already attained the highest path in this virtue.
            }
            else if (from.Fame < 2500)
            {
                from.SendLocalizedMessage(1052017); // You do not have enough fame to sacrifice.
            }
            else if (DateTime.UtcNow < pm.LastSacrificeGain + GainDelay)
            {
                from.SendLocalizedMessage(1052016); // You must wait approximately one day before sacrificing again.
            }
            else
            {
                int toGain;

                if (from.Fame < 5000)
                {
                    toGain = 500;
                }
                else if (from.Fame < 10000)
                {
                    toGain = 1000;
                }
                else
                {
                    toGain = 2000;
                }

                from.Fame = 0;

                // I have seen the error of my ways!
                targ.PublicOverheadMessage(MessageType.Regular, 0x3B2, 1052009);

                from.SendLocalizedMessage(1052010); // You have set the creature free.

                Timer.DelayCall(TimeSpan.FromSeconds(1.0), targ.Delete);

                pm.LastSacrificeGain = DateTime.UtcNow;

                var gainedPath = false;

                if (VirtueHelper.Award(from, VirtueName.Sacrifice, toGain, ref gainedPath))
                {
                    if (gainedPath)
                    {
                        from.SendLocalizedMessage(1052008); // You have gained a path in Sacrifice!

                        if (pm.AvailableResurrects < 3)
                        {
                            ++pm.AvailableResurrects;
                        }
                    }
                    else
                    {
                        from.SendLocalizedMessage(1054160); // You have gained in sacrifice.
                    }
                }

                from.SendLocalizedMessage(1052016); // You must wait approximately one day before sacrificing again.
            }
        }