/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Aug-08-2011 09:29:08pm
Filepath: scripts\Mobiles\custom mobiles - to sort\boses\paracelsus.cs
Lines of code: 192

Description: 

***********************************************************/


using System;
using Server;
using Server.Items;
using Server.Spells;
using Server.Spells.Seventh;
using Server.Spells.Fifth;
using Server.Engines.CannedEvil;

namespace Server.Mobiles
{

	public class Paracelsus : BaseChampion
	{
			private Timer m_Timer;
	
		public override WeaponAbility GetWeaponAbility()
		{
			switch ( Utility.Random( 2 ) )
			{
				default:	
				case 0: return WeaponAbility.DoubleStrike;
				case 1: return WeaponAbility.Disarm;				
			}
		}

	
		public override ChampionSkullType SkullType{ get{ return ChampionSkullType.Elements; } }

		[Constructable]
		public Paracelsus() : base( AIType.AI_Super )
		{
			Name = "Paracelsus";
			Title = "The Lord of the Elements";
			Body = 199;
			
			switch(Utility.Random(7))
			{			
			case 0:Hue = 1150;break;
			case 1:Hue = 2118;break;
			case 2:Hue = 1266;break;
			case 3:Hue = 1161;break;
			case 4:Hue = 24;break;
			case 5:Hue = 1420;break;
			case 6:Hue = 1109;break;
			}

			SetStr( 1700, 2100 );
			SetDex( 172, 250 );
			SetInt( 1000, 2000 );

			//SetHits( 6000 );
			//SetStam( 900, 1500 );

			SetDamage( 12, 15 );
			SetDamageType( ResistanceType.Physical, 0 );
			SetDamageType( ResistanceType.Fire, 25 );
			SetDamageType( ResistanceType.Cold, 25 );
			SetDamageType( ResistanceType.Poison, 25 );
			SetDamageType( ResistanceType.Energy, 25 );
			

			SetResistance( ResistanceType.Physical, 5, 20 );
			SetResistance( ResistanceType.Fire, 60, 80 );
			SetResistance( ResistanceType.Cold, 60, 80 );
			SetResistance( ResistanceType.Poison, 60, 80 );
			SetResistance( ResistanceType.Energy, 60, 80 );

			SetSkill( SkillName.MagicResist, 100.0 );
			SetSkill( SkillName.Tactics, 100.0 );
			SetSkill( SkillName.Wrestling, 120.0 );
			SetSkill( SkillName.Magery, 120.0 );
			SetSkill( SkillName.EvalInt, 120.0 );

			Fame = 28900;
			Karma = -24000;

			VirtualArmor = 70;


				
		
		SwordOfParacelsus sword = new SwordOfParacelsus();
		sword.Movable = false;		
		AddItem( sword );
		
		
			m_Timer = new TeleportTimer( this );
			m_Timer.Start();
			
			if(0.5>Utility.RandomDouble())	PackItem(new RandomTalisman());
			
		}//ends main mobile function
		
		
		public override int GetAngerSound()
		{
			return 358;
		}

		public override int GetDeathSound()
		{
			return 699;
		}

		public override int GetHurtSound()
		{
			return 697;
		}

		public override int GetIdleSound()
		{
			return 357;
		}
		
		
		//harrower copied code		
		private class TeleportTimer : Timer
		{
			private Mobile m_Owner;

			private static int[] m_Offsets = new int[]
			{
				-1, -1,
				-1,  0,
				-1,  1,
				0, -1,
				0,  1,
				1, -1,
				1,  0,
				1,  1
			};

			public TeleportTimer( Mobile owner ) : base( TimeSpan.FromSeconds( 1 ), TimeSpan.FromSeconds( 3.0 ) )
			{
				m_Owner = owner;
			}

			protected override void OnTick()
			{
				if ( m_Owner.Deleted )
				{
					Stop();
					return;
				}

				Map map = m_Owner.Map;

				if ( map == null )
					return;

				if ( 0.25 < Utility.RandomDouble() )
					return;

				Mobile toTeleport = null;

				foreach ( Mobile m in m_Owner.GetMobilesInRange( 16 ) )
				{
					if ( m != m_Owner && m.Player && m_Owner.CanBeHarmful( m ) && m_Owner.CanSee( m ) )
					{
						toTeleport = m;
						break;
					}
				}

				if ( toTeleport != null )
				{
					int offset = Utility.Random( 8 ) * 2;

					Point3D to = m_Owner.Location;

					for ( int i = 0; i < m_Offsets.Length; i += 2 )
					{
						int x = m_Owner.X + m_Offsets[(offset + i) % m_Offsets.Length];
						int y = m_Owner.Y + m_Offsets[(offset + i + 1) % m_Offsets.Length];

						if ( map.CanSpawnMobile( x, y, m_Owner.Z ) )
						{
							to = new Point3D( x, y, m_Owner.Z );
							break;
						}
						else
						{
							int z = map.GetAverageZ( x, y );

							if ( map.CanSpawnMobile( x, y, z ) )
							{
								to = new Point3D( x, y, z );
								break;
							}
						}
					}

					Mobile m = toTeleport;

					Point3D from = m.Location;

					m.Location = to;

					Server.Spells.SpellHelper.Turn( m_Owner, toTeleport );
					Server.Spells.SpellHelper.Turn( toTeleport, m_Owner );

					m.ProcessDelta();

					Effects.SendLocationParticles( EffectItem.Create( from, m.Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 2023 );
					Effects.SendLocationParticles( EffectItem.Create(   to, m.Map, EffectItem.DefaultDuration ), 0x3728, 10, 10, 5023 );

					m.PlaySound( 896 );

					m_Owner.Combatant = toTeleport;
				}
			}
		}		
		//end harrower copied code		
		

		
		
		
		

		public override void GenerateLoot()
		{
			AddLoot( LootPack.UltraRich, 5 );
		
			if(0.05>Utility.RandomDouble())
			{
				switch(Utility.Random(3))
				{
				case 0:PackItem(new ParacelsusPeril());break;
				case 1:PackItem(new SashOfTheElementalKinship());break;			
				case 2:PackItem(new braceofparacelsus());break;			
				}
			}	
		}

		public override bool AutoDispel{ get{ return true; } }
		public override double AutoDispelChance{ get{ return 0.2; } }
		public override bool Unprovokable{ get{ return Core.SE; } }
		public override bool Uncalmable{ get{ return Core.SE; } }

		public override bool ShowFameTitle{ get{ return false; } }
		public override bool ClickTitle{ get{ return false; } }

	
	
	

		public Paracelsus( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}
		
		

	}
}