/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on May-15-2012 07:15:47pm
Filepath: scripts\events and scenarios\Long Live the King 2012\Britain Undead Invasions\Evil Side\InvadingDeathWalker.cs
Lines of code: 139

Description: 

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


using System;
using System.Collections;
using Server;
using Server.Items;
using System.Collections.Generic;

namespace Server.Mobiles
{
	[CorpseName( "a death walker corpse" )]
	public class InvasionDeathWalker : BoneDemon
	{
		private DateTime lastability;
		
		public static void GiveReward(Mobile boss)
		{
			ArrayList toGive = new ArrayList();
			List<DamageStore> rights = BaseCreature.GetLootingRights( boss.DamageEntries, boss.HitsMax );

			for ( int i = rights.Count - 1; i >= 0; --i )
			{
				DamageStore ds = rights[i];
				if ( ds.m_HasRight )	toGive.Add( ds.m_Mobile );
			}
			if ( rights.Count == 0 )return;	
			
			for(int i=0;i<rights.Count;i++)
			{
				Mobile m = rights[i].m_Mobile;			
				PlayerMobile pm = m as PlayerMobile;	
	
				Item gift = new UnderworldBone();	
						
				m.SendMessage(200,"You pull a strange bone from the corpse");
				m.GiveItem(gift);
			}
		}	

		public override void OnDeath( Container c )
		{
			if (0.07 >= Utility.RandomDouble())
				GiveReward(this);	
				
			base.OnDeath( c );
		}
	
		[Constructable]
		public InvasionDeathWalker() : base()
		{
			Name = "an invading death walker";
			Body = 308;
			BaseSoundID = 0x48D;

			SetStr( 1000 );
			SetDex( 151, 175 );
			SetInt( 171, 220 );

			SetHits( 1500 );

			SetDamage( 34, 36 );

			SetDamageType( ResistanceType.Physical, 50 );
			SetDamageType( ResistanceType.Cold, 50 );

			SetResistance( ResistanceType.Physical, 75 );
			SetResistance( ResistanceType.Fire, 60 );
			SetResistance( ResistanceType.Cold, 90 );
			SetResistance( ResistanceType.Poison, 100 );
			SetResistance( ResistanceType.Energy, 60 );

			SetSkill( SkillName.DetectHidden, 80.0 );
			SetSkill( SkillName.EvalInt, 77.6, 87.5 );
			SetSkill( SkillName.Magery, 77.6, 87.5 );
			SetSkill( SkillName.Meditation, 100.0 );
			SetSkill( SkillName.MagicResist, 50.1, 75.0 );
			SetSkill( SkillName.Tactics, 100.0 );
			SetSkill( SkillName.Wrestling, 100.0 );
			
			SetSkill( SkillName.Spellweaving, 120, 150.0 );

			Fame = 20000;
			Karma = -20000;
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.SuperBoss, 2 );
			AddLoot( LootPack.FilthyRich, 9 );
		}

		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }
		public override int TreasureMapLevel{ get{ return 1; } }
		public override int SuperAI_DelayMax{ get{ return 0; } }
		public override int SuperAI_Intensity{ get{ return 150; } }		
		public override double TargetTamerChance { get { return 0.05; }}	
		public override bool CantbeSupreme { get { return true;} }
		public override bool CantbeParagon { get { return true;} }	
		public override int ArcaneLevel{ get{ return 4; } }		
		public override bool AlwaysMurderer{ get{ return true; } }
		public override bool NoFlee { get { return true; } }
		
		public override void OnThink()
		{
			if (0.2 > Utility.RandomDouble() && lastability < DateTime.Now) {
				this.Say("*Slams the ground with great force!*");
				GroundStomp();
			}

			base.OnThink();		
		}
		
		public static readonly TimeSpan DefenderRemountDelay = TimeSpan.FromSeconds( 10.0 );
		
		public void GroundStomp()
		{
			ArrayList ilist = new ArrayList();
			ArrayList list = new ArrayList();

			foreach ( Mobile m in this.GetMobilesInRange( 12 ) )
			{
				if ( m == this || !CanBeHarmful( m ) || !ShouldHarm( m ))
					continue;

				if ( m is BaseCreature && (((BaseCreature)m).Controlled || ((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team) )
					list.Add( m );
				else if ( m.Player )
					list.Add( m );
			}

			foreach ( Mobile m in list )
			{
				DoHarmful( m );
				
				if (m.Mounted)	
				{					
					m.Dismount();
					
					m.SendLocalizedMessage( 1060083 ); // You fall off of your mount and take damage!

					m.PlaySound( 0x59C );
					m.FixedParticles( 0x3728, 10, 15, 9955, EffectLayer.Waist );

					AOS.Damage( m, this, 30, 100, 0, 0, 0, 0 );
					BaseMount.SetMountPrevention( m, BlockMountType.Dazed, DefenderRemountDelay );
				}
				else {
					m.PlaySound( 0x59C );
					m.FixedParticles( 0x3728, 10, 15, 9955, EffectLayer.Waist );

					AOS.Damage( m, this, 30, 100, 0, 0, 0, 0 );
				}
			}
			lastability=DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax( 80, 120 ));
		}

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

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 );
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
		}
	}
}