context: using System;
  using System.Collections;
  using System.Collections.Generic;
  using Server;
  using Server.Items;
  using Server.Mobiles;
  using Server.Targeting;
  using Server.Spells;
  using Server.Spells.Fourth;
  
  namespace Server.Mobiles
  {
  	[CorpseName( "a dragon corpse" )]
  	public class StygianDragon : BaseCreature
  	{
  	        public override bool AlwaysMurderer { get { return true; } }
  
  		[Constructable]
  		public StygianDragon () : base( AIType.AI_Mage, FightMode.Closest, 10, 1, 0.3, 0.5 )
  		{
  			Name = "a stygian dragon";
  			Body = 826;
  			BaseSoundID = 362;
  
  			SetStr( 494, 595 );
  			SetDex( 239, 345 );
  			SetInt( 108, 230 );
  
  			SetHits( 150000, 200000 );
  			SetStam( 468, 486 );
  			SetMana( 108, 236 );
  
  			SetDamage( 33, 55 );
  
  			SetDamageType( ResistanceType.Physical, 25 );
  			SetDamageType( ResistanceType.Fire, 35 );
  			SetDamageType( ResistanceType.Energy, 25 );
  
  			SetResistance( ResistanceType.Physical, 84, 90 );
  			SetResistance( ResistanceType.Fire, 81, 88 );
  			SetResistance( ResistanceType.Cold, 66, 69 );
  			SetResistance( ResistanceType.Poison, 89, 88 );
  			SetResistance( ResistanceType.Energy, 80, 84 );
  
  
  			SetSkill( SkillName.Anatomy, 114.3, 123.8 );
  			SetSkill( SkillName.MagicResist, 122.2, 126.8 );
  			SetSkill( SkillName.Tactics, 113.9, 116.1 );
  			SetSkill( SkillName.Wrestling, 113.4, 117.2 );
  
  			Fame = 55000;
  			Karma = -55000;
  
  			VirtualArmor = 60;
  
  			Tamable = false;
  		}
  
  		public override void GenerateLoot()
  		{
  			AddLoot( LootPack.SuperBoss, 4 );
  			AddLoot( LootPack.FilthyRich, 2 );
  			AddLoot( LootPack.Meager );
  		}
  
  
          private void RandoTarget(Mobile from)
          {
              double SwitchRate = .05;
              int PullRange = 10;
              foreach (Mobile m_target in GetMobilesInRange(PullRange))
                  if ((m_target != from) && (SpellHelper.ValidIndirectTarget(from, (Mobile)m_target) && from.CanBeHarmful((Mobile)m_target, false)))
                  {
                      if (Utility.RandomDouble() < SwitchRate)
                          from.Combatant = m_target;
                  }
          }
  
          public override void OnThink()
          {
              base.OnThink();
              RandoTarget(this);
          }
  
          public override bool Unprovokable { get { return true; } }
  	    public override bool BardImmune { get { return true; } }
  	    //public override bool GivesMinorArtifact { get { return true; } }
  		public override bool HasBreath{ get{ return true; } } // fire breath enabled
  		public override bool AutoDispel{ get{ return !Controlled; } }
  		public override int TreasureMapLevel{ get{ return 5; } }
  		//public override int DragonBlood{ get{ return 48; } }
  		public override int Meat{ get{ return 19; } }
  		public override int Hides{ get{ return 44; } }
  		public override HideType HideType{ get{ return HideType.Barbed; } }
  		public override int Scales{ get{ return 7; } }
  		public override ScaleType ScaleType{ get{ return ( Body == 12 ? ScaleType.Yellow : ScaleType.Red ); } }
  		public override FoodType FavoriteFood{ get{ return FoodType.Meat; } }
  		public override bool CanAngerOnTame { get { return true; } }
  
  		public override WeaponAbility GetWeaponAbility()
  		{
  			if (50.0 >= Utility.RandomDouble())
  			return WeaponAbility.Bladeweave;
  			else
  			return WeaponAbility.TalonStrike;
  
  		}
  	/*
          public override void OnGaveMeleeAttack(Mobile defender)
          {
              base.OnGaveMeleeAttack(defender);
              if (0.2 >= Utility.RandomDouble())
                  CrimsonMeteor(Mobile from, int damage);
          }
  
  		public static void CrimsonMeteor( Mobile from, int damage )
  		{
  			if ( !CanUse( from ) )
  				return;
  
  			new CrimsonMeteorTimer( from, damage ).Start();
  		}
  
  		public class CrimsonMeteorTimer : Timer
  		{
  			private Mobile m_From;
  			private int m_Damage;
  			private int m_Count;
  			private int m_MaxCount;
  			private Point3D m_LastTarget;
  			private Point3D m_ShowerLocation;
  
  			public CrimsonMeteorTimer( Mobile from, int damage ) : base( TimeSpan.FromMilliseconds( 500.0 ), TimeSpan.FromMilliseconds( 500.0 ) )
  			{
  				m_From = from;
  				m_Damage = damage;
  				m_Count = 0;
  				m_MaxCount = 30;
  				m_LastTarget = new Point3D( 0, 0, 0 );
  				m_ShowerLocation = new Point3D( from.Location );
  			}
  
  			protected override void OnTick()
  			{
  				if ( m_From == null )
  				{
  					Stop();
  					return;
  				}
  
  				new FireField( m_From, 30, m_Damage, m_Damage, Utility.RandomBool(), m_LastTarget, m_From.Map );
  
  				if ( m_Count >= m_MaxCount )
  				{
  					Stop();
  					return;
  				}
  
  				Point3D point = new Point3D();
  				int tries = 0;
  
  				while ( tries < 5 )
  				{
  					point.X = m_ShowerLocation.X += Utility.RandomMinMax( -5, 5 );
  					point.Y = m_ShowerLocation.Y += Utility.RandomMinMax( -5, 5 );
  
  					if ( m_From.CanSee( point ) )
  						break;
  
  					tries++;
  				}
  
  				Effects.SendMovingParticles( 
  					new Entity( Serial.Zero, new Point3D( point.X, point.Y, point.Z + 30 ), m_From.Map ), 
  					new Entity( Serial.Zero, point, m_From.Map ), 
  					0x36D4, 5, 0, false, false, 0, 0, 9502, 1, 0, (EffectLayer)255, 0x100 );
  
  				m_LastTarget = point;
  				m_Count++;
  			}
  		}*/
  
  		public StygianDragon( Serial serial ) : base( serial )
  		{
  		}
  
  		public override void Serialize( GenericWriter writer )
  		{
  			base.Serialize( writer );
  			writer.Write( (int) 1 );
  		}
  
  		public override void Deserialize( GenericReader reader )
  		{
  			base.Deserialize( reader );
  			int version = reader.ReadInt();
  
  		}
  	}
  		/*
  		#region FireField
  		public class FireField : Item
  		{
  			private Mobile m_Owner;
  			private int m_MinDamage;
  			private int m_MaxDamage;
  			private DateTime m_Destroy;
  			private Point3D m_MoveToPoint;
  			private Map m_MoveToMap;
  			private Timer m_Timer;
  			private List<Mobile> m_List;
  
  			[Constructable]
  			public FireField( int duration, int min, int max, bool south, Point3D point, Map map ) : this( null, duration, min, max, south, point, map )
  			{
  			}
  
  			[Constructable]
  			public FireField( Mobile owner, int duration, int min, int max, bool south, Point3D point, Map map ) : base( GetItemID( south ) )
  			{
  				Movable = false;
  
  				m_Owner = owner;
  				m_MinDamage = min;
  				m_MaxDamage = max;
  				m_Destroy = DateTime.Now + TimeSpan.FromSeconds( (double)duration + 1.5 );
  				m_MoveToPoint = point;
  				m_MoveToMap = map;
  				m_List = new List<Mobile>();
  				m_Timer = Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1 ), new TimerCallback( OnTick ) );
  				Timer.DelayCall( TimeSpan.Zero, TimeSpan.FromSeconds( 1.5 ), new TimerCallback( Move ) );
  			}
  
  			private static int GetItemID( bool south )
  			{
  				if ( south )
  					return 0x398C;
  				else
  					return 0x3996;
  			}
  			
  			public override void OnAfterDelete()
  			{
  				if ( m_Timer != null )
  					m_Timer.Stop();
  			}
  
  			private void Move()
  			{
  				if ( !Visible )
  					ItemID = 0x36FE;
  
  				MoveToWorld( m_MoveToPoint, m_MoveToMap );
  			}
  
  			private void OnTick()
  			{
  				if ( DateTime.Now > m_Destroy )
  					Delete();
  				else if ( m_MinDamage != 0 )
  				{
  					foreach( Mobile m in GetMobilesInRange( 0 ) )
  					{
  						if ( m == null )
  							continue;
  						else if ( m_Owner != null )
  						{
  							if ( Ability.CanTarget( m_Owner, m, true, true, false ) )
  								m_List.Add( m );
  						}
  						else
  							m_List.Add( m );
  					}
  
  					for ( int i = 0; i < m_List.Count; i++ )
  					{
  						if ( m_List[i] != null )
  							DealDamage( m_List[i] );
  					}
  
  					m_List.Clear();
  
gt: 					m_List = new List<Mobile>();