/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\mobiles\ml\Satyr.cs
Lines of code: 93
***********************************************************/


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

////Coded by Bartok for Age of Valor shard////

namespace Server.Mobiles
{
	[CorpseName( "a satyr corpse" )]
	public class Satyr : BaseCreature
	{

		[Constructable]
		public Satyr() : base( AIType.AI_Super, FightMode.Evil, 10, 1, 0.2, 0.4 )
		{
			Name = "a satyr";
			Body = 271;

			SetStr( 177, 195 );
			SetDex( 251, 269 );
			SetInt( 153, 170 );

			SetHits( 353, 399 );

			SetDamage( 18, 22 ); 
			
			SetDamageType( ResistanceType.Physical, 100 );

			SetResistance( ResistanceType.Physical, 55, 60 );
			SetResistance( ResistanceType.Fire, 26, 35 );
			SetResistance( ResistanceType.Cold, 30, 40 );
			SetResistance( ResistanceType.Poison, 30, 39 );
			SetResistance( ResistanceType.Energy, 30, 39 );

			SetSkill( SkillName.MagicResist, 56.2, 64.3 );
			SetSkill( SkillName.Tactics, 80.1, 99.3 );
			SetSkill( SkillName.Wrestling, 83.9, 98.8 );
			
			SetSkill( SkillName.Musicianship, 100, 120 );
			SetSkill( SkillName.Peacemaking, 100, 120 );
			SetSkill( SkillName.Discordance, 100, 120 );
			SetSkill( SkillName.Provocation, 100, 120 );			

			Fame = 8500;
			Karma = 4500;
			
			PackItem( new BeverageBottle( BeverageType.Wine ));
			PackItem( new CheeseWedge() );
			PackItem( new SatyrPipe() );	
			
		}

		public override void GenerateLoot()
		{
			AddLoot( LootPack.FilthyRich );
			AddLoot( LootPack.Average );
		}
		
		
		public override bool OnBeforeDeath()
 		{
			PackItem( new BambooFlute() );	
		
			return base.OnBeforeDeath();
	 	}
		
		
		

		public override bool CanRummageCorpses{ get{ return true; } }
		public override Poison PoisonImmune{ get{ return Poison.Greater; } }
		public override int TreasureMapLevel{ get{ return 4; } }
		
		public override bool BardImmune{ get{ return true; } }
		public override bool Unprovokable{ get{ return true; } }
		public override bool Uncalmable{ get{ return true; } }
		public override bool IsMLCreature { get { return true;} }
		 
		public override int GetAngerSound()
		{
			return 1416;
		}

		public override int GetIdleSound()
		{
			return 1415;
		}

		public override int GetAttackSound()
		{
			return 1414;
		}

		public override int GetHurtSound()
		{
			return 1417; 
		}

		public override int GetDeathSound()
		{
			return 1413; 
		}
		
		public override int SuperAI_Intensity{ get{ return 100; } }
			
		/*	
			
		public override void OnThink()
		{
			if (this.Combatant != null && 0.02 > Utility.RandomDouble() && 0.4 > Utility.RandomDouble()) //Peace Attack
			{
			
				//Peace Attack: Satyr Peaces (Paralyzes) target for 5 seconds. Although it does not stack, second it expires
				//the satyr can choose to peace you again. 
				
				Mobile attacker = this.Combatant; 
				if ( !IsBeingPeaced( attacker ) && this.InLOS( this.Combatant ) )
				{
					attacker.SendMessage("The satyr peaces you");
					attacker.FixedEffect( 0x375A, 10, 15 );
					this.PlaySound( 1419 ); 
					BeginPeacemade( attacker, this );
				}
			}
			else if (this.Combatant != null && 0.03 > Utility.RandomDouble() && 0.4 > Utility.RandomDouble() && this.InLOS( this.Combatant )) //Discord Attack
			{
				//Discordance Attack: Satyr discords the target, reducing their resistances by 28% for 1 minute. Also reduces skills

				Mobile attacker = this.Combatant; 
				ExpireTimer timer = (ExpireTimer)DiscordanceTable[attacker];

				if ( timer != null )
				{
					timer.DoExpire();
					this.PlaySound( 1464 );
					attacker.SendMessage( "The satyr continues to discord you" );
				}
				else if ( timer == null && this.InLOS( attacker ))
				{
					this.PlaySound( 1464 );
					attacker.SendMessage( "The satyr discords you" );
				}

				List<ResistanceMod> mods = new List<ResistanceMod>();
				
				double penalty = 0;
				
				if ( attacker.PhysicalResistance > 0 ) //Discordance checks per resist. 28% resistance reduction
				{
					penalty = -(attacker.PhysicalResistance - attacker.PhysicalResistance * 0.28); 
					mods.Add( new ResistanceMod( ResistanceType.Physical,(int)penalty));
				}

				if ( attacker.FireResistance > 0 )
				{
					penalty = -(attacker.FireResistance - attacker.FireResistance * 0.28);
					mods.Add( new ResistanceMod( ResistanceType.Fire,(int)penalty));
				}

				if ( attacker.ColdResistance > 0 )
				{
					penalty = -(attacker.ColdResistance - attacker.ColdResistance * 0.28);
					mods.Add( new ResistanceMod( ResistanceType.Cold,(int)penalty));
				}

				if ( attacker.PoisonResistance > 0 )
				{
					penalty = -(attacker.PoisonResistance - attacker.PoisonResistance * 0.28);
					mods.Add( new ResistanceMod( ResistanceType.Poison,(int)penalty));
				}

				if ( attacker.EnergyResistance > 0 )
				{
					penalty = -(attacker.EnergyResistance - attacker.EnergyResistance * 0.28);
					mods.Add( new ResistanceMod( ResistanceType.Energy,(int)penalty));
				}
				
				for ( int i = 0; i < mods.Count; ++i )
					attacker.AddResistanceMod( mods[i] );

				attacker.FixedEffect( 0x37B9, 10, 5 );

				timer = new ExpireTimer( attacker, mods, TimeSpan.FromMinutes( 1.0 ) ); //Discord lasts 1 minute
				timer.Start();
				DiscordanceTable[attacker] = timer;
				ApplySkillLoss( attacker );
			}
			else if (this.Combatant != null && 0.04 > Utility.RandomDouble() && 0.4 > Utility.RandomDouble() && this.InLOS( this.Combatant )) //Provocation Attack
			{
				//Provocation Attack: Satyr provokes other mobiles onto the target (Except summons and tames as well as other satyrs)
			
				Mobile attacker = this.Combatant; 
				ProvokeTarget(attacker);
			}
		}
		
		private void ProvokeTarget( Mobile target )
		{
			ArrayList mob = new ArrayList();
		
			foreach ( Mobile m in this.GetMobilesInRange( 12 ) )
			{
				if ( m == this || !CanBeHarmful( m ) || !this.InLOS( m ) || m.Player || m is Satyr || m.Blessed)
					continue;
				if ( m is BaseCreature && (!((BaseCreature)m).Controlled || !((BaseCreature)m).Summoned || ((BaseCreature)m).Team != this.Team))
					mob.Add( m );
			}
			
			
				if(mob.Count<=0)return;
			
				Mobile n = mob[Utility.Random(mob.Count)] as Mobile;
				
				if (n != null)
				{				
				this.PlaySound( 1463 );
				target.SendMessage( "The satyr provokes a creature onto you" );
				n.Combatant = target;
				}
		}
				
		private static Hashtable PeacemadeTable = new Hashtable();

		public static bool IsBeingPeaced( Mobile m )
		{
			return PeacemadeTable.Contains( m );
		}

		public static void BeginPeacemade( Mobile m, Mobile from )
		{
			m.Frozen = true;
			Timer t = (Timer)PeacemadeTable[m];

			if ( t != null )
				t.Stop();

			t = new InternalTimer( from, m );
			PeacemadeTable[m] = t;

			t.Start();
		}

		public static void LifeCheck( Mobile m, Mobile from )
		{
			if ( !m.Alive )
			{
				EndPeacemade( m );
			}
		}

		public static void EndPeacemade( Mobile m )
		{
			Timer t = (Timer)PeacemadeTable[m];

			if ( t != null )
				t.Stop();

			PeacemadeTable.Remove( m );

			m.Frozen = false;
			m.SendMessage("You are no longer peaced"); 
		}
		
		private class InternalTimer : Timer
		{
			private Mobile m_From;
			private Mobile m_Mobile;
			private int m_Count;

			public InternalTimer( Mobile from, Mobile m ) : base( TimeSpan.FromSeconds( 1.0 ), TimeSpan.FromSeconds( 1.0 ) )
			{
				m_From = from;
				m_Mobile = m;
				Priority = TimerPriority.TwoFiftyMS;
			}

			protected override void OnTick()
			{
				LifeCheck( m_Mobile, m_From );

				if ( ++m_Count == 5) //5 ticks at 1.0 second per (5 seconds)
					EndPeacemade( m_Mobile );
			}
		}

		private static Hashtable DiscordanceTable = new Hashtable();

		private class ExpireTimer : Timer
		{
			private Mobile m_Mobile;
			private List<ResistanceMod> m_Mods;

			public ExpireTimer( Mobile m, List<ResistanceMod> mods, TimeSpan delay ) : base( delay )
			{
				m_Mobile = m;
				m_Mods = mods;
				Priority = TimerPriority.TwoFiftyMS;
			}

			public void DoExpire()
			{
				for ( int i = 0; i < m_Mods.Count; ++i )
					m_Mobile.RemoveResistanceMod( m_Mods[i] );

				Stop();
				DiscordanceTable.Remove( m_Mobile );
			}

			protected override void OnTick()
			{
				m_Mobile.SendMessage( "You are no longer discorded" );
				DoExpire();
			}
		}
		
		#region Skill Loss
		public const double SkillLossFactor = 1.0 / 3;
		public static readonly TimeSpan SkillLossPeriod = TimeSpan.FromMinutes( 1.0 );

		private static Hashtable m_SkillLoss = new Hashtable();

		private class SkillLossContext
		{
			public Timer m_Timer;
			public ArrayList m_Mods;
		}

		public static void ApplySkillLoss( Mobile mob )
		{
			SkillLossContext context = (SkillLossContext)m_SkillLoss[mob];

			if ( context != null )
				return;

			context = new SkillLossContext();
			m_SkillLoss[mob] = context;

			ArrayList mods = context.m_Mods = new ArrayList();

			for ( int i = 0; i < mob.Skills.Length; ++i )
			{
				Skill sk = mob.Skills[i];
				double baseValue = sk.Base;

				if ( baseValue > 0 )
				{
					SkillMod mod = new DefaultSkillMod( sk.SkillName, true, -(baseValue * SkillLossFactor) );

					mods.Add( mod );
					mob.AddSkillMod( mod );
				}
			}

			context.m_Timer = Timer.DelayCall( SkillLossPeriod, new TimerStateCallback( ClearSkillLoss_Callback ), mob );
		}

		private static void ClearSkillLoss_Callback( object state )
		{
			ClearSkillLoss( (Mobile) state );
		}

		public static void ClearSkillLoss( Mobile mob )
		{
			SkillLossContext context = (SkillLossContext)m_SkillLoss[mob];

			if ( context == null )
				return;

			m_SkillLoss.Remove( mob );

			ArrayList mods = context.m_Mods;

			for ( int i = 0; i < mods.Count; ++i )
				mob.RemoveSkillMod( (SkillMod) mods[i] );

			context.m_Timer.Stop();
		}
		#endregion
		
		
		*/

		public Satyr( 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();
		}

	}
}
ÿ